www.mooseframework.org
Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | List of all members
AddNavierStokesKernelsAction Class Reference

This class allows us to have a section of the input file like the following which automatically adds Kernels and AuxKernels for all the required nonlinear and auxiliary variables. More...

#include <AddNavierStokesKernelsAction.h>

Inheritance diagram for AddNavierStokesKernelsAction:
[legend]

Public Member Functions

 AddNavierStokesKernelsAction (InputParameters parameters)
 
virtual ~AddNavierStokesKernelsAction ()
 
virtual void act ()
 

Protected Types

typedef std::vector< VariableName > CoupledName
 

Protected Member Functions

void setCommonParams (InputParameters &params)
 
void coupleVelocities (InputParameters &params)
 
void coupleMomentums (InputParameters &params)
 
void addNSMassInviscidFlux ()
 
void addNSMomentumInviscidFlux (unsigned int component)
 
void addNSEnergyInviscidFlux ()
 
void addNSSUPGMass ()
 
void addNSSUPGMomentum (unsigned int component)
 
void addNSSUPGEnergy ()
 
void addPressureOrTemperatureAux (const std::string &kernel_type)
 
void addNSVelocityAux (unsigned int component)
 
void addNSEnthalpyAux ()
 
void addNSMachAux ()
 
void addNSInternalEnergyAux ()
 
void addSpecificVolumeComputation ()
 

Protected Attributes

UserObjectName _fp_name
 
std::vector< std::string > _vars
 
std::vector< std::string > _auxs
 
unsigned int _dim
 

Detailed Description

This class allows us to have a section of the input file like the following which automatically adds Kernels and AuxKernels for all the required nonlinear and auxiliary variables.

[NavierStokes] [./Kernels] [../] []

Definition at line 30 of file AddNavierStokesKernelsAction.h.

Member Typedef Documentation

◆ CoupledName

typedef std::vector<VariableName> NSAction::CoupledName
protectedinherited

Definition at line 43 of file NSAction.h.

Constructor & Destructor Documentation

◆ AddNavierStokesKernelsAction()

AddNavierStokesKernelsAction::AddNavierStokesKernelsAction ( InputParameters  parameters)

Definition at line 32 of file AddNavierStokesKernelsAction.C.

33  : NSAction(parameters), _fp_name(getParam<UserObjectName>("fluid_properties"))
34 {
35 }
NSAction(InputParameters parameters)
Definition: NSAction.C:30

◆ ~AddNavierStokesKernelsAction()

AddNavierStokesKernelsAction::~AddNavierStokesKernelsAction ( )
virtual

Definition at line 37 of file AddNavierStokesKernelsAction.C.

37 {}

Member Function Documentation

◆ act()

void AddNavierStokesKernelsAction::act ( )
virtual

Reimplemented from NSAction.

Definition at line 40 of file AddNavierStokesKernelsAction.C.

41 {
42  // Call the base class's act() function to initialize the _vars and _auxs names.
43  NSAction::act();
44 
45  // Add time derivative Kernel for all the _vars
46  for (const auto & name : _vars)
47  {
48  const std::string kernel_type = "TimeDerivative";
49  InputParameters params = _factory.getValidParams(kernel_type);
50  params.set<NonlinearVariableName>("variable") = name;
51  _problem->addKernel(kernel_type, name + std::string("_time_deriv"), params);
52  }
53 
54  // Add all the inviscid flux Kernels.
57  for (unsigned int component = 0; component < _dim; ++component)
59 
60  // Add SUPG Kernels
61  addNSSUPGMass();
63  for (unsigned int component = 0; component < _dim; ++component)
65 
66  // Add AuxKernels.
67  addPressureOrTemperatureAux("NSPressureAux");
68  addPressureOrTemperatureAux("NSTemperatureAux");
70  addNSMachAux();
73  for (unsigned int component = 0; component < _dim; ++component)
75 }
void addNSMomentumInviscidFlux(unsigned int component)
void addPressureOrTemperatureAux(const std::string &kernel_type)
Real component(const SymmTensor &symm_tensor, unsigned int index)
void addNSSUPGMomentum(unsigned int component)
unsigned int _dim
Definition: NSAction.h:40
std::vector< std::string > _vars
Definition: NSAction.h:35
const std::string name
Definition: Setup.h:22
void addNSVelocityAux(unsigned int component)
virtual void act()
Definition: NSAction.C:35

◆ addNSEnergyInviscidFlux()

void AddNavierStokesKernelsAction::addNSEnergyInviscidFlux ( )
protected

Definition at line 260 of file AddNavierStokesKernelsAction.C.

Referenced by act().

261 {
262  const std::string kernel_type = "NSEnergyInviscidFlux";
263  InputParameters params = _factory.getValidParams(kernel_type);
264  params.set<NonlinearVariableName>("variable") = NS::total_energy;
265  setCommonParams(params);
266 
267  // Extra stuff needed by energy equation
268  params.set<CoupledName>(NS::enthalpy) = {NS::enthalpy};
269 
270  // Add the Kernel
271  _problem->addKernel(kernel_type, "rhoE_if", params);
272 }
void setCommonParams(InputParameters &params)
std::vector< VariableName > CoupledName
Definition: NSAction.h:43
const std::string enthalpy
Definition: NS.h:28
const std::string total_energy
Definition: NS.h:21

◆ addNSEnthalpyAux()

void AddNavierStokesKernelsAction::addNSEnthalpyAux ( )
protected

Definition at line 184 of file AddNavierStokesKernelsAction.C.

Referenced by act().

185 {
186  const std::string kernel_type = "NSEnthalpyAux";
187 
188  InputParameters params = _factory.getValidParams(kernel_type);
189  params.set<AuxVariableName>("variable") = NS::enthalpy;
190 
191  // coupled variables
192  params.set<CoupledName>(NS::density) = {NS::density};
194  params.set<CoupledName>(NS::pressure) = {NS::pressure};
195 
196  _problem->addAuxKernel(kernel_type, "enthalpy_auxkernel", params);
197 }
std::vector< VariableName > CoupledName
Definition: NSAction.h:43
const std::string density
Definition: NS.h:17
const std::string enthalpy
Definition: NS.h:28
const std::string pressure
Definition: NS.h:26
const std::string total_energy
Definition: NS.h:21

◆ addNSInternalEnergyAux()

void AddNavierStokesKernelsAction::addNSInternalEnergyAux ( )
protected

Definition at line 146 of file AddNavierStokesKernelsAction.C.

Referenced by act().

147 {
148  const std::string kernel_type = "NSInternalEnergyAux";
149 
150  InputParameters params = _factory.getValidParams(kernel_type);
151  params.set<AuxVariableName>("variable") = NS::internal_energy;
152 
153  // coupled variables
154  params.set<CoupledName>(NS::density) = {NS::density};
156 
157  // Couple the appropriate number of velocities
158  coupleVelocities(params);
159 
160  _problem->addAuxKernel(kernel_type, "internal_energy_auxkernel", params);
161 }
std::vector< VariableName > CoupledName
Definition: NSAction.h:43
const std::string density
Definition: NS.h:17
const std::string total_energy
Definition: NS.h:21
const std::string internal_energy
Definition: NS.h:30
void coupleVelocities(InputParameters &params)

◆ addNSMachAux()

void AddNavierStokesKernelsAction::addNSMachAux ( )
protected

Definition at line 164 of file AddNavierStokesKernelsAction.C.

Referenced by act().

165 {
166  const std::string kernel_type = "NSMachAux";
167 
168  InputParameters params = _factory.getValidParams(kernel_type);
169  params.set<AuxVariableName>("variable") = NS::mach_number;
170 
171  // coupled variables
174 
175  // Couple the appropriate number of velocities
176  coupleVelocities(params);
177 
178  params.set<UserObjectName>("fluid_properties") = _fp_name;
179 
180  _problem->addAuxKernel(kernel_type, "mach_auxkernel", params);
181 }
const std::string mach_number
Definition: NS.h:29
std::vector< VariableName > CoupledName
Definition: NSAction.h:43
const std::string specific_volume
Definition: NS.h:31
const std::string internal_energy
Definition: NS.h:30
void coupleVelocities(InputParameters &params)

◆ addNSMassInviscidFlux()

void AddNavierStokesKernelsAction::addNSMassInviscidFlux ( )
protected

Definition at line 233 of file AddNavierStokesKernelsAction.C.

Referenced by act().

234 {
235  const std::string kernel_type = "NSMassInviscidFlux";
236  InputParameters params = _factory.getValidParams(kernel_type);
237  params.set<NonlinearVariableName>("variable") = NS::density;
238  setCommonParams(params);
239  _problem->addKernel(kernel_type, "rho_if", params);
240 }
void setCommonParams(InputParameters &params)
const std::string density
Definition: NS.h:17

◆ addNSMomentumInviscidFlux()

void AddNavierStokesKernelsAction::addNSMomentumInviscidFlux ( unsigned int  component)
protected

Definition at line 243 of file AddNavierStokesKernelsAction.C.

Referenced by act().

244 {
245  const static std::string momentums[3] = {NS::momentum_x, NS::momentum_y, NS::momentum_z};
246  const std::string kernel_type = "NSMomentumInviscidFlux";
247  InputParameters params = _factory.getValidParams(kernel_type);
248  params.set<NonlinearVariableName>("variable") = momentums[component];
249  setCommonParams(params);
250 
251  // Extra stuff needed by momentum Kernels
252  params.set<CoupledName>(NS::pressure) = {NS::pressure};
253  params.set<unsigned int>("component") = component;
254 
255  // Add the Kernel
256  _problem->addKernel(kernel_type, momentums[component] + std::string("if"), params);
257 }
const std::string momentum_x
Definition: NS.h:18
void setCommonParams(InputParameters &params)
std::vector< VariableName > CoupledName
Definition: NSAction.h:43
Real component(const SymmTensor &symm_tensor, unsigned int index)
const std::string momentum_y
Definition: NS.h:19
const std::string pressure
Definition: NS.h:26
const std::string momentum_z
Definition: NS.h:20

◆ addNSSUPGEnergy()

void AddNavierStokesKernelsAction::addNSSUPGEnergy ( )
protected

Definition at line 113 of file AddNavierStokesKernelsAction.C.

Referenced by act().

114 {
115  const std::string kernel_type = "NSSUPGEnergy";
116  InputParameters params = _factory.getValidParams(kernel_type);
117  params.set<NonlinearVariableName>("variable") = NS::total_energy;
118  setCommonParams(params);
119 
120  // SUPG Kernels also need temperature and enthalpy currently.
122  params.set<CoupledName>(NS::enthalpy) = {NS::enthalpy};
123 
124  _problem->addKernel(kernel_type, "rhoE_supg", params);
125 }
void setCommonParams(InputParameters &params)
std::vector< VariableName > CoupledName
Definition: NSAction.h:43
const std::string temperature
Definition: NS.h:27
const std::string enthalpy
Definition: NS.h:28
const std::string total_energy
Definition: NS.h:21

◆ addNSSUPGMass()

void AddNavierStokesKernelsAction::addNSSUPGMass ( )
protected

Definition at line 78 of file AddNavierStokesKernelsAction.C.

Referenced by act().

79 {
80  const std::string kernel_type = "NSSUPGMass";
81  InputParameters params = _factory.getValidParams(kernel_type);
82  params.set<NonlinearVariableName>("variable") = NS::density;
83  setCommonParams(params);
84 
85  // SUPG Kernels also need temperature and enthalpy currently.
87  params.set<CoupledName>(NS::enthalpy) = {NS::enthalpy};
88 
89  _problem->addKernel(kernel_type, "rho_supg", params);
90 }
void setCommonParams(InputParameters &params)
std::vector< VariableName > CoupledName
Definition: NSAction.h:43
const std::string density
Definition: NS.h:17
const std::string temperature
Definition: NS.h:27
const std::string enthalpy
Definition: NS.h:28

◆ addNSSUPGMomentum()

void AddNavierStokesKernelsAction::addNSSUPGMomentum ( unsigned int  component)
protected

Definition at line 93 of file AddNavierStokesKernelsAction.C.

Referenced by act().

94 {
95  const static std::string momentums[3] = {NS::momentum_x, NS::momentum_y, NS::momentum_z};
96 
97  const std::string kernel_type = "NSSUPGMomentum";
98  InputParameters params = _factory.getValidParams(kernel_type);
99  params.set<NonlinearVariableName>("variable") = momentums[component];
100  setCommonParams(params);
101 
102  // SUPG Kernels also need temperature and enthalpy currently.
104  params.set<CoupledName>(NS::enthalpy) = {NS::enthalpy};
105 
106  // Momentum Kernels also need the component.
107  params.set<unsigned int>("component") = component;
108 
109  _problem->addKernel(kernel_type, momentums[component] + std::string("_supg"), params);
110 }
const std::string momentum_x
Definition: NS.h:18
void setCommonParams(InputParameters &params)
std::vector< VariableName > CoupledName
Definition: NSAction.h:43
Real component(const SymmTensor &symm_tensor, unsigned int index)
const std::string temperature
Definition: NS.h:27
const std::string enthalpy
Definition: NS.h:28
const std::string momentum_y
Definition: NS.h:19
const std::string momentum_z
Definition: NS.h:20

◆ addNSVelocityAux()

void AddNavierStokesKernelsAction::addNSVelocityAux ( unsigned int  component)
protected

Definition at line 200 of file AddNavierStokesKernelsAction.C.

Referenced by act().

201 {
202  const std::string kernel_type = "NSVelocityAux";
203  const static std::string velocities[3] = {NS::velocity_x, NS::velocity_y, NS::velocity_z};
204  const static std::string momentums[3] = {NS::momentum_x, NS::momentum_y, NS::momentum_z};
205 
206  InputParameters params = _factory.getValidParams(kernel_type);
207  params.set<AuxVariableName>("variable") = velocities[component];
208 
209  // coupled variables
210  params.set<CoupledName>(NS::density) = {NS::density};
211  params.set<CoupledName>("momentum") = {momentums[component]};
212  params.set<UserObjectName>("fluid_properties") = _fp_name;
213 
214  _problem->addAuxKernel(kernel_type, velocities[component] + "_auxkernel", params);
215 }
const std::string momentum_x
Definition: NS.h:18
std::vector< VariableName > CoupledName
Definition: NSAction.h:43
const std::string velocity_z
Definition: NS.h:25
const std::string density
Definition: NS.h:17
Real component(const SymmTensor &symm_tensor, unsigned int index)
const std::string velocity_x
Definition: NS.h:23
const std::string velocity_y
Definition: NS.h:24
const std::string momentum_y
Definition: NS.h:19
const std::string momentum_z
Definition: NS.h:20

◆ addPressureOrTemperatureAux()

void AddNavierStokesKernelsAction::addPressureOrTemperatureAux ( const std::string &  kernel_type)
protected

Definition at line 218 of file AddNavierStokesKernelsAction.C.

Referenced by act().

219 {
220  InputParameters params = _factory.getValidParams(kernel_type);
221  std::string var_name = (kernel_type == "NSPressureAux" ? NS::pressure : NS::temperature);
222  params.set<AuxVariableName>("variable") = var_name;
223 
224  // coupled variables
227  params.set<UserObjectName>("fluid_properties") = _fp_name;
228 
229  _problem->addAuxKernel(kernel_type, var_name + "_auxkernel", params);
230 }
std::vector< VariableName > CoupledName
Definition: NSAction.h:43
const std::string temperature
Definition: NS.h:27
const std::string specific_volume
Definition: NS.h:31
const std::string pressure
Definition: NS.h:26
const std::string internal_energy
Definition: NS.h:30

◆ addSpecificVolumeComputation()

void AddNavierStokesKernelsAction::addSpecificVolumeComputation ( )
protected

Definition at line 128 of file AddNavierStokesKernelsAction.C.

Referenced by act().

