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"
57template <
class MapType>
59std::map<typename MapType::mapped_type, typename MapType::key_type>
60build_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;
81std::map<std::string, ElemType> elem_type_to_enum {
152std::map<ElemType, std::string> enum_to_elem_type =
153 build_reverse_map(elem_type_to_enum);
156std::map<std::string, ElemMappingType> elem_mapping_type_to_enum {
162std::map<ElemMappingType, std::string> enum_to_elem_mapping_type =
163 build_reverse_map(elem_mapping_type_to_enum);
166std::map<std::string, Order> order_to_enum {
218std::map<Order, std::string> enum_to_order =
219 build_reverse_map(order_to_enum);
222std::map<std::string, FEFamily> fefamily_to_enum {
251std::map<FEFamily, std::string> enum_to_fefamily =
252 build_reverse_map(fefamily_to_enum);
255std::map<std::string, InfMapType> inf_map_type_to_enum {
261std::map<InfMapType, std::string> enum_to_inf_map_type =
262 build_reverse_map(inf_map_type_to_enum);
265std::map<std::string, QuadratureType> quadrature_type_to_enum {
281std::map<QuadratureType, std::string> enum_to_quadrature_type =
282 build_reverse_map(quadrature_type_to_enum);
285std::map<std::string, PartitionerType> partitioner_type_to_enum {
308std::map<PartitionerType, std::string> enum_to_partitioner_type =
309 build_reverse_map(partitioner_type_to_enum);
312std::map<std::string, PreconditionerType> preconditioner_type_to_enum {
349std::map<PreconditionerType, std::string> enum_to_preconditioner_type =
350 build_reverse_map(preconditioner_type_to_enum);
353#ifdef LIBMESH_ENABLE_AMR
354std::map<std::string, Elem::RefinementState> refinementstate_type_to_enum {
365std::map<Elem::RefinementState, std::string> enum_to_refinementstate_type =
366 build_reverse_map(refinementstate_type_to_enum);
370std::map<std::string, EigenSolverType> eigensolvertype_to_enum {
380std::map<EigenSolverType, std::string> enum_to_eigensolvertype =
381 build_reverse_map(eigensolvertype_to_enum);
384std::map<std::string, SolverType> solvertype_to_enum {
407std::map<SolverType, std::string> enum_to_solvertype =
408 build_reverse_map(solvertype_to_enum);
411std::map<std::string, ElemQuality> elemquality_to_enum {
433std::map<ElemQuality, std::string> enum_to_elemquality =
434 build_reverse_map(elemquality_to_enum);
437std::map<std::string, IOPackage> iopackage_to_enum {
448std::map<IOPackage, std::string> enum_to_iopackage =
449 build_reverse_map(iopackage_to_enum);
452std::map<std::string, FEMNormType> norm_type_to_enum {
481std::map<FEMNormType, std::string> enum_to_norm_type =
482 build_reverse_map(norm_type_to_enum);
485std::map<std::string, ParallelType> parallel_type_to_enum {
493std::map<ParallelType, std::string> enum_to_parallel_type =
494 build_reverse_map(parallel_type_to_enum);
497std::map<std::string, PointLocatorType> point_locator_type_to_enum {
502std::map<PointLocatorType, std::string> enum_to_point_locator_type =
503 build_reverse_map(point_locator_type_to_enum);
506std::map<std::string, SolverPackage> solverpackage_type_to_enum {
516std::map<SolverPackage, std::string> enum_to_solverpackage_type =
517 build_reverse_map(solverpackage_type_to_enum);
520std::map<std::string, SubsetSolveMode> subset_solve_mode_to_enum {
526std::map<SubsetSolveMode, std::string> enum_to_subset_solve_mode =
527 build_reverse_map(subset_solve_mode_to_enum);
530std::map<std::string, XdrMODE> xdr_mode_to_enum {
538std::map<XdrMODE, std::string> enum_to_xdr_mode =
539 build_reverse_map(xdr_mode_to_enum);
542std::map<std::string, LinearConvergenceReason> linear_convergence_reason_to_enum {
566std::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]; \
616INSTANTIATE_STRING_TO_ENUM(
ElemType,elem_type)
618INSTANTIATE_STRING_TO_ENUM(
Order,order)
619INSTANTIATE_STRING_TO_ENUM(
FEFamily,fefamily)
620INSTANTIATE_STRING_TO_ENUM(
InfMapType,inf_map_type)
625#ifdef LIBMESH_ENABLE_AMR
629INSTANTIATE_STRING_TO_ENUM(
SolverType,solvertype)
632INSTANTIATE_STRING_TO_ENUM(
IOPackage,iopackage)
638INSTANTIATE_STRING_TO_ENUM(
XdrMODE,xdr_mode)
641#undef INSTANTIATE_STRING_TO_ENUM
RefinementState
Enumeration of possible element refinement states.
@ INVALID_REFINEMENTSTATE
The libMesh namespace provides an interface to certain functionality in the library.
PartitionerType
Defines an enum for mesh partitioner types.
@ MAPPED_SUBDOMAIN_PARTITIONER
@ HILBERT_SFC_PARTITIONER
ParallelType
Defines an enum for parallel data structure types.
@ INVALID_PARALLELIZATION
IOPackage
libMesh interfaces with several different software packages for the purposes of creating,...
ElemType
Defines an enum for geometric element types.
SubsetSolveMode
defines an enum for the question what happens to the dofs outside the given subset when a system is s...
ElemMappingType
Enumeration of possible element master->physical mapping types.
SolverPackage
Defines an enum for various linear solver packages.
ElemQuality
Defines an enum for element quality metrics.
QuadratureType
Defines an enum for currently available quadrature rules.
PointLocatorType
defines an enum for the types of point locators (given a point with global coordinates,...
PreconditionerType
Defines an enum for preconditioner types.
SolverType
Defines an enum for iterative solver types.
EigenSolverType
Defines an enum for iterative eigenproblem solver types.
XdrMODE
Defines an enum for read/write mode in Xdr format.
LinearConvergenceReason
Linear solver convergence flags (taken from the PETSc flags).
@ CONVERGED_HAPPY_BREAKDOWN
@ CONVERGED_CG_CONSTRAINED
@ DIVERGED_PCSETUP_FAILED
@ DIVERGED_BREAKDOWN_BICG
@ DIVERGED_INDEFINITE_MAT