LCOV - code coverage report
Current view: top level - src/actions - RadiationTransferAction.C (source / functions) Hit Total Coverage
Test: idaholab/moose heat_transfer: #31405 (292dce) with base fef103 Lines: 253 266 95.1 %
Date: 2025-09-04 07:53:51 Functions: 18 18 100.0 %
Legend: Lines: hit not hit

          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         495 : RadiationTransferAction::validParams()
      27             : {
      28         495 :   InputParameters params = Action::validParams();
      29         495 :   params.addClassDescription(
      30             :       "This action sets up the net radiation calculation between specified sidesets.");
      31             : 
      32         990 :   params.addRequiredParam<std::vector<BoundaryName>>(
      33             :       "boundary", "The boundaries that participate in the radiative exchange.");
      34             : 
      35         990 :   params.addParam<std::vector<BoundaryName>>(
      36             :       "adiabatic_boundary",
      37             :       {},
      38             :       "The adiabatic boundaries that participate in the radiative exchange.");
      39             : 
      40         990 :   params.addParam<std::vector<BoundaryName>>(
      41             :       "fixed_temperature_boundary",
      42             :       {},
      43             :       "The fixed temperature boundaries that participate in the radiative exchange.");
      44             : 
      45         990 :   params.addParam<std::vector<FunctionName>>(
      46             :       "fixed_boundary_temperatures", {}, "The temperatures of the fixed boundary.");
      47             : 
      48         990 :   params.addRequiredParam<std::vector<unsigned int>>("n_patches",
      49             :                                                      "Number of radiation patches per sideset.");
      50             :   MultiMooseEnum partitioning(
      51         495 :       "default=-3 metis=-2 parmetis=-1 linear=0 centroid hilbert_sfc morton_sfc", "default");
      52         495 :   partitioning.addValidName("grid");
      53         990 :   params.addParam<MultiMooseEnum>(
      54             :       "partitioners",
      55             :       partitioning,
      56             :       "Specifies a mesh partitioner to use when preparing the radiation patches.");
      57             : 
      58         495 :   MultiMooseEnum direction("x y z radial");
      59         990 :   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         990 :   params.addRequiredParam<VariableName>("temperature", "The coupled temperature variable.");
      65         990 :   params.addRequiredParam<std::vector<FunctionName>>("emissivity",
      66             :                                                      "Emissivities for each boundary.");
      67             : 
      68         990 :   MooseEnum view_factor_calculator("analytical ray_tracing", "ray_tracing");
      69         990 :   params.addParam<MooseEnum>(
      70             :       "view_factor_calculator", view_factor_calculator, "The view factor calculator being used.");
      71             : 
      72         990 :   params.addParam<bool>(
      73         990 :       "print_view_factor_info", false, "Flag to print information about computed view factors.");
      74        1485 :   params.addParam<bool>("normalize_view_factor",
      75         990 :                         true,
      76             :                         "Determines if view factors are normalized to sum to one (consistent with "
      77             :                         "their definition).");
      78             : 
      79             :   std::vector<BoundaryName> empty = {};
      80         990 :   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         990 :   MooseEnum qtypes("GAUSS GRID", "GRID");
      88         990 :   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         990 :                     "CONSTANT");
      95         990 :   params.addParam<MooseEnum>(
      96             :       "ray_tracing_face_order", qorders, "The face quadrature rule order used for ray tracing.");
      97             : 
      98         990 :   params.addParam<unsigned int>(
      99             :       "polar_quad_order",
     100         990 :       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         990 :   params.addParam<unsigned int>(
     104             :       "azimuthal_quad_order",
     105         990 :       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         495 :   return params;
     111         495 : }
     112             : 
     113         495 : RadiationTransferAction::RadiationTransferAction(const InputParameters & params)
     114             :   : Action(params),
     115         495 :     _boundary_names(getParam<std::vector<BoundaryName>>("boundary")),
     116        1485 :     _view_factor_calculator(getParam<MooseEnum>("view_factor_calculator"))
     117             : {
     118         495 :   const auto & symmetry_names = getParam<std::vector<BoundaryName>>("symmetry_boundary");
     119             : 
     120         495 :   if (_view_factor_calculator != "ray_tracing")
     121             :   {
     122         660 :     for (const auto & param_name : {"polar_quad_order",
     123             :                                     "azimuthal_quad_order",
     124             :                                     "ray_tracing_face_type",
     125         825 :                                     "ray_tracing_face_order"})
     126        1320 :       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         165 :     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        1925 :     for (const auto & name : _boundary_names)
     140        1595 :       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         495 : }
     147             : 
     148             : void
     149         495 : RadiationTransferAction::act()
     150             : {
     151         495 :   if (_current_task == "append_mesh_generator")
     152          99 :     addMeshGenerator();
     153         396 :   else if (_current_task == "setup_mesh_complete")
     154          99 :     radiationPatchNames();
     155         297 :   else if (_current_task == "add_user_object")
     156             :   {
     157          99 :     addRadiationObject();
     158          99 :     addRayStudyObject();
     159          99 :     addViewFactorObject();
     160             :   }
     161         198 :   else if (_current_task == "add_bc")
     162          99 :     addRadiationBCs();
     163          99 :   else if (_current_task == "add_ray_boundary_condition")
     164          99 :     addRayBCs();
     165         495 : }
     166             : 
     167             : void
     168          99 : RadiationTransferAction::addRadiationBCs() const
     169             : {
     170          99 :   InputParameters params = _factory.getValidParams("GrayLambertNeumannBC");
     171             : 
     172             :   // set boundary
     173          99 :   std::vector<std::vector<std::string>> radiation_patch_names = bcRadiationPatchNames();
     174             :   std::vector<BoundaryName> boundary_names;
     175         352 :   for (auto & e1 : radiation_patch_names)
     176         704 :     for (auto & e2 : e1)
     177         451 :       boundary_names.push_back(e2);
     178             : 
     179          99 :   params.set<std::vector<BoundaryName>>("boundary") = boundary_names;
     180             : 
     181             :   // set temperature variable
     182         297 :   params.set<NonlinearVariableName>("variable") = getParam<VariableName>("temperature");
     183             : 
     184             :   // set radiationuserobject
     185         198 :   params.set<UserObjectName>("surface_radiation_object_name") = radiationObjectName();
     186             : 
     187         198 :   _problem->addBoundaryCondition("GrayLambertNeumannBC", "gray_lamber_neumann_bc_" + _name, params);
     188          99 : }
     189             : 
     190             : void
     191          99 : RadiationTransferAction::addViewFactorObject() const
     192             : {
     193          99 :   std::vector<std::vector<std::string>> radiation_patch_names = radiationPatchNames();
     194             :   std::vector<BoundaryName> boundary_names;
     195         550 :   for (auto & e1 : radiation_patch_names)
     196        1265 :     for (auto & e2 : e1)
     197         814 :       boundary_names.push_back(e2);
     198             : 
     199             :   // this userobject is only executed on initial
     200          99 :   ExecFlagEnum exec_enum = MooseUtils::getDefaultExecFlagEnum();
     201         297 :   exec_enum = {EXEC_INITIAL};
     202             : 
     203          99 :   if (_view_factor_calculator == "analytical")
     204             :   {
     205             :     // this branch adds the UnobstructedPlanarViewFactor
     206          33 :     InputParameters params = _factory.getValidParams("UnobstructedPlanarViewFactor");
     207          33 :     params.set<std::vector<BoundaryName>>("boundary") = boundary_names;
     208          33 :     params.set<ExecFlagEnum>("execute_on") = exec_enum;
     209             : 
     210          66 :     _problem->addUserObject("UnobstructedPlanarViewFactor", viewFactorObjectName(), params);
     211          33 :   }
     212          66 :   else if (_view_factor_calculator == "ray_tracing")
     213             :   {
     214             :     // this branch adds the ray tracing UO
     215          66 :     InputParameters params = _factory.getValidParams("RayTracingViewFactor");
     216          66 :     params.set<std::vector<BoundaryName>>("boundary") = boundary_names;
     217          66 :     params.set<ExecFlagEnum>("execute_on") = exec_enum;
     218         132 :     params.set<UserObjectName>("ray_study_name") = rayStudyName();
     219         132 :     params.set<bool>("print_view_factor_info") = getParam<bool>("print_view_factor_info");
     220         132 :     params.set<bool>("normalize_view_factor") = getParam<bool>("normalize_view_factor");
     221         132 :     _problem->addUserObject("RayTracingViewFactor", viewFactorObjectName(), params);
     222          66 :   }
     223         198 : }
     224             : 
     225             : void
     226          99 : RadiationTransferAction::addRayStudyObject() const
     227             : {
     228          99 :   if (_view_factor_calculator == "analytical")
     229          33 :     return;
     230             : 
     231          66 :   std::vector<std::vector<std::string>> radiation_patch_names = radiationPatchNames();
     232             :   std::vector<BoundaryName> boundary_names;
     233         385 :   for (auto & e1 : radiation_patch_names)
     234         836 :     for (auto & e2 : e1)
     235         517 :       boundary_names.push_back(e2);
     236             : 
     237          66 :   InputParameters params = _factory.getValidParams("ViewFactorRayStudy");
     238             : 
     239          66 :   params.set<std::vector<BoundaryName>>("boundary") = boundary_names;
     240             : 
     241             :   // set this object to be execute on initial only
     242          66 :   ExecFlagEnum exec_enum = MooseUtils::getDefaultExecFlagEnum();
     243         132 :   exec_enum = {EXEC_INITIAL};
     244          66 :   params.set<ExecFlagEnum>("execute_on") = exec_enum;
     245             : 
     246             :   // set face order
     247         198 :   params.set<MooseEnum>("face_order") = getParam<MooseEnum>("ray_tracing_face_order");
     248         198 :   params.set<MooseEnum>("face_type") = getParam<MooseEnum>("ray_tracing_face_type");
     249             : 
     250             :   // set angular quadrature
     251         132 :   params.set<unsigned int>("polar_quad_order") = getParam<unsigned int>("polar_quad_order");
     252         132 :   params.set<unsigned int>("azimuthal_quad_order") = getParam<unsigned int>("azimuthal_quad_order");
     253         132 :   _problem->addUserObject("ViewFactorRayStudy", rayStudyName(), params);
     254         132 : }
     255             : 
     256             : void
     257          99 : RadiationTransferAction::addRayBCs() const
     258             : {
     259          99 :   if (_view_factor_calculator == "analytical")
     260          33 :     return;
     261             : 
     262          66 :   std::vector<std::vector<std::string>> radiation_patch_names = radiationPatchNames();
     263             :   std::vector<BoundaryName> boundary_names;
     264         385 :   for (auto & e1 : radiation_patch_names)
     265         836 :     for (auto & e2 : e1)
     266         517 :       boundary_names.push_back(e2);
     267             : 
     268             :   {
     269          66 :     InputParameters params = _factory.getValidParams("ViewFactorRayBC");
     270          66 :     params.set<std::vector<BoundaryName>>("boundary") = boundary_names;
     271          66 :     params.set<RayTracingStudy *>("_ray_tracing_study") =
     272          66 :         &_problem->getUserObject<ViewFactorRayStudy>(rayStudyName());
     273         132 :     _problem->addObject<RayBoundaryConditionBase>("ViewFactorRayBC", rayBCName(), params);
     274          66 :   }
     275             : 
     276             :   // add symmetry BCs if applicable
     277         132 :   const auto & symmetry_names = getParam<std::vector<BoundaryName>>("symmetry_boundary");
     278          66 :   if (symmetry_names.size() > 0)
     279             :   {
     280          11 :     InputParameters params = _factory.getValidParams("ReflectRayBC");
     281          11 :     params.set<std::vector<BoundaryName>>("boundary") = symmetry_names;
     282          11 :     params.set<RayTracingStudy *>("_ray_tracing_study") =
     283          11 :         &_problem->getUserObject<ViewFactorRayStudy>(rayStudyName());
     284          22 :     _problem->addObject<RayBoundaryConditionBase>("ReflectRayBC", symmetryRayBCName(), params);
     285          11 :   }
     286          66 : }
     287             : 
     288             : UserObjectName
     289         209 : RadiationTransferAction::rayStudyName() const
     290             : {
     291         418 :   return "ray_study_uo_" + _name;
     292             : }
     293             : 
     294             : std::string
     295          66 : RadiationTransferAction::rayBCName() const
     296             : {
     297          66 :   return "ray_bc_" + _name;
     298             : }
     299             : 
     300             : std::string
     301          11 : RadiationTransferAction::symmetryRayBCName() const
     302             : {
     303          11 :   return "symmetry_ray_bc_" + _name;
     304             : }
     305             : 
     306             : UserObjectName
     307         198 : RadiationTransferAction::viewFactorObjectName() const
     308             : {
     309         396 :   return "view_factor_uo_" + _name;
     310             : }
     311             : 
     312             : UserObjectName
     313         198 : RadiationTransferAction::radiationObjectName() const
     314             : {
     315         396 :   return "view_factor_surface_radiation_" + _name;
     316             : }
     317             : 
     318             : void
     319          99 : RadiationTransferAction::addRadiationObject() const
     320             : {
     321          99 :   std::vector<std::vector<std::string>> radiation_patch_names = radiationPatchNames();
     322             : 
     323             :   // input parameter check
     324         297 :   std::vector<FunctionName> emissivity = getParam<std::vector<FunctionName>>("emissivity");
     325          99 :   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          99 :   InputParameters params = _factory.getValidParams("ViewFactorObjectSurfaceRadiation");
     331         297 :   params.set<std::vector<VariableName>>("temperature") = {getParam<VariableName>("temperature")};
     332             : 
     333             :   std::vector<FunctionName> extended_emissivity;
     334         550 :   for (unsigned int j = 0; j < _boundary_names.size(); ++j)
     335        1265 :     for (unsigned int i = 0; i < nPatch(j); ++i)
     336         814 :       extended_emissivity.push_back(emissivity[j]);
     337         198 :   params.set<std::vector<FunctionName>>("emissivity") = extended_emissivity;
     338             : 
     339             :   // add boundary parameter
     340             :   std::vector<BoundaryName> boundary_names;
     341         550 :   for (auto & e1 : radiation_patch_names)
     342        1265 :     for (auto & e2 : e1)
     343         814 :       boundary_names.push_back(e2);
     344          99 :   params.set<std::vector<BoundaryName>>("boundary") = boundary_names;
     345             : 
     346             :   // add adiabatic_boundary parameter if required
     347         198 :   if (isParamValid("adiabatic_boundary"))
     348             :   {
     349             :     std::vector<BoundaryName> adiabatic_boundary_names =
     350         297 :         getParam<std::vector<BoundaryName>>("adiabatic_boundary");
     351             :     std::vector<BoundaryName> adiabatic_patch_names;
     352         242 :     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         143 :       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         143 :       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         396 :       for (auto & e : radiation_patch_names[index])
     369         253 :         adiabatic_patch_names.push_back(e);
     370             :     }
     371          99 :     params.set<std::vector<BoundaryName>>("adiabatic_boundary") = adiabatic_patch_names;
     372          99 :   }
     373             : 
     374             :   // add isothermal sidesets if required
     375         198 :   if (isParamValid("fixed_temperature_boundary"))
     376             :   {
     377         198 :     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         198 :         getParam<std::vector<BoundaryName>>("fixed_temperature_boundary");
     383             : 
     384             :     std::vector<FunctionName> fixed_T_funcs =
     385         297 :         getParam<std::vector<FunctionName>>("fixed_boundary_temperatures");
     386             : 
     387             :     // check length of fixed_boundary_temperatures
     388          99 :     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         154 :     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          55 :       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          55 :       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         165 :       for (auto & e : radiation_patch_names[index])
     411             :       {
     412         110 :         fixed_T_patch_names.push_back(e);
     413         110 :         fixed_T_function_names.push_back(fixed_T_funcs[k]);
     414             :       }
     415             :     }
     416          99 :     params.set<std::vector<BoundaryName>>("fixed_temperature_boundary") = fixed_T_patch_names;
     417          99 :     params.set<std::vector<FunctionName>>("fixed_boundary_temperatures") = fixed_T_function_names;
     418          99 :   }
     419             : 
     420             :   // the view factor userobject name
     421         198 :   params.set<UserObjectName>("view_factor_object_name") = viewFactorObjectName();
     422             : 
     423             :   // this userobject needs to be executed on linear and timestep end
     424          99 :   ExecFlagEnum exec_enum = MooseUtils::getDefaultExecFlagEnum();
     425         297 :   exec_enum = {EXEC_LINEAR, EXEC_TIMESTEP_END};
     426          99 :   params.set<ExecFlagEnum>("execute_on") = exec_enum;
     427             : 
     428             :   // add the object
     429         198 :   _problem->addUserObject("ViewFactorObjectSurfaceRadiation", radiationObjectName(), params);
     430         396 : }
     431             : 
     432             : std::vector<std::vector<std::string>>
     433         429 : RadiationTransferAction::radiationPatchNames() const
     434             : {
     435         429 :   std::vector<std::vector<std::string>> radiation_patch_names(_boundary_names.size());
     436         429 :   std::vector<BoundaryID> boundary_ids = _mesh->getBoundaryIDs(_boundary_names);
     437        2420 :   for (unsigned int j = 0; j < boundary_ids.size(); ++j)
     438             :   {
     439        1991 :     boundary_id_type bid = boundary_ids[j];
     440        1991 :     std::string base_name = _mesh->getBoundaryName(bid);
     441             :     std::vector<std::string> bnames;
     442        5467 :     for (unsigned int i = 0; i < nPatch(j); ++i)
     443             :     {
     444        3476 :       std::stringstream ss;
     445        3476 :       ss << base_name << "_" << i;
     446        3476 :       bnames.push_back(ss.str());
     447        3476 :     }
     448        1991 :     radiation_patch_names[j] = bnames;
     449        1991 :   }
     450         429 :   return radiation_patch_names;
     451         429 : }
     452             : 
     453             : std::vector<std::vector<std::string>>
     454          99 : RadiationTransferAction::bcRadiationPatchNames() const
     455             : {
     456         198 :   auto ad_bnd_names = getParam<std::vector<BoundaryName>>("adiabatic_boundary");
     457         297 :   auto ft_bnd_names = getParam<std::vector<BoundaryName>>("fixed_temperature_boundary");
     458             :   std::vector<std::vector<std::string>> radiation_patch_names;
     459          99 :   std::vector<BoundaryID> boundary_ids = _mesh->getBoundaryIDs(_boundary_names);
     460         550 :   for (unsigned int j = 0; j < boundary_ids.size(); ++j)
     461             :   {
     462         451 :     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         451 :     auto it_a = std::find(ad_bnd_names.begin(), ad_bnd_names.end(), bnd_name);
     467         451 :     auto it_t = std::find(ft_bnd_names.begin(), ft_bnd_names.end(), bnd_name);
     468         451 :     if (it_a != ad_bnd_names.end() || it_t != ft_bnd_names.end())
     469             :       continue;
     470             : 
     471         253 :     std::string base_name = _mesh->getBoundaryName(bid);
     472             :     std::vector<std::string> bnames;
     473         704 :     for (unsigned int i = 0; i < nPatch(j); ++i)
     474             :     {
     475         451 :       std::stringstream ss;
     476         451 :       ss << base_name << "_" << i;
     477         451 :       bnames.push_back(ss.str());
     478         451 :     }
     479         253 :     radiation_patch_names.push_back(bnames);
     480         253 :   }
     481          99 :   return radiation_patch_names;
     482          99 : }
     483             : 
     484             : void
     485          99 : RadiationTransferAction::addMeshGenerator()
     486             : {
     487         198 :   std::vector<unsigned int> n_patches = getParam<std::vector<unsigned int>>("n_patches");
     488         198 :   MultiMooseEnum partitioners = getParam<MultiMooseEnum>("partitioners");
     489         198 :   if (!_pars.isParamSetByUser("partitioners"))
     490             :   {
     491          22 :     partitioners.clearSetValues();
     492         110 :     for (unsigned int j = 0; j < _boundary_names.size(); ++j)
     493         176 :       partitioners.setAdditionalValue("metis");
     494             :   }
     495             : 
     496         297 :   MultiMooseEnum direction = getParam<MultiMooseEnum>("centroid_partitioner_directions");
     497             : 
     498             :   // check input parameters
     499          99 :   if (_boundary_names.size() != n_patches.size())
     500           0 :     mooseError("n_patches parameter must have same length as boundary parameter.");
     501             : 
     502          99 :   if (_boundary_names.size() != partitioners.size())
     503           0 :     mooseError("partitioners parameter must have same length as boundary parameter.");
     504             : 
     505         550 :   for (unsigned int j = 0; j < partitioners.size(); ++j)
     506         451 :     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          99 :   std::shared_ptr<MeshGeneratorMesh> mg_mesh = std::dynamic_pointer_cast<MeshGeneratorMesh>(_mesh);
     513          99 :   if (!mg_mesh)
     514           0 :     mooseError("This action adds MeshGenerator objects and therefore only works with a "
     515             :                "MeshGeneratorMesh.");
     516             : 
     517         550 :   for (unsigned int j = 0; j < _boundary_names.size(); ++j)
     518             :   {
     519         902 :     InputParameters params = _factory.getValidParams("PatchSidesetGenerator");
     520         902 :     params.set<BoundaryName>("boundary") = _boundary_names[j];
     521         451 :     params.set<unsigned int>("n_patches") = n_patches[j];
     522         451 :     params.set<MooseEnum>("partitioner") = partitioners[j];
     523             : 
     524         451 :     if (partitioners[j] == "centroid")
     525         440 :       params.set<MooseEnum>("centroid_partitioner_direction") = direction[j];
     526             : 
     527         902 :     _app.appendMeshGenerator("PatchSidesetGenerator", meshGeneratorName(j), params);
     528         451 :   }
     529          99 : }
     530             : 
     531             : unsigned int
     532        7436 : RadiationTransferAction::nPatch(unsigned int j) const
     533             : {
     534        7436 :   const MeshGenerator * mg = &_app.getMeshGenerator(meshGeneratorName(j));
     535        7436 :   const PatchSidesetGenerator * psg = dynamic_cast<const PatchSidesetGenerator *>(mg);
     536        7436 :   if (!psg)
     537           0 :     mooseError("Failed to convert mesh generator ", mg->name(), " to PatchSidesetGenerator.");
     538        7436 :   return psg->nPatches();
     539             : }
     540             : 
     541             : MeshGeneratorName
     542        7887 : RadiationTransferAction::meshGeneratorName(unsigned int j) const
     543             : {
     544        7887 :   std::stringstream ss;
     545        7887 :   ss << "patch_side_set_generator_" << _boundary_names[j];
     546        7887 :   return ss.str();
     547        7887 : }

Generated by: LCOV version 1.14