20 #ifndef GEOS_MESH_MESHOBJECTPATH_HPP_
21 #define GEOS_MESH_MESHOBJECTPATH_HPP_
47 using permutationMapType = std::map< string, std::map< string, std::map< string, std::vector< string > > > >;
96 return m_pathPermutations;
120 FUNC && func )
const;
135 FUNC && func )
const;
151 #if defined(MESH_OBJECT_PATH_PRIVATE_FUNCTION_UNIT_TESTING)
152 template<
typename OBJECT_TYPE >
153 bool testCheckObjectTypeConsistency()
155 return checkObjectTypeConsistency< OBJECT_TYPE >();
158 std::vector< string > testFillPathTokens(
string const & path,
161 return fillPathTokens( path, meshBodies );
178 template<
typename OBJECT_TYPE,
181 MeshLevel & meshLevel,
182 FUNC && func )
const;
184 template<
typename OBJECT_TYPE,
187 MeshLevel
const & meshLevel,
188 FUNC && func )
const;
197 template<
typename OBJECT_TYPE >
198 bool checkObjectTypeConsistency()
const;
203 void printPermutations()
const;
211 std::vector< string > fillPathTokens(
string const & path,
212 dataRepository::Group
const & meshBodies )
const;
220 void processPathTokens( std::vector< string >
const & pathTokens,
221 dataRepository::Group
const & meshBodies );
244 MeshLevel::groupStructKeys::nodeManagerString(),
245 MeshLevel::groupStructKeys::edgeManagerString(),
246 MeshLevel::groupStructKeys::faceManagerString(),
247 MeshLevel::groupStructKeys::elemManagerString(),
250 template<
typename OBJECT_TYPE >
251 bool MeshObjectPath::checkObjectTypeConsistency()
const
253 bool consistent =
false;
256 consistent = std::is_same< NodeManager, OBJECT_TYPE >::value;
260 consistent = std::is_same< EdgeManager, OBJECT_TYPE >::value;
264 consistent = std::is_same< FaceManager, OBJECT_TYPE >::value;
268 consistent = std::is_base_of< ElementRegionBase, OBJECT_TYPE >::value ||
269 std::is_base_of< ElementSubRegionBase, OBJECT_TYPE >::value;
274 template<
typename OBJECT_TYPE,
277 MeshLevel & meshLevel,
280 forObjectsInPath< OBJECT_TYPE >( levelPair,
const_cast< MeshLevel
const &
>( meshLevel ), [&]( OBJECT_TYPE
const &
object )
282 func(
const_cast< OBJECT_TYPE &
>(
object) );
286 template<
typename OBJECT_TYPE,
289 MeshLevel
const & meshLevel,
294 func(
dynamic_cast< OBJECT_TYPE
const &
>(meshLevel.getNodeManager() ) );
298 func(
dynamic_cast< OBJECT_TYPE
const &
>(meshLevel.getEdgeManager()) );
302 func(
dynamic_cast< OBJECT_TYPE
const &
>(meshLevel.getFaceManager()) );
306 ElementRegionManager
const & elemRegionMan = meshLevel.getElemManager();
307 for(
auto & elemRegionPair : levelPair.second )
309 ElementRegionBase
const & elemRegion = elemRegionMan.getRegion( elemRegionPair.first );
310 if( std::is_base_of< ElementRegionBase, OBJECT_TYPE >::value )
312 func(
dynamic_cast< OBJECT_TYPE
const &
>(elemRegion) );
316 for(
auto & elemSubRegionName : elemRegionPair.second )
318 ElementSubRegionBase
const & subRegion = elemRegion.getSubRegion( elemSubRegionName );
319 if( std::is_base_of< ElementSubRegionBase, OBJECT_TYPE >::value ||
320 std::is_same< dataRepository::Group, OBJECT_TYPE >::value )
322 func(
dynamic_cast< OBJECT_TYPE
const &
>(subRegion) );
334 template<
typename OBJECT_TYPE,
340 [&](
auto const &
object )
342 func(
const_cast< OBJECT_TYPE &
>(
object) );
346 template<
typename OBJECT_TYPE,
typename FUNC >
350 checkObjectTypeConsistency< OBJECT_TYPE >();
351 for(
auto const & meshBodyPair : m_pathPermutations )
354 for(
auto const & meshLevelPair : meshBodyPair.second )
357 forObjectsInPath< OBJECT_TYPE, FUNC >( meshLevelPair, meshLevel, std::forward< FUNC >( func ));
362 template<
typename OBJECT_TYPE,
368 string const levelName = meshLevel.
getName();
370 auto bodyIter = m_pathPermutations.find( bodyName );
371 if( bodyIter != m_pathPermutations.end() )
373 auto const levelIter = bodyIter->second.find( levelName );
374 if( levelIter != bodyIter->second.end() )
380 if( checkObjectTypeConsistency< OBJECT_TYPE >() ||
381 std::is_same< OBJECT_TYPE, dataRepository::Group >::value )
383 forObjectsInPath< OBJECT_TYPE, FUNC >( *levelIter, meshLevel, std::forward< FUNC >( func ) );
#define GEOS_ERROR(msg)
Raise a hard error and terminate the program.
The class is used to manage mesh body.
MeshLevel & getMeshLevel(T const &level) const
Get a reference to a MeshLevel.
Class facilitating the representation of a multi-level discretization of a MeshBody.
Class to hold the path to a collection of mesh objects.
void processPath(string const path, dataRepository::Group const &meshBodies)
Processes the path string into the permutation container.
void forObjectsInPath(dataRepository::Group &meshBodies, FUNC &&func) const
LLoop over objects in the path and execute a callback function.
bool containsMeshLevel(MeshLevel const &meshLevel) const
Helper function to decide whether a given meshLevel is in the objectPath.
permutationMapType const & pathPermutations() const
Get the m_pathPermutations object.
MeshObjectPath(string const path, dataRepository::Group const &meshBodies)
Construct a new Mesh Object Path object.
ObjectTypes
Contains enums for the types of objects.
@ invalid
an invalide object
std::map< string, std::map< string, std::map< string, std::vector< string > > > > permutationMapType
The container type that holds the path information The first key is the name of a MeshBody The second...
ObjectTypes const & getObjectType() const
Get the Object Type object.
string const & getName() const
Get group name.
T & getGroup(KEY const &key)
Return a reference to a sub-group of the current Group.
Group & getParent()
Access the group's parent.
ENUM_STRINGS(LinearSolverParameters::SolverType, "direct", "cg", "gmres", "fgmres", "bicgstab", "preconditioner")
Declare strings associated with enumeration values.
mapBase< TKEY, TVAL, std::integral_constant< bool, true > > map
Ordered map type.