25 #include "libmesh/libmesh_common.h" 26 #include "libmesh/string_to_enum.h" 27 #include "libmesh/enum_to_string.h" 28 #include "libmesh/enum_convergence_flags.h" 29 #include "libmesh/enum_elem_quality.h" 30 #include "libmesh/enum_elem_type.h" 31 #include "libmesh/enum_eigen_solver_type.h" 32 #include "libmesh/enum_fe_family.h" 33 #include "libmesh/enum_inf_map_type.h" 34 #include "libmesh/enum_io_package.h" 35 #include "libmesh/enum_norm_type.h" 36 #include "libmesh/enum_order.h" 37 #include "libmesh/enum_parallel_type.h" 38 #include "libmesh/enum_partitioner_type.h" 39 #include "libmesh/enum_point_locator_type.h" 40 #include "libmesh/enum_preconditioner_type.h" 41 #include "libmesh/enum_quadrature_type.h" 42 #include "libmesh/enum_solver_package.h" 43 #include "libmesh/enum_solver_type.h" 44 #include "libmesh/enum_subset_solve_mode.h" 45 #include "libmesh/enum_xdr_mode.h" 46 #include "libmesh/elem.h" 57 template <
class MapType>
59 std::map<typename MapType::mapped_type, typename MapType::key_type>
60 build_reverse_map (
const MapType & forward)
62 std::map<typename MapType::mapped_type, typename MapType::key_type> reverse;
64 for (
auto & [key, val] : forward)
71 if (
auto preimage = reverse.find(val);
72 preimage == reverse.end())
73 reverse.emplace (val, key);
74 else if (preimage->second < key)
75 preimage->second = key;
81 std::map<std::string, ElemType> elem_type_to_enum {
152 std::map<ElemType, std::string> enum_to_elem_type =
153 build_reverse_map(elem_type_to_enum);
156 std::map<std::string, ElemMappingType> elem_mapping_type_to_enum {
162 std::map<ElemMappingType, std::string> enum_to_elem_mapping_type =
163 build_reverse_map(elem_mapping_type_to_enum);
166 std::map<std::string, Order> order_to_enum {
218 std::map<Order, std::string> enum_to_order =
219 build_reverse_map(order_to_enum);
222 std::map<std::string, FEFamily> fefamily_to_enum {
251 std::map<FEFamily, std::string> enum_to_fefamily =
252 build_reverse_map(fefamily_to_enum);
255 std::map<std::string, InfMapType> inf_map_type_to_enum {
261 std::map<InfMapType, std::string> enum_to_inf_map_type =
262 build_reverse_map(inf_map_type_to_enum);
265 std::map<std::string, QuadratureType> quadrature_type_to_enum {
281 std::map<QuadratureType, std::string> enum_to_quadrature_type =
282 build_reverse_map(quadrature_type_to_enum);
285 std::map<std::string, PartitionerType> partitioner_type_to_enum {
308 std::map<PartitionerType, std::string> enum_to_partitioner_type =
309 build_reverse_map(partitioner_type_to_enum);
312 std::map<std::string, PreconditionerType> preconditioner_type_to_enum {
349 std::map<PreconditionerType, std::string> enum_to_preconditioner_type =
350 build_reverse_map(preconditioner_type_to_enum);
353 #ifdef LIBMESH_ENABLE_AMR 354 std::map<std::string, Elem::RefinementState> refinementstate_type_to_enum {
365 std::map<Elem::RefinementState, std::string> enum_to_refinementstate_type =
366 build_reverse_map(refinementstate_type_to_enum);
367 #endif // LIBMESH_ENABLE_AMR 370 std::map<std::string, EigenSolverType> eigensolvertype_to_enum {
380 std::map<EigenSolverType, std::string> enum_to_eigensolvertype =
381 build_reverse_map(eigensolvertype_to_enum);
384 std::map<std::string, SolverType> solvertype_to_enum {
407 std::map<SolverType, std::string> enum_to_solvertype =
408 build_reverse_map(solvertype_to_enum);
411 std::map<std::string, ElemQuality> elemquality_to_enum {
433 std::map<ElemQuality, std::string> enum_to_elemquality =
434 build_reverse_map(elemquality_to_enum);
437 std::map<std::string, IOPackage> iopackage_to_enum {
448 std::map<IOPackage, std::string> enum_to_iopackage =
449 build_reverse_map(iopackage_to_enum);
452 std::map<std::string, FEMNormType> norm_type_to_enum {
481 std::map<FEMNormType, std::string> enum_to_norm_type =
482 build_reverse_map(norm_type_to_enum);
485 std::map<std::string, ParallelType> parallel_type_to_enum {
493 std::map<ParallelType, std::string> enum_to_parallel_type =
494 build_reverse_map(parallel_type_to_enum);
497 std::map<std::string, PointLocatorType> point_locator_type_to_enum {
502 std::map<PointLocatorType, std::string> enum_to_point_locator_type =
503 build_reverse_map(point_locator_type_to_enum);
506 std::map<std::string, SolverPackage> solverpackage_type_to_enum {
516 std::map<SolverPackage, std::string> enum_to_solverpackage_type =
517 build_reverse_map(solverpackage_type_to_enum);
520 std::map<std::string, SubsetSolveMode> subset_solve_mode_to_enum {
526 std::map<SubsetSolveMode, std::string> enum_to_subset_solve_mode =
527 build_reverse_map(subset_solve_mode_to_enum);
530 std::map<std::string, XdrMODE> xdr_mode_to_enum {
538 std::map<XdrMODE, std::string> enum_to_xdr_mode =
539 build_reverse_map(xdr_mode_to_enum);
542 std::map<std::string, LinearConvergenceReason> linear_convergence_reason_to_enum {
566 std::map<LinearConvergenceReason, std::string> enum_to_linear_convergence_reason =
567 build_reverse_map(linear_convergence_reason_to_enum);
578 #define INSTANTIATE_STRING_TO_ENUM(ENUM_NAME,VAR_NAME) \ 580 ENUM_NAME string_to_enum<ENUM_NAME> (std::string_view s) \ 582 std::string upper(s); \ 583 std::transform(upper.begin(), upper.end(), upper.begin(), ::toupper); \ 585 if (!VAR_NAME##_to_enum.count(upper)) \ 587 libmesh_error_msg("No " #ENUM_NAME " named " << s << " found."); \ 590 return VAR_NAME##_to_enum[upper]; \ 594 ENUM_NAME string_to_enum<ENUM_NAME> (const std::string & s) \ 596 return string_to_enum<ENUM_NAME>(std::string_view(s)); \ 600 ENUM_NAME string_to_enum<ENUM_NAME> (const char * s) \ 602 return string_to_enum<ENUM_NAME>(std::string_view(s)); \ 606 std::string enum_to_string<ENUM_NAME> (const ENUM_NAME e) \ 608 if (!enum_to_##VAR_NAME .count(e)) \ 609 libmesh_error_msg("No " #ENUM_NAME " with enumeration " << e << " found."); \ 611 return enum_to_##VAR_NAME [e]; \ 616 INSTANTIATE_STRING_TO_ENUM(
ElemType,elem_type)
618 INSTANTIATE_STRING_TO_ENUM(
Order,order)
619 INSTANTIATE_STRING_TO_ENUM(
FEFamily,fefamily)
620 INSTANTIATE_STRING_TO_ENUM(
InfMapType,inf_map_type)
625 #ifdef LIBMESH_ENABLE_AMR 627 #endif // LIBMESH_ENABLE_AMR 629 INSTANTIATE_STRING_TO_ENUM(
SolverType,solvertype)
631 INSTANTIATE_STRING_TO_ENUM(
ElemQuality,elemquality)
632 INSTANTIATE_STRING_TO_ENUM(
IOPackage,iopackage)
638 INSTANTIATE_STRING_TO_ENUM(
XdrMODE,xdr_mode)
641 #undef INSTANTIATE_STRING_TO_ENUM
ElemType
Defines an enum for geometric element types.
Order
defines an enum for polynomial orders.
IOPackage
libMesh interfaces with several different software packages for the purposes of creating, reading, and writing mesh files.
FEMNormType
defines an enum for norms defined on vectors of finite element coefficients
RefinementState
Enumeration of possible element refinement states.
LinearConvergenceReason
Linear solver convergence flags (taken from the PETSc flags).
QuadratureType
Defines an enum for currently available quadrature rules.
The libMesh namespace provides an interface to certain functionality in the library.
XdrMODE
Defines an enum for read/write mode in Xdr format.
PartitionerType
Defines an enum for mesh partitioner types.
ElemQuality
Defines an enum for element quality metrics.
PreconditionerType
Defines an enum for preconditioner types.
SolverType
Defines an enum for iterative solver types.
ElemMappingType
Enumeration of possible element master->physical mapping types.
InfMapType
defines an enum for the types of coordinate mappings available in infinite elements.
EigenSolverType
Defines an enum for iterative eigenproblem solver types.
PointLocatorType
defines an enum for the types of point locators (given a point with global coordinates, locate the corresponding element in space) available in libMesh.
SolverPackage
Defines an enum for various linear solver packages.
FEFamily
defines an enum for finite element families.
SubsetSolveMode
defines an enum for the question what happens to the dofs outside the given subset when a system is s...
ParallelType
Defines an enum for parallel data structure types.