https://mooseframework.inl.gov
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Protected Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
DepletionIDGenerator Class Reference

Assigns depletion IDs to elements based on reporting and material IDs. More...

#include <DepletionIDGenerator.h>

Inheritance diagram for DepletionIDGenerator:
[legend]

Public Types

typedef DataFileName DataFileParameterType
 

Public Member Functions

 DepletionIDGenerator (const InputParameters &parameters)
 
virtual std::unique_ptr< MeshBase > generate () override
 
std::unique_ptr< MeshBase > generateInternal ()
 
const std::set< MeshGeneratorName > & getRequestedMeshGenerators () const
 
const std::set< MeshGeneratorName > & getRequestedMeshGeneratorsForSub () const
 
void addParentMeshGenerator (const MeshGenerator &mg, const AddParentChildKey)
 
void addChildMeshGenerator (const MeshGenerator &mg, const AddParentChildKey)
 
const std::set< const MeshGenerator *, Comparator > & getParentMeshGenerators () const
 
const std::set< const MeshGenerator *, Comparator > & getChildMeshGenerators () const
 
const std::set< const MeshGenerator *, Comparator > & getSubMeshGenerators () const
 
bool isParentMeshGenerator (const MeshGeneratorName &name, const bool direct=true) const
 
bool isChildMeshGenerator (const MeshGeneratorName &name, const bool direct=true) const
 
bool isNullMeshName (const MeshGeneratorName &name) const
 
bool hasSaveMesh () const
 
bool hasOutput () const
 
const std::string & getSavedMeshName () const
 
bool hasGenerateData () const
 
bool isDataOnly () const
 
virtual bool enabled () const
 
std::shared_ptr< MooseObjectgetSharedPtr ()
 
std::shared_ptr< const MooseObjectgetSharedPtr () const
 
MooseAppgetMooseApp () const
 
const std::string & type () const
 
virtual const std::string & name () const
 
std::string typeAndName () const
 
std::string errorPrefix (const std::string &error_type) const
 
void callMooseError (std::string msg, const bool with_prefix) const
 
MooseObjectParameterName uniqueParameterName (const std::string &parameter_name) const
 
const InputParametersparameters () const
 
MooseObjectName uniqueName () const
 
const T & getParam (const std::string &name) const
 
std::vector< std::pair< T1, T2 > > getParam (const std::string &param1, const std::string &param2) const
 
const T * queryParam (const std::string &name) const
 
const T & getRenamedParam (const std::string &old_name, const std::string &new_name) const
 
getCheckedPointerParam (const std::string &name, const std::string &error_string="") const
 
bool isParamValid (const std::string &name) const
 
bool isParamSetByUser (const std::string &nm) const
 
void paramError (const std::string &param, Args... args) const
 
void paramWarning (const std::string &param, Args... args) const
 
void paramInfo (const std::string &param, Args... args) const
 
void connectControllableParams (const std::string &parameter, const std::string &object_type, const std::string &object_name, const std::string &object_parameter) const
 
void mooseError (Args &&... args) const
 
void mooseErrorNonPrefixed (Args &&... args) const
 
void mooseDocumentedError (const std::string &repo_name, const unsigned int issue_num, Args &&... args) const
 
void mooseWarning (Args &&... args) const
 
void mooseWarningNonPrefixed (Args &&... args) const
 
void mooseDeprecated (Args &&... args) const
 
void mooseInfo (Args &&... args) const
 
std::string getDataFileName (const std::string &param) const
 
std::string getDataFileNameByName (const std::string &relative_path) const
 
std::string getDataFilePath (const std::string &relative_path) const
 
const Parallel::Communicator & comm () const
 
processor_id_type n_processors () const
 
processor_id_type processor_id () const
 

Static Public Member Functions

static InputParameters validParams ()
 
static bool hasGenerateData (const InputParameters &params)
 
static void setHasGenerateData (InputParameters &params)
 

Public Attributes

const ConsoleStream _console
 

Static Public Attributes

static const std::string data_only_param
 
static constexpr auto SYSTEM
 
static constexpr auto NAME
 

Protected Member Functions

virtual void generateData ()
 
T & copyMeshProperty (const std::string &target_data_name, const std::string &source_data_name, const std::string &source_mesh)
 
T & copyMeshProperty (const std::string &source_data_name, const std::string &source_mesh)
 
std::unique_ptr< MeshBase > & getMesh (const std::string &param_name, const bool allow_invalid=false)
 
std::vector< std::unique_ptr< MeshBase > *> getMeshes (const std::string &param_name)
 
std::unique_ptr< MeshBase > & getMeshByName (const MeshGeneratorName &mesh_generator_name)
 
std::vector< std::unique_ptr< MeshBase > *> getMeshesByName (const std::vector< MeshGeneratorName > &mesh_generator_names)
 
