Line data Source code
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 "CNSAction.h"
12 :
13 : #include "NS.h"
14 : #include "AddVariableAction.h"
15 : #include "MooseObject.h"
16 :
17 : // MOOSE includes
18 : #include "FEProblem.h"
19 :
20 : #include "libmesh/fe.h"
21 : #include "libmesh/vector_value.h"
22 : #include "libmesh/string_to_enum.h"
23 :
24 : using namespace libMesh;
25 :
26 : registerMooseAction("NavierStokesApp", CNSAction, "add_navier_stokes_variables");
27 : registerMooseAction("NavierStokesApp", CNSAction, "add_navier_stokes_kernels");
28 : registerMooseAction("NavierStokesApp", CNSAction, "add_navier_stokes_bcs");
29 : registerMooseAction("NavierStokesApp", CNSAction, "add_navier_stokes_ics");
30 :
31 : InputParameters
32 19 : CNSAction::validParams()
33 : {
34 19 : InputParameters params = Action::validParams();
35 19 : params.addClassDescription("This class allows us to have a section of the input file like the "
36 : "following which automatically adds Kernels and AuxKernels for all "
37 : "the required nonlinear and auxiliary variables.");
38 :
39 38 : MooseEnum type("steady-state transient", "steady-state");
40 38 : params.addParam<MooseEnum>("equation_type", type, "Navier-Stokes equation type");
41 :
42 38 : params.addParam<std::vector<SubdomainName>>(
43 : "block", {}, "The list of block ids (SubdomainID) on which NS equation is defined on");
44 :
45 38 : params.addRequiredParam<UserObjectName>("fluid_properties",
46 : "The name of the user object for fluid properties");
47 :
48 19 : params.addParam<std::vector<BoundaryName>>(
49 19 : "stagnation_boundary", std::vector<BoundaryName>(), "Stagnation boundaries");
50 19 : params.addParam<std::vector<Real>>(
51 19 : "stagnation_pressure", std::vector<Real>(), "Pressure on stagnation boundaries");
52 19 : params.addParam<std::vector<Real>>(
53 19 : "stagnation_temperature", std::vector<Real>(), "Temperature on stagnation boundaries");
54 19 : params.addParam<std::vector<Real>>(
55 19 : "stagnation_flow_direction", std::vector<Real>(), "Flow directions on stagnation boundaries");
56 19 : params.addParam<std::vector<BoundaryName>>(
57 19 : "no_penetration_boundary", std::vector<BoundaryName>(), "No-penetration boundaries");
58 19 : params.addParam<std::vector<BoundaryName>>(
59 19 : "static_pressure_boundary", std::vector<BoundaryName>(), "Static pressure boundaries");
60 19 : params.addParam<std::vector<Real>>(
61 19 : "static_pressure", std::vector<Real>(), "Static pressure on boundaries");
62 :
63 57 : MooseEnum families(AddVariableAction::getNonlinearVariableFamilies(), "LAGRANGE");
64 57 : MooseEnum orders(AddVariableAction::getNonlinearVariableOrders(), "FIRST");
65 38 : params.addParam<MooseEnum>(
66 : "family", families, "Specifies the family of FE shape functions to use for this variable");
67 38 : params.addParam<MooseEnum>("order",
68 : orders,
69 : "Specifies the order of the FE shape function to use "
70 : "for this variable (additional orders not listed are "
71 : "allowed)");
72 38 : params.addParam<Real>("density_scaling", 1, "Scaling for the density variable");
73 19 : params.addParam<RealVectorValue>(
74 19 : "momentum_scaling", RealVectorValue(1, 1, 1), "Scaling for the momentum variables");
75 38 : params.addParam<Real>("total_energy_density_scaling", 1, "Scaling for the total-energy variable");
76 :
77 38 : params.addRequiredParam<Real>("initial_pressure",
78 : "The initial pressure, assumed constant everywhere");
79 38 : params.addRequiredParam<Real>("initial_temperature",
80 : "The initial temperature, assumed constant everywhere");
81 38 : params.addRequiredParam<RealVectorValue>("initial_velocity",
82 : "The initial velocity, assumed constant everywhere");
83 :
84 38 : params.addParamNamesToGroup("equation_type block fluid_properties", "Base");
85 38 : params.addParamNamesToGroup(
86 : "stagnation_boundary stagnation_pressure stagnation_temperature "
87 : "stagnation_flow_direction no_penetration_boundary static_pressure_boundary static_pressure",
88 : "BoundaryCondition");
89 38 : params.addParamNamesToGroup(
90 : "family order density_scaling momentum_scaling total_energy_density_scaling", "Variable");
91 38 : params.addParam<std::string>("pressure_variable_name",
92 : "A name for the pressure variable. If this is not provided, a "
93 : "sensible default will be used.");
94 19 : return params;
95 19 : }
96 :
97 19 : CNSAction::CNSAction(const InputParameters & parameters)
98 : : Action(parameters),
99 19 : _type(getParam<MooseEnum>("equation_type")),
100 19 : _fp_name(getParam<UserObjectName>("fluid_properties")),
101 38 : _blocks(getParam<std::vector<SubdomainName>>("block")),
102 38 : _stagnation_boundary(getParam<std::vector<BoundaryName>>("stagnation_boundary")),
103 38 : _stagnation_pressure(getParam<std::vector<Real>>("stagnation_pressure")),
104 38 : _stagnation_temperature(getParam<std::vector<Real>>("stagnation_temperature")),
105 38 : _stagnation_direction(getParam<std::vector<Real>>("stagnation_flow_direction")),
106 38 : _no_penetration_boundary(getParam<std::vector<BoundaryName>>("no_penetration_boundary")),
107 38 : _static_pressure_boundary(getParam<std::vector<BoundaryName>>("static_pressure_boundary")),
108 38 : _static_pressure(getParam<std::vector<Real>>("static_pressure")),
109 57 : _fe_type(Utility::string_to_enum<Order>(getParam<MooseEnum>("order")),
110 19 : Utility::string_to_enum<FEFamily>(getParam<MooseEnum>("family"))),
111 38 : _initial_pressure(getParam<Real>("initial_pressure")),
112 38 : _initial_temperature(getParam<Real>("initial_temperature")),
113 38 : _initial_velocity(getParam<RealVectorValue>("initial_velocity")),
114 76 : _pressure_variable_name(isParamValid("pressure_variable_name")
115 19 : ? getParam<std::string>("pressure_variable_name")
116 19 : : "p")
117 : {
118 19 : if (_stagnation_pressure.size() != _stagnation_boundary.size())
119 0 : paramError("stagnation_pressure",
120 : "Size is not the same as the number of boundaries in 'stagnation_boundary'");
121 19 : if (_stagnation_temperature.size() != _stagnation_boundary.size())
122 0 : paramError("stagnation_temperature",
123 : "Size is not the same as the number of boundaries in 'stagnation_boundary'");
124 19 : if (_static_pressure.size() != _static_pressure_boundary.size())
125 0 : paramError("static_pressure",
126 : "Size is not the same as the number of boundaries in 'static_pressure_boundary'");
127 19 : }
128 :
129 : void
130 76 : CNSAction::act()
131 : {
132 76 : if (_current_task == "add_navier_stokes_variables")
133 : {
134 19 : _dim = _mesh->dimension();
135 19 : for (const auto & subdomain_name : _blocks)
136 : {
137 0 : SubdomainID id = _mesh->getSubdomainID(subdomain_name);
138 0 : _block_ids.insert(id);
139 : }
140 19 : if (_stagnation_direction.size() != _stagnation_boundary.size() * _dim)
141 0 : paramError("stagnation_flow_direction",
142 : "Size is not the same as the number of boundaries in 'stagnation_boundary' times "
143 : "the mesh dimension");
144 :
145 : // FIXME: need to check boundaries are non-overlapping and enclose the blocks
146 :
147 19 : auto var_type = AddVariableAction::variableType(_fe_type);
148 19 : auto base_params = _factory.getValidParams(var_type);
149 19 : base_params.set<MooseEnum>("order") = _fe_type.order.get_order();
150 38 : base_params.set<MooseEnum>("family") = Moose::stringify(_fe_type.family);
151 19 : if (_block_ids.size() != 0)
152 0 : for (const SubdomainID & id : _block_ids)
153 0 : base_params.set<std::vector<SubdomainName>>("block").push_back(Moose::stringify(id));
154 :
155 : // add primal variables
156 19 : InputParameters params(base_params);
157 57 : params.set<std::vector<Real>>("scaling") = {getParam<Real>("density_scaling")};
158 19 : _problem->addVariable(var_type, NS::density, params);
159 :
160 38 : auto mscaling = getParam<RealVectorValue>("momentum_scaling");
161 19 : params.set<std::vector<Real>>("scaling") = {mscaling(0)};
162 19 : _problem->addVariable(var_type, NS::momentum_x, params);
163 19 : if (_dim >= 2)
164 : {
165 19 : params.set<std::vector<Real>>("scaling") = {mscaling(1)};
166 19 : _problem->addVariable(var_type, NS::momentum_y, params);
167 : }
168 19 : if (_dim >= 3)
169 : {
170 0 : params.set<std::vector<Real>>("scaling") = {mscaling(2)};
171 0 : _problem->addVariable(var_type, NS::momentum_z, params);
172 : }
173 57 : params.set<std::vector<Real>>("scaling") = {getParam<Real>("total_energy_density_scaling")};
174 19 : _problem->addVariable(var_type, NS::total_energy_density, params);
175 :
176 : // Add Aux variables. These are all required in order for the code
177 : // to run, so they should not be independently selectable by the
178 : // user.
179 19 : _problem->addAuxVariable(var_type, NS::velocity_x, base_params);
180 19 : if (_dim >= 2)
181 19 : _problem->addAuxVariable(var_type, NS::velocity_y, base_params);
182 19 : if (_dim >= 3)
183 0 : _problem->addAuxVariable(var_type, NS::velocity_z, base_params);
184 19 : _problem->addAuxVariable(var_type, _pressure_variable_name, base_params);
185 19 : _problem->addAuxVariable(var_type, NS::temperature, base_params);
186 19 : _problem->addAuxVariable(var_type, NS::specific_total_enthalpy, base_params);
187 19 : _problem->addAuxVariable(var_type, NS::mach_number, base_params);
188 :
189 : // Needed for FluidProperties calculations
190 19 : _problem->addAuxVariable(var_type, NS::specific_internal_energy, base_params);
191 19 : _problem->addAuxVariable(var_type, NS::specific_volume, base_params);
192 19 : }
193 :
194 76 : if (_current_task == "add_navier_stokes_kernels")
195 : {
196 19 : if (_type == "transient")
197 19 : addNSTimeKernels();
198 :
199 : // Add all the inviscid flux Kernels.
200 19 : addNSMassInviscidFlux();
201 19 : addNSEnergyInviscidFlux();
202 57 : for (unsigned int component = 0; component < _dim; ++component)
203 38 : addNSMomentumInviscidFlux(component);
204 :
205 : // Add SUPG Kernels
206 19 : addNSSUPGMass();
207 19 : addNSSUPGEnergy();
208 57 : for (unsigned int component = 0; component < _dim; ++component)
209 38 : addNSSUPGMomentum(component);
210 :
211 : // Add AuxKernels.
212 19 : addPressureOrTemperatureAux("PressureAux");
213 19 : addPressureOrTemperatureAux("TemperatureAux");
214 19 : addSpecificTotalEnthalpyAux();
215 19 : addNSMachAux();
216 19 : addNSInternalEnergyAux();
217 19 : addSpecificVolumeComputation();
218 57 : for (unsigned int component = 0; component < _dim; ++component)
219 38 : addNSVelocityAux(component);
220 : }
221 :
222 76 : if (_current_task == "add_navier_stokes_bcs")
223 : {
224 19 : if (_stagnation_boundary.size() > 0)
225 : {
226 19 : addNSMassWeakStagnationBC();
227 19 : addNSEnergyWeakStagnationBC();
228 57 : for (unsigned int component = 0; component < _dim; ++component)
229 38 : addNSMomentumWeakStagnationBC(component);
230 : }
231 :
232 19 : if (_no_penetration_boundary.size() > 0)
233 : {
234 57 : for (unsigned int component = 0; component < _dim; ++component)
235 38 : addNoPenetrationBC(component);
236 : }
237 :
238 19 : if (_static_pressure_boundary.size() > 0)
239 : {
240 19 : addNSMassUnspecifiedNormalFlowBC();
241 19 : addNSEnergyInviscidSpecifiedPressureBC();
242 57 : for (unsigned int component = 0; component < _dim; ++component)
243 38 : addNSMomentumInviscidSpecifiedPressureBC(component);
244 : }
245 : }
246 :
247 76 : if (_current_task == "add_navier_stokes_ics")
248 : {
249 : // add ICs for primal variables
250 : std::vector<VariableName> vars;
251 19 : vars.push_back(NS::density);
252 19 : vars.push_back(NS::momentum_x);
253 19 : if (_dim >= 2)
254 19 : vars.push_back(NS::momentum_y);
255 19 : if (_dim >= 3)
256 0 : vars.push_back(NS::momentum_z);
257 19 : vars.push_back(NS::total_energy_density);
258 95 : for (const auto & name : vars)
259 : {
260 76 : InputParameters params = _factory.getValidParams("NSInitialCondition");
261 76 : params.set<VariableName>("variable") = name;
262 76 : params.set<Real>("initial_pressure") = _initial_pressure;
263 76 : params.set<Real>("initial_temperature") = _initial_temperature;
264 76 : params.set<RealVectorValue>("initial_velocity") = _initial_velocity;
265 76 : params.set<UserObjectName>("fluid_properties") = _fp_name;
266 152 : _problem->addInitialCondition("NSInitialCondition", name + std::string("_ic"), params);
267 76 : }
268 :
269 : // add ICs for aux variables (possibly we do not need this)
270 : std::vector<VariableName> auxs;
271 19 : auxs.push_back(NS::velocity_x);
272 19 : if (_dim >= 2)
273 19 : auxs.push_back(NS::velocity_y);
274 19 : if (_dim >= 3)
275 0 : auxs.push_back(NS::velocity_z);
276 :
277 38 : auxs.push_back(_pressure_variable_name);
278 19 : auxs.push_back(NS::temperature);
279 19 : auxs.push_back(NS::specific_total_enthalpy);
280 19 : auxs.push_back(NS::mach_number);
281 :
282 : // Needed for FluidProperties calculations
283 19 : auxs.push_back(NS::specific_internal_energy);
284 19 : auxs.push_back(NS::specific_volume);
285 171 : for (const auto & name : auxs)
286 : {
287 152 : InputParameters params = _factory.getValidParams("NSInitialCondition");
288 152 : params.set<VariableName>("variable") = name;
289 152 : params.set<Real>("initial_pressure") = _initial_pressure;
290 152 : params.set<Real>("initial_temperature") = _initial_temperature;
291 152 : params.set<RealVectorValue>("initial_velocity") = _initial_velocity;
292 152 : params.set<UserObjectName>("fluid_properties") = _fp_name;
293 152 : if (name == _pressure_variable_name)
294 38 : params.set<MooseEnum>("variable_type") = NS::pressure;
295 304 : _problem->addInitialCondition("NSInitialCondition", name + std::string("_ic"), params);
296 152 : }
297 19 : }
298 76 : }
299 :
300 : void
301 19 : CNSAction::addNSTimeKernels()
302 : {
303 19 : const std::string kernel_type = "TimeDerivative";
304 19 : InputParameters params = _factory.getValidParams(kernel_type);
305 38 : params.set<std::vector<SubdomainName>>("block") = _blocks;
306 :
307 38 : params.set<NonlinearVariableName>("variable") = NS::density;
308 38 : _problem->addKernel(kernel_type, NS::density + "_time_deriv", params);
309 :
310 38 : params.set<NonlinearVariableName>("variable") = NS::momentum_x;
311 19 : _problem->addKernel(kernel_type, NS::momentum_x + "_time_deriv", params);
312 19 : if (_dim >= 2)
313 : {
314 38 : params.set<NonlinearVariableName>("variable") = NS::momentum_y;
315 38 : _problem->addKernel(kernel_type, NS::momentum_y + "_time_deriv", params);
316 : }
317 19 : if (_dim >= 3)
318 : {
319 0 : params.set<NonlinearVariableName>("variable") = NS::momentum_z;
320 0 : _problem->addKernel(kernel_type, NS::momentum_z + "_time_deriv", params);
321 : }
322 :
323 38 : params.set<NonlinearVariableName>("variable") = NS::total_energy_density;
324 19 : _problem->addKernel(kernel_type, NS::total_energy_density + "_time_deriv", params);
325 38 : }
326 :
327 : void
328 19 : CNSAction::addNSSUPGMass()
329 : {
330 19 : const std::string kernel_type = "NSSUPGMass";
331 19 : InputParameters params = _factory.getValidParams(kernel_type);
332 38 : params.set<NonlinearVariableName>("variable") = NS::density;
333 19 : setKernelCommonParams(params);
334 :
335 : // SUPG Kernels also need temperature and specific_total_enthalpy currently.
336 57 : params.set<CoupledName>(NS::temperature) = {NS::temperature};
337 57 : params.set<CoupledName>(NS::specific_total_enthalpy) = {NS::specific_total_enthalpy};
338 :
339 19 : _problem->addKernel(kernel_type, "rho_supg", params);
340 38 : }
341 :
342 : void
343 38 : CNSAction::addNSSUPGMomentum(unsigned int component)
344 : {
345 38 : const static std::string momentums[3] = {NS::momentum_x, NS::momentum_y, NS::momentum_z};
346 :
347 38 : const std::string kernel_type = "NSSUPGMomentum";
348 38 : InputParameters params = _factory.getValidParams(kernel_type);
349 76 : params.set<NonlinearVariableName>("variable") = momentums[component];
350 38 : setKernelCommonParams(params);
351 :
352 : // SUPG Kernels also need temperature and specific_total_enthalpy currently.
353 114 : params.set<CoupledName>(NS::temperature) = {NS::temperature};
354 114 : params.set<CoupledName>(NS::specific_total_enthalpy) = {NS::specific_total_enthalpy};
355 :
356 : // Momentum Kernels also need the component.
357 38 : params.set<unsigned int>("component") = component;
358 :
359 38 : _problem->addKernel(kernel_type, momentums[component] + std::string("_supg"), params);
360 76 : }
361 :
362 : void
363 19 : CNSAction::addNSSUPGEnergy()
364 : {
365 19 : const std::string kernel_type = "NSSUPGEnergy";
366 19 : InputParameters params = _factory.getValidParams(kernel_type);
367 38 : params.set<NonlinearVariableName>("variable") = NS::total_energy_density;
368 19 : setKernelCommonParams(params);
369 :
370 : // SUPG Kernels also need temperature and specific_total_enthalpy currently.
371 57 : params.set<CoupledName>(NS::temperature) = {NS::temperature};
372 57 : params.set<CoupledName>(NS::specific_total_enthalpy) = {NS::specific_total_enthalpy};
373 :
374 19 : _problem->addKernel(kernel_type, "rhoE_supg", params);
375 38 : }
376 :
377 : void
378 19 : CNSAction::addSpecificVolumeComputation()
379 : {
380 19 : const std::string kernel_type = "ParsedAux";
381 :
382 19 : InputParameters params = _factory.getValidParams(kernel_type);
383 38 : params.set<AuxVariableName>("variable") = NS::specific_volume;
384 :
385 : // arguments
386 57 : params.set<CoupledName>("args") = {NS::density};
387 :
388 : // expression
389 38 : std::string function = "if(" + NS::density + " = 0, 1e10, 1 / " + NS::density + ")";
390 19 : params.set<std::string>("function") = function;
391 :
392 38 : _problem->addAuxKernel(kernel_type, "specific_volume_auxkernel", params);
393 38 : }
394 :
395 : void
396 19 : CNSAction::addNSInternalEnergyAux()
397 : {
398 19 : const std::string kernel_type = "NSInternalEnergyAux";
399 :
400 19 : InputParameters params = _factory.getValidParams(kernel_type);
401 38 : params.set<AuxVariableName>("variable") = NS::specific_internal_energy;
402 :
403 : // coupled variables
404 57 : params.set<CoupledName>(NS::density) = {NS::density};
405 57 : params.set<CoupledName>(NS::total_energy_density) = {NS::total_energy_density};
406 :
407 : // Couple the appropriate number of velocities
408 19 : coupleVelocities(params);
409 :
410 19 : _problem->addAuxKernel(kernel_type, "specific_internal_energy_auxkernel", params);
411 38 : }
412 :
413 : void
414 19 : CNSAction::addNSMachAux()
415 : {
416 19 : const std::string kernel_type = "NSMachAux";
417 :
418 19 : InputParameters params = _factory.getValidParams(kernel_type);
419 38 : params.set<AuxVariableName>("variable") = NS::mach_number;
420 :
421 : // coupled variables
422 57 : params.set<CoupledName>(NS::specific_internal_energy) = {NS::specific_internal_energy};
423 57 : params.set<CoupledName>(NS::specific_volume) = {NS::specific_volume};
424 :
425 : // Couple the appropriate number of velocities
426 19 : coupleVelocities(params);
427 :
428 19 : params.set<UserObjectName>("fluid_properties") = _fp_name;
429 :
430 19 : _problem->addAuxKernel(kernel_type, "mach_auxkernel", params);
431 38 : }
432 :
433 : void
434 19 : CNSAction::addSpecificTotalEnthalpyAux()
435 : {
436 19 : const std::string kernel_type = "NSSpecificTotalEnthalpyAux";
437 :
438 19 : InputParameters params = _factory.getValidParams(kernel_type);
439 38 : params.set<AuxVariableName>("variable") = NS::specific_total_enthalpy;
440 :
441 : // coupled variables
442 57 : params.set<CoupledName>(NS::density) = {NS::density};
443 57 : params.set<CoupledName>(NS::total_energy_density) = {NS::total_energy_density};
444 57 : params.set<CoupledName>(NS::pressure) = {_pressure_variable_name};
445 :
446 19 : _problem->addAuxKernel(kernel_type, "specific_total_enthalpy_auxkernel", params);
447 38 : }
448 :
449 : void
450 38 : CNSAction::addNSVelocityAux(unsigned int component)
451 : {
452 38 : const std::string kernel_type = "NSVelocityAux";
453 38 : const static std::string velocities[3] = {NS::velocity_x, NS::velocity_y, NS::velocity_z};
454 38 : const static std::string momentums[3] = {NS::momentum_x, NS::momentum_y, NS::momentum_z};
455 :
456 38 : InputParameters params = _factory.getValidParams(kernel_type);
457 76 : params.set<AuxVariableName>("variable") = velocities[component];
458 :
459 : // coupled variables
460 114 : params.set<CoupledName>(NS::density) = {NS::density};
461 114 : params.set<CoupledName>("momentum") = {momentums[component]};
462 38 : params.set<UserObjectName>("fluid_properties") = _fp_name;
463 :
464 38 : _problem->addAuxKernel(kernel_type, velocities[component] + "_auxkernel", params);
465 76 : }
466 :
467 : void
468 38 : CNSAction::addPressureOrTemperatureAux(const std::string & kernel_type)
469 : {
470 38 : InputParameters params = _factory.getValidParams(kernel_type);
471 38 : std::string var_name = (kernel_type == "PressureAux" ? _pressure_variable_name : NS::temperature);
472 76 : params.set<AuxVariableName>("variable") = var_name;
473 :
474 : // coupled variables
475 114 : params.set<CoupledName>("e") = {NS::specific_internal_energy};
476 114 : params.set<CoupledName>("v") = {NS::specific_volume};
477 38 : params.set<UserObjectName>("fp") = _fp_name;
478 :
479 76 : _problem->addAuxKernel(kernel_type, var_name + "_auxkernel", params);
480 38 : }
481 :
482 : void
483 19 : CNSAction::addNSMassInviscidFlux()
484 : {
485 19 : const std::string kernel_type = "NSMassInviscidFlux";
486 19 : InputParameters params = _factory.getValidParams(kernel_type);
487 38 : params.set<NonlinearVariableName>("variable") = NS::density;
488 19 : setKernelCommonParams(params);
489 19 : _problem->addKernel(kernel_type, "rho_if", params);
490 38 : }
491 :
492 : void
493 38 : CNSAction::addNSMomentumInviscidFlux(unsigned int component)
494 : {
495 38 : const static std::string momentums[3] = {NS::momentum_x, NS::momentum_y, NS::momentum_z};
496 38 : const std::string kernel_type = "NSMomentumInviscidFlux";
497 38 : InputParameters params = _factory.getValidParams(kernel_type);
498 76 : params.set<NonlinearVariableName>("variable") = momentums[component];
499 38 : setKernelCommonParams(params);
500 :
501 : // Extra stuff needed by momentum Kernels
502 114 : params.set<CoupledName>(NS::pressure) = {_pressure_variable_name};
503 38 : params.set<unsigned int>("component") = component;
504 :
505 : // Add the Kernel
506 38 : _problem->addKernel(kernel_type, momentums[component] + std::string("if"), params);
507 76 : }
508 :
509 : void
510 19 : CNSAction::addNSEnergyInviscidFlux()
511 : {
512 19 : const std::string kernel_type = "NSEnergyInviscidFlux";
513 19 : InputParameters params = _factory.getValidParams(kernel_type);
514 38 : params.set<NonlinearVariableName>("variable") = NS::total_energy_density;
515 19 : setKernelCommonParams(params);
516 :
517 : // Extra stuff needed by energy equation
518 57 : params.set<CoupledName>(NS::specific_total_enthalpy) = {NS::specific_total_enthalpy};
519 :
520 : // Add the Kernel
521 19 : _problem->addKernel(kernel_type, "rhoE_if", params);
522 38 : }
523 :
524 : void
525 19 : CNSAction::addNSMassWeakStagnationBC()
526 : {
527 19 : const std::string kernel_type = "NSMassWeakStagnationBC";
528 19 : InputParameters params = _factory.getValidParams(kernel_type);
529 38 : params.set<NonlinearVariableName>("variable") = NS::density;
530 19 : setBCCommonParams(params);
531 :
532 38 : for (unsigned int i = 0; i < _stagnation_boundary.size(); ++i)
533 : {
534 19 : setStagnationBCCommonParams(params, i);
535 38 : _problem->addBoundaryCondition(
536 38 : kernel_type, "weak_stagnation_mass_inflow_" + Moose::stringify(i), params);
537 : }
538 38 : }
539 :
540 : void
541 19 : CNSAction::addNSEnergyWeakStagnationBC()
542 : {
543 19 : const std::string kernel_type = "NSEnergyWeakStagnationBC";
544 19 : InputParameters params = _factory.getValidParams(kernel_type);
545 38 : params.set<NonlinearVariableName>("variable") = NS::total_energy_density;
546 19 : setBCCommonParams(params);
547 38 : for (unsigned int i = 0; i < _stagnation_boundary.size(); ++i)
548 : {
549 19 : setStagnationBCCommonParams(params, i);
550 38 : _problem->addBoundaryCondition(
551 38 : kernel_type, "weak_stagnation_energy_inflow_" + Moose::stringify(i), params);
552 : }
553 38 : }
554 :
555 : void
556 38 : CNSAction::addNSMomentumWeakStagnationBC(unsigned int component)
557 : {
558 38 : const static std::string momentums[3] = {NS::momentum_x, NS::momentum_y, NS::momentum_z};
559 :
560 : // Convective part
561 : {
562 38 : const std::string kernel_type = "NSMomentumConvectiveWeakStagnationBC";
563 38 : InputParameters params = _factory.getValidParams(kernel_type);
564 76 : params.set<NonlinearVariableName>("variable") = momentums[component];
565 38 : setBCCommonParams(params);
566 : // Momentum BCs also need the component.
567 38 : params.set<unsigned int>("component") = component;
568 76 : for (unsigned int i = 0; i < _stagnation_boundary.size(); ++i)
569 : {
570 38 : setStagnationBCCommonParams(params, i);
571 76 : _problem->addBoundaryCondition(kernel_type,
572 76 : std::string("weak_stagnation_") + momentums[component] +
573 114 : std::string("_convective_inflow_") + Moose::stringify(i),
574 : params);
575 : }
576 38 : }
577 :
578 : // Pressure part
579 : {
580 38 : const std::string kernel_type = "NSMomentumPressureWeakStagnationBC";
581 38 : InputParameters params = _factory.getValidParams(kernel_type);
582 76 : params.set<NonlinearVariableName>("variable") = momentums[component];
583 38 : setBCCommonParams(params);
584 : // Momentum BCs also need the component.
585 38 : params.set<unsigned int>("component") = component;
586 :
587 76 : for (unsigned int i = 0; i < _stagnation_boundary.size(); ++i)
588 : {
589 38 : setStagnationBCCommonParams(params, i);
590 :
591 76 : _problem->addBoundaryCondition(kernel_type,
592 76 : std::string("weak_stagnation_") + momentums[component] +
593 114 : std::string("_pressure_inflow_") + Moose::stringify(i),
594 : params);
595 : }
596 38 : }
597 38 : }
598 :
599 : void
600 38 : CNSAction::addNoPenetrationBC(unsigned int component)
601 : {
602 38 : const static std::string momentums[3] = {NS::momentum_x, NS::momentum_y, NS::momentum_z};
603 38 : const std::string kernel_type = "NSPressureNeumannBC";
604 38 : InputParameters params = _factory.getValidParams(kernel_type);
605 76 : params.set<NonlinearVariableName>("variable") = momentums[component];
606 38 : setBCCommonParams(params);
607 :
608 : // These BCs also need the component and couping to the pressure.
609 38 : params.set<unsigned int>("component") = component;
610 114 : params.set<CoupledName>(NS::pressure) = {_pressure_variable_name};
611 :
612 38 : params.set<std::vector<BoundaryName>>("boundary") = _no_penetration_boundary;
613 76 : _problem->addBoundaryCondition(
614 38 : kernel_type, momentums[component] + std::string("_no_penetration"), params);
615 76 : }
616 :
617 : void
618 19 : CNSAction::addNSMassUnspecifiedNormalFlowBC()
619 : {
620 19 : const std::string kernel_type = "NSMassUnspecifiedNormalFlowBC";
621 19 : InputParameters params = _factory.getValidParams(kernel_type);
622 38 : params.set<NonlinearVariableName>("variable") = NS::density;
623 19 : setBCCommonParams(params);
624 38 : for (unsigned int i = 0; i < _static_pressure_boundary.size(); ++i)
625 : {
626 57 : params.set<std::vector<BoundaryName>>("boundary") = {_static_pressure_boundary[i]};
627 19 : params.set<Real>("specified_pressure") = _static_pressure[i];
628 38 : _problem->addBoundaryCondition(kernel_type, "mass_outflow_" + Moose::stringify(i), params);
629 : }
630 38 : }
631 :
632 : void
633 38 : CNSAction::addNSMomentumInviscidSpecifiedPressureBC(unsigned int component)
634 : {
635 38 : const static std::string momentums[3] = {NS::momentum_x, NS::momentum_y, NS::momentum_z};
636 38 : const std::string kernel_type = "NSMomentumInviscidSpecifiedPressureBC";
637 38 : InputParameters params = _factory.getValidParams(kernel_type);
638 76 : params.set<NonlinearVariableName>("variable") = momentums[component];
639 38 : setBCCommonParams(params);
640 :
641 : // These BCs also need the component.
642 38 : params.set<unsigned int>("component") = component;
643 :
644 76 : for (unsigned int i = 0; i < _static_pressure_boundary.size(); ++i)
645 : {
646 114 : params.set<std::vector<BoundaryName>>("boundary") = {_static_pressure_boundary[i]};
647 38 : params.set<Real>("specified_pressure") = _static_pressure[i];
648 76 : _problem->addBoundaryCondition(
649 : kernel_type,
650 76 : momentums[component] + std::string("_specified_pressure_outflow_") + Moose::stringify(i),
651 : params);
652 : }
653 76 : }
654 :
655 : void
656 19 : CNSAction::addNSEnergyInviscidSpecifiedPressureBC()
657 : {
658 19 : const std::string kernel_type = "NSEnergyInviscidSpecifiedPressureBC";
659 19 : InputParameters params = _factory.getValidParams(kernel_type);
660 38 : params.set<NonlinearVariableName>("variable") = NS::total_energy_density;
661 19 : setBCCommonParams(params);
662 : // This BC also requires the current value of the temperature.
663 57 : params.set<CoupledName>(NS::temperature) = {NS::temperature};
664 38 : for (unsigned int i = 0; i < _static_pressure_boundary.size(); ++i)
665 : {
666 57 : params.set<std::vector<BoundaryName>>("boundary") = {_static_pressure_boundary[i]};
667 19 : params.set<Real>("specified_pressure") = _static_pressure[i];
668 38 : _problem->addBoundaryCondition(
669 38 : kernel_type, "rhoE_specified_pressure_outflow_" + Moose::stringify(i), params);
670 : }
671 38 : }
672 :
673 : void
674 152 : CNSAction::setKernelCommonParams(InputParameters & params)
675 : {
676 304 : params.set<std::vector<SubdomainName>>("block") = _blocks;
677 :
678 : // coupled variables
679 456 : params.set<CoupledName>(NS::density) = {NS::density};
680 456 : params.set<CoupledName>(NS::total_energy_density) = {NS::total_energy_density};
681 :
682 : // Couple the appropriate number of velocities
683 152 : coupleVelocities(params);
684 152 : coupleMomentums(params);
685 :
686 : // FluidProperties object
687 152 : params.set<UserObjectName>("fluid_properties") = _fp_name;
688 152 : }
689 :
690 : void
691 228 : CNSAction::setBCCommonParams(InputParameters & params)
692 : {
693 : // coupled variables
694 684 : params.set<CoupledName>(NS::density) = {NS::density};
695 684 : params.set<CoupledName>(NS::total_energy_density) = {NS::total_energy_density};
696 :
697 : // Couple the appropriate number of velocities
698 228 : coupleVelocities(params);
699 228 : coupleMomentums(params);
700 :
701 : // FluidProperties object
702 228 : params.set<UserObjectName>("fluid_properties") = _fp_name;
703 228 : }
704 :
705 : void
706 114 : CNSAction::setStagnationBCCommonParams(InputParameters & params, unsigned int i)
707 : {
708 342 : params.set<std::vector<BoundaryName>>("boundary") = {_stagnation_boundary[i]};
709 114 : params.set<Real>("stagnation_pressure") = _stagnation_pressure[i];
710 114 : params.set<Real>("stagnation_temperature") = _stagnation_temperature[i];
711 114 : params.set<Real>("sx") = _stagnation_direction[_dim * i];
712 114 : if (_dim == 1)
713 0 : params.set<Real>("sy") = 0;
714 114 : if (_dim >= 2)
715 114 : params.set<Real>("sy") = _stagnation_direction[_dim * i + 1];
716 114 : if (_dim >= 3)
717 0 : params.set<Real>("sz") = _stagnation_direction[_dim * i + 2];
718 114 : }
719 :
720 : void
721 418 : CNSAction::coupleVelocities(InputParameters & params)
722 : {
723 1254 : params.set<CoupledName>(NS::velocity_x) = {NS::velocity_x};
724 :
725 418 : if (_dim >= 2)
726 1254 : params.set<CoupledName>(NS::velocity_y) = {NS::velocity_y};
727 :
728 418 : if (_dim >= 3)
729 0 : params.set<CoupledName>(NS::velocity_z) = {NS::velocity_z};
730 418 : }
731 :
732 : void
733 380 : CNSAction::coupleMomentums(InputParameters & params)
734 : {
735 1140 : params.set<CoupledName>(NS::momentum_x) = {NS::momentum_x};
736 :
737 380 : if (_dim >= 2)
738 1140 : params.set<CoupledName>(NS::momentum_y) = {NS::momentum_y};
739 :
740 380 : if (_dim >= 3)
741 0 : params.set<CoupledName>(NS::momentum_z) = {NS::momentum_z};
742 380 : }
|