www.mooseframework.org
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
RadiationTransferAction Class Reference

#include <RadiationTransferAction.h>

Inheritance diagram for RadiationTransferAction:
[legend]

Public Member Functions

 RadiationTransferAction (const InputParameters &params)
 
virtual void act () override
 

Protected Member Functions

void addMeshGenerator () const
 
void addRadiationObject () const
 
void addViewFactorObject () const
 
void addRadiationBCs () const
 
std::vector< std::vector< std::string > > radiationPatchNames () const
 
UserObjectName viewFactorObjectName () const
 
UserObjectName radiationObjectName () const
 

Protected Attributes

std::vector< boundary_id_type > _boundary_ids
 the boundary ids participating in the radiative heat transfer More...
 
std::vector< unsigned int > _n_patches
 the number of radiation patches per boundary More...
 

Detailed Description

Definition at line 16 of file RadiationTransferAction.h.

Constructor & Destructor Documentation

◆ RadiationTransferAction()

RadiationTransferAction::RadiationTransferAction ( const InputParameters &  params)

Definition at line 65 of file RadiationTransferAction.C.

66  : Action(params),
67  _boundary_ids(getParam<std::vector<boundary_id_type>>("sidesets")),
68  _n_patches(getParam<std::vector<unsigned int>>("n_patches"))
69 {
70 }

Member Function Documentation

◆ act()

void RadiationTransferAction::act ( )
overridevirtual

Definition at line 73 of file RadiationTransferAction.C.

74 {
75  if (_current_task == "add_mesh_generator")
77  else if (_current_task == "setup_mesh_complete")
79  else if (_current_task == "add_user_object")
80  {
83  }
84  else if (_current_task == "add_bc")
86 }

◆ addMeshGenerator()

void RadiationTransferAction::addMeshGenerator ( ) const
protected

Definition at line 279 of file RadiationTransferAction.C.

280 {
281  MultiMooseEnum partitioners = getParam<MultiMooseEnum>("partitioners");
282  if (!_pars.isParamSetByUser("partitioners"))
283  {
284  partitioners.clear();
285  for (unsigned int j = 0; j < _boundary_ids.size(); ++j)
286  partitioners.push_back("metis");
287  }
288 
289  MultiMooseEnum direction = getParam<MultiMooseEnum>("centroid_partitioner_directions");
290 
291  // check input parameters
292  if (_boundary_ids.size() != _n_patches.size())
293  mooseError("n_patches parameter must have same length as sidesets parameter.");
294 
295  if (_boundary_ids.size() != partitioners.size())
296  mooseError("partitioners parameter must have same length as sidesets parameter.");
297 
298  for (unsigned int j = 0; j < partitioners.size(); ++j)
299  if (partitioners[j] == "centroid" && direction.size() != _boundary_ids.size())
300  mooseError(
301  "centroid partitioner is selected for at least one sideset. "
302  "centroid_partitioner_directions parameter must have same length as sidesets parameter.");
303 
304  // check if mesh is a MeshGeneratorMesh
305  std::shared_ptr<MeshGeneratorMesh> mg_mesh = std::dynamic_pointer_cast<MeshGeneratorMesh>(_mesh);
306  if (!mg_mesh)
307  mooseError("This action adds MeshGenerator objects and therefore only works with a "
308  "MeshGeneratorMesh.");
309 
310  MeshGeneratorName input = getParam<MeshGeneratorName>("final_mesh_generator");
311 
312  for (unsigned int j = 0; j < _boundary_ids.size(); ++j)
313  {
314  boundary_id_type bid = _boundary_ids[j];
315 
316  // create the name of this PatchSidesetGenerator
317  std::stringstream ss;
318  ss << "patch_side_set_generator_" << bid;
319  MeshGeneratorName mg_name = ss.str();
320 
321  InputParameters params = _factory.getValidParams("PatchSidesetGenerator");
322  params.set<MeshGeneratorName>("input") = input;
323  params.set<boundary_id_type>("sideset") = bid;
324  params.set<unsigned int>("n_patches") = _n_patches[j];
325  params.set<MooseEnum>("partitioner") = partitioners[j];
326 
327  if (partitioners[j] == "centroid")
328  params.set<MooseEnum>("centroid_partitioner_direction") = direction[j];
329 
330  _app.addMeshGenerator("PatchSidesetGenerator", mg_name, params);
331 
332  // reset input parameter to last one added
333  input = mg_name;
334  }
335 }