void declareMeshForSub (const std::string &param_name)
 
void declareMeshesForSub (const std::string &param_name)
 
void declareMeshForSubByName (const MeshGeneratorName &mesh_generator_name)
 
void declareMeshesForSubByName (const std::vector< MeshGeneratorName > &mesh_generator_names)
 
std::unique_ptr< MeshBase > buildMeshBaseObject (unsigned int dim=libMesh::invalid_uint)
 
std::unique_ptr< ReplicatedMesh > buildReplicatedMesh (unsigned int dim=libMesh::invalid_uint)
 
std::unique_ptr< DistributedMesh > buildDistributedMesh (unsigned int dim=libMesh::invalid_uint)
 
void addMeshSubgenerator (const std::string &type, const std::string &name, Ts... extra_input_parameters)
 
void addMeshSubgenerator (const std::string &type, const std::string &name, InputParameters params)
 
void declareNullMeshName (const MeshGeneratorName &name)
 
const T & getMeshProperty (const std::string &data_name, const std::string &prefix)
 
const T & getMeshProperty (const std::string &data_name)
 
bool hasMeshProperty (const std::string &data_name, const std::string &prefix) const
 
bool hasMeshProperty (const std::string &data_name, const std::string &prefix) const
 
bool hasMeshProperty (const std::string &data_name) const
 
bool hasMeshProperty (const std::string &data_name) const
 
std::string meshPropertyName (const std::string &data_name) const
 
T & declareMeshProperty (const std::string &data_name, Args &&... args)
 
T & declareMeshProperty (const std::string &data_name, const T &data_value)
 
T & declareMeshProperty (const std::string &data_name, Args &&... args)
 
T & declareMeshProperty (const std::string &data_name, const T &data_value)
 
T & setMeshProperty (const std::string &data_name, Args &&... args)
 
T & setMeshProperty (const std::string &data_name, const T &data_value)
 
T & setMeshProperty (const std::string &data_name, Args &&... args)
 
T & setMeshProperty (const std::string &data_name, const T &data_value)
 

Static Protected Member Functions

static std::string meshPropertyName (const std::string &data_name, const std::string &prefix)
 

Protected Attributes

std::unique_ptr< MeshBase > & _input
 input mesh for adding element IDs More...
 
ExtraElementIDName _material_id_name
 material id name More...
 
MooseMesh *const _mesh
 
const bool & _enabled
 
MooseApp_app
 
const std::string _type
 
const std::string _name
 
const InputParameters_pars
 
Factory_factory
 
ActionFactory_action_factory
 
const Parallel::Communicator & _communicator
 

Detailed Description

Assigns depletion IDs to elements based on reporting and material IDs.

Definition at line 16 of file DepletionIDGenerator.h.

Constructor & Destructor Documentation

◆ DepletionIDGenerator()

DepletionIDGenerator::DepletionIDGenerator ( const InputParameters parameters)

Definition at line 39 of file DepletionIDGenerator.C.

40  : MeshGenerator(params),
41  _input(getMesh("input")),
42  _material_id_name(getParam<ExtraElementIDName>("material_id_name"))
43 {
44 }
ExtraElementIDName _material_id_name
material id name
MeshGenerator(const InputParameters &parameters)
std::unique_ptr< MeshBase > & getMesh(const std::string &param_name, const bool allow_invalid=false)
std::unique_ptr< MeshBase > & _input
input mesh for adding element IDs

Member Function Documentation

◆ generate()

std::unique_ptr< MeshBase > DepletionIDGenerator::generate ( )
overridevirtual

Implements MeshGenerator.

Definition at line 47 of file DepletionIDGenerator.C.

