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 auto preimage = reverse.find(val);
72 if (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 {
147 std::map<ElemType, std::string> enum_to_elem_type =
148 build_reverse_map(elem_type_to_enum);
151 std::map<std::string, ElemMappingType> elem_mapping_type_to_enum {
157 std::map<ElemMappingType, std::string> enum_to_elem_mapping_type =
158 build_reverse_map(elem_mapping_type_to_enum);
161 std::map<std::string, Order> order_to_enum {
212 std::map<Order, std::string> enum_to_order =
213 build_reverse_map(order_to_enum);
216 std::map<std::string, FEFamily> fefamily_to_enum {
245 std::map<FEFamily, std::string> enum_to_fefamily =
246 build_reverse_map(fefamily_to_enum);
249 std::map<std::string, InfMapType> inf_map_type_to_enum {
255 std::map<InfMapType, std::string> enum_to_inf_map_type =
256 build_reverse_map(inf_map_type_to_enum);
259 std::map<std::string, QuadratureType> quadrature_type_to_enum {
275 std::map<QuadratureType, std::string> enum_to_quadrature_type =
276 build_reverse_map(quadrature_type_to_enum);
279 std::map<std::string, PartitionerType> partitioner_type_to_enum {
302 std::map<PartitionerType, std::string> enum_to_partitioner_type =
303 build_reverse_map(partitioner_type_to_enum);
306 std::map<std::string, PreconditionerType> preconditioner_type_to_enum {
343 std::map<PreconditionerType, std::string> enum_to_preconditioner_type =
344 build_reverse_map(preconditioner_type_to_enum);
347 #ifdef LIBMESH_ENABLE_AMR 348 std::map<std::string, Elem::RefinementState> refinementstate_type_to_enum {
359 std::map<Elem::RefinementState, std::string> enum_to_refinementstate_type =
360 build_reverse_map(refinementstate_type_to_enum);
361 #endif // LIBMESH_ENABLE_AMR 364 std::map<std::string, EigenSolverType> eigensolvertype_to_enum {
374 std::map<EigenSolverType, std::string> enum_to_eigensolvertype =
375 build_reverse_map(eigensolvertype_to_enum);
378 std::map<std::string, SolverType> solvertype_to_enum {
401 std::map<SolverType, std::string> enum_to_solvertype =
402 build_reverse_map(solvertype_to_enum);
405 std::map<std::string, ElemQuality> elemquality_to_enum {
425 std::map<ElemQuality, std::string> enum_to_elemquality =
426 build_reverse_map(elemquality_to_enum);
429 std::map<std::string, IOPackage> iopackage_to_enum {
440 std::map<IOPackage, std::string> enum_to_iopackage =
441 build_reverse_map(iopackage_to_enum);
444 std::map<std::string, FEMNormType> norm_type_to_enum {
473 std::map<FEMNormType, std::string> enum_to_norm_type =
474 build_reverse_map(norm_type_to_enum);
477 std::map<std::string, ParallelType> parallel_type_to_enum {
485 std::map<ParallelType, std::string> enum_to_parallel_type =
486 build_reverse_map(parallel_type_to_enum);
489 std::map<std::string, PointLocatorType> point_locator_type_to_enum {
494 std::map<PointLocatorType, std::string> enum_to_point_locator_type =
495 build_reverse_map(point_locator_type_to_enum);
498 std::map<std::string, SolverPackage> solverpackage_type_to_enum {
508 std::map<SolverPackage, std::string> enum_to_solverpackage_type =
509 build_reverse_map(solverpackage_type_to_enum);
512 std::map<std::string, SubsetSolveMode> subset_solve_mode_to_enum {
518 std::map<SubsetSolveMode, std::string> enum_to_subset_solve_mode =
519 build_reverse_map(subset_solve_mode_to_enum);
522 std::map<std::string, XdrMODE> xdr_mode_to_enum {
530 std::map<XdrMODE, std::string> enum_to_xdr_mode =
531 build_reverse_map(xdr_mode_to_enum);
534 std::map<std::string, LinearConvergenceReason> linear_convergence_reason_to_enum {
558 std::map<LinearConvergenceReason, std::string> enum_to_linear_convergence_reason =
559 build_reverse_map(linear_convergence_reason_to_enum);
570 #define INSTANTIATE_STRING_TO_ENUM(ENUM_NAME,VAR_NAME) \ 572 ENUM_NAME string_to_enum<ENUM_NAME> (std::string_view s) \ 574 std::string upper(s); \ 575 std::transform(upper.begin(), upper.end(), upper.begin(), ::toupper); \ 577 if (!VAR_NAME##_to_enum.count(upper)) \ 579 libmesh_error_msg("No " #ENUM_NAME " named " << s << " found."); \ 582 return VAR_NAME##_to_enum[upper]; \ 586 ENUM_NAME string_to_enum<ENUM_NAME> (const std::string & s) \ 588 return string_to_enum<ENUM_NAME>(std::string_view(s)); \ 592 ENUM_NAME string_to_enum<ENUM_NAME> (const char * s) \ 594 return string_to_enum<ENUM_NAME>(std::string_view(s)); \ 598 std::string enum_to_string<ENUM_NAME> (const ENUM_NAME e) \ 600 if (!enum_to_##VAR_NAME .count(e)) \ 601 libmesh_error_msg("No " #ENUM_NAME " with enumeration " << e << " found."); \ 603 return enum_to_##VAR_NAME [e]; \ 608 INSTANTIATE_STRING_TO_ENUM(
ElemType,elem_type)
610 INSTANTIATE_STRING_TO_ENUM(
Order,order)
611 INSTANTIATE_STRING_TO_ENUM(
FEFamily,fefamily)
612 INSTANTIATE_STRING_TO_ENUM(
InfMapType,inf_map_type)
617 #ifdef LIBMESH_ENABLE_AMR 619 #endif // LIBMESH_ENABLE_AMR 621 INSTANTIATE_STRING_TO_ENUM(
SolverType,solvertype)
623 INSTANTIATE_STRING_TO_ENUM(
ElemQuality,elemquality)
624 INSTANTIATE_STRING_TO_ENUM(
IOPackage,iopackage)
630 INSTANTIATE_STRING_TO_ENUM(
XdrMODE,xdr_mode)
633 #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.