19 #ifndef GEOS_MESH_MESHOBJECTPATH_HPP_
20 #define GEOS_MESH_MESHOBJECTPATH_HPP_
23 #include "codingUtilities/EnumStrings.hpp"
46 using permutationMapType = std::map< string, std::map< string, std::map< string, std::vector< string > > > >;
95 return m_pathPermutations;
119 FUNC && func )
const;
134 FUNC && func )
const;
150 #if defined(MESH_OBJECT_PATH_PRIVATE_FUNCTION_UNIT_TESTING)
151 template<
typename OBJECT_TYPE >
152 bool testCheckObjectTypeConsistency()
154 return checkObjectTypeConsistency< OBJECT_TYPE >();
157 std::vector< string > testFillPathTokens(
string const & path,
160 return fillPathTokens( path, meshBodies );
177 template<
typename OBJECT_TYPE,
180 MeshLevel & meshLevel,
181 FUNC && func )
const;
183 template<
typename OBJECT_TYPE,
186 MeshLevel
const & meshLevel,
187 FUNC && func )
const;
196 template<
typename OBJECT_TYPE >
197 bool checkObjectTypeConsistency()
const;
202 void printPermutations()
const;
210 std::vector< string > fillPathTokens(
string const & path,
211 dataRepository::Group
const & meshBodies )
const;
219 void processPathTokens( std::vector< string >
const & pathTokens,
220 dataRepository::Group
const & meshBodies );
243 MeshLevel::groupStructKeys::nodeManagerString(),
244 MeshLevel::groupStructKeys::edgeManagerString(),
245 MeshLevel::groupStructKeys::faceManagerString(),
246 MeshLevel::groupStructKeys::elemManagerString(),
249 template<
typename OBJECT_TYPE >
250 bool MeshObjectPath::checkObjectTypeConsistency()
const
252 bool consistent =
false;
255 consistent = std::is_same< NodeManager, OBJECT_TYPE >::value;
259 consistent = std::is_same< EdgeManager, OBJECT_TYPE >::value;
263 consistent = std::is_same< FaceManager, OBJECT_TYPE >::value;
267 consistent = std::is_base_of< ElementRegionBase, OBJECT_TYPE >::value ||
268 std::is_base_of< ElementSubRegionBase, OBJECT_TYPE >::value;
273 template<
typename OBJECT_TYPE,
276 MeshLevel & meshLevel,
279 forObjectsInPath< OBJECT_TYPE >( levelPair,
const_cast< MeshLevel
const &
>( meshLevel ), [&]( OBJECT_TYPE
const &
object )
281 func(
const_cast< OBJECT_TYPE &
>(
object) );
285 template<
typename OBJECT_TYPE,
288 MeshLevel
const & meshLevel,
293 func(
dynamic_cast< OBJECT_TYPE
const &
>(meshLevel.getNodeManager() ) );
297 func(
dynamic_cast< OBJECT_TYPE
const &
>(meshLevel.getEdgeManager()) );
301 func(
dynamic_cast< OBJECT_TYPE
const &
>(meshLevel.getFaceManager()) );
305 ElementRegionManager
const & elemRegionMan = meshLevel.getElemManager();
306 for(
auto & elemRegionPair : levelPair.second )
308 ElementRegionBase
const & elemRegion = elemRegionMan.getRegion( elemRegionPair.first );
309 if( std::is_base_of< ElementRegionBase, OBJECT_TYPE >::value )
311 func(
dynamic_cast< OBJECT_TYPE
const &
>(elemRegion) );
315 for(
auto & elemSubRegionName : elemRegionPair.second )
317 ElementSubRegionBase
const & subRegion = elemRegion.getSubRegion( elemSubRegionName );
318 if( std::is_base_of< ElementSubRegionBase, OBJECT_TYPE >::value ||
319 std::is_same< dataRepository::Group, OBJECT_TYPE >::value )
321 func(
dynamic_cast< OBJECT_TYPE
const &
>(subRegion) );
333 template<
typename OBJECT_TYPE,
339 [&](
auto const &
object )
341 func(
const_cast< OBJECT_TYPE &
>(
object) );
345 template<
typename OBJECT_TYPE,
typename FUNC >
349 checkObjectTypeConsistency< OBJECT_TYPE >();
350 for(
auto const & meshBodyPair : m_pathPermutations )
353 for(
auto const & meshLevelPair : meshBodyPair.second )
356 forObjectsInPath< OBJECT_TYPE, FUNC >( meshLevelPair, meshLevel, std::forward< FUNC >( func ));
361 template<
typename OBJECT_TYPE,
367 string const levelName = meshLevel.
getName();
369 auto bodyIter = m_pathPermutations.find( bodyName );
370 if( bodyIter != m_pathPermutations.end() )
372 auto const levelIter = bodyIter->second.find( levelName );
373 if( levelIter != bodyIter->second.end() )
379 if( checkObjectTypeConsistency< OBJECT_TYPE >() ||
380 std::is_same< OBJECT_TYPE, dataRepository::Group >::value )
382 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.