55 template <
typename MapIter,
class MapType>
57 void build_reverse_map (MapIter it, MapIter
end, MapType & reverse)
61 for (; it !=
end; ++it)
68 typename MapType::iterator preimage = reverse.find(it->second);
69 if (preimage == reverse.end())
70 reverse.insert (std::make_pair(it->second, it->first));
71 else if (preimage->second < it->first)
72 preimage->second = it->first;
76 #define INSTANTIATE_ENUM_MAPS(ENUM_NAME,VAR_NAME) \ 77 std::map<std::string, ENUM_NAME> VAR_NAME##_to_enum; \ 79 std::map<ENUM_NAME, std::string> enum_to_##VAR_NAME; \ 81 void init_##VAR_NAME##_to_enum (); \ 84 void init_enum_to_##VAR_NAME () \ 87 if (enum_to_##VAR_NAME .empty()) \ 90 init_##VAR_NAME##_to_enum(); \ 92 build_reverse_map (VAR_NAME##_to_enum.begin(), \ 93 VAR_NAME##_to_enum.end(), \ 94 enum_to_##VAR_NAME); \ 98 INSTANTIATE_ENUM_MAPS(
ElemType, elem_type)
103 void init_elem_type_to_enum ()
105 if (elem_type_to_enum.empty())
107 elem_type_to_enum[
"EDGE" ]=
EDGE2;
108 elem_type_to_enum[
"EDGE2" ]=
EDGE2;
109 elem_type_to_enum[
"EDGE3" ]=
EDGE3;
110 elem_type_to_enum[
"EDGE4" ]=
EDGE4;
112 elem_type_to_enum[
"TRI" ]=
TRI3;
113 elem_type_to_enum[
"TRI3" ]=
TRI3;
114 elem_type_to_enum[
"TRISHELL3" ]=
TRISHELL3;
116 elem_type_to_enum[
"TRI6" ]=
TRI6;
118 elem_type_to_enum[
"QUAD" ]=
QUAD4;
119 elem_type_to_enum[
"QUAD4" ]=
QUAD4;
121 elem_type_to_enum[
"QUAD8" ]=
QUAD8;
123 elem_type_to_enum[
"QUAD9" ]=
QUAD9;
125 elem_type_to_enum[
"TET" ]=
TET4;
126 elem_type_to_enum[
"TET4" ]=
TET4;
127 elem_type_to_enum[
"TET10" ]=
TET10;
129 elem_type_to_enum[
"HEX" ]=
HEX8;
130 elem_type_to_enum[
"HEX8" ]=
HEX8;
131 elem_type_to_enum[
"HEX20" ]=
HEX20;
132 elem_type_to_enum[
"HEX27" ]=
HEX27;
134 elem_type_to_enum[
"PRISM" ]=
PRISM6;
135 elem_type_to_enum[
"PRISM6" ]=
PRISM6;
136 elem_type_to_enum[
"PRISM15" ]=
PRISM15;
137 elem_type_to_enum[
"PRISM18" ]=
PRISM18;
139 elem_type_to_enum[
"PYRAMID" ]=
PYRAMID5;
140 elem_type_to_enum[
"PYRAMID5" ]=
PYRAMID5;
141 elem_type_to_enum[
"PYRAMID13" ]=
PYRAMID13;
142 elem_type_to_enum[
"PYRAMID14" ]=
PYRAMID14;
144 elem_type_to_enum[
"INFEDGE" ]=
INFEDGE2;
145 elem_type_to_enum[
"INFEDGE2" ]=
INFEDGE2;
147 elem_type_to_enum[
"INFQUAD" ]=
INFQUAD4;
148 elem_type_to_enum[
"INFQUAD4" ]=
INFQUAD4;
149 elem_type_to_enum[
"INFQUAD6" ]=
INFQUAD6;
151 elem_type_to_enum[
"INFHEX" ]=
INFHEX8;
152 elem_type_to_enum[
"INFHEX8" ]=
INFHEX8;
153 elem_type_to_enum[
"INFHEX16" ]=
INFHEX16;
154 elem_type_to_enum[
"INFHEX18" ]=
INFHEX18;
156 elem_type_to_enum[
"INFPRISM" ]=
INFPRISM6;
157 elem_type_to_enum[
"INFPRISM6" ]=
INFPRISM6;
160 elem_type_to_enum[
"NODE" ]=
NODEELEM;
161 elem_type_to_enum[
"NODEELEM" ]=
NODEELEM;
168 INSTANTIATE_ENUM_MAPS(
Order, order)
171 void init_order_to_enum ()
173 if (order_to_enum.empty())
175 order_to_enum[
"CONSTANT" ]=
CONSTANT;
176 order_to_enum[
"FIRST" ]=
FIRST;
177 order_to_enum[
"SECOND" ]=
SECOND;
178 order_to_enum[
"THIRD" ]=
THIRD;
179 order_to_enum[
"FOURTH" ]=
FOURTH;
180 order_to_enum[
"FIFTH" ]=
FIFTH;
181 order_to_enum[
"SIXTH" ]=
SIXTH;
182 order_to_enum[
"SEVENTH" ]=
SEVENTH;
183 order_to_enum[
"EIGHTH" ]=
EIGHTH;
184 order_to_enum[
"NINTH" ]=
NINTH;
185 order_to_enum[
"TENTH" ]=
TENTH;
187 order_to_enum[
"ELEVENTH" ]=
ELEVENTH;
188 order_to_enum[
"TWELFTH" ]=
TWELFTH;
218 order_to_enum[
"FORTIETH" ]=
FORTIETH;
228 INSTANTIATE_ENUM_MAPS(
FEFamily, fefamily)
231 void init_fefamily_to_enum ()
233 if (fefamily_to_enum.empty())
235 fefamily_to_enum[
"LAGRANGE" ]=
LAGRANGE;
240 fefamily_to_enum[
"MONOMIAL" ]=
MONOMIAL;
241 fefamily_to_enum[
"SCALAR" ]=
SCALAR;
242 fefamily_to_enum[
"XYZ" ]=
XYZ;
243 fefamily_to_enum[
"BERNSTEIN" ]=
BERNSTEIN;
244 fefamily_to_enum[
"SZABAB" ]=
SZABAB;
248 fefamily_to_enum[
"LEGENDRE" ]=
LEGENDRE;
249 fefamily_to_enum[
"CLOUGH" ]=
CLOUGH;
250 fefamily_to_enum[
"HERMITE" ]=
HERMITE;
259 INSTANTIATE_ENUM_MAPS(
InfMapType, inf_map_type)
262 void init_inf_map_type_to_enum ()
264 if (inf_map_type_to_enum.empty())
266 inf_map_type_to_enum[
"CARTESIAN" ]=
CARTESIAN;
267 inf_map_type_to_enum[
"SPHERICAL" ]=
SPHERICAL;
276 void init_quadrature_type_to_enum ()
278 if (quadrature_type_to_enum.empty())
280 quadrature_type_to_enum[
"QGAUSS" ]=
QGAUSS;
281 quadrature_type_to_enum[
"QJACOBI_1_0"]=
QJACOBI_1_0;
282 quadrature_type_to_enum[
"QJACOBI_2_0"]=
QJACOBI_2_0;
283 quadrature_type_to_enum[
"QSIMPSON" ]=
QSIMPSON;
284 quadrature_type_to_enum[
"QTRAP" ]=
QTRAP;
285 quadrature_type_to_enum[
"QGRID" ]=
QGRID;
286 quadrature_type_to_enum[
"QCLOUGH" ]=
QCLOUGH;
295 void init_preconditioner_type_to_enum ()
297 if (preconditioner_type_to_enum.empty())
302 preconditioner_type_to_enum[
"SOR_PRECOND" ]=
SOR_PRECOND;
303 preconditioner_type_to_enum[
"SSOR_PRECOND" ]=
SSOR_PRECOND;
305 preconditioner_type_to_enum[
"ASM_PRECOND" ]=
ASM_PRECOND;
307 preconditioner_type_to_enum[
"ICC_PRECOND" ]=
ICC_PRECOND;
308 preconditioner_type_to_enum[
"ILU_PRECOND" ]=
ILU_PRECOND;
309 preconditioner_type_to_enum[
"LU_PRECOND" ]=
LU_PRECOND;
310 preconditioner_type_to_enum[
"USER_PRECOND" ]=
USER_PRECOND;
312 preconditioner_type_to_enum[
"AMG_PRECOND" ]=
AMG_PRECOND;
326 preconditioner_type_to_enum[
"LU" ]=
LU_PRECOND;
335 #ifdef LIBMESH_ENABLE_AMR 340 void init_refinementstate_type_to_enum ()
342 if (refinementstate_type_to_enum.empty())
354 #endif // LIBMESH_ENABLE_AMR 360 void init_eigensolvertype_to_enum ()
362 if (eigensolvertype_to_enum.empty())
364 eigensolvertype_to_enum[
"POWER" ]=
POWER;
365 eigensolvertype_to_enum[
"LAPACK" ]=
LAPACK;
366 eigensolvertype_to_enum[
"SUBSPACE" ]=
SUBSPACE;
367 eigensolvertype_to_enum[
"ARNOLDI" ]=
ARNOLDI;
368 eigensolvertype_to_enum[
"LANCZOS" ]=
LANCZOS;
369 eigensolvertype_to_enum[
"KRYLOVSCHUR" ]=
KRYLOVSCHUR;
378 void init_solvertype_to_enum ()
380 if (solvertype_to_enum.empty())
382 solvertype_to_enum[
"CG" ]=
CG;
383 solvertype_to_enum[
"CGN" ]=
CGN;
384 solvertype_to_enum[
"CGS" ]=
CGS;
385 solvertype_to_enum[
"CR" ]=
CR;
386 solvertype_to_enum[
"QMR" ]=
QMR;
387 solvertype_to_enum[
"TCQMR" ]=
TCQMR;
388 solvertype_to_enum[
"TFQMR" ]=
TFQMR;
389 solvertype_to_enum[
"BICG" ]=
BICG;
390 solvertype_to_enum[
"MINRES" ]=
MINRES;
391 solvertype_to_enum[
"GMRES" ]=
GMRES;
392 solvertype_to_enum[
"LSQR" ]=
LSQR;
393 solvertype_to_enum[
"JACOBI" ]=
JACOBI;
396 solvertype_to_enum[
"SSOR" ]=
SSOR;
398 solvertype_to_enum[
"CHEBYSHEV" ]=
CHEBYSHEV;
407 void init_elemquality_to_enum ()
409 if (elemquality_to_enum.empty())
412 elemquality_to_enum[
"SKEW" ]=
SKEW;
413 elemquality_to_enum[
"SHEAR" ]=
SHEAR;
414 elemquality_to_enum[
"SHAPE" ]=
SHAPE;
415 elemquality_to_enum[
"MAX_ANGLE" ]=
MAX_ANGLE;
416 elemquality_to_enum[
"MIN_ANGLE" ]=
MIN_ANGLE;
417 elemquality_to_enum[
"CONDITION" ]=
CONDITION;
418 elemquality_to_enum[
"DISTORTION" ]=
DISTORTION;
419 elemquality_to_enum[
"TAPER" ]=
TAPER;
420 elemquality_to_enum[
"WARP" ]=
WARP;
421 elemquality_to_enum[
"STRETCH" ]=
STRETCH;
422 elemquality_to_enum[
"DIAGONAL" ]=
DIAGONAL;
425 elemquality_to_enum[
"SIZE" ]=
SIZE;
426 elemquality_to_enum[
"JACOBIAN" ]=
JACOBIAN;
431 INSTANTIATE_ENUM_MAPS(
IOPackage, iopackage)
434 void init_iopackage_to_enum ()
436 if (iopackage_to_enum.empty())
438 iopackage_to_enum[
"TECPLOT" ]=
TECPLOT;
439 iopackage_to_enum[
"GMV" ]=
GMV;
440 iopackage_to_enum[
"GMSH" ]=
GMSH;
441 iopackage_to_enum[
"VTK" ]=
VTK;
442 iopackage_to_enum[
"DIVA" ]=
DIVA;
443 iopackage_to_enum[
"TETGEN" ]=
TETGEN;
444 iopackage_to_enum[
"UCD" ]=
UCD;
445 iopackage_to_enum[
"LIBMESH" ]=
LIBMESH;
453 void init_norm_type_to_enum ()
455 if (norm_type_to_enum.empty())
457 norm_type_to_enum[
"L2" ]=
L2;
458 norm_type_to_enum[
"H1" ]=
H1;
459 norm_type_to_enum[
"H2" ]=
H2;
460 norm_type_to_enum[
"HCURL" ]=
HCURL;
461 norm_type_to_enum[
"HDIV" ]=
HDIV;
463 norm_type_to_enum[
"L1" ]=
L1;
464 norm_type_to_enum[
"L_INF" ]=
L_INF;
490 void init_parallel_type_to_enum ()
492 if (parallel_type_to_enum.empty())
494 parallel_type_to_enum[
"AUTOMATIC" ]=
AUTOMATIC;
495 parallel_type_to_enum[
"SERIAL" ]=
SERIAL;
496 parallel_type_to_enum[
"PARALLEL" ]=
PARALLEL;
497 parallel_type_to_enum[
"GHOSTED" ]=
GHOSTED;
506 void init_point_locator_type_to_enum ()
508 if (point_locator_type_to_enum.empty())
510 point_locator_type_to_enum[
"TREE" ]=
TREE;
519 void init_solverpackage_type_to_enum ()
521 if (solverpackage_type_to_enum.empty())
537 void init_subset_solve_mode_to_enum ()
539 if (subset_solve_mode_to_enum.empty())
541 subset_solve_mode_to_enum[
"SUBSET_ZERO" ]=
SUBSET_ZERO;
548 INSTANTIATE_ENUM_MAPS(
XdrMODE, xdr_mode)
551 void init_xdr_mode_to_enum ()
553 if (xdr_mode_to_enum.empty())
555 xdr_mode_to_enum[
"UNKNOWN" ]=
UNKNOWN;
556 xdr_mode_to_enum[
"ENCODE" ]=
ENCODE;
557 xdr_mode_to_enum[
"DECODE" ]=
DECODE;
558 xdr_mode_to_enum[
"WRITE" ]=
WRITE;
559 xdr_mode_to_enum[
"READ" ]=
READ;
567 void init_linear_convergence_reason_to_enum ()
569 if (linear_convergence_reason_to_enum.empty())
573 linear_convergence_reason_to_enum[
"CONVERGED_RTOL"] =
CONVERGED_RTOL;
574 linear_convergence_reason_to_enum[
"CONVERGED_ATOL"] =
CONVERGED_ATOL;
575 linear_convergence_reason_to_enum[
"CONVERGED_ITS"] =
CONVERGED_ITS;
580 linear_convergence_reason_to_enum[
"DIVERGED_NULL"] =
DIVERGED_NULL;
581 linear_convergence_reason_to_enum[
"DIVERGED_ITS"] =
DIVERGED_ITS;
582 linear_convergence_reason_to_enum[
"DIVERGED_DTOL"] =
DIVERGED_DTOL;
587 linear_convergence_reason_to_enum[
"DIVERGED_NAN"] =
DIVERGED_NAN;
591 linear_convergence_reason_to_enum[
"UNKNOWN_FLAG"] =
UNKNOWN_FLAG;
596 #undef INSTANTIATE_ENUM_MAPS 607 #define INSTANTIATE_STRING_TO_ENUM(ENUM_NAME,VAR_NAME) \ 609 ENUM_NAME string_to_enum<ENUM_NAME> (const std::string & s) \ 611 init_##VAR_NAME##_to_enum(); \ 613 std::string upper(s); \ 614 std::transform(upper.begin(), upper.end(), upper.begin(), ::toupper); \ 616 if (!VAR_NAME##_to_enum.count(upper)) \ 618 libmesh_error_msg("No " #ENUM_NAME " named " + s + " found."); \ 621 return VAR_NAME##_to_enum[upper]; \ 625 std::string enum_to_string<ENUM_NAME> (const ENUM_NAME e) \ 627 init_enum_to_##VAR_NAME (); \ 629 if (!enum_to_##VAR_NAME .count(e)) \ 630 libmesh_error_msg("No " #ENUM_NAME " with enumeration " << e << " found."); \ 632 return enum_to_##VAR_NAME [e]; \ 636 INSTANTIATE_STRING_TO_ENUM(
ElemType,elem_type)
637 INSTANTIATE_STRING_TO_ENUM(
Order,order)
638 INSTANTIATE_STRING_TO_ENUM(
FEFamily,fefamily)
639 INSTANTIATE_STRING_TO_ENUM(
InfMapType,inf_map_type)
643 #ifdef LIBMESH_ENABLE_AMR 645 #endif // LIBMESH_ENABLE_AMR 647 INSTANTIATE_STRING_TO_ENUM(
SolverType,solvertype)
649 INSTANTIATE_STRING_TO_ENUM(
ElemQuality,elemquality)
650 INSTANTIATE_STRING_TO_ENUM(
IOPackage,iopackage)
656 INSTANTIATE_STRING_TO_ENUM(
XdrMODE,xdr_mode)
659 #undef INSTANTIATE_STRING_TO_ENUM