48 {
49  std::unique_ptr<MeshBase> mesh = std::move(_input);
50  // parsing the extra ids
51  std::vector<ExtraElementIDName> id_names;
52  id_names = getParam<std::vector<ExtraElementIDName>>("id_name");
53  if (!mesh->has_elem_integer(_material_id_name))
54  paramError("material_id_name",
55  "Material ID name '",
57  "'is not defined in input mesh!");
58  id_names.push_back(_material_id_name);
59  auto parsed_ids = MooseMeshUtils::getExtraIDUniqueCombinationMap(*mesh, {}, id_names);
60  // re-numbering if exclude_id_name is used
61  if (isParamValid("exclude_id_name") && isParamValid("exclude_id_value"))
62  {
63  const auto exclude_id_name = getParam<std::vector<ExtraElementIDName>>("exclude_id_name");
64  const auto & exclude_id_value =
65  getParam<std::vector<std::vector<dof_id_type>>>("exclude_id_value");
66  std::vector<unsigned int> id_index;
67  std::vector<std::set<dof_id_type>> id_value_set;
68  id_index.resize(exclude_id_name.size());
69  id_value_set.resize(exclude_id_name.size());
70  for (unsigned int i = 0; i < exclude_id_name.size(); ++i)
71  {
72  id_index[i] = mesh->get_elem_integer_index(exclude_id_name[i]);
73  std::copy(exclude_id_value[i].begin(),
74  exclude_id_value[i].end(),
75  std::inserter(id_value_set[i], id_value_set[i].end()));
76  }
77  // list of unique IDs not removed by "exclude_id_name" and "exclude_id_value" option
78  std::set<dof_id_type> ids;
79  for (const auto & elem : mesh->active_element_ptr_range())
80  {
81  // don't need to check if this unique parsed ID corresponding to this element is already in
82  // the "ids"
83  if (ids.count(parsed_ids[elem->id()]))
84  continue;
85  // check extra IDs of this element is defined in "exclude_id_name" and "exclude_id_value"
86  bool is_exclude_elem = false;
87  for (unsigned int i = 0; i < id_index.size(); ++i)
88  {
89  const auto id = elem->get_extra_integer(id_index[i]);
90  if (id_value_set[i].count(id))
91  {
92  is_exclude_elem = true;
93  break;
94  }
95  }
96  // if this element does not need to be excluded, having unique ID, add to "ids"
97  if (!is_exclude_elem)
98  ids.insert(parsed_ids[elem->id()]);
99  }
100  comm().set_union(ids);
101 
102  std::map<dof_id_type, dof_id_type> map_ids;
103  for (auto id : parsed_ids)
104  {
105  dof_id_type new_id = std::distance(ids.begin(), ids.find(id.second)) + 1;
106  map_ids[id.second] = new_id;
107  }
108 
109  // reassign parsed (depletion) ids
110  for (const auto & elem : mesh->active_element_ptr_range())
111  {
112  dof_id_type id = parsed_ids[elem->id()];
113  dof_id_type new_id = 0;
114  if (ids.count(id))
115  new_id = map_ids[id];
116  parsed_ids[elem->id()] = new_id;
117  }
118  }
119  // assign depletion id to mesh
120  const auto depletion_id =
121  mesh->add_elem_integer(getParam<ExtraElementIDName>("generated_id_name"));
122  for (Elem * const elem : mesh->active_element_ptr_range())
123  elem->set_extra_integer(depletion_id, parsed_ids.at(elem->id()));
124  return mesh;
125 }
std::unordered_map< dof_id_type, dof_id_type > getExtraIDUniqueCombinationMap(const MeshBase &mesh, const std::set< SubdomainID > &block_ids, std::vector< ExtraElementIDName > extra_ids)
ExtraElementIDName _material_id_name
material id name
MeshBase & mesh
const Parallel::Communicator & comm() const
bool isParamValid(const std::string &name) const
void paramError(const std::string &param, Args... args) const
std::unique_ptr< MeshBase > & _input
input mesh for adding element IDs
uint8_t dof_id_type
void set_union(T &data, const unsigned int root_id) const

◆ validParams()

InputParameters DepletionIDGenerator::validParams ( )
static

Definition at line 17 of file DepletionIDGenerator.C.

18 {
20  params.addRequiredParam<MeshGeneratorName>(
21  "input", "Name of an existing mesh generator to which we assign element IDs");
22  params.addParam<std::vector<ExtraElementIDName>>("id_name", "Extra integer id names");
23  params.addParam<ExtraElementIDName>("material_id_name", "material_id", "Material id name");
24  params.addParam<std::vector<dof_id_type>>(
25  "exclude_material_id",
26  "Define a list of material IDs to be excluded in the depletion ID generation");
27  params.addParam<std::vector<ExtraElementIDName>>(
28  "exclude_id_name", "Extra ID names that need to be excluded in the depletion ID generation");
29  params.addParam<std::vector<std::vector<dof_id_type>>>(
30  "exclude_id_value", "Extra ID values corresponding to names defined in `exclude_id_name`");
31  params.addParam<ExtraElementIDName>(
32  "generated_id_name", "depletion_id", "The generated extra element integer name");
33  params.addClassDescription(
34  "This DepletionIDGenerator source code is to assign an extra element integer for "
35  "elements on a mesh based on material and other extra element IDs that is typically used for "
36  "depletion.");
37  return params;
38 }
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
void addRequiredParam(const std::string &name, const std::string &doc_string)
static InputParameters validParams()
void addClassDescription(const std::string &doc_string)

Member Data Documentation

◆ _input

std::unique_ptr<MeshBase>& DepletionIDGenerator::_input
protected

input mesh for adding element IDs

Definition at line 26 of file DepletionIDGenerator.h.

Referenced by generate().

◆ _material_id_name

ExtraElementIDName DepletionIDGenerator::_material_id_name
protected

material id name

Definition at line 28 of file DepletionIDGenerator.h.

Referenced by generate().


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