libMesh
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)
36 class vtkMPIController;
37 #endif
38 
39 namespace TIMPI {
40  class TIMPIInit;
41 }
42 
43 #ifdef GETPOT_NAMESPACE
44 namespace GETPOT_NAMESPACE {
45 #endif
46 class GetPot;
47 #ifdef GETPOT_NAMESPACE
48 }
49 #endif
50 
60 namespace libMesh
61 {
62 
63 // Forward declarations
64 namespace Parallel {
65  class Communicator;
66 }
67 
68 class PerfLog;
69 enum SolverPackage : int;
70 
92 {
93 public:
94 #ifdef LIBMESH_HAVE_MPI
95 
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 
133 private:
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 
168 bool initialized ();
169 
176 bool closed ();
177 
191 bool on_command_line (std::string arg);
192 
201 template <typename T>
202 T command_line_value (const std::string &, T);
203 template <typename T>
204 T command_line_value (const std::vector<std::string> &, T);
205 
219 template <typename T>
220 T command_line_next (std::string name, T default_value);
221 
229 template <typename T>
230 void command_line_vector (const std::string &, std::vector<T> &);
231 
240 std::vector<std::string> command_line_names();
241 
245 void add_command_line_name(const std::string & name);
246 
251 void add_command_line_names(const GetPot & getpot);
252 
253 
257 #ifdef LIBMESH_USE_COMPLEX_NUMBERS
258 extern const Number imaginary;
259 #endif
260 
270 
282 #ifdef LIBMESH_DEFAULT_QUADRUPLE_PRECISION
283 constexpr Real operator ""_R(const char * r) { return Real(r); }
284 #else
285 constexpr Real operator ""_R(long double r) { return r; }
286 constexpr Real operator ""_R(unsigned long long r) { return Real(r); }
287 #endif
288 
292 const Real pi = 3.1415926535897932384626433832795029_R;
293 
297 const Number zero = 0.;
298 
303 const unsigned int invalid_uint = static_cast<unsigned int>(-1);
304 
309 const int invalid_int = std::numeric_limits<int>::max();
310 
311 } // namespace libMesh
312 
313 #endif // LIBMESH_LIBMESH_H
std::string name(const ElemQuality q)
This function returns a string containing some name for q.
Definition: elem_quality.C:42
friend void libmesh_abort()
Abort as soon as possible.
Definition: libmesh.C:338
T command_line_next(std::string name, T default_value)
Use GetPot&#39;s search()/next() functions to get following arguments from the command line...
Definition: libmesh.C:1025
bool closed()
Checks that the library has been closed.
Definition: libmesh.C:331
friend void libmesh_terminate_handler()
A terminate handler.
unsigned int n_threads()
Definition: libmesh_base.h:109
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
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.
The LibMeshInit class, when constructed, initializes the dependent libraries (e.g.
Definition: libmesh.h:91
The libMesh namespace provides an interface to certain functionality in the library.
const Number zero
.
Definition: libmesh.h:297
vtkMPIController * _vtk_mpi_controller
Definition: libmesh.h:149
const Number imaginary
The imaginary unit, .
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
SolverPackage default_solver_package()
Definition: libmesh.C:1064
The PerfLog class allows monitoring of specific events.
Definition: perf_log.h:153
T command_line_value(const std::string &, T)
Definition: libmesh.C:971
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
virtual ~LibMeshInit()
Destructor.
Definition: libmesh.C:746
static PerfLog & perf_log()
Definition: libmesh.C:896
TIMPI::TIMPIInit * _timpi_init
Definition: libmesh.h:136
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
void add_command_line_names(const GetPot &getpot)
Merge a GetPot object&#39;s requested names into the set of queried command-line names.
Definition: libmesh.C:916
void add_command_line_name(const std::string &name)
Add a name to the set of queried command-line names.
Definition: libmesh.C:903
void command_line_vector(const std::string &, std::vector< T > &)
Definition: libmesh.C:1044
std::vector< std::string > command_line_names()
Definition: libmesh.C:926
Parallel::Communicator & comm()
Definition: libmesh.h:131
bool initialized()
Checks that library initialization has been done.
Definition: libmesh.C:324
bool on_command_line(std::string arg)
Definition: libmesh.C:934
SolverPackage
Defines an enum for various linear solver packages.
static std::terminate_handler _old_terminate_handler
Definition: libmesh.h:153
void ErrorVector unsigned int
Definition: adjoints_ex3.C:360
const Real pi
.
Definition: libmesh.h:292
Parallel::Communicator * _comm
Definition: libmesh.h:143