Line data Source code
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 :
10 : #include "RadiationTransferAction.h"
11 : #include "Factory.h"
12 : #include "MooseMesh.h"
13 : #include "MeshGeneratorMesh.h"
14 : #include "FEProblemBase.h"
15 : #include "PatchSidesetGenerator.h"
16 : #include "ViewFactorRayBC.h"
17 : #include "ViewFactorRayStudy.h"
18 :
19 : registerMooseAction("HeatTransferApp", RadiationTransferAction, "append_mesh_generator");
20 : registerMooseAction("HeatTransferApp", RadiationTransferAction, "setup_mesh_complete");
21 : registerMooseAction("HeatTransferApp", RadiationTransferAction, "add_user_object");
22 : registerMooseAction("HeatTransferApp", RadiationTransferAction, "add_bc");
23 : registerMooseAction("HeatTransferApp", RadiationTransferAction, "add_ray_boundary_condition");
24 :
25 : InputParameters
26 315 : RadiationTransferAction::validParams()
27 : {
28 315 : InputParameters params = Action::validParams();
29 315 : params.addClassDescription(
30 : "This action sets up the net radiation calculation between specified sidesets.");
31 :
32 630 : params.addRequiredParam<std::vector<BoundaryName>>(
33 : "boundary", "The boundaries that participate in the radiative exchange.");
34 :
35 630 : params.addParam<std::vector<BoundaryName>>(
36 : "adiabatic_boundary",
37 : {},
38 : "The adiabatic boundaries that participate in the radiative exchange.");
39 :
40 630 : params.addParam<std::vector<BoundaryName>>(
41 : "fixed_temperature_boundary",
42 : {},
43 : "The fixed temperature boundaries that participate in the radiative exchange.");
44 :
45 630 : params.addParam<std::vector<FunctionName>>(
46 : "fixed_boundary_temperatures", {}, "The temperatures of the fixed boundary.");
47 :
48 630 : params.addRequiredParam<std::vector<unsigned int>>("n_patches",
49 : "Number of radiation patches per sideset.");
50 : MultiMooseEnum partitioning(
51 315 : "default=-3 metis=-2 parmetis=-1 linear=0 centroid hilbert_sfc morton_sfc", "default");
52 315 : partitioning.addValidName("grid");
53 630 : params.addParam<MultiMooseEnum>(
54 : "partitioners",
55 : partitioning,
56 : "Specifies a mesh partitioner to use when preparing the radiation patches.");
57 :
58 315 : MultiMooseEnum direction("x y z radial");
59 630 : params.addParam<MultiMooseEnum>("centroid_partitioner_directions",
60 : direction,
61 : "Specifies the sort direction if using the centroid partitioner. "
62 : "Available options: x, y, z, radial");
63 :
64 630 : params.addRequiredParam<VariableName>("temperature", "The coupled temperature variable.");
65 630 : params.addRequiredParam<std::vector<FunctionName>>("emissivity",
66 : "Emissivities for each boundary.");
67 :
68 630 : MooseEnum view_factor_calculator("analytical ray_tracing", "ray_tracing");
69 630 : params.addParam<MooseEnum>(
70 : "view_factor_calculator", view_factor_calculator, "The view factor calculator being used.");
71 :
72 630 : params.addParam<bool>(
73 630 : "print_view_factor_info", false, "Flag to print information about computed view factors.");
74 945 : params.addParam<bool>("normalize_view_factor",
75 630 : true,
76 : "Determines if view factors are normalized to sum to one (consistent with "
77 : "their definition).");
78 :
79 : std::vector<BoundaryName> empty = {};
80 630 : params.addParam<std::vector<BoundaryName>>(
81 : "symmetry_boundary",
82 : empty,
83 : "The sidesets that represent symmetry lines/planes for the problem. These sidesets do not "
84 : "participate in the radiative exchange"
85 : "so they should not be listed in the sidesets parameter.");
86 :
87 630 : MooseEnum qtypes("GAUSS GRID", "GRID");
88 630 : params.addParam<MooseEnum>(
89 : "ray_tracing_face_type", qtypes, "The face quadrature rule type used for ray tracing.");
90 :
91 : MooseEnum qorders("CONSTANT FIRST SECOND THIRD FOURTH FIFTH SIXTH SEVENTH EIGHTH NINTH TENTH "
92 : "ELEVENTH TWELFTH THIRTEENTH FOURTEENTH FIFTEENTH SIXTEENTH SEVENTEENTH "
93 : "EIGHTTEENTH NINTEENTH TWENTIETH",
94 630 : "CONSTANT");
95 630 : params.addParam<MooseEnum>(
96 : "ray_tracing_face_order", qorders, "The face quadrature rule order used for ray tracing.");
97 :
98 630 : params.addParam<unsigned int>(
99 : "polar_quad_order",
100 630 : 16,
101 : "Order of the polar quadrature [polar angle is between ray and normal]. Must be even. Only "
102 : "used if view_factor_calculator = ray_tracing.");
103 630 : params.addParam<unsigned int>(
104 : "azimuthal_quad_order",
105 630 : 8,
106 : "Order of the azimuthal quadrature per quadrant [azimuthal angle is measured in "
107 : "a plane perpendicular to the normal]. Only used if view_factor_calculator = "
108 : "ray_tracing.");
109 :
110 315 : return params;
111 315 : }
112 :
113 315 : RadiationTransferAction::RadiationTransferAction(const InputParameters & params)
114 : : Action(params),
115 315 : _boundary_names(getParam<std::vector<BoundaryName>>("boundary")),
116 945 : _view_factor_calculator(getParam<MooseEnum>("view_factor_calculator"))
117 : {
118 315 : const auto & symmetry_names = getParam<std::vector<BoundaryName>>("symmetry_boundary");
119 :
120 315 : if (_view_factor_calculator != "ray_tracing")
121 : {
122 420 : for (const auto & param_name : {"polar_quad_order",
123 : "azimuthal_quad_order",
124 : "ray_tracing_face_type",
125 525 : "ray_tracing_face_order"})
126 840 : if (params.isParamSetByUser(param_name))
127 0 : paramWarning(param_name,
128 : "Only used for view_factor_calculator = ray_tracing. It is ignored for this "
129 : "calculation.");
130 :
131 105 : if (symmetry_names.size())
132 0 : paramError("symmetry_boundary",
133 : "Symmetry boundaries are only supported with view_factor_calculator = "
134 : "ray_tracing.");
135 : }
136 : else
137 : {
138 : // check that there is no overlap between sidesets and symmetry sidesets
139 1225 : for (const auto & name : _boundary_names)
140 1015 : if (std::find(symmetry_names.begin(), symmetry_names.end(), name) != symmetry_names.end())
141 0 : paramError("boundary",
142 : "Boundary ",
143 : name,
144 : " is present in parameter boundary and symmetry_boundary.");
145 : }
146 315 : }
147 :
148 : void
149 315 : RadiationTransferAction::act()
150 : {
151 315 : if (_current_task == "append_mesh_generator")
152 63 : addMeshGenerator();
153 252 : else if (_current_task == "setup_mesh_complete")
154 63 : radiationPatchNames();
155 189 : else if (_current_task == "add_user_object")
156 : {
157 63 : addRadiationObject();
158 63 : addRayStudyObject();
159 63 : addViewFactorObject();
160 : }
161 126 : else if (_current_task == "add_bc")
162 63 : addRadiationBCs();
163 63 : else if (_current_task == "add_ray_boundary_condition")
164 63 : addRayBCs();
165 315 : }
166 :
167 : void
168 63 : RadiationTransferAction::addRadiationBCs() const
169 : {
170 63 : InputParameters params = _factory.getValidParams("GrayLambertNeumannBC");
171 :
172 : // set boundary
173 63 : std::vector<std::vector<std::string>> radiation_patch_names = bcRadiationPatchNames();
174 : std::vector<BoundaryName> boundary_names;
175 224 : for (auto & e1 : radiation_patch_names)
176 448 : for (auto & e2 : e1)
177 287 : boundary_names.push_back(e2);
178 :
179 63 : params.set<std::vector<BoundaryName>>("boundary") = boundary_names;
180 :
181 : // set temperature variable
182 189 : params.set<NonlinearVariableName>("variable") = getParam<VariableName>("temperature");
183 :
184 : // set radiationuserobject
185 126 : params.set<UserObjectName>("surface_radiation_object_name") = radiationObjectName();
186 :
187 126 : _problem->addBoundaryCondition("GrayLambertNeumannBC", "gray_lamber_neumann_bc_" + _name, params);
188 63 : }
189 :
190 : void
191 63 : RadiationTransferAction::addViewFactorObject() const
192 : {
193 63 : std::vector<std::vector<std::string>> radiation_patch_names = radiationPatchNames();
194 : std::vector<BoundaryName> boundary_names;
195 350 : for (auto & e1 : radiation_patch_names)
196 805 : for (auto & e2 : e1)
197 518 : boundary_names.push_back(e2);
198 :
199 : // this userobject is only executed on initial
200 63 : ExecFlagEnum exec_enum = MooseUtils::getDefaultExecFlagEnum();
201 189 : exec_enum = {EXEC_INITIAL};
202 :
203 63 : if (_view_factor_calculator == "analytical")
204 : {
205 : // this branch adds the UnobstructedPlanarViewFactor
206 21 : InputParameters params = _factory.getValidParams("UnobstructedPlanarViewFactor");
207 21 : params.set<std::vector<BoundaryName>>("boundary") = boundary_names;
208 21 : params.set<ExecFlagEnum>("execute_on") = exec_enum;
209 :
210 42 : _problem->addUserObject("UnobstructedPlanarViewFactor", viewFactorObjectName(), params);
211 21 : }
212 42 : else if (_view_factor_calculator == "ray_tracing")
213 : {
214 : // this branch adds the ray tracing UO
215 42 : InputParameters params = _factory.getValidParams("RayTracingViewFactor");
216 42 : params.set<std::vector<BoundaryName>>("boundary") = boundary_names;
217 42 : params.set<ExecFlagEnum>("execute_on") = exec_enum;
218 84 : params.set<UserObjectName>("ray_study_name") = rayStudyName();
219 84 : params.set<bool>("print_view_factor_info") = getParam<bool>("print_view_factor_info");
220 84 : params.set<bool>("normalize_view_factor") = getParam<bool>("normalize_view_factor");
221 84 : _problem->addUserObject("RayTracingViewFactor", viewFactorObjectName(), params);
222 42 : }
223 126 : }
224 :
225 : void
226 63 : RadiationTransferAction::addRayStudyObject() const
227 : {
228 63 : if (_view_factor_calculator == "analytical")
229 21 : return;
230 :
231 42 : std::vector<std::vector<std::string>> radiation_patch_names = radiationPatchNames();
232 : std::vector<BoundaryName> boundary_names;
233 245 : for (auto & e1 : radiation_patch_names)
234 532 : for (auto & e2 : e1)
235 329 : boundary_names.push_back(e2);
236 :
237 42 : InputParameters params = _factory.getValidParams("ViewFactorRayStudy");
238 :
239 42 : params.set<std::vector<BoundaryName>>("boundary") = boundary_names;
240 :
241 : // set this object to be execute on initial only
242 42 : ExecFlagEnum exec_enum = MooseUtils::getDefaultExecFlagEnum();
243 84 : exec_enum = {EXEC_INITIAL};
244 42 : params.set<ExecFlagEnum>("execute_on") = exec_enum;
245 :
246 : // set face order
247 126 : params.set<MooseEnum>("face_order") = getParam<MooseEnum>("ray_tracing_face_order");
248 126 : params.set<MooseEnum>("face_type") = getParam<MooseEnum>("ray_tracing_face_type");
249 :
250 : // set angular quadrature
251 84 : params.set<unsigned int>("polar_quad_order") = getParam<unsigned int>("polar_quad_order");
252 84 : params.set<unsigned int>("azimuthal_quad_order") = getParam<unsigned int>("azimuthal_quad_order");
253 84 : _problem->addUserObject("ViewFactorRayStudy", rayStudyName(), params);
254 84 : }
255 :
256 : void
257 63 : RadiationTransferAction::addRayBCs() const
258 : {
259 63 : if (_view_factor_calculator == "analytical")
260 21 : return;
261 :
262 42 : std::vector<std::vector<std::string>> radiation_patch_names = radiationPatchNames();
263 : std::vector<BoundaryName> boundary_names;
264 245 : for (auto & e1 : radiation_patch_names)
265 532 : for (auto & e2 : e1)
266 329 : boundary_names.push_back(e2);
267 :
268 : {
269 42 : InputParameters params = _factory.getValidParams("ViewFactorRayBC");
270 42 : params.set<std::vector<BoundaryName>>("boundary") = boundary_names;
271 42 : params.set<RayTracingStudy *>("_ray_tracing_study") =
272 42 : &_problem->getUserObject<ViewFactorRayStudy>(rayStudyName());
273 84 : _problem->addObject<RayBoundaryConditionBase>("ViewFactorRayBC", rayBCName(), params);
274 42 : }
275 :
276 : // add symmetry BCs if applicable
277 84 : const auto & symmetry_names = getParam<std::vector<BoundaryName>>("symmetry_boundary");
278 42 : if (symmetry_names.size() > 0)
279 : {
280 7 : InputParameters params = _factory.getValidParams("ReflectRayBC");
281 7 : params.set<std::vector<BoundaryName>>("boundary") = symmetry_names;
282 7 : params.set<RayTracingStudy *>("_ray_tracing_study") =
283 7 : &_problem->getUserObject<ViewFactorRayStudy>(rayStudyName());
284 14 : _problem->addObject<RayBoundaryConditionBase>("ReflectRayBC", symmetryRayBCName(), params);
285 7 : }
286 42 : }
287 :
288 : UserObjectName
289 133 : RadiationTransferAction::rayStudyName() const
290 : {
291 266 : return "ray_study_uo_" + _name;
292 : }
293 :
294 : std::string
295 42 : RadiationTransferAction::rayBCName() const
296 : {
297 42 : return "ray_bc_" + _name;
298 : }
299 :
300 : std::string
301 7 : RadiationTransferAction::symmetryRayBCName() const
302 : {
303 7 : return "symmetry_ray_bc_" + _name;
304 : }
305 :
306 : UserObjectName
307 126 : RadiationTransferAction::viewFactorObjectName() const
308 : {
309 252 : return "view_factor_uo_" + _name;
310 : }
311 :
312 : UserObjectName
313 126 : RadiationTransferAction::radiationObjectName() const
314 : {
315 252 : return "view_factor_surface_radiation_" + _name;
316 : }
317 :
318 : void
319 63 : RadiationTransferAction::addRadiationObject() const
320 : {
321 63 : std::vector<std::vector<std::string>> radiation_patch_names = radiationPatchNames();
322 :
323 : // input parameter check
324 189 : std::vector<FunctionName> emissivity = getParam<std::vector<FunctionName>>("emissivity");
325 63 : if (emissivity.size() != _boundary_names.size())
326 0 : mooseError("emissivity parameter needs to be the same size as the boundary parameter.");
327 :
328 : // the action only sets up ViewFactorObjectSurfaceRadiation, because after splitting
329 : // faces auotmatically, it makes no sense to require view factor input by hand.
330 63 : InputParameters params = _factory.getValidParams("ViewFactorObjectSurfaceRadiation");
331 189 : params.set<std::vector<VariableName>>("temperature") = {getParam<VariableName>("temperature")};
332 :
333 : std::vector<FunctionName> extended_emissivity;
334 350 : for (unsigned int j = 0; j < _boundary_names.size(); ++j)
335 805 : for (unsigned int i = 0; i < nPatch(j); ++i)
336 518 : extended_emissivity.push_back(emissivity[j]);
337 126 : params.set<std::vector<FunctionName>>("emissivity") = extended_emissivity;
338 :
339 : // add boundary parameter
340 : std::vector<BoundaryName> boundary_names;
341 350 : for (auto & e1 : radiation_patch_names)
342 805 : for (auto & e2 : e1)
343 518 : boundary_names.push_back(e2);
344 63 : params.set<std::vector<BoundaryName>>("boundary") = boundary_names;
345 :
346 : // add adiabatic_boundary parameter if required
347 126 : if (isParamValid("adiabatic_boundary"))
348 : {
349 : std::vector<BoundaryName> adiabatic_boundary_names =
350 189 : getParam<std::vector<BoundaryName>>("adiabatic_boundary");
351 : std::vector<BoundaryName> adiabatic_patch_names;
352 154 : for (unsigned int k = 0; k < adiabatic_boundary_names.size(); ++k)
353 : {
354 : BoundaryName bnd_name = adiabatic_boundary_names[k];
355 :
356 : // find the right entry in _boundary_names
357 91 : auto it = std::find(_boundary_names.begin(), _boundary_names.end(), bnd_name);
358 :
359 : // check if entry was found: it must be found or an error would occur later
360 91 : if (it == _boundary_names.end())
361 0 : mooseError("Adiabatic boundary ", bnd_name, " not present in boundary.");
362 :
363 : // this is the position in the _boundary_names vector; this is what
364 : // we are really after
365 : auto index = std::distance(_boundary_names.begin(), it);
366 :
367 : // collect the correct boundary names
368 252 : for (auto & e : radiation_patch_names[index])
369 161 : adiabatic_patch_names.push_back(e);
370 : }
371 63 : params.set<std::vector<BoundaryName>>("adiabatic_boundary") = adiabatic_patch_names;
372 63 : }
373 :
374 : // add isothermal sidesets if required
375 126 : if (isParamValid("fixed_temperature_boundary"))
376 : {
377 126 : if (!isParamValid("fixed_boundary_temperatures"))
378 0 : mooseError("fixed_temperature_boundary is provided so fixed_boundary_temperatures must be "
379 : "provided too");
380 :
381 : std::vector<BoundaryName> fixed_T_boundary_names =
382 126 : getParam<std::vector<BoundaryName>>("fixed_temperature_boundary");
383 :
384 : std::vector<FunctionName> fixed_T_funcs =
385 189 : getParam<std::vector<FunctionName>>("fixed_boundary_temperatures");
386 :
387 : // check length of fixed_boundary_temperatures
388 63 : if (fixed_T_funcs.size() != fixed_T_boundary_names.size())
389 0 : mooseError("Size of parameter fixed_boundary_temperatures and fixed_temperature_boundary "
390 : "must be equal.");
391 :
392 : std::vector<BoundaryName> fixed_T_patch_names;
393 : std::vector<FunctionName> fixed_T_function_names;
394 98 : for (unsigned int k = 0; k < fixed_T_boundary_names.size(); ++k)
395 : {
396 : BoundaryName bnd_name = fixed_T_boundary_names[k];
397 :
398 : // find the right entry in _boundary_names
399 35 : auto it = std::find(_boundary_names.begin(), _boundary_names.end(), bnd_name);
400 :
401 : // check if entry was found: it must be found or an error would occur later
402 35 : if (it == _boundary_names.end())
403 0 : mooseError("Fixed temperature sideset ", bnd_name, " not present in boundary.");
404 :
405 : // this is the position in the _boundary_names vector; this is what
406 : // we are really after
407 : auto index = std::distance(_boundary_names.begin(), it);
408 :
409 : // collect the correct boundary names
410 105 : for (auto & e : radiation_patch_names[index])
411 : {
412 70 : fixed_T_patch_names.push_back(e);
413 70 : fixed_T_function_names.push_back(fixed_T_funcs[k]);
414 : }
415 : }
416 63 : params.set<std::vector<BoundaryName>>("fixed_temperature_boundary") = fixed_T_patch_names;
417 63 : params.set<std::vector<FunctionName>>("fixed_boundary_temperatures") = fixed_T_function_names;
418 63 : }
419 :
420 : // the view factor userobject name
421 126 : params.set<UserObjectName>("view_factor_object_name") = viewFactorObjectName();
422 :
423 : // this userobject needs to be executed on linear and timestep end
424 63 : ExecFlagEnum exec_enum = MooseUtils::getDefaultExecFlagEnum();
425 189 : exec_enum = {EXEC_LINEAR, EXEC_TIMESTEP_END};
426 63 : params.set<ExecFlagEnum>("execute_on") = exec_enum;
427 :
428 : // add the object
429 126 : _problem->addUserObject("ViewFactorObjectSurfaceRadiation", radiationObjectName(), params);
430 252 : }
431 :
432 : std::vector<std::vector<std::string>>
433 273 : RadiationTransferAction::radiationPatchNames() const
434 : {
435 273 : std::vector<std::vector<std::string>> radiation_patch_names(_boundary_names.size());
436 273 : std::vector<BoundaryID> boundary_ids = _mesh->getBoundaryIDs(_boundary_names);
437 1540 : for (unsigned int j = 0; j < boundary_ids.size(); ++j)
438 : {
439 1267 : boundary_id_type bid = boundary_ids[j];
440 1267 : std::string base_name = _mesh->getBoundaryName(bid);
441 : std::vector<std::string> bnames;
442 3479 : for (unsigned int i = 0; i < nPatch(j); ++i)
443 : {
444 2212 : std::stringstream ss;
445 2212 : ss << base_name << "_" << i;
446 2212 : bnames.push_back(ss.str());
447 2212 : }
448 1267 : radiation_patch_names[j] = bnames;
449 1267 : }
450 273 : return radiation_patch_names;
451 273 : }
452 :
453 : std::vector<std::vector<std::string>>
454 63 : RadiationTransferAction::bcRadiationPatchNames() const
455 : {
456 126 : auto ad_bnd_names = getParam<std::vector<BoundaryName>>("adiabatic_boundary");
457 189 : auto ft_bnd_names = getParam<std::vector<BoundaryName>>("fixed_temperature_boundary");
458 : std::vector<std::vector<std::string>> radiation_patch_names;
459 63 : std::vector<BoundaryID> boundary_ids = _mesh->getBoundaryIDs(_boundary_names);
460 350 : for (unsigned int j = 0; j < boundary_ids.size(); ++j)
461 : {
462 287 : boundary_id_type bid = boundary_ids[j];
463 : BoundaryName bnd_name = _boundary_names[j];
464 :
465 : // check if this sideset is adiabatic or isothermal
466 287 : auto it_a = std::find(ad_bnd_names.begin(), ad_bnd_names.end(), bnd_name);
467 287 : auto it_t = std::find(ft_bnd_names.begin(), ft_bnd_names.end(), bnd_name);
468 287 : if (it_a != ad_bnd_names.end() || it_t != ft_bnd_names.end())
469 : continue;
470 :
471 161 : std::string base_name = _mesh->getBoundaryName(bid);
472 : std::vector<std::string> bnames;
473 448 : for (unsigned int i = 0; i < nPatch(j); ++i)
474 : {
475 287 : std::stringstream ss;
476 287 : ss << base_name << "_" << i;
477 287 : bnames.push_back(ss.str());
478 287 : }
479 161 : radiation_patch_names.push_back(bnames);
480 161 : }
481 63 : return radiation_patch_names;
482 63 : }
483 :
484 : void
485 63 : RadiationTransferAction::addMeshGenerator()
486 : {
487 126 : std::vector<unsigned int> n_patches = getParam<std::vector<unsigned int>>("n_patches");
488 126 : MultiMooseEnum partitioners = getParam<MultiMooseEnum>("partitioners");
489 126 : if (!_pars.isParamSetByUser("partitioners"))
490 : {
491 14 : partitioners.clearSetValues();
492 70 : for (unsigned int j = 0; j < _boundary_names.size(); ++j)
493 112 : partitioners.setAdditionalValue("metis");
494 : }
495 :
496 189 : MultiMooseEnum direction = getParam<MultiMooseEnum>("centroid_partitioner_directions");
497 :
498 : // check input parameters
499 63 : if (_boundary_names.size() != n_patches.size())
500 0 : mooseError("n_patches parameter must have same length as boundary parameter.");
501 :
502 63 : if (_boundary_names.size() != partitioners.size())
503 0 : mooseError("partitioners parameter must have same length as boundary parameter.");
504 :
505 350 : for (unsigned int j = 0; j < partitioners.size(); ++j)
506 287 : if (partitioners[j] == "centroid" && direction.size() != _boundary_names.size())
507 0 : mooseError(
508 : "centroid partitioner is selected for at least one sideset. "
509 : "centroid_partitioner_directions parameter must have same length as boundary parameter.");
510 :
511 : // check if mesh is a MeshGeneratorMesh
512 63 : std::shared_ptr<MeshGeneratorMesh> mg_mesh = std::dynamic_pointer_cast<MeshGeneratorMesh>(_mesh);
513 63 : if (!mg_mesh)
514 0 : mooseError("This action adds MeshGenerator objects and therefore only works with a "
515 : "MeshGeneratorMesh.");
516 :
517 350 : for (unsigned int j = 0; j < _boundary_names.size(); ++j)
518 : {
519 574 : InputParameters params = _factory.getValidParams("PatchSidesetGenerator");
520 574 : params.set<BoundaryName>("boundary") = _boundary_names[j];
521 287 : params.set<unsigned int>("n_patches") = n_patches[j];
522 287 : params.set<MooseEnum>("partitioner") = partitioners[j];
523 :
524 287 : if (partitioners[j] == "centroid")
525 280 : params.set<MooseEnum>("centroid_partitioner_direction") = direction[j];
526 :
527 574 : _app.appendMeshGenerator("PatchSidesetGenerator", meshGeneratorName(j), params);
528 287 : }
529 63 : }
530 :
531 : unsigned int
532 4732 : RadiationTransferAction::nPatch(unsigned int j) const
533 : {
534 4732 : const MeshGenerator * mg = &_app.getMeshGenerator(meshGeneratorName(j));
535 4732 : const PatchSidesetGenerator * psg = dynamic_cast<const PatchSidesetGenerator *>(mg);
536 4732 : if (!psg)
537 0 : mooseError("Failed to convert mesh generator ", mg->name(), " to PatchSidesetGenerator.");
538 4732 : return psg->nPatches();
539 : }
540 :
541 : MeshGeneratorName
542 5019 : RadiationTransferAction::meshGeneratorName(unsigned int j) const
543 : {
544 5019 : std::stringstream ss;
545 5019 : ss << "patch_side_set_generator_" << _boundary_names[j];
546 5019 : return ss.str();
547 5019 : }
|