https://mooseframework.inl.gov
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Private Member Functions | Static Private Member Functions | Private 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< CSG::CSGBasegenerateInternalCSG ()
 
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 hasGenerateCSG () const
 
bool isDataOnly () const
 
virtual bool enabled () const
 
std::shared_ptr< MooseObjectgetSharedPtr ()
 
std::shared_ptr< const MooseObjectgetSharedPtr () const
 
bool isKokkosObject () const
 
MooseAppgetMooseApp () const
 
const std::string & type () const
 
const std::string & name () const
 
std::string typeAndName () const
 
MooseObjectParameterName uniqueParameterName (const std::string &parameter_name) const
 
MooseObjectName uniqueName () const
 
const InputParametersparameters () const
 
const hit::Node * getHitNode () const
 
bool hasBase () const
 
const std::string & getBase () const
 
const TgetParam (const std::string &name) const
 
std::vector< std::pair< T1, T2 > > getParam (const std::string &param1, const std::string &param2) const
 
const TqueryParam (const std::string &name) const
 
const TgetRenamedParam (const std::string &old_name, const std::string &new_name) const
 
T getCheckedPointerParam (const std::string &name, const std::string &error_string="") const
 
bool isParamValid (const std::string &name) const
 
bool isParamSetByUser (const std::string &name) const
 
void connectControllableParams (const std::string &parameter, const std::string &object_type, const std::string &object_name, const std::string &object_parameter) const
 
void paramError (const std::string &param, Args... args) const
 
