1#ifndef DUNE_FEM_MISC_GRIDNAME_HH
2#define DUNE_FEM_MISC_GRIDNAME_HH
25 template<
class Gr
id >
struct GridName;
32 template<
class Gr
idImp >
33 static const std::string &gridName ()
35 return GridName< GridImp >::str();
38 template<
class Gr
idImp >
39 static const std::string &gridName (
const GridImp &grid )
41 return gridName< GridImp >();
49 class UnknownGridException :
public Exception {};
56 template<
class Gr
idImp >
59 static const std::string &str ()
61 static std::string str = computeString();
66 static std::string computeString ()
68 std::string name(
typeid( GridImp ).name() );
70 size_t dunePos = name.find(
"Dune" );
71 name.erase( 0, dunePos+4 );
75 long int result = std::strtol( name.c_str(), &endptr, 0 );
76 if( result == LONG_MAX || result == LONG_MIN )
77 DUNE_THROW( UnknownGridException,
"GridName: faild to determine name of grid!" );
80 name = std::string( endptr );
83 size_t pos = name.find(
"GridI" );
86 if( pos < name.size() )
87 name.erase( pos, name.size() - pos );
89 std::vector< std::string > knownGrids;
90 knownGrids.push_back(
"AlbertaGrid" );
91 knownGrids.push_back(
"ALUConformGrid" );
92 knownGrids.push_back(
"ALUCubeGrid" );
93 knownGrids.push_back(
"ALUGrid" );
94 knownGrids.push_back(
"ALUSimplexGrid" );
95 knownGrids.push_back(
"CacheItGrid" );
96 knownGrids.push_back(
"CartesianGrid" );
97 knownGrids.push_back(
"GeometryGrid" );
98 knownGrids.push_back(
"OneDGrid" );
99 knownGrids.push_back(
"P4estGrid" );
100 knownGrids.push_back(
"ParallelGrid" );
101 knownGrids.push_back(
"ParallelSimplexGrid" );
102 knownGrids.push_back(
"PrismGrid" );
103 knownGrids.push_back(
"SPGrid" );
104 knownGrids.push_back(
"UGGrid" );
105 knownGrids.push_back(
"YaspGrid" );
108 for(
size_t i=0; i < knownGrids.size(); ++i )
110 if( name == knownGrids[ i ] )
119 std::cerr <<
"WARNING: Grid name `" << name <<
"' not found in list of known grids! Please add in file " << __FILE__ << std::endl;
A few common exception classes.
#define DUNE_THROW(E, m)
Definition: exceptions.hh:218
Dune namespace.
Definition: alignedallocator.hh:13