www.mooseframework.org
AddNavierStokesKernelsAction.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
10 #include "NS.h"
11 
12 // MOOSE includes
13 #include "FEProblem.h"
14 
15 template <>
16 InputParameters
18 {
19  InputParameters params = validParams<NSAction>();
20  params.addClassDescription("This class allows us to have a section of the input file like the "
21  "following which automatically adds Kernels and AuxKernels for all "
22  "the required nonlinear and auxiliary variables.");
23  params.addRequiredParam<UserObjectName>("fluid_properties",
24  "The name of the user object for fluid properties");
25  return params;
26 }
27 
29  : NSAction(parameters), _fp_name(getParam<UserObjectName>("fluid_properties"))
30 {
31 }
32 
34 
35 void
37 {
38  // Call the base class's act() function to initialize the _vars and _auxs names.
39  NSAction::act();
40 
41  // Add time derivative Kernel for all the _vars
42  for (const auto & name : _vars)
43  {
44  const std::string kernel_type = "TimeDerivative";
45  InputParameters params = _factory.getValidParams(kernel_type);
46  params.set<NonlinearVariableName>("variable") = name;
47  _problem->addKernel(kernel_type, name + std::string("_time_deriv"), params);
48  }
49 
50  // Add all the inviscid flux Kernels.
53  for (unsigned int component = 0; component < _dim; ++component)
55 
56  // Add SUPG Kernels
57  addNSSUPGMass();
59  for (unsigned int component = 0; component < _dim; ++component)
61 
62  // Add AuxKernels.
63  addPressureOrTemperatureAux("NSPressureAux");
64  addPressureOrTemperatureAux("NSTemperatureAux");
66  addNSMachAux();
69  for (unsigned int component = 0; component < _dim; ++component)
71 }
72 
73 void
75 {
76  const std::string kernel_type = "NSSUPGMass";
77  InputParameters params = _factory.getValidParams(kernel_type);
78  params.set<NonlinearVariableName>("variable") = NS::density;
79  setCommonParams(params);
80 
81  // SUPG Kernels also need temperature and enthalpy currently.
83  params.set<CoupledName>(NS::enthalpy) = {NS::enthalpy};
84 
85  _problem->addKernel(kernel_type, "rho_supg", params);
86 }
87 
88 void
90 {
91  const static std::string momentums[3] = {NS::momentum_x, NS::momentum_y, NS::momentum_z};
92 
93  const std::string kernel_type = "NSSUPGMomentum";
94  InputParameters params = _factory.getValidParams(kernel_type);
95  params.set<NonlinearVariableName>("variable") = momentums[component];
96  setCommonParams(params);
97 
98  // SUPG Kernels also need temperature and enthalpy currently.
100  params.set<CoupledName>(NS::enthalpy) = {NS::enthalpy};
101 
102  // Momentum Kernels also need the component.
103  params.set<unsigned int>("component") = component;
104 
105  _problem->addKernel(kernel_type, momentums[component] + std::string("_supg"), params);
106 }
107 
108 void
110 {
111  const std::string kernel_type = "NSSUPGEnergy";
112  InputParameters params = _factory.getValidParams(kernel_type);
113  params.set<NonlinearVariableName>("variable") = NS::total_energy;
114  setCommonParams(params);
115 
116  // SUPG Kernels also need temperature and enthalpy currently.
118  params.set<CoupledName>(NS::enthalpy) = {NS::enthalpy};
119 
120  _problem->addKernel(kernel_type, "rhoE_supg", params);
121 }
122 
123 void
125 {
126  const std::string kernel_type = "NSSpecificVolumeAux";
127 
128  InputParameters params = _factory.getValidParams(kernel_type);
129  params.set<AuxVariableName>("variable") = NS::specific_volume;
130 
131  // coupled variables
132  params.set<CoupledName>(NS::density) = {NS::density};
133 
134  _problem->addAuxKernel(kernel_type, "specific_volume_auxkernel", params);
135 }
136 
137 void
139 {
140  const std::string kernel_type = "NSInternalEnergyAux";
141 
142  InputParameters params = _factory.getValidParams(kernel_type);
143  params.set<AuxVariableName>("variable") = NS::internal_energy;
144 
145  // coupled variables
146  params.set<CoupledName>(NS::density) = {NS::density};
148 
149  // Couple the appropriate number of velocities
150  coupleVelocities(params);
151 
152  _problem->addAuxKernel(kernel_type, "internal_energy_auxkernel", params);
153 }
154 
155 void
157 {
158  const std::string kernel_type = "NSMachAux";
159 
160  InputParameters params = _factory.getValidParams(kernel_type);
161  params.set<AuxVariableName>("variable") = NS::mach_number;
162 
163  // coupled variables
166 
167  // Couple the appropriate number of velocities
168  coupleVelocities(params);
169 
170  params.set<UserObjectName>("fluid_properties") = _fp_name;
171 
172  _problem->addAuxKernel(kernel_type, "mach_auxkernel", params);
173 }
174 
175 void
177 {
178  const std::string kernel_type = "NSEnthalpyAux";
179 
180  InputParameters params = _factory.getValidParams(kernel_type);
181  params.set<AuxVariableName>("variable") = NS::enthalpy;
182 
183  // coupled variables
184  params.set<CoupledName>(NS::density) = {NS::density};
186  params.set<CoupledName>(NS::pressure) = {NS::pressure};
187 
188  _problem->addAuxKernel(kernel_type, "enthalpy_auxkernel", params);
189 }
190 
191 void
193 {
194  const std::string kernel_type = "NSVelocityAux";
195  const static std::string velocities[3] = {NS::velocity_x, NS::velocity_y, NS::velocity_z};
196  const static std::string momentums[3] = {NS::momentum_x, NS::momentum_y, NS::momentum_z};
197 
198  InputParameters params = _factory.getValidParams(kernel_type);
199  params.set<AuxVariableName>("variable") = velocities[component];
200 
201  // coupled variables
202  params.set<CoupledName>(NS::density) = {NS::density};
203  params.set<CoupledName>("momentum") = {momentums[component]};
204  params.set<UserObjectName>("fluid_properties") = _fp_name;
205 
206  _problem->addAuxKernel(kernel_type, velocities[component] + "_auxkernel", params);
207 }
208 
209 void
211 {
212  InputParameters params = _factory.getValidParams(kernel_type);
213  std::string var_name = (kernel_type == "NSPressureAux" ? NS::pressure : NS::temperature);
214  params.set<AuxVariableName>("variable") = var_name;
215 
216  // coupled variables
219  params.set<UserObjectName>("fluid_properties") = _fp_name;
220 
221  _problem->addAuxKernel(kernel_type, var_name + "_auxkernel", params);
222 }
223 
224 void
226 {
227  const std::string kernel_type = "NSMassInviscidFlux";
228  InputParameters params = _factory.getValidParams(kernel_type);
229  params.set<NonlinearVariableName>("variable") = NS::density;
230  setCommonParams(params);
231  _problem->addKernel(kernel_type, "rho_if", params);
232 }
233 
234 void
236 {
237  const static std::string momentums[3] = {NS::momentum_x, NS::momentum_y, NS::momentum_z};
238  const std::string kernel_type = "NSMomentumInviscidFlux";
239  InputParameters params = _factory.getValidParams(kernel_type);
240  params.set<NonlinearVariableName>("variable") = momentums[component];
241  setCommonParams(params);
242 
243  // Extra stuff needed by momentum Kernels
244  params.set<CoupledName>(NS::pressure) = {NS::pressure};
245  params.set<unsigned int>("component") = component;
246 
247  // Add the Kernel
248  _problem->addKernel(kernel_type, momentums[component] + std::string("if"), params);
249 }
250 
251 void
253 {
254  const std::string kernel_type = "NSEnergyInviscidFlux";
255  InputParameters params = _factory.getValidParams(kernel_type);
256  params.set<NonlinearVariableName>("variable") = NS::total_energy;
257  setCommonParams(params);
258 
259  // Extra stuff needed by energy equation
260  params.set<CoupledName>(NS::enthalpy) = {NS::enthalpy};
261 
262  // Add the Kernel
263  _problem->addKernel(kernel_type, "rhoE_if", params);
264 }
265 
266 void
268 {
269  // coupled variables
270  params.set<CoupledName>(NS::density) = {NS::density};
272 
273  // Couple the appropriate number of velocities
274  coupleVelocities(params);
275  coupleMomentums(params);
276 
277  // FluidProperties object
278  params.set<UserObjectName>("fluid_properties") = _fp_name;
279 }
280 
281 void
283 {
284  params.set<CoupledName>(NS::velocity_x) = {NS::velocity_x};
285 
286  if (_dim >= 2)
287  params.set<CoupledName>(NS::velocity_y) = {NS::velocity_y};
288 
289  if (_dim >= 3)
290  params.set<CoupledName>(NS::velocity_z) = {NS::velocity_z};
291 }
292 
293 void
295 {
296  params.set<CoupledName>(NS::momentum_x) = {NS::momentum_x};
297 
298  if (_dim >= 2)
299  params.set<CoupledName>(NS::momentum_y) = {NS::momentum_y};
300 
301  if (_dim >= 3)
302  params.set<CoupledName>(NS::momentum_z) = {NS::momentum_z};
303 }
const std::string momentum_x
Definition: NS.h:16
void coupleMomentums(InputParameters &params)
AddNavierStokesKernelsAction(InputParameters parameters)
void addNSMomentumInviscidFlux(unsigned int component)
void addPressureOrTemperatureAux(const std::string &kernel_type)
void setCommonParams(InputParameters &params)
const std::string mach_number
Definition: NS.h:27
std::vector< VariableName > CoupledName
Definition: NSAction.h:40
const std::string velocity_z
Definition: NS.h:23
const std::string density
Definition: NS.h:15
Real component(const SymmTensor &symm_tensor, unsigned int index)
InputParameters validParams< NSAction >()
Definition: NSAction.C:17
void addNSSUPGMomentum(unsigned int component)
const std::string velocity_x
Definition: NS.h:21
const std::string temperature
Definition: NS.h:25
const std::string enthalpy
Definition: NS.h:26
unsigned int _dim
Definition: NSAction.h:37
std::vector< std::string > _vars
Definition: NSAction.h:32
const std::string specific_volume
Definition: NS.h:29
const std::string velocity_y
Definition: NS.h:22
void addNSVelocityAux(unsigned int component)
const std::string momentum_y
Definition: NS.h:17
virtual void act()
Definition: NSAction.C:33
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
InputParameters validParams< AddNavierStokesKernelsAction >()
This is a base Action class for the Navier-Stokes module which is responsible for building lists of n...
Definition: NSAction.h:23
void coupleVelocities(InputParameters &params)