www.mooseframework.org
Public Member Functions | Private Attributes | List of all members
MeshExtruder::QueryElemSubdomainID Class Reference

This class is used during the mesh construction (extrusion) to set element ids as they are created. More...

#include <MeshExtruder.h>

Inheritance diagram for MeshExtruder::QueryElemSubdomainID:
[legend]

Public Member Functions

 QueryElemSubdomainID (std::vector< SubdomainID > existing_subdomains, std::vector< unsigned int > layers, std::vector< unsigned int > new_ids, unsigned int num_layers)
 
virtual subdomain_id_type get_subdomain_for_layer (const Elem *old_elem, unsigned int layer)
 The override from the base class for obtaining a new id based on the old (original) element and the specified layer. More...
 

Private Attributes

std::map< unsigned int, std::map< SubdomainID, unsigned int > > _layer_data
 Data structure for holding the old -> new id mapping based on the layer number. More...
 
unsigned int _num_layers
 The total number of layers in the extrusion. More...
 

Detailed Description

This class is used during the mesh construction (extrusion) to set element ids as they are created.

Definition at line 39 of file MeshExtruder.h.

Constructor & Destructor Documentation

◆ QueryElemSubdomainID()

MeshExtruder::QueryElemSubdomainID::QueryElemSubdomainID ( std::vector< SubdomainID existing_subdomains,
std::vector< unsigned int >  layers,
std::vector< unsigned int >  new_ids,
unsigned int  num_layers 
)

Definition at line 128 of file MeshExtruder.C.

133  : QueryElemSubdomainIDBase()
134 #ifndef NDEBUG
135  ,
136  _num_layers(num_layers)
137 #endif
138 {
139  // Setup our stride depending on whether the user passed unique sets in new ids or just a single
140  // set of new ids
141  const unsigned int zero = 0;
142  const unsigned int stride =
143  existing_subdomains.size() == new_ids.size() ? zero : existing_subdomains.size();
144 
145  // Populate the data structure
146  for (unsigned int i = 0; i < layers.size(); ++i)
147  for (unsigned int j = 0; j < existing_subdomains.size(); ++j)
148  _layer_data[layers[i]][existing_subdomains[j]] = new_ids[i * stride + j];
149 }
150 
151 subdomain_id_type
153  unsigned int layer)
154 {
155  mooseAssert(layer < _num_layers, "Access out of bounds: " << layer);
156 
157  // First locate the layer if it exists
158  std::map<unsigned int, std::map<SubdomainID, unsigned int>>::const_iterator layer_it =
159  _layer_data.find(layer);
160 
161  if (layer_it == _layer_data.end())
162  // If the layer wasn't found, there is no mapping so just return the original subdomain id
163  return old_elem->subdomain_id();
164  else
165  {
166  std::map<SubdomainID, unsigned int>::const_iterator sub_id_it =
167  layer_it->second.find(old_elem->subdomain_id());
168 
169  if (sub_id_it == layer_it->second.end())
170  // If the subdomain wasn't found, it won't be remapped, so just return the original subdomain
171  // id
172  return old_elem->subdomain_id();
173 
174  // Return the remapped id
175  return sub_id_it->second;
176  }
177 }
virtual subdomain_id_type get_subdomain_for_layer(const Elem *old_elem, unsigned int layer)
The override from the base class for obtaining a new id based on the old (original) element and the s...
std::map< unsigned int, std::map< SubdomainID, unsigned int > > _layer_data
Data structure for holding the old -> new id mapping based on the layer number.
Definition: MeshExtruder.h:52
unsigned int _num_layers
The total number of layers in the extrusion.
Definition: MeshExtruder.h:57

Member Function Documentation

◆ get_subdomain_for_layer()

virtual subdomain_id_type MeshExtruder::QueryElemSubdomainID::get_subdomain_for_layer ( const Elem *  old_elem,
unsigned int  layer 
)
virtual

The override from the base class for obtaining a new id based on the old (original) element and the specified layer.

Member Data Documentation

◆ _layer_data

std::map<unsigned int, std::map<SubdomainID, unsigned int> > MeshExtruder::QueryElemSubdomainID::_layer_data
private

Data structure for holding the old -> new id mapping based on the layer number.

Definition at line 52 of file MeshExtruder.h.

Referenced by QueryElemSubdomainID().

◆ _num_layers

unsigned int MeshExtruder::QueryElemSubdomainID::_num_layers
private

The total number of layers in the extrusion.

This is currently only used for a sanity check in dbg mode.

Definition at line 57 of file MeshExtruder.h.


The documentation for this class was generated from the following files: