https://mooseframework.inl.gov
Loading...
Searching...
No Matches
CartesianIDPatternedMeshGenerator.C
Go to the documentation of this file.
1//* This file is part of the MOOSE framework
2//* https://mooseframework.inl.gov
3//*
4//* All rights reserved, see COPYRIGHT for full restrictions
5//* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6//*
7//* Licensed under LGPL 2.1, please see LICENSE for details
8//* https://www.gnu.org/licenses/lgpl-2.1.html
9
12
14
17{
19 params.addRequiredParam<std::string>("id_name", "Name of integer ID set");
20 params.addParam<std::vector<MeshGeneratorName>>(
21 "exclude_id", "Name of input meshes to be excluded in ID generation");
22 MooseEnum option("cell pattern manual", "cell");
23 params.addParam<MooseEnum>("assign_type", option, "Type of integer ID assignment");
24 params.addParam<std::vector<std::vector<dof_id_type>>>(
25 "id_pattern",
26 "User-defined element IDs. A double-indexed array starting with the upper-left corner");
27 params.addClassDescription("Generate Certesian lattice meshes with reporting ID assignment that "
28 "indentifies individual components of lattice.");
29
30 return params;
31}
32
34 const InputParameters & parameters)
35 : PatternedMeshGenerator(parameters),
36 _element_id_name(getParam<std::string>("id_name")),
37 _assign_type(
38 getParam<MooseEnum>("assign_type").getEnum<ReportingIDGeneratorUtils::AssignType>()),
39 _use_exclude_id(isParamValid("exclude_id"))
40{
42 paramError("exclude_id", "works only when \"assign_type\" is equal 'cell'");
44 paramError("id_pattern", "required when \"assign_type\" is equal to 'manual'");
45
47 _id_pattern = getParam<std::vector<std::vector<dof_id_type>>>("id_pattern");
48 _exclude_ids.resize(_input_names.size());
50 {
51 std::vector<MeshGeneratorName> exclude_id_name =
52 getParam<std::vector<MeshGeneratorName>>("exclude_id");
53 for (unsigned int i = 0; i < _input_names.size(); ++i)
54 {
55 _exclude_ids[i] = false;
56 for (auto input_name : exclude_id_name)
57 if (_input_names[i] == input_name)
58 {
59 _exclude_ids[i] = true;
60 break;
61 }
62 }
63 }
64 else
65 for (unsigned int i = 0; i < _input_names.size(); ++i)
66 _exclude_ids[i] = false;
67}
68
69std::unique_ptr<MeshBase>
71{
72 std::vector<std::unique_ptr<ReplicatedMesh>> input_meshes;
73 auto mesh = PatternedMeshGenerator::generate(&input_meshes);
74
75 unsigned int extra_id_index;
76 if (!mesh->has_elem_integer(_element_id_name))
77 extra_id_index = mesh->add_elem_integer(_element_id_name);
78 else
79 {
80 extra_id_index = mesh->get_elem_integer_index(_element_id_name);
82 "id_name", "An element integer with the name '", _element_id_name, "' already exists");
83 }
84
85 // patternedMeshGenerator for Carterisan lattice does not support duct structures
86 const bool has_assembly_duct = false;
87 const std::set<subdomain_id_type> duct_block_ids;
88 // asssign reporting IDs to individual elements
90 extra_id_index,
94 has_assembly_duct,
95 duct_block_ids,
96 input_meshes,
99
100 return mesh;
101}
registerMooseObject("ReactorApp", CartesianIDPatternedMeshGenerator)
Generates patterned Cartesian meshes with a reporting ID.
std::vector< bool > _exclude_ids
flag to indicate if exclude_id is used for each input
std::vector< std::vector< dof_id_type > > _id_pattern
hold integer ID for each input pattern cell
const bool _use_exclude_id
flag to indicate if exclude_id is defined
const ReportingIDGeneratorUtils::AssignType _assign_type
integer ID assignment type
std::unique_ptr< MeshBase > generate() override
const std::string _element_id_name
name of integer ID.
CartesianIDPatternedMeshGenerator(const InputParameters &parameters)
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)
void paramWarning(const std::string &param, Args... args) const
void paramError(const std::string &param, Args... args) const
bool isParamValid(const std::string &name) const
std::unique_ptr< MeshBase > generate() override
const std::vector< std::vector< unsigned int > > & _pattern
static InputParameters validParams()
const std::vector< MeshGeneratorName > & _input_names
MeshBase & mesh
@ manual
assign IDs based on user-defined mapping
@ cell
assign unique IDs for each tile in the lattice in sequential order
void assignReportingIDs(MeshBase &mesh, const unsigned int extra_id_index, const ReportingIDGeneratorUtils::AssignType assign_type, const bool use_exclude_id, const std::vector< bool > &exclude_ids, const bool has_assembly_boundary, const std::set< subdomain_id_type > background_block_ids, const std::vector< std::unique_ptr< libMesh::ReplicatedMesh > > &input_meshes, const std::vector< std::vector< unsigned int > > &pattern, const std::vector< std::vector< dof_id_type > > &id_pattern)
assign the reporting IDs to the output mesh from the cartesian or hexagonal patterned mesh generator