Referenced by act().

◆ addRadiationBCs()

void RadiationTransferAction::addRadiationBCs ( ) const
protected

Definition at line 89 of file RadiationTransferAction.C.

90 {
91  InputParameters params = _factory.getValidParams("GrayLambertNeumannBC");
92 
93  // set boundary
94  std::vector<std::vector<std::string>> radiation_patch_names = radiationPatchNames();
95  std::vector<BoundaryName> boundary_names;
96  for (auto & e1 : radiation_patch_names)
97  for (auto & e2 : e1)
98  boundary_names.push_back(e2);
99  params.set<std::vector<BoundaryName>>("boundary") = boundary_names;
100 
101  // set temperature variable
102  params.set<NonlinearVariableName>("variable") = getParam<VariableName>("temperature");
103 
104  // set radiationuserobject
105  params.set<UserObjectName>("surface_radiation_object_name") = radiationObjectName();
106 
107  _problem->addBoundaryCondition("GrayLambertNeumannBC", "gray_lamber_neumann_bc_" + _name, params);
108 }

Referenced by act().

◆ addRadiationObject()

void RadiationTransferAction::addRadiationObject ( ) const
protected

Definition at line 145 of file RadiationTransferAction.C.

146 {
147  std::vector<std::vector<std::string>> radiation_patch_names = radiationPatchNames();
148 
149  // input parameter check
150  std::vector<Real> emissivity = getParam<std::vector<Real>>("emissivity");
151  if (emissivity.size() != _boundary_ids.size())
152  mooseError("emissivity parameter needs to be the same size as the sidesets parameter.");
153 
154  // the action only sets up ViewFactorObjectSurfaceRadiation, because after splitting
155  // faces auotmatically, it makes no sense to require view factor input by hand.
156  InputParameters params = _factory.getValidParams("ViewFactorObjectSurfaceRadiation");
157  params.set<std::vector<VariableName>>("temperature") = {getParam<VariableName>("temperature")};
158 
159  std::vector<Real> extended_emissivity;
160  for (unsigned int j = 0; j < _boundary_ids.size(); ++j)
161  for (unsigned int i = 0; i < _n_patches[j]; ++i)
162  extended_emissivity.push_back(emissivity[j]);
163  params.set<std::vector<Real>>("emissivity") = extended_emissivity;
164 
165  // add boundary parameter
166  std::vector<BoundaryName> boundary_names;
167  for (auto & e1 : radiation_patch_names)
168  for (auto & e2 : e1)
169  boundary_names.push_back(e2);
170  params.set<std::vector<BoundaryName>>("boundary") = boundary_names;
171 
172  // add adiabatic_boundary parameter if required
173  if (isParamValid("adiabatic_sidesets"))
174  {
175  std::vector<boundary_id_type> adiabatic_boundary_ids =
176  getParam<std::vector<boundary_id_type>>("adiabatic_sidesets");
177  std::vector<BoundaryName> adiabatic_boundary_names;
178  for (unsigned int k = 0; k < adiabatic_boundary_ids.size(); ++k)
179  {
180  boundary_id_type abid = adiabatic_boundary_ids[k];
181 
182  // find the right entry in _boundary_ids
183  auto it = std::find(_boundary_ids.begin(), _boundary_ids.end(), abid);
184 
185  // check if entry was found: it must be found or an error would occur later
186  if (it == _boundary_ids.end())
187  mooseError("Adiabatic sideset ", abid, " not present in sidesets.");
188 
189  // this is the position in the _boundary_ids vector; this is what
190  // we are really after
191  auto index = std::distance(_boundary_ids.begin(), it);
192 
193  // collect the correct boundary names
194  for (auto & e : radiation_patch_names[index])
195  adiabatic_boundary_names.push_back(e);
196  }
197  params.set<std::vector<BoundaryName>>("adiabatic_boundary") = adiabatic_boundary_names;
198  }
199 
200  // add isothermal sidesets if required
201  if (isParamValid("fixed_temperature_sidesets"))
202  {
203  if (!isParamValid("fixed_boundary_temperatures"))
204  mooseError("fixed_temperature_sidesets is provided so fixed_boundary_temperatures must be "
205  "provided too");
206 
207  std::vector<boundary_id_type> fixed_T_boundary_ids =
208  getParam<std::vector<boundary_id_type>>("fixed_temperature_sidesets");
209 
210  std::vector<FunctionName> fixed_T_funcs =
211  getParam<std::vector<FunctionName>>("fixed_boundary_temperatures");
212 
213  // check length of fixed_boundary_temperatures
214  if (fixed_T_funcs.size() != fixed_T_boundary_ids.size())
215  mooseError("Size of parameter fixed_boundary_temperatures and fixed_temperature_sidesets "
216  "must be equal.");
217 
218  std::vector<BoundaryName> fixed_T_boundary_names;
219  std::vector<FunctionName> fixed_T_function_names;
220  for (unsigned int k = 0; k < fixed_T_boundary_ids.size(); ++k)
221  {
222  boundary_id_type bid = fixed_T_boundary_ids[k];
223 
224  // find the right entry in _boundary_ids
225  auto it = std::find(_boundary_ids.begin(), _boundary_ids.end(), bid);
226 
227  // check if entry was found: it must be found or an error would occur later
228  if (it == _boundary_ids.end())
229  mooseError("Fixed temperature sideset ", bid, " not present in sidesets.");
230 
231  // this is the position in the _boundary_ids vector; this is what
232  // we are really after
233  auto index = std::distance(_boundary_ids.begin(), it);
234 
235  // collect the correct boundary names
236  for (auto & e : radiation_patch_names[index])
237  {
238  fixed_T_boundary_names.push_back(e);
239  fixed_T_function_names.push_back(fixed_T_funcs[k]);
240  }
241  }
242  params.set<std::vector<BoundaryName>>("fixed_temperature_boundary") = fixed_T_boundary_names;
243  params.set<std::vector<FunctionName>>("fixed_boundary_temperatures") = fixed_T_function_names;
244  }
245 
246  // the view factor userobject name
247  params.set<UserObjectName>("view_factor_object_name") = viewFactorObjectName();
248 
249  // this userobject needs to be executed on linear and timestep end
250  ExecFlagEnum exec_enum = MooseUtils::getDefaultExecFlagEnum();
251  exec_enum = {EXEC_LINEAR, EXEC_TIMESTEP_END};
252  params.set<ExecFlagEnum>("execute_on") = exec_enum;
253 
254  // add the object
255  _problem->addUserObject("ViewFactorObjectSurfaceRadiation", radiationObjectName(), params);
256 }

