https://mooseframework.inl.gov
Loading...
Searching...
No Matches
ConcentricCircleGeneratorBase.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
11
14{
16 params.addRangeCheckedParam<std::vector<Real>>(
17 "ring_radii", "ring_radii>0", "Radii of major concentric circles (rings).");
18 params.addRangeCheckedParam<std::vector<unsigned int>>(
19 "ring_intervals",
20 "ring_intervals>0",
21 "Number of radial mesh intervals within each major concentric circle excluding their "
22 "boundary layers.");
23 params.addRangeCheckedParam<std::vector<Real>>(
24 "ring_radial_biases",
25 "ring_radial_biases>0",
26 "Values used to create biasing in radial meshing for ring regions.");
27 params.addRangeCheckedParam<std::vector<Real>>(
28 "ring_inner_boundary_layer_widths",
29 "ring_inner_boundary_layer_widths>=0",
30 "Widths of each ring regions that are assigned to be each ring's inner boundary layers.");
31 params.addParam<std::vector<unsigned int>>(
32 "ring_inner_boundary_layer_intervals",
33 "Number of radial intervals of the rings' inner boundary layers");
34 params.addRangeCheckedParam<std::vector<Real>>(
35 "ring_inner_boundary_layer_biases",
36 "ring_inner_boundary_layer_biases>0",
37 "Growth factors used for mesh biasing of the rings' inner boundary layers.");
38 params.addRangeCheckedParam<std::vector<Real>>(
39 "ring_outer_boundary_layer_widths",
40 "ring_outer_boundary_layer_widths>=0",
41 "Widths of each ring regions that are assigned to be each ring's outer boundary layers.");
42 params.addParam<std::vector<unsigned int>>(
43 "ring_outer_boundary_layer_intervals",
44 "Number of radial intervals of the rings' outer boundary layers");
45 params.addRangeCheckedParam<std::vector<Real>>(
46 "ring_outer_boundary_layer_biases",
47 "ring_outer_boundary_layer_biases>0",
48 "Growth factors used for mesh biasing of the rings' outer boundary layers.");
49 params.addParam<std::vector<subdomain_id_type>>(
50 "ring_block_ids", "Optional customized block ids for each ring geometry block.");
51 params.addParam<std::vector<SubdomainName>>(
52 "ring_block_names", "Optional customized block names for each ring geometry block.");
53 params.addParam<bool>("preserve_volumes",
54 true,
55 "Volume of concentric circles can be preserved using this function.");
56 params.addParam<subdomain_id_type>("block_id_shift", 0, "Integer used to shift block IDs.");
57 params.addParam<bool>("create_inward_interface_boundaries",
58 false,
59 "Whether the inward interface boundaries are created.");
60 params.addParam<bool>("create_outward_interface_boundaries",
61 true,
62 "Whether the outward interface boundaries are created.");
63 params.addParam<boundary_id_type>(
64 "interface_boundary_id_shift", 0, "Integer used to shift interface boundary IDs.");
65 params.addParam<bool>("generate_side_specific_boundaries",
66 false,
67 "whether the side-specific external boundaries are generated or not");
68 params.addRangeCheckedParam<boundary_id_type>("external_boundary_id",
69 "external_boundary_id>0",
70 "Optional customized external boundary id.");
71 params.addParam<BoundaryName>(
72 "external_boundary_name", "", "Optional customized external boundary name.");
73
74 MooseEnum tri_elem_type("TRI3 TRI6 TRI7", "TRI3");
75 params.addParam<MooseEnum>(
76 "tri_element_type", tri_elem_type, "Type of the triangular elements to be generated.");
77 MooseEnum quad_elem_type("QUAD4 QUAD8 QUAD9", "QUAD4");
78 params.addParam<MooseEnum>(
79 "quad_element_type", quad_elem_type, "Type of the quadrilateral elements to be generated.");
80
81 params.addParam<std::vector<std::string>>(
82 "inward_interface_boundary_names",
83 "Optional customized boundary names for the internal inward interfaces between block.");
84 params.addParam<std::vector<std::string>>(
85 "outward_interface_boundary_names",
86 "Optional customized boundary names for the internal outward interfaces between block.");
87
89 "ring_block_ids ring_block_names external_boundary_id external_boundary_name "
90 "inward_interface_boundary_names outward_interface_boundary_names "
91 "block_id_shift create_inward_interface_boundaries create_outward_interface_boundaries "
92 "interface_boundary_id_shift generate_side_specific_boundaries",
93 "Customized Subdomain/Boundary");
94 params.addParamNamesToGroup("ring_intervals", "General Mesh Density");
96 "ring_radial_biases ring_inner_boundary_layer_biases ring_inner_boundary_layer_widths "
97 "ring_inner_boundary_layer_intervals ring_outer_boundary_layer_biases "
98 "ring_outer_boundary_layer_widths ring_outer_boundary_layer_intervals ",
99 "Mesh Boundary Layers and Biasing Options");
100
101 params.addClassDescription("This ConcentricCircleGeneratorBase object is a base class to be "
102 "inherited for mesh generators that involve concentric circles.");
103 return params;
104}
105
107 : PolygonMeshGeneratorBase(parameters),
108 _ring_radii(isParamValid("ring_radii") ? getParam<std::vector<Real>>("ring_radii")
109 : std::vector<Real>()),
110 _ring_intervals(isParamValid("ring_intervals")
111 ? getParam<std::vector<unsigned int>>("ring_intervals")
112 : std::vector<unsigned int>()),
113 _ring_radial_biases(isParamValid("ring_radial_biases")
114 ? getParam<std::vector<Real>>("ring_radial_biases")
115 : std::vector<Real>(_ring_intervals.size(), 1.0)),
116 _ring_inner_boundary_layer_params(
117 {isParamValid("ring_inner_boundary_layer_widths")
118 ? getParam<std::vector<Real>>("ring_inner_boundary_layer_widths")
119 : std::vector<Real>(_ring_intervals.size(), 0.0),
120 std::vector<Real>(),
121 isParamValid("ring_inner_boundary_layer_intervals")
122 ? getParam<std::vector<unsigned int>>("ring_inner_boundary_layer_intervals")
123 : std::vector<unsigned int>(_ring_intervals.size(), 0),
124 isParamValid("ring_inner_boundary_layer_biases")
125 ? getParam<std::vector<Real>>("ring_inner_boundary_layer_biases")
126 : std::vector<Real>(_ring_intervals.size(), 0.0)}),
127 _ring_outer_boundary_layer_params(
128 {isParamValid("ring_outer_boundary_layer_widths")
129 ? getParam<std::vector<Real>>("ring_outer_boundary_layer_widths")
130 : std::vector<Real>(_ring_intervals.size(), 0.0),
131 std::vector<Real>(),
132 isParamValid("ring_outer_boundary_layer_intervals")
133 ? getParam<std::vector<unsigned int>>("ring_outer_boundary_layer_intervals")
134 : std::vector<unsigned int>(_ring_intervals.size(), 0),
135 isParamValid("ring_outer_boundary_layer_biases")
136 ? getParam<std::vector<Real>>("ring_outer_boundary_layer_biases")
137 : std::vector<Real>(_ring_intervals.size(), 0.0)}),
138 _ring_block_ids(isParamValid("ring_block_ids")
139 ? getParam<std::vector<subdomain_id_type>>("ring_block_ids")
140 : std::vector<subdomain_id_type>()),
141 _ring_block_names(isParamValid("ring_block_names")
142 ? getParam<std::vector<SubdomainName>>("ring_block_names")
143 : std::vector<SubdomainName>()),
144 _preserve_volumes(getParam<bool>("preserve_volumes")),
145 _block_id_shift(getParam<subdomain_id_type>("block_id_shift")),
146 _create_inward_interface_boundaries(getParam<bool>("create_inward_interface_boundaries")),
147 _create_outward_interface_boundaries(getParam<bool>("create_outward_interface_boundaries")),
148 _interface_boundary_id_shift(getParam<boundary_id_type>("interface_boundary_id_shift")),
149 _generate_side_specific_boundaries(getParam<bool>("generate_side_specific_boundaries")),
150 _external_boundary_id(isParamValid("external_boundary_id")
151 ? getParam<boundary_id_type>("external_boundary_id")
152 : 0),
153 _external_boundary_name(getParam<BoundaryName>("external_boundary_name")),
154 _inward_interface_boundary_names(
155 isParamValid("inward_interface_boundary_names")
156 ? getParam<std::vector<std::string>>("inward_interface_boundary_names")
157 : std::vector<std::string>()),
158 _outward_interface_boundary_names(
159 isParamValid("outward_interface_boundary_names")
160 ? getParam<std::vector<std::string>>("outward_interface_boundary_names")
161 : std::vector<std::string>()),
162 _tri_elem_type(getParam<MooseEnum>("tri_element_type").template getEnum<TRI_ELEM_TYPE>()),
163 _quad_elem_type(getParam<MooseEnum>("quad_element_type").template getEnum<QUAD_ELEM_TYPE>())
164{
165 // Customized interface boundary id/name related error messages
167 paramError("create_inward_interface_boundaries",
168 "If set false, 'inward_interface_boundary_names' "
169 "should not be provided as they are not used.");
171 paramError("create_outward_interface_boundaries",
172 "If set false, 'outward_interface_boundary_names' "
173 "should not be provided as they are not used.");
176 paramError("interface_boundary_id_shift",
177 "this parameter should not be set if no interface boundaries are created.");
178
179 // Rings related error messages
180 if (_ring_radii.size() != _ring_intervals.size())
181 paramError("ring_radii", "This parameter and ring_intervals must have the same length.");
182 if (_ring_radii.size() != _ring_radial_biases.size())
183 paramError("ring_radii", "This parameter and ring_radial_biases must have the same length.");
184 for (unsigned int i = 1; i < _ring_intervals.size(); i++)
185 if (_ring_radii[i] <= _ring_radii[i - 1])
186 paramError("ring_radii", "This parameter must be strictly ascending.");
193 paramError("ring_radii",
194 "The inner and outer ring boundary layer parameters must have the same sizes as "
195 "ring_radii.");
196}
197
198void
200{
202 {
203 for (unsigned int i = 0; i < _inward_interface_boundary_names.size(); i++)
204 {
205 mesh.get_boundary_info().sideset_name(i * 2 + 2 + _interface_boundary_id_shift) =
207 mesh.get_boundary_info().nodeset_name(i * 2 + 2 + _interface_boundary_id_shift) =
209 }
210 }
212 {
213 for (unsigned int i = 0; i < _outward_interface_boundary_names.size(); i++)
214 {
215 mesh.get_boundary_info().sideset_name(i * 2 + 1 + _interface_boundary_id_shift) =
217 mesh.get_boundary_info().nodeset_name(i * 2 + 1 + _interface_boundary_id_shift) =
219 }
220 }
221}
222
223void
225 std::vector<subdomain_id_type> & block_ids_old,
226 std::vector<subdomain_id_type> & block_ids_new,
227 std::vector<SubdomainName> & block_names,
228 const std::string & generator_name) const
229{
230 if (block_ids_old.size() != block_ids_new.size() || block_ids_old.size() != block_names.size())
231 mooseError("In ",
232 generator_name,
233 " ",
234 _name,
235 ": block_ids_old, block_ids_new and block_names must have the same size.");
236
237 for (auto it = block_names.begin(); it != block_names.end() - 1; it++)
238 {
239 auto it_tmp = std::find(block_names.begin(), it + 1, *(it + 1));
240 if (it_tmp != it + 1 && block_ids_new[std::distance(block_names.begin(), it + 1)] !=
241 block_ids_new[std::distance(block_names.begin(), it_tmp)])
242 mooseError("In ",
243 generator_name,
244 " ",
245 _name,
246 ": blocks with different ids cannot have the same block name.");
247 }
248 for (const auto & elem : mesh.element_ptr_range())
249 for (unsigned i = 0; i < block_ids_old.size(); ++i)
250 if (elem->subdomain_id() == block_ids_old[i])
251 {
252 elem->subdomain_id() = block_ids_new[i];
253 break;
254 }
255 for (unsigned i = 0; i < block_ids_new.size(); ++i)
256 mesh.set_subdomain_name(block_ids_new[i], block_names[i]);
257}
258
259void
261 unsigned int & block_counter,
262 unsigned int & ring_block_num,
263 std::vector<subdomain_id_type> & block_ids_old,
264 std::vector<subdomain_id_type> & block_ids_new,
265 std::vector<SubdomainName> & block_names) const
266{
267 if (_ring_intervals.front() == 1)
268 ring_block_num = _ring_intervals.size();
269 else
270 {
271 ring_block_num = _ring_intervals.size() + 1;
272 block_ids_old.push_back(_block_id_shift + 1);
273 block_ids_new.push_back(_ring_block_ids.empty() ? block_ids_old.back()
274 : _ring_block_ids.front());
275 block_names.push_back(_ring_block_names.empty()
276 ? (SubdomainName)std::to_string(block_ids_new.back())
277 : _ring_block_names.front());
278 block_counter++;
279 }
280 for (unsigned int i = ring_block_num - _ring_intervals.size(); i < ring_block_num; i++)
281 {
282 block_ids_old.push_back(_block_id_shift + 1 + i);
283 block_ids_new.push_back(_ring_block_ids.empty() ? block_ids_old.back() : _ring_block_ids[i]);
284 block_names.push_back(_ring_block_names.empty()
285 ? (SubdomainName)std::to_string(block_ids_new.back())
286 : _ring_block_names[i]);
287 block_counter++;
288 }
289}
void ErrorVector unsigned int
ConcentricCircleGeneratorBase(const InputParameters &parameters)
const std::vector< Real > _ring_radial_biases
Bias values used to induce biasing to radial meshing in ring regions.
const boundary_id_type _interface_boundary_id_shift
Shift in default boundary IDs of interfaces to avert potential conflicts.
std::vector< subdomain_id_type > _ring_block_ids
Subdomain IDs of the ring regions.
multiBdryLayerParams _ring_inner_boundary_layer_params
Widths, fractions, radial sectors and growth factors of the inner boundary layers of the ring regions...
const std::vector< std::string > _inward_interface_boundary_names
Boundary Names of the mesh's inward interface boundaries.
std::vector< SubdomainName > _ring_block_names
Subdomain Names of the ring regions.
const subdomain_id_type _block_id_shift
Shift in default subdomain IDs to avert potential conflicts with other meshes.
const std::vector< std::string > _outward_interface_boundary_names
Boundary Names of the mesh's outward interface boundaries.
multiBdryLayerParams _ring_outer_boundary_layer_params
Widths, fractions, radial sectors and growth factors of the outer boundary layers of the ring regions...
const std::vector< unsigned int > _ring_intervals
Number of rings in each circle or in the enclosing square.
void ringBlockIdsNamesPreparer(unsigned int &block_counter, unsigned int &ring_block_num, std::vector< subdomain_id_type > &block_ids_old, std::vector< subdomain_id_type > &block_ids_new, std::vector< SubdomainName > &block_names) const
Prepare user-defined ring block IDs and names to replace the default ones.
const std::vector< Real > _ring_radii
Radii of concentric circles.
void assignInterfaceBoundaryNames(ReplicatedMesh &mesh) const
Assign interface boundary names to the mesh if applicable.
const bool _create_inward_interface_boundaries
Whether inward interface boundaries are created.
void assignBlockIdsNames(ReplicatedMesh &mesh, std::vector< subdomain_id_type > &block_ids_old, std::vector< subdomain_id_type > &block_ids_new, std::vector< SubdomainName > &block_names, const std::string &generator_name) const
Assign block IDs and names to the mesh if applicable.
const bool _create_outward_interface_boundaries
Whether outward interface boundaries are created.
void addParamNamesToGroup(const std::string &space_delim_names, const std::string group_name)
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 addRangeCheckedParam(const std::string &name, const T &value, const std::string &parsed_function, const std::string &doc_string)
void paramError(const std::string &param, Args... args) const
void mooseError(Args &&... args) const
const std::string & _name
bool isParamValid(const std::string &name) const
A base class that contains common members for Reactor module mesh generators.
static InputParameters validParams()
MeshBase & mesh