https://mooseframework.inl.gov
Loading...
Searching...
No Matches
FlowChannel1Phase.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 "FlowChannel1Phase.h"
13#include "THMNames.h"
14#include "MooseUtils.h"
16
17registerMooseObject("ThermalHydraulicsApp", FlowChannel1Phase);
18
21{
23
24 params.addParam<std::vector<FunctionName>>(
25 "initial_passives",
26 {},
27 "Initial passive transport variable values in the flow channel, if any (units are "
28 "[amount/m^3], where 'amount' may be mass (kg) or a number (molecules, moles, etc.))");
29 params.addParam<std::vector<VariableName>>(
30 "passives_names",
31 {},
32 "Names for each passive transport variable [amount/m^3]. Note that the conserved (solution) "
33 "variables will be an amount per unit volume multiplied by the channel cross-sectional area, "
34 "yielding an amount per unit length; these solution variable names will append '_times_area' "
35 "to the names given in this parameter.");
36
37 MooseEnum wave_speed_formulation("einfeldt davis", "einfeldt");
38 params.addParam<MooseEnum>(
39 "wave_speed_formulation", wave_speed_formulation, "Method for computing wave speeds");
40
41 std::vector<Real> sf_1phase(3, 1.0);
42 params.addParam<std::vector<Real>>(
43 "scaling_factor_1phase",
44 sf_1phase,
45 "Scaling factors for each single phase variable (rhoA, rhouA, rhoEA)");
46 params.addParam<std::vector<Real>>("scaling_factor_passives",
47 "Scaling factor for each passive transport variable");
48 params.addParam<bool>(
49 "create_flux_vpp",
50 false,
51 "If true, create a VectorPostprocessor with the the mass, momentum, and energy side fluxes");
52
53 params.addParam<Real>("p_rel_step_tol", 1e-5, "Pressure relative step tolerance");
54 params.addParam<Real>("T_rel_step_tol", 1e-5, "Temperature relative step tolerance");
55 params.addParam<Real>("vel_rel_step_tol", 1e-5, "Velocity relative step tolerance");
56 params.addParam<Real>("mass_res_tol", 1e-5, "Mass equation normalized residual tolerance");
57 params.addParam<Real>(
58 "momentum_res_tol", 1e-5, "Momentum equation normalized residual tolerance");
59 params.addParam<Real>("energy_res_tol", 1e-5, "Energy equation normalized residual tolerance");
60
61 params.addParamNamesToGroup("scaling_factor_1phase", "Numerical scheme");
62 params.addClassDescription("1-phase 1D flow channel");
63
64 return params;
65}
66
70
71void
73{
75
76 checkEqualSize<VariableName, FunctionName>("passives_names", "initial_passives");
77 if (isParamValid("scaling_factor_passives"))
78 checkEqualSize<VariableName, Real>("passives_names", "scaling_factor_passives");
79}
80
81void
83{
85 if (dynamic_cast<const SinglePhaseFluidProperties *>(&fp) == nullptr)
86 logError("Supplied fluid properties must be for 1-phase fluids.");
87}
88
89std::string
91{
92 return "FlowModelSinglePhase";
93}
94
95std::vector<std::string>
97{
98 return {"initial_p", "initial_T", "initial_vel"};
99}
100
101void
103{
105
106 if (getParam<bool>("create_flux_vpp"))
108
110
111 const std::vector<std::pair<std::string, Real>> var_norm_pairs{
112 {THM::PRESSURE, getParam<Real>("p_ref")},
113 {THM::TEMPERATURE, getParam<Real>("T_ref")},
114 {THM::VELOCITY, getParam<Real>("vel_ref")}};
115 for (const auto & [var, norm] : var_norm_pairs)
116 {
118 THM::functorMaterialPropertyName<false>(var), var + "_change", false);
120 var + "_change", genName(name(), var + "_rel_step"), norm, getSubdomainNames());
121 }
122
123 const std::vector<std::pair<std::string, std::string>> var_eq_pairs{
124 {THM::RHOA, "mass"}, {THM::RHOUA, "momentum"}, {THM::RHOEA, "energy"}};
125 for (const auto & [var, eq] : var_eq_pairs)
127
129 {genName(name(), "p_rel_step"),
130 genName(name(), "T_rel_step"),
131 genName(name(), "vel_rel_step"),
132 genName(name(), "mass_res"),
133 genName(name(), "momentum_res"),
134 genName(name(), "energy_res")},
135 {"step: p", "step: T", "step: vel", "res: mass", "res: momentum", "res: energy"},
136 {getParam<Real>("p_rel_step_tol"),
137 getParam<Real>("T_rel_step_tol"),
138 getParam<Real>("vel_rel_step_tol"),
139 getParam<Real>("mass_res_tol"),
140 getParam<Real>("momentum_res_tol"),
141 getParam<Real>("energy_res_tol")});
142}
143
144void
146{
147 const std::string class_name = "NumericalFlux3EqnInternalValues";
148 InputParameters params = _factory.getValidParams(class_name);
149 params.set<std::vector<SubdomainName>>("block") = getSubdomainNames();
150 params.set<UserObjectName>("numerical_flux") = _numerical_flux_name;
151 params.set<std::vector<VariableName>>("A_linear") = {THM::AREA_LINEAR};
152 params.set<std::string>("sort_by") = sortBy();
153 params.set<ExecFlagEnum>("execute_on") = {EXEC_INITIAL, EXEC_TIMESTEP_END};
154 getTHMProblem().addVectorPostprocessor(class_name, name() + "_flux_vpp", params);
155}
156
157void
159{
160 const std::string class_name = "FlowModel1PhaseFunctorMaterial";
161 const std::string obj_name = genName(name(), "fm1phase_fmat");
162 InputParameters params = _factory.getValidParams(class_name);
163 params.set<std::vector<SubdomainName>>("block") = getSubdomainNames();
164 params.set<UserObjectName>("fluid_properties") = _fp_name;
165 getTHMProblem().addFunctorMaterial(class_name, obj_name, params);
166}
167
168void
170 const std::string & equation)
171{
172 const std::string class_name = "Normalized1PhaseResidualNorm";
173 InputParameters params = _factory.getValidParams(class_name);
174 params.applyParameters(parameters());
175 params.set<VariableName>("variable") = variable;
176 params.set<std::vector<SubdomainName>>("block") = getSubdomainNames();
177 params.set<MooseEnum>("norm_type") = "l_inf";
178 const Point mid_point = 0.5 * (getStartPoint() + getEndPoint());
179 params.set<Point>("point") = mid_point;
180 params.set<UserObjectName>("fluid_properties") = _fp_name;
181 params.set<Real>("min_elem_size") = getMinimumElemSize();
182 params.set<ExecFlagEnum>("execute_on") = EXEC_NONLINEAR_CONVERGENCE;
183 params.set<std::vector<OutputName>>("outputs") = {"none"};
184 getTHMProblem().addPostprocessor(class_name, genName(name(), equation + "_res"), params);
185}
186
registerMooseObject("ThermalHydraulicsApp", FlowChannel1Phase)
const ExecFlagType EXEC_TIMESTEP_END
const ExecFlagType EXEC_INITIAL
const ExecFlagType EXEC_NONLINEAR_CONVERGENCE
const std::string name
Definition Setup.h:21
std::string sortBy() const
virtual const std::vector< SubdomainName > & getSubdomainNames() const
Gets the subdomain names for this component.
Definition Component.C:345
void logError(Args &&... args) const
Logs an error.
Definition Component.h:226
void addMaximumFunctorPostprocessor(const std::string &functor_name, const std::string &pp_name, const Real normalization, const std::vector< SubdomainName > &subdomains)
Adds a Postprocessor to compute the maximum of a functor over some domain.
Definition Component.C:252
THMProblem & getTHMProblem() const
Gets the THM problem.
Definition Component.C:135
Factory & _factory
The Factory associated with the MooseApp.
Definition Component.h:497
std::string nonlinearConvergenceName() const
Nonlinear Convergence name.
Definition Component.h:486
void addNonlinearStepFunctorMaterial(const std::string &functor_name, const std::string &property, bool functor_is_ad)
Adds a functor material to compute the absolute value of the change (step) of some functor between no...
Definition Component.C:236
void addMultiPostprocessorConvergence(const std::vector< PostprocessorName > &postprocessors, const std::vector< std::string > &descriptions, const std::vector< Real > &tolerances)
Adds a MultiPostprocessorConvergence for nonlinear convergence for the component.
Definition Component.C:269
Real getMinimumElemSize() const
Gets the minimum element size.
T & getUserObject(const std::string &name, unsigned int tid=0) const
virtual void addVectorPostprocessor(const std::string &pp_name, const std::string &name, InputParameters &parameters)
virtual Convergence & getConvergence(const std::string &name, const THREAD_ID tid=0) const
virtual void addPostprocessor(const std::string &pp_name, const std::string &name, InputParameters &parameters)
virtual void addFunctorMaterial(const std::string &functor_material_name, const std::string &name, InputParameters &parameters)
InputParameters getValidParams(const std::string &name) const
Base class for single-phase flow channels.
virtual void addMooseObjects() override
const UserObjectName _numerical_flux_name
Numerical flux user object name.
virtual void check() const override
Check the component integrity.
static InputParameters validParams()
Single-component, single-phase flow channel.
virtual void checkFluidProperties() const override
Logs an error if the fluid properties is not valid.
void addNormalized1PhaseResidualNorm(const VariableName &variable, const std::string &equation)
Adds a residual norm Postprocessor.
FlowChannel1Phase(const InputParameters &params)
static InputParameters validParams()
virtual Convergence * getNonlinearConvergence() const override
Gets the Component's nonlinear Convergence object if it has one.
virtual std::string flowModelClassName() const override
Returns the flow model class name.
void addFlowChannel1PhaseFunctorMaterial()
Adds the functor material for the flow channel.
virtual void addMooseObjects() override
virtual void check() const override
Check the component integrity.
virtual std::vector< std::string > ICParameters() const override
Returns the names of the IC parameters.
void addNumericalFluxVectorPostprocessor()
const UserObjectName & _fp_name
Name of fluid properties user object.
void addParamNamesToGroup(const std::string &space_delim_names, const std::string group_name)
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
void addClassDescription(const std::string &doc_string)
T & set(const std::string &name, bool quiet_mode=false)
void applyParameters(const InputParameters &common, const std::vector< std::string > &exclude={}, const bool allow_private=false)
const InputParameters & parameters() const
bool isParamValid(const std::string &name) const
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.
Common class for single phase fluid properties.
static const std::string RHOEA
Definition THMNames.h:30
static const std::string AREA_LINEAR
Definition THMNames.h:15
static const std::string TEMPERATURE
Definition THMNames.h:39
static const std::string VELOCITY
Definition THMNames.h:43
static const std::string RHOUA
Definition THMNames.h:31
static const std::string PRESSURE
Definition THMNames.h:27
static const std::string RHOA
Definition THMNames.h:29