https://mooseframework.inl.gov
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"
13 #include "INSFVMomentumAdvection.h"
15 #include "INSFVTimeKernel.h"
16 #include "MapConversionUtils.h"
17 #include "NS.h"
18 
20 registerMooseAction("NavierStokesApp", WCNSFVFlowPhysics, "add_fv_kernel");
21 registerMooseAction("NavierStokesApp", WCNSFVFlowPhysics, "add_fv_bc");
22 
25 {
27  params.addClassDescription(
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");
66  params.transferParam<bool>(NSFVBase::validParams(),
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");
75  params.addParamNamesToGroup(
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 
141 void
143 {
144  if (!_has_flow_equations)
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") && !_problem->hasScalarVariable("lambda"))
255  {
256  lm_params.set<SolverSystemName>("solver_sys") = getSolverSystem("lambda");
257  getProblem().addVariable("MooseVariableScalar", "lambda", lm_params);
258  }
259  else
260  reportPotentiallyMissedParameters({"system_names"}, "MooseVariableScalar");
261  }
262 }
263 
264 void
266 {
267  if (!_has_flow_equations)
268  return;
269 
270  // Mass equation: time derivative
271  if (_compressibility == "weakly-compressible" &&
272  shouldCreateTimeDerivative(_pressure_name, _blocks, /*error if already defined*/ false))
274 
275  // Mass equation: divergence of momentum
276  addMassKernels();
277 
278  // Pressure pin
279  if (getParam<bool>("pin_pressure"))
281 
282  // Momentum equation: time derivative
283  if (isTransient())
285 
286  // Momentum equation: momentum advection
288 
289  // Momentum equation: momentum viscous stress
291 
292  // Momentum equation: pressure term
294 
295  // Momentum equation: gravity source term
297 
298  // Momentum equation: friction kernels
299  if (_friction_types.size())
301 
302  // Momentum equation: boussinesq approximation
303  if (getParam<bool>("boussinesq_approximation"))
305 }
306 
307 void
309 {
310  std::string mass_kernel_type = "WCNSFVMassTimeDerivative";
311  std::string kernel_name = prefix() + "wcns_mass_time";
312 
314  {
315  mass_kernel_type = "PWCNSFVMassTimeDerivative";
316  kernel_name = prefix() + "pwcns_mass_time";
317  }
318 
319  InputParameters params = getFactory().getValidParams(mass_kernel_type);
320  assignBlocks(params, _blocks);
321  params.set<NonlinearVariableName>("variable") = _pressure_name;
322  params.set<MooseFunctorName>(NS::time_deriv(NS::density)) = NS::time_deriv(_density_name);
324  params.set<MooseFunctorName>(NS::porosity) = _flow_porosity_functor_name;
325  getProblem().addFVKernel(mass_kernel_type, kernel_name, params);
326 }
327 
328 void
330 {
331  std::string kernel_type = "INSFVMassAdvection";
332  std::string kernel_name = prefix() + "ins_mass_advection";
333 
335  {
336  kernel_type = "PINSFVMassAdvection";
337  kernel_name = prefix() + "pins_mass_advection";
338  }
339 
340  InputParameters params = getFactory().getValidParams(kernel_type);
341  assignBlocks(params, _blocks);
342  params.set<NonlinearVariableName>("variable") = _pressure_name;
343  params.set<MooseFunctorName>(NS::density) = _density_name;
344  params.set<MooseEnum>("velocity_interp_method") = _velocity_interpolation;
345  params.set<UserObjectName>("rhie_chow_user_object") = rhieChowUOName();
346  params.set<MooseEnum>("advected_interp_method") =
347  getParam<MooseEnum>("mass_advection_interpolation");
348 
349  getProblem().addFVKernel(kernel_type, kernel_name, params);
350 }
351 
352 void
354 {
355  const auto pin_type = getParam<MooseEnum>("pinned_pressure_type");
356  const auto object_type =
357  (pin_type == "average") ? "FVIntegralValueConstraint" : "FVPointValueConstraint";
358  InputParameters params = getFactory().getValidParams(object_type);
359  if (pin_type != "point-value" && pin_type != "average")
360  return;
361 
362  params.set<CoupledName>("lambda") = {"lambda"};
363  params.set<PostprocessorName>("phi0") = getParam<PostprocessorName>("pinned_pressure_value");
364  params.set<NonlinearVariableName>("variable") = _pressure_name;
365  if (pin_type == "point-value")
366  params.set<Point>("point") = getParam<Point>("pinned_pressure_point");
367 
368  getProblem().addFVKernel(object_type, prefix() + "ins_mass_pressure_pin", params);
369 }
370 
371 void
373 {
374  std::string kernel_type = (_compressibility == "weakly-compressible")
375  ? "WCNSFVMomentumTimeDerivative"
376  : "INSFVMomentumTimeDerivative";
377  std::string kernel_name = prefix() +
378  ((_compressibility == "weakly-compressible") ? "wcns_" : "ins_") +
379  "momentum_time_";
380 
382  {
383  // Porosity does not appear in the term
384  kernel_type = (_compressibility == "weakly-compressible") ? "WCNSFVMomentumTimeDerivative"
385  : "PINSFVMomentumTimeDerivative";
386  kernel_name = prefix() + ((_compressibility == "weakly-compressible") ? "pwcns_" : "pins_") +
387  "momentum_time_";
388  }
389 
390  InputParameters params = getFactory().getValidParams(kernel_type);
391  assignBlocks(params, _blocks);
392  params.set<MooseFunctorName>(NS::density) = _density_name;
393  if (_compressibility == "weakly-compressible")
394  params.set<MooseFunctorName>(NS::time_deriv(NS::density)) = NS::time_deriv(_density_name);
395 
396  params.set<UserObjectName>("rhie_chow_user_object") = rhieChowUOName();
397  params.set<bool>("contribute_to_rc") =
398  getParam<bool>("time_derivative_contributes_to_RC_coefficients");
399 
400  for (const auto d : make_range(dimension()))
401  {
402  params.set<NonlinearVariableName>("variable") = _velocity_names[d];
403  params.set<MooseEnum>("momentum_component") = NS::directions[d];
404 
405  if (shouldCreateTimeDerivative(_velocity_names[d], _blocks, /*error if already defined*/ false))
406  getProblem().addFVKernel(kernel_type, kernel_name + _velocity_names[d], params);
407  }
408 }
409 
410 void
412 {
413  std::string kernel_type = "INSFVMomentumAdvection";
414  std::string kernel_name = prefix() + "ins_momentum_advection_";
415 
417  {
418  kernel_type = "PINSFVMomentumAdvection";
419  kernel_name = prefix() + "pins_momentum_advection_";
420  }
421 
422  InputParameters params = getFactory().getValidParams(kernel_type);
423  assignBlocks(params, _blocks);
424  params.set<MooseFunctorName>(NS::density) = _density_name;
425  params.set<MooseEnum>("velocity_interp_method") = _velocity_interpolation;
426  params.set<UserObjectName>("rhie_chow_user_object") = rhieChowUOName();
427  params.set<MooseEnum>("advected_interp_method") = _momentum_advection_interpolation;
429  params.set<MooseFunctorName>(NS::porosity) = _flow_porosity_functor_name;
431 
432  for (const auto d : make_range(dimension()))
433  {
434  params.set<NonlinearVariableName>("variable") = _velocity_names[d];
435  params.set<MooseEnum>("momentum_component") = NS::directions[d];
436 
437  getProblem().addFVKernel(kernel_type, kernel_name + NS::directions[d], params);
438  }
439 }
440 
441 void
443 {
444  std::string kernel_type = "INSFVMomentumDiffusion";
445  std::string kernel_name = prefix() + "ins_momentum_diffusion_";
446 
448  {
449  kernel_type = "PINSFVMomentumDiffusion";
450  kernel_name = prefix() + "pins_momentum_diffusion_";
451  }
452 
453  InputParameters params = getFactory().getValidParams(kernel_type);
454  assignBlocks(params, _blocks);
455  params.set<UserObjectName>("rhie_chow_user_object") = rhieChowUOName();
456  params.set<MooseFunctorName>(NS::mu) = _dynamic_viscosity_name;
457  params.set<MooseEnum>("mu_interp_method") = getParam<MooseEnum>("mu_interp_method");
458  params.set<MooseEnum>("variable_interp_method") =
459  getParam<MooseEnum>("momentum_face_interpolation");
460  if (getParam<bool>("include_deviatoric_stress"))
461  {
462  params.set<bool>("complete_expansion") = true;
463  const std::string u_names[3] = {"u", "v", "w"};
464  for (unsigned int i = 0; i < dimension(); ++i)
465  params.set<MooseFunctorName>(u_names[i]) = _velocity_names[i];
466  }
467 
469  params.set<MooseFunctorName>(NS::porosity) = _flow_porosity_functor_name;
470  // Currently only Newton method for WCNSFVFlowPhysics
471  params.set<bool>("newton_solve") = true;
472  for (const auto d : make_range(dimension()))
473  {
474  params.set<NonlinearVariableName>("variable") = _velocity_names[d];
475  params.set<MooseEnum>("momentum_component") = NS::directions[d];
476 
477  getProblem().addFVKernel(kernel_type, kernel_name + NS::directions[d], params);
478  }
479 }
480 
481 void
483 {
484  std::string kernel_type = "INSFVMomentumPressure";
485  std::string kernel_name = prefix() + "ins_momentum_pressure_";
486 
488  {
489  kernel_type = "PINSFVMomentumPressure";
490  kernel_name = prefix() + "pins_momentum_pressure_";
491  }
492 
493  InputParameters params = getFactory().getValidParams(kernel_type);
494  assignBlocks(params, _blocks);
495  params.set<UserObjectName>("rhie_chow_user_object") = rhieChowUOName();
496  params.set<MooseFunctorName>("pressure") = _pressure_name;
497  params.set<bool>("correct_skewness") =
498  getParam<MooseEnum>("pressure_face_interpolation") == "skewness-corrected";
500  params.set<MooseFunctorName>(NS::porosity) = _flow_porosity_functor_name;
501 
502  for (const auto d : make_range(dimension()))
503  {
504  params.set<MooseEnum>("momentum_component") = NS::directions[d];
505  params.set<NonlinearVariableName>("variable") = _velocity_names[d];
506  getProblem().addFVKernel(kernel_type, kernel_name + NS::directions[d], params);
507  }
508 }
509 
510 void
512 {
514  {
515  std::string kernel_type = "INSFVMomentumGravity";
516  std::string kernel_name = prefix() + "ins_momentum_gravity_";
517 
519  {
520  kernel_type = "PINSFVMomentumGravity";
521  kernel_name = prefix() + "pins_momentum_gravity_";
522  }
523 
524  InputParameters params = getFactory().getValidParams(kernel_type);
525  assignBlocks(params, _blocks);
526  params.set<UserObjectName>("rhie_chow_user_object") = rhieChowUOName();
527  params.set<MooseFunctorName>(NS::density) = _density_gravity_name;
528  params.set<RealVectorValue>("gravity") = getParam<RealVectorValue>("gravity");
530  params.set<MooseFunctorName>(NS::porosity) = _flow_porosity_functor_name;
531 
532  for (const auto d : make_range(dimension()))
533  {
534  if (getParam<RealVectorValue>("gravity")(d) != 0)
535  {
536  params.set<MooseEnum>("momentum_component") = NS::directions[d];
537  params.set<NonlinearVariableName>("variable") = _velocity_names[d];
538 
539  getProblem().addFVKernel(kernel_type, kernel_name + NS::directions[d], params);
540  }
541  }
542  }
543 }
544 
545 void
547 {
548  if (_compressibility == "weakly-compressible")
549  paramError("boussinesq_approximation",
550  "We cannot use boussinesq approximation while running in weakly-compressible mode!");
551 
552  std::string kernel_type = "INSFVMomentumBoussinesq";
553  std::string kernel_name = prefix() + "ins_momentum_boussinesq_";
554 
556  {
557  kernel_type = "PINSFVMomentumBoussinesq";
558  kernel_name = prefix() + "pins_momentum_boussinesq_";
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::T_fluid) = _fluid_temperature_name;
565  params.set<MooseFunctorName>(NS::density) = _density_gravity_name;
566  params.set<RealVectorValue>("gravity") = getParam<RealVectorValue>("gravity");
567  params.set<Real>("ref_temperature") = getParam<Real>("ref_temperature");
568  params.set<MooseFunctorName>("alpha_name") = getParam<MooseFunctorName>("thermal_expansion");
570  params.set<MooseFunctorName>(NS::porosity) = _flow_porosity_functor_name;
571  // User declared the flow to be incompressible, we have to trust them
572  params.set<bool>("_override_constant_check") = true;
573 
574  for (const auto d : make_range(dimension()))
575  {
576  params.set<MooseEnum>("momentum_component") = NS::directions[d];
577  params.set<NonlinearVariableName>("variable") = _velocity_names[d];
578 
579  getProblem().addFVKernel(kernel_type, kernel_name + NS::directions[d], params);
580  }
581 }
582 
583 void
585 {
586  unsigned int num_friction_blocks = _friction_blocks.size();
587  unsigned int num_used_blocks = num_friction_blocks ? num_friction_blocks : 1;
588 
589  const std::string kernel_type = "PINSFVMomentumFriction";
590  InputParameters params = getFactory().getValidParams(kernel_type);
591  params.set<MooseFunctorName>(NS::density) = _density_name;
592  params.set<UserObjectName>("rhie_chow_user_object") = rhieChowUOName();
594  params.set<MooseFunctorName>(NS::speed) = NS::speed;
595  params.set<bool>("standard_friction_formulation") =
596  getParam<bool>("standard_friction_formulation");
597  params.set<bool>("is_porous_medium") = _porous_medium_treatment;
598 
599  for (const auto block_i : make_range(num_used_blocks))
600  {
601  std::string block_name = "";
602  if (num_friction_blocks)
603  {
604  params.set<std::vector<SubdomainName>>("block") = _friction_blocks[block_i];
605  block_name = Moose::stringify(_friction_blocks[block_i]);
606  }
607  else
608  {
609  assignBlocks(params, _blocks);
610  block_name = std::to_string(block_i);
611  }
612 
613  for (const auto d : make_range(dimension()))
614  {
615  params.set<NonlinearVariableName>("variable") = _velocity_names[d];
616  params.set<MooseEnum>("momentum_component") = NS::directions[d];
617  for (unsigned int type_i = 0; type_i < _friction_types[block_i].size(); ++type_i)
618  {
619  const auto upper_name = MooseUtils::toUpper(_friction_types[block_i][type_i]);
620  if (upper_name == "DARCY")
621  {
622  params.set<MooseFunctorName>(NS::mu) = _dynamic_viscosity_name;
623  params.set<MooseFunctorName>("Darcy_name") = _friction_coeffs[block_i][type_i];
624  }
625  else if (upper_name == "FORCHHEIMER")
626  {
627  params.set<MooseFunctorName>(NS::speed) = NS::speed;
628  params.set<MooseFunctorName>("Forchheimer_name") = _friction_coeffs[block_i][type_i];
629  }
630  else
631  paramError("momentum_friction_types",
632  "Friction type '",
633  _friction_types[block_i][type_i],
634  "' is not implemented");
635  }
636 
637  getProblem().addFVKernel(kernel_type,
638  prefix() + "momentum_friction_" + block_name + "_" +
639  NS::directions[d],
640  params);
641  }
642 
643  if (_porous_medium_treatment && getParam<bool>("use_friction_correction"))
644  {
645  const std::string correction_kernel_type = "PINSFVMomentumFrictionCorrection";
646  InputParameters corr_params = getFactory().getValidParams(correction_kernel_type);
647  if (num_friction_blocks)
648  corr_params.set<std::vector<SubdomainName>>("block") = _friction_blocks[block_i];
649  else
650  assignBlocks(corr_params, _blocks);
651  corr_params.set<MooseFunctorName>(NS::density) = _density_name;
652  corr_params.set<UserObjectName>("rhie_chow_user_object") = rhieChowUOName();
653  corr_params.set<Real>("consistent_scaling") = getParam<Real>("consistent_scaling");
654  for (const auto d : make_range(dimension()))
655  {
656  corr_params.set<NonlinearVariableName>("variable") = _velocity_names[d];
657  corr_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  corr_params.set<MooseFunctorName>(NS::mu) = _dynamic_viscosity_name;
664  corr_params.set<MooseFunctorName>("Darcy_name") = _friction_coeffs[block_i][type_i];
665  }
666  else if (upper_name == "FORCHHEIMER")
667  {
668  corr_params.set<MooseFunctorName>(NS::speed) = NS::speed;
669  corr_params.set<MooseFunctorName>("Forchheimer_name") =
670  _friction_coeffs[block_i][type_i];
671  }
672  }
673 
674  getProblem().addFVKernel(correction_kernel_type,
675  prefix() + "pins_momentum_friction_correction_" + block_name +
676  "_" + NS::directions[d],
677  corr_params);
678  }
679  }
680  }
681 }
682 
683 void
685 {
686  // Check the size of the BC parameters
687  unsigned int num_velocity_functor_inlets = 0;
688  for (const auto & [bdy, momentum_outlet_type] : _momentum_inlet_types)
689  if (momentum_outlet_type == "fixed-velocity" || momentum_outlet_type == "fixed-pressure")
690  num_velocity_functor_inlets++;
691 
692  if (num_velocity_functor_inlets != _momentum_inlet_functors.size())
693  paramError("momentum_inlet_functors",
694  "Size (" + std::to_string(_momentum_inlet_functors.size()) +
695  ") is not the same as the number of entries in the momentum_inlet_types "
696  "subvector for fixed-velocities/pressures functors (size " +
697  std::to_string(num_velocity_functor_inlets) + ")");
698 
699  unsigned int flux_bc_counter = 0;
700  unsigned int velocity_pressure_counter = 0;
701  for (const auto & [inlet_bdy, momentum_inlet_type] : _momentum_inlet_types)
702  {
703  if (momentum_inlet_type == "fixed-velocity")
704  {
705  const std::string bc_type = "INSFVInletVelocityBC";
706  InputParameters params = getFactory().getValidParams(bc_type);
707  params.set<std::vector<BoundaryName>>("boundary") = {inlet_bdy};
708  if (_momentum_inlet_functors.size() < velocity_pressure_counter + 1)
709  paramError("momentum_inlet_functors",
710  "More non-flux inlets than inlet functors (" +
711  std::to_string(_momentum_inlet_functors.size()) + ")");
712 
713  // Check that enough functors have been provided for the dimension of the problem
714  const auto momentum_functors = libmesh_map_find(_momentum_inlet_functors, inlet_bdy);
715  if (momentum_functors.size() < dimension())
716  paramError("momentum_inlet_functors",
717  "Subvector for boundary '" + inlet_bdy + "' (size " +
718  std::to_string(momentum_functors.size()) +
719  ") is not the same size as the number of dimensions of the physics (" +
720  std::to_string(dimension()) + ")");
721 
722  for (const auto d : make_range(dimension()))
723  {
724  params.set<NonlinearVariableName>("variable") = _velocity_names[d];
725  params.set<MooseFunctorName>("functor") = momentum_functors[d];
726 
727  getProblem().addFVBC(bc_type, _velocity_names[d] + "_" + inlet_bdy, params);
728  }
729  ++velocity_pressure_counter;
730  }
731  else if (momentum_inlet_type == "fixed-pressure")
732  {
733  const std::string bc_type = "INSFVOutletPressureBC";
734  InputParameters params = getFactory().getValidParams(bc_type);
735  params.set<NonlinearVariableName>("variable") = _pressure_name;
736  if (_momentum_inlet_functors.size() < velocity_pressure_counter + 1)
737  paramError("momentum_inlet_functors",
738  "More non-flux inlets than inlet functors (" +
739  std::to_string(_momentum_inlet_functors.size()) + ")");
740 
741  params.set<FunctionName>("function") =
742  libmesh_map_find(_momentum_inlet_functors, inlet_bdy)[0];
743  params.set<std::vector<BoundaryName>>("boundary") = {inlet_bdy};
744 
745  getProblem().addFVBC(bc_type, _pressure_name + "_" + inlet_bdy, params);
746  ++velocity_pressure_counter;
747  }
748  else if (momentum_inlet_type == "flux-mass" || momentum_inlet_type == "flux-velocity")
749  {
750  {
751  const std::string bc_type =
752  _porous_medium_treatment ? "PWCNSFVMomentumFluxBC" : "WCNSFVMomentumFluxBC";
753  InputParameters params = getFactory().getValidParams(bc_type);
754 
755  if (_flux_inlet_directions.size())
756  params.set<Point>("direction") = _flux_inlet_directions[flux_bc_counter];
757 
758  params.set<MooseFunctorName>(NS::density) = _density_name;
759  params.set<std::vector<BoundaryName>>("boundary") = {inlet_bdy};
760  params.set<UserObjectName>("rhie_chow_user_object") = rhieChowUOName();
762  params.set<MooseFunctorName>(NS::porosity) = _porosity_name;
763  if (_flux_inlet_pps.size() < flux_bc_counter + 1)
764  paramError("flux_inlet_pps",
765  "More inlet flux BCs than inlet flux pps (" +
766  std::to_string(_flux_inlet_pps.size()) + ")");
767 
768  if (momentum_inlet_type == "flux-mass")
769  {
770  params.set<PostprocessorName>("mdot_pp") = _flux_inlet_pps[flux_bc_counter];
771  params.set<PostprocessorName>("area_pp") = "area_pp_" + inlet_bdy;
772  }
773  else
774  params.set<PostprocessorName>("velocity_pp") = _flux_inlet_pps[flux_bc_counter];
775 
776  for (const auto d : make_range(dimension()))
777  params.set<MooseFunctorName>(NS::velocity_vector[d]) = _velocity_names[d];
778 
779  for (const auto d : make_range(dimension()))
780  {
781  params.set<MooseEnum>("momentum_component") = NS::directions[d];
782  params.set<NonlinearVariableName>("variable") = _velocity_names[d];
783 
784  getProblem().addFVBC(bc_type, _velocity_names[d] + "_" + inlet_bdy, params);
785  }
786  }
787  {
788  const std::string bc_type = "WCNSFVMassFluxBC";
789  InputParameters params = getFactory().getValidParams(bc_type);
790  params.set<MooseFunctorName>(NS::density) = _density_name;
791  params.set<NonlinearVariableName>("variable") = _pressure_name;
792  params.set<std::vector<BoundaryName>>("boundary") = {inlet_bdy};
793 
794  if (_flux_inlet_directions.size())
795  params.set<Point>("direction") = _flux_inlet_directions[flux_bc_counter];
796 
797  if (momentum_inlet_type == "flux-mass")
798  {
799  params.set<PostprocessorName>("mdot_pp") = _flux_inlet_pps[flux_bc_counter];
800  params.set<PostprocessorName>("area_pp") = "area_pp_" + inlet_bdy;
801  }
802  else
803  params.set<PostprocessorName>("velocity_pp") = _flux_inlet_pps[flux_bc_counter];
804 
805  for (const auto d : make_range(dimension()))
806  params.set<MooseFunctorName>(NS::velocity_vector[d]) = _velocity_names[d];
807 
808  getProblem().addFVBC(bc_type, _pressure_name + "_" + inlet_bdy, params);
809  }
810 
811  // need to increment flux_bc_counter
812  ++flux_bc_counter;
813  }
814  }
815 }
816 
817 void
819 {
820  // Check the BCs size
821  unsigned int num_pressure_outlets = 0;
822  for (const auto & [bdy, momentum_outlet_type] : _momentum_outlet_types)
823  if (momentum_outlet_type == "fixed-pressure" ||
824  momentum_outlet_type == "fixed-pressure-zero-gradient")
825  num_pressure_outlets++;
826 
827  if (num_pressure_outlets != _pressure_functors.size())
828  paramError("pressure_functors",
829  "Size (" + std::to_string(_pressure_functors.size()) +
830  ") is not the same as the number of pressure outlet boundaries in "
831  "'fixed-pressure/fixed-pressure-zero-gradient' (size " +
832  std::to_string(num_pressure_outlets) + ")");
833 
834  const std::string u_names[3] = {"u", "v", "w"};
835  for (const auto & [outlet_bdy, momentum_outlet_type] : _momentum_outlet_types)
836  {
837  if (momentum_outlet_type == "zero-gradient" ||
838  momentum_outlet_type == "fixed-pressure-zero-gradient")
839  {
840  {
841  const std::string bc_type = _porous_medium_treatment ? "PINSFVMomentumAdvectionOutflowBC"
842  : "INSFVMomentumAdvectionOutflowBC";
843  InputParameters params = getFactory().getValidParams(bc_type);
844  params.set<std::vector<BoundaryName>>("boundary") = {outlet_bdy};
846  params.set<MooseFunctorName>(NS::porosity) = _flow_porosity_functor_name;
847  params.set<UserObjectName>("rhie_chow_user_object") = rhieChowUOName();
848  params.set<MooseFunctorName>(NS::density) = _density_name;
849 
850  for (unsigned int i = 0; i < dimension(); ++i)
851  params.set<MooseFunctorName>(u_names[i]) = _velocity_names[i];
852 
853  for (const auto d : make_range(dimension()))
854  {
855  params.set<NonlinearVariableName>("variable") = _velocity_names[d];
856  params.set<MooseEnum>("momentum_component") = NS::directions[d];
857 
858  getProblem().addFVBC(bc_type, _velocity_names[d] + "_" + outlet_bdy, params);
859  }
860  }
861  }
862 
863  if (momentum_outlet_type == "fixed-pressure" ||
864  momentum_outlet_type == "fixed-pressure-zero-gradient")
865  {
866  const std::string bc_type = "INSFVOutletPressureBC";
867  InputParameters params = getFactory().getValidParams(bc_type);
868  params.set<NonlinearVariableName>("variable") = _pressure_name;
869  params.set<MooseFunctorName>("functor") = libmesh_map_find(_pressure_functors, outlet_bdy);
870  params.set<std::vector<BoundaryName>>("boundary") = {outlet_bdy};
871 
872  getProblem().addFVBC(bc_type, _pressure_name + "_" + outlet_bdy, params);
873  }
874  else if (momentum_outlet_type == "zero-gradient")
875  {
876  const std::string bc_type = "INSFVMassAdvectionOutflowBC";
877  InputParameters params = getFactory().getValidParams(bc_type);
878  params.set<NonlinearVariableName>("variable") = _pressure_name;
879  params.set<MooseFunctorName>(NS::density) = _density_name;
880  params.set<std::vector<BoundaryName>>("boundary") = {outlet_bdy};
881 
882  for (const auto d : make_range(dimension()))
883  params.set<MooseFunctorName>(u_names[d]) = _velocity_names[d];
884 
885  getProblem().addFVBC(bc_type, _pressure_name + "_" + outlet_bdy, params);
886  }
887  }
888 }
889 
890 void
892 {
893  const std::string u_names[3] = {"u", "v", "w"};
894 
895  // Count the number of fixed velocity wall boundaries (moving walls)
896  unsigned int num_functor_walls = 0;
897  for (const auto & [boundary_name, momentum_wall_type] : _momentum_wall_types)
898  if (momentum_wall_type == "noslip")
899  num_functor_walls++;
900  if (_momentum_wall_functors.size() && num_functor_walls != _momentum_wall_functors.size())
901  paramError("momentum_wall_functors",
902  "If any wall functors are specified, the number of boundaries requiring a momentum "
903  "functor (" +
904  std::to_string(num_functor_walls) + ") and the number of functors specified (" +
905  std::to_string(_momentum_wall_functors.size()) + ") must match");
906  for (const auto & wall_functors : _momentum_wall_functors)
907  if (wall_functors.second.size() != dimension())
908  paramError("momentum_wall_functors",
909  "Number of wall functors (" + std::to_string(wall_functors.second.size()) +
910  ") must match dimension (" + std::to_string(dimension()) +
911  ").\nFunctors currently specified:" + Moose::stringify(wall_functors.second));
912 
913  for (const auto & [boundary_name, wall_type] : _momentum_wall_types)
914  {
915  if (wall_type == "noslip")
916  {
917  const std::string bc_type = "INSFVNoSlipWallBC";
918  InputParameters params = getFactory().getValidParams(bc_type);
919  params.set<std::vector<BoundaryName>>("boundary") = {boundary_name};
920 
921  for (const auto d : make_range(dimension()))
922  {
923  params.set<NonlinearVariableName>("variable") = _velocity_names[d];
924  if (_momentum_wall_functors.count(boundary_name) == 0)
925  params.set<FunctionName>("function") = "0";
926  else
927  params.set<FunctionName>("function") = _momentum_wall_functors[boundary_name][d];
928 
929  getProblem().addFVBC(bc_type, _velocity_names[d] + "_" + boundary_name, params);
930  }
931  }
932  else if (wall_type == "wallfunction")
933  {
934  const std::string bc_type = "INSFVWallFunctionBC";
935  InputParameters params = getFactory().getValidParams(bc_type);
936  params.set<MooseFunctorName>(NS::mu) = _dynamic_viscosity_name;
937  params.set<MooseFunctorName>(NS::density) = _density_name;
938  params.set<std::vector<BoundaryName>>("boundary") = {boundary_name};
939  params.set<UserObjectName>("rhie_chow_user_object") = rhieChowUOName();
940 
941  for (const auto d : make_range(dimension()))
942  params.set<MooseFunctorName>(u_names[d]) = _velocity_names[d];
943 
944  for (const auto d : make_range(dimension()))
945  {
946  params.set<NonlinearVariableName>("variable") = _velocity_names[d];
947  params.set<MooseEnum>("momentum_component") = NS::directions[d];
948 
949  getProblem().addFVBC(bc_type, _velocity_names[d] + "_" + boundary_name, params);
950  }
951  }
952  else if (wall_type == "slip")
953  {
954  const std::string bc_type = "INSFVNaturalFreeSlipBC";
955  InputParameters params = getFactory().getValidParams(bc_type);
956  params.set<std::vector<BoundaryName>>("boundary") = {boundary_name};
957  params.set<UserObjectName>("rhie_chow_user_object") = rhieChowUOName();
958 
959  for (const auto d : make_range(dimension()))
960  {
961  params.set<NonlinearVariableName>("variable") = _velocity_names[d];
962  params.set<MooseEnum>("momentum_component") = NS::directions[d];
963 
964  getProblem().addFVBC(bc_type, _velocity_names[d] + "_" + boundary_name, params);
965  }
966  }
967  else if (wall_type == "symmetry")
968  {
969  {
970  std::string bc_type;
972  bc_type = "PINSFVSymmetryVelocityBC";
973  else
974  bc_type = "INSFVSymmetryVelocityBC";
975 
976  InputParameters params = getFactory().getValidParams(bc_type);
977  params.set<std::vector<BoundaryName>>("boundary") = {boundary_name};
978 
979  MooseFunctorName viscosity_name = _dynamic_viscosity_name;
980  if (hasTurbulencePhysics())
981  viscosity_name = NS::total_viscosity;
982  params.set<MooseFunctorName>(NS::mu) = viscosity_name;
983  params.set<UserObjectName>("rhie_chow_user_object") = rhieChowUOName();
984 
985  for (const auto d : make_range(dimension()))
986  params.set<MooseFunctorName>(u_names[d]) = _velocity_names[d];
987 
988  for (const auto d : make_range(dimension()))
989  {
990  params.set<NonlinearVariableName>("variable") = _velocity_names[d];
991  params.set<MooseEnum>("momentum_component") = NS::directions[d];
992 
993  getProblem().addFVBC(bc_type, _velocity_names[d] + "_" + boundary_name, params);
994  }
995  }
996  {
997  const std::string bc_type = "INSFVSymmetryPressureBC";
998  InputParameters params = getFactory().getValidParams(bc_type);
999  params.set<NonlinearVariableName>("variable") = _pressure_name;
1000  params.set<std::vector<BoundaryName>>("boundary") = {boundary_name};
1001 
1002  getProblem().addFVBC(bc_type, _pressure_name + "_" + boundary_name, params);
1003  }
1004  }
1005  }
1006 }
1007 
1008 void
1010 {
1011  if (_hydraulic_separators.size())
1012  {
1013  std::string bc_type = "INSFVVelocityHydraulicSeparatorBC";
1014  InputParameters params = getFactory().getValidParams(bc_type);
1015  params.set<std::vector<BoundaryName>>("boundary") = _hydraulic_separators;
1016  params.set<UserObjectName>("rhie_chow_user_object") = rhieChowUOName();
1017 
1018  for (const auto d : make_range(dimension()))
1019  {
1020  params.set<NonlinearVariableName>("variable") = _velocity_names[d];
1021  params.set<MooseEnum>("momentum_component") = NS::directions[d];
1022  getProblem().addFVBC(bc_type, prefix() + _velocity_names[d] + "_separators", params);
1023  }
1024 
1025  bc_type = "INSFVScalarFieldSeparatorBC";
1026  params = getFactory().getValidParams(bc_type);
1027  params.set<std::vector<BoundaryName>>("boundary") = _hydraulic_separators;
1028  params.set<NonlinearVariableName>("variable") = _pressure_name;
1029  getProblem().addFVBC(bc_type, prefix() + _pressure_name + "_separators", params);
1030  }
1031 }
1032 
1033 void
1035 {
1036  // Rhie Chow user object for interpolation velocities
1038 }
1039 
1040 void
1042 {
1043  if (!_has_flow_equations)
1044  return;
1045 
1046  // Pressure pin
1047  if (getParam<bool>("pin_pressure"))
1048  {
1049  const auto pin_type = getParam<MooseEnum>("pinned_pressure_type");
1050  std::string object_type = "NSPressurePin";
1051 
1052  // No need for the user object
1053  if (pin_type == "point-value" || pin_type == "average")
1054  return;
1055 
1056  // Create the average value postprocessor if needed
1057  if (pin_type == "average-uo")
1058  {
1059  // Volume average by default, but we could do inlet or outlet for example
1060  InputParameters params = getFactory().getValidParams("ElementAverageValue");
1061  params.set<std::vector<VariableName>>("variable") = {_pressure_name};
1062  assignBlocks(params, _blocks);
1063  params.set<std::vector<OutputName>>("outputs") = {"none"};
1064  getProblem().addPostprocessor("ElementAverageValue", "ns_pressure_average", params);
1065  }
1066 
1067  InputParameters params = getFactory().getValidParams(object_type);
1068  if (pin_type == "point-value" || pin_type == "point-value-uo")
1069  params.set<MooseEnum>("pin_type") = "point-value";
1070  else
1071  params.set<MooseEnum>("pin_type") = "average";
1072 
1073  params.set<PostprocessorName>("phi0") = getParam<PostprocessorName>("pinned_pressure_value");
1074  params.set<NonlinearVariableName>("variable") = _pressure_name;
1075  if (pin_type == "point-value" || pin_type == "point-value-uo")
1076  params.set<Point>("point") = getParam<Point>("pinned_pressure_point");
1077  else if (pin_type == "average-uo")
1078  params.set<PostprocessorName>("pressure_average") = "ns_pressure_average";
1079 
1080  getProblem().addUserObject(object_type, prefix() + "ins_mass_pressure_pin", params);
1081  }
1082 }
1083 
1084 bool
1086 {
1087  for (const auto block_i : index_range(_friction_types))
1088  for (const auto type_i : index_range(_friction_types[block_i]))
1089  if (MooseUtils::toUpper(_friction_types[block_i][type_i]) == "FORCHHEIMER")
1090  return true;
1091  return false;
1092 }
1093 
1094 unsigned short
1096 {
1098  if (_porous_medium_treatment && isParamValid("porosity_smoothing_layers"))
1099  ghost_layers = std::max(getParam<unsigned short>("porosity_smoothing_layers"), ghost_layers);
1100  if ((_porous_medium_treatment &&
1101  getParam<MooseEnum>("porosity_interface_pressure_treatment") != "automatic") ||
1102  getParam<MooseEnum>("momentum_face_interpolation") == "skewness-corrected" ||
1103  getParam<MooseEnum>("pressure_face_interpolation") == "skewness-corrected")
1104  ghost_layers = std::max(ghost_layers, (unsigned short)3);
1105  return ghost_layers;
1106 }
1107 
1108 void
1110 {
1111  mooseAssert(dimension(), "0-dimension not supported");
1112 
1113  // First make sure that we only add this object once
1114  // Potential cases:
1115  // - there is a flow physics, and an advection one (UO should be added by one)
1116  // - there is only an advection physics (UO should be created)
1117  // - there are two advection physics on different blocks with set velocities (first one picks)
1118  // Counting RC UOs defined on the same blocks seems to be the most fool proof option
1119  std::vector<UserObject *> objs;
1120  getProblem()
1121  .theWarehouse()
1122  .query()
1123  .condition<AttribSystem>("UserObject")
1124  .condition<AttribThread>(0)
1125  .queryInto(objs);
1126  bool have_matching_rc_uo = false;
1127  for (const auto & obj : objs)
1128  if (const auto * const rc_obj = dynamic_cast<INSFVRhieChowInterpolator *>(obj); rc_obj)
1129  // Latter check is for whether one of the RC user object is defined everywhere
1130  if (rc_obj->blocks() == _blocks || (rc_obj->blocks().size() == 0 || _blocks.size() == 0))
1131  {
1132  have_matching_rc_uo = true;
1133  _rc_uo_name = rc_obj->name();
1134  break;
1135  }
1136 
1137  if (have_matching_rc_uo)
1138  return;
1139 
1140  _rc_uo_name =
1141  _porous_medium_treatment ? +"pins_rhie_chow_interpolator" : "ins_rhie_chow_interpolator";
1142 
1143  const std::string u_names[3] = {"u", "v", "w"};
1144  const auto object_type =
1145  _porous_medium_treatment ? "PINSFVRhieChowInterpolator" : "INSFVRhieChowInterpolator";
1146 
1147  auto params = getFactory().getValidParams(object_type);
1148  assignBlocks(params, _blocks);
1149  for (unsigned int d = 0; d < dimension(); ++d)
1150  params.set<VariableName>(u_names[d]) = _velocity_names[d];
1151 
1152  params.set<VariableName>("pressure") = _pressure_name;
1153 
1155  {
1156  params.set<MooseFunctorName>(NS::porosity) = _porosity_name;
1157  unsigned short smoothing_layers = isParamValid("porosity_smoothing_layers")
1158  ? getParam<unsigned short>("porosity_smoothing_layers")
1159  : 0;
1160  params.set<unsigned short>("smoothing_layers") = smoothing_layers;
1161  }
1162 
1163  if (!_has_flow_equations)
1164  {
1166  params.set<MooseFunctorName>("a_u") = "ax";
1167  params.set<MooseFunctorName>("a_v") = "ay";
1168  params.set<MooseFunctorName>("a_w") = "az";
1169  }
1170 
1171  params.applySpecificParameters(parameters(), INSFVRhieChowInterpolator::listOfCommonParams());
1172  getProblem().addUserObject(object_type, _rc_uo_name, params);
1173 }
1174 
1175 void
1177 {
1178  if (!getProblem().hasFunctor("ax", /*thread_id=*/0))
1179  mooseError("Rhie Chow coefficient ax must be provided for advection by auxiliary velocities");
1180  if (dimension() >= 2 && !getProblem().hasFunctor("ay", /*thread_id=*/0))
1181  mooseError("Rhie Chow coefficient ay must be provided for advection by auxiliary velocities");
1182  if (dimension() == 3 && !getProblem().hasFunctor("az", /*thread_id=*/0))
1183  mooseError("Rhie Chow coefficient az must be provided for advection by auxiliary velocities");
1184 }
1185 
1186 UserObjectName
1188 {
1189  mooseAssert(!_rc_uo_name.empty(), "The Rhie-Chow user-object name should be set!");
1190  return _rc_uo_name;
1191 }
1192 
1193 MooseFunctorName
1195 {
1196  // Check all blocks. If more than one block, they would need to be consolidated #include in
1197  // a single functor material. We won't implement this for now
1198  if (_friction_types.empty())
1199  return "";
1200  else if (_friction_types.size() == 1)
1201  {
1202  for (const auto & type_i : index_range(_friction_types[0]))
1203  {
1204  const auto upper_name = MooseUtils::toUpper(_friction_types[0][type_i]);
1205  if (upper_name == "DARCY")
1206  return _friction_coeffs[0][type_i];
1207  }
1208  // No linear type found
1209  return "";
1210  }
1211  else if (_friction_types.size() > 1)
1212  {
1213  bool linear_friction_factor_found = false;
1214  MooseFunctorName linear_friction_factor;
1215  for (const auto block_i : index_range(_friction_types))
1216  for (const auto type_i : index_range(_friction_types[block_i]))
1217  {
1218  const auto upper_name = MooseUtils::toUpper(_friction_types[block_i][type_i]);
1219  if (upper_name == "DARCY" && !linear_friction_factor_found)
1220  {
1221  linear_friction_factor_found = true;
1222  linear_friction_factor = _friction_types[block_i][type_i];
1223  }
1224  else if (upper_name == "DARCY" && !linear_friction_factor_found)
1225  if (linear_friction_factor != _friction_types[block_i][type_i])
1226  mooseError("Multiple linear friction factor with different names have been specified. "
1227  "This is not currently supported as a single name should be retrievable. "
1228  "Use a PiecewiseByBlockFunctorMaterial to consolidate them.");
1229  }
1230  if (linear_friction_factor_found)
1231  return linear_friction_factor;
1232  else
1233  return "";
1234  }
1235  mooseError("Should not get here");
1236 }
std::string prefix() const
static InputParameters validParams()
Definition: NSFVBase.C:368
void addMomentumTimeKernels() override
Functions adding kernels for the incompressible momentum equation If the material properties are not ...
const bool _has_flow_equations
Boolean to keep track of whether the flow equations should be created.
void addMomentumBoussinesqKernels() override
unsigned short getNumberAlgebraicGhostingLayersNeeded() const override
Return the number of algebraic ghosting layers needed.
void assignBlocks(InputParameters &params, const std::vector< SubdomainName > &blocks) const
bool shouldCreateVariable(const VariableName &var_name, const std::vector< SubdomainName > &blocks, const bool error_if_aux)
Factory & getFactory()
std::vector< std::vector< std::string > > _friction_types
The friction correlation types used for each block.
std::map< BoundaryName, MooseEnum > _momentum_inlet_types
Momentum inlet boundary types.
std::string toUpper(const std::string &name)
static const std::string speed
Definition: NS.h:143
static InputParameters validParams()
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
void applySpecificParameters(const InputParameters &common, const std::vector< std::string > &include, bool allow_private=false)
void addInletBC() override
Functions adding boundary conditions for the incompressible simulation.
const MooseFunctorName _density_name
Name of the density material property.
const MooseFunctorName _density_gravity_name
Name of the density material property used for gravity and Boussinesq terms.
static const std::string smoothed_porosity
Definition: NS.h:105
void addMomentumViscousDissipationKernels()
virtual void addUserObjects() override
void addMassKernels()
Function adding kernels for the incompressible continuity equation.
void addPressurePinKernel()
Function adding the pressure constraint.
T & set(const std::string &name, bool quiet_mode=false)
static const std::string density
Definition: NS.h:33
InputParameters getValidParams(const std::string &name) const
Creates all the objects needed to solve the Navier Stokes mass and momentum equations.
UserObjectName _rc_uo_name
Name of the user object in charge of computing the Rhie Chow coefficients.
void checkRhieChowFunctorsDefined() const
Checks that sufficient Rhie Chow coefficients have been defined for the given dimension, used for scalar or temperature advection by auxiliary variables.
std::map< BoundaryName, std::vector< MooseFunctorName > > _momentum_inlet_functors
Functors describing the momentum inlet for each boundary.
const MooseEnum _momentum_advection_interpolation
The momentum face interpolation method for being advected.
std::map< BoundaryName, std::vector< MooseFunctorName > > _momentum_wall_functors
Functors describing the momentum for each wall boundary.
const NonlinearVariableName _pressure_name
Pressure name.
const MooseFunctorName _porosity_name
Name of the porosity functor.
bool shouldCreateTimeDerivative(const VariableName &var_name, const std::vector< SubdomainName > &blocks, const bool error_if_already_defined) const
static const std::string pin_type
static InputParameters validParams()
static InputParameters validParams()
const bool _porous_medium_treatment
Whether to use the porous medium treatment.
std::vector< SubdomainName > _blocks
unsigned int dimension() const
static const std::string directions[3]
Definition: NS.h:22
void addRhieChowUserObjects() override
Function which adds the RhieChow interpolator user objects for weakly and incompressible formulations...
void errorDependentParameter(const std::string &param1, const std::string &value_not_set, const std::vector< std::string > &dependent_params) const
bool isParamValid(const std::string &name) const
UserObjectName rhieChowUOName() const override
Return the name of the Rhie Chow user object.
virtual FEProblemBase & getProblem()
virtual void addPostprocessor(const std::string &pp_name, const std::string &name, InputParameters &parameters)
static const std::string porosity
Definition: NS.h:104
void addOutletBC() override
virtual void addCorrectors() override
WCNSFVFlowPhysics(const InputParameters &parameters)
unsigned short getNumberAlgebraicGhostingLayersNeeded() const override
Return the number of algebraic ghosting layers needed.
const SolverSystemName & getSolverSystem(unsigned int variable_index) const
static const std::string T_fluid
Definition: NS.h:106
std::vector< std::vector< SubdomainName > > _friction_blocks
Subdomains where we want to have volumetric friction.
void addMassTimeKernels()
Function adding kernels for the time derivative term of the weakly compressible continuity equation...
std::vector< PostprocessorName > _flux_inlet_pps
Postprocessors describing the momentum inlet for each boundary. Indexing based on the number of flux ...
TheWarehouse & theWarehouse() const
void addMomentumPressureKernels() override
std::map< BoundaryName, MooseEnum > _momentum_outlet_types
Momentum outlet boundary types.
static const std::string mu
Definition: NS.h:123
const std::vector< std::string > _velocity_names
Velocity names.
static std::vector< std::string > listOfCommonParams()
const std::string & type() const
Base class for Physics which create the Navier Stokes flow equations.
const T & getParam(const std::string &name) const
void paramError(const std::string &param, Args... args) const
const MooseFunctorName _dynamic_viscosity_name
Name of the dynamic viscosity material property.
std::string stringify(const T &t)
const bool _solve_for_dynamic_pressure
Whether we are solving for the total or dynamic pressure.
void transferParam(const InputParameters &source_param, const std::string &name, const std::string &new_name="", const std::string &new_description="")
virtual void addVariable(const std::string &var_type, const std::string &var_name, InputParameters &params)
const MooseEnum _compressibility
Compressibility type, can be compressible, incompressible or weakly-compressible. ...
void addSeparatorBC() override
MooseFunctorName _flow_porosity_functor_name
Name of the porosity functor for the flow equations (if smoothed)
bool _define_variables
Whether to define variables if they do not exist.
virtual void addSolverVariables() override
virtual MooseFunctorName getLinearFrictionCoefName() const override
Get the name of the linear friction coefficient. Returns an empty string if no friction.
static std::vector< std::string > listOfCommonParams()
void addMomentumFrictionKernels() override
void addMomentumGravityKernels() override
bool isParamSetByUser(const std::string &nm) const
std::map< BoundaryName, MooseEnum > _momentum_wall_types
Momentum wall boundary types.
const NonlinearVariableName _fluid_temperature_name
Fluid temperature name.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
const MooseEnum _velocity_interpolation
The velocity face interpolation method for advecting other quantities.
std::vector< VariableName > CoupledName
std::map< BoundaryName, MooseFunctorName > _pressure_functors
Functors describing the outlet pressure on each boundary.
bool hasTurbulencePhysics() const
Whether a turbulence Physics has been coupled in, to know which viscosity to pick on symmetry boundar...
virtual std::vector< std::shared_ptr< UserObject > > addUserObject(const std::string &user_object_name, const std::string &name, InputParameters &parameters)
Query query()
IntRange< T > make_range(T beg, T end)
void mooseError(Args &&... args) const
registerWCNSFVFlowPhysicsBaseTasks("NavierStokesApp", WCNSFVFlowPhysics)
const std::vector< BoundaryName > _hydraulic_separators
Hydraulic separator boundaries.
void addClassDescription(const std::string &doc_string)
std::shared_ptr< FEProblemBase > & _problem
const InputParameters & parameters() const
void addMomentumAdvectionKernels()
void reportPotentiallyMissedParameters(const std::vector< std::string > &param_names, const std::string &object_type) const
const std::string velocity_vector[3]
Definition: NS.h:49
registerMooseAction("NavierStokesApp", WCNSFVFlowPhysics, "add_fv_kernel")
std::vector< Point > _flux_inlet_directions
Direction of each flux inlet. Indexing based on the number of flux boundaries.
void checkSecondParamSetOnlyIfFirstOneTrue(const std::string &param1, const std::string &param2) const
void addWallsBC() override
virtual void addFVKernel(const std::string &kernel_name, const std::string &name, InputParameters &parameters)
virtual void addFVBC(const std::string &fv_bc_name, const std::string &name, InputParameters &parameters)
void saveSolverVariableName(const VariableName &var_name)
static const std::string total_viscosity
Definition: NS.h:78
auto index_range(const T &sizable)
bool isTransient() const
std::vector< std::vector< std::string > > _friction_coeffs
The coefficients used for each item if friction type.
bool hasForchheimerFriction() const override
Return whether a Forchheimer friction model is in use.
virtual void addFVKernels() override
std::string time_deriv(const std::string &var)
Definition: NS.h:97
void addParamNamesToGroup(const std::string &space_delim_names, const std::string group_name)