libMesh
string_to_enum.C
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2017 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 // C++ includes
21 #include <algorithm>
22 #include <map>
23 
24 // Local includes
25 #include "libmesh/libmesh_common.h"
26 #include "libmesh/string_to_enum.h"
27 #include "libmesh/enum_convergence_flags.h"
28 #include "libmesh/enum_elem_quality.h"
29 #include "libmesh/enum_elem_type.h"
30 #include "libmesh/enum_eigen_solver_type.h"
31 #include "libmesh/enum_fe_family.h"
32 #include "libmesh/enum_inf_map_type.h"
33 #include "libmesh/enum_io_package.h"
34 #include "libmesh/enum_norm_type.h"
35 #include "libmesh/enum_order.h"
36 #include "libmesh/enum_parallel_type.h"
37 #include "libmesh/enum_point_locator_type.h"
38 #include "libmesh/enum_preconditioner_type.h"
39 #include "libmesh/enum_quadrature_type.h"
40 #include "libmesh/enum_solver_package.h"
41 #include "libmesh/enum_solver_type.h"
42 #include "libmesh/enum_subset_solve_mode.h"
43 #include "libmesh/enum_xdr_mode.h"
44 #include "libmesh/elem.h"
45 
46 namespace libMesh
47 {
48 
49 // ------------------------------------------------------------
50 // Anonymous namespace to hold local data & methods
51 namespace {
52 
53 
54 // Reverse a map
55 template <typename MapIter, class MapType>
56 inline
57 void build_reverse_map (MapIter it, MapIter end, MapType & reverse)
58 {
59  reverse.clear();
60 
61  for (; it != end; ++it)
62  {
63  // If the forward map is not invertible, we might already have
64  // found a preimage of it->second. Choose the "largest"
65  // preimage according to operator<; for std::string this will
66  // give us the longest, hopefully most specific name
67  // corresponding to an enum.
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;
73  }
74 }
75 
76 #define INSTANTIATE_ENUM_MAPS(ENUM_NAME,VAR_NAME) \
77  std::map<std::string, ENUM_NAME> VAR_NAME##_to_enum; \
78  \
79  std::map<ENUM_NAME, std::string> enum_to_##VAR_NAME; \
80  \
81  void init_##VAR_NAME##_to_enum (); \
82  \
83  /* Initialize the enum_to_elem_type on first call */ \
84  void init_enum_to_##VAR_NAME () \
85  { \
86  /* Build reverse map */ \
87  if (enum_to_##VAR_NAME .empty()) \
88  { \
89  /* Initialize elem_type_to_enum on first call */ \
90  init_##VAR_NAME##_to_enum(); \
91  \
92  build_reverse_map (VAR_NAME##_to_enum.begin(), \
93  VAR_NAME##_to_enum.end(), \
94  enum_to_##VAR_NAME); \
95  } \
96  }
97 
98 INSTANTIATE_ENUM_MAPS(ElemType, elem_type)
99 
100 //----------------------------------------------------
101 
102 // Initialize elem_type_to_enum on first call
103 void init_elem_type_to_enum ()
104 {
105  if (elem_type_to_enum.empty())
106  {
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;
111 
112  elem_type_to_enum["TRI" ]=TRI3;
113  elem_type_to_enum["TRI3" ]=TRI3;
114  elem_type_to_enum["TRISHELL3" ]=TRISHELL3;
115  elem_type_to_enum["TRI3SUBDIVISION"]=TRI3SUBDIVISION;
116  elem_type_to_enum["TRI6" ]=TRI6;
117 
118  elem_type_to_enum["QUAD" ]=QUAD4;
119  elem_type_to_enum["QUAD4" ]=QUAD4;
120  elem_type_to_enum["QUADSHELL4" ]=QUADSHELL4;
121  elem_type_to_enum["QUAD8" ]=QUAD8;
122  elem_type_to_enum["QUADSHELL8" ]=QUADSHELL8;
123  elem_type_to_enum["QUAD9" ]=QUAD9;
124 
125  elem_type_to_enum["TET" ]=TET4;
126  elem_type_to_enum["TET4" ]=TET4;
127  elem_type_to_enum["TET10" ]=TET10;
128 
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;
133 
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;
138 
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;
143 
144  elem_type_to_enum["INFEDGE" ]=INFEDGE2;
145  elem_type_to_enum["INFEDGE2" ]=INFEDGE2;
146 
147  elem_type_to_enum["INFQUAD" ]=INFQUAD4;
148  elem_type_to_enum["INFQUAD4" ]=INFQUAD4;
149  elem_type_to_enum["INFQUAD6" ]=INFQUAD6;
150 
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;
155 
156  elem_type_to_enum["INFPRISM" ]=INFPRISM6;
157  elem_type_to_enum["INFPRISM6" ]=INFPRISM6;
158  elem_type_to_enum["INFPRISM12" ]=INFPRISM12;
159 
160  elem_type_to_enum["NODE" ]=NODEELEM;
161  elem_type_to_enum["NODEELEM" ]=NODEELEM;
162 
163  elem_type_to_enum["INVALID_ELEM" ]=INVALID_ELEM;
164  }
165 }
166 
167 
168 INSTANTIATE_ENUM_MAPS(Order, order)
169 
170 // Initialize order_to_enum on first call
171 void init_order_to_enum ()
172 {
173  if (order_to_enum.empty())
174  {
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;
186 
187  order_to_enum["ELEVENTH" ]=ELEVENTH;
188  order_to_enum["TWELFTH" ]=TWELFTH;
189  order_to_enum["THIRTEENTH" ]=THIRTEENTH;
190  order_to_enum["FOURTEENTH" ]=FOURTEENTH;
191  order_to_enum["FIFTEENTH" ]=FIFTEENTH;
192  order_to_enum["SIXTEENTH" ]=SIXTEENTH;
193  order_to_enum["SEVENTEENTH" ]=SEVENTEENTH;
194  order_to_enum["EIGHTTEENTH" ]=EIGHTTEENTH;
195  order_to_enum["NINTEENTH" ]=NINTEENTH; // deprecated
196  order_to_enum["NINETEENTH" ]=NINETEENTH;
197  order_to_enum["TWENTIETH" ]=TWENTIETH;
198 
199  order_to_enum["TWENTYFIRST" ]=TWENTYFIRST;
200  order_to_enum["TWENTYSECOND" ]=TWENTYSECOND;
201  order_to_enum["TWENTYTHIRD" ]=TWENTYTHIRD;
202  order_to_enum["TWENTYFOURTH" ]=TWENTYFOURTH;
203  order_to_enum["TWENTYFIFTH" ]=TWENTYFIFTH;
204  order_to_enum["TWENTYSIXTH" ]=TWENTYSIXTH;
205  order_to_enum["TWENTYSEVENTH"]=TWENTYSEVENTH;
206  order_to_enum["TWENTYEIGHTH" ]=TWENTYEIGHTH;
207  order_to_enum["TWENTYNINTH" ]=TWENTYNINTH;
208  order_to_enum["THIRTIETH" ]=THIRTIETH;
209 
210  order_to_enum["THIRTYFIRST" ]=THIRTYFIRST;
211  order_to_enum["THIRTYSECOND" ]=THIRTYSECOND;
212  order_to_enum["THIRTYTHIRD" ]=THIRTYTHIRD;
213  order_to_enum["THIRTYFOURTH" ]=THIRTYFOURTH;
214  order_to_enum["THIRTYFIFTH" ]=THIRTYFIFTH;
215  order_to_enum["THIRTYSIXTH" ]=THIRTYSIXTH;
216  order_to_enum["THIRTYSEVENTH"]=THIRTYSEVENTH;
217  order_to_enum["THIRTYEIGHTH" ]=THIRTYEIGHTH;
218  order_to_enum["THIRTYNINTH" ]=THIRTYNINTH;
219  order_to_enum["FORTIETH" ]=FORTIETH;
220 
221  order_to_enum["FORTYFIRST" ]=FORTYFIRST;
222  order_to_enum["FORTYSECOND" ]=FORTYSECOND;
223  order_to_enum["FORTYTHIRD" ]=FORTYTHIRD;
224  }
225 }
226 
227 
228 
229 INSTANTIATE_ENUM_MAPS(FEFamily, fefamily)
230 
231 // Initialize fefamily_to_enum on first call
232 void init_fefamily_to_enum ()
233 {
234  if (fefamily_to_enum.empty())
235  {
236  fefamily_to_enum["LAGRANGE" ]=LAGRANGE;
237  fefamily_to_enum["LAGRANGE_VEC" ]=LAGRANGE_VEC;
238  fefamily_to_enum["L2_LAGRANGE" ]=L2_LAGRANGE;
239  fefamily_to_enum["HIERARCHIC" ]=HIERARCHIC;
240  fefamily_to_enum["L2_HIERARCHIC"]=L2_HIERARCHIC;
241  fefamily_to_enum["MONOMIAL" ]=MONOMIAL;
242  fefamily_to_enum["SCALAR" ]=SCALAR;
243  fefamily_to_enum["XYZ" ]=XYZ;
244  fefamily_to_enum["BERNSTEIN" ]=BERNSTEIN;
245  fefamily_to_enum["SZABAB" ]=SZABAB;
246  fefamily_to_enum["INFINITE_MAP" ]=INFINITE_MAP;
247  fefamily_to_enum["JACOBI_20_00" ]=JACOBI_20_00;
248  fefamily_to_enum["JACOBI_30_00" ]=JACOBI_30_00;
249  fefamily_to_enum["LEGENDRE" ]=LEGENDRE;
250  fefamily_to_enum["CLOUGH" ]=CLOUGH;
251  fefamily_to_enum["HERMITE" ]=HERMITE;
252  fefamily_to_enum["SUBDIVISION" ]=SUBDIVISION;
253  fefamily_to_enum["NEDELEC_ONE" ]=NEDELEC_ONE;
254  }
255 
256 }
257 
258 
259 
260 INSTANTIATE_ENUM_MAPS(InfMapType, inf_map_type)
261 
262 // Initialize inf_map_type_to_enum on first call
263 void init_inf_map_type_to_enum ()
264 {
265  if (inf_map_type_to_enum.empty())
266  {
267  inf_map_type_to_enum["CARTESIAN" ]=CARTESIAN;
268  inf_map_type_to_enum["SPHERICAL" ]=SPHERICAL;
269  inf_map_type_to_enum["ELLIPSOIDAL"]=ELLIPSOIDAL;
270  }
271 }
272 
273 
274 INSTANTIATE_ENUM_MAPS(QuadratureType, quadrature_type)
275 
276 // Initialize quadrature_type_to_enum on first call
277 void init_quadrature_type_to_enum ()
278 {
279  if (quadrature_type_to_enum.empty())
280  {
281  quadrature_type_to_enum["QGAUSS" ]=QGAUSS;
282  quadrature_type_to_enum["QJACOBI_1_0"]=QJACOBI_1_0;
283  quadrature_type_to_enum["QJACOBI_2_0"]=QJACOBI_2_0;
284  quadrature_type_to_enum["QSIMPSON" ]=QSIMPSON;
285  quadrature_type_to_enum["QTRAP" ]=QTRAP;
286  quadrature_type_to_enum["QGRID" ]=QGRID;
287  quadrature_type_to_enum["QCLOUGH" ]=QCLOUGH;
288  quadrature_type_to_enum["QGAUSS_LOBATTO" ]=QGAUSS_LOBATTO;
289  }
290 }
291 
292 
293 INSTANTIATE_ENUM_MAPS(PreconditionerType, preconditioner_type)
294 
295 // Initialize preconditioner_type_to_enum on first call
296 void init_preconditioner_type_to_enum ()
297 {
298  if (preconditioner_type_to_enum.empty())
299  {
300  preconditioner_type_to_enum["IDENTITY_PRECOND" ]=IDENTITY_PRECOND;
301  preconditioner_type_to_enum["JACOBI_PRECOND" ]=JACOBI_PRECOND;
302  preconditioner_type_to_enum["BLOCK_JACOBI_PRECOND" ]=BLOCK_JACOBI_PRECOND;
303  preconditioner_type_to_enum["SOR_PRECOND" ]=SOR_PRECOND;
304  preconditioner_type_to_enum["SSOR_PRECOND" ]=SSOR_PRECOND;
305  preconditioner_type_to_enum["EISENSTAT_PRECOND" ]=EISENSTAT_PRECOND;
306  preconditioner_type_to_enum["ASM_PRECOND" ]=ASM_PRECOND;
307  preconditioner_type_to_enum["CHOLESKY_PRECOND" ]=CHOLESKY_PRECOND;
308  preconditioner_type_to_enum["ICC_PRECOND" ]=ICC_PRECOND;
309  preconditioner_type_to_enum["ILU_PRECOND" ]=ILU_PRECOND;
310  preconditioner_type_to_enum["LU_PRECOND" ]=LU_PRECOND;
311  preconditioner_type_to_enum["USER_PRECOND" ]=USER_PRECOND;
312  preconditioner_type_to_enum["SHELL_PRECOND" ]=SHELL_PRECOND;
313  preconditioner_type_to_enum["AMG_PRECOND" ]=AMG_PRECOND;
314  preconditioner_type_to_enum["INVALID_PRECONDITIONER"]=INVALID_PRECONDITIONER;
315 
316  //shorter
317  preconditioner_type_to_enum["IDENTITY" ]=IDENTITY_PRECOND;
318  preconditioner_type_to_enum["JACOBI" ]=JACOBI_PRECOND;
319  preconditioner_type_to_enum["BLOCK_JACOBI"]=BLOCK_JACOBI_PRECOND;
320  preconditioner_type_to_enum["SOR" ]=SOR_PRECOND;
321  preconditioner_type_to_enum["SSOR" ]=SSOR_PRECOND;
322  preconditioner_type_to_enum["EISENSTAT" ]=EISENSTAT_PRECOND;
323  preconditioner_type_to_enum["ASM" ]=ASM_PRECOND;
324  preconditioner_type_to_enum["CHOLESKY" ]=CHOLESKY_PRECOND;
325  preconditioner_type_to_enum["ICC" ]=ICC_PRECOND;
326  preconditioner_type_to_enum["ILU" ]=ILU_PRECOND;
327  preconditioner_type_to_enum["LU" ]=LU_PRECOND;
328  preconditioner_type_to_enum["USER" ]=USER_PRECOND;
329  preconditioner_type_to_enum["SHELL" ]=SHELL_PRECOND;
330  preconditioner_type_to_enum["AMG" ]=AMG_PRECOND;
331  preconditioner_type_to_enum["INVALID" ]=INVALID_PRECONDITIONER;
332  }
333 }
334 
335 
336 #ifdef LIBMESH_ENABLE_AMR
337 
338 INSTANTIATE_ENUM_MAPS(Elem::RefinementState, refinementstate_type)
339 
340 // Initialize refinementstate_type_to_enum on first call
341 void init_refinementstate_type_to_enum ()
342 {
343  if (refinementstate_type_to_enum.empty())
344  {
345  refinementstate_type_to_enum["COARSEN" ]=Elem::COARSEN;
346  refinementstate_type_to_enum["DO_NOTHING" ]=Elem::DO_NOTHING;
347  refinementstate_type_to_enum["REFINE" ]=Elem::REFINE;
348  refinementstate_type_to_enum["JUST_REFINED" ]=Elem::JUST_REFINED;
349  refinementstate_type_to_enum["JUST_COARSENED" ]=Elem::JUST_COARSENED;
350  refinementstate_type_to_enum["INACTIVE" ]=Elem::INACTIVE;
351  refinementstate_type_to_enum["COARSEN_INACTIVE" ]=Elem::COARSEN_INACTIVE;
352  refinementstate_type_to_enum["INVALID_REFINEMENTSTATE"]=Elem::INVALID_REFINEMENTSTATE;
353  }
354 }
355 #endif // LIBMESH_ENABLE_AMR
356 
357 
358 INSTANTIATE_ENUM_MAPS(EigenSolverType, eigensolvertype)
359 
360 // Initialize eigensolvertype_to_enum on first call
361 void init_eigensolvertype_to_enum ()
362 {
363  if (eigensolvertype_to_enum.empty())
364  {
365  eigensolvertype_to_enum["POWER" ]=POWER;
366  eigensolvertype_to_enum["LAPACK" ]=LAPACK;
367  eigensolvertype_to_enum["SUBSPACE" ]=SUBSPACE;
368  eigensolvertype_to_enum["ARNOLDI" ]=ARNOLDI;
369  eigensolvertype_to_enum["LANCZOS" ]=LANCZOS;
370  eigensolvertype_to_enum["KRYLOVSCHUR" ]=KRYLOVSCHUR;
371  eigensolvertype_to_enum["INVALID_EIGENSOLVER"]=INVALID_EIGENSOLVER;
372  }
373 }
374 
375 
376 INSTANTIATE_ENUM_MAPS(SolverType, solvertype)
377 
378 // Initialize solvertype_to_enum on first call
379 void init_solvertype_to_enum ()
380 {
381  if (solvertype_to_enum.empty())
382  {
383  solvertype_to_enum["CG" ]=CG;
384  solvertype_to_enum["CGN" ]=CGN;
385  solvertype_to_enum["CGS" ]=CGS;
386  solvertype_to_enum["CR" ]=CR;
387  solvertype_to_enum["QMR" ]=QMR;
388  solvertype_to_enum["TCQMR" ]=TCQMR;
389  solvertype_to_enum["TFQMR" ]=TFQMR;
390  solvertype_to_enum["BICG" ]=BICG;
391  solvertype_to_enum["MINRES" ]=MINRES;
392  solvertype_to_enum["GMRES" ]=GMRES;
393  solvertype_to_enum["LSQR" ]=LSQR;
394  solvertype_to_enum["JACOBI" ]=JACOBI;
395  solvertype_to_enum["SOR_FORWARD" ]=SOR_FORWARD;
396  solvertype_to_enum["SOR_BACKWARD" ]=SOR_BACKWARD;
397  solvertype_to_enum["SSOR" ]=SSOR;
398  solvertype_to_enum["RICHARDSON" ]=RICHARDSON;
399  solvertype_to_enum["CHEBYSHEV" ]=CHEBYSHEV;
400  solvertype_to_enum["INVALID_SOLVER"]=INVALID_SOLVER;
401  }
402 }
403 
404 
405 INSTANTIATE_ENUM_MAPS(ElemQuality, elemquality)
406 
407 // Initialize elemquality_to_enum on first call
408 void init_elemquality_to_enum ()
409 {
410  if (elemquality_to_enum.empty())
411  {
412  elemquality_to_enum["ASPECT_RATIO" ]=ASPECT_RATIO;
413  elemquality_to_enum["SKEW" ]=SKEW;
414  elemquality_to_enum["SHEAR" ]=SHEAR;
415  elemquality_to_enum["SHAPE" ]=SHAPE;
416  elemquality_to_enum["MAX_ANGLE" ]=MAX_ANGLE;
417  elemquality_to_enum["MIN_ANGLE" ]=MIN_ANGLE;
418  elemquality_to_enum["CONDITION" ]=CONDITION;
419  elemquality_to_enum["DISTORTION" ]=DISTORTION;
420  elemquality_to_enum["TAPER" ]=TAPER;
421  elemquality_to_enum["WARP" ]=WARP;
422  elemquality_to_enum["STRETCH" ]=STRETCH;
423  elemquality_to_enum["DIAGONAL" ]=DIAGONAL;
424  elemquality_to_enum["ASPECT_RATIO_BETA" ]=ASPECT_RATIO_BETA;
425  elemquality_to_enum["ASPECT_RATIO_GAMMA" ]=ASPECT_RATIO_GAMMA;
426  elemquality_to_enum["SIZE" ]=SIZE;
427  elemquality_to_enum["JACOBIAN" ]=JACOBIAN;
428  }
429 }
430 
431 
432 INSTANTIATE_ENUM_MAPS(IOPackage, iopackage)
433 
434 // Initialize iopackage_to_enum on first call
435 void init_iopackage_to_enum ()
436 {
437  if (iopackage_to_enum.empty())
438  {
439  iopackage_to_enum["TECPLOT" ]=TECPLOT;
440  iopackage_to_enum["GMV" ]=GMV;
441  iopackage_to_enum["GMSH" ]=GMSH;
442  iopackage_to_enum["VTK" ]=VTK;
443  iopackage_to_enum["DIVA" ]=DIVA;
444  iopackage_to_enum["TETGEN" ]=TETGEN;
445  iopackage_to_enum["UCD" ]=UCD;
446  iopackage_to_enum["LIBMESH" ]=LIBMESH;
447  }
448 }
449 
450 
451 INSTANTIATE_ENUM_MAPS(FEMNormType, norm_type)
452 
453 // Initialize norm_type_to_enum on first call
454 void init_norm_type_to_enum ()
455 {
456  if (norm_type_to_enum.empty())
457  {
458  norm_type_to_enum["L2" ]=L2;
459  norm_type_to_enum["H1" ]=H1;
460  norm_type_to_enum["H2" ]=H2;
461  norm_type_to_enum["HCURL" ]=HCURL;
462  norm_type_to_enum["HDIV" ]=HDIV;
463 
464  norm_type_to_enum["L1" ]=L1;
465  norm_type_to_enum["L_INF" ]=L_INF;
466 
467  norm_type_to_enum["H1_SEMINORM" ]=H1_SEMINORM;
468  norm_type_to_enum["H2_SEMINORM" ]=H2_SEMINORM;
469  norm_type_to_enum["HCURL_SEMINORM" ]=HCURL_SEMINORM;
470  norm_type_to_enum["HDIV_SEMINORM" ]=HDIV_SEMINORM;
471 
472  norm_type_to_enum["W1_INF_SEMINORM" ]=W1_INF_SEMINORM;
473  norm_type_to_enum["W2_INF_SEMINORM" ]=W2_INF_SEMINORM;
474 
475  norm_type_to_enum["DISCRETE_L1" ]=DISCRETE_L1;
476  norm_type_to_enum["DISCRETE_L2" ]=DISCRETE_L2;
477  norm_type_to_enum["DISCRETE_L_INF" ]=DISCRETE_L_INF;
478 
479  norm_type_to_enum["H1_X_SEMINORM" ]=H1_X_SEMINORM;
480  norm_type_to_enum["H1_Y_SEMINORM" ]=H1_Y_SEMINORM;
481  norm_type_to_enum["H1_Z_SEMINORM" ]=H1_Z_SEMINORM;
482 
483  norm_type_to_enum["INVALID_NORM" ]=INVALID_NORM;
484  }
485 }
486 
487 
488 INSTANTIATE_ENUM_MAPS(ParallelType, parallel_type)
489 
490 // Initialize parallel_type_to_enum on first call
491 void init_parallel_type_to_enum ()
492 {
493  if (parallel_type_to_enum.empty())
494  {
495  parallel_type_to_enum["AUTOMATIC" ]=AUTOMATIC;
496  parallel_type_to_enum["SERIAL" ]=SERIAL;
497  parallel_type_to_enum["PARALLEL" ]=PARALLEL;
498  parallel_type_to_enum["GHOSTED" ]=GHOSTED;
499  parallel_type_to_enum["INVALID_PARALLELIZATION" ]=INVALID_PARALLELIZATION;
500  }
501 }
502 
503 
504 INSTANTIATE_ENUM_MAPS(PointLocatorType, point_locator_type)
505 
506 // Initialize point_locator_type_to_enum on first call
507 void init_point_locator_type_to_enum ()
508 {
509  if (point_locator_type_to_enum.empty())
510  {
511  point_locator_type_to_enum["TREE" ]=TREE;
512  point_locator_type_to_enum["INVALID_LOCATOR" ]=INVALID_LOCATOR;
513  }
514 }
515 
516 
517 INSTANTIATE_ENUM_MAPS(SolverPackage, solverpackage_type)
518 
519 // Initialize solverpackage_type_to_enum on first call
520 void init_solverpackage_type_to_enum ()
521 {
522  if (solverpackage_type_to_enum.empty())
523  {
524  solverpackage_type_to_enum["PETSC_SOLVERS" ]=PETSC_SOLVERS;
525  solverpackage_type_to_enum["TRILINOS_SOLVERS" ]=TRILINOS_SOLVERS;
526  solverpackage_type_to_enum["LASPACK_SOLVERS" ]=LASPACK_SOLVERS;
527  solverpackage_type_to_enum["SLEPC_SOLVERS" ]=SLEPC_SOLVERS;
528  solverpackage_type_to_enum["EIGEN_SOLVERS" ]=EIGEN_SOLVERS;
529  solverpackage_type_to_enum["NLOPT_SOLVERS" ]=NLOPT_SOLVERS;
530  solverpackage_type_to_enum["INVALID_SOLVER_PACKAGE" ]=INVALID_SOLVER_PACKAGE;
531  }
532 }
533 
534 
535 INSTANTIATE_ENUM_MAPS(SubsetSolveMode, subset_solve_mode)
536 
537 // Initialize subset_solve_mode_to_enum on first call
538 void init_subset_solve_mode_to_enum ()
539 {
540  if (subset_solve_mode_to_enum.empty())
541  {
542  subset_solve_mode_to_enum["SUBSET_ZERO" ]=SUBSET_ZERO;
543  subset_solve_mode_to_enum["SUBSET_COPY_RHS" ]=SUBSET_COPY_RHS;
544  subset_solve_mode_to_enum["SUBSET_DONT_TOUCH" ]=SUBSET_DONT_TOUCH;
545  }
546 }
547 
548 
549 INSTANTIATE_ENUM_MAPS(XdrMODE, xdr_mode)
550 
551 // Initialize xdr_mode_to_enum on first call
552 void init_xdr_mode_to_enum ()
553 {
554  if (xdr_mode_to_enum.empty())
555  {
556  xdr_mode_to_enum["UNKNOWN" ]=UNKNOWN;
557  xdr_mode_to_enum["ENCODE" ]=ENCODE;
558  xdr_mode_to_enum["DECODE" ]=DECODE;
559  xdr_mode_to_enum["WRITE" ]=WRITE;
560  xdr_mode_to_enum["READ" ]=READ;
561  }
562 }
563 
564 
565 INSTANTIATE_ENUM_MAPS(LinearConvergenceReason, linear_convergence_reason)
566 
567 // Initialize xdr_mode_to_enum on first call
568 void init_linear_convergence_reason_to_enum ()
569 {
570  if (linear_convergence_reason_to_enum.empty())
571  {
572  linear_convergence_reason_to_enum["CONVERGED_RTOL_NORMAL"] = CONVERGED_RTOL_NORMAL;
573  linear_convergence_reason_to_enum["CONVERGED_ATOL_NORMAL"] = CONVERGED_ATOL_NORMAL;
574  linear_convergence_reason_to_enum["CONVERGED_RTOL"] = CONVERGED_RTOL;
575  linear_convergence_reason_to_enum["CONVERGED_ATOL"] = CONVERGED_ATOL;
576  linear_convergence_reason_to_enum["CONVERGED_ITS"] = CONVERGED_ITS;
577  linear_convergence_reason_to_enum["CONVERGED_CG_NEG_CURVE"] = CONVERGED_CG_NEG_CURVE;
578  linear_convergence_reason_to_enum["CONVERGED_CG_CONSTRAINED"] = CONVERGED_CG_CONSTRAINED;
579  linear_convergence_reason_to_enum["CONVERGED_STEP_LENGTH"] = CONVERGED_STEP_LENGTH;
580  linear_convergence_reason_to_enum["CONVERGED_HAPPY_BREAKDOWN"] = CONVERGED_HAPPY_BREAKDOWN;
581  linear_convergence_reason_to_enum["DIVERGED_NULL"] = DIVERGED_NULL;
582  linear_convergence_reason_to_enum["DIVERGED_ITS"] = DIVERGED_ITS;
583  linear_convergence_reason_to_enum["DIVERGED_DTOL"] = DIVERGED_DTOL;
584  linear_convergence_reason_to_enum["DIVERGED_BREAKDOWN"] = DIVERGED_BREAKDOWN;
585  linear_convergence_reason_to_enum["DIVERGED_BREAKDOWN_BICG"] = DIVERGED_BREAKDOWN_BICG;
586  linear_convergence_reason_to_enum["DIVERGED_NONSYMMETRIC"] = DIVERGED_NONSYMMETRIC;
587  linear_convergence_reason_to_enum["DIVERGED_INDEFINITE_PC"] = DIVERGED_INDEFINITE_PC;
588  linear_convergence_reason_to_enum["DIVERGED_NAN"] = DIVERGED_NAN;
589  linear_convergence_reason_to_enum["DIVERGED_INDEFINITE_MAT"] = DIVERGED_INDEFINITE_MAT;
590  linear_convergence_reason_to_enum["DIVERGED_PCSETUP_FAILED"] = DIVERGED_PCSETUP_FAILED;
591  linear_convergence_reason_to_enum["CONVERGED_ITERATING"] = CONVERGED_ITERATING;
592  linear_convergence_reason_to_enum["UNKNOWN_FLAG"] = UNKNOWN_FLAG;
593  }
594 }
595 
596 
597 #undef INSTANTIATE_ENUM_MAPS
598 
599 } // end anonymous namespace
600 
601 
602 
603 // ------------------------------------------------------
604 // Utility::string_to_enum<> & Utility::enum_to_string<>
605 // full specializations
606 namespace Utility {
607 
608 #define INSTANTIATE_STRING_TO_ENUM(ENUM_NAME,VAR_NAME) \
609  template <> \
610  ENUM_NAME string_to_enum<ENUM_NAME> (const std::string & s) \
611  { \
612  init_##VAR_NAME##_to_enum(); \
613  \
614  std::string upper(s); \
615  std::transform(upper.begin(), upper.end(), upper.begin(), ::toupper); \
616  \
617  if (!VAR_NAME##_to_enum.count(upper)) \
618  { \
619  libmesh_error_msg("No " #ENUM_NAME " named " + s + " found."); \
620  } \
621  \
622  return VAR_NAME##_to_enum[upper]; \
623  } \
624  \
625  template <> \
626  std::string enum_to_string<ENUM_NAME> (const ENUM_NAME e) \
627  { \
628  init_enum_to_##VAR_NAME (); \
629  \
630  if (!enum_to_##VAR_NAME .count(e)) \
631  libmesh_error_msg("No " #ENUM_NAME " with enumeration " << e << " found."); \
632  \
633  return enum_to_##VAR_NAME [e]; \
634  }
635 
636 
637 INSTANTIATE_STRING_TO_ENUM(ElemType,elem_type)
638 INSTANTIATE_STRING_TO_ENUM(Order,order)
639 INSTANTIATE_STRING_TO_ENUM(FEFamily,fefamily)
640 INSTANTIATE_STRING_TO_ENUM(InfMapType,inf_map_type)
641 INSTANTIATE_STRING_TO_ENUM(QuadratureType,quadrature_type)
642 INSTANTIATE_STRING_TO_ENUM(PreconditionerType,preconditioner_type)
643 
644 #ifdef LIBMESH_ENABLE_AMR
645 INSTANTIATE_STRING_TO_ENUM(Elem::RefinementState,refinementstate_type)
646 #endif // LIBMESH_ENABLE_AMR
647 
648 INSTANTIATE_STRING_TO_ENUM(SolverType,solvertype)
649 INSTANTIATE_STRING_TO_ENUM(EigenSolverType,eigensolvertype)
650 INSTANTIATE_STRING_TO_ENUM(ElemQuality,elemquality)
651 INSTANTIATE_STRING_TO_ENUM(IOPackage,iopackage)
652 INSTANTIATE_STRING_TO_ENUM(FEMNormType, norm_type)
653 INSTANTIATE_STRING_TO_ENUM(ParallelType, parallel_type)
654 INSTANTIATE_STRING_TO_ENUM(PointLocatorType, point_locator_type)
655 INSTANTIATE_STRING_TO_ENUM(SolverPackage,solverpackage_type)
656 INSTANTIATE_STRING_TO_ENUM(SubsetSolveMode,subset_solve_mode)
657 INSTANTIATE_STRING_TO_ENUM(XdrMODE,xdr_mode)
658 INSTANTIATE_STRING_TO_ENUM(LinearConvergenceReason, linear_convergence_reason)
659 
660 #undef INSTANTIATE_STRING_TO_ENUM
661 
662 } // namespace Utility
663 
664 } // namespace libMesh
QuadratureType
Defines an enum for currently available quadrature rules.
SolverType
Defines an enum for iterative solver types.
Leaves dofs outside the subset unchanged. This is fastest, but also most confusing because it abandon...
Set dofs outside the subset to zero.
ElemType
Defines an enum for geometric element 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.
RefinementState
Enumeration of possible element refinement states.
Definition: elem.h:1125
IterBase * end
Also have a polymorphic pointer to the end object, this prevents iterating past the end...
The libMesh namespace provides an interface to certain functionality in the library.
InfMapType
defines an enum for the types of coordinate mappings available in infinite elements.
PreconditionerType
Defines an enum for preconditioner types.
FEFamily
defines an enum for finite element families.
ParallelType
Defines an enum for parallel data structure types.
XdrMODE
Defines an enum for read/write mode in Xdr format.
Definition: enum_xdr_mode.h:32
Set dofs outside the subset to the value of the corresponding dofs of the right hand side...
Order
defines an enum for polynomial orders.
Definition: enum_order.h:32
LinearConvergenceReason
Linear solver convergence flags (taken from the PETSc flags)
SubsetSolveMode
defines an enum for the question what happens to the dofs outside the given subset when a system is s...
ElemQuality
Defines an enum for element quality metrics.
EigenSolverType
Defines an enum for iterative eigenproblem solver types.
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