https://mooseframework.inl.gov
HeatTransferBase.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 
10 #include "HeatTransferBase.h"
11 #include "FlowModelSinglePhase.h"
12 #include "FlowChannelBase.h"
13 #include "ClosuresBase.h"
14 #include "MooseUtils.h"
15 
18 {
20  params.addRequiredParam<std::string>("flow_channel",
21  "Name of flow channel component to connect to");
22  params.addParam<bool>(
23  "P_hf_transferred", false, "Is heat flux perimeter transferred from an external source?");
24  params.addParam<FunctionName>("P_hf", "Heat flux perimeter [m]");
25  return params;
26 }
27 
29  : ConnectorBase(parameters),
30  _flow_channel_name(getParam<std::string>("flow_channel")),
31  _P_hf_transferred(getParam<bool>("P_hf_transferred")),
32  _P_hf_provided(isParamValid("P_hf"))
33 {
35 }
36 
37 void
39 {
41 
42  checkComponentOfTypeExistsByName<FlowChannelBase>(_flow_channel_name);
43 
44  if (hasComponentByName<FlowChannelBase>(_flow_channel_name))
45  {
46  const FlowChannelBase & flow_channel = getComponentByName<FlowChannelBase>(_flow_channel_name);
47 
48  // add the name of this heat transfer component to list for flow channel
49  flow_channel.addHeatTransferName(name());
50 
51  // get various data from flow channel
53  _model_type = flow_channel.getFlowModelID();
54  _fp_name = flow_channel.getFluidPropertiesName();
55  _A_fn_name = flow_channel.getAreaFunctionName();
56  _closures_objects = flow_channel.getClosuresObjects();
57  }
58 }
59 
60 void
62 {
64 
65  // determine names of heat transfer variables
66  if (hasComponentByName<FlowChannelBase>(_flow_channel_name))
67  {
68  const FlowChannelBase & flow_channel = getComponentByName<FlowChannelBase>(_flow_channel_name);
69 
70  const std::string suffix = flow_channel.getHeatTransferNamesSuffix(name());
71 
76  }
77 }
78 
79 void
81 {
83 }
84 
85 void
87 {
88  // heat flux perimeter variable
89  if (!_P_hf_transferred)
91 }
92 
93 void
95 {
96  // create heat flux perimeter aux if not transferred from external app
97  if (!_P_hf_transferred)
98  {
99  const std::string class_name = "FunctionAux";
100  InputParameters params = _factory.getValidParams(class_name);
101  params.set<AuxVariableName>("variable") = {_P_hf_name};
102  params.set<std::vector<SubdomainName>>("block") = _flow_channel_subdomains;
103  params.set<FunctionName>("function") = _P_hf_fn_name;
104 
106  execute_on = {EXEC_TIMESTEP_BEGIN, EXEC_INITIAL};
107  params.set<ExecFlagEnum>("execute_on") = execute_on;
108 
109  getTHMProblem().addAuxKernel(class_name, genName(name(), "P_hf_auxkernel"), params);
110  }
111 }
112 
113 void
115 {
117  false, _P_hf_name, getTHMProblem().getFlowFEType(), _flow_channel_subdomains);
118 
119  // create heat flux perimeter variable if not transferred from external app
120  if (!_P_hf_transferred)
121  {
122  if (_P_hf_provided)
123  {
124  _P_hf_fn_name = getParam<FunctionName>("P_hf");
125  }
126  // create heat flux perimeter function if not provided; assume circular flow channel
127  else
128  {
129  _P_hf_fn_name = genName(name(), "P_hf_fn");
130 
131  const std::string class_name = "GeneralizedCircumference";
132  InputParameters params = _factory.getValidParams(class_name);
133  params.set<FunctionName>("area_function") = _A_fn_name;
134  getTHMProblem().addFunction(class_name, _P_hf_fn_name, params);
135  }
136 
137  if (!_app.isRestarting())
139  }
140 }
141 
142 const VariableName &
144 {
146 
147  return _P_hf_name;
148 }
149 
150 const VariableName &
152 {
154 
155  return _T_wall_name;
156 }
157 
158 const MaterialPropertyName &
160 {
162 
163  return _T_wall_mat_name;
164 }
165 
166 const MaterialPropertyName &
168 {
169  return _q_wall_name;
170 }
171 
172 const UserObjectName &
174 {
176 
177  return _fp_name;
178 }
const FunctionName & getAreaFunctionName() const
Get the name of the function describing the flow channel area.
HeatTransferBase(const InputParameters &parameters)
virtual void initSecondary() override
Perform secondary initialization, which relies on init() being called for all components.
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.
VariableName _T_wall_name
wall temperature name
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
THMProblem & getTHMProblem() const
Gets the THM problem.
Definition: Component.C:135
void addDependency(const std::string &dependency)
Adds a component name to the list of dependencies.
Definition: Component.C:129
std::vector< std::shared_ptr< ClosuresBase > > getClosuresObjects() const
Get the used closures object(s)
std::vector< std::shared_ptr< ClosuresBase > > _closures_objects
Used closures object(s)
const UserObjectName & getFluidPropertiesName() const
T & set(const std::string &name, bool quiet_mode=false)
FunctionName _A_fn_name
area function name for the connected flow channel
InputParameters getValidParams(const std::string &name) const
A base class for flow channels.
Base class for creating component that connect other components together (e.g.
Definition: ConnectorBase.h:18
virtual void addAuxKernel(const std::string &kernel_name, const std::string &name, InputParameters &parameters)
bool isRestarting() const
void addRequiredParam(const std::string &name, const std::string &doc_string)
void addFunctionIC(const VariableName &var_name, const std::string &func_name, const std::vector< SubdomainName > &block_names)
Definition: Simulation.C:532
void addHeatedPerimeter()
Adds heated perimeter variable and objects.
ExecFlagEnum getDefaultExecFlagEnum()
VariableName _P_hf_name
heated perimeter name
virtual void check() const
Check the component integrity.
Definition: Component.h:416
void addSimVariable(bool nl, const VariableName &name, libMesh::FEType fe_type, Real scaling_factor=1.0)
Queues a variable of type MooseVariableScalar to be added to the nonlinear or aux system...
Definition: Simulation.C:271
const std::string & name() const
virtual void check() const override
Check the component integrity.
static const std::string TEMPERATURE_WALL
Definition: FlowModel.h:108
const ExecFlagType EXEC_TIMESTEP_BEGIN
const MaterialPropertyName & getWallHeatFluxName() const
Returns wall heat flux name.
void addHeatTransferName(const std::string &ht_name) const
Adds the name of a heat transfer component to the flow channel&#39;s list.
virtual void addFunction(const std::string &type, const std::string &name, InputParameters &parameters)
virtual void addMooseObjects() override
mesh set up, called primary init
Definition: Component.h:41
mesh set up, called both inits
Definition: Component.h:42
virtual void init()
Initializes the component.
Definition: Component.h:405
UserObjectName _fp_name
fluid properties object name
const std::string _flow_channel_name
name of the connected flow channel
virtual void initSecondary()
Perform secondary initialization, which relies on init() being called for all components.
Definition: Component.h:411
static InputParameters validParams()
static const std::string HEAT_FLUX_PERIMETER
Definition: FlowModel.h:105
MooseApp & _app
void checkSetupStatus(const EComponentSetupStatus &status) const
Throws an error if the supplied setup status of this component has not been reached.
Definition: Component.C:117
MaterialPropertyName _q_wall_name
wall heat flux name
THM::FlowModelID _model_type
flow model type
Factory & _factory
The Factory associated with the MooseApp.
Definition: Component.h:497
FunctionName _P_hf_fn_name
heated perimeter function name
static const std::string HEAT_FLUX_WALL
Definition: FlowModel.h:104
virtual void init() override
Initializes the component.
std::string getHeatTransferNamesSuffix(const std::string &ht_name) const
Gets suffix to add to heat-transfer-related names in a heat transfer component.
const VariableName & getWallTemperatureName() const
Returns wall temperature name.
virtual void addVariables() override
virtual const std::vector< SubdomainName > & getSubdomainNames() const
Gets the subdomain names for this component.
Definition: Component.C:345
const VariableName & getHeatedPerimeterName() const
Returns heated perimeter name.
const MaterialPropertyName & getWallTemperatureMatName() const
Returns wall temperature name.
std::vector< SubdomainName > _flow_channel_subdomains
Subdomains corresponding to the connected flow channel.
const bool _P_hf_transferred
flag that heated perimeter is transferred from another application
const bool _P_hf_provided
flag that the heated perimeter was specified via an input parameter
virtual const THM::FlowModelID & getFlowModelID() const =0
Gets the flow model ID.
static InputParameters validParams()
Definition: ConnectorBase.C:13
MaterialPropertyName _T_wall_mat_name
wall temperature material name
const UserObjectName & getFluidPropertiesName() const
Gets the name of the fluid properties user object for this component.
const ExecFlagType EXEC_INITIAL