Referenced by act().

◆ addViewFactorObject()

void RadiationTransferAction::addViewFactorObject ( ) const
protected

Definition at line 111 of file RadiationTransferAction.C.

112 {
113  // add the view factor userobject; currently there is only one object implemented so no choices
114  // in the future this section will allow switching different types
115  InputParameters params = _factory.getValidParams("UnobstructedPlanarViewFactor");
116 
117  std::vector<std::vector<std::string>> radiation_patch_names = radiationPatchNames();
118  std::vector<BoundaryName> boundary_names;
119  for (auto & e1 : radiation_patch_names)
120  for (auto & e2 : e1)
121  boundary_names.push_back(e2);
122  params.set<std::vector<BoundaryName>>("boundary") = boundary_names;
123 
124  // this userobject is only executed on initial
125  ExecFlagEnum exec_enum = MooseUtils::getDefaultExecFlagEnum();
126  exec_enum = {EXEC_INITIAL};
127  params.set<ExecFlagEnum>("execute_on") = exec_enum;
128 
129  _problem->addUserObject("UnobstructedPlanarViewFactor", viewFactorObjectName(), params);
130 }

Referenced by act().

◆ radiationObjectName()

UserObjectName RadiationTransferAction::radiationObjectName ( ) const
protected

Definition at line 139 of file RadiationTransferAction.C.

