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

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

#include <MeshExtruderGenerator.h>

Inheritance diagram for MeshExtruderGenerator::QueryElemSubdomainID:
[legend]

Public Member Functions

 QueryElemSubdomainID (const std::vector< SubdomainID > &existing_subdomains, std::vector< unsigned int > layers, const 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 47 of file MeshExtruderGenerator.h.

Constructor & Destructor Documentation

◆ QueryElemSubdomainID()

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

Definition at line 126 of file MeshExtruderGenerator.C.

131  : QueryElemSubdomainIDBase(), _num_layers(num_layers)
132 {
133  // Setup our stride depending on whether the user passed unique sets in new ids or just a single
134  // set of new ids
135  const unsigned int stride =
136  existing_subdomains.size() == new_ids.size() ? 0 : existing_subdomains.size();
137 
138  if (layers.size() == 0)
139  for (unsigned int i = 0; i < _num_layers; i++)
140  layers.push_back(i);
141 
142  // Populate the data structure
143  for (unsigned int i = 0; i < layers.size(); ++i)
144  for (unsigned int j = 0; j < existing_subdomains.size(); ++j)
145  _layer_data[layers[i]][existing_subdomains[j]] = new_ids[i * stride + j];
146 }
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.
unsigned int _num_layers
The total number of layers in the extrusion.

Member Function Documentation

◆ get_subdomain_for_layer()

subdomain_id_type MeshExtruderGenerator::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.

Definition at line 149 of file MeshExtruderGenerator.C.

151 {
152  mooseAssert(layer < _num_layers, "Access out of bounds: " << layer);
153 
154  // First locate the layer if it exists
155  std::map<unsigned int, std::map<SubdomainID, unsigned int>>::const_iterator layer_it =
156  _layer_data.find(layer);
157 
158  if (layer_it == _layer_data.end())
159  // If the layer wasn't found, there is no mapping so just return the original subdomain id
160  return old_elem->subdomain_id();
161  else
162  {
163  std::map<SubdomainID, unsigned int>::const_iterator sub_id_it =
164  layer_it->second.find(old_elem->subdomain_id());
165 
166  if (sub_id_it == layer_it->second.end())
167  // If the subdomain wasn't found, it won't be remapped, so just return the original subdomain
168  // id
169  return old_elem->subdomain_id();
170 
171  // Return the remapped id
172  return sub_id_it->second;
173  }
174 }
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.
unsigned int _num_layers
The total number of layers in the extrusion.

Member Data Documentation

◆ _layer_data

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

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

Definition at line 60 of file MeshExtruderGenerator.h.

Referenced by QueryElemSubdomainID().

◆ _num_layers

unsigned int MeshExtruderGenerator::QueryElemSubdomainID::_num_layers
private

The total number of layers in the extrusion.

Definition at line 63 of file MeshExtruderGenerator.h.

Referenced by QueryElemSubdomainID().


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