129 {
130  const std::string kernel_type = "ParsedAux";
131 
132  InputParameters params = _factory.getValidParams(kernel_type);
133  params.set<AuxVariableName>("variable") = NS::specific_volume;
134 
135  // arguments
136  params.set<CoupledName>("args") = {NS::density};
137 
138  // expression
139  std::string function = "if(" + NS::density + " = 0, 1e10, 1 / " + NS::density + ")";
140  params.set<std::string>("function") = function;
141 
142  _problem->addAuxKernel(kernel_type, "specific_volume_auxkernel", params);
143 }
std::vector< VariableName > CoupledName
Definition: NSAction.h:43
const std::string density
Definition: NS.h:17
const std::string specific_volume
Definition: NS.h:31

◆ coupleMomentums()

void AddNavierStokesKernelsAction::coupleMomentums ( InputParameters &  params)
protected

Definition at line 302 of file AddNavierStokesKernelsAction.C.

Referenced by setCommonParams().

303 {
304  params.set<CoupledName>(NS::momentum_x) = {NS::momentum_x};
305 
306  if (_dim >= 2)
307  params.set<CoupledName>(NS::momentum_y) = {NS::momentum_y};
308 
309  if (_dim >= 3)
310  params.set<CoupledName>(NS::momentum_z) = {NS::momentum_z};
311 }
const std::string momentum_x
Definition: NS.h:18
std::vector< VariableName > CoupledName
Definition: NSAction.h:43
unsigned int _dim
Definition: NSAction.h:40
const std::string momentum_y
Definition: NS.h:19
const std::string momentum_z
Definition: NS.h:20

◆ coupleVelocities()

void AddNavierStokesKernelsAction::coupleVelocities ( InputParameters &  params)
protected

Definition at line 290 of file AddNavierStokesKernelsAction.C.

Referenced by addNSInternalEnergyAux(), addNSMachAux(), and setCommonParams().

291 {
292  params.set<CoupledName>(NS::velocity_x) = {NS::velocity_x};
293 
294  if (_dim >= 2)
295  params.set<CoupledName>(NS::velocity_y) = {NS::velocity_y};
296 
297  if (_dim >= 3)
298  params.set<CoupledName>(NS::velocity_z) = {NS::velocity_z};
299 }
std::vector< VariableName > CoupledName
Definition: NSAction.h:43
const std::string velocity_z
Definition: NS.h:25
const std::string velocity_x
Definition: NS.h:23
unsigned int _dim
Definition: NSAction.h:40
const std::string velocity_y
Definition: NS.h:24

◆ setCommonParams()

void AddNavierStokesKernelsAction::setCommonParams ( InputParameters &  params)
protected

Definition at line 275 of file AddNavierStokesKernelsAction.C.

Referenced by addNSEnergyInviscidFlux(), addNSMassInviscidFlux(), addNSMomentumInviscidFlux(), addNSSUPGEnergy(), addNSSUPGMass(), and addNSSUPGMomentum().

276 {
277  // coupled variables
278  params.set<CoupledName>(NS::density) = {NS::density};
280 
281  // Couple the appropriate number of velocities
282  coupleVelocities(params);
283  coupleMomentums(params);
284 
285  // FluidProperties object
286  params.set<UserObjectName>("fluid_properties") = _fp_name;
287 }
void coupleMomentums(InputParameters &params)
std::vector< VariableName > CoupledName
Definition: NSAction.h:43
const std::string density
Definition: NS.h:17
const std::string total_energy
Definition: NS.h:21
void coupleVelocities(InputParameters &params)

Member Data Documentation

◆ _auxs

std::vector<std::string> NSAction::_auxs
protectedinherited

◆ _dim

unsigned int NSAction::_dim
protectedinherited

Definition at line 40 of file NSAction.h.

Referenced by NSAction::act(), act(), coupleMomentums(), and coupleVelocities().

◆ _fp_name

UserObjectName AddNavierStokesKernelsAction::_fp_name
protected

◆ _vars

std::vector<std::string> NSAction::_vars
protectedinherited

The documentation for this class was generated from the following files: