www.mooseframework.org
NSInitialCondition.C
Go to the documentation of this file.
1 /****************************************************************/
2 /* MOOSE - Multiphysics Object Oriented Simulation Environment */
3 /* */
4 /* All contents are licensed under LGPL V2.1 */
5 /* See LICENSE for full restrictions */
6 /****************************************************************/
7 
8 // Navier-Stokes includes
9 #include "NS.h"
10 #include "NSInitialCondition.h"
11 
12 // FluidProperties includes
14 
15 // MOOSE includes
16 #include "MooseVariable.h"
17 
18 template <>
19 InputParameters
21 {
22  InputParameters params = validParams<InitialCondition>();
23  params.addClassDescription("NSInitialCondition sets intial constant values for all variables.");
24  params.addRequiredParam<Real>("initial_pressure",
25  "The initial pressure, assumed constant everywhere");
26  params.addRequiredParam<Real>("initial_temperature",
27  "The initial temperature, assumed constant everywhere");
28  params.addRequiredParam<RealVectorValue>("initial_velocity",
29  "The initial velocity, assumed constant everywhere");
30  params.addRequiredParam<UserObjectName>("fluid_properties",
31  "The name of the user object for fluid properties");
32 
33  return params;
34 }
35 
36 NSInitialCondition::NSInitialCondition(const InputParameters & parameters)
37  : InitialCondition(parameters),
38  _initial_pressure(getParam<Real>("initial_pressure")),
39  _initial_temperature(getParam<Real>("initial_temperature")),
40  _initial_velocity(getParam<RealVectorValue>("initial_velocity")),
41  _fp(getUserObject<IdealGasFluidProperties>("fluid_properties"))
42 {
43 }
44 
45 Real
46 NSInitialCondition::value(const Point & /*p*/)
47 {
48  const Real rho_initial = _fp.rho(_initial_pressure, _initial_temperature);
49 
50  // TODO: The internal energy could be computed by the IdealGasFluidProperties.
51  const Real e_initial = _fp.cv() * _initial_temperature;
52  const Real E_initial = e_initial + 0.5 * _initial_velocity.norm_sq();
53  const Real v_initial = 1. / rho_initial;
54 
55  if (_var.name() == NS::enthalpy)
56  return E_initial + _initial_pressure / rho_initial;
57 
58  if (_var.name() == NS::internal_energy)
59  return e_initial;
60 
61  if (_var.name() == NS::mach_number)
62  return _initial_velocity.norm() / _fp.c(v_initial, e_initial);
63 
64  if (_var.name() == NS::pressure)
65  return _initial_pressure;
66 
67  if (_var.name() == NS::density)
68  return rho_initial;
69 
70  if (_var.name() == NS::momentum_x)
71  return rho_initial * _initial_velocity(0);
72 
73  if (_var.name() == NS::momentum_y)
74  return rho_initial * _initial_velocity(1);
75 
76  if (_var.name() == NS::momentum_z)
77  return rho_initial * _initial_velocity(2);
78 
79  if (_var.name() == NS::total_energy)
80  return rho_initial * E_initial;
81 
82  if (_var.name() == NS::specific_volume)
83  return v_initial;
84 
85  if (_var.name() == NS::temperature)
86  return _initial_temperature;
87 
88  if (_var.name() == NS::velocity_x)
89  return _initial_velocity(0);
90 
91  if (_var.name() == NS::velocity_y)
92  return _initial_velocity(1);
93 
94  if (_var.name() == NS::velocity_z)
95  return _initial_velocity(2);
96 
97  // If we got here, then the variable name was not one of the ones we know about.
98  mooseError("Unrecognized variable: ", _var.name());
99  return 0.;
100 }
const std::string momentum_x
Definition: NS.h:16
const std::string mach_number
Definition: NS.h:27
virtual Real rho(Real pressure, Real temperature) const override
Computes density from pressure and temperature.
const std::string velocity_z
Definition: NS.h:23
const std::string density
Definition: NS.h:15
const std::string velocity_x
Definition: NS.h:21
const std::string temperature
Definition: NS.h:25
InputParameters validParams< NSInitialCondition >()
const std::string enthalpy
Definition: NS.h:26
virtual Real cv(Real v=0., Real u=0.) const override
Isochoric specific heat.
const IdealGasFluidProperties & _fp
NSInitialCondition(const InputParameters &parameters)
virtual Real value(const Point &p)
The value of the variable at a point.
RealVectorValue _initial_velocity
const std::string specific_volume
Definition: NS.h:29
virtual Real c(Real v, Real u) const override
Sound speed.
const std::string velocity_y
Definition: NS.h:22
const std::string momentum_y
Definition: NS.h:17
const std::string pressure
Definition: NS.h:24
const std::string total_energy
Definition: NS.h:19
const std::string internal_energy
Definition: NS.h:28
const std::string momentum_z
Definition: NS.h:18
Ideal gas fluid properties.