https://mooseframework.inl.gov
FlowChannel1PhaseBase.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 "FlowChannel1PhaseBase.h"
11 #include "HeatTransfer1PhaseBase.h"
13 #include "THMNames.h"
14 
17 {
19 
20  params.addParam<FunctionName>("initial_p", "Initial pressure in the flow channel [Pa]");
21  params.addParam<FunctionName>("initial_vel", "Initial velocity in the flow channel [m/s]");
22  params.addParam<FunctionName>("initial_T", "Initial temperature in the flow channel [K]");
23  params.addParam<FunctionName>("D_h", "Hydraulic diameter [m]");
24  params.addParam<MooseEnum>(
25  "rdg_slope_reconstruction",
27  "Slope reconstruction type for rDG spatial discretization");
28 
29  params.declareControllable("initial_p initial_T initial_vel D_h");
30  params.addParamNamesToGroup("initial_p initial_T initial_vel", "Variable initialization");
31  params.addParamNamesToGroup("rdg_slope_reconstruction", "Numerical scheme");
32 
33  return params;
34 }
35 
37  : FlowChannelBase(params),
38 
39  _numerical_flux_name(genName(name(), "numerical_flux")),
40  _rdg_slope_reconstruction(getParam<MooseEnum>("rdg_slope_reconstruction"))
41 {
42 }
43 
44 void
46 {
48 }
49 
50 std::shared_ptr<FlowModel>
52 {
53  const std::string class_name = flowModelClassName();
54  InputParameters pars = _factory.getValidParams(class_name);
55  pars.set<THMProblem *>("_thm_problem") = &getTHMProblem();
56  pars.set<FlowChannelBase *>("_flow_channel") = this;
57  pars.set<UserObjectName>("numerical_flux") = _numerical_flux_name;
58  pars.set<bool>("output_vector_velocity") = getTHMProblem().getVectorValuedVelocity();
60  return _factory.create<FlowModel>(class_name, name(), pars, 0);
61 }
62 
63 void
65 {
67 
69 
70  // only 1-phase flow compatible heat transfers are allowed
71  for (unsigned int i = 0; i < _heat_transfer_names.size(); i++)
72  {
73  if (!hasComponentByName<HeatTransfer1PhaseBase>(_heat_transfer_names[i]))
74  logError("Coupled heat source '",
76  "' is not compatible with single phase flow channel. Use single phase heat transfer "
77  "component instead.");
78  }
79 
80  bool ics_set = true;
81  for (const auto & ic_param : ICParameters())
82  ics_set = ics_set && isParamValid(ic_param);
83  ics_set = ics_set || getTHMProblem().hasInitialConditionsFromFile();
84 
85  if (!ics_set && !_app.isRestarting())
86  {
87  // create a list of the missing IC parameters
88  std::ostringstream oss;
89  for (const auto & ic_param : ICParameters())
90  if (!isParamValid(ic_param))
91  oss << " " << ic_param;
92 
93  logError("The following initial condition parameters are missing:", oss.str());
94  }
95 }
96 
97 void
99 {
101 
104 }
105 
106 void
108 {
109  const std::string mat_name = genName(name(), "D_h_material");
110 
111  if (isParamValid("D_h"))
112  {
113  const FunctionName & D_h_fn_name = getParam<FunctionName>("D_h");
114 
115  const std::string class_name = "ADGenericFunctionMaterial";
116  InputParameters params = _factory.getValidParams(class_name);
117  params.set<std::vector<SubdomainName>>("block") = getSubdomainNames();
118  params.set<std::vector<std::string>>("prop_names") = {THM::HYDRAULIC_DIAMETER};
119  params.set<std::vector<FunctionName>>("prop_values") = {D_h_fn_name};
120  getTHMProblem().addMaterial(class_name, mat_name, params);
121 
122  makeFunctionControllableIfConstant(D_h_fn_name, "D_h");
123  }
124  else
125  {
126  const std::string class_name = "ADHydraulicDiameterCircularMaterial";
127  InputParameters params = _factory.getValidParams(class_name);
128  params.set<std::vector<SubdomainName>>("block") = getSubdomainNames();
129  params.set<MaterialPropertyName>("D_h_name") = THM::HYDRAULIC_DIAMETER;
130  params.set<std::vector<VariableName>>("A") = {THM::AREA};
131  getTHMProblem().addMaterial(class_name, mat_name, params);
132  }
133 }
134 
135 void
137 {
139 
140  for (unsigned int i = 0; i < _n_heat_transfer_connections; i++)
141  {
142  const HeatTransfer1PhaseBase & heat_transfer =
143  getComponentByName<HeatTransfer1PhaseBase>(_heat_transfer_names[i]);
144 
146  }
147 }
virtual std::string flowModelClassName() const =0
Returns the flow model class name.
Specialization of FEProblem to run with component subsystem.
Definition: THMProblem.h:18
virtual void init() override
Initializes the component.
virtual void addHydraulicDiameterMaterial()
Adds a material for the hydraulic diameter.
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.
static InputParameters validParams()
virtual void addMooseObjects() override
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
virtual void check() const override
Check the component integrity.
Provides functions to setup the flow model.
Definition: FlowModel.h:27
virtual void addMaterial(const std::string &material_name, const std::string &name, InputParameters &parameters)
const bool & _pipe_pars_transferred
Base class for heat transfer connections to 1-phase flow channels.
T & set(const std::string &name, bool quiet_mode=false)
std::shared_ptr< MooseObject > create(const std::string &obj_name, const std::string &name, const InputParameters &parameters, THREAD_ID tid=0, bool print_deprecated=true)
virtual std::vector< std::string > ICParameters() const =0
Returns the names of the IC parameters.
InputParameters getValidParams(const std::string &name) const
void applyParameters(const InputParameters &common, const std::vector< std::string > &exclude={}, const bool allow_private=false)
A base class for flow channels.
bool getVectorValuedVelocity()
Is velocity output as vector-valued field.
Definition: Simulation.h:359
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
std::vector< MaterialPropertyName > _Hw_1phase_names
1-phase wall heat transfer coefficient names for connected heat transfers
FlowChannel1PhaseBase(const InputParameters &params)
bool isRestarting() const
virtual const std::string & name() const
void logError(Args &&... args) const
Logs an error.
Definition: Component.h:215
bool isParamValid(const std::string &name) const
virtual std::shared_ptr< FlowModel > buildFlowModel() override
const UserObjectName _numerical_flux_name
Numerical flux user object name.
std::vector< std::string > _heat_transfer_names
Names of the heat transfer components connected to this component.
unsigned int _n_heat_transfer_connections
Number of connected heat transfer components.
const std::string name
Definition: Setup.h:20
static const std::string HYDRAULIC_DIAMETER
Definition: THMNames.h:23
virtual void getHeatTransferVariableNames()
Populates heat connection variable names lists.
const MaterialPropertyName & getWallHeatTransferCoefficient1PhaseName() const
Returns 1-phase wall heat transfer coefficient name.
static const std::string AREA
Definition: THMNames.h:14
static InputParameters validParams()
virtual void addMooseObjects() override
virtual void init() override
Initializes the component.
MooseApp & _app
virtual void getHeatTransferVariableNames() override
Populates heat connection variable names lists.
Factory & _factory
The Factory associated with the MooseApp.
Definition: Component.h:446
virtual void check() const override
Check the component integrity.
virtual void checkFluidProperties() const =0
Logs an error if the fluid properties is not valid.
const InputParameters & parameters() const
virtual const std::vector< SubdomainName > & getSubdomainNames() const
Gets the subdomain names for this component.
Definition: Component.C:307
void declareControllable(const std::string &name, std::set< ExecFlagType > execute_flags={})
static MooseEnum getSlopeReconstructionMooseEnum(const std::string &name="")
Gets a MooseEnum for slope reconstruction type.
bool hasInitialConditionsFromFile() const
Are initial conditions specified from a file.
Definition: Simulation.C:1070
void addParamNamesToGroup(const std::string &space_delim_names, const std::string group_name)