https://mooseframework.inl.gov
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());
49  if (_use_exclude_id)
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 
69 std::unique_ptr<MeshBase>
71 {
73 
74  unsigned int extra_id_index;
75  if (!mesh->has_elem_integer(_element_id_name))
76  extra_id_index = mesh->add_elem_integer(_element_id_name);
77  else
78  {
79  extra_id_index = mesh->get_elem_integer_index(_element_id_name);
81  "id_name", "An element integer with the name '", _element_id_name, "' already exists");
82  }
83 
84  // patternedMeshGenerator for Carterisan lattice does not support duct structures
85  const bool has_assembly_duct = false;
86  const std::set<subdomain_id_type> duct_block_ids;
87  // asssign reporting IDs to individual elements
89  extra_id_index,
93  has_assembly_duct,
94  duct_block_ids,
95  _meshes,
96  _pattern,
97  _id_pattern);
98 
99  return mesh;
100 }
std::vector< std::unique_ptr< ReplicatedMesh > > _meshes
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 ...
assign IDs based on user-defined mapping
const std::vector< std::vector< unsigned int > > & _pattern
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
std::vector< bool > _exclude_ids
flag to indicate if exclude_id is used for each input
AssignType
Enum item for reporting id assign types.
MeshBase & mesh
static InputParameters validParams()
void addRequiredParam(const std::string &name, const std::string &doc_string)
Generates patterned Cartesian meshes with a reporting ID.
bool isParamValid(const std::string &name) const
registerMooseObject("ReactorApp", CartesianIDPatternedMeshGenerator)
void paramError(const std::string &param, Args... args) const
assign unique IDs for each tile in the lattice in sequential order
CartesianIDPatternedMeshGenerator(const InputParameters &parameters)
std::unique_ptr< MeshBase > generate() override
std::unique_ptr< MeshBase > generate() override
const bool _use_exclude_id
flag to indicate if exclude_id is defined
const ReportingIDGeneratorUtils::AssignType _assign_type
integer ID assignment type
void addClassDescription(const std::string &doc_string)
void paramWarning(const std::string &param, Args... args) const
std::vector< std::vector< dof_id_type > > _id_pattern
hold integer ID for each input pattern cell
const std::string _element_id_name
name of integer ID.
const std::vector< MeshGeneratorName > & _input_names