$extrastylesheet
00001 // The libMesh Finite Element Library. 00002 // Copyright (C) 2002-2014 Benjamin S. Kirk, John W. Peterson, Roy H. Stogner 00003 00004 // This library is free software; you can redistribute it and/or 00005 // modify it under the terms of the GNU Lesser General Public 00006 // License as published by the Free Software Foundation; either 00007 // version 2.1 of the License, or (at your option) any later version. 00008 00009 // This library is distributed in the hope that it will be useful, 00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 // Lesser General Public License for more details. 00013 00014 // You should have received a copy of the GNU Lesser General Public 00015 // License along with this library; if not, write to the Free Software 00016 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00017 00018 00019 00020 // C++ includes 00021 #include <algorithm> 00022 #include <map> 00023 00024 // Local includes 00025 #include "libmesh/libmesh_common.h" 00026 #include "libmesh/string_to_enum.h" 00027 #include "libmesh/enum_convergence_flags.h" 00028 #include "libmesh/enum_elem_quality.h" 00029 #include "libmesh/enum_elem_type.h" 00030 #include "libmesh/enum_eigen_solver_type.h" 00031 #include "libmesh/enum_fe_family.h" 00032 #include "libmesh/enum_inf_map_type.h" 00033 #include "libmesh/enum_io_package.h" 00034 #include "libmesh/enum_norm_type.h" 00035 #include "libmesh/enum_order.h" 00036 #include "libmesh/enum_parallel_type.h" 00037 #include "libmesh/enum_point_locator_type.h" 00038 #include "libmesh/enum_preconditioner_type.h" 00039 #include "libmesh/enum_quadrature_type.h" 00040 #include "libmesh/enum_solver_package.h" 00041 #include "libmesh/enum_solver_type.h" 00042 #include "libmesh/enum_subset_solve_mode.h" 00043 #include "libmesh/enum_xdr_mode.h" 00044 #include "libmesh/elem.h" 00045 00046 namespace libMesh 00047 { 00048 00049 // ------------------------------------------------------------ 00050 // Anonymous namespace to hold local data & methods 00051 namespace { 00052 00053 00054 // Reverse a map 00055 template <typename MapIter, class MapType> 00056 inline 00057 void build_reverse_map (MapIter it, MapIter end, MapType& reverse) 00058 { 00059 reverse.clear(); 00060 00061 for (; it != end; ++it) 00062 { 00063 // If the forward map is not invertible, we might already have 00064 // found a preimage of it->second. Choose the "largest" 00065 // preimage according to operator<; for std::string this will 00066 // give us the longest, hopefully most specific name 00067 // corresponding to an enum. 00068 typename MapType::iterator preimage = reverse.find(it->second); 00069 if (preimage == reverse.end()) 00070 reverse.insert (std::make_pair(it->second, it->first)); 00071 else if (preimage->second < it->first) 00072 preimage->second = it->first; 00073 } 00074 } 00075 00076 #define INSTANTIATE_ENUM_MAPS(ENUM_NAME,VAR_NAME) \ 00077 std::map<std::string, ENUM_NAME> VAR_NAME##_to_enum; \ 00078 \ 00079 std::map<ENUM_NAME, std::string> enum_to_##VAR_NAME; \ 00080 \ 00081 void init_##VAR_NAME##_to_enum (); \ 00082 \ 00083 /* Initialize the enum_to_elem_type on first call */ \ 00084 void init_enum_to_##VAR_NAME () \ 00085 { \ 00086 /* Build reverse map */ \ 00087 if (enum_to_##VAR_NAME .empty()) \ 00088 { \ 00089 /* Initialize elem_type_to_enum on first call */ \ 00090 init_##VAR_NAME##_to_enum(); \ 00091 \ 00092 build_reverse_map (VAR_NAME##_to_enum.begin(), \ 00093 VAR_NAME##_to_enum.end(), \ 00094 enum_to_##VAR_NAME); \ 00095 } \ 00096 } 00097 00098 INSTANTIATE_ENUM_MAPS(ElemType, elem_type) 00099 00100 //---------------------------------------------------- 00101 00102 // Initialize elem_type_to_enum on first call 00103 void init_elem_type_to_enum () 00104 { 00105 if (elem_type_to_enum.empty()) 00106 { 00107 elem_type_to_enum["EDGE" ]=EDGE2; 00108 elem_type_to_enum["EDGE2" ]=EDGE2; 00109 elem_type_to_enum["EDGE3" ]=EDGE3; 00110 elem_type_to_enum["EDGE4" ]=EDGE4; 00111 00112 elem_type_to_enum["TRI" ]=TRI3; 00113 elem_type_to_enum["TRI3" ]=TRI3; 00114 elem_type_to_enum["TRI3SUBDIVISION"]=TRI3SUBDIVISION; 00115 elem_type_to_enum["TRI6" ]=TRI6; 00116 00117 elem_type_to_enum["QUAD" ]=QUAD4; 00118 elem_type_to_enum["QUAD4" ]=QUAD4; 00119 elem_type_to_enum["QUAD8" ]=QUAD8; 00120 elem_type_to_enum["QUAD9" ]=QUAD9; 00121 00122 elem_type_to_enum["TET" ]=TET4; 00123 elem_type_to_enum["TET4" ]=TET4; 00124 elem_type_to_enum["TET10" ]=TET10; 00125 00126 elem_type_to_enum["HEX" ]=HEX8; 00127 elem_type_to_enum["HEX8" ]=HEX8; 00128 elem_type_to_enum["HEX20" ]=HEX20; 00129 elem_type_to_enum["HEX27" ]=HEX27; 00130 00131 elem_type_to_enum["PRISM" ]=PRISM6; 00132 elem_type_to_enum["PRISM6" ]=PRISM6; 00133 elem_type_to_enum["PRISM15" ]=PRISM15; 00134 elem_type_to_enum["PRISM18" ]=PRISM18; 00135 00136 elem_type_to_enum["PYRAMID" ]=PYRAMID5; 00137 elem_type_to_enum["PYRAMID5" ]=PYRAMID5; 00138 elem_type_to_enum["PYRAMID13" ]=PYRAMID13; 00139 elem_type_to_enum["PYRAMID14" ]=PYRAMID14; 00140 00141 elem_type_to_enum["INFEDGE" ]=INFEDGE2; 00142 elem_type_to_enum["INFEDGE2" ]=INFEDGE2; 00143 00144 elem_type_to_enum["INFQUAD" ]=INFQUAD4; 00145 elem_type_to_enum["INFQUAD4" ]=INFQUAD4; 00146 elem_type_to_enum["INFQUAD6" ]=INFQUAD6; 00147 00148 elem_type_to_enum["INFHEX" ]=INFHEX8; 00149 elem_type_to_enum["INFHEX8" ]=INFHEX8; 00150 elem_type_to_enum["INFHEX16" ]=INFHEX16; 00151 elem_type_to_enum["INFHEX18" ]=INFHEX18; 00152 00153 elem_type_to_enum["INFPRISM" ]=INFPRISM6; 00154 elem_type_to_enum["INFPRISM6" ]=INFPRISM6; 00155 elem_type_to_enum["INFPRISM12" ]=INFPRISM12; 00156 00157 elem_type_to_enum["NODE" ]=NODEELEM; 00158 elem_type_to_enum["NODEELEM" ]=NODEELEM; 00159 00160 elem_type_to_enum["INVALID_ELEM" ]=INVALID_ELEM; 00161 } 00162 } 00163 00164 00165 INSTANTIATE_ENUM_MAPS(Order, order) 00166 00167 // Initialize order_to_enum on first call 00168 void init_order_to_enum () 00169 { 00170 if (order_to_enum.empty()) 00171 { 00172 order_to_enum["CONSTANT" ]=CONSTANT; 00173 order_to_enum["FIRST" ]=FIRST; 00174 order_to_enum["SECOND" ]=SECOND; 00175 order_to_enum["THIRD" ]=THIRD; 00176 order_to_enum["FOURTH" ]=FOURTH; 00177 order_to_enum["FIFTH" ]=FIFTH; 00178 order_to_enum["SIXTH" ]=SIXTH; 00179 order_to_enum["SEVENTH" ]=SEVENTH; 00180 order_to_enum["EIGHTH" ]=EIGHTH; 00181 order_to_enum["NINTH" ]=NINTH; 00182 order_to_enum["TENTH" ]=TENTH; 00183 00184 order_to_enum["ELEVENTH" ]=ELEVENTH; 00185 order_to_enum["TWELFTH" ]=TWELFTH; 00186 order_to_enum["THIRTEENTH" ]=THIRTEENTH; 00187 order_to_enum["FOURTEENTH" ]=FOURTEENTH; 00188 order_to_enum["FIFTEENTH" ]=FIFTEENTH; 00189 order_to_enum["SIXTEENTH" ]=SIXTEENTH; 00190 order_to_enum["SEVENTEENTH" ]=SEVENTEENTH; 00191 order_to_enum["EIGHTTEENTH" ]=EIGHTTEENTH; 00192 order_to_enum["NINTEENTH" ]=NINTEENTH; // deprecated 00193 order_to_enum["NINETEENTH" ]=NINETEENTH; 00194 order_to_enum["TWENTIETH" ]=TWENTIETH; 00195 00196 order_to_enum["TWENTYFIRST" ]=TWENTYFIRST; 00197 order_to_enum["TWENTYSECOND" ]=TWENTYSECOND; 00198 order_to_enum["TWENTYTHIRD" ]=TWENTYTHIRD; 00199 order_to_enum["TWENTYFOURTH" ]=TWENTYFOURTH; 00200 order_to_enum["TWENTYFIFTH" ]=TWENTYFIFTH; 00201 order_to_enum["TWENTYSIXTH" ]=TWENTYSIXTH; 00202 order_to_enum["TWENTYSEVENTH"]=TWENTYSEVENTH; 00203 order_to_enum["TWENTYEIGHTH" ]=TWENTYEIGHTH; 00204 order_to_enum["TWENTYNINTH" ]=TWENTYNINTH; 00205 order_to_enum["THIRTIETH" ]=THIRTIETH; 00206 00207 order_to_enum["THIRTYFIRST" ]=THIRTYFIRST; 00208 order_to_enum["THIRTYSECOND" ]=THIRTYSECOND; 00209 order_to_enum["THIRTYTHIRD" ]=THIRTYTHIRD; 00210 order_to_enum["THIRTYFOURTH" ]=THIRTYFOURTH; 00211 order_to_enum["THIRTYFIFTH" ]=THIRTYFIFTH; 00212 order_to_enum["THIRTYSIXTH" ]=THIRTYSIXTH; 00213 order_to_enum["THIRTYSEVENTH"]=THIRTYSEVENTH; 00214 order_to_enum["THIRTYEIGHTH" ]=THIRTYEIGHTH; 00215 order_to_enum["THIRTYNINTH" ]=THIRTYNINTH; 00216 order_to_enum["FORTIETH" ]=FORTIETH; 00217 00218 order_to_enum["FORTYFIRST" ]=FORTYFIRST; 00219 order_to_enum["FORTYSECOND" ]=FORTYSECOND; 00220 order_to_enum["FORTYTHIRD" ]=FORTYTHIRD; 00221 } 00222 } 00223 00224 00225 00226 INSTANTIATE_ENUM_MAPS(FEFamily, fefamily) 00227 00228 // Initialize fefamily_to_enum on first call 00229 void init_fefamily_to_enum () 00230 { 00231 if (fefamily_to_enum.empty()) 00232 { 00233 fefamily_to_enum["LAGRANGE" ]=LAGRANGE; 00234 fefamily_to_enum["LAGRANGE_VEC" ]=LAGRANGE_VEC; 00235 fefamily_to_enum["L2_LAGRANGE" ]=L2_LAGRANGE; 00236 fefamily_to_enum["HIERARCHIC" ]=HIERARCHIC; 00237 fefamily_to_enum["L2_HIERARCHIC"]=L2_HIERARCHIC; 00238 fefamily_to_enum["MONOMIAL" ]=MONOMIAL; 00239 fefamily_to_enum["SCALAR" ]=SCALAR; 00240 fefamily_to_enum["XYZ" ]=XYZ; 00241 fefamily_to_enum["BERNSTEIN" ]=BERNSTEIN; 00242 fefamily_to_enum["SZABAB" ]=SZABAB; 00243 fefamily_to_enum["INFINITE_MAP" ]=INFINITE_MAP; 00244 fefamily_to_enum["JACOBI_20_00" ]=JACOBI_20_00; 00245 fefamily_to_enum["JACOBI_30_00" ]=JACOBI_30_00; 00246 fefamily_to_enum["LEGENDRE" ]=LEGENDRE; 00247 fefamily_to_enum["CLOUGH" ]=CLOUGH; 00248 fefamily_to_enum["HERMITE" ]=HERMITE; 00249 fefamily_to_enum["SUBDIVISION" ]=SUBDIVISION; 00250 fefamily_to_enum["NEDELEC_ONE" ]=NEDELEC_ONE; 00251 } 00252 00253 } 00254 00255 00256 00257 INSTANTIATE_ENUM_MAPS(InfMapType, inf_map_type) 00258 00259 // Initialize inf_map_type_to_enum on first call 00260 void init_inf_map_type_to_enum () 00261 { 00262 if (inf_map_type_to_enum.empty()) 00263 { 00264 inf_map_type_to_enum["CARTESIAN" ]=CARTESIAN; 00265 inf_map_type_to_enum["SPHERICAL" ]=SPHERICAL; 00266 inf_map_type_to_enum["ELLIPSOIDAL"]=ELLIPSOIDAL; 00267 } 00268 } 00269 00270 00271 INSTANTIATE_ENUM_MAPS(QuadratureType, quadrature_type) 00272 00273 // Initialize quadrature_type_to_enum on first call 00274 void init_quadrature_type_to_enum () 00275 { 00276 if (quadrature_type_to_enum.empty()) 00277 { 00278 quadrature_type_to_enum["QGAUSS" ]=QGAUSS; 00279 quadrature_type_to_enum["QJACOBI_1_0"]=QJACOBI_1_0; 00280 quadrature_type_to_enum["QJACOBI_2_0"]=QJACOBI_2_0; 00281 quadrature_type_to_enum["QSIMPSON" ]=QSIMPSON; 00282 quadrature_type_to_enum["QTRAP" ]=QTRAP; 00283 quadrature_type_to_enum["QGRID" ]=QGRID; 00284 quadrature_type_to_enum["QCLOUGH" ]=QCLOUGH; 00285 quadrature_type_to_enum["QGAUSS_LOBATTO" ]=QGAUSS_LOBATTO; 00286 } 00287 } 00288 00289 00290 INSTANTIATE_ENUM_MAPS(PreconditionerType, preconditioner_type) 00291 00292 // Initialize preconditioner_type_to_enum on first call 00293 void init_preconditioner_type_to_enum () 00294 { 00295 if (preconditioner_type_to_enum.empty()) 00296 { 00297 preconditioner_type_to_enum["IDENTITY_PRECOND" ]=IDENTITY_PRECOND; 00298 preconditioner_type_to_enum["JACOBI_PRECOND" ]=JACOBI_PRECOND; 00299 preconditioner_type_to_enum["BLOCK_JACOBI_PRECOND" ]=BLOCK_JACOBI_PRECOND; 00300 preconditioner_type_to_enum["SOR_PRECOND" ]=SOR_PRECOND; 00301 preconditioner_type_to_enum["SSOR_PRECOND" ]=SSOR_PRECOND; 00302 preconditioner_type_to_enum["EISENSTAT_PRECOND" ]=EISENSTAT_PRECOND; 00303 preconditioner_type_to_enum["ASM_PRECOND" ]=ASM_PRECOND; 00304 preconditioner_type_to_enum["CHOLESKY_PRECOND" ]=CHOLESKY_PRECOND; 00305 preconditioner_type_to_enum["ICC_PRECOND" ]=ICC_PRECOND; 00306 preconditioner_type_to_enum["ILU_PRECOND" ]=ILU_PRECOND; 00307 preconditioner_type_to_enum["LU_PRECOND" ]=LU_PRECOND; 00308 preconditioner_type_to_enum["USER_PRECOND" ]=USER_PRECOND; 00309 preconditioner_type_to_enum["SHELL_PRECOND" ]=SHELL_PRECOND; 00310 preconditioner_type_to_enum["AMG_PRECOND" ]=AMG_PRECOND; 00311 preconditioner_type_to_enum["INVALID_PRECONDITIONER"]=INVALID_PRECONDITIONER; 00312 00313 //shorter 00314 preconditioner_type_to_enum["IDENTITY" ]=IDENTITY_PRECOND; 00315 preconditioner_type_to_enum["JACOBI" ]=JACOBI_PRECOND; 00316 preconditioner_type_to_enum["BLOCK_JACOBI"]=BLOCK_JACOBI_PRECOND; 00317 preconditioner_type_to_enum["SOR" ]=SOR_PRECOND; 00318 preconditioner_type_to_enum["SSOR" ]=SSOR_PRECOND; 00319 preconditioner_type_to_enum["EISENSTAT" ]=EISENSTAT_PRECOND; 00320 preconditioner_type_to_enum["ASM" ]=ASM_PRECOND; 00321 preconditioner_type_to_enum["CHOLESKY" ]=CHOLESKY_PRECOND; 00322 preconditioner_type_to_enum["ICC" ]=ICC_PRECOND; 00323 preconditioner_type_to_enum["ILU" ]=ILU_PRECOND; 00324 preconditioner_type_to_enum["LU" ]=LU_PRECOND; 00325 preconditioner_type_to_enum["USER" ]=USER_PRECOND; 00326 preconditioner_type_to_enum["SHELL" ]=SHELL_PRECOND; 00327 preconditioner_type_to_enum["AMG" ]=AMG_PRECOND; 00328 preconditioner_type_to_enum["INVALID" ]=INVALID_PRECONDITIONER; 00329 } 00330 } 00331 00332 00333 #ifdef LIBMESH_ENABLE_AMR 00334 00335 INSTANTIATE_ENUM_MAPS(Elem::RefinementState, refinementstate_type) 00336 00337 // Initialize refinementstate_type_to_enum on first call 00338 void init_refinementstate_type_to_enum () 00339 { 00340 if (refinementstate_type_to_enum.empty()) 00341 { 00342 refinementstate_type_to_enum["COARSEN" ]=Elem::COARSEN; 00343 refinementstate_type_to_enum["DO_NOTHING" ]=Elem::DO_NOTHING; 00344 refinementstate_type_to_enum["REFINE" ]=Elem::REFINE; 00345 refinementstate_type_to_enum["JUST_REFINED" ]=Elem::JUST_REFINED; 00346 refinementstate_type_to_enum["JUST_COARSENED" ]=Elem::JUST_COARSENED; 00347 refinementstate_type_to_enum["INACTIVE" ]=Elem::INACTIVE; 00348 refinementstate_type_to_enum["COARSEN_INACTIVE" ]=Elem::COARSEN_INACTIVE; 00349 refinementstate_type_to_enum["INVALID_REFINEMENTSTATE"]=Elem::INVALID_REFINEMENTSTATE; 00350 } 00351 } 00352 #endif // LIBMESH_ENABLE_AMR 00353 00354 00355 INSTANTIATE_ENUM_MAPS(EigenSolverType, eigensolvertype) 00356 00357 // Initialize eigensolvertype_to_enum on first call 00358 void init_eigensolvertype_to_enum () 00359 { 00360 if (eigensolvertype_to_enum.empty()) 00361 { 00362 eigensolvertype_to_enum["POWER" ]=POWER; 00363 eigensolvertype_to_enum["LAPACK" ]=LAPACK; 00364 eigensolvertype_to_enum["SUBSPACE" ]=SUBSPACE; 00365 eigensolvertype_to_enum["ARNOLDI" ]=ARNOLDI; 00366 eigensolvertype_to_enum["LANCZOS" ]=LANCZOS; 00367 eigensolvertype_to_enum["KRYLOVSCHUR" ]=KRYLOVSCHUR; 00368 eigensolvertype_to_enum["INVALID_EIGENSOLVER"]=INVALID_EIGENSOLVER; 00369 } 00370 } 00371 00372 00373 INSTANTIATE_ENUM_MAPS(SolverType, solvertype) 00374 00375 // Initialize solvertype_to_enum on first call 00376 void init_solvertype_to_enum () 00377 { 00378 if (solvertype_to_enum.empty()) 00379 { 00380 solvertype_to_enum["CG" ]=CG; 00381 solvertype_to_enum["CGN" ]=CGN; 00382 solvertype_to_enum["CGS" ]=CGS; 00383 solvertype_to_enum["CR" ]=CR; 00384 solvertype_to_enum["QMR" ]=QMR; 00385 solvertype_to_enum["TCQMR" ]=TCQMR; 00386 solvertype_to_enum["TFQMR" ]=TFQMR; 00387 solvertype_to_enum["BICG" ]=BICG; 00388 solvertype_to_enum["MINRES" ]=MINRES; 00389 solvertype_to_enum["GMRES" ]=GMRES; 00390 solvertype_to_enum["LSQR" ]=LSQR; 00391 solvertype_to_enum["JACOBI" ]=JACOBI; 00392 solvertype_to_enum["SOR_FORWARD" ]=SOR_FORWARD; 00393 solvertype_to_enum["SOR_BACKWARD" ]=SOR_BACKWARD; 00394 solvertype_to_enum["SSOR" ]=SSOR; 00395 solvertype_to_enum["RICHARDSON" ]=RICHARDSON; 00396 solvertype_to_enum["CHEBYSHEV" ]=CHEBYSHEV; 00397 solvertype_to_enum["INVALID_SOLVER"]=INVALID_SOLVER; 00398 } 00399 } 00400 00401 00402 INSTANTIATE_ENUM_MAPS(ElemQuality, elemquality) 00403 00404 // Initialize elemquality_to_enum on first call 00405 void init_elemquality_to_enum () 00406 { 00407 if (elemquality_to_enum.empty()) 00408 { 00409 elemquality_to_enum["ASPECT_RATIO" ]=ASPECT_RATIO; 00410 elemquality_to_enum["SKEW" ]=SKEW; 00411 elemquality_to_enum["SHEAR" ]=SHEAR; 00412 elemquality_to_enum["SHAPE" ]=SHAPE; 00413 elemquality_to_enum["MAX_ANGLE" ]=MAX_ANGLE; 00414 elemquality_to_enum["MIN_ANGLE" ]=MIN_ANGLE; 00415 elemquality_to_enum["CONDITION" ]=CONDITION; 00416 elemquality_to_enum["DISTORTION" ]=DISTORTION; 00417 elemquality_to_enum["TAPER" ]=TAPER; 00418 elemquality_to_enum["WARP" ]=WARP; 00419 elemquality_to_enum["STRETCH" ]=STRETCH; 00420 elemquality_to_enum["DIAGONAL" ]=DIAGONAL; 00421 elemquality_to_enum["ASPECT_RATIO_BETA" ]=ASPECT_RATIO_BETA; 00422 elemquality_to_enum["ASPECT_RATIO_GAMMA" ]=ASPECT_RATIO_GAMMA; 00423 elemquality_to_enum["SIZE" ]=SIZE; 00424 elemquality_to_enum["JACOBIAN" ]=JACOBIAN; 00425 } 00426 } 00427 00428 00429 INSTANTIATE_ENUM_MAPS(IOPackage, iopackage) 00430 00431 // Initialize iopackage_to_enum on first call 00432 void init_iopackage_to_enum () 00433 { 00434 if (iopackage_to_enum.empty()) 00435 { 00436 iopackage_to_enum["TECPLOT" ]=TECPLOT; 00437 iopackage_to_enum["GMV" ]=GMV; 00438 iopackage_to_enum["GMSH" ]=GMSH; 00439 iopackage_to_enum["VTK" ]=VTK; 00440 iopackage_to_enum["DIVA" ]=DIVA; 00441 iopackage_to_enum["TETGEN" ]=TETGEN; 00442 iopackage_to_enum["UCD" ]=UCD; 00443 iopackage_to_enum["LIBMESH" ]=LIBMESH; 00444 } 00445 } 00446 00447 00448 INSTANTIATE_ENUM_MAPS(FEMNormType, norm_type) 00449 00450 // Initialize norm_type_to_enum on first call 00451 void init_norm_type_to_enum () 00452 { 00453 if (norm_type_to_enum.empty()) 00454 { 00455 norm_type_to_enum["L2" ]=L2; 00456 norm_type_to_enum["H1" ]=H1; 00457 norm_type_to_enum["H2" ]=H2; 00458 norm_type_to_enum["HCURL" ]=HCURL; 00459 norm_type_to_enum["HDIV" ]=HDIV; 00460 00461 norm_type_to_enum["L1" ]=L1; 00462 norm_type_to_enum["L_INF" ]=L_INF; 00463 00464 norm_type_to_enum["H1_SEMINORM" ]=H1_SEMINORM; 00465 norm_type_to_enum["H2_SEMINORM" ]=H2_SEMINORM; 00466 norm_type_to_enum["HCURL_SEMINORM" ]=HCURL_SEMINORM; 00467 norm_type_to_enum["HDIV_SEMINORM" ]=HDIV_SEMINORM; 00468 00469 norm_type_to_enum["W1_INF_SEMINORM" ]=W1_INF_SEMINORM; 00470 norm_type_to_enum["W2_INF_SEMINORM" ]=W2_INF_SEMINORM; 00471 00472 norm_type_to_enum["DISCRETE_L1" ]=DISCRETE_L1; 00473 norm_type_to_enum["DISCRETE_L2" ]=DISCRETE_L2; 00474 norm_type_to_enum["DISCRETE_L_INF" ]=DISCRETE_L_INF; 00475 00476 norm_type_to_enum["H1_X_SEMINORM" ]=H1_X_SEMINORM; 00477 norm_type_to_enum["H1_Y_SEMINORM" ]=H1_Y_SEMINORM; 00478 norm_type_to_enum["H1_Z_SEMINORM" ]=H1_Z_SEMINORM; 00479 00480 norm_type_to_enum["INVALID_NORM" ]=INVALID_NORM; 00481 } 00482 } 00483 00484 00485 INSTANTIATE_ENUM_MAPS(ParallelType, parallel_type) 00486 00487 // Initialize parallel_type_to_enum on first call 00488 void init_parallel_type_to_enum () 00489 { 00490 if (parallel_type_to_enum.empty()) 00491 { 00492 parallel_type_to_enum["AUTOMATIC" ]=AUTOMATIC; 00493 parallel_type_to_enum["SERIAL" ]=SERIAL; 00494 parallel_type_to_enum["PARALLEL" ]=PARALLEL; 00495 parallel_type_to_enum["GHOSTED" ]=GHOSTED; 00496 parallel_type_to_enum["INVALID_PARALLELIZATION" ]=INVALID_PARALLELIZATION; 00497 } 00498 } 00499 00500 00501 INSTANTIATE_ENUM_MAPS(PointLocatorType, point_locator_type) 00502 00503 // Initialize point_locator_type_to_enum on first call 00504 void init_point_locator_type_to_enum () 00505 { 00506 if (point_locator_type_to_enum.empty()) 00507 { 00508 point_locator_type_to_enum["TREE" ]=TREE; 00509 point_locator_type_to_enum["LIST" ]=LIST; 00510 point_locator_type_to_enum["INVALID_LOCATOR" ]=INVALID_LOCATOR; 00511 } 00512 } 00513 00514 00515 INSTANTIATE_ENUM_MAPS(SolverPackage, solverpackage_type) 00516 00517 // Initialize solverpackage_type_to_enum on first call 00518 void init_solverpackage_type_to_enum () 00519 { 00520 if (solverpackage_type_to_enum.empty()) 00521 { 00522 solverpackage_type_to_enum["PETSC_SOLVERS" ]=PETSC_SOLVERS; 00523 solverpackage_type_to_enum["TRILINOS_SOLVERS" ]=TRILINOS_SOLVERS; 00524 solverpackage_type_to_enum["LASPACK_SOLVERS" ]=LASPACK_SOLVERS; 00525 solverpackage_type_to_enum["SLEPC_SOLVERS" ]=SLEPC_SOLVERS; 00526 solverpackage_type_to_enum["EIGEN_SOLVERS" ]=EIGEN_SOLVERS; 00527 solverpackage_type_to_enum["INVALID_SOLVER_PACKAGE" ]=INVALID_SOLVER_PACKAGE; 00528 } 00529 } 00530 00531 00532 INSTANTIATE_ENUM_MAPS(SubsetSolveMode, subset_solve_mode) 00533 00534 // Initialize subset_solve_mode_to_enum on first call 00535 void init_subset_solve_mode_to_enum () 00536 { 00537 if (subset_solve_mode_to_enum.empty()) 00538 { 00539 subset_solve_mode_to_enum["SUBSET_ZERO" ]=SUBSET_ZERO; 00540 subset_solve_mode_to_enum["SUBSET_COPY_RHS" ]=SUBSET_COPY_RHS; 00541 subset_solve_mode_to_enum["SUBSET_DONT_TOUCH" ]=SUBSET_DONT_TOUCH; 00542 } 00543 } 00544 00545 00546 INSTANTIATE_ENUM_MAPS(XdrMODE, xdr_mode) 00547 00548 // Initialize xdr_mode_to_enum on first call 00549 void init_xdr_mode_to_enum () 00550 { 00551 if (xdr_mode_to_enum.empty()) 00552 { 00553 xdr_mode_to_enum["UNKNOWN" ]=UNKNOWN; 00554 xdr_mode_to_enum["ENCODE" ]=ENCODE; 00555 xdr_mode_to_enum["DECODE" ]=DECODE; 00556 xdr_mode_to_enum["WRITE" ]=WRITE; 00557 xdr_mode_to_enum["READ" ]=READ; 00558 } 00559 } 00560 00561 00562 INSTANTIATE_ENUM_MAPS(LinearConvergenceReason, linear_convergence_reason) 00563 00564 // Initialize xdr_mode_to_enum on first call 00565 void init_linear_convergence_reason_to_enum () 00566 { 00567 if (linear_convergence_reason_to_enum.empty()) 00568 { 00569 linear_convergence_reason_to_enum["CONVERGED_RTOL_NORMAL"] = CONVERGED_RTOL_NORMAL; 00570 linear_convergence_reason_to_enum["CONVERGED_ATOL_NORMAL"] = CONVERGED_ATOL_NORMAL; 00571 linear_convergence_reason_to_enum["CONVERGED_RTOL"] = CONVERGED_RTOL; 00572 linear_convergence_reason_to_enum["CONVERGED_ATOL"] = CONVERGED_ATOL; 00573 linear_convergence_reason_to_enum["CONVERGED_ITS"] = CONVERGED_ITS; 00574 linear_convergence_reason_to_enum["CONVERGED_CG_NEG_CURVE"] = CONVERGED_CG_NEG_CURVE; 00575 linear_convergence_reason_to_enum["CONVERGED_CG_CONSTRAINED"] = CONVERGED_CG_CONSTRAINED; 00576 linear_convergence_reason_to_enum["CONVERGED_STEP_LENGTH"] = CONVERGED_STEP_LENGTH; 00577 linear_convergence_reason_to_enum["CONVERGED_HAPPY_BREAKDOWN"] = CONVERGED_HAPPY_BREAKDOWN; 00578 linear_convergence_reason_to_enum["DIVERGED_NULL"] = DIVERGED_NULL; 00579 linear_convergence_reason_to_enum["DIVERGED_ITS"] = DIVERGED_ITS; 00580 linear_convergence_reason_to_enum["DIVERGED_DTOL"] = DIVERGED_DTOL; 00581 linear_convergence_reason_to_enum["DIVERGED_BREAKDOWN"] = DIVERGED_BREAKDOWN; 00582 linear_convergence_reason_to_enum["DIVERGED_BREAKDOWN_BICG"] = DIVERGED_BREAKDOWN_BICG; 00583 linear_convergence_reason_to_enum["DIVERGED_NONSYMMETRIC"] = DIVERGED_NONSYMMETRIC; 00584 linear_convergence_reason_to_enum["DIVERGED_INDEFINITE_PC"] = DIVERGED_INDEFINITE_PC; 00585 linear_convergence_reason_to_enum["DIVERGED_NAN"] = DIVERGED_NAN; 00586 linear_convergence_reason_to_enum["DIVERGED_INDEFINITE_MAT"] = DIVERGED_INDEFINITE_MAT; 00587 linear_convergence_reason_to_enum["CONVERGED_ITERATING"] = CONVERGED_ITERATING; 00588 linear_convergence_reason_to_enum["UNKNOWN_FLAG"] = UNKNOWN_FLAG; 00589 } 00590 } 00591 00592 00593 #undef INSTANTIATE_ENUM_MAPS 00594 00595 } // end anonymous namespace 00596 00597 00598 00599 // ------------------------------------------------------ 00600 // Utility::string_to_enum<> & Utility::enum_to_string<> 00601 // full specializations 00602 namespace Utility { 00603 00604 #define INSTANTIATE_STRING_TO_ENUM(ENUM_NAME,VAR_NAME) \ 00605 template <> \ 00606 ENUM_NAME string_to_enum<ENUM_NAME> (const std::string& s) \ 00607 { \ 00608 init_##VAR_NAME##_to_enum(); \ 00609 \ 00610 std::string upper(s); \ 00611 std::transform(upper.begin(), upper.end(), upper.begin(), ::toupper); \ 00612 \ 00613 if (!VAR_NAME##_to_enum.count(upper)) \ 00614 { \ 00615 libmesh_error_msg("No " #ENUM_NAME " named " + s + " found."); \ 00616 } \ 00617 \ 00618 return VAR_NAME##_to_enum[upper]; \ 00619 } \ 00620 \ 00621 template <> \ 00622 std::string enum_to_string<ENUM_NAME> (const ENUM_NAME e) \ 00623 { \ 00624 init_enum_to_##VAR_NAME (); \ 00625 \ 00626 if (!enum_to_##VAR_NAME .count(e)) \ 00627 libmesh_error_msg("No " #ENUM_NAME " with enumeration " << e << " found."); \ 00628 \ 00629 return enum_to_##VAR_NAME [e]; \ 00630 } 00631 00632 00633 INSTANTIATE_STRING_TO_ENUM(ElemType,elem_type) 00634 INSTANTIATE_STRING_TO_ENUM(Order,order) 00635 INSTANTIATE_STRING_TO_ENUM(FEFamily,fefamily) 00636 INSTANTIATE_STRING_TO_ENUM(InfMapType,inf_map_type) 00637 INSTANTIATE_STRING_TO_ENUM(QuadratureType,quadrature_type) 00638 INSTANTIATE_STRING_TO_ENUM(PreconditionerType,preconditioner_type) 00639 00640 #ifdef LIBMESH_ENABLE_AMR 00641 INSTANTIATE_STRING_TO_ENUM(Elem::RefinementState,refinementstate_type) 00642 #endif // LIBMESH_ENABLE_AMR 00643 00644 INSTANTIATE_STRING_TO_ENUM(SolverType,solvertype) 00645 INSTANTIATE_STRING_TO_ENUM(EigenSolverType,eigensolvertype) 00646 INSTANTIATE_STRING_TO_ENUM(ElemQuality,elemquality) 00647 INSTANTIATE_STRING_TO_ENUM(IOPackage,iopackage) 00648 INSTANTIATE_STRING_TO_ENUM(FEMNormType, norm_type) 00649 INSTANTIATE_STRING_TO_ENUM(ParallelType, parallel_type) 00650 INSTANTIATE_STRING_TO_ENUM(PointLocatorType, point_locator_type) 00651 INSTANTIATE_STRING_TO_ENUM(SolverPackage,solverpackage_type) 00652 INSTANTIATE_STRING_TO_ENUM(SubsetSolveMode,subset_solve_mode) 00653 INSTANTIATE_STRING_TO_ENUM(XdrMODE,xdr_mode) 00654 INSTANTIATE_STRING_TO_ENUM(LinearConvergenceReason, linear_convergence_reason) 00655 00656 #undef INSTANTIATE_STRING_TO_ENUM 00657 00658 } // namespace Utility 00659 00660 } // namespace libMesh