void paramWarning (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
 
std::string messagePrefix (const bool hit_prefix=true) const
 
std::string errorPrefix (const std::string &) const
 
void mooseError (Args &&... args) const
 
void mooseDocumentedError (const std::string &repo_name, const unsigned int issue_num, Args &&... args) const
 
void mooseErrorNonPrefixed (Args &&... args) const
 
void mooseWarning (Args &&... args) const
 
void mooseWarning (Args &&... args) const
 
void mooseWarningNonPrefixed (Args &&... args) const
 
void mooseWarningNonPrefixed (Args &&... args) const
 
void mooseDeprecated (Args &&... args) const
 
void mooseDeprecated (Args &&... args) const
 
void mooseDeprecatedNoTrace (Args &&... args) const
 
void mooseInfo (Args &&... args) const
 
void callMooseError (std::string msg, const bool with_prefix, const hit::Node *node=nullptr, const bool show_trace=true) 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 bool hasGenerateCSG (const InputParameters &params)
 
static void callMooseError (MooseApp *const app, const InputParameters &params, std::string msg, const bool with_prefix, const hit::Node *node, const bool show_trace=true)
 
static void setHasGenerateData (InputParameters &params)
 
static void setHasGenerateCSG (InputParameters &params)
 

Public Attributes

 usingCombinedWarningSolutionWarnings
 
const ConsoleStream _console
 

Static Public Attributes

static const std::string data_only_param
 
static const std::string type_param
 
static const std::string name_param
 
static const std::string unique_name_param
 
static const std::string app_param
 
static const std::string moose_base_param
 
static const std::string kokkos_object_param
 
static constexpr auto SYSTEM
 
static constexpr auto NAME
 

Protected Member Functions

virtual void generateData ()
 
virtual std::unique_ptr< CSG::CSGBasegenerateCSG ()
 
TcopyMeshProperty (const std::string &target_data_name, const std::string &source_data_name, const std::string &source_mesh)
 
TcopyMeshProperty (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)
 
std::unique_ptr< CSG::CSGBase > & getCSGBase (const std::string &param_name)
 
std::unique_ptr< CSG::CSGBase > & getCSGBaseByName (const MeshGeneratorName &mesh_generator_name)
 
std::vector< std::unique_ptr< CSG::CSGBase > * > getCSGBases (const std::string &param_name)
 
std::vector< std::unique_ptr< CSG::CSGBase > * > getCSGBasesByName (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)
 
void flagInvalidSolutionInternal (const InvalidSolutionID invalid_solution_id) const
 
InvalidSolutionID registerInvalidSolutionInternal (const std::string &message, const bool warning) const
 
const TgetMeshProperty (const std::string &data_name, const std::string &prefix)
 
const TgetMeshProperty (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
 
TdeclareMeshProperty (const std::string &data_name, Args &&... args)
 
TdeclareMeshProperty (const std::string &data_name, const T &data_value)
 
TdeclareMeshProperty (const std::string &data_name, Args &&... args)
 
TdeclareMeshProperty (const std::string &data_name, const T &data_value)
 
TsetMeshProperty (const std::string &data_name, Args &&... args)
 
TsetMeshProperty (const std::string &data_name, const T &data_value)
 
TsetMeshProperty (const std::string &data_name, Args &&... args)
 
TsetMeshProperty (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
 
ExtraElementIDName _material_id_name
 material id name
 
MooseMesh *const _mesh
 
const bool & _enabled
 
MooseApp_app
 
Factory_factory
 
ActionFactory_action_factory
 
const std::string & _type
 
const std::string & _name
 
const InputParameters_pars
 
const Parallel::Communicator & _communicator
 

Private Member Functions

virtual std::string meshPropertyPrefix (const std::string &) const override final
 
void checkGetMesh (const MeshGeneratorName &mesh_generator_name, const std::string &param_name) const
 
const MeshGeneratorName * getMeshGeneratorNameFromParam (const std::string &param_name, const bool allow_invalid) const
 
const std::vector< MeshGeneratorName > & getMeshGeneratorNamesFromParam (const std::string &param_name) const
 
RestartableDataValuesetMeshPropertyHelper (const std::string &data_name)
 
const RestartableDataValuegetMeshPropertyInternal (const std::string &data_name, const std::string &prefix) const
 
void mooseErrorInternal (Args &&... args) const
 

Static Private Member Functions

static const hit::Node * getHitNode (const InputParameters &params)
 
static std::string messagePrefix (const InputParameters &params, const bool hit_prefix)
 

Private Attributes

std::set< MeshGeneratorName > _requested_mesh_generators
 
std::set< MeshGeneratorName > _requested_mesh_generators_for_sub
 
std::vector< std::pair< std::string, std::unique_ptr< MeshBase > * > > _requested_meshes
 
std::vector< std::pair< std::string, std::unique_ptr< CSG::CSGBase > * > > _requested_csg_bases
 
std::unique_ptr< MeshBase > _null_mesh
 
std::unique_ptr< CSG::CSGBase_null_csg_base
 
std::set< const MeshGenerator *, Comparator > _parent_mesh_generators
 
std::set< const MeshGenerator *, Comparator > _child_mesh_generators
 
std::set< const MeshGenerator *, Comparator > _sub_mesh_generators
 
std::set< std::string > _null_mesh_names
 
const std::string & _save_with_name
 
const bool _data_only
 
const ParallelParamObject_parent
 
const MooseBase_si_moose_base
 
const FEProblemBase_si_problem
 
MooseApp_meta_data_app
 
const MooseObject *const _meta_data_object
 

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}
std::unique_ptr< MeshBase > & _input
input mesh for adding element IDs
ExtraElementIDName _material_id_name
material id name
std::unique_ptr< MeshBase > & getMesh(const std::string &param_name, const bool allow_invalid=false)

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}
unsigned int count
void paramError(const std::string &param, Args... args) const
bool isParamValid(const std::string &name) const
void set_union(T &data, const unsigned int root_id) const
const Parallel::Communicator & comm() const
MeshBase & mesh
std::unordered_map< dof_id_type, dof_id_type > getExtraIDUniqueCombinationMap(const MeshBase &mesh, const std::set< SubdomainID > &block_ids, std::vector< ExtraElementIDName > extra_ids)
uint8_t dof_id_type

◆ 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");
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 addRequiredParam(const std::string &name, const std::string &doc_string)
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
void addClassDescription(const std::string &doc_string)
static InputParameters validParams()

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: