https://mooseframework.inl.gov
Loading...
Searching...
No Matches
NSFunctionInitialCondition.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"
13
14// FluidProperties includes
16
17// MOOSE includes
18#include "MooseVariable.h"
19
21
24{
26 params.addClassDescription("Sets intial 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<FunctionName>("initial_pressure", "The initial pressure");
51 params.addRequiredParam<FunctionName>("initial_temperature", "The initial temperature");
52 params.addRequiredParam<std::vector<FunctionName>>("initial_velocity", "The initial velocity");
53 params.addRequiredParam<UserObjectName>("fluid_properties",
54 "The name of the user object for fluid properties");
55
56 return params;
57}
58
60 : InitialCondition(parameters),
61 _variable_type(isParamValid("variable_type") ? getParam<MooseEnum>("variable_type")
62 : MooseEnum(_var.name(), _var.name())),
63 _initial_pressure(getFunction("initial_pressure")),
64 _initial_temperature(getFunction("initial_temperature")),
65 _fp(getUserObject<IdealGasFluidProperties>("fluid_properties")),
66 _pressure_variable_name(getParam<std::string>("pressure_variable_name"))
67{
68 for (const auto i : make_range(Moose::dim))
69 _initial_velocity.push_back(
70 &getFunctionByName(getParam<std::vector<FunctionName>>("initial_velocity")[i]));
71}
72
73Real
75{
76 const Real initial_pressure = _initial_pressure.value(_t, p);
77 const Real initial_temperature = _initial_temperature.value(_t, p);
78 const RealVectorValue initial_velocity = {_initial_velocity[0]->value(_t, p),
79 _initial_velocity[1]->value(_t, p),
80 _initial_velocity[2]->value(_t, p)};
81
82 const Real rho_initial = _fp.rho_from_p_T(initial_pressure, initial_temperature);
83
84 // TODO: The internal energy could be computed by the IdealGasFluidProperties.
85 const Real e_initial = _fp.cv() * initial_temperature;
86 const Real et_initial = e_initial + 0.5 * initial_velocity.norm_sq();
87 const Real v_initial = 1. / rho_initial;
88
90 return et_initial + initial_pressure / rho_initial;
91
93 return e_initial;
94
96 return initial_velocity.norm() / _fp.c_from_v_e(v_initial, e_initial);
97
99 return initial_pressure;
100
102 return rho_initial;
103
105 return rho_initial * initial_velocity(0);
106
108 return rho_initial * initial_velocity(1);
109
111 return rho_initial * initial_velocity(2);
112
114 return rho_initial * et_initial;
115
117 return v_initial;
118
120 return initial_temperature;
121
123 return initial_velocity(0);
124
126 return initial_velocity(1);
127
129 return initial_velocity(2);
130
131 // If we got here, then the variable name was not one of the ones we know about.
132 mooseError("Unrecognized variable: ", _variable_type);
133 return 0.;
134}
const Real p
registerMooseObject("NavierStokesApp", NSFunctionInitialCondition)
const std::string name
Definition Setup.h:21
const Function & getFunctionByName(const FunctionName &name) const
virtual Real value(Real t, const Point &p) const
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 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)
void addClassDescription(const std::string &doc_string)
void mooseError(Args &&... args) const
const T & getParam(const std::string &name) const
NSFunctionInitialCondition sets intial constant values for all variables given the: ....
static InputParameters validParams()
const Function & _initial_temperature
Initial constant value of the fluid temperature.
const Function & _initial_pressure
Initial constant value of the pressure.
std::vector< const Function * > _initial_velocity
Initial constant value of the velocity.
virtual Real value(const Point &p)
The value of the variable at a point.
NSFunctionInitialCondition(const InputParameters &parameters)
const std::string _pressure_variable_name
pressure variable name
const IdealGasFluidProperties & _fp
Fluid properties.
const std::string _variable_type
Used to map the variable to one of the expected types.
static constexpr std::size_t dim
static const std::string specific_volume
Definition NS.h:82
static const std::string density
Definition NS.h:34
static const std::string velocity_y
Definition NS.h:48
static const std::string temperature
Definition NS.h:60
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 velocity_z
Definition NS.h:49
static const std::string momentum_y
Definition NS.h:37
static const std::string mach_number
Definition NS.h:81
static const std::string specific_total_enthalpy
Definition NS.h:70
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