140 {
141  return "view_factor_surface_radiation_" + _name;
142 }

Referenced by addRadiationBCs(), and addRadiationObject().

◆ radiationPatchNames()

std::vector< std::vector< std::string > > RadiationTransferAction::radiationPatchNames ( ) const
protected

Definition at line 259 of file RadiationTransferAction.C.

260 {
261  std::vector<std::vector<std::string>> radiation_patch_names(_boundary_ids.size());
262  for (unsigned int j = 0; j < _boundary_ids.size(); ++j)
263  {
264  boundary_id_type bid = _boundary_ids[j];
265  std::string base_name = _mesh->getBoundaryName(bid);
266  std::vector<std::string> bnames;
267  for (unsigned int i = 0; i < _n_patches[j]; ++i)
268  {
269  std::stringstream ss;
270  ss << base_name << "_" << i;
271  bnames.push_back(ss.str());
272  }
273  radiation_patch_names[j] = bnames;
274  }
275  return radiation_patch_names;
276 }

Referenced by act(), addRadiationBCs(), addRadiationObject(), and addViewFactorObject().

◆ viewFactorObjectName()

UserObjectName RadiationTransferAction::viewFactorObjectName ( ) const
protected

Definition at line 133 of file RadiationTransferAction.C.

134 {
135  return "view_factor_uo_" + _name;
136 }

Referenced by addRadiationObject(), and addViewFactorObject().

Member Data Documentation

◆ _boundary_ids

std::vector<boundary_id_type> RadiationTransferAction::_boundary_ids
protected

the boundary ids participating in the radiative heat transfer

Definition at line 33 of file RadiationTransferAction.h.

Referenced by addMeshGenerator(), addRadiationObject(), and radiationPatchNames().

◆ _n_patches

std::vector<unsigned int> RadiationTransferAction::_n_patches
protected

the number of radiation patches per boundary

Definition at line 36 of file RadiationTransferAction.h.

Referenced by addMeshGenerator(), addRadiationObject(), and radiationPatchNames().


The documentation for this class was generated from the following files:
RadiationTransferAction::addViewFactorObject
void addViewFactorObject() const
Definition: RadiationTransferAction.C:111
RadiationTransferAction::_boundary_ids
std::vector< boundary_id_type > _boundary_ids
the boundary ids participating in the radiative heat transfer
Definition: RadiationTransferAction.h:33
RadiationTransferAction::radiationPatchNames
std::vector< std::vector< std::string > > radiationPatchNames() const
Definition: RadiationTransferAction.C:259
RadiationTransferAction::viewFactorObjectName
UserObjectName viewFactorObjectName() const
Definition: RadiationTransferAction.C:133
RadiationTransferAction::addRadiationObject
void addRadiationObject() const
Definition: RadiationTransferAction.C:145
RadiationTransferAction::addMeshGenerator
void addMeshGenerator() const
Definition: RadiationTransferAction.C:279
RadiationTransferAction::radiationObjectName
UserObjectName radiationObjectName() const
Definition: RadiationTransferAction.C:139
RadiationTransferAction::_n_patches
std::vector< unsigned int > _n_patches
the number of radiation patches per boundary
Definition: RadiationTransferAction.h:36
RadiationTransferAction::addRadiationBCs
void addRadiationBCs() const
Definition: RadiationTransferAction.C:89