https://mooseframework.inl.gov
Loading...
Searching...
No Matches
WCNSLinearFVFlowPhysics.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
12#include "NSFVBase.h"
14#include "RhieChowMassFlux.h"
15#include "INSFVTimeKernel.h"
16#include "MapConversionUtils.h"
17#include "NSFVUtils.h"
18#include "NS.h"
19
21registerMooseAction("NavierStokesApp", WCNSLinearFVFlowPhysics, "add_interpolation_method_physics");
22registerMooseAction("NavierStokesApp", WCNSLinearFVFlowPhysics, "add_linear_fv_kernel");
23registerMooseAction("NavierStokesApp", WCNSLinearFVFlowPhysics, "add_linear_fv_bc");
24registerMooseAction("NavierStokesApp", WCNSLinearFVFlowPhysics, "add_functor_material");
25
28{
31 "Define the Navier Stokes weakly-compressible equations with the linear "
32 "solver implementation of the SIMPLE scheme");
33 params.set<MooseEnum>("momentum_advection_interpolation") = NS::fvAdvectedInterpolationMethods();
34 params.addParam<InterpolationMethodName>(
35 "momentum_advection_interpolation_method_name",
36 "Name of an externally defined FVInterpolationMethod to use for momentum advection. When "
37 "provided, this overrides 'momentum_advection_interpolation'.");
38
39 params.addParam<bool>(
40 "orthogonality_correction", false, "Whether to use orthogonality correction");
41 params.renameParam("orthogonality_correction", "use_nonorthogonal_correction", "");
42 params.addParam<MooseEnum>(
43 "pressure_diffusion_interpolation",
45 "The face interpolation method for Ainv in the pressure correction diffusion term.");
46 params.addParamNamesToGroup("pressure_diffusion_interpolation", "Numerical scheme");
47 params.set<unsigned short>("ghost_layers") = 1;
48
49 // This will be adapted based on the dimension
50 params.set<std::vector<SolverSystemName>>("system_names") = {
51 "u_system", "v_system", "w_system", "pressure_system"};
52
53 // Implemented in the executioner
54 params.suppressParameter<MooseEnum>("pinned_pressure_type");
55 params.suppressParameter<Point>("pinned_pressure_point");
56 params.suppressParameter<PostprocessorName>("pinned_pressure_value");
57
58 // Not supported
59 params.suppressParameter<bool>("add_flow_equations");
60 params.set<bool>("porous_medium_treatment") = false;
61 params.suppressParameter<bool>("porous_medium_treatment");
62 params.set<MooseFunctorName>("porosity") = "1";
63 params.suppressParameter<MooseFunctorName>("porosity");
64 params.suppressParameter<MooseEnum>("mu_interp_method");
65 // Not needed
66 params.suppressParameter<bool>("add_flow_equations");
67 params.suppressParameter<MooseEnum>("preconditioning");
68
69 // No other options so far
70 params.set<MooseEnum>("velocity_interpolation") = "rc";
71 params.suppressParameter<MooseEnum>("velocity_interpolation");
72
73 // Rhie-Chow
74 params.transferParam<MooseEnum>(RhieChowMassFlux::validParams(), "pressure_projection_method");
75 params.addParamNamesToGroup("momentum_advection_interpolation_method_name", "Numerical scheme");
76
77 return params;
78}
79
81 : WCNSFVFlowPhysicsBase(parameters),
82 _non_orthogonal_correction(getParam<bool>("orthogonality_correction"))
83{
84 addRequiredPhysicsTask("add_interpolation_method_physics");
85
87 paramError("porous_medium_treatment", "Porous media unsupported");
89 mooseError("Not supported");
90
91 if (_hydraulic_separators.size())
92 paramError("hydraulic_separator_sidesets",
93 "Flow separators are not supported yet for linearFV!");
94 if (getParam<bool>("pin_pressure"))
95 paramError("pin_pressure",
96 "Pressure pinning is implemented in the executioner for the linear finite volume "
97 "segregated solves");
98}
99
100void
102{
103 if (!_has_flow_equations || isParamValid("momentum_advection_interpolation_method_name"))
104 return;
105
106 addFVAdvectedInterpolationMethod(getParam<MooseEnum>("momentum_advection_interpolation"));
107}
108
109void
111{
113 // TODO Add support for multi-system by either:
114 // - creating the problem in the Physics or,
115 // - checking that the right systems are being created
116 getProblem().needSolutionState(2, Moose::SolutionIterationType::Nonlinear);
117 // TODO Ban all other nonlinear Physics for now
118
119 // Fix the default system names if using a different dimension
120 if (!isParamSetByUser("system_name"))
121 {
122 if (dimension() == 1)
123 _system_names = {"u_system", "pressure_system"};
124 else if (dimension() == 2)
125 _system_names = {"u_system", "v_system", "pressure_system"};
126 }
127}
128
129void
131{
133 return;
134
135 for (const auto d : make_range(dimension()))
138
139 const std::vector<std::string> v_short = {"u", "v", "w"};
140
141 // Check number of variables
142 if (_velocity_names.size() != dimension() && _velocity_names.size() != 3)
143 paramError("velocity_variable",
144 "The number of velocity variable names supplied to the NSFVAction is not " +
145 Moose::stringify(dimension()) + " (mesh dimension)" +
146 ((dimension() == 3) ? "" : " or 3!") + "\nVelocity variables " +
148
149 // Velocities
150 for (const auto d : make_range(dimension()))
151 {
152 if (!shouldCreateVariable(_velocity_names[d], _blocks, /*error if aux*/ true))
153 reportPotentiallyMissedParameters({"system_names"}, "MooseLinearVariableFVReal");
154 else if (_define_variables)
155 {
156 std::string variable_type = "MooseLinearVariableFVReal";
157
158 auto params = getFactory().getValidParams(variable_type);
159
160 addSharedSolverVariable(variable_type, _velocity_names[d], params);
161 }
162 else
163 paramError("velocity_variable",
164 "Variable (" + _velocity_names[d] +
165 ") supplied to the WCNSLinearFVFlowPhysics does not exist!");
166 }
167
168 // Pressure
169 if (!shouldCreateVariable(_pressure_name, _blocks, /*error if aux*/ true))
170 reportPotentiallyMissedParameters({"system_names"}, "MooseLinearVariableFVReal");
171 else if (_define_variables)
172 {
173 const auto pressure_type = "MooseLinearVariableFVReal";
174
175 auto params = getFactory().getValidParams(pressure_type);
176
177 addSharedSolverVariable(pressure_type, _pressure_name, params);
178 }
179 else
180 paramError("pressure_variable",
181 "Variable (" + _pressure_name +
182 ") supplied to the WCNSLinearFVFlowPhysics does not exist!");
183}
184
185void
187{
189 return;
190
191 // Pressure correction equation: divergence of momentum
193
194 // Momentum equation: time derivative
195 if (isTransient())
197
198 // Momentum equation: flux terms
200
201 // Momentum equation: pressure term
203
204 // Momentum equation: friction term
205 if (_friction_types.size())
207
208 // Momentum equation: gravity source term
210
211 // Momentum equation: boussinesq approximation
212 if (getParam<bool>("boussinesq_approximation"))
214}
215
216void
218{
219 {
220 std::string kernel_type = "LinearFVPressureCorrectionDiffusion";
221 std::string kernel_name = prefix() + "p_diffusion";
222
223 InputParameters params = getFactory().getValidParams(kernel_type);
224 assignBlocks(params, _blocks);
225 params.set<LinearVariableName>("variable") = _pressure_name;
226 params.set<MooseFunctorName>("diffusion_tensor") = "Ainv";
227 params.set<bool>("use_nonorthogonal_correction") = _non_orthogonal_correction;
228
229 getProblem().addLinearFVKernel(kernel_type, kernel_name, params);
230 }
231 {
232 std::string kernel_type = "LinearFVDivergence";
233 std::string kernel_name = prefix() + "HbyA_divergence";
234
235 InputParameters params = getFactory().getValidParams(kernel_type);
236 assignBlocks(params, _blocks);
237 params.set<LinearVariableName>("variable") = _pressure_name;
238 params.set<MooseFunctorName>("face_flux") = "HbyA";
239 params.set<bool>("force_boundary_execution") = true;
240
241 getProblem().addLinearFVKernel(kernel_type, kernel_name, params);
242 }
243}
244
245void
247{
248 std::string kernel_type = "LinearFVTimeDerivative";
249 std::string kernel_name = prefix() + "ins_momentum_time";
250
251 InputParameters params = getFactory().getValidParams(kernel_type);
252 assignBlocks(params, _blocks);
253 params.set<MooseFunctorName>("factor") = _density_name;
254
255 for (const auto d : make_range(dimension()))
256 {
257 params.set<LinearVariableName>("variable") = _velocity_names[d];
258 if (shouldCreateTimeDerivative(_velocity_names[d], _blocks, /*error if already defined*/ false))
259 getProblem().addLinearFVKernel(kernel_type, kernel_name + "_" + NS::directions[d], params);
260 }
261}
262
263void
265{
266 const auto momentum_advection_method_name =
267 isParamValid("momentum_advection_interpolation_method_name")
268 ? getParam<InterpolationMethodName>("momentum_advection_interpolation_method_name")
269 : InterpolationMethodName(
270 std::string(getParam<MooseEnum>("momentum_advection_interpolation")));
271
272 const std::string u_names[3] = {"u", "v", "w"};
273 std::string kernel_type = "LinearWCNSFVMomentumFlux";
274 std::string kernel_name = prefix() + "ins_momentum_flux_";
275
276 InputParameters params = getFactory().getValidParams(kernel_type);
277 assignBlocks(params, _blocks);
279 params.set<MooseFunctorName>(NS::mu) = _dynamic_viscosity_name;
280 else
281 params.set<MooseFunctorName>(NS::mu) = NS::mu_eff;
282
283 params.set<UserObjectName>("rhie_chow_user_object") = rhieChowUOName();
284 params.set<InterpolationMethodName>("advected_interp_method_name") =
285 momentum_advection_method_name;
286 params.set<bool>("use_nonorthogonal_correction") = _non_orthogonal_correction;
287 params.set<bool>("use_deviatoric_terms") = includeSymmetrizedViscousStress();
288
289 for (unsigned int i = 0; i < dimension(); ++i)
290 params.set<SolverVariableName>(u_names[i]) = _velocity_names[i];
291
292 for (const auto d : make_range(dimension()))
293 {
294 params.set<LinearVariableName>("variable") = _velocity_names[d];
295 params.set<MooseEnum>("momentum_component") = NS::directions[d];
296
297 getProblem().addLinearFVKernel(kernel_type, kernel_name + NS::directions[d], params);
298 }
299}
300
301void
303{
304 std::string kernel_type = "LinearFVMomentumPressure";
305 std::string kernel_name = prefix() + "ins_momentum_pressure_";
306
307 InputParameters params = getFactory().getValidParams(kernel_type);
308 assignBlocks(params, _blocks);
309 params.set<VariableName>("pressure") = _pressure_name;
310
311 for (const auto d : make_range(dimension()))
312 {
313 params.set<MooseEnum>("momentum_component") = NS::directions[d];
314 params.set<LinearVariableName>("variable") = _velocity_names[d];
315 getProblem().addLinearFVKernel(kernel_type, kernel_name + NS::directions[d], params);
316 }
317}
318
319void
321{
322 unsigned int num_friction_blocks = _friction_blocks.size();
323 unsigned int num_used_blocks = num_friction_blocks ? num_friction_blocks : 1;
324
325 const std::string kernel_type = "LinearFVMomentumFriction";
326 InputParameters params = getFactory().getValidParams(kernel_type);
327
328 for (const auto block_i : make_range(num_used_blocks))
329 {
330 std::string block_name = "";
331 if (num_friction_blocks)
332 {
333 params.set<std::vector<SubdomainName>>("block") = _friction_blocks[block_i];
334 block_name = Moose::stringify(_friction_blocks[block_i]);
335 }
336 else
337 {
338 assignBlocks(params, _blocks);
339 block_name = std::to_string(block_i);
340 }
341
342 for (const auto d : make_range(dimension()))
343 {
344 params.set<LinearVariableName>("variable") = _velocity_names[d];
345 params.set<MooseEnum>("momentum_component") = NS::directions[d];
346 for (unsigned int type_i = 0; type_i < _friction_types[block_i].size(); ++type_i)
347 {
348 const auto upper_name = MooseUtils::toUpper(_friction_types[block_i][type_i]);
349 if (upper_name == "DARCY")
350 {
351 params.set<MooseFunctorName>(NS::mu) = _dynamic_viscosity_name;
352 params.set<MooseFunctorName>("Darcy_name") = _friction_coeffs[block_i][type_i];
353 }
354 else
355 paramError("friction_types",
356 "Friction type '",
357 _friction_types[block_i][type_i],
358 "' is not implemented");
359 }
360
361 getProblem().addLinearFVKernel(kernel_type,
362 prefix() + "momentum_friction_" + block_name + "_" +
364 params);
365 }
366 }
367}
368
369void
371{
373 {
374 std::string kernel_type = "LinearFVSource";
375 std::string kernel_name = prefix() + "ins_momentum_gravity_";
376
377 InputParameters params = getFactory().getValidParams(kernel_type);
378 assignBlocks(params, _blocks);
379 const auto gravity_vector = getParam<RealVectorValue>("gravity");
380 const std::vector<std::string> comp_axis({"x", "y", "z"});
381
382 for (const auto d : make_range(dimension()))
383 if (gravity_vector(d) != 0)
384 {
385 params.set<MooseFunctorName>("source_density") = "rho_g_" + comp_axis[d];
386 params.set<LinearVariableName>("variable") = _velocity_names[d];
387
388 getProblem().addLinearFVKernel(kernel_type, kernel_name + NS::directions[d], params);
389 }
390 }
391}
392
393void
395{
396 if (_compressibility == "weakly-compressible")
397 paramError("boussinesq_approximation",
398 "We cannot use boussinesq approximation while running in weakly-compressible mode!");
399
400 std::string kernel_type = "LinearFVMomentumBoussinesq";
401 std::string kernel_name = prefix() + "ins_momentum_boussinesq_";
402
403 InputParameters params = getFactory().getValidParams(kernel_type);
404 assignBlocks(params, _blocks);
405 params.set<VariableName>(NS::T_fluid) = _fluid_temperature_name;
406 params.set<MooseFunctorName>(NS::density) = _density_gravity_name;
407 params.set<RealVectorValue>("gravity") = getParam<RealVectorValue>("gravity");
408 params.set<Real>("ref_temperature") = getParam<Real>("ref_temperature");
409 params.set<MooseFunctorName>("alpha_name") = getParam<MooseFunctorName>("thermal_expansion");
410
411 for (const auto d : make_range(dimension()))
412 {
413 params.set<MooseEnum>("momentum_component") = NS::directions[d];
414 params.set<LinearVariableName>("variable") = _velocity_names[d];
415
416 getProblem().addLinearFVKernel(kernel_type, kernel_name + NS::directions[d], params);
417 }
418}
419
420void
422{
423 // Check the size of the BC parameters
424 unsigned int num_velocity_functor_inlets = 0;
425 for (const auto & [bdy, momentum_inlet_type] : _momentum_inlet_types)
426 if (momentum_inlet_type == "fixed-velocity" || momentum_inlet_type == "fixed-pressure")
427 num_velocity_functor_inlets++;
428
429 if (num_velocity_functor_inlets != _momentum_inlet_functors.size())
430 paramError("momentum_inlet_functors",
431 "Size (" + std::to_string(_momentum_inlet_functors.size()) +
432 ") is not the same as the number of entries in the momentum_inlet_types "
433 "subvector for fixed-velocities/pressures functors (size " +
434 std::to_string(num_velocity_functor_inlets) + ")");
435
436 unsigned int velocity_pressure_counter = 0;
437 for (const auto & [inlet_bdy, momentum_inlet_type] : _momentum_inlet_types)
438 {
439 if (momentum_inlet_type == "fixed-velocity")
440 {
441 const std::string bc_type = "LinearFVAdvectionDiffusionFunctorDirichletBC";
442 InputParameters params = getFactory().getValidParams(bc_type);
443 params.set<std::vector<BoundaryName>>("boundary") = {inlet_bdy};
444 if (_momentum_inlet_functors.size() < velocity_pressure_counter + 1)
445 paramError("momentum_inlet_functors",
446 "More non-flux inlets than inlet functors (" +
447 std::to_string(_momentum_inlet_functors.size()) + ")");
448
449 // Check that enough functors have been provided for the dimension of the problem
450 const auto momentum_functors = libmesh_map_find(_momentum_inlet_functors, inlet_bdy);
451 if (momentum_functors.size() < dimension())
452 paramError("momentum_inlet_functors",
453 "Subvector for boundary '" + inlet_bdy + "' (size " +
454 std::to_string(momentum_functors.size()) +
455 ") is not the same size as the number of dimensions of the physics (" +
456 std::to_string(dimension()) + ")");
457
458 for (const auto d : make_range(dimension()))
459 {
460 params.set<LinearVariableName>("variable") = _velocity_names[d];
461 params.set<MooseFunctorName>("functor") = momentum_functors[d];
462
463 getProblem().addLinearFVBC(bc_type, _velocity_names[d] + "_" + inlet_bdy, params);
464 }
465 ++velocity_pressure_counter;
466
467 // Add the two term BC expansion for pressure if requested
468 if (getParam<bool>("pressure_two_term_bc_expansion"))
469 {
470 const std::string bc_type = "LinearFVExtrapolatedPressureBC";
471 InputParameters params = getFactory().getValidParams(bc_type);
472 params.set<std::vector<BoundaryName>>("boundary") = {inlet_bdy};
473 params.set<LinearVariableName>("variable") = _pressure_name;
474 params.set<bool>("use_two_term_expansion") = true;
475 getProblem().addLinearFVBC(bc_type,
476 _pressure_name + "_extrapolation_inlet_" +
477 Moose::stringify(inlet_bdy),
478 params);
479 }
480 }
481 else if (momentum_inlet_type == "fixed-pressure")
482 {
483 const std::string bc_type = "LinearFVAdvectionDiffusionFunctorDirichletBC";
484 InputParameters params = getFactory().getValidParams(bc_type);
485 params.set<LinearVariableName>("variable") = _pressure_name;
486 if (_momentum_inlet_functors.size() < velocity_pressure_counter + 1)
487 paramError("momentum_inlet_functors",
488 "More non-flux inlets than inlet functors (" +
489 std::to_string(_momentum_inlet_functors.size()) + ")");
490
491 params.set<MooseFunctorName>("functor") =
492 libmesh_map_find(_momentum_inlet_functors, inlet_bdy)[0];
493 params.set<std::vector<BoundaryName>>("boundary") = {inlet_bdy};
494
495 getProblem().addLinearFVBC(bc_type, _pressure_name + "_" + inlet_bdy, params);
496 ++velocity_pressure_counter;
497 }
498 else
499 mooseError("Unsupported inlet boundary condition type: ", momentum_inlet_type);
500 }
501}
502
503void
505{
506 // Check the BCs size
507 unsigned int num_pressure_outlets = 0;
508 for (const auto & [bdy, momentum_outlet_type] : _momentum_outlet_types)
509 if (momentum_outlet_type == "fixed-pressure" ||
510 momentum_outlet_type == "fixed-pressure-zero-gradient")
511 num_pressure_outlets++;
512
513 if (num_pressure_outlets != _pressure_functors.size())
514 paramError("pressure_functors",
515 "Size (" + std::to_string(_pressure_functors.size()) +
516 ") is not the same as the number of pressure outlet boundaries in "
517 "'fixed-pressure/fixed-pressure-zero-gradient' (size " +
518 std::to_string(num_pressure_outlets) + ")");
519
520 const std::string u_names[3] = {"u", "v", "w"};
521 for (const auto & [outlet_bdy, momentum_outlet_type] : _momentum_outlet_types)
522 {
523 // Zero tangeantial gradient condition on velocity
524 if (momentum_outlet_type == "zero-gradient" || momentum_outlet_type == "fixed-pressure" ||
525 momentum_outlet_type == "fixed-pressure-zero-gradient")
526 {
527 const std::string bc_type = "LinearFVAdvectionDiffusionOutflowBC";
528 InputParameters params = getFactory().getValidParams(bc_type);
529 params.set<std::vector<BoundaryName>>("boundary") = {outlet_bdy};
530 params.set<bool>("use_two_term_expansion") = getParam<bool>("momentum_two_term_bc_expansion");
531
532 for (const auto d : make_range(dimension()))
533 {
534 params.set<LinearVariableName>("variable") = _velocity_names[d];
535 getProblem().addLinearFVBC(bc_type, _velocity_names[d] + "_" + outlet_bdy, params);
536 }
537 }
538
539 // Fixed pressure condition, coming in the pressure correction equation
540 if (momentum_outlet_type == "fixed-pressure" ||
541 momentum_outlet_type == "fixed-pressure-zero-gradient")
542 {
543 const std::string bc_type = "LinearFVAdvectionDiffusionFunctorDirichletBC";
544 InputParameters params = getFactory().getValidParams(bc_type);
545 params.set<LinearVariableName>("variable") = _pressure_name;
546 params.set<MooseFunctorName>("functor") = libmesh_map_find(_pressure_functors, outlet_bdy);
547 params.set<std::vector<BoundaryName>>("boundary") = {outlet_bdy};
548
549 getProblem().addLinearFVBC(bc_type, _pressure_name + "_" + outlet_bdy, params);
550 }
551 }
552}
553
554void
556{
557 const std::string u_names[3] = {"u", "v", "w"};
558 bool has_symmetry_bc = false;
559
560 for (const auto & [boundary_name, momentum_wall_type] : _momentum_wall_types)
561 {
562 if (momentum_wall_type == "noslip")
563 {
564 const std::string bc_type = "LinearFVAdvectionDiffusionFunctorDirichletBC";
565 InputParameters params = getFactory().getValidParams(bc_type);
566 params.set<std::vector<BoundaryName>>("boundary") = {boundary_name};
567
568 for (const auto d : make_range(dimension()))
569 {
570 params.set<LinearVariableName>("variable") = _velocity_names[d];
571 if (_momentum_wall_functors.count(boundary_name) == 0)
572 params.set<MooseFunctorName>("functor") = "0";
573 else
574 params.set<MooseFunctorName>("functor") = _momentum_wall_functors[boundary_name][d];
575
576 getProblem().addLinearFVBC(bc_type, _velocity_names[d] + "_" + boundary_name, params);
577 }
578 }
579 else if (momentum_wall_type == "symmetry")
580 {
581 has_symmetry_bc = true;
582 {
583 const std::string bc_type = "LinearFVVelocitySymmetryBC";
584 InputParameters params = getFactory().getValidParams(bc_type);
585 params.set<std::vector<BoundaryName>>("boundary") = {boundary_name};
586 for (unsigned int d = 0; d < dimension(); ++d)
587 params.set<SolverVariableName>(u_names[d]) = _velocity_names[d];
588
589 for (const auto d : make_range(dimension()))
590 {
591 params.set<LinearVariableName>("variable") = _velocity_names[d];
592 params.set<MooseEnum>("momentum_component") = NS::directions[d];
593
594 getProblem().addLinearFVBC(bc_type, _velocity_names[d] + "_" + boundary_name, params);
595 }
596 }
597 {
598 const std::string bc_type = "LinearFVPressureSymmetryBC";
599 InputParameters params = getFactory().getValidParams(bc_type);
600 params.set<std::vector<BoundaryName>>("boundary") = {boundary_name};
601 params.set<LinearVariableName>("variable") = _pressure_name;
602 params.set<MooseFunctorName>("HbyA_flux") = "HbyA";
603 getProblem().addLinearFVBC(bc_type, _pressure_name + "_" + boundary_name, params);
604 }
605 }
606 else
607 mooseError("Unsupported wall boundary condition type: " + std::string(momentum_wall_type));
608 }
609
610 if (getParam<bool>("pressure_two_term_bc_expansion"))
611 {
612 if (!has_symmetry_bc)
613 {
614 const std::string bc_type = "LinearFVExtrapolatedPressureBC";
615 InputParameters params = getFactory().getValidParams(bc_type);
616 params.set<std::vector<BoundaryName>>("boundary") = _wall_boundaries;
617 params.set<LinearVariableName>("variable") = _pressure_name;
618 params.set<bool>("use_two_term_expansion") = true;
620 bc_type, _pressure_name + "_extrapolation_" + Moose::stringify(_wall_boundaries), params);
621 }
622 else
623 for (const auto & [boundary_name, momentum_wall_type] : _momentum_wall_types)
624 if (momentum_wall_type != "symmetry")
625 {
626 const std::string bc_type = "LinearFVExtrapolatedPressureBC";
627 InputParameters params = getFactory().getValidParams(bc_type);
628 params.set<std::vector<BoundaryName>>("boundary") = {boundary_name};
629 params.set<LinearVariableName>("variable") = _pressure_name;
630 params.set<bool>("use_two_term_expansion") = true;
632 bc_type, _pressure_name + "_extrapolation_" + boundary_name, params);
633 }
634 }
635}
636
637void
639{
640 mooseAssert(!_porous_medium_treatment, "Not implemented");
641 // Rhie Chow user object for interpolation velocities
643}
644
645void
647{
648 mooseAssert(dimension(), "0-dimension not supported");
649
650 // First make sure that we only add this object once
651 // Potential cases:
652 // - there is a flow physics, and an advection one (UO should be added by one)
653 // - there is only an advection physics (UO should be created)
654 // - there are two advection physics on different blocks with set velocities (first one picks)
655 // Counting RC UOs defined on the same blocks seems to be the most fool proof option
656 std::vector<UserObject *> objs;
657 getProblem()
658 .theWarehouse()
659 .query()
660 .condition<AttribSystem>("UserObject")
661 .condition<AttribThread>(0)
662 .queryInto(objs);
663 unsigned int num_rc_uo = 0;
664 for (const auto & obj : objs)
665 if (dynamic_cast<RhieChowMassFlux *>(obj))
666 {
667 const auto rc_obj = dynamic_cast<RhieChowMassFlux *>(obj);
668 if (rc_obj->blocks() == _blocks)
669 num_rc_uo++;
670 // one of the RC user object is defined everywhere
671 else if (rc_obj->blocks().size() == 0 || _blocks.size() == 0)
672 num_rc_uo++;
673 }
674
675 if (num_rc_uo)
676 return;
677
678 const std::string u_names[3] = {"u", "v", "w"};
679 const auto object_type = "RhieChowMassFlux";
680
681 auto params = getFactory().getValidParams(object_type);
682 assignBlocks(params, _blocks);
683 for (unsigned int d = 0; d < dimension(); ++d)
684 params.set<VariableName>(u_names[d]) = _velocity_names[d];
685
686 params.set<VariableName>("pressure") = _pressure_name;
687 params.set<std::string>("p_diffusion_kernel") = prefix() + "p_diffusion";
688 params.set<MooseFunctorName>(NS::density) = _density_name;
689 params.set<MooseEnum>("pressure_projection_method") =
690 getParam<MooseEnum>("pressure_projection_method");
691 params.set<MooseEnum>("pressure_diffusion_interpolation") =
692 getParam<MooseEnum>("pressure_diffusion_interpolation");
693
694 addUserObject(object_type, rhieChowUOName(), params);
695}
696
697std::vector<UserObjectName>
702
703void
705{
706 if (parameters().isParamValid("gravity"))
707 {
708 const auto gravity_vector = getParam<RealVectorValue>("gravity");
709 const std::vector<std::string> comp_axis({"x", "y", "z"});
710 for (const auto d : make_range(dimension()))
711 if (gravity_vector(d) != 0)
712 {
713 // Add rho * g functor for each relevant direction
714 // TODO: we could avoid using an AD functor material for non-AD density functor
715 auto params = getFactory().getValidParams("ADParsedFunctorMaterial");
716 assignBlocks(params, _blocks);
717 params.set<std::string>("expression") =
718 _density_gravity_name + " * " + std::to_string(gravity_vector(d));
720 params.set<std::vector<std::string>>("functor_names") = {_density_gravity_name};
721 params.set<std::string>("property_name") = "rho_g_" + comp_axis[d];
722 // We don't output this helper material
724 "ADParsedFunctorMaterial", prefix() + "gravity_helper_" + comp_axis[d], params);
725 }
726 }
727}
728
729unsigned short
registerMooseAction("NavierStokesApp", WCNSLinearFVFlowPhysics, "add_interpolation_method_physics")
registerWCNSFVFlowPhysicsBaseTasks("NavierStokesApp", WCNSLinearFVFlowPhysics)
void needSolutionState(unsigned int oldest_needed, Moose::SolutionIterationType iteration_type)
virtual void addLinearFVKernel(const std::string &kernel_name, const std::string &name, InputParameters &parameters)
virtual void addMaterial(const std::string &material_name, const std::string &name, InputParameters &parameters)
virtual void addLinearFVBC(const std::string &fv_bc_name, const std::string &name, InputParameters &parameters)
TheWarehouse & theWarehouse() const
InputParameters getValidParams(const std::string &name) const
void suppressParameter(const std::string &name)
void addParamNamesToGroup(const std::string &space_delim_names, const std::string group_name)
void renameParam(const std::string &old_name, const std::string &new_name, const std::string &new_docstring)
void transferParam(const InputParameters &source_param, const std::string &name, const std::string &new_name="", const std::string &new_description="")
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)
T & set(const std::string &name, bool quiet_mode=false)
const InputParameters & parameters() const
void paramError(const std::string &param, Args... args) const
bool isParamSetByUser(const std::string &name) const
void mooseError(Args &&... args) const
bool isParamValid(const std::string &name) const
bool _define_variables
Whether to define variables if they do not exist.
void addFVAdvectedInterpolationMethod(const MooseEnum &interpolation_method)
Add the FVInterpolationMethod object for an advected interpolation method if absent.
virtual FEProblemBase & getProblem()
std::vector< SolverSystemName > _system_names
void addUserObject(const std::string &uo_type, const std::string &uo_name, InputParameters &params)
Factory & getFactory()
bool shouldCreateTimeDerivative(const VariableName &var_name, const std::vector< SubdomainName > &blocks, const bool error_if_already_defined) const
void assignBlocks(InputParameters &params, const std::vector< SubdomainName > &blocks) const
unsigned int dimension() const
void reportPotentiallyMissedParameters(const std::vector< std::string > &param_names, const std::string &object_type, const std::string &object_name="") const
void saveSolverVariableName(const VariableName &var_name)
std::string prefix() const
void addSharedSolverVariable(const std::string &var_type, const VariableName &var_name, InputParameters params)
bool shouldCreateVariable(const VariableName &var_name, const std::vector< SubdomainName > &blocks, const bool error_if_aux)
bool isTransient() const
std::vector< SubdomainName > _blocks
void addRequiredPhysicsTask(const std::string &task)
User object responsible for determining the face fluxes using the Rhie-Chow interpolation in a segreg...
static InputParameters validParams()
Query query()
Base class for Physics which create the Navier Stokes flow equations.
std::map< BoundaryName, MooseEnum > _momentum_outlet_types
Momentum outlet boundary types.
std::vector< std::vector< SubdomainName > > _friction_blocks
Subdomains where we want to have volumetric friction.
static InputParameters validParams()
std::map< BoundaryName, std::vector< MooseFunctorName > > _momentum_wall_functors
Functors describing the momentum for each wall boundary.
std::map< BoundaryName, MooseEnum > _momentum_inlet_types
Momentum inlet boundary types.
std::map< BoundaryName, MooseFunctorName > _pressure_functors
Functors describing the outlet pressure on each boundary.
std::vector< std::vector< std::string > > _friction_types
The friction correlation types used for each block.
const MooseEnum _compressibility
Compressibility type, can be compressible, incompressible or weakly-compressible.
const std::vector< std::string > _velocity_names
Velocity names.
const std::vector< BoundaryName > _wall_boundaries
Boundaries which define a wall (slip/noslip/etc.)
const NonlinearVariableName _pressure_name
Pressure name.
const bool _has_flow_equations
Boolean to keep track of whether the flow equations should be created.
const NonlinearVariableName _fluid_temperature_name
Fluid temperature name.
const bool _porous_medium_treatment
Whether to use the porous medium treatment.
std::map< BoundaryName, std::vector< MooseFunctorName > > _momentum_inlet_functors
Functors describing the momentum inlet for each boundary.
virtual void initializePhysicsAdditional() override
const UserObjectName & rhieChowUOName() const
Return the name of the Rhie Chow user object.
const MooseFunctorName _dynamic_viscosity_name
Name of the dynamic viscosity material property.
std::map< BoundaryName, MooseEnum > _momentum_wall_types
Momentum wall boundary types.
const std::vector< BoundaryName > _hydraulic_separators
Hydraulic separator boundaries.
const bool _solve_for_dynamic_pressure
Whether we are solving for the total or dynamic pressure.
const MooseFunctorName _density_name
Name of the density material property.
const WCNSFVTurbulencePhysicsBase * _turbulence_physics
Can be set to a coupled turbulence physics.
std::vector< std::vector< std::string > > _friction_coeffs
The coefficients used for each item if friction type.
bool includeSymmetrizedViscousStress() const
Whether to include the symmetrized contribution in the viscous stress.
const MooseFunctorName _density_gravity_name
Name of the density material property used for gravity and Boussinesq terms.
Creates all the objects needed to solve the Navier-Stokes equations with the SIMPLE algorithm using t...
virtual void addUserObjects() override
virtual void addSolverVariables() override
virtual void addMomentumPressureKernels() override
virtual void addRhieChowUserObjects() override
Function which adds the RhieChow interpolator user objects for weakly and incompressible formulations...
void addMomentumTimeKernels() override
Functions adding kernels for the incompressible momentum equation If the material properties are not ...
virtual void initializePhysicsAdditional() override
unsigned short getNumberAlgebraicGhostingLayersNeeded() const override
Return the number of algebraic ghosting layers needed.
virtual void addMomentumBoussinesqKernels() override
WCNSLinearFVFlowPhysics(const InputParameters &parameters)
virtual void addInletBC() override
Functions adding boundary conditions for the flow simulation.
virtual void addFVKernels() override
static InputParameters validParams()
virtual void addMomentumFrictionKernels() override
virtual std::vector< UserObjectName > getSuppliedUserObjects() const override
virtual void addOutletBC() override
virtual void addFVInterpolationMethods() override
virtual void addMomentumGravityKernels() override
virtual void addWallsBC() override
void addPressureCorrectionKernels()
Function adding kernels for the incompressible pressure correction equation.
const bool _non_orthogonal_correction
Whether to use the correction term for non-orthogonality.
virtual void addFunctorMaterials() override
std::string toUpper(std::string name)
bool parsesToReal(const std::string &input, Real *parsed_real)
std::string stringify(const T &t)
static const std::string density
Definition NS.h:34
static const std::string T_fluid
Definition NS.h:110
MooseEnum fvFaceInterpolationMethods()
Enum of the interpolation methods supported by FVInterpolationMethod objects.
Definition NSFVUtils.C:85
static const std::string mu
Definition NS.h:127
static const std::string directions[3]
Definition NS.h:23
static const std::string mu_eff
Definition NS.h:133
MooseEnum fvAdvectedInterpolationMethods()
Enum of the advected interpolation methods supported by FVInterpolationMethod objects.
Definition NSFVUtils.C:61