https://mooseframework.inl.gov
HeatTransferFromHeatStructure1Phase.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 #include "FlowChannel1PhaseBase.h"
12 #include "HeatStructureBase.h"
14 #include "FlowModelSinglePhase.h"
15 #include "THMMesh.h"
16 #include "MooseUtils.h"
17 
19 
22 {
25 
26  params.addParam<MooseFunctorName>("scale", 1.0, "Functor by which to scale the heat flux");
27 
28  params.addClassDescription("Connects a 1-phase flow channel and a heat structure");
29 
30  return params;
31 }
32 
34  const InputParameters & parameters)
36  HSBoundaryInterface(this),
37  _mesh_alignment(constMesh())
38 {
39 }
40 
41 const libMesh::FEType &
43 {
45 }
46 
47 void
49 {
50  if (hasComponentByName<HeatStructureBase>(_hs_name) && _hs_side_valid &&
51  hasComponentByName<FlowChannel1PhaseBase>(_flow_channel_name))
52  {
53  const HeatStructureBase & hs = getComponentByName<HeatStructureBase>(_hs_name);
54  const FlowChannel1PhaseBase & flow_channel =
55  getComponentByName<FlowChannel1PhaseBase>(_flow_channel_name);
56 
57  _mesh_alignment.initialize(flow_channel.getElementIDs(), hs.getBoundaryInfo(_hs_side));
58 
59  for (auto & elem_id : flow_channel.getElementIDs())
60  {
61  if (_mesh_alignment.hasCoupledElemID(elem_id))
63  }
64  }
65 }
66 
67 void
69 {
72 
73  if (hasComponentByName<HeatStructureBase>(_hs_name) &&
74  hasComponentByName<FlowChannel1PhaseBase>(_flow_channel_name))
75  {
76  const HeatStructureBase & hs = getComponentByName<HeatStructureBase>(_hs_name);
77  const FlowChannel1PhaseBase & flow_channel =
78  getComponentByName<FlowChannel1PhaseBase>(_flow_channel_name);
79 
80  if (hs.getNumElems() != flow_channel.getNumElems())
81  logError("The number of elements in component '",
83  "' is ",
84  flow_channel.getNumElems(),
85  ", but the number of axial elements in component '",
86  _hs_name,
87  "' is ",
88  hs.getNumElems(),
89  ". They must be the same.");
90 
91  if (!MooseUtils::absoluteFuzzyEqual(hs.getLength(), flow_channel.getLength()))
92  logError("The length of component '",
94  "' is ",
95  flow_channel.getLength(),
96  ", but the length of component '",
97  _hs_name,
98  "' is ",
99  hs.getLength(),
100  ". They must be the same.");
101 
102  if (_hs_side_valid)
103  {
105  logError("The centers of the elements of flow channel '",
107  "' do not align with the centers of the specified heat structure side.");
108  }
109  }
110 }
111 
112 void
114 {
116 
117  // wall temperature initial condition
118  if (!getTHMProblem().hasInitialConditionsFromFile() && !_app.isRestarting())
119  {
120  const HeatStructureBase & hs = getComponentByName<HeatStructureBase>(_hs_name);
122  }
123 }
124 
125 void
127 {
129 
131  execute_on = {EXEC_INITIAL, EXEC_LINEAR, EXEC_NONLINEAR};
132 
133  const HeatStructureBase & hs = getComponentByName<HeatStructureBase>(_hs_name);
134  const bool is_cylindrical = dynamic_cast<const HeatStructureCylindricalBase *>(&hs) != nullptr;
135  const FlowChannel1PhaseBase & flow_channel =
136  getComponentByName<FlowChannel1PhaseBase>(_flow_channel_name);
137 
138  const UserObjectName heat_flux_uo_name = genName(name(), "heat_flux_uo");
139  {
140  const std::string class_name = "ADHeatFluxFromHeatStructure3EqnUserObject";
141  InputParameters params = _factory.getValidParams(class_name);
142  params.set<std::vector<SubdomainName>>("block") = flow_channel.getSubdomainNames();
143  params.set<MeshAlignment *>("_mesh_alignment") = &_mesh_alignment;
144  params.set<MaterialPropertyName>("T_wall") = _T_wall_name + "_coupled";
145  params.set<std::vector<VariableName>>("P_hf") = {_P_hf_name};
146  params.set<MaterialPropertyName>("Hw") = _Hw_1phase_name;
147  params.set<MaterialPropertyName>("T") = FlowModelSinglePhase::TEMPERATURE;
148  params.set<MooseFunctorName>("scale") = getParam<MooseFunctorName>("scale");
149  params.set<ExecFlagEnum>("execute_on") = execute_on;
150  getTHMProblem().addUserObject(class_name, heat_flux_uo_name, params);
151  }
152 
153  {
154  const std::string class_name = "ADOneD3EqnEnergyHeatFlux";
155  InputParameters params = _factory.getValidParams(class_name);
156  params.set<std::vector<SubdomainName>>("block") = flow_channel.getSubdomainNames();
157  params.set<NonlinearVariableName>("variable") = FlowModelSinglePhase::RHOEA;
158  params.set<UserObjectName>("q_uo") = heat_flux_uo_name;
159  getTHMProblem().addKernel(class_name, genName(name(), "heat_flux_kernel"), params);
160  }
161 
162  {
163  const std::string class_name = "ADHeatFlux3EqnBC";
164  InputParameters params = _factory.getValidParams(class_name);
165  params.set<std::vector<BoundaryName>>("boundary") = {getHeatStructureSideName()};
166  params.set<NonlinearVariableName>("variable") = HeatConductionModel::TEMPERATURE;
167  params.set<UserObjectName>("q_uo") = heat_flux_uo_name;
168  params.set<Real>("P_hs_unit") = hs.getUnitPerimeter(_hs_side);
169  params.set<unsigned int>("n_unit") = hs.getNumberOfUnits();
170  params.set<bool>("hs_coord_system_is_cylindrical") = is_cylindrical;
171  getTHMProblem().addBoundaryCondition(class_name, genName(name(), "heat_flux_bc"), params);
172  }
173 
174  // Transfer the temperature of the solid onto the flow channel
175  {
176  std::string class_name = "MeshAlignmentVariableTransferMaterial";
177  InputParameters params = _factory.getValidParams(class_name);
178  params.set<std::vector<SubdomainName>>("block") = flow_channel.getSubdomainNames();
179  params.set<MaterialPropertyName>("property_name") = _T_wall_name + "_coupled";
180  params.set<std::string>("paired_variable") = HeatConductionModel::TEMPERATURE;
181  params.set<MeshAlignment *>("_mesh_alignment") = &_mesh_alignment;
182  getTHMProblem().addMaterial(class_name, genName(name(), "T_wall_transfer_mat"), params);
183  }
184 
185  // Transfer the temperature of the solid onto the flow channel as aux variable for visualization
186  {
187  std::string class_name = "VariableValueTransferAux";
188  InputParameters params = _factory.getValidParams(class_name);
189  params.set<AuxVariableName>("variable") = _T_wall_name;
190  params.set<std::vector<BoundaryName>>("boundary") = {getChannelSideName()};
191  params.set<BoundaryName>("paired_boundary") = getHeatStructureSideName();
192  params.set<std::vector<VariableName>>("paired_variable") =
193  std::vector<VariableName>(1, HeatConductionModel::TEMPERATURE);
194  getTHMProblem().addAuxKernel(class_name, genName(name(), "T_wall_transfer"), params);
195  }
196 }
197 
198 const BoundaryName &
200 {
201  return getHSBoundaryName(this);
202 }
203 
204 const BoundaryName &
206 {
207  const FlowChannel1PhaseBase & flow_channel =
208  getComponentByName<FlowChannel1PhaseBase>(_flow_channel_name);
209  return flow_channel.getNodesetName();
210 }
const BoundaryName & getHeatStructureSideName() const
Gets the heat structure boundary name for this connection.
registerMooseObject("ThermalHydraulicsApp", HeatTransferFromHeatStructure1Phase)
Real getNumberOfUnits() const
Gets the number of units that heat structure represents.
std::string genName(const std::string &prefix, unsigned int id, const std::string &suffix="") const
Build a name from a prefix, number and possible suffix.
bool absoluteFuzzyEqual(const T &var1, const T2 &var2, const T3 &tol=libMesh::TOLERANCE *libMesh::TOLERANCE)
VariableName _T_wall_name
wall temperature name
const Component2D::ExternalBoundaryType _hs_side
Heat structure side.
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
static const std::string TEMPERATURE
THMProblem & getTHMProblem() const
Gets the THM problem.
Definition: Component.C:135
virtual void addMaterial(const std::string &material_name, const std::string &name, InputParameters &parameters)
T & set(const std::string &name, bool quiet_mode=false)
Connects a 1-phase flow channel and a heat structure.
FunctionName getInitialT() const
Gets the initial temperature function name.
InputParameters getValidParams(const std::string &name) const
Builds mapping between two aligned subdomains/boundaries.
Definition: MeshAlignment.h:24
void initialize(const std::vector< dof_id_type > &primary_elem_ids, const std::vector< std::tuple< dof_id_type, unsigned short int >> &secondary_boundary_info)
Extracts mesh information and builds the mapping.
Definition: MeshAlignment.C:22
virtual void addAuxKernel(const std::string &kernel_name, const std::string &name, InputParameters &parameters)
virtual void addKernel(const std::string &kernel_name, const std::string &name, InputParameters &parameters)
MaterialPropertyName _Hw_1phase_name
1-phase wall heat transfer coefficient name
const BoundaryName & getHSBoundaryName(const Component *const component) const
Gets the boundary name corresponding to the heat structure and side.
bool isRestarting() const
virtual const std::string & name() const
bool meshesAreAligned() const
Returns true if the primary and secondary meshes are aligned.
void addFunctionIC(const VariableName &var_name, const std::string &func_name, const std::vector< SubdomainName > &block_names)
Definition: Simulation.C:532
virtual void addBoundaryCondition(const std::string &bc_name, const std::string &name, InputParameters &parameters)
ExecFlagEnum getDefaultExecFlagEnum()
void logError(Args &&... args) const
Logs an error.
Definition: Component.h:215
VariableName _P_hf_name
heated perimeter name
const dof_id_type & getCoupledElemID(const dof_id_type &elem_id) const
Gets the coupled element ID for a given element ID.
Base class for cylindrical heat structure components.
virtual void check() const override
Check the component integrity.
static const std::string TEMPERATURE
const BoundaryName & getChannelSideName() const
Gets the flow channel nodeset name for this connection.
void check(const Component *const component) const
virtual Real getUnitPerimeter(const ExternalBoundaryType &side) const =0
Gets the perimeter of one unit of this heat structure on the specified side.
Interface class for coupling to a heat structure boundary.
const ExecFlagType EXEC_LINEAR
virtual void check() const override
Check the component integrity.
const std::string _flow_channel_name
name of the connected flow channel
const bool _hs_side_valid
True if valid heat structure side was provided.
Base class for heat transfer connections from temperature for 1-phase flow.
const std::vector< std::tuple< dof_id_type, unsigned short int > > & getBoundaryInfo(const BoundaryName &boundary_name) const
Gets boundary info associated with the component boundary.
Definition: Component2D.C:519
static const libMesh::FEType & feType()
Get the FE type used for heat conduction.
const BoundaryName & getNodesetName() const
Gets the 1D component nodeset name.
Definition: Component1D.C:148
const ExecFlagType EXEC_NONLINEAR
const std::string & _hs_name
Heat structure name.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
MooseApp & _app
HeatTransferFromHeatStructure1Phase(const InputParameters &parameters)
Factory & _factory
The Factory associated with the MooseApp.
Definition: Component.h:446
virtual std::vector< std::shared_ptr< UserObject > > addUserObject(const std::string &user_object_name, const std::string &name, InputParameters &parameters)
Base class for 2D generated heat structures.
void addClassDescription(const std::string &doc_string)
static const std::string RHOEA
virtual const std::vector< SubdomainName > & getSubdomainNames() const
Gets the subdomain names for this component.
Definition: Component.C:307
virtual const libMesh::FEType & getFEType() override
Get the FE type for wall temperature variable.
virtual void setupMesh() override
Performs mesh setup such as creating mesh or naming mesh sets.
std::vector< SubdomainName > _flow_channel_subdomains
Subdomains corresponding to the connected flow channel.
Base class for single-phase flow channels.
static InputParameters validParams()
virtual void augmentSparsity(const dof_id_type &elem_id1, const dof_id_type &elem_id2)
Hint how to augment sparsity pattern between two elements.
Definition: Simulation.C:71
bool hasCoupledElemID(const dof_id_type &elem_id) const
Returns true if the element ID has a coupled element ID.
const ExecFlagType EXEC_INITIAL