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.addDeprecatedParam<std::string>(
21  "pipe", "Name of pipe component to connect", "Use 'flow_channel' parameter instead.");
22  params.addRequiredParam<std::string>("flow_channel",
23  "Name of flow channel component to connect to");
24  params.addParam<bool>(
25  "P_hf_transferred", false, "Is heat flux perimeter transferred from an external source?");
26  params.addParam<FunctionName>("P_hf", "Heat flux perimeter [m]");
27  params.declareControllable("P_hf");
28  return params;
29 }
30 
32  : ConnectorBase(parameters),
33  _flow_channel_name(getParam<std::string>("flow_channel")),
34  _P_hf_transferred(getParam<bool>("P_hf_transferred")),
35  _P_hf_provided(isParamValid("P_hf"))
36 {
38 }
39 
40 void
42 {
44 
45  checkComponentOfTypeExistsByName<FlowChannelBase>(_flow_channel_name);
46 
47  if (hasComponentByName<FlowChannelBase>(_flow_channel_name))
48  {
49  const FlowChannelBase & flow_channel = getComponentByName<FlowChannelBase>(_flow_channel_name);
50 
51  // add the name of this heat transfer component to list for flow channel
52  flow_channel.addHeatTransferName(name());
53 
54  // get various data from flow channel
56  _model_type = flow_channel.getFlowModelID();
57  _fp_name = flow_channel.getFluidPropertiesName();
58  _A_fn_name = flow_channel.getAreaFunctionName();
59  _closures_objects = flow_channel.getClosuresObjects();
60  }
61 }
62 
63 void
65 {
67 
68  // determine names of heat transfer variables
69  if (hasComponentByName<FlowChannelBase>(_flow_channel_name))
70  {
71  const FlowChannelBase & flow_channel = getComponentByName<FlowChannelBase>(_flow_channel_name);
72 
73  const std::string suffix = flow_channel.getHeatTransferNamesSuffix(name());
74 
79  }
80 }
81 
82 void
84 {
86 }
87 
88 void
90 {
91  // heat flux perimeter variable
92  if (!_P_hf_transferred)
94 }
95 
96 void
98 {
99  // create heat flux perimeter aux if not transferred from external app
100  if (!_P_hf_transferred)
101  {
102  const std::string class_name = "FunctionAux";
103  InputParameters params = _factory.getValidParams(class_name);
104  params.set<AuxVariableName>("variable") = {_P_hf_name};
105  params.set<std::vector<SubdomainName>>("block") = _flow_channel_subdomains;
106  params.set<FunctionName>("function") = _P_hf_fn_name;
107 
109  execute_on = {EXEC_TIMESTEP_BEGIN, EXEC_INITIAL};
110  params.set<ExecFlagEnum>("execute_on") = execute_on;
111 
112  getTHMProblem().addAuxKernel(class_name, genName(name(), "P_hf_auxkernel"), params);
113  }
114 }
115 
116 void
118 {
120  false, _P_hf_name, getTHMProblem().getFlowFEType(), _flow_channel_subdomains);
121 
122  // create heat flux perimeter variable if not transferred from external app
123  if (!_P_hf_transferred)
124  {
125  if (_P_hf_provided)
126  {
127  _P_hf_fn_name = getParam<FunctionName>("P_hf");
128  }
129  // create heat flux perimeter function if not provided; assume circular flow channel
130  else
131  {
132  _P_hf_fn_name = genName(name(), "P_hf_fn");
133 
134  const std::string class_name = "GeneralizedCircumference";
135  InputParameters params = _factory.getValidParams(class_name);
136  params.set<FunctionName>("area_function") = _A_fn_name;
137  getTHMProblem().addFunction(class_name, _P_hf_fn_name, params);
138 
140  }
141 
142  if (!_app.isRestarting())
144  }
145 }
146 
147 const VariableName &
149 {
151 
152  return _P_hf_name;
153 }
154 
155 const VariableName &
157 {
159 
160  return _T_wall_name;
161 }
162 
163 const MaterialPropertyName &
165 {
167 
168  return _T_wall_mat_name;
169 }
170 
171 const MaterialPropertyName &
173 {
174  return _q_wall_name;
175 }
176 
177 const UserObjectName &
179 {
181 
182  return _fp_name;
183 }
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 addDeprecatedParam(const std::string &name, const T &value, const std::string &doc_string, const std::string &deprecation_message)
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)
void makeFunctionControllableIfConstant(const FunctionName &fn_name, const std::string &control_name, const std::string &param="value") const
Makes a function controllable if it is constant.
Definition: Component.C:141
bool isRestarting() const
virtual const std::string & name() 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:301
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
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:40
mesh set up, called both inits
Definition: Component.h:41
virtual void init()
Initializes the component.
Definition: Component.h:290
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:296
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:446
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:307
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
void declareControllable(const std::string &name, std::set< ExecFlagType > execute_flags={})
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