https://mooseframework.inl.gov
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 
20 registerMooseObject("NavierStokesApp", PNSInitialCondition);
21 
24 {
26  params.addClassDescription(
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 
93 Real
94 PNSInitialCondition::value(const Point & /*p*/)
95 {
96  // Compute velocities
99  else
101 
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 
158  return _initial_temperature;
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 }
static const std::string superficial_density
Definition: NS.h:34
static const std::string total_energy_density
Definition: NS.h:65
static const std::string momentum_x
Definition: NS.h:35
std::string join(Iterator begin, Iterator end, const std::string &delimiter)
auto norm() const -> decltype(std::norm(Real()))
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
virtual Real rho_from_p_T(Real p, Real T) const override
static const std::string mach_number
Definition: NS.h:80
static const std::string superficial_momentum_y
Definition: NS.h:40
static const std::string velocity_z
Definition: NS.h:48
static const std::string superficial_momentum_x
Definition: NS.h:39
const IdealGasFluidProperties & _fp
Fluid properties.
static const std::string density
Definition: NS.h:33
static const std::string superficial_momentum_z
Definition: NS.h:41
static InputParameters validParams()
static const std::string velocity_x
Definition: NS.h:46
static const std::string temperature
Definition: NS.h:59
const bool _superficial_velocities_set
Whether initial velocities were specified as superficial or interstitial.
const std::string _variable_type
Used to map the variable to one of the expected types.
static const std::string specific_internal_energy
Definition: NS.h:62
const Real _initial_pressure
Initial constant value of the pressure.
void addRequiredParam(const std::string &name, const std::string &doc_string)
RealVectorValue _initial_superficial_velocity
Initial constant value of the superficial velocity.
bool isParamValid(const std::string &name) const
static const std::string porosity
Definition: NS.h:104
RealVectorValue _initial_interstitial_velocity
Initial constant value of the interstitial velocity.
auto norm_sq() const -> decltype(std::norm(Real()))
static const std::string superficial_velocity_y
Definition: NS.h:51
const std::string name
Definition: Setup.h:20
static const std::string specific_volume
Definition: NS.h:81
static const std::string velocity_y
Definition: NS.h:47
void paramError(const std::string &param, Args... args) const
registerMooseObject("NavierStokesApp", PNSInitialCondition)
static const std::string superficial_total_enthalpy_density
Definition: NS.h:72
const Real _initial_temperature
Initial constant value of the fluid temperature.
void addCoupledVar(const std::string &name, const std::string &doc_string)
const VariableValue & _eps
The porosity variable.
static const std::string momentum_y
Definition: NS.h:36
static InputParameters validParams()
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
static const std::string specific_total_enthalpy
Definition: NS.h:69
static const std::string pressure
Definition: NS.h:56
void mooseError(Args &&... args) const
static const std::string superficial_total_energy_density
Definition: NS.h:66
virtual Real c_from_v_e(Real v, Real e) const override
void addClassDescription(const std::string &doc_string)
virtual Real value(const Point &p)
The value of the variable at a point.
static const std::string momentum_z
Definition: NS.h:37
Ideal gas fluid properties Default parameters are for air at atmospheric pressure and temperature...
PNSInitialCondition sets intial constant values for all variables given the: .) Initial pressure ...
PNSInitialCondition(const InputParameters &parameters)
static const std::string superficial_velocity_z
Definition: NS.h:52
const Elem & get(const ElemType type_in)
static const std::string superficial_velocity_x
Definition: NS.h:50