https://mooseframework.inl.gov
Loading...
Searching...
No Matches
WCNSFVFlowPhysics.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
10#include "WCNSFVFlowPhysics.h"
12#include "NSFVBase.h"
15#include "INSFVTimeKernel.h"
16#include "MapConversionUtils.h"
17#include "NS.h"
18
20registerMooseAction("NavierStokesApp", WCNSFVFlowPhysics, "add_fv_kernel");
21registerMooseAction("NavierStokesApp", WCNSFVFlowPhysics, "add_fv_bc");
22
25{
28 "Define the Navier Stokes weakly-compressible mass and momentum equations");
29
30 // Rhie Chow interpolation parameters
31 params.transferParam<Real>(INSFVMomentumAdvection::validParams(), "characteristic_speed");
32 params.addParam<bool>(
33 "time_derivative_contributes_to_RC_coefficients",
34 true,
35 "Whether the time derivative term should contribute to the Rhie Chow coefficients. This adds "
36 "stabilization, but makes the solution dependent on the time step size");
37 params.addParamNamesToGroup("time_derivative_contributes_to_RC_coefficients characteristic_speed",
38 "Numerical scheme");
39
40 // Used for flow mixtures, where one phase is solid / not moving under the action of gravity
41 params.addParam<MooseFunctorName>(
42 "density_for_gravity_terms",
43 "If specified, replaces the 'density' for the Boussinesq and gravity momentum kernels");
44
45 // Additional porous media parameters
46 params.transferParam<unsigned short>(NSFVBase::validParams(), "porosity_smoothing_layers");
47
48 // Techniques to limit or remove oscillations at porosity jump interfaces
49 params.transferParam<MooseEnum>(NSFVBase::validParams(), "porosity_interface_pressure_treatment");
50 params.transferParam<std::vector<BoundaryName>>(NSFVBase::validParams(),
51 "pressure_drop_sidesets");
52 params.transferParam<std::vector<Real>>(NSFVBase::validParams(), "pressure_drop_form_factors");
53
54 // Friction correction, a technique to limit oscillations at friction interfaces
55 params.transferParam<bool>(NSFVBase::validParams(), "use_friction_correction");
56 params.transferParam<Real>(NSFVBase::validParams(), "consistent_scaling");
57
58 // Couple to turbulence physics
59 params.addParam<PhysicsName>("coupled_turbulence_physics",
60 "Turbulence Physics coupled with the flow");
61
62 // Spatial discretization scheme
63 // Specify the numerical schemes for interpolations of velocity and pressure
64 params.transferParam<MooseEnum>(NSFVBase::validParams(), "pressure_face_interpolation");
65 params.transferParam<MooseEnum>(NSFVBase::validParams(), "mass_advection_interpolation");
67 "pressure_allow_expansion_on_bernoulli_faces");
68
69 // Nonlinear solver parameters
70 params.transferParam<Real>(NSFVBase::validParams(), "mass_scaling");
71 params.transferParam<Real>(NSFVBase::validParams(), "momentum_scaling");
72
73 // Parameter groups
74 params.addParamNamesToGroup("coupled_turbulence_physics", "Coupled Physics");
76 "porosity_interface_pressure_treatment pressure_allow_expansion_on_bernoulli_faces "
77 "porosity_smoothing_layers use_friction_correction consistent_scaling "
78 "pressure_drop_sidesets pressure_drop_form_factors",
79 "Flow medium discontinuity treatment");
80 params.addParamNamesToGroup("pressure_face_interpolation "
81 "mass_advection_interpolation momentum_advection_interpolation "
82 "mass_scaling momentum_scaling characteristic_speed",
83 "Numerical scheme");
84
85 // TODO Add default preconditioning and move scaling parameters to a preconditioning group
86
87 return params;
88}
89
91 : WCNSFVFlowPhysicsBase(parameters),
92 _porosity_smoothing_layers(isParamValid("porosity_smoothing_layers")
93 ? getParam<unsigned short>("porosity_smoothing_layers")
94 : 0)
95{
96 _flow_porosity_functor_name = isParamValid("porosity_smoothing_layers") &&
97 getParam<unsigned short>("porosity_smoothing_layers")
100
101 // Most likely to be a mistake
102 if (getParam<bool>("pin_pressure") &&
103 getParam<std::vector<MooseFunctorName>>("pressure_functors").size())
104 paramError("pin_pressure", "Cannot pin the pressure if a pressure boundary exists");
105
106 // Pressure pin checks
107 checkSecondParamSetOnlyIfFirstOneTrue("pin_pressure", "pinned_pressure_type");
108 checkSecondParamSetOnlyIfFirstOneTrue("pin_pressure", "pinned_pressure_value");
109 if (getParam<bool>("pin_pressure"))
110 {
111 if ((std::string(getParam<MooseEnum>("pinned_pressure_type")).find("point") !=
112 std::string::npos) &&
113 !isParamSetByUser("pinned_pressure_point"))
114 paramError("pinned_pressure_point",
115 "This parameter must be set to specify the pinned pressure point");
116 else if ((std::string(getParam<MooseEnum>("pinned_pressure_type")).find("point") ==
117 std::string::npos) &&
118 isParamSetByUser("pinned_pressure_point"))
119 paramError("pinned_pressure_point",
120 "This parameter should not be given by the user with the corresponding "
121 "pinned_pressure_type setting: " +
122 std::string(getParam<MooseEnum>("pinned_pressure_type")) + ".");
123 }
124
125 // Porosity correction checks
126 checkSecondParamSetOnlyIfFirstOneTrue("porous_medium_treatment", "use_friction_correction");
127 checkSecondParamSetOnlyIfFirstOneTrue("use_friction_correction", "consistent_scaling");
128 checkSecondParamSetOnlyIfFirstOneTrue("porous_medium_treatment",
129 "porosity_interface_pressure_treatment");
130 if (getParam<MooseEnum>("porosity_interface_pressure_treatment") != "bernoulli")
131 errorDependentParameter("porosity_interface_pressure_treatment",
132 "bernoulli",
133 {"pressure_allow_expansion_on_bernoulli_faces",
134 "pressure_drop_sidesets",
135 "pressure_drop_form_factors"});
136
137 // Porous media parameters
138 checkSecondParamSetOnlyIfFirstOneTrue("porous_medium_treatment", "porosity_smoothing_layers");
139}
140
141void
143{
145 return;
146
147 for (const auto d : make_range(dimension()))
150
151 // Check number of variables
152 if (_velocity_names.size() != dimension() && _velocity_names.size() != 3)
153 paramError("velocity_variable",
154 "The number of velocity variable names supplied to the NSFVAction is not " +
155 Moose::stringify(dimension()) + " (mesh dimension)" +
156 ((dimension() == 3) ? "" : " or 3!") + "\nVelocity variables " +
158
159 // Velocities
160 for (const auto d : make_range(dimension()))
161 {
162 if (!shouldCreateVariable(_velocity_names[d], _blocks, /*error if aux*/ true))
163 reportPotentiallyMissedParameters({"system_names",
164 "momentum_scaling",
165 "momentum_face_interpolation",
166 "momentum_two_term_bc_expansion"},
167 "INSFVVelocityVariable");
168 else if (_define_variables)
169 {
170 std::string variable_type = "INSFVVelocityVariable";
172 variable_type = "PINSFVSuperficialVelocityVariable";
173
174 auto params = getFactory().getValidParams(variable_type);
175 assignBlocks(params, _blocks); // TODO: check wrt components
176 params.set<std::vector<Real>>("scaling") = {getParam<Real>("momentum_scaling")};
177 params.set<MooseEnum>("face_interp_method") =
178 getParam<MooseEnum>("momentum_face_interpolation");
179 params.set<bool>("two_term_boundary_expansion") =
180 getParam<bool>("momentum_two_term_bc_expansion");
181
182 params.set<SolverSystemName>("solver_sys") = getSolverSystem(_velocity_names[d]);
183 getProblem().addVariable(variable_type, _velocity_names[d], params);
184 }
185 else
186 paramError("velocity_variable",
187 "Variable (" + _velocity_names[d] +
188 ") supplied to the WCNSFVFlowPhysics does not exist!");
189 }
190
191 // Pressure
192 const bool using_bernouilli_pressure_var =
194 getParam<MooseEnum>("porosity_interface_pressure_treatment") != "automatic";
195 const auto pressure_type =
196 using_bernouilli_pressure_var ? "BernoulliPressureVariable" : "INSFVPressureVariable";
197 if (!shouldCreateVariable(_pressure_name, _blocks, /*error if aux*/ true))
198 {
199 std::vector<std::string> potentially_missed = {"system_names",
200 "mass_scaling",
201 "pressure_face_interpolation",
202 "pressure_two_term_bc_expansion"};
203 if (using_bernouilli_pressure_var)
204 {
205 std::vector<std::string> other_missed = {"pressure_allow_expansion_on_bernoulli_faces",
206 "pressure_drop_sidesets",
207 "pressure_drop_form_factors"};
208 potentially_missed.insert(potentially_missed.end(), other_missed.begin(), other_missed.end());
209 }
210 reportPotentiallyMissedParameters(potentially_missed, pressure_type);
211 }
212 else if (_define_variables)
213 {
214 auto params = getFactory().getValidParams(pressure_type);
215 assignBlocks(params, _blocks);
216 params.set<std::vector<Real>>("scaling") = {getParam<Real>("mass_scaling")};
217 params.set<MooseEnum>("face_interp_method") =
218 getParam<MooseEnum>("pressure_face_interpolation");
219 params.set<bool>("two_term_boundary_expansion") =
220 getParam<bool>("pressure_two_term_bc_expansion");
221
222 if (using_bernouilli_pressure_var)
223 {
224 params.set<MooseFunctorName>("u") = _velocity_names[0];
225 if (dimension() >= 2)
226 params.set<MooseFunctorName>("v") = _velocity_names[1];
227 if (dimension() == 3)
228 params.set<MooseFunctorName>("w") = _velocity_names[2];
229 params.set<MooseFunctorName>(NS::porosity) = _porosity_name;
230 params.set<MooseFunctorName>(NS::density) = _density_name;
231 params.set<bool>("allow_two_term_expansion_on_bernoulli_faces") =
232 getParam<bool>("pressure_allow_expansion_on_bernoulli_faces");
233 params.set<std::vector<BoundaryName>>("pressure_drop_sidesets") =
234 getParam<std::vector<BoundaryName>>("pressure_drop_sidesets");
235 params.set<std::vector<Real>>("pressure_drop_form_factors") =
236 getParam<std::vector<Real>>("pressure_drop_form_factors");
237 }
238 params.set<SolverSystemName>("solver_sys") = getSolverSystem(_pressure_name);
239 getProblem().addVariable(pressure_type, _pressure_name, params);
240 }
241 else
242 paramError("pressure_variable",
243 "Variable (" + _pressure_name +
244 ") supplied to the WCNSFVFlowPhysics does not exist!");
245
246 // Add lagrange multiplier for pinning pressure, if needed
247 if (getParam<bool>("pin_pressure"))
248 {
249 auto type = getParam<MooseEnum>("pinned_pressure_type");
250 auto lm_params = getFactory().getValidParams("MooseVariableScalar");
251 lm_params.set<MooseEnum>("family") = "scalar";
252 lm_params.set<MooseEnum>("order") = "first";
253
254 if ((type == "point-value" || type == "average"))
255 {
256 if (!_problem->hasScalarVariable("lambda"))
257 {
258 lm_params.set<SolverSystemName>("solver_sys") = getSolverSystem("lambda");
259 getProblem().addVariable("MooseVariableScalar", "lambda", lm_params);
260 }
261 else
262 reportPotentiallyMissedParameters({"system_names"}, "MooseVariableScalar");
263 }
264 }
265}
266
267void
269{
271 return;
272
273 // Mass equation: time derivative
274 if (_compressibility == "weakly-compressible" &&
275 shouldCreateTimeDerivative(_pressure_name, _blocks, /*error if already defined*/ false))
277
278 // Mass equation: divergence of momentum
280
281 // Pressure pin
282 if (getParam<bool>("pin_pressure"))
284
285 // Momentum equation: time derivative
286 if (isTransient())
288
289 // Momentum equation: momentum advection
291
292 // Momentum equation: momentum viscous stress
295
296 // Momentum equation: pressure term
298
299 // Momentum equation: gravity source term
301
302 // Momentum equation: friction kernels
303 if (_friction_types.size())
305
306 // Momentum equation: boussinesq approximation
307 if (getParam<bool>("boussinesq_approximation"))
309}
310
311void
313{
314 std::string mass_kernel_type = "WCNSFVMassTimeDerivative";
315 std::string kernel_name = prefix() + "wcns_mass_time";
316
318 {
319 mass_kernel_type = "PWCNSFVMassTimeDerivative";
320 kernel_name = prefix() + "pwcns_mass_time";
321 }
322
323 InputParameters params = getFactory().getValidParams(mass_kernel_type);
324 assignBlocks(params, _blocks);
325 params.set<NonlinearVariableName>("variable") = _pressure_name;
326 params.set<MooseFunctorName>(NS::time_deriv(NS::density)) = NS::time_deriv(_density_name);
328 params.set<MooseFunctorName>(NS::porosity) = _flow_porosity_functor_name;
329 getProblem().addFVKernel(mass_kernel_type, kernel_name, params);
330}
331
332void
334{
335 std::string kernel_type = "INSFVMassAdvection";
336 std::string kernel_name = prefix() + "ins_mass_advection";
337
339 {
340 kernel_type = "PINSFVMassAdvection";
341 kernel_name = prefix() + "pins_mass_advection";
342 }
343
344 InputParameters params = getFactory().getValidParams(kernel_type);
345 assignBlocks(params, _blocks);
346 params.set<NonlinearVariableName>("variable") = _pressure_name;
347 params.set<MooseFunctorName>(NS::density) = _density_name;
348 params.set<MooseEnum>("velocity_interp_method") = _velocity_interpolation;
349 params.set<UserObjectName>("rhie_chow_user_object") = rhieChowUOName();
350 params.set<MooseEnum>("advected_interp_method") =
351 getParam<MooseEnum>("mass_advection_interpolation");
352
353 getProblem().addFVKernel(kernel_type, kernel_name, params);
354}
355
356void
358{
359 const auto pin_type = getParam<MooseEnum>("pinned_pressure_type");
360 const auto object_type =
361 (pin_type == "average") ? "FVIntegralValueConstraint" : "FVPointValueConstraint";
362 InputParameters params = getFactory().getValidParams(object_type);
363 if (pin_type != "point-value" && pin_type != "average")
364 return;
365
366 params.set<CoupledName>("lambda") = {"lambda"};
367 params.set<PostprocessorName>("phi0") = getParam<PostprocessorName>("pinned_pressure_value");
368 params.set<NonlinearVariableName>("variable") = _pressure_name;
369 if (pin_type == "point-value")
370 params.set<Point>("point") = getParam<Point>("pinned_pressure_point");
371
372 getProblem().addFVKernel(object_type, prefix() + "ins_mass_pressure_pin", params);
373}
374
375void
377{
378 std::string kernel_type = (_compressibility == "weakly-compressible")
379 ? "WCNSFVMomentumTimeDerivative"
380 : "INSFVMomentumTimeDerivative";
381 std::string kernel_name = prefix() +
382 ((_compressibility == "weakly-compressible") ? "wcns_" : "ins_") +
383 "momentum_time_";
384
386 {
387 // Porosity does not appear in the term
388 kernel_type = (_compressibility == "weakly-compressible") ? "WCNSFVMomentumTimeDerivative"
389 : "PINSFVMomentumTimeDerivative";
390 kernel_name = prefix() + ((_compressibility == "weakly-compressible") ? "pwcns_" : "pins_") +
391 "momentum_time_";
392 }
393
394 InputParameters params = getFactory().getValidParams(kernel_type);
395 assignBlocks(params, _blocks);
396 params.set<MooseFunctorName>(NS::density) = _density_name;
397 if (_compressibility == "weakly-compressible")
398 params.set<MooseFunctorName>(NS::time_deriv(NS::density)) = NS::time_deriv(_density_name);
399
400 params.set<UserObjectName>("rhie_chow_user_object") = rhieChowUOName();
401 params.set<bool>("contribute_to_rc") =
402 getParam<bool>("time_derivative_contributes_to_RC_coefficients");
403
404 for (const auto d : make_range(dimension()))
405 {
406 params.set<NonlinearVariableName>("variable") = _velocity_names[d];
407 params.set<MooseEnum>("momentum_component") = NS::directions[d];
408
409 if (shouldCreateTimeDerivative(_velocity_names[d], _blocks, /*error if already defined*/ false))
410 getProblem().addFVKernel(kernel_type, kernel_name + _velocity_names[d], params);
411 }
412}
413
414void
416{
417 std::string kernel_type = "INSFVMomentumAdvection";
418 std::string kernel_name = prefix() + "ins_momentum_advection_";
419
421 {
422 kernel_type = "PINSFVMomentumAdvection";
423 kernel_name = prefix() + "pins_momentum_advection_";
424 }
425
426 InputParameters params = getFactory().getValidParams(kernel_type);
427 assignBlocks(params, _blocks);
428 params.set<MooseFunctorName>(NS::density) = _density_name;
429 params.set<MooseEnum>("velocity_interp_method") = _velocity_interpolation;
430 params.set<UserObjectName>("rhie_chow_user_object") = rhieChowUOName();
431 params.set<MooseEnum>("advected_interp_method") = _momentum_advection_interpolation;
433 params.set<MooseFunctorName>(NS::porosity) = _flow_porosity_functor_name;
435
436 for (const auto d : make_range(dimension()))
437 {
438 params.set<NonlinearVariableName>("variable") = _velocity_names[d];
439 params.set<MooseEnum>("momentum_component") = NS::directions[d];
440
441 getProblem().addFVKernel(kernel_type, kernel_name + NS::directions[d], params);
442 }
443}
444
445void
447{
448 std::string kernel_type = "INSFVMomentumDiffusion";
449 std::string kernel_name = prefix() + "ins_momentum_diffusion_";
450
452 {
453 kernel_type = "PINSFVMomentumDiffusion";
454 kernel_name = prefix() + "pins_momentum_diffusion_";
455 }
456
457 InputParameters params = getFactory().getValidParams(kernel_type);
458 assignBlocks(params, _blocks);
459 params.set<UserObjectName>("rhie_chow_user_object") = rhieChowUOName();
460 params.set<MooseFunctorName>(NS::mu) = _dynamic_viscosity_name;
461 const bool user_include_iso = includeIsotropicStress();
462 if (user_include_iso && _porous_medium_treatment)
463 paramWarning("include_isotropic_viscous_stress",
464 "Including the isotropic viscous stress is not supported with the porous medium "
465 "treatment. Ignoring the request.");
466 const bool include_isotropic = (!_porous_medium_treatment) && user_include_iso;
467 if (include_isotropic)
468 params.set<bool>("include_isotropic_viscous_stress") = true;
469 params.set<MooseEnum>("mu_interp_method") = getParam<MooseEnum>("mu_interp_method");
470 params.set<MooseEnum>("variable_interp_method") =
471 getParam<MooseEnum>("momentum_face_interpolation");
472 bool include_symmetric = includeSymmetrizedViscousStress();
473 if (include_symmetric && _porous_medium_treatment)
474 {
475 paramWarning("include_symmetrized_viscous_stress",
476 "Including the symmetrized viscous stress is not supported with the porous "
477 "medium treatment. Ignoring the request.");
478 include_symmetric = false;
479 }
480 if (include_symmetric || include_isotropic)
481 {
482 params.set<bool>("complete_expansion") = true;
483 const std::string u_names[3] = {"u", "v", "w"};
484 for (unsigned int i = 0; i < dimension(); ++i)
485 params.set<MooseFunctorName>(u_names[i]) = _velocity_names[i];
486 }
487
489 params.set<MooseFunctorName>(NS::porosity) = _flow_porosity_functor_name;
490 // Currently only Newton method for WCNSFVFlowPhysics
491 params.set<bool>("newton_solve") = true;
492 for (const auto d : make_range(dimension()))
493 {
494 params.set<NonlinearVariableName>("variable") = _velocity_names[d];
495 params.set<MooseEnum>("momentum_component") = NS::directions[d];
496
497 getProblem().addFVKernel(kernel_type, kernel_name + NS::directions[d], params);
498 }
499}
500
501void
502WCNSFVFlowPhysics::addAxisymmetricViscousSourceKernel(const std::vector<SubdomainName> & rz_blocks,
503 const unsigned int radial_index)
504{
505 InputParameters params = getFactory().getValidParams("INSFVMomentumViscousSourceRZ");
506 assignBlocks(params, rz_blocks);
507 params.set<MooseFunctorName>(NS::mu) = _dynamic_viscosity_name;
508 params.set<UserObjectName>("rhie_chow_user_object") = rhieChowUOName();
509 params.set<MooseEnum>("momentum_component") = NS::directions[radial_index];
510 params.set<bool>("complete_expansion") = includeSymmetrizedViscousStress();
511 params.set<NonlinearVariableName>("variable") = _velocity_names[radial_index];
512
513 getProblem().addFVKernel("INSFVMomentumViscousSourceRZ",
514 prefix() + "ins_momentum_viscous_source_rz_" +
515 NS::directions[radial_index],
516 params);
517}
518
519void
521{
522 std::string kernel_type = "INSFVMomentumPressure";
523 std::string kernel_name = prefix() + "ins_momentum_pressure_";
524
526 {
527 kernel_type = "PINSFVMomentumPressure";
528 kernel_name = prefix() + "pins_momentum_pressure_";
529 }
530
531 InputParameters params = getFactory().getValidParams(kernel_type);
532 assignBlocks(params, _blocks);
533 params.set<UserObjectName>("rhie_chow_user_object") = rhieChowUOName();
534 params.set<MooseFunctorName>("pressure") = _pressure_name;
535 params.set<bool>("correct_skewness") =
536 getParam<MooseEnum>("pressure_face_interpolation") == "skewness-corrected";
538 params.set<MooseFunctorName>(NS::porosity) = _flow_porosity_functor_name;
539
540 for (const auto d : make_range(dimension()))
541 {
542 params.set<MooseEnum>("momentum_component") = NS::directions[d];
543 params.set<NonlinearVariableName>("variable") = _velocity_names[d];
544 getProblem().addFVKernel(kernel_type, kernel_name + NS::directions[d], params);
545 }
546}
547
548void
550{
552 {
553 std::string kernel_type = "INSFVMomentumGravity";
554 std::string kernel_name = prefix() + "ins_momentum_gravity_";
555
557 {
558 kernel_type = "PINSFVMomentumGravity";
559 kernel_name = prefix() + "pins_momentum_gravity_";
560 }
561
562 InputParameters params = getFactory().getValidParams(kernel_type);
563 assignBlocks(params, _blocks);
564 params.set<UserObjectName>("rhie_chow_user_object") = rhieChowUOName();
565 params.set<MooseFunctorName>(NS::density) = _density_gravity_name;
566 params.set<RealVectorValue>("gravity") = getParam<RealVectorValue>("gravity");
568 params.set<MooseFunctorName>(NS::porosity) = _flow_porosity_functor_name;
569
570 for (const auto d : make_range(dimension()))
571 {
572 if (getParam<RealVectorValue>("gravity")(d) != 0)
573 {
574 params.set<MooseEnum>("momentum_component") = NS::directions[d];
575 params.set<NonlinearVariableName>("variable") = _velocity_names[d];
576
577 getProblem().addFVKernel(kernel_type, kernel_name + NS::directions[d], params);
578 }
579 }
580 }
581}
582
583void
585{
586 if (_compressibility == "weakly-compressible")
587 paramError("boussinesq_approximation",
588 "We cannot use boussinesq approximation while running in weakly-compressible mode!");
589
590 std::string kernel_type = "INSFVMomentumBoussinesq";
591 std::string kernel_name = prefix() + "ins_momentum_boussinesq_";
592
594 {
595 kernel_type = "PINSFVMomentumBoussinesq";
596 kernel_name = prefix() + "pins_momentum_boussinesq_";
597 }
598
599 InputParameters params = getFactory().getValidParams(kernel_type);
600 assignBlocks(params, _blocks);
601 params.set<UserObjectName>("rhie_chow_user_object") = rhieChowUOName();
602 params.set<MooseFunctorName>(NS::T_fluid) = _fluid_temperature_name;
603 params.set<MooseFunctorName>(NS::density) = _density_gravity_name;
604 params.set<RealVectorValue>("gravity") = getParam<RealVectorValue>("gravity");
605 params.set<Real>("ref_temperature") = getParam<Real>("ref_temperature");
606 params.set<MooseFunctorName>("alpha_name") = getParam<MooseFunctorName>("thermal_expansion");
608 params.set<MooseFunctorName>(NS::porosity) = _flow_porosity_functor_name;
609 // User declared the flow to be incompressible, we have to trust them
610 params.set<bool>("_override_constant_check") = true;
611
612 for (const auto d : make_range(dimension()))
613 {
614 if (getParam<RealVectorValue>("gravity")(d) != 0)
615 {
616 params.set<MooseEnum>("momentum_component") = NS::directions[d];
617 params.set<NonlinearVariableName>("variable") = _velocity_names[d];
618
619 getProblem().addFVKernel(kernel_type, kernel_name + NS::directions[d], params);
620 }
621 }
622}
623
624void
626{
627 unsigned int num_friction_blocks = _friction_blocks.size();
628 unsigned int num_used_blocks = num_friction_blocks ? num_friction_blocks : 1;
629
630 const std::string kernel_type = "PINSFVMomentumFriction";
631 InputParameters params = getFactory().getValidParams(kernel_type);
632 params.set<MooseFunctorName>(NS::density) = _density_name;
633 params.set<UserObjectName>("rhie_chow_user_object") = rhieChowUOName();
635 params.set<MooseFunctorName>(NS::speed) = NS::speed;
636 params.set<bool>("standard_friction_formulation") =
637 getParam<bool>("standard_friction_formulation");
638 params.set<bool>("is_porous_medium") = _porous_medium_treatment;
639
640 for (const auto block_i : make_range(num_used_blocks))
641 {
642 std::string block_name = "";
643 if (num_friction_blocks)
644 {
645 params.set<std::vector<SubdomainName>>("block") = _friction_blocks[block_i];
646 block_name = Moose::stringify(_friction_blocks[block_i]);
647 }
648 else
649 {
650 assignBlocks(params, _blocks);
651 block_name = std::to_string(block_i);
652 }
653
654 for (const auto d : make_range(dimension()))
655 {
656 params.set<NonlinearVariableName>("variable") = _velocity_names[d];
657 params.set<MooseEnum>("momentum_component") = NS::directions[d];
658 for (unsigned int type_i = 0; type_i < _friction_types[block_i].size(); ++type_i)
659 {
660 const auto upper_name = MooseUtils::toUpper(_friction_types[block_i][type_i]);
661 if (upper_name == "DARCY")
662 {
663 params.set<MooseFunctorName>(NS::mu) = _dynamic_viscosity_name;
664 params.set<MooseFunctorName>("Darcy_name") = _friction_coeffs[block_i][type_i];
665 }
666 else if (upper_name == "FORCHHEIMER")
667 {
668 params.set<MooseFunctorName>(NS::speed) = NS::speed;
669 params.set<MooseFunctorName>("Forchheimer_name") = _friction_coeffs[block_i][type_i];
670 }
671 else
672 paramError("friction_types",
673 "Friction type '",
674 _friction_types[block_i][type_i],
675 "' is not implemented");
676 }
677
678 getProblem().addFVKernel(kernel_type,
679 prefix() + "momentum_friction_" + block_name + "_" +
681 params);
682 }
683
684 if (_porous_medium_treatment && getParam<bool>("use_friction_correction"))
685 {
686 const std::string correction_kernel_type = "PINSFVMomentumFrictionCorrection";
687 InputParameters corr_params = getFactory().getValidParams(correction_kernel_type);
688 if (num_friction_blocks)
689 corr_params.set<std::vector<SubdomainName>>("block") = _friction_blocks[block_i];
690 else
691 assignBlocks(corr_params, _blocks);
692 corr_params.set<MooseFunctorName>(NS::density) = _density_name;
693 corr_params.set<UserObjectName>("rhie_chow_user_object") = rhieChowUOName();
694 corr_params.set<Real>("consistent_scaling") = getParam<Real>("consistent_scaling");
695 for (const auto d : make_range(dimension()))
696 {
697 corr_params.set<NonlinearVariableName>("variable") = _velocity_names[d];
698 corr_params.set<MooseEnum>("momentum_component") = NS::directions[d];
699 for (unsigned int type_i = 0; type_i < _friction_types[block_i].size(); ++type_i)
700 {
701 const auto upper_name = MooseUtils::toUpper(_friction_types[block_i][type_i]);
702 if (upper_name == "DARCY")
703 {
704 corr_params.set<MooseFunctorName>(NS::mu) = _dynamic_viscosity_name;
705 corr_params.set<MooseFunctorName>("Darcy_name") = _friction_coeffs[block_i][type_i];
706 }
707 else if (upper_name == "FORCHHEIMER")
708 {
709 corr_params.set<MooseFunctorName>(NS::speed) = NS::speed;
710 corr_params.set<MooseFunctorName>("Forchheimer_name") =
711 _friction_coeffs[block_i][type_i];
712 }
713 }
714
715 getProblem().addFVKernel(correction_kernel_type,
716 prefix() + "pins_momentum_friction_correction_" + block_name +
717 "_" + NS::directions[d],
718 corr_params);
719 }
720 }
721 }
722}
723
724void
726{
727 // Check the size of the BC parameters
728 unsigned int num_velocity_functor_inlets = 0;
729 for (const auto & [bdy, momentum_outlet_type] : _momentum_inlet_types)
730 if (momentum_outlet_type == "fixed-velocity" || momentum_outlet_type == "fixed-pressure")
731 num_velocity_functor_inlets++;
732
733 if (num_velocity_functor_inlets != _momentum_inlet_functors.size())
734 paramError("momentum_inlet_functors",
735 "Size (" + std::to_string(_momentum_inlet_functors.size()) +
736 ") is not the same as the number of entries in the momentum_inlet_types "
737 "subvector for fixed-velocities/pressures functors (size " +
738 std::to_string(num_velocity_functor_inlets) + ")");
739
740 unsigned int flux_bc_counter = 0;
741 unsigned int velocity_pressure_counter = 0;
742 for (const auto & [inlet_bdy, momentum_inlet_type] : _momentum_inlet_types)
743 {
744 if (momentum_inlet_type == "fixed-velocity")
745 {
746 const std::string bc_type = "INSFVInletVelocityBC";
747 InputParameters params = getFactory().getValidParams(bc_type);
748 params.set<std::vector<BoundaryName>>("boundary") = {inlet_bdy};
749 if (_momentum_inlet_functors.size() < velocity_pressure_counter + 1)
750 paramError("momentum_inlet_functors",
751 "More non-flux inlets than inlet functors (" +
752 std::to_string(_momentum_inlet_functors.size()) + ")");
753
754 // Check that enough functors have been provided for the dimension of the problem
755 const auto momentum_functors = libmesh_map_find(_momentum_inlet_functors, inlet_bdy);
756 if (momentum_functors.size() < dimension())
757 paramError("momentum_inlet_functors",
758 "Subvector for boundary '" + inlet_bdy + "' (size " +
759 std::to_string(momentum_functors.size()) +
760 ") is not the same size as the number of dimensions of the physics (" +
761 std::to_string(dimension()) + ")");
762
763 for (const auto d : make_range(dimension()))
764 {
765 params.set<NonlinearVariableName>("variable") = _velocity_names[d];
766 params.set<MooseFunctorName>("functor") = momentum_functors[d];
767
768 getProblem().addFVBC(bc_type, _velocity_names[d] + "_" + inlet_bdy, params);
769 }
770 ++velocity_pressure_counter;
771 }
772 else if (momentum_inlet_type == "fixed-pressure")
773 {
774 const std::string bc_type = "INSFVOutletPressureBC";
775 InputParameters params = getFactory().getValidParams(bc_type);
776 params.set<NonlinearVariableName>("variable") = _pressure_name;
777 if (_momentum_inlet_functors.size() < velocity_pressure_counter + 1)
778 paramError("momentum_inlet_functors",
779 "More non-flux inlets than inlet functors (" +
780 std::to_string(_momentum_inlet_functors.size()) + ")");
781
782 params.set<FunctionName>("function") =
783 libmesh_map_find(_momentum_inlet_functors, inlet_bdy)[0];
784 params.set<std::vector<BoundaryName>>("boundary") = {inlet_bdy};
785
786 getProblem().addFVBC(bc_type, _pressure_name + "_" + inlet_bdy, params);
787 ++velocity_pressure_counter;
788 }
789 else if (momentum_inlet_type == "flux-mass" || momentum_inlet_type == "flux-velocity")
790 {
791 {
792 const std::string bc_type =
793 _porous_medium_treatment ? "PWCNSFVMomentumFluxBC" : "WCNSFVMomentumFluxBC";
794 InputParameters params = getFactory().getValidParams(bc_type);
795
796 if (_flux_inlet_directions.size())
797 params.set<Point>("direction") = _flux_inlet_directions[flux_bc_counter];
798
799 params.set<MooseFunctorName>(NS::density) = _density_name;
800 params.set<std::vector<BoundaryName>>("boundary") = {inlet_bdy};
801 params.set<UserObjectName>("rhie_chow_user_object") = rhieChowUOName();
803 params.set<MooseFunctorName>(NS::porosity) = _porosity_name;
804 if (_flux_inlet_pps.size() < flux_bc_counter + 1)
805 paramError("flux_inlet_pps",
806 "More inlet flux BCs than inlet flux pps (" +
807 std::to_string(_flux_inlet_pps.size()) + ")");
808
809 if (momentum_inlet_type == "flux-mass")
810 {
811 params.set<PostprocessorName>("mdot_pp") = _flux_inlet_pps[flux_bc_counter];
812 params.set<PostprocessorName>("area_pp") = "area_pp_" + inlet_bdy;
813 }
814 else
815 params.set<PostprocessorName>("velocity_pp") = _flux_inlet_pps[flux_bc_counter];
816
817 for (const auto d : make_range(dimension()))
818 params.set<MooseFunctorName>(NS::velocity_vector[d]) = _velocity_names[d];
819
820 for (const auto d : make_range(dimension()))
821 {
822 params.set<MooseEnum>("momentum_component") = NS::directions[d];
823 params.set<NonlinearVariableName>("variable") = _velocity_names[d];
824
825 getProblem().addFVBC(bc_type, _velocity_names[d] + "_" + inlet_bdy, params);
826 }
827 }
828 {
829 const std::string bc_type = "WCNSFVMassFluxBC";
830 InputParameters params = getFactory().getValidParams(bc_type);
831 params.set<MooseFunctorName>(NS::density) = _density_name;
832 params.set<NonlinearVariableName>("variable") = _pressure_name;
833 params.set<std::vector<BoundaryName>>("boundary") = {inlet_bdy};
834
835 if (_flux_inlet_directions.size())
836 params.set<Point>("direction") = _flux_inlet_directions[flux_bc_counter];
837
838 if (momentum_inlet_type == "flux-mass")
839 {
840 params.set<PostprocessorName>("mdot_pp") = _flux_inlet_pps[flux_bc_counter];
841 params.set<PostprocessorName>("area_pp") = "area_pp_" + inlet_bdy;
842 }
843 else
844 params.set<PostprocessorName>("velocity_pp") = _flux_inlet_pps[flux_bc_counter];
845
846 for (const auto d : make_range(dimension()))
847 params.set<MooseFunctorName>(NS::velocity_vector[d]) = _velocity_names[d];
848
849 getProblem().addFVBC(bc_type, _pressure_name + "_" + inlet_bdy, params);
850 }
851
852 // need to increment flux_bc_counter
853 ++flux_bc_counter;
854 }
855 }
856}
857
858void
860{
861 // Check the BCs size
862 unsigned int num_pressure_outlets = 0;
863 for (const auto & [bdy, momentum_outlet_type] : _momentum_outlet_types)
864 if (momentum_outlet_type == "fixed-pressure" ||
865 momentum_outlet_type == "fixed-pressure-zero-gradient")
866 num_pressure_outlets++;
867
868 if (num_pressure_outlets != _pressure_functors.size())
869 paramError("pressure_functors",
870 "Size (" + std::to_string(_pressure_functors.size()) +
871 ") is not the same as the number of pressure outlet boundaries in "
872 "'fixed-pressure/fixed-pressure-zero-gradient' (size " +
873 std::to_string(num_pressure_outlets) + ")");
874
875 const std::string u_names[3] = {"u", "v", "w"};
876 for (const auto & [outlet_bdy, momentum_outlet_type] : _momentum_outlet_types)
877 {
878 if (momentum_outlet_type == "zero-gradient" ||
879 momentum_outlet_type == "fixed-pressure-zero-gradient")
880 {
881 {
882 const std::string bc_type = _porous_medium_treatment ? "PINSFVMomentumAdvectionOutflowBC"
883 : "INSFVMomentumAdvectionOutflowBC";
884 InputParameters params = getFactory().getValidParams(bc_type);
885 params.set<std::vector<BoundaryName>>("boundary") = {outlet_bdy};
887 params.set<MooseFunctorName>(NS::porosity) = _flow_porosity_functor_name;
888 params.set<UserObjectName>("rhie_chow_user_object") = rhieChowUOName();
889 params.set<MooseFunctorName>(NS::density) = _density_name;
890
891 for (unsigned int i = 0; i < dimension(); ++i)
892 params.set<MooseFunctorName>(u_names[i]) = _velocity_names[i];
893
894 for (const auto d : make_range(dimension()))
895 {
896 params.set<NonlinearVariableName>("variable") = _velocity_names[d];
897 params.set<MooseEnum>("momentum_component") = NS::directions[d];
898
899 getProblem().addFVBC(bc_type, _velocity_names[d] + "_" + outlet_bdy, params);
900 }
901 }
902 }
903
904 if (momentum_outlet_type == "fixed-pressure" ||
905 momentum_outlet_type == "fixed-pressure-zero-gradient")
906 {
907 const std::string bc_type = "INSFVOutletPressureBC";
908 InputParameters params = getFactory().getValidParams(bc_type);
909 params.set<NonlinearVariableName>("variable") = _pressure_name;
910 params.set<MooseFunctorName>("functor") = libmesh_map_find(_pressure_functors, outlet_bdy);
911 params.set<std::vector<BoundaryName>>("boundary") = {outlet_bdy};
912
913 getProblem().addFVBC(bc_type, _pressure_name + "_" + outlet_bdy, params);
914 }
915 else if (momentum_outlet_type == "zero-gradient")
916 {
917 const std::string bc_type = "INSFVMassAdvectionOutflowBC";
918 InputParameters params = getFactory().getValidParams(bc_type);
919 params.set<NonlinearVariableName>("variable") = _pressure_name;
920 params.set<MooseFunctorName>(NS::density) = _density_name;
921 params.set<std::vector<BoundaryName>>("boundary") = {outlet_bdy};
922
923 for (const auto d : make_range(dimension()))
924 params.set<MooseFunctorName>(u_names[d]) = _velocity_names[d];
925
926 getProblem().addFVBC(bc_type, _pressure_name + "_" + outlet_bdy, params);
927 }
928 }
929}
930
931void
933{
934 const std::string u_names[3] = {"u", "v", "w"};
935
936 // Count the number of fixed velocity wall boundaries (moving walls)
937 unsigned int num_functor_walls = 0;
938 for (const auto & [boundary_name, momentum_wall_type] : _momentum_wall_types)
939 if (momentum_wall_type == "noslip")
940 num_functor_walls++;
941 if (_momentum_wall_functors.size() && num_functor_walls != _momentum_wall_functors.size())
942 paramError("momentum_wall_functors",
943 "If any wall functors are specified, the number of boundaries requiring a momentum "
944 "functor (" +
945 std::to_string(num_functor_walls) + ") and the number of functors specified (" +
946 std::to_string(_momentum_wall_functors.size()) + ") must match");
947 for (const auto & wall_functors : _momentum_wall_functors)
948 if (wall_functors.second.size() != dimension())
949 paramError("momentum_wall_functors",
950 "Number of wall functors (" + std::to_string(wall_functors.second.size()) +
951 ") must match dimension (" + std::to_string(dimension()) +
952 ").\nFunctors currently specified:" + Moose::stringify(wall_functors.second));
953
954 for (const auto & [boundary_name, wall_type] : _momentum_wall_types)
955 {
956 if (wall_type == "noslip")
957 {
958 const std::string bc_type = "INSFVNoSlipWallBC";
959 InputParameters params = getFactory().getValidParams(bc_type);
960 params.set<std::vector<BoundaryName>>("boundary") = {boundary_name};
961
962 for (const auto d : make_range(dimension()))
963 {
964 params.set<NonlinearVariableName>("variable") = _velocity_names[d];
965 if (_momentum_wall_functors.count(boundary_name) == 0)
966 params.set<FunctionName>("function") = "0";
967 else
968 params.set<FunctionName>("function") = _momentum_wall_functors[boundary_name][d];
969
970 getProblem().addFVBC(bc_type, _velocity_names[d] + "_" + boundary_name, params);
971 }
972 }
973 else if (wall_type == "wallfunction")
974 {
975 const std::string bc_type = "INSFVWallFunctionBC";
976 InputParameters params = getFactory().getValidParams(bc_type);
977 params.set<MooseFunctorName>(NS::mu) = _dynamic_viscosity_name;
978 params.set<MooseFunctorName>(NS::density) = _density_name;
979 params.set<std::vector<BoundaryName>>("boundary") = {boundary_name};
980 params.set<UserObjectName>("rhie_chow_user_object") = rhieChowUOName();
981
982 for (const auto d : make_range(dimension()))
983 params.set<MooseFunctorName>(u_names[d]) = _velocity_names[d];
984
985 for (const auto d : make_range(dimension()))
986 {
987 params.set<NonlinearVariableName>("variable") = _velocity_names[d];
988 params.set<MooseEnum>("momentum_component") = NS::directions[d];
989
990 getProblem().addFVBC(bc_type, _velocity_names[d] + "_" + boundary_name, params);
991 }
992 }
993 else if (wall_type == "slip")
994 {
995 const std::string bc_type = "INSFVNaturalFreeSlipBC";
996 InputParameters params = getFactory().getValidParams(bc_type);
997 params.set<std::vector<BoundaryName>>("boundary") = {boundary_name};
998 params.set<UserObjectName>("rhie_chow_user_object") = rhieChowUOName();
999
1000 for (const auto d : make_range(dimension()))
1001 {
1002 params.set<NonlinearVariableName>("variable") = _velocity_names[d];
1003 params.set<MooseEnum>("momentum_component") = NS::directions[d];
1004
1005 getProblem().addFVBC(bc_type, _velocity_names[d] + "_" + boundary_name, params);
1006 }
1007 }
1008 else if (wall_type == "symmetry")
1009 {
1010 {
1011 std::string bc_type;
1013 bc_type = "PINSFVSymmetryVelocityBC";
1014 else
1015 bc_type = "INSFVSymmetryVelocityBC";
1016
1017 InputParameters params = getFactory().getValidParams(bc_type);
1018 params.set<std::vector<BoundaryName>>("boundary") = {boundary_name};
1019
1020 MooseFunctorName viscosity_name = _dynamic_viscosity_name;
1022 viscosity_name = NS::total_viscosity;
1023 params.set<MooseFunctorName>(NS::mu) = viscosity_name;
1024 params.set<UserObjectName>("rhie_chow_user_object") = rhieChowUOName();
1025
1026 for (const auto d : make_range(dimension()))
1027 params.set<MooseFunctorName>(u_names[d]) = _velocity_names[d];
1028
1029 for (const auto d : make_range(dimension()))
1030 {
1031 params.set<NonlinearVariableName>("variable") = _velocity_names[d];
1032 params.set<MooseEnum>("momentum_component") = NS::directions[d];
1033
1034 getProblem().addFVBC(bc_type, _velocity_names[d] + "_" + boundary_name, params);
1035 }
1036 }
1037 {
1038 const std::string bc_type = "INSFVSymmetryPressureBC";
1039 InputParameters params = getFactory().getValidParams(bc_type);
1040 params.set<NonlinearVariableName>("variable") = _pressure_name;
1041 params.set<std::vector<BoundaryName>>("boundary") = {boundary_name};
1042
1043 getProblem().addFVBC(bc_type, _pressure_name + "_" + boundary_name, params);
1044 }
1045 }
1046 }
1047}
1048
1049void
1051{
1052 if (_hydraulic_separators.size())
1053 {
1054 std::string bc_type = "INSFVVelocityHydraulicSeparatorBC";
1055 InputParameters params = getFactory().getValidParams(bc_type);
1056 params.set<std::vector<BoundaryName>>("boundary") = _hydraulic_separators;
1057 params.set<UserObjectName>("rhie_chow_user_object") = rhieChowUOName();
1058
1059 for (const auto d : make_range(dimension()))
1060 {
1061 params.set<NonlinearVariableName>("variable") = _velocity_names[d];
1062 params.set<MooseEnum>("momentum_component") = NS::directions[d];
1063 getProblem().addFVBC(bc_type, prefix() + _velocity_names[d] + "_separators", params);
1064 }
1065
1066 bc_type = "INSFVScalarFieldSeparatorBC";
1067 params = getFactory().getValidParams(bc_type);
1068 params.set<std::vector<BoundaryName>>("boundary") = _hydraulic_separators;
1069 params.set<NonlinearVariableName>("variable") = _pressure_name;
1070 getProblem().addFVBC(bc_type, prefix() + _pressure_name + "_separators", params);
1071 }
1072}
1073
1074void
1076{
1077 // Rhie Chow user object for interpolation velocities
1079}
1080
1081void
1083{
1085 return;
1086
1087 // Pressure pin
1088 if (getParam<bool>("pin_pressure"))
1089 {
1090 const auto pin_type = getParam<MooseEnum>("pinned_pressure_type");
1091 std::string object_type = "NSPressurePin";
1092
1093 // No need for the user object
1094 if (pin_type == "point-value" || pin_type == "average")
1095 return;
1096
1097 // Create the average value postprocessor if needed
1098 if (pin_type == "average-uo")
1099 {
1100 // Volume average by default, but we could do inlet or outlet for example
1101 InputParameters params = getFactory().getValidParams("ElementAverageValue");
1102 params.set<std::vector<VariableName>>("variable") = {_pressure_name};
1103 assignBlocks(params, _blocks);
1104 params.set<std::vector<OutputName>>("outputs") = {"none"};
1105 getProblem().addPostprocessor("ElementAverageValue", "ns_pressure_average", params);
1106 }
1107
1108 InputParameters params = getFactory().getValidParams(object_type);
1109 if (pin_type == "point-value" || pin_type == "point-value-uo")
1110 params.set<MooseEnum>("pin_type") = "point-value";
1111 else
1112 params.set<MooseEnum>("pin_type") = "average";
1113
1114 params.set<PostprocessorName>("phi0") = getParam<PostprocessorName>("pinned_pressure_value");
1115 params.set<NonlinearVariableName>("variable") = _pressure_name;
1116 if (pin_type == "point-value" || pin_type == "point-value-uo")
1117 params.set<Point>("point") = getParam<Point>("pinned_pressure_point");
1118 else if (pin_type == "average-uo")
1119 params.set<PostprocessorName>("pressure_average") = "ns_pressure_average";
1120
1121 getProblem().addUserObject(object_type, prefix() + "ins_mass_pressure_pin", params);
1122 }
1123}
1124
1125bool
1127{
1128 for (const auto block_i : index_range(_friction_types))
1129 for (const auto type_i : index_range(_friction_types[block_i]))
1130 if (MooseUtils::toUpper(_friction_types[block_i][type_i]) == "FORCHHEIMER")
1131 return true;
1132 return false;
1133}
1134
1135unsigned short
1137{
1139 if (_porous_medium_treatment && isParamValid("porosity_smoothing_layers"))
1140 ghost_layers = std::max(getParam<unsigned short>("porosity_smoothing_layers"), ghost_layers);
1142 getParam<MooseEnum>("porosity_interface_pressure_treatment") != "automatic") ||
1143 getParam<MooseEnum>("momentum_face_interpolation") == "skewness-corrected" ||
1144 getParam<MooseEnum>("pressure_face_interpolation") == "skewness-corrected")
1145 ghost_layers = std::max(ghost_layers, (unsigned short)3);
1146 return ghost_layers;
1147}
1148
1149void
1151{
1152 mooseAssert(dimension(), "0-dimension not supported");
1153
1154 // First make sure that we only add this object once
1155 // Potential cases:
1156 // - there is a flow physics, and an advection one (UO should be added by one)
1157 // - there is only an advection physics (UO should be created)
1158 // - there are two advection physics on different blocks with set velocities (first one picks)
1159 // Counting RC UOs defined on the same blocks seems to be the most fool proof option
1160 std::vector<UserObject *> objs;
1161 getProblem()
1162 .theWarehouse()
1163 .query()
1164 .condition<AttribSystem>("UserObject")
1165 .condition<AttribThread>(0)
1166 .queryInto(objs);
1167 bool have_matching_rc_uo = false;
1168 for (const auto & obj : objs)
1169 if (const auto * const rc_obj = dynamic_cast<INSFVRhieChowInterpolator *>(obj); rc_obj)
1170 // Latter check is for whether one of the RC user object is defined everywhere
1171 if (rc_obj->blocks() == _blocks || (rc_obj->blocks().size() == 0 || _blocks.size() == 0))
1172 {
1173 have_matching_rc_uo = true;
1174 _rc_uo_name = rc_obj->name();
1175 break;
1176 }
1177
1178 if (have_matching_rc_uo)
1179 return;
1180
1181 _rc_uo_name =
1182 _porous_medium_treatment ? +"pins_rhie_chow_interpolator" : "ins_rhie_chow_interpolator";
1183
1184 const std::string u_names[3] = {"u", "v", "w"};
1185 const auto object_type =
1186 _porous_medium_treatment ? "PINSFVRhieChowInterpolator" : "INSFVRhieChowInterpolator";
1187
1188 auto params = getFactory().getValidParams(object_type);
1189 assignBlocks(params, _blocks);
1190 for (unsigned int d = 0; d < dimension(); ++d)
1191 params.set<VariableName>(u_names[d]) = _velocity_names[d];
1192
1193 params.set<VariableName>("pressure") = _pressure_name;
1194
1196 {
1197 params.set<MooseFunctorName>(NS::porosity) = _porosity_name;
1198 unsigned short smoothing_layers = isParamValid("porosity_smoothing_layers")
1199 ? getParam<unsigned short>("porosity_smoothing_layers")
1200 : 0;
1201 params.set<unsigned short>("smoothing_layers") = smoothing_layers;
1202 }
1203
1205 {
1207 params.set<MooseFunctorName>("a_u") = "ax";
1208 params.set<MooseFunctorName>("a_v") = "ay";
1209 params.set<MooseFunctorName>("a_w") = "az";
1210 }
1211
1212 params.applySpecificParameters(parameters(), INSFVRhieChowInterpolator::listOfCommonParams());
1213 addUserObject(object_type, _rc_uo_name, params);
1214}
1215
1216std::vector<UserObjectName>
1221
1222void
1224{
1225 if (!getProblem().hasFunctor("ax", /*thread_id=*/0))
1226 mooseError("Rhie Chow coefficient ax must be provided for advection by auxiliary velocities");
1227 if (dimension() >= 2 && !getProblem().hasFunctor("ay", /*thread_id=*/0))
1228 mooseError("Rhie Chow coefficient ay must be provided for advection by auxiliary velocities");
1229 if (dimension() == 3 && !getProblem().hasFunctor("az", /*thread_id=*/0))
1230 mooseError("Rhie Chow coefficient az must be provided for advection by auxiliary velocities");
1231}
1232
1233MooseFunctorName
1235{
1236 // Check all blocks. If more than one block, they would need to be consolidated #include in
1237 // a single functor material. We won't implement this for now
1238 if (_friction_types.empty())
1239 return "";
1240 else if (_friction_types.size() == 1)
1241 {
1242 for (const auto & type_i : index_range(_friction_types[0]))
1243 {
1244 const auto upper_name = MooseUtils::toUpper(_friction_types[0][type_i]);
1245 if (upper_name == "DARCY")
1246 return _friction_coeffs[0][type_i];
1247 }
1248 // No linear type found
1249 return "";
1250 }
1251 else if (_friction_types.size() > 1)
1252 {
1253 bool linear_friction_factor_found = false;
1254 MooseFunctorName linear_friction_factor;
1255 for (const auto block_i : index_range(_friction_types))
1256 for (const auto type_i : index_range(_friction_types[block_i]))
1257 {
1258 const auto upper_name = MooseUtils::toUpper(_friction_types[block_i][type_i]);
1259 if (upper_name == "DARCY" && !linear_friction_factor_found)
1260 {
1261 linear_friction_factor_found = true;
1262 linear_friction_factor = _friction_types[block_i][type_i];
1263 }
1264 else if (upper_name == "DARCY" && !linear_friction_factor_found)
1265 if (linear_friction_factor != _friction_types[block_i][type_i])
1266 mooseError("Multiple linear friction factor with different names have been specified. "
1267 "This is not currently supported as a single name should be retrievable. "
1268 "Use a PiecewiseByBlockFunctorMaterial to consolidate them.");
1269 }
1270 if (linear_friction_factor_found)
1271 return linear_friction_factor;
1272 else
1273 return "";
1274 }
1275 mooseError("Should not get here");
1276}
std::vector< VariableName > CoupledName
registerWCNSFVFlowPhysicsBaseTasks("NavierStokesApp", WCNSFVFlowPhysics)
registerMooseAction("NavierStokesApp", WCNSFVFlowPhysics, "add_fv_kernel")
std::shared_ptr< FEProblemBase > & _problem
virtual std::vector< std::shared_ptr< UserObject > > addUserObject(const std::string &user_object_name, const std::string &name, InputParameters &parameters)
virtual void addVariable(const std::string &var_type, const std::string &var_name, InputParameters &params)
virtual void addFVBC(const std::string &fv_bc_name, const std::string &name, InputParameters &parameters)
virtual void addPostprocessor(const std::string &pp_name, const std::string &name, InputParameters &parameters)
TheWarehouse & theWarehouse() const
virtual void addFVKernel(const std::string &kernel_name, const std::string &name, InputParameters &parameters)
InputParameters getValidParams(const std::string &name) const
static InputParameters validParams()
static std::vector< std::string > listOfCommonParams()
This user-object gathers 'a' (on-diagonal velocity coefficients) data.
static std::vector< std::string > listOfCommonParams()
void errorDependentParameter(const std::string &param1, const std::string &value_not_set, const std::vector< std::string > &dependent_params) const
void checkSecondParamSetOnlyIfFirstOneTrue(const std::string &param1, const std::string &param2) const
void applySpecificParameters(const InputParameters &common, const std::vector< std::string > &include, bool allow_private=false)
void addParamNamesToGroup(const std::string &space_delim_names, const std::string group_name)
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
const std::string & type() const
void paramWarning(const std::string &param, Args... args) const
void paramError(const std::string &param, Args... args) const
bool isParamSetByUser(const std::string &name) const
void mooseError(Args &&... args) const
const T & getParam(const std::string &name) const
bool isParamValid(const std::string &name) const
static InputParameters validParams()
Definition NSFVBase.C:371
bool _define_variables
Whether to define variables if they do not exist.
virtual FEProblemBase & getProblem()
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
const SolverSystemName & getSolverSystem(unsigned int variable_index) const
bool shouldCreateVariable(const VariableName &var_name, const std::vector< SubdomainName > &blocks, const bool error_if_aux)
bool isTransient() const
std::vector< SubdomainName > _blocks
Query query()
Base class for Physics which create the Navier Stokes flow equations.
std::map< BoundaryName, MooseEnum > _momentum_outlet_types
Momentum outlet boundary types.
const MooseEnum _velocity_interpolation
The velocity face interpolation method for advecting other quantities.
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< PostprocessorName > _flux_inlet_pps
Postprocessors describing the momentum inlet for each boundary. Indexing based on the number of flux ...
const MooseEnum _momentum_advection_interpolation
The momentum face interpolation method for being advected.
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.
MooseFunctorName _flow_porosity_functor_name
Name of the porosity functor for the flow equations (if smoothed)
void addAxisymmetricViscousSource()
Adds the cylindrical source kernel for the radial momentum equation when requested and valid.
const NonlinearVariableName _pressure_name
Pressure name.
const bool _has_flow_equations
Boolean to keep track of whether the flow equations should be created.
bool includeIsotropicStress() const
Whether to include the isotropic viscous stress contribution.
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.
const UserObjectName & rhieChowUOName() const
Return the name of the Rhie Chow user object.
std::vector< Point > _flux_inlet_directions
Direction of each flux inlet. Indexing based on the number of flux boundaries.
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.
bool hasTurbulencePhysics() const
Whether a turbulence Physics has been coupled in, to know which viscosity to pick on symmetry boundar...
const MooseFunctorName _density_name
Name of the density material property.
const MooseFunctorName _porosity_name
Name of the porosity functor.
unsigned short getNumberAlgebraicGhostingLayersNeeded() const override
Return the number of algebraic ghosting layers needed.
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 mass and momentum equations.
unsigned short getNumberAlgebraicGhostingLayersNeeded() const override
Return the number of algebraic ghosting layers needed.
void addAxisymmetricViscousSourceKernel(const std::vector< SubdomainName > &rz_blocks, unsigned int radial_index) override
Derived classes must override this hook to add the actual object that implements the axisymmetric vis...
void addMomentumBoussinesqKernels() override
void addMassKernels()
Function adding kernels for the incompressible continuity equation.
void addMomentumPressureKernels() override
virtual void addUserObjects() override
void addRhieChowUserObjects() override
Function which adds the RhieChow interpolator user objects for weakly and incompressible formulations...
void addMassTimeKernels()
Function adding kernels for the time derivative term of the weakly compressible continuity equation.
void addWallsBC() override
void addMomentumTimeKernels() override
Functions adding kernels for the incompressible momentum equation If the material properties are not ...
void addMomentumGravityKernels() override
void addSeparatorBC() override
virtual void addSolverVariables() override
void checkRhieChowFunctorsDefined() const
Checks that sufficient Rhie Chow coefficients have been defined for the given dimension,...
void addMomentumViscousDissipationKernels()
void addOutletBC() override
virtual std::vector< UserObjectName > getSuppliedUserObjects() const override
virtual void addCorrectors() override
static InputParameters validParams()
void addMomentumFrictionKernels() override
UserObjectName _rc_uo_name
Name of the user object in charge of computing the Rhie Chow coefficients.
WCNSFVFlowPhysics(const InputParameters &parameters)
void addInletBC() override
Functions adding boundary conditions for the incompressible simulation.
void addPressurePinKernel()
Function adding the pressure constraint.
virtual void addFVKernels() override
virtual MooseFunctorName getLinearFrictionCoefName() const override
Get the name of the linear friction coefficient. Returns an empty string if no friction.
bool hasForchheimerFriction() const override
Return whether a Forchheimer friction model is in use.
std::string toUpper(std::string name)
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
static const std::string mu
Definition NS.h:127
const std::string velocity_vector[3]
Definition NS.h:50
static const std::string smoothed_porosity
Definition NS.h:109
static const std::string porosity
Definition NS.h:108
static const std::string directions[3]
Definition NS.h:23
static const std::string speed
Definition NS.h:147
std::string time_deriv(const std::string &var)
Definition NS.h:98
static const std::string total_viscosity
Definition NS.h:79