https://mooseframework.inl.gov
Loading...
Searching...
No Matches
PNSInitialCondition.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// Navier-Stokes includes
11#include "NS.h"
12#include "PNSInitialCondition.h"
13
14// FluidProperties includes
16
17// MOOSE includes
18#include "MooseVariable.h"
19
21
24{
27 "PNSInitialCondition sets intial constant values for any porous flow variable.");
28
29 MooseEnum variable_types(
30 MooseUtils::join(std::vector<std::string>{NS::specific_total_enthalpy,
53 " "));
54 params.addParam<MooseEnum>(
55 "variable_type",
56 variable_types,
57 "Specifies what this variable is in the Navier Stokes namespace of variables");
58 params.addRequiredParam<Real>("initial_pressure",
59 "The initial pressure, assumed constant everywhere");
60 params.addRequiredParam<Real>("initial_temperature",
61 "The initial temperature, assumed constant everywhere");
62 params.addParam<RealVectorValue>(
63 "initial_interstitial_velocity",
64 "The initial interstitial velocity, assumed constant everywhere");
65 params.addParam<RealVectorValue>("initial_superficial_velocity",
66 "The initial superficial velocity, assumed constant everywhere");
67 params.addCoupledVar("porosity", "Porosity variable (defaults to porosity material property).");
68 params.addRequiredParam<UserObjectName>("fluid_properties",
69 "The name of the user object for fluid properties");
70
71 return params;
72}
73
75 : InitialCondition(parameters),
76 _variable_type(isParamValid("variable_type") ? getParam<MooseEnum>("variable_type")
77 : MooseEnum(_var.name(), _var.name())),
78 _initial_pressure(getParam<Real>("initial_pressure")),
79 _initial_temperature(getParam<Real>("initial_temperature")),
80 _superficial_velocities_set(isParamValid("initial_superficial_velocity") ? true : false),
81 _eps(isCoupled("porosity") ? coupledValue("porosity")
82 : getMaterialProperty<Real>(NS::porosity).get()),
83 _fp(getUserObject<IdealGasFluidProperties>("fluid_properties"))
84{
85 if (isParamValid("initial_superficial_velocity"))
86 _initial_superficial_velocity = getParam<RealVectorValue>("initial_superficial_velocity");
87 if (isParamValid("initial_interstitial_velocity"))
88 _initial_interstitial_velocity = getParam<RealVectorValue>("initial_interstitial_velocity");
89 if (isParamValid("initial_superficial_velocity") && isParamValid("initial_interstitial_velocity"))
90 paramError("Either superficial or interstitial velocities may be specified.");
91}
92
93Real
94PNSInitialCondition::value(const Point & /*p*/)
95{
96 // Compute velocities
99 else
101
102 const Real rho_initial = _fp.rho_from_p_T(_initial_pressure, _initial_temperature);
103
104 // TODO: The internal energy could be computed by the IdealGasFluidProperties.
105 const Real e_initial = _fp.cv() * _initial_temperature;
106 const Real et_initial = e_initial + 0.5 * _initial_interstitial_velocity.norm_sq();
107 const Real v_initial = 1. / rho_initial;
108
110 return et_initial + _initial_pressure / rho_initial;
111
113 return (et_initial + _initial_pressure / rho_initial) * _eps[_qp];
114
116 return e_initial;
117
119 return _initial_superficial_velocity.norm() / _fp.c_from_v_e(v_initial, e_initial);
120
122 return _initial_pressure;
123
125 return rho_initial;
126
128 return rho_initial * _eps[_qp];
129
131 return rho_initial * _initial_superficial_velocity(0);
132
134 return rho_initial * _initial_superficial_velocity(1);
135
137 return rho_initial * _initial_superficial_velocity(2);
138
140 return rho_initial * _initial_interstitial_velocity(0);
141
143 return rho_initial * _initial_interstitial_velocity(1);
144
146 return rho_initial * _initial_interstitial_velocity(2);
147
149 return rho_initial * et_initial;
150
152 return rho_initial * et_initial * _eps[_qp];
153
155 return v_initial;
156
159
162
165
168
171
174
177
178 // If we got here, then the variable name was not one of the ones we know about.
179 mooseError("Unrecognized variable: ", _variable_type);
180 return 0.;
181}
registerMooseObject("NavierStokesApp", PNSInitialCondition)
const std::string name
Definition Setup.h:21
Ideal gas fluid properties Default parameters are for air at atmospheric pressure and temperature.
virtual Real c_from_v_e(Real v, Real e) const override
virtual Real rho_from_p_T(Real p, Real T) const override
static InputParameters validParams()
void addRequiredParam(const std::string &name, const std::string &doc_string)
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)
void addCoupledVar(const std::string &name, const std::string &doc_string)
void paramError(const std::string &param, Args... args) const
void mooseError(Args &&... args) const
bool isParamValid(const std::string &name) const
PNSInitialCondition sets intial constant values for all variables given the: .) Initial pressure ....
const IdealGasFluidProperties & _fp
Fluid properties.
const VariableValue & _eps
The porosity variable.
static InputParameters validParams()
RealVectorValue _initial_superficial_velocity
Initial constant value of the superficial velocity.
virtual Real value(const Point &p)
The value of the variable at a point.
RealVectorValue _initial_interstitial_velocity
Initial constant value of the interstitial velocity.
const Real _initial_pressure
Initial constant value of the pressure.
const bool _superficial_velocities_set
Whether initial velocities were specified as superficial or interstitial.
const Real _initial_temperature
Initial constant value of the fluid temperature.
PNSInitialCondition(const InputParameters &parameters)
const std::string _variable_type
Used to map the variable to one of the expected types.
static const std::string superficial_momentum_z
Definition NS.h:42
static const std::string specific_volume
Definition NS.h:82
static const std::string superficial_velocity_y
Definition NS.h:52
static const std::string superficial_momentum_y
Definition NS.h:41
static const std::string density
Definition NS.h:34
static const std::string velocity_y
Definition NS.h:48
static const std::string superficial_total_enthalpy_density
Definition NS.h:73
static const std::string temperature
Definition NS.h:60
static const std::string superficial_velocity_z
Definition NS.h:53
static const std::string total_energy_density
Definition NS.h:66
static const std::string momentum_x
Definition NS.h:36
static const std::string superficial_density
Definition NS.h:35
static const std::string velocity_z
Definition NS.h:49
static const std::string momentum_y
Definition NS.h:37
static const std::string superficial_total_energy_density
Definition NS.h:67
static const std::string mach_number
Definition NS.h:81
static const std::string superficial_velocity_x
Definition NS.h:51
static const std::string specific_total_enthalpy
Definition NS.h:70
static const std::string superficial_momentum_x
Definition NS.h:40
static const std::string velocity_x
Definition NS.h:47
static const std::string specific_internal_energy
Definition NS.h:63
static const std::string pressure
Definition NS.h:57
static const std::string momentum_z
Definition NS.h:38