libMesh
Loading...
Searching...
No Matches
libmesh.h
Go to the documentation of this file.
1// The libMesh Finite Element Library.
2// Copyright (C) 2002-2026 Benjamin S. Kirk, John W. Peterson, Roy H. Stogner
3
4// This library is free software; you can redistribute it and/or
5// modify it under the terms of the GNU Lesser General Public
6// License as published by the Free Software Foundation; either
7// version 2.1 of the License, or (at your option) any later version.
8
9// This library is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12// Lesser General Public License for more details.
13
14// You should have received a copy of the GNU Lesser General Public
15// License along with this library; if not, write to the Free Software
16// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
18
19
20#ifndef LIBMESH_LIBMESH_H
21#define LIBMESH_LIBMESH_H
22
23
24// Local includes
25#include "libmesh/libmesh_base.h"
26#include "libmesh/libmesh_common.h"
27#include "libmesh/libmesh_config.h"
28
29// C++ includes
30#include <string>
31#include <vector>
32
33// Forward declarations
34// For dealing with MPI stuff in VTK.
35#if defined(LIBMESH_HAVE_MPI) && defined(LIBMESH_HAVE_VTK)
36class vtkMPIController;
37#endif
38
39namespace TIMPI {
40 class TIMPIInit;
41}
42
43#ifdef GETPOT_NAMESPACE
44namespace GETPOT_NAMESPACE {
45#endif
46class GetPot;
47#ifdef GETPOT_NAMESPACE
48}
49#endif
50
60namespace libMesh
61{
62
63// Forward declarations
64namespace Parallel {
65 class Communicator;
66}
67
68class PerfLog;
69enum SolverPackage : int;
70
92{
93public:
94#ifdef LIBMESH_HAVE_MPI
108 LibMeshInit(int argc, const char * const * argv,
109 MPI_Comm COMM_WORLD_IN=MPI_COMM_WORLD, int n_threads=-1);
110#else
111 LibMeshInit(int argc, const char * const * argv,
112 int COMM_WORLD_IN=0, int n_threads=-1);
113#endif
114
123 virtual ~LibMeshInit();
124
129 const Parallel::Communicator & comm() const { return *_comm; }
130
132
133private:
134 // Should we just bite the bullet, use unique_ptr here, and bring an
135 // #include <memory> into everything?
137
138 // Or should we keep this around so we can still inline its
139 // accessors despite forward declaring _timpi_init?
140 //
141 // This is constructed from the TIMPI::Communicator, for backwards
142 // compatibility.
144
145#if defined(LIBMESH_HAVE_MPI) && defined(LIBMESH_HAVE_VTK)
146 // VTK object for dealing with MPI stuff in VTK.
147 // This can't be a std::unique_ptr because VTK makes the destructor
148 // protected and forces us to use a named destructor manually
149 vtkMPIController * _vtk_mpi_controller;
150#endif
151
152#ifdef LIBMESH_ENABLE_EXCEPTIONS
153 static std::terminate_handler _old_terminate_handler;
154#endif
155
156 static PerfLog & perf_log();
157
158 friend void libmesh_abort();
159 friend void libmesh_terminate_handler();
160};
161
168bool initialized ();
169
176bool closed ();
177
191bool on_command_line (std::string arg);
192
201template <typename T>
202T command_line_value (const std::string &, T);
203template <typename T>
204T command_line_value (const std::vector<std::string> &, T);
205
219template <typename T>
220T command_line_next (std::string name, T default_value);
221
229template <typename T>
230void command_line_vector (const std::string &, std::vector<T> &);
231
240std::vector<std::string> command_line_names();
241
245void add_command_line_name(const std::string & name);
246
251void add_command_line_names(const GetPot & getpot);
252
253
257#ifdef LIBMESH_USE_COMPLEX_NUMBERS
258extern const Number imaginary;
259#endif
260
270
282#ifdef LIBMESH_DEFAULT_QUADRUPLE_PRECISION
283constexpr Real operator ""_R(const char * r) { return Real(r); }
284#else
285constexpr Real operator ""_R(long double r) { return r; }
286constexpr Real operator ""_R(unsigned long long r) { return Real(r); }
287#endif
288
292const Real pi = 3.1415926535897932384626433832795029_R;
293
297const Number zero = 0.;
298
303const unsigned int invalid_uint = static_cast<unsigned int>(-1);
304
309const int invalid_int = std::numeric_limits<int>::max();
310
311} // namespace libMesh
312
313#endif // LIBMESH_LIBMESH_H
void ErrorVector unsigned int
The LibMeshInit class, when constructed, initializes the dependent libraries (e.g.
Definition libmesh.h:92
Parallel::Communicator * _comm
Definition libmesh.h:143
LibMeshInit(int argc, const char *const *argv, MPI_Comm COMM_WORLD_IN=MPI_COMM_WORLD, int n_threads=-1)
Initialize the library for use, with the command line options provided.
static std::terminate_handler _old_terminate_handler
Definition libmesh.h:153
LibMeshInit(int argc, const char *const *argv, int COMM_WORLD_IN=0, int n_threads=-1)
friend void libmesh_abort()
Abort as soon as possible.
Definition libmesh.C:338
const Parallel::Communicator & comm() const
Returns a Communicator created from the TIMPIInit object we hold, which will be a compatibility shim ...
Definition libmesh.h:129
vtkMPIController * _vtk_mpi_controller
Definition libmesh.h:149
TIMPI::TIMPIInit * _timpi_init
Definition libmesh.h:136
Parallel::Communicator & comm()
Definition libmesh.h:131
static PerfLog & perf_log()
Definition libmesh.C:896
virtual ~LibMeshInit()
Destructor.
Definition libmesh.C:746
friend void libmesh_terminate_handler()
A terminate handler.
The PerfLog class allows monitoring of specific events.
Definition perf_log.h:154
The libMesh namespace provides an interface to certain functionality in the library.
bool closed()
Checks that the library has been closed.
Definition libmesh.C:331
void command_line_vector(const std::string &, std::vector< T > &)
Definition libmesh.C:1044
SolverPackage default_solver_package()
Definition libmesh.C:1064
const unsigned int invalid_uint
A number which is used quite often to represent an invalid or uninitialized value for an unsigned int...
Definition libmesh.h:303
const int invalid_int
A number which is used quite often to represent an invalid or uninitialized value for an integer.
Definition libmesh.h:309
const Real pi
.
Definition libmesh.h:292
void add_command_line_names(const GetPot &getpot)
Merge a GetPot object's requested names into the set of queried command-line names.
Definition libmesh.C:916
const Number zero
.
Definition libmesh.h:297
T command_line_next(std::string name, T default_value)
Use GetPot's search()/next() functions to get following arguments from the command line.
Definition libmesh.C:1025
SolverPackage
Defines an enum for various linear solver packages.
void add_command_line_name(const std::string &name)
Add a name to the set of queried command-line names.
Definition libmesh.C:903
T command_line_value(const std::string &, T)
Definition libmesh.C:971
const Number imaginary
The imaginary unit, .
bool initialized()
Checks that library initialization has been done.
Definition libmesh.C:324
std::vector< std::string > command_line_names()
Definition libmesh.C:926
bool on_command_line(std::string arg)
Definition libmesh.C:934
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
unsigned int n_threads()