20 #ifndef GEOS_MESH_MPICOMMUNICATIONS_FIELDIDENTIFIERS_HPP_
21 #define GEOS_MESH_MPICOMMUNICATIONS_FIELDIDENTIFIERS_HPP_
58 generateKey( location, key );
67 template<
typename T = std::vector<
string > >
68 void addElementFields( std::vector< string >
const & fieldNames, T
const & regionNames )
70 for(
auto const & regionName : regionNames )
72 addFields( fieldNames, generateKey( regionName ) );
81 std::map< string, array1d< string > >
const &
getFields()
const
93 string regionName( key );
94 regionName.erase( 0,
std::string( m_locationKeys.elemsKey()).length());
106 if( key.find( m_locationKeys.nodesKey() ) != string::npos )
110 else if( key.find( m_locationKeys.edgesKey()) != string::npos )
114 else if( key.find( m_locationKeys.facesKey()) != string::npos )
118 else if( key.find( m_locationKeys.elemsKey()) != string::npos )
124 GEOS_ERROR( GEOS_FMT(
"Invalid key, {}, was provided. Location cannot be retrieved.", key ) );
130 std::map< string, array1d< string > > m_fields;
135 static constexpr
char const * nodesKey() {
return "nodes"; }
137 static constexpr
char const * edgesKey() {
return "edges"; }
139 static constexpr
char const * facesKey() {
return "faces"; }
141 static constexpr
char const * elemsKey() {
return "elems/"; }
158 key = m_locationKeys.nodesKey();
163 key = m_locationKeys.edgesKey();
168 key = m_locationKeys.facesKey();
173 GEOS_ERROR(
"An element located field also requires a region name to be specified." );
184 string generateKey(
string const & regionName )
const
186 return stringutilities::concat(
"", m_locationKeys.elemsKey(), regionName );
194 void addFields( std::vector< string >
const fieldNames,
string const key )
196 for(
string const & field : fieldNames )
198 m_fields[key].emplace_back( field );
#define GEOS_ERROR(msg)
Raise a hard error and terminate the program.
void getLocation(string const &key, FieldLocation &location) const
Get the Location object.
string getRegionName(string const &key) const
Get the Region Name object.
void addFields(FieldLocation const location, std::vector< string > const &fieldNames)
adds fields to the fields map using the location to define a convenient key.
void addElementFields(std::vector< string > const &fieldNames, T const ®ionNames)
adds element-based fields to the fields map using the element region names to define keys.
std::map< string, array1d< string > > const & getFields() const
Get the Fields object which is the map containing the fields existing for each location.
std::string string
String type.
FieldLocation
Enum defining the possible location of a field on the mesh.
@ Node
location is node (like displacements in finite elements)
@ Face
location is face (like flux in mixed finite elements)
@ Elem
location is element (like pressure in finite volumes)
@ Edge
location is edge (like flux between fracture elements)