20#include "libmesh/fe.h"
21#include "libmesh/vector_value.h"
22#include "libmesh/string_to_enum.h"
33 params.
addClassDescription(
"This class allows us to have a section of the input file like the "
34 "following which automatically adds Kernels and AuxKernels for all "
35 "the required nonlinear and auxiliary variables.");
40 params.
addParam<std::vector<SubdomainName>>(
41 "block", {},
"The list of block ids (SubdomainID) on which NS equation is defined on");
44 "The name of the user object for fluid properties");
46 params.
addParam<std::vector<BoundaryName>>(
47 "stagnation_boundary", std::vector<BoundaryName>(),
"Stagnation boundaries");
49 "stagnation_pressure", std::vector<Real>(),
"Pressure on stagnation boundaries");
51 "stagnation_temperature", std::vector<Real>(),
"Temperature on stagnation boundaries");
53 "stagnation_flow_direction", std::vector<Real>(),
"Flow directions on stagnation boundaries");
54 params.
addParam<std::vector<BoundaryName>>(
55 "no_penetration_boundary", std::vector<BoundaryName>(),
"No-penetration boundaries");
56 params.
addParam<std::vector<BoundaryName>>(
57 "static_pressure_boundary", std::vector<BoundaryName>(),
"Static pressure boundaries");
59 "static_pressure", std::vector<Real>(),
"Static pressure on boundaries");
64 "family", families,
"Specifies the family of FE shape functions to use for this variable");
67 "Specifies the order of the FE shape function to use "
68 "for this variable (additional orders not listed are "
70 params.
addParam<Real>(
"density_scaling", 1,
"Scaling for the density variable");
72 "momentum_scaling", RealVectorValue(1, 1, 1),
"Scaling for the momentum variables");
73 params.
addParam<Real>(
"total_energy_density_scaling", 1,
"Scaling for the total-energy variable");
76 "The initial pressure, assumed constant everywhere");
78 "The initial temperature, assumed constant everywhere");
80 "The initial velocity, assumed constant everywhere");
84 "stagnation_boundary stagnation_pressure stagnation_temperature "
85 "stagnation_flow_direction no_penetration_boundary static_pressure_boundary static_pressure",
88 "family order density_scaling momentum_scaling total_energy_density_scaling",
"Variable");
89 params.
addParam<std::string>(
"pressure_variable_name",
90 "A name for the pressure variable. If this is not provided, a "
91 "sensible default will be used.");
97 _type(getParam<
MooseEnum>(
"equation_type")),
98 _fp_name(getParam<UserObjectName>(
"fluid_properties")),
99 _blocks(getParam<
std::vector<SubdomainName>>(
"block")),
100 _stagnation_boundary(getParam<
std::vector<BoundaryName>>(
"stagnation_boundary")),
101 _stagnation_pressure(getParam<
std::vector<Real>>(
"stagnation_pressure")),
102 _stagnation_temperature(getParam<
std::vector<Real>>(
"stagnation_temperature")),
103 _stagnation_direction(getParam<
std::vector<Real>>(
"stagnation_flow_direction")),
104 _no_penetration_boundary(getParam<
std::vector<BoundaryName>>(
"no_penetration_boundary")),
105 _static_pressure_boundary(getParam<
std::vector<BoundaryName>>(
"static_pressure_boundary")),
106 _static_pressure(getParam<
std::vector<Real>>(
"static_pressure")),
107 _fe_type(Utility::string_to_enum<Order>(getParam<
MooseEnum>(
"order")),
108 Utility::string_to_enum<FEFamily>(getParam<
MooseEnum>(
"family"))),
109 _initial_pressure(getParam<Real>(
"initial_pressure")),
110 _initial_temperature(getParam<Real>(
"initial_temperature")),
111 _initial_velocity(getParam<RealVectorValue>(
"initial_velocity")),
112 _pressure_variable_name(isParamValid(
"pressure_variable_name")
113 ? getParam<
std::string>(
"pressure_variable_name")
118 "Size is not the same as the number of boundaries in 'stagnation_boundary'");
121 "Size is not the same as the number of boundaries in 'stagnation_boundary'");
124 "Size is not the same as the number of boundaries in 'static_pressure_boundary'");
133 for (
const auto & subdomain_name :
_blocks)
140 "Size is not the same as the number of boundaries in 'stagnation_boundary' times "
141 "the mesh dimension");
151 base_params.set<std::vector<SubdomainName>>(
"block").push_back(
Moose::stringify(
id));
155 params.
set<std::vector<Real>>(
"scaling") = {getParam<Real>(
"density_scaling")};
158 auto mscaling = getParam<RealVectorValue>(
"momentum_scaling");
159 params.
set<std::vector<Real>>(
"scaling") = {mscaling(0)};
163 params.
set<std::vector<Real>>(
"scaling") = {mscaling(1)};
168 params.
set<std::vector<Real>>(
"scaling") = {mscaling(2)};
171 params.
set<std::vector<Real>>(
"scaling") = {getParam<Real>(
"total_energy_density_scaling")};
194 if (
_type ==
"transient")
200 for (
unsigned int component = 0; component <
_dim; ++component)
206 for (
unsigned int component = 0; component <
_dim; ++component)
216 for (
unsigned int component = 0; component <
_dim; ++component)
226 for (
unsigned int component = 0; component <
_dim; ++component)
232 for (
unsigned int component = 0; component <
_dim; ++component)
240 for (
unsigned int component = 0; component <
_dim; ++component)
248 std::vector<VariableName>
vars;
259 params.
set<VariableName>(
"variable") =
name;
263 params.
set<UserObjectName>(
"fluid_properties") =
_fp_name;
264 _problem->addInitialCondition(
"NSInitialCondition",
name + std::string(
"_ic"), params);
268 std::vector<VariableName> auxs;
283 for (
const auto &
name : auxs)
286 params.
set<VariableName>(
"variable") =
name;
290 params.
set<UserObjectName>(
"fluid_properties") =
_fp_name;
293 _problem->addInitialCondition(
"NSInitialCondition",
name + std::string(
"_ic"), params);
301 const std::string kernel_type =
"TimeDerivative";
303 params.
set<std::vector<SubdomainName>>(
"block") =
_blocks;
328 const std::string kernel_type =
"NSSUPGMass";
337 _problem->addKernel(kernel_type,
"rho_supg", params);
345 const std::string kernel_type =
"NSSUPGMomentum";
347 params.
set<NonlinearVariableName>(
"variable") = momentums[component];
355 params.
set<
unsigned int>(
"component") = component;
357 _problem->addKernel(kernel_type, momentums[component] + std::string(
"_supg"), params);
363 const std::string kernel_type =
"NSSUPGEnergy";
372 _problem->addKernel(kernel_type,
"rhoE_supg", params);
378 const std::string kernel_type =
"ParsedAux";
388 params.
set<std::string>(
"expression") = function;
390 _problem->addAuxKernel(kernel_type,
"specific_volume_auxkernel", params);
396 const std::string kernel_type =
"NSInternalEnergyAux";
408 _problem->addAuxKernel(kernel_type,
"specific_internal_energy_auxkernel", params);
414 const std::string kernel_type =
"NSMachAux";
426 params.
set<UserObjectName>(
"fluid_properties") =
_fp_name;
428 _problem->addAuxKernel(kernel_type,
"mach_auxkernel", params);
434 const std::string kernel_type =
"NSSpecificTotalEnthalpyAux";
444 _problem->addAuxKernel(kernel_type,
"specific_total_enthalpy_auxkernel", params);
450 const std::string kernel_type =
"NSVelocityAux";
455 params.
set<AuxVariableName>(
"variable") = velocities[component];
460 params.
set<UserObjectName>(
"fluid_properties") =
_fp_name;
462 _problem->addAuxKernel(kernel_type, velocities[component] +
"_auxkernel", params);
470 params.
set<AuxVariableName>(
"variable") = var_name;
477 _problem->addAuxKernel(kernel_type, var_name +
"_auxkernel", params);
483 const std::string kernel_type =
"NSMassInviscidFlux";
487 _problem->addKernel(kernel_type,
"rho_if", params);
494 const std::string kernel_type =
"NSMomentumInviscidFlux";
496 params.
set<NonlinearVariableName>(
"variable") = momentums[component];
501 params.
set<
unsigned int>(
"component") = component;
504 _problem->addKernel(kernel_type, momentums[component] + std::string(
"if"), params);
510 const std::string kernel_type =
"NSEnergyInviscidFlux";
519 _problem->addKernel(kernel_type,
"rhoE_if", params);
525 const std::string kernel_type =
"NSMassWeakStagnationBC";
541 const std::string kernel_type =
"NSEnergyWeakStagnationBC";
549 kernel_type,
"weak_stagnation_energy_inflow_" +
Moose::stringify(i), params);
560 const std::string kernel_type =
"NSMomentumConvectiveWeakStagnationBC";
562 params.
set<NonlinearVariableName>(
"variable") = momentums[component];
565 params.
set<
unsigned int>(
"component") = component;
569 _problem->addBoundaryCondition(kernel_type,
570 std::string(
"weak_stagnation_") + momentums[component] +
578 const std::string kernel_type =
"NSMomentumPressureWeakStagnationBC";
580 params.
set<NonlinearVariableName>(
"variable") = momentums[component];
583 params.
set<
unsigned int>(
"component") = component;
589 _problem->addBoundaryCondition(kernel_type,
590 std::string(
"weak_stagnation_") + momentums[component] +
601 const std::string kernel_type =
"NSPressureNeumannBC";
603 params.
set<NonlinearVariableName>(
"variable") = momentums[component];
607 params.
set<
unsigned int>(
"component") = component;
612 kernel_type, momentums[component] + std::string(
"_no_penetration"), params);
618 const std::string kernel_type =
"NSMassUnspecifiedNormalFlowBC";
634 const std::string kernel_type =
"NSMomentumInviscidSpecifiedPressureBC";
636 params.
set<NonlinearVariableName>(
"variable") = momentums[component];
640 params.
set<
unsigned int>(
"component") = component;
648 momentums[component] + std::string(
"_specified_pressure_outflow_") +
Moose::stringify(i),
656 const std::string kernel_type =
"NSEnergyInviscidSpecifiedPressureBC";
667 kernel_type,
"rhoE_specified_pressure_outflow_" +
Moose::stringify(i), params);
674 params.
set<std::vector<SubdomainName>>(
"block") =
_blocks;
685 params.
set<UserObjectName>(
"fluid_properties") =
_fp_name;
700 params.
set<UserObjectName>(
"fluid_properties") =
_fp_name;
711 params.
set<Real>(
"sy") = 0;
subdomain_id_type SubdomainID
registerMooseAction("NavierStokesApp", CNSAction, "add_navier_stokes_variables")
std::vector< VariableName > CoupledName
std::shared_ptr< MooseMesh > & _mesh
static InputParameters validParams()
std::shared_ptr< FEProblemBase > & _problem
const std::string & _current_task
static MooseEnum getNonlinearVariableFamilies()
static MooseEnum getNonlinearVariableOrders()
static std::string variableType(const libMesh::FEType &fe_type, const bool is_fv=false, const bool is_array=false)
This class allows us to have a section of the input file like the following which automatically adds ...
const std::string _pressure_variable_name
pressure variable name
void addNSMomentumInviscidSpecifiedPressureBC(unsigned int component)
void addNSMomentumInviscidFlux(unsigned int component)
void addNSMomentumWeakStagnationBC(unsigned int component)
void addSpecificTotalEnthalpyAux()
virtual void act() override
UserObjectName _fp_name
Name of the FluidProperties object to pass on to Kernels.
void addNSMassUnspecifiedNormalFlowBC()
unsigned int _dim
Mesh dimension.
std::vector< Real > _stagnation_temperature
Temperatures on stagnation boundaries.
void addNSEnergyInviscidSpecifiedPressureBC()
void addNSInternalEnergyAux()
void addNSSUPGMomentum(unsigned int component)
std::vector< BoundaryName > _stagnation_boundary
Boundaries stagnation BC applies.
void addNSVelocityAux(unsigned int component)
void addNSMassWeakStagnationBC()
std::vector< BoundaryName > _static_pressure_boundary
Boundaries static pressure BC applies.
std::vector< SubdomainName > _blocks
Subdomains Navier-Stokes equation is defined on.
void setBCCommonParams(InputParameters ¶ms)
void setStagnationBCCommonParams(InputParameters ¶ms, unsigned int i)
void setKernelCommonParams(InputParameters ¶ms)
void addNoPenetrationBC(unsigned int component)
static InputParameters validParams()
CNSAction(const InputParameters ¶meters)
void addNSEnergyInviscidFlux()
void coupleVelocities(InputParameters ¶ms)
MooseEnum _type
Equation type, transient or steady-state.
libMesh::FEType _fe_type
FE type for various variables.
RealVectorValue _initial_velocity
Initial value for velocity.
void addNSMassInviscidFlux()
std::set< SubdomainID > _block_ids
Subdomain IDs.
void coupleMomentums(InputParameters ¶ms)
std::vector< BoundaryName > _no_penetration_boundary
Boundaries no-penetration BC applies.
Real _initial_pressure
Initial value for pressure.
std::vector< Real > _stagnation_direction
Flow directions on stagnation boundaries.
void addNSEnergyWeakStagnationBC()
void addSpecificVolumeComputation()
void addPressureOrTemperatureAux(const std::string &kernel_type)
Real _initial_temperature
Initial value for temperature.
std::vector< Real > _stagnation_pressure
Pressures on stagnation boundaries.
std::vector< Real > _static_pressure
Pressures on static pressure boundaries.
InputParameters getValidParams(const std::string &name) const
const std::string & type() const
const std::string & name() const
void paramError(const std::string ¶m, Args... args) const
std::string stringify(const T &t)
static const std::string specific_volume
static const std::string density
static const std::string velocity_y
static const std::string temperature
static const std::string total_energy_density
static const std::string momentum_x
static const std::string velocity_z
static const std::string momentum_y
static const std::string mach_number
static const std::string specific_total_enthalpy
static const std::string velocity_x
static const std::string specific_internal_energy
static const std::string pressure
static const std::string momentum_z