https://mooseframework.inl.gov
Closures1PhaseSimple.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 "Closures1PhaseSimple.h"
11 #include "FlowModelSinglePhase.h"
12 #include "FlowChannel1Phase.h"
13 #include "HeatTransfer1PhaseBase.h"
14 
15 registerMooseObject("ThermalHydraulicsApp", Closures1PhaseSimple);
16 
19 {
21 
22  params.addClassDescription("Simple 1-phase closures");
23 
24  return params;
25 }
26 
28  : Closures1PhaseBase(params)
29 {
30 }
31 
32 void
34 {
35  if (!flow_channel.isParamValid("f"))
36  logComponentError(flow_channel.cname(),
37  "When using simple closures, the parameter 'f' must be provided.");
38 }
39 
40 void
42  const FlowChannelBase & /*flow_channel*/) const
43 {
44  if (!heat_transfer.isParamValid("Hw"))
45  logComponentError(heat_transfer.cname(),
46  "The parameter 'Hw' must be provided when using simple closures.");
47 }
48 
49 void
51 {
52  const FlowChannel1Phase & flow_channel_1phase =
53  dynamic_cast<const FlowChannel1Phase &>(flow_channel);
54 
55  // wall friction material
56  addWallFrictionFunctionMaterial(flow_channel_1phase);
57 
58  const unsigned int n_ht_connections = flow_channel_1phase.getNumberOfHeatTransferConnections();
59  if (n_ht_connections > 0)
60  {
61  // wall heat transfer coefficient material
62  if (n_ht_connections > 1)
63  addWeightedAverageMaterial(flow_channel_1phase,
64  flow_channel_1phase.getWallHTCNames1Phase(),
65  flow_channel_1phase.getHeatedPerimeterNames(),
67 
68  // wall temperature material
69  if (flow_channel_1phase.getTemperatureMode())
70  {
71  if (n_ht_connections > 1)
72  addAverageWallTemperatureMaterial(flow_channel_1phase);
73  else
74  addWallTemperatureFromAuxMaterial(flow_channel_1phase);
75  }
76  else
77  {
78  if (n_ht_connections > 1)
79  addWallTemperatureFromHeatFluxMaterial(flow_channel_1phase);
80  }
81  }
82 }
83 
84 void
86  const FlowChannelBase & flow_channel)
87 {
88  const HeatTransfer1PhaseBase & heat_transfer_1phase =
89  dynamic_cast<const HeatTransfer1PhaseBase &>(heat_transfer);
90  const FunctionName & Hw_fn_name = heat_transfer.getParam<FunctionName>("Hw");
91 
92  {
93  const std::string class_name = "ADGenericFunctionMaterial";
94  InputParameters params = _factory.getValidParams(class_name);
95  params.set<std::vector<SubdomainName>>("block") = flow_channel.getSubdomainNames();
96  params.set<std::vector<std::string>>("prop_names") = {
97  heat_transfer_1phase.getWallHeatTransferCoefficient1PhaseName()};
98  params.set<std::vector<FunctionName>>("prop_values") = {Hw_fn_name};
100  class_name, genName(heat_transfer.name(), "Hw_material", flow_channel.name()), params);
101  }
102 
103  heat_transfer.makeFunctionControllableIfConstant(Hw_fn_name, "Hw");
104 }
105 
106 void
108  const FlowChannel1Phase & flow_channel) const
109 {
110  const std::string class_name = "ADTemperatureWall3EqnMaterial";
111  InputParameters params = _factory.getValidParams(class_name);
112  params.set<std::vector<SubdomainName>>("block") = flow_channel.getSubdomainNames();
113  params.set<MaterialPropertyName>("T") = FlowModelSinglePhase::TEMPERATURE;
114  params.set<MaterialPropertyName>("q_wall") = FlowModel::HEAT_FLUX_WALL;
115  params.set<MaterialPropertyName>("Hw") = FlowModelSinglePhase::HEAT_TRANSFER_COEFFICIENT_WALL;
116  _sim.addMaterial(class_name, genName(flow_channel.name(), "T_wall_mat"), params);
117 }
THMProblem & _sim
Simulation.
Definition: ClosuresBase.h:100
static InputParameters validParams()
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.
std::vector< VariableName > getHeatedPerimeterNames() const
Gets heated perimeter names for connected heat transfers.
static const std::string TEMPERATURE
void addWeightedAverageMaterial(const FlowChannelBase &flow_channel, const std::vector< MaterialPropertyName > &values, const std::vector< VariableName > &weights, const MaterialPropertyName &property_name) const
Adds a weighted average material.
Definition: ClosuresBase.C:49
unsigned int getNumberOfHeatTransferConnections() const
Gets the number of heat transfer connections.
virtual void addMaterial(const std::string &material_name, const std::string &name, InputParameters &parameters)
Base class for heat transfer connections to 1-phase flow channels.
T & set(const std::string &name, bool quiet_mode=false)
static InputParameters validParams()
InputParameters getValidParams(const std::string &name) const
const std::string & cname() const
Get the component name.
Definition: Component.C:51
static const std::string HEAT_TRANSFER_COEFFICIENT_WALL
void logComponentError(const std::string &component_name, Args &&... args) const
Logs an error for a component.
A base class for flow channels.
void addAverageWallTemperatureMaterial(const FlowChannel1Phase &flow_channel) const
Adds average wall temperature material.
virtual void checkHeatTransfer(const HeatTransferBase &heat_transfer, const FlowChannelBase &flow_channel) const override
Checks for errors associated with a heat transfer component.
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
virtual const std::string & name() const
bool isParamValid(const std::string &name) const
void addWallTemperatureFromAuxMaterial(const FlowChannelBase &flow_channel, unsigned int i=0) const
Adds a material for wall temperature from an aux variable.
Definition: ClosuresBase.C:64
virtual void addMooseObjectsFlowChannel(const FlowChannelBase &flow_channel) override
Adds MOOSE objects associated with a flow channel component.
Single-component, single-phase flow channel.
Simple 1-phase closures.
const T & getParam(const std::string &name) const
Base class for heat transfer connections.
Closures1PhaseSimple(const InputParameters &params)
const MaterialPropertyName & getWallHeatTransferCoefficient1PhaseName() const
Returns 1-phase wall heat transfer coefficient name.
Base class for 1-phase closures.
virtual void addMooseObjectsHeatTransfer(const HeatTransferBase &heat_transfer, const FlowChannelBase &flow_channel) override
Adds MOOSE objects associated with a heat transfer component.
std::vector< MaterialPropertyName > getWallHTCNames1Phase() const
Gets 1-phase wall heat transfer coefficient names for connected heat transfers.
Factory & _factory
Factory associated with the MooseApp.
Definition: ClosuresBase.h:103
void addWallTemperatureFromHeatFluxMaterial(const FlowChannel1Phase &flow_channel) const
Adds material to compute wall temperature from heat flux.
static const std::string HEAT_FLUX_WALL
Definition: FlowModel.h:104
virtual void checkFlowChannel(const FlowChannelBase &flow_channel) const override
Checks for errors associated with a flow channel component.
void addClassDescription(const std::string &doc_string)
void addWallFrictionFunctionMaterial(const FlowChannel1Phase &flow_channel) const
Adds material that computes wall friction factor from a specified function.
virtual const std::vector< SubdomainName > & getSubdomainNames() const
Gets the subdomain names for this component.
Definition: Component.C:307
bool getTemperatureMode() const
Gets temperature mode flag.
registerMooseObject("ThermalHydraulicsApp", Closures1PhaseSimple)