string_to_enum.C
Go to the documentation of this file.00001 // The libMesh Finite Element Library. 00002 // Copyright (C) 2002-2012 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_elem_type.h" 00028 #include "libmesh/enum_order.h" 00029 #include "libmesh/enum_fe_family.h" 00030 #include "libmesh/enum_inf_map_type.h" 00031 #include "libmesh/enum_quadrature_type.h" 00032 #include "libmesh/enum_preconditioner_type.h" 00033 #include "libmesh/elem.h" 00034 00035 namespace libMesh 00036 { 00037 00038 00039 // ------------------------------------------------------------ 00040 // Anonymous namespace to hold local data & methods 00041 namespace { 00042 00043 00044 // Reverse a map 00045 template <typename MapIter, class MapType> 00046 inline 00047 void build_reverse_map (MapIter it, MapIter end, MapType& reverse) 00048 { 00049 reverse.clear(); 00050 00051 for (; it != end; ++it) 00052 { 00053 // If the forward map is not invertible, we might already have 00054 // found a preimage of it->second. Choose the "largest" 00055 // preimage according to operator<; for std::string this will 00056 // give us the longest, hopefully most specific name 00057 // corresponding to an enum. 00058 typename MapType::iterator preimage = reverse.find(it->second); 00059 if (preimage == reverse.end()) 00060 reverse.insert (std::make_pair(it->second, it->first)); 00061 else if (preimage->second < it->first) 00062 preimage->second = it->first; 00063 } 00064 } 00065 00066 00067 //---------------------------------------------------- 00068 std::map<std::string, ElemType> elem_type_to_enum; 00069 00070 // Initialize elem_type_to_enum on first call 00071 void init_elem_type_to_enum () 00072 { 00073 if (elem_type_to_enum.empty()) 00074 { 00075 elem_type_to_enum["EDGE" ]=EDGE2; 00076 elem_type_to_enum["EDGE2" ]=EDGE2; 00077 elem_type_to_enum["EDGE3" ]=EDGE3; 00078 elem_type_to_enum["EDGE4" ]=EDGE4; 00079 00080 elem_type_to_enum["TRI" ]=TRI3; 00081 elem_type_to_enum["TRI3" ]=TRI3; 00082 elem_type_to_enum["TRI6" ]=TRI6; 00083 00084 elem_type_to_enum["QUAD" ]=QUAD4; 00085 elem_type_to_enum["QUAD4" ]=QUAD4; 00086 elem_type_to_enum["QUAD8" ]=QUAD8; 00087 elem_type_to_enum["QUAD9" ]=QUAD9; 00088 00089 elem_type_to_enum["TET" ]=TET4; 00090 elem_type_to_enum["TET4" ]=TET4; 00091 elem_type_to_enum["TET10" ]=TET10; 00092 00093 elem_type_to_enum["HEX" ]=HEX8; 00094 elem_type_to_enum["HEX8" ]=HEX8; 00095 elem_type_to_enum["HEX20" ]=HEX20; 00096 elem_type_to_enum["HEX27" ]=HEX27; 00097 00098 elem_type_to_enum["PRISM" ]=PRISM6; 00099 elem_type_to_enum["PRISM6" ]=PRISM6; 00100 elem_type_to_enum["PRISM15" ]=PRISM15; 00101 elem_type_to_enum["PRISM18" ]=PRISM18; 00102 00103 elem_type_to_enum["PYRAMID" ]=PYRAMID5; 00104 elem_type_to_enum["PYRAMID5" ]=PYRAMID5; 00105 00106 elem_type_to_enum["INFEDGE" ]=INFEDGE2; 00107 elem_type_to_enum["INFEDGE2" ]=INFEDGE2; 00108 00109 elem_type_to_enum["INFQUAD" ]=INFQUAD4; 00110 elem_type_to_enum["INFQUAD4" ]=INFQUAD4; 00111 elem_type_to_enum["INFQUAD6" ]=INFQUAD6; 00112 00113 elem_type_to_enum["INFHEX" ]=INFHEX8; 00114 elem_type_to_enum["INFHEX8" ]=INFHEX8; 00115 elem_type_to_enum["INFHEX16" ]=INFHEX16; 00116 elem_type_to_enum["INFHEX18" ]=INFHEX18; 00117 00118 elem_type_to_enum["INFPRISM" ]=INFPRISM6; 00119 elem_type_to_enum["INFPRISM6" ]=INFPRISM6; 00120 elem_type_to_enum["INFPRISM12"]=INFPRISM12; 00121 00122 elem_type_to_enum["NODE" ]=NODEELEM; 00123 elem_type_to_enum["NODEELEM" ]=NODEELEM; 00124 } 00125 } 00126 00127 00128 00129 std::map<ElemType, std::string> enum_to_elem_type; 00130 00131 // Initialize the enum_to_elem_type on first call 00132 void init_enum_to_elem_type () 00133 { 00134 // Build reverse map 00135 if (enum_to_elem_type.empty()) 00136 { 00137 // Initialize elem_type_to_enum on first call 00138 init_elem_type_to_enum(); 00139 00140 build_reverse_map (elem_type_to_enum.begin(), 00141 elem_type_to_enum.end(), 00142 enum_to_elem_type); 00143 } 00144 } 00145 00146 00147 00148 00149 //--------------------------------------------- 00150 std::map<std::string, Order> order_to_enum; 00151 00152 // Initialize order_to_enum on first call 00153 void init_order_to_enum () 00154 { 00155 if (order_to_enum.empty()) 00156 { 00157 order_to_enum["CONSTANT" ]=CONSTANT; 00158 order_to_enum["FIRST" ]=FIRST; 00159 order_to_enum["SECOND" ]=SECOND; 00160 order_to_enum["THIRD" ]=THIRD; 00161 order_to_enum["FOURTH" ]=FOURTH; 00162 order_to_enum["FIFTH" ]=FIFTH; 00163 order_to_enum["SIXTH" ]=SIXTH; 00164 order_to_enum["SEVENTH" ]=SEVENTH; 00165 order_to_enum["EIGHTH" ]=EIGHTH; 00166 order_to_enum["NINTH" ]=NINTH; 00167 order_to_enum["TENTH" ]=TENTH; 00168 00169 order_to_enum["ELEVENTH" ]=ELEVENTH; 00170 order_to_enum["TWELFTH" ]=TWELFTH; 00171 order_to_enum["THIRTEENTH" ]=THIRTEENTH; 00172 order_to_enum["FOURTEENTH" ]=FOURTEENTH; 00173 order_to_enum["FIFTEENTH" ]=FIFTEENTH; 00174 order_to_enum["SIXTEENTH" ]=SIXTEENTH; 00175 order_to_enum["SEVENTEENTH" ]=SEVENTEENTH; 00176 order_to_enum["EIGHTTEENTH" ]=EIGHTTEENTH; 00177 order_to_enum["NINTEENTH" ]=NINTEENTH; 00178 order_to_enum["TWENTIETH" ]=TWENTIETH; 00179 00180 order_to_enum["TWENTYFIRST" ]=TWENTYFIRST; 00181 order_to_enum["TWENTYSECOND" ]=TWENTYSECOND; 00182 order_to_enum["TWENTYTHIRD" ]=TWENTYTHIRD; 00183 order_to_enum["TWENTYFOURTH" ]=TWENTYFOURTH; 00184 order_to_enum["TWENTYFIFTH" ]=TWENTYFIFTH; 00185 order_to_enum["TWENTYSIXTH" ]=TWENTYSIXTH; 00186 order_to_enum["TWENTYSEVENTH"]=TWENTYSEVENTH; 00187 order_to_enum["TWENTYEIGHTH" ]=TWENTYEIGHTH; 00188 order_to_enum["TWENTYNINTH" ]=TWENTYNINTH; 00189 order_to_enum["THIRTIETH" ]=THIRTIETH; 00190 00191 order_to_enum["THIRTYFIRST" ]=THIRTYFIRST; 00192 order_to_enum["THIRTYSECOND" ]=THIRTYSECOND; 00193 order_to_enum["THIRTYTHIRD" ]=THIRTYTHIRD; 00194 order_to_enum["THIRTYFOURTH" ]=THIRTYFOURTH; 00195 order_to_enum["THIRTYFIFTH" ]=THIRTYFIFTH; 00196 order_to_enum["THIRTYSIXTH" ]=THIRTYSIXTH; 00197 order_to_enum["THIRTYSEVENTH"]=THIRTYSEVENTH; 00198 order_to_enum["THIRTYEIGHTH" ]=THIRTYEIGHTH; 00199 order_to_enum["THIRTYNINTH" ]=THIRTYNINTH; 00200 order_to_enum["FORTIETH" ]=FORTIETH; 00201 00202 order_to_enum["FORTYFIRST" ]=FORTYFIRST; 00203 order_to_enum["FORTYSECOND" ]=FORTYSECOND; 00204 order_to_enum["FORTYTHIRD" ]=FORTYTHIRD; 00205 } 00206 } 00207 00208 00209 00210 std::map<Order, std::string> enum_to_order; 00211 00212 // Initialize the enum_to_order on first call 00213 void init_enum_to_order () 00214 { 00215 // Build reverse map 00216 if (enum_to_order.empty()) 00217 { 00218 // Initialize order_to_enum on first call 00219 init_order_to_enum(); 00220 00221 build_reverse_map (order_to_enum.begin(), 00222 order_to_enum.end(), 00223 enum_to_order); 00224 } 00225 } 00226 00227 00228 00229 //--------------------------------------------------- 00230 std::map<std::string, FEFamily> fefamily_to_enum; 00231 00232 // Initialize fefamily_to_enum on first call 00233 void init_fefamily_to_enum () 00234 { 00235 if (fefamily_to_enum.empty()) 00236 { 00237 fefamily_to_enum["LAGRANGE" ]=LAGRANGE; 00238 fefamily_to_enum["LAGRANGE_VEC" ]=LAGRANGE_VEC; 00239 fefamily_to_enum["L2_LAGRANGE" ]=L2_LAGRANGE; 00240 fefamily_to_enum["HIERARCHIC" ]=HIERARCHIC; 00241 fefamily_to_enum["L2_HIERARCHIC"]=L2_HIERARCHIC; 00242 fefamily_to_enum["MONOMIAL" ]=MONOMIAL; 00243 fefamily_to_enum["SCALAR" ]=SCALAR; 00244 fefamily_to_enum["XYZ" ]=XYZ; 00245 fefamily_to_enum["BERNSTEIN" ]=BERNSTEIN; 00246 fefamily_to_enum["SZABAB" ]=SZABAB; 00247 fefamily_to_enum["INFINITE_MAP" ]=INFINITE_MAP; 00248 fefamily_to_enum["JACOBI_20_00" ]=JACOBI_20_00; 00249 fefamily_to_enum["JACOBI_30_00" ]=JACOBI_30_00; 00250 fefamily_to_enum["LEGENDRE" ]=LEGENDRE; 00251 fefamily_to_enum["CLOUGH" ]=CLOUGH; 00252 fefamily_to_enum["HERMITE" ]=HERMITE; 00253 fefamily_to_enum["NEDELEC_ONE" ]=NEDELEC_ONE; 00254 } 00255 00256 } 00257 00258 00259 std::map<FEFamily, std::string> enum_to_fefamily; 00260 00261 // Initialize the enum_to_fefamily on first call 00262 void init_enum_to_fefamily () 00263 { 00264 // Build reverse map 00265 if (enum_to_fefamily.empty()) 00266 { 00267 // Initialize fefamily_to_enum on first call 00268 init_fefamily_to_enum(); 00269 00270 build_reverse_map (fefamily_to_enum.begin(), 00271 fefamily_to_enum.end(), 00272 enum_to_fefamily); 00273 } 00274 } 00275 00276 00277 00278 //--------------------------------------------------- 00279 std::map<std::string, InfMapType> inf_map_type_to_enum; 00280 00281 // Initialize inf_map_type_to_enum on first call 00282 void init_inf_map_type_to_enum () 00283 { 00284 if (inf_map_type_to_enum.empty()) 00285 { 00286 inf_map_type_to_enum["CARTESIAN" ]=CARTESIAN; 00287 inf_map_type_to_enum["SPHERICAL" ]=SPHERICAL; 00288 inf_map_type_to_enum["ELLIPSOIDAL"]=ELLIPSOIDAL; 00289 } 00290 } 00291 00292 00293 std::map<InfMapType, std::string> enum_to_inf_map_type; 00294 00295 // Initialize the enum_to_inf_map_type on first call 00296 void init_enum_to_inf_map_type () 00297 { 00298 // Build reverse map 00299 if (enum_to_inf_map_type.empty()) 00300 { 00301 // Initialize inf_map_type_to_enum on first call 00302 init_inf_map_type_to_enum(); 00303 00304 build_reverse_map (inf_map_type_to_enum.begin(), 00305 inf_map_type_to_enum.end(), 00306 enum_to_inf_map_type); 00307 } 00308 } 00309 00310 00311 00312 //--------------------------------------------------- 00313 std::map<std::string, QuadratureType> quadrature_type_to_enum; 00314 00315 // Initialize quadrature_type_to_enum on first call 00316 void init_quadrature_type_to_enum () 00317 { 00318 if (quadrature_type_to_enum.empty()) 00319 { 00320 quadrature_type_to_enum["QGAUSS" ]=QGAUSS; 00321 quadrature_type_to_enum["QJACOBI_1_0"]=QJACOBI_1_0; 00322 quadrature_type_to_enum["QJACOBI_2_0"]=QJACOBI_2_0; 00323 quadrature_type_to_enum["QSIMPSON" ]=QSIMPSON; 00324 quadrature_type_to_enum["QTRAP" ]=QTRAP; 00325 quadrature_type_to_enum["QGRID" ]=QGRID; 00326 quadrature_type_to_enum["QCLOUGH" ]=QCLOUGH; 00327 } 00328 } 00329 00330 00331 std::map<QuadratureType, std::string> enum_to_quadrature_type; 00332 00333 // Initialize the enum_to_quadrature_type on first call 00334 void init_enum_to_quadrature_type () 00335 { 00336 // Build reverse map 00337 if (enum_to_quadrature_type.empty()) 00338 { 00339 // Initialize inf_map_type_to_enum on first call 00340 init_quadrature_type_to_enum(); 00341 00342 build_reverse_map (quadrature_type_to_enum.begin(), 00343 quadrature_type_to_enum.end(), 00344 enum_to_quadrature_type); 00345 } 00346 } 00347 00348 00349 //--------------------------------------------------- 00350 std::map<std::string, PreconditionerType> preconditioner_type_to_enum; 00351 00352 // Initialize preconditioner_type_to_enum on first call 00353 void init_preconditioner_type_to_enum () 00354 { 00355 if (preconditioner_type_to_enum.empty()) 00356 { 00357 preconditioner_type_to_enum["IDENTITY_PRECOND" ]=IDENTITY_PRECOND; 00358 preconditioner_type_to_enum["JACOBI_PRECOND" ]=JACOBI_PRECOND; 00359 preconditioner_type_to_enum["BLOCK_JACOBI_PRECOND" ]=BLOCK_JACOBI_PRECOND; 00360 preconditioner_type_to_enum["SOR_PRECOND" ]=SOR_PRECOND; 00361 preconditioner_type_to_enum["SSOR_PRECOND" ]=SSOR_PRECOND; 00362 preconditioner_type_to_enum["EISENSTAT_PRECOND" ]=EISENSTAT_PRECOND; 00363 preconditioner_type_to_enum["ASM_PRECOND" ]=ASM_PRECOND; 00364 preconditioner_type_to_enum["CHOLESKY_PRECOND" ]=CHOLESKY_PRECOND; 00365 preconditioner_type_to_enum["ICC_PRECOND" ]=ICC_PRECOND; 00366 preconditioner_type_to_enum["ILU_PRECOND" ]=ILU_PRECOND; 00367 preconditioner_type_to_enum["LU_PRECOND" ]=LU_PRECOND; 00368 preconditioner_type_to_enum["USER_PRECOND" ]=USER_PRECOND; 00369 preconditioner_type_to_enum["SHELL_PRECOND" ]=SHELL_PRECOND; 00370 preconditioner_type_to_enum["AMG_PRECOND" ]=AMG_PRECOND; 00371 preconditioner_type_to_enum["INVALID_PRECONDITIONER"]=INVALID_PRECONDITIONER; 00372 00373 //shorter 00374 preconditioner_type_to_enum["IDENTITY" ]=IDENTITY_PRECOND; 00375 preconditioner_type_to_enum["JACOBI" ]=JACOBI_PRECOND; 00376 preconditioner_type_to_enum["BLOCK_JACOBI"]=BLOCK_JACOBI_PRECOND; 00377 preconditioner_type_to_enum["SOR" ]=SOR_PRECOND; 00378 preconditioner_type_to_enum["SSOR" ]=SSOR_PRECOND; 00379 preconditioner_type_to_enum["EISENSTAT" ]=EISENSTAT_PRECOND; 00380 preconditioner_type_to_enum["ASM" ]=ASM_PRECOND; 00381 preconditioner_type_to_enum["CHOLESKY" ]=CHOLESKY_PRECOND; 00382 preconditioner_type_to_enum["ICC" ]=ICC_PRECOND; 00383 preconditioner_type_to_enum["ILU" ]=ILU_PRECOND; 00384 preconditioner_type_to_enum["LU" ]=LU_PRECOND; 00385 preconditioner_type_to_enum["USER" ]=USER_PRECOND; 00386 preconditioner_type_to_enum["SHELL" ]=SHELL_PRECOND; 00387 preconditioner_type_to_enum["AMG" ]=AMG_PRECOND; 00388 preconditioner_type_to_enum["INVALID" ]=INVALID_PRECONDITIONER; 00389 } 00390 } 00391 00392 00393 std::map<PreconditionerType, std::string> enum_to_preconditioner_type; 00394 00395 // Initialize the enum_to_preconditioner_type on first call 00396 void init_enum_to_preconditioner_type () 00397 { 00398 // Build reverse map 00399 if (enum_to_preconditioner_type.empty()) 00400 { 00401 // Initialize inf_map_type_to_enum on first call 00402 init_preconditioner_type_to_enum(); 00403 00404 build_reverse_map (preconditioner_type_to_enum.begin(), 00405 preconditioner_type_to_enum.end(), 00406 enum_to_preconditioner_type); 00407 } 00408 } 00409 00410 00411 00412 #ifdef LIBMESH_ENABLE_AMR 00413 //--------------------------------------------------- 00414 std::map<std::string, Elem::RefinementState> refinementstate_type_to_enum; 00415 00416 // Initialize refinementstate_type_to_enum on first call 00417 void init_refinementstate_type_to_enum () 00418 { 00419 if (refinementstate_type_to_enum.empty()) 00420 { 00421 refinementstate_type_to_enum["COARSEN" ]=Elem::COARSEN; 00422 refinementstate_type_to_enum["DO_NOTHING" ]=Elem::DO_NOTHING; 00423 refinementstate_type_to_enum["REFINE" ]=Elem::REFINE; 00424 refinementstate_type_to_enum["JUST_REFINED" ]=Elem::JUST_REFINED; 00425 refinementstate_type_to_enum["JUST_COARSENED" ]=Elem::JUST_COARSENED; 00426 refinementstate_type_to_enum["INACTIVE" ]=Elem::INACTIVE; 00427 refinementstate_type_to_enum["COARSEN_INACTIVE" ]=Elem::COARSEN_INACTIVE; 00428 refinementstate_type_to_enum["INVALID_REFINEMENTSTATE"]=Elem::INVALID_REFINEMENTSTATE; 00429 } 00430 } 00431 00432 00433 std::map<Elem::RefinementState, std::string> enum_to_refinementstate_type; 00434 00435 // Initialize the enum_to_refinementstate_type on first call 00436 void init_enum_to_refinementstate_type () 00437 { 00438 // Build reverse map 00439 if (enum_to_refinementstate_type.empty()) 00440 { 00441 // Initialize refinementstate_type_to_enum on first call 00442 init_refinementstate_type_to_enum(); 00443 00444 build_reverse_map (refinementstate_type_to_enum.begin(), 00445 refinementstate_type_to_enum.end(), 00446 enum_to_refinementstate_type); 00447 } 00448 } 00449 #endif // LIBMESH_ENABLE_AMR 00450 00451 } // end anonymous namespace 00452 00453 00454 00455 // ------------------------------------------------------ 00456 // Utility::string_to_enum<> & Utility::enum_to_string<> 00457 // full specializations 00458 namespace Utility { 00459 00460 //------------------------------------------------------ 00461 // ElemType specialization 00462 template <> 00463 ElemType string_to_enum<ElemType> (const std::string& s) 00464 { 00465 init_elem_type_to_enum(); 00466 00467 std::string upper(s); 00468 std::transform(upper.begin(), upper.end(), upper.begin(), ::toupper); 00469 00470 if (!elem_type_to_enum.count(upper)) 00471 libmesh_error(); 00472 00473 return elem_type_to_enum[upper]; 00474 } 00475 00476 00477 00478 template <> 00479 std::string enum_to_string<ElemType> (const ElemType e) 00480 { 00481 init_enum_to_elem_type(); 00482 00483 if (!enum_to_elem_type.count(e)) 00484 libmesh_error(); 00485 00486 return enum_to_elem_type[e]; 00487 } 00488 00489 00490 00491 //------------------------------------------------ 00492 // Order specialization 00493 template <> 00494 Order string_to_enum<Order> (const std::string& s) 00495 { 00496 init_order_to_enum(); 00497 00498 std::string upper(s); 00499 std::transform(upper.begin(), upper.end(), upper.begin(), ::toupper); 00500 00501 if (!order_to_enum.count(upper)) 00502 libmesh_error(); 00503 00504 return order_to_enum[upper]; 00505 } 00506 00507 00508 00509 template <> 00510 std::string enum_to_string<Order> (const Order o) 00511 { 00512 init_enum_to_order(); 00513 00514 if (!enum_to_order.count(o)) 00515 libmesh_error(); 00516 00517 return enum_to_order[o]; 00518 } 00519 00520 00521 00522 //------------------------------------------------------ 00523 // FEFamily specialization 00524 template <> 00525 FEFamily string_to_enum<FEFamily> (const std::string& s) 00526 { 00527 init_fefamily_to_enum(); 00528 00529 std::string upper(s); 00530 std::transform(upper.begin(), upper.end(), upper.begin(), ::toupper); 00531 00532 if (!fefamily_to_enum.count(upper)) 00533 { 00534 libMesh::err << "ERROR: could not convert '" << upper << "' to enum." << std::endl; 00535 libmesh_error(); 00536 } 00537 00538 return fefamily_to_enum[upper]; 00539 } 00540 00541 00542 00543 template <> 00544 std::string enum_to_string<FEFamily> (const FEFamily f) 00545 { 00546 init_enum_to_fefamily(); 00547 00548 if (!enum_to_fefamily.count(f)) 00549 libmesh_error(); 00550 00551 return enum_to_fefamily[f]; 00552 } 00553 00554 00555 00556 //------------------------------------------------------ 00557 // InfMapType specialization 00558 template <> 00559 InfMapType string_to_enum<InfMapType> (const std::string& s) 00560 { 00561 init_inf_map_type_to_enum(); 00562 00563 std::string upper(s); 00564 std::transform(upper.begin(), upper.end(), upper.begin(), ::toupper); 00565 00566 if (!inf_map_type_to_enum.count(upper)) 00567 libmesh_error(); 00568 00569 return inf_map_type_to_enum[upper]; 00570 } 00571 00572 00573 00574 template <> 00575 std::string enum_to_string<InfMapType> (const InfMapType i) 00576 { 00577 init_enum_to_inf_map_type(); 00578 00579 if (!enum_to_inf_map_type.count(i)) 00580 libmesh_error(); 00581 00582 return enum_to_inf_map_type[i]; 00583 } 00584 00585 00586 00587 //------------------------------------------------------ 00588 // QuadratureType specialization 00589 template <> 00590 QuadratureType string_to_enum<QuadratureType> (const std::string& s) 00591 { 00592 init_quadrature_type_to_enum(); 00593 00594 std::string upper(s); 00595 std::transform(upper.begin(), upper.end(), upper.begin(), ::toupper); 00596 00597 if (!quadrature_type_to_enum.count(upper)) 00598 libmesh_error(); 00599 00600 return quadrature_type_to_enum[upper]; 00601 } 00602 00603 00604 00605 template <> 00606 std::string enum_to_string<QuadratureType> (const QuadratureType i) 00607 { 00608 init_enum_to_quadrature_type(); 00609 00610 if (!enum_to_quadrature_type.count(i)) 00611 libmesh_error(); 00612 00613 return enum_to_quadrature_type[i]; 00614 } 00615 00616 00617 //------------------------------------------------------ 00618 // PreconditionerType specialization 00619 template <> 00620 PreconditionerType string_to_enum<PreconditionerType> (const std::string& s) 00621 { 00622 init_preconditioner_type_to_enum(); 00623 00624 std::string upper(s); 00625 std::transform(upper.begin(), upper.end(), upper.begin(), ::toupper); 00626 00627 if (!preconditioner_type_to_enum.count(upper)) 00628 libmesh_error(); 00629 00630 return preconditioner_type_to_enum[upper]; 00631 } 00632 00633 00634 00635 template <> 00636 std::string enum_to_string<PreconditionerType> (const PreconditionerType i) 00637 { 00638 init_enum_to_preconditioner_type(); 00639 00640 if (!enum_to_preconditioner_type.count(i)) 00641 libmesh_error(); 00642 00643 return enum_to_preconditioner_type[i]; 00644 } 00645 00646 00647 #ifdef LIBMESH_ENABLE_AMR 00648 //------------------------------------------------------ 00649 // Elem::RefinementState specialization 00650 template <> 00651 Elem::RefinementState string_to_enum<Elem::RefinementState> (const std::string& s) 00652 { 00653 init_refinementstate_type_to_enum(); 00654 00655 std::string upper(s); 00656 std::transform(upper.begin(), upper.end(), upper.begin(), ::toupper); 00657 00658 if (!refinementstate_type_to_enum.count(upper)) 00659 libmesh_error(); 00660 00661 return refinementstate_type_to_enum[upper]; 00662 } 00663 00664 00665 00666 template <> 00667 std::string enum_to_string<Elem::RefinementState> (const Elem::RefinementState i) 00668 { 00669 init_enum_to_refinementstate_type(); 00670 00671 if (!enum_to_refinementstate_type.count(i)) 00672 libmesh_error(); 00673 00674 return enum_to_refinementstate_type[i]; 00675 } 00676 #endif // LIBMESH_ENABLE_AMR 00677 00678 00679 } // namespace Utility 00680 00681 } // namespace libMesh 00682 00683 00684
Site Created By: libMesh Developers
Last modified: February 05 2013 19:54:48 UTC
Hosted By: