www.mooseframework.org
NSInitialCondition.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
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 "NSInitialCondition.h"
13 
14 // FluidProperties includes
16 
17 // MOOSE includes
18 #include "MooseVariable.h"
19 
20 registerMooseObject("NavierStokesApp", NSInitialCondition);
21 
24 {
26  params.addClassDescription("NSInitialCondition sets intial constant values for all variables.");
27  params.addDeprecatedParam<std::string>("pressure_variable_name",
29  "The name of the pressure variable",
30  "pressure_variable_name is deprecated, use variable_type");
31  MooseEnum variable_types(MooseUtils::join(std::vector<std::string>{NS::specific_total_enthalpy,
45  " "));
46  params.addParam<MooseEnum>(
47  "variable_type",
48  variable_types,
49  "Specifies what this variable is in the Navier Stokes namespace of variables");
50  params.addRequiredParam<Real>("initial_pressure",
51  "The initial pressure, assumed constant everywhere");
52  params.addRequiredParam<Real>("initial_temperature",
53  "The initial temperature, assumed constant everywhere");
54  params.addRequiredParam<RealVectorValue>("initial_velocity",
55  "The initial velocity, assumed constant everywhere");
56  params.addRequiredParam<UserObjectName>("fluid_properties",
57  "The name of the user object for fluid properties");
58 
59  return params;
60 }
61 
63  : InitialCondition(parameters),
64  _variable_type(isParamValid("variable_type") ? getParam<MooseEnum>("variable_type")
65  : MooseEnum(_var.name(), _var.name())),
66  _initial_pressure(getParam<Real>("initial_pressure")),
67  _initial_temperature(getParam<Real>("initial_temperature")),
68  _initial_velocity(getParam<RealVectorValue>("initial_velocity")),
69  _fp(getUserObject<IdealGasFluidProperties>("fluid_properties")),
70  _pressure_variable_name(getParam<std::string>("pressure_variable_name"))
71 {
72 }
73 
74 Real
75 NSInitialCondition::value(const Point & /*p*/)
76 {
78 
79  // TODO: The internal energy could be computed by the IdealGasFluidProperties.
80  const Real e_initial = _fp.cv() * _initial_temperature;
81  const Real et_initial = e_initial + 0.5 * _initial_velocity.norm_sq();
82  const Real v_initial = 1. / rho_initial;
83 
85  return et_initial + _initial_pressure / rho_initial;
86 
88  return e_initial;
89 
91  return _initial_velocity.norm() / _fp.c_from_v_e(v_initial, e_initial);
92 
94  return _initial_pressure;
95 
97  return rho_initial;
98 
100  return rho_initial * _initial_velocity(0);
101 
103  return rho_initial * _initial_velocity(1);
104 
106  return rho_initial * _initial_velocity(2);
107 
109  return rho_initial * et_initial;
110 
112  return v_initial;
113 
115  return _initial_temperature;
116 
118  return _initial_velocity(0);
119 
121  return _initial_velocity(1);
122 
124  return _initial_velocity(2);
125 
126  // If we got here, then the variable name was not one of the ones we know about.
127  mooseError("Unrecognized variable: ", _variable_type);
128  return 0.;
129 }
static const std::string total_energy_density
Definition: NS.h:63
static const std::string momentum_x
Definition: NS.h:35
const Real _initial_temperature
Initial constant value of the fluid temperature.
static InputParameters validParams()
auto norm() const -> decltype(std::norm(Real()))
void addDeprecatedParam(const std::string &name, const T &value, const std::string &doc_string, const std::string &deprecation_message)
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:78
static const std::string velocity_z
Definition: NS.h:48
NSInitialCondition sets intial constant values for all variables given the: .) Initial pressure ...
static const std::string density
Definition: NS.h:33
static InputParameters validParams()
static const std::string velocity_x
Definition: NS.h:46
static const std::string temperature
Definition: NS.h:57
static const std::string specific_internal_energy
Definition: NS.h:60
const std::string _pressure_variable_name
pressure variable name
void addRequiredParam(const std::string &name, const std::string &doc_string)
const IdealGasFluidProperties & _fp
Fluid properties.
auto norm_sq() const -> decltype(std::norm(Real()))
NSInitialCondition(const InputParameters &parameters)
const std::string _variable_type
Used to map the variable to one of the expected types.
virtual Real value(const Point &p)
The value of the variable at a point.
const std::string name
Definition: Setup.h:20
static const std::string specific_volume
Definition: NS.h:79
const RealVectorValue _initial_velocity
Initial constant value of the velocity.
static const std::string velocity_y
Definition: NS.h:47
const Real _initial_pressure
Initial constant value of the pressure.
static const std::string momentum_y
Definition: NS.h:36
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
static const std::string specific_total_enthalpy
Definition: NS.h:67
registerMooseObject("NavierStokesApp", NSInitialCondition)
static const std::string pressure
Definition: NS.h:56
void mooseError(Args &&... args) const
virtual Real c_from_v_e(Real v, Real e) const override
void addClassDescription(const std::string &doc_string)
static const std::string momentum_z
Definition: NS.h:37
Ideal gas fluid properties Default parameters are for air at atmospheric pressure and temperature...
std::string join(const T &strings, const std::string &delimiter)