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<bool>("enable_heat_conduction", false, "Enable heat conduction?");
25  params.addParam<MooseEnum>(
26  "rdg_slope_reconstruction",
28  "Slope reconstruction type for rDG spatial discretization");
29 
30  params.addParam<Real>("p_ref", 101.325e3, "Reference pressure [Pa]");
31  params.addParam<Real>("T_ref", 273.15, "Reference temperature [K]");
32  params.addParam<Real>("vel_ref", 1.0, "Reference velocity [m/s]");
33 
34  params.declareControllable("initial_p initial_T initial_vel");
35  params.addParamNamesToGroup("initial_p initial_T initial_vel", "Variable initialization");
36  params.addParamNamesToGroup("rdg_slope_reconstruction", "Numerical scheme");
37 
38  return params;
39 }
40 
42  : FlowChannelBase(params),
43 
44  _numerical_flux_name(genName(name(), "numerical_flux")),
45  _rdg_slope_reconstruction(getParam<MooseEnum>("rdg_slope_reconstruction"))
46 {
47 }
48 
49 void
51 {
53 }
54 
55 std::shared_ptr<FlowModel>
57 {
58  const std::string class_name = flowModelClassName();
59  InputParameters pars = _factory.getValidParams(class_name);
60  pars.set<THMProblem *>("_thm_problem") = &getTHMProblem();
61  pars.set<FlowChannelBase *>("_flow_channel") = this;
62  pars.set<UserObjectName>("numerical_flux") = _numerical_flux_name;
63  pars.set<bool>("output_vector_velocity") = getTHMProblem().getVectorValuedVelocity();
65  return _factory.create<FlowModel>(class_name, name(), pars, 0);
66 }
67 
68 void
70 {
72 
74 
75  // only 1-phase flow compatible heat transfers are allowed
76  for (unsigned int i = 0; i < _heat_transfer_names.size(); i++)
77  {
78  if (!hasComponentByName<HeatTransfer1PhaseBase>(_heat_transfer_names[i]))
79  logError("Coupled heat source '",
81  "' is not compatible with single phase flow channel. Use single phase heat transfer "
82  "component instead.");
83  }
84 
85  bool ics_set = true;
86  for (const auto & ic_param : ICParameters())
87  ics_set = ics_set && isParamValid(ic_param);
88  ics_set = ics_set || getTHMProblem().hasInitialConditionsFromFile();
89 
90  if (!ics_set && !_app.isRestarting())
91  {
92  // create a list of the missing IC parameters
93  std::ostringstream oss;
94  for (const auto & ic_param : ICParameters())
95  if (!isParamValid(ic_param))
96  oss << " " << ic_param;
97 
98  logError("The following initial condition parameters are missing:", oss.str());
99  }
100 }
101 
102 void
104 {
106 
109 }
110 
111 void
113 {
114  const std::string mat_name = genName(name(), "D_h_material");
115 
116  if (isParamValid("D_h"))
117  {
118  const FunctionName & D_h_fn_name = getParam<FunctionName>("D_h");
119 
120  const std::string class_name = "ADGenericFunctionMaterial";
121  InputParameters params = _factory.getValidParams(class_name);
122  params.set<std::vector<SubdomainName>>("block") = getSubdomainNames();
123  params.set<std::vector<std::string>>("prop_names") = {THM::HYDRAULIC_DIAMETER};
124  params.set<std::vector<FunctionName>>("prop_values") = {D_h_fn_name};
125  getTHMProblem().addMaterial(class_name, mat_name, params);
126  }
127  else
128  {
129  const std::string class_name = "ADHydraulicDiameterCircularMaterial";
130  InputParameters params = _factory.getValidParams(class_name);
131  params.set<std::vector<SubdomainName>>("block") = getSubdomainNames();
132  params.set<MaterialPropertyName>("D_h_name") = THM::HYDRAULIC_DIAMETER;
133  params.set<std::vector<VariableName>>("A") = {THM::AREA};
134  getTHMProblem().addMaterial(class_name, mat_name, params);
135  }
136 }
137 
138 void
140 {
142 
143  for (unsigned int i = 0; i < _n_heat_transfer_connections; i++)
144  {
145  const HeatTransfer1PhaseBase & heat_transfer =
146  getComponentByName<HeatTransfer1PhaseBase>(_heat_transfer_names[i]);
147 
149  }
150 }
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
const InputParameters & parameters() const
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
std::vector< MaterialPropertyName > _Hw_1phase_names
1-phase wall heat transfer coefficient names for connected heat transfers
FlowChannel1PhaseBase(const InputParameters &params)
bool isRestarting() const
void logError(Args &&... args) const
Logs an error.
Definition: Component.h:226
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.
const std::string & name() const
unsigned int _n_heat_transfer_connections
Number of connected heat transfer components.
const std::string name
Definition: Setup.h:21
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.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
MooseApp & _app
virtual void getHeatTransferVariableNames() override
Populates heat connection variable names lists.
Factory & _factory
The Factory associated with the MooseApp.
Definition: Component.h:497
virtual void check() const override
Check the component integrity.
virtual void checkFluidProperties() const =0
Logs an error if the fluid properties is not valid.
bool isParamValid(const std::string &name) const
virtual const std::vector< SubdomainName > & getSubdomainNames() const
Gets the subdomain names for this component.
Definition: Component.C:345
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)