libMesh
libmesh.h
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2025 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 enum SolverPackage : int;
69 
91 {
92 public:
93 #ifdef LIBMESH_HAVE_MPI
94 
107  LibMeshInit(int argc, const char * const * argv,
108  MPI_Comm COMM_WORLD_IN=MPI_COMM_WORLD, int n_threads=-1);
109 #else
110  LibMeshInit(int argc, const char * const * argv,
111  int COMM_WORLD_IN=0, int n_threads=-1);
112 #endif
113 
122  virtual ~LibMeshInit();
123 
128  const Parallel::Communicator & comm() const { return *_comm; }
129 
131 
132 private:
133  // Should we just bite the bullet, use unique_ptr here, and bring an
134  // #include <memory> into everything?
136 
137  // Or should we keep this around so we can still inline its
138  // accessors despite forward declaring _timpi_init?
139  //
140  // This is constructed from the TIMPI::Communicator, for backwards
141  // compatibility.
143 
144 #if defined(LIBMESH_HAVE_MPI) && defined(LIBMESH_HAVE_VTK)
145  // VTK object for dealing with MPI stuff in VTK.
146  // This can't be a std::unique_ptr because VTK makes the destructor
147  // protected and forces us to use a named destructor manually
148  vtkMPIController * _vtk_mpi_controller;
149 #endif
150 };
151 
158 bool initialized ();
159 
166 bool closed ();
167 
174 
178 void enableFPE(bool on);
179 
183 void enableSEGV(bool on);
184 
198 bool on_command_line (std::string arg);
199 
208 template <typename T>
209 T command_line_value (const std::string &, T);
210 template <typename T>
211 T command_line_value (const std::vector<std::string> &, T);
212 
226 template <typename T>
227 T command_line_next (std::string name, T default_value);
228 
236 template <typename T>
237 void command_line_vector (const std::string &, std::vector<T> &);
238 
247 std::vector<std::string> command_line_names();
248 
252 void add_command_line_name(const std::string & name);
253 
258 void add_command_line_names(const GetPot & getpot);
259 
260 
264 #ifdef LIBMESH_USE_COMPLEX_NUMBERS
265 extern const Number imaginary;
266 #endif
267 
277 
289 #ifdef LIBMESH_DEFAULT_QUADRUPLE_PRECISION
290 constexpr Real operator ""_R(const char * r) { return Real(r); }
291 #else
292 constexpr Real operator ""_R(long double r) { return r; }
293 constexpr Real operator ""_R(unsigned long long r) { return Real(r); }
294 #endif
295 
299 const Real pi = 3.1415926535897932384626433832795029_R;
300 
304 const Number zero = 0.;
305 
310 const unsigned int invalid_uint = static_cast<unsigned int>(-1);
311 
316 const int invalid_int = std::numeric_limits<int>::max();
317 
318 } // namespace libMesh
319 
320 #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
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:1078
bool closed()
Checks that the library has been closed.
Definition: libmesh.C:283
unsigned int n_threads()
Definition: libmesh_base.h:96
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:310
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.
void enableSEGV(bool on)
Toggle libMesh reporting of segmentation faults.
Definition: libmesh.C:926
The LibMeshInit class, when constructed, initializes the dependent libraries (e.g.
Definition: libmesh.h:90
The libMesh namespace provides an interface to certain functionality in the library.
const Number zero
.
Definition: libmesh.h:304
vtkMPIController * _vtk_mpi_controller
Definition: libmesh.h:148
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:128
SolverPackage default_solver_package()
Definition: libmesh.C:1117
T command_line_value(const std::string &, T)
Definition: libmesh.C:1024
const int invalid_int
A number which is used quite often to represent an invalid or uninitialized value for an integer...
Definition: libmesh.h:316
virtual ~LibMeshInit()
Destructor.
Definition: libmesh.C:727
TIMPI::TIMPIInit * _timpi_init
Definition: libmesh.h:135
void enableFPE(bool on)
Toggle hardware trap floating point exceptions.
Definition: libmesh.C:884
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:969
void add_command_line_name(const std::string &name)
Add a name to the set of queried command-line names.
Definition: libmesh.C:956
void command_line_vector(const std::string &, std::vector< T > &)
Definition: libmesh.C:1097
std::vector< std::string > command_line_names()
Definition: libmesh.C:979
Parallel::Communicator & comm()
Definition: libmesh.h:130
bool initialized()
Checks that library initialization has been done.
Definition: libmesh.C:276
bool on_command_line(std::string arg)
Definition: libmesh.C:987
SolverPackage
Defines an enum for various linear solver packages.
void ErrorVector unsigned int
Definition: adjoints_ex3.C:360
const Real pi
.
Definition: libmesh.h:299
void libmesh_terminate_handler()
A terminate handler.
Definition: libmesh.C:293
Parallel::Communicator * _comm
Definition: libmesh.h:142