https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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
12#include "HeatStructureBase.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)
37 _mesh_alignment(constMesh(), true)
38{
39}
40
41const libMesh::FEType &
46
47void
49{
50 if (hasComponentByName<HeatStructureBase>(_hs_name) &&
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 if (!HSBoundaryIsValid(this))
58 return;
59
60 const auto hs_boundary = getHSBoundaryName(this);
61
62 _mesh_alignment.initialize(flow_channel.getElementIDs(), hs.getBoundaryInfo(hs_boundary));
63
65 {
66 logError("The centers of the elements of flow channel '",
68 "' do not align with the centers of the specified heat structure side.");
69 return;
70 }
71
72 for (const auto & elem_id : _mesh_alignment.getPrimaryElemIDs())
73 {
76 }
77 }
78}
79
80void
86
87void
89{
91
92 // wall temperature initial condition
93 if (!getTHMProblem().hasInitialConditionsFromFile() && !_app.isRestarting())
94 {
95 const HeatStructureBase & hs = getComponentByName<HeatStructureBase>(_hs_name);
97 }
98}
99
100void
102{
104
106 execute_on = {EXEC_INITIAL, EXEC_LINEAR, EXEC_NONLINEAR};
107
108 const HeatStructureBase & hs = getComponentByName<HeatStructureBase>(_hs_name);
109 const bool is_cylindrical = dynamic_cast<const HeatStructureCylindricalBase *>(&hs) != nullptr;
110 const FlowChannel1PhaseBase & flow_channel =
111 getComponentByName<FlowChannel1PhaseBase>(_flow_channel_name);
112
113 const UserObjectName heat_flux_uo_name = genName(name(), "heat_flux_uo");
114 {
115 const std::string class_name = "ADHeatFluxFromHeatStructure3EqnUserObject";
116 InputParameters params = _factory.getValidParams(class_name);
117 params.set<std::vector<SubdomainName>>("block") = flow_channel.getSubdomainNames();
118 params.set<MeshAlignment *>("_mesh_alignment") = &_mesh_alignment;
119 params.set<MaterialPropertyName>("T_wall") = _T_wall_name + "_coupled";
120 params.set<std::vector<VariableName>>("P_hf") = {_P_hf_name};
121 params.set<MaterialPropertyName>("Hw") = _Hw_1phase_name;
122 params.set<MaterialPropertyName>("T") = FlowModelSinglePhase::TEMPERATURE;
123 params.set<MooseFunctorName>("scale") = getParam<MooseFunctorName>("scale");
124 params.set<ExecFlagEnum>("execute_on") = execute_on;
125 getTHMProblem().addUserObject(class_name, heat_flux_uo_name, params);
126 }
127
128 {
129 const std::string class_name = "ADOneD3EqnEnergyHeatFlux";
130 InputParameters params = _factory.getValidParams(class_name);
131 params.set<std::vector<SubdomainName>>("block") = flow_channel.getSubdomainNames();
132 params.set<NonlinearVariableName>("variable") = FlowModelSinglePhase::RHOEA;
133 params.set<UserObjectName>("q_uo") = heat_flux_uo_name;
134 getTHMProblem().addKernel(class_name, genName(name(), "heat_flux_kernel"), params);
135 }
136
137 {
138 const std::string class_name = "ADHeatFlux3EqnBC";
139 InputParameters params = _factory.getValidParams(class_name);
140 params.set<std::vector<BoundaryName>>("boundary") = {getHSBoundaryName(this)};
141 params.set<NonlinearVariableName>("variable") = HeatConductionModel::TEMPERATURE;
142 params.set<UserObjectName>("q_uo") = heat_flux_uo_name;
143 params.set<Real>("P_hs_unit") = hs.getUnitPerimeter(getHSExternalBoundaryType(this));
144 params.set<unsigned int>("n_unit") = hs.getNumberOfUnits();
145 params.set<bool>("hs_coord_system_is_cylindrical") = is_cylindrical;
146 getTHMProblem().addBoundaryCondition(class_name, genName(name(), "heat_flux_bc"), params);
147 }
148
149 // Transfer the temperature of the solid onto the flow channel
150 {
151 std::string class_name = "MeshAlignmentVariableTransferMaterial";
152 InputParameters params = _factory.getValidParams(class_name);
153 params.set<std::vector<SubdomainName>>("block") = flow_channel.getSubdomainNames();
154 params.set<MaterialPropertyName>("property_name") = _T_wall_name + "_coupled";
155 params.set<std::string>("paired_variable") = HeatConductionModel::TEMPERATURE;
156 params.set<MeshAlignment *>("_mesh_alignment") = &_mesh_alignment;
157 getTHMProblem().addMaterial(class_name, genName(name(), "T_wall_transfer_mat"), params);
158 }
159
160 // Transfer the temperature of the solid onto the flow channel as aux variable for visualization
161 {
162 std::string class_name = "VariableValueTransferAux";
163 InputParameters params = _factory.getValidParams(class_name);
164 params.set<AuxVariableName>("variable") = _T_wall_name;
165 params.set<std::vector<BoundaryName>>("boundary") = {getChannelSideName()};
166 params.set<BoundaryName>("paired_boundary") = getHSBoundaryName(this);
167 params.set<std::vector<VariableName>>("paired_variable") =
168 std::vector<VariableName>(1, HeatConductionModel::TEMPERATURE);
169 getTHMProblem().addAuxKernel(class_name, genName(name(), "T_wall_transfer"), params);
170 }
171}
172
173const BoundaryName &
175{
176 const FlowChannel1PhaseBase & flow_channel =
177 getComponentByName<FlowChannel1PhaseBase>(_flow_channel_name);
178 return flow_channel.getNodesetName();
179}
registerMooseObject("ThermalHydraulicsApp", HeatTransferFromHeatStructure1Phase)
const ExecFlagType EXEC_INITIAL
const ExecFlagType EXEC_LINEAR
const ExecFlagType EXEC_NONLINEAR
const std::string name
Definition Setup.h:21
const BoundaryName & getNodesetName() const
Gets the 1D component nodeset name.
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.
virtual const std::vector< SubdomainName > & getSubdomainNames() const
Gets the subdomain names for this component.
Definition Component.C:345
void logError(Args &&... args) const
Logs an error.
Definition Component.h:226
const std::vector< dof_id_type > & getElementIDs() const
Gets the element IDs corresponding to this component.
Definition Component.C:337
THMProblem & getTHMProblem() const
Gets the THM problem.
Definition Component.C:135
Factory & _factory
The Factory associated with the MooseApp.
Definition Component.h:497
virtual void check() const
Check the component integrity.
Definition Component.h:416
virtual std::vector< std::shared_ptr< UserObject > > addUserObject(const std::string &user_object_name, const std::string &name, InputParameters &parameters)
virtual void addMaterial(const std::string &material_name, const std::string &name, InputParameters &parameters)
virtual void addBoundaryCondition(const std::string &bc_name, const std::string &name, InputParameters &parameters)
virtual void addKernel(const std::string &kernel_name, const std::string &name, InputParameters &parameters)
virtual void addAuxKernel(const std::string &kernel_name, const std::string &name, InputParameters &parameters)
InputParameters getValidParams(const std::string &name) const
Base class for single-phase flow channels.
static const std::string TEMPERATURE
static const std::string RHOEA
Interface class for coupling to a heat structure boundary.
const std::string & _hs_name
Heat structure name.
const BoundaryName & getHSBoundaryName(const Component *const component) const
Gets the boundary name corresponding to the heat structure and side.
static InputParameters validParams()
bool HSBoundaryIsValid(const Component *const component) const
Returns true if the specified heat structure boundary is valid.
Component2D::ExternalBoundaryType getHSExternalBoundaryType(const Component *const component) const
Gets the external boundary type for the coupled heat structure boundary.
void check(const Component *const component) const
static const libMesh::FEType & feType()
Get the FE type used for heat conduction.
static const std::string TEMPERATURE
Base class for 2D generated heat structures.
Real getNumberOfUnits() const
Gets the number of units that heat structure represents.
virtual Real getUnitPerimeter(const ExternalBoundaryType &side) const =0
Gets the perimeter of one unit of this heat structure on the specified side.
Base class for cylindrical heat structure components.
FunctionName getInitialT() const
Gets the initial temperature function name.
MaterialPropertyName _Hw_1phase_name
1-phase wall heat transfer coefficient name
VariableName _P_hf_name
heated perimeter name
VariableName _T_wall_name
wall temperature name
const std::string _flow_channel_name
name of the connected flow channel
std::vector< SubdomainName > _flow_channel_subdomains
Subdomains corresponding to the connected flow channel.
Connects a 1-phase flow channel and a heat structure.
virtual void setupMesh() override
Performs mesh setup such as creating mesh or naming mesh sets.
virtual void check() const override
Check the component integrity.
const BoundaryName & getChannelSideName() const
Gets the flow channel nodeset name for this connection.
HeatTransferFromHeatStructure1Phase(const InputParameters &parameters)
virtual const libMesh::FEType & getFEType() override
Get the FE type for wall temperature variable.
Base class for heat transfer connections from temperature for 1-phase flow.
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)
T & set(const std::string &name, bool quiet_mode=false)
const std::vector< dof_id_type > & getPrimaryElemIDs() const
Returns the list of element IDs on the primary boundary.
bool meshesAreAligned() const
Returns true if the primary and secondary meshes are aligned.
Builds mapping between two aligned subdomains/boundaries.
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.
bool hasCoupledElemID(const dof_id_type &elem_id) const
Returns true if the element ID has a coupled element ID.
const dof_id_type & getCoupledElemID(const dof_id_type &elem_id) const
Gets the coupled element ID for a given element ID.
bool isRestarting() const
MooseApp & _app
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.
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
void addFunctionIC(const VariableName &var_name, const std::string &func_name, const std::vector< SubdomainName > &block_names)
Definition Simulation.C:532
ExecFlagEnum getDefaultExecFlagEnum()