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