LCOV - code coverage report
Current view: top level - src/physics - WCNSFVFlowPhysicsBase.C (source / functions) Hit Total Coverage
Test: idaholab/moose navier_stokes: #32971 (54bef8) with base c6cf66 Lines: 286 308 92.9 %
Date: 2026-05-29 20:37:52 Functions: 17 18 94.4 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //* This file is part of the MOOSE framework
       2             : //* https://mooseframework.inl.gov
       3             : //*
       4             : //* All rights reserved, see COPYRIGHT for full restrictions
       5             : //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
       6             : //*
       7             : //* Licensed under LGPL 2.1, please see LICENSE for details
       8             : //* https://www.gnu.org/licenses/lgpl-2.1.html
       9             : 
      10             : #include "WCNSFVFlowPhysicsBase.h"
      11             : #include "WCNSLinearFVFlowPhysics.h"
      12             : #include "WCNSFVTurbulencePhysics.h"
      13             : #include "NSFVBase.h"
      14             : #include "MapConversionUtils.h"
      15             : #include "NS.h"
      16             : #include "MooseMesh.h"
      17             : 
      18             : InputParameters
      19        1163 : WCNSFVFlowPhysicsBase::validParams()
      20             : {
      21        1163 :   InputParameters params = NavierStokesPhysicsBase::validParams();
      22        1163 :   params.addClassDescription("Base class for Physics defining the Navier Stokes flow equations");
      23             : 
      24        1163 :   params += NSFVBase::commonMomentumEquationParams();
      25        2326 :   params.addParam<bool>("add_flow_equations",
      26        2326 :                         true,
      27             :                         "Whether to add the flow equations. This parameter is not necessary when "
      28             :                         "using the Physics syntax");
      29             : 
      30             :   // We pull in parameters from various flow objects. This helps make sure the parameters are
      31             :   // spelled the same way and match the evolution of other objects.
      32             :   // If we remove these objects, or change their parameters, these parameters should be updated
      33             :   // Downstream actions must either implement all these options, or redefine the parameter with
      34             :   // a restricted MooseEnum, or place an error in the constructor for unsupported configurations
      35             :   // We mostly pull the boundary parameters from NSFV Action
      36             : 
      37        1163 :   params += NSFVBase::commonNavierStokesFlowParams();
      38        2326 :   params.addParam<bool>("include_deviatoric_stress",
      39        2326 :                         false,
      40             :                         "Whether to include the symmetrized viscous stress contribution "
      41             :                         "(grad(u)+grad(u)^T).");
      42        2326 :   params.deprecateParam(
      43             :       "include_deviatoric_stress", "include_symmetrized_viscous_stress", "12/31/2025");
      44        2326 :   params.addParam<bool>("include_isotropic_viscous_stress",
      45        2326 :                         false,
      46             :                         "Whether to add the isotropic -(2/3) mu div(u) I contribution to the "
      47             :                         "viscous stress (requires complete expansion of the velocity gradient).");
      48        2326 :   params.addParam<bool>("add_rz_viscous_source",
      49        2326 :                         true,
      50             :                         "When true, automatically adds INSFVMomentumViscousSourceRZ to the radial "
      51             :                         "momentum equation on RZ blocks. Disable if this term should be omitted.");
      52             : 
      53             :   // Momentum boundary conditions are important for advection problems as well
      54        1163 :   params += NSFVBase::commonMomentumBoundaryTypesParams();
      55             : 
      56             :   // Convenient for sharing the executioner block with a non-Physics syntax
      57             :   // or for defining the RhieChow user object outside the Physics
      58        2326 :   params.addParam<UserObjectName>(
      59             :       "rhie_chow_uo_name",
      60             :       "Name of the Rhie Chow user object. Defaults to 'pins_rhie_chow_interpolator' for porous "
      61             :       "flow and 'ins_rhie_chow_interpolator' for non-porous.");
      62             : 
      63             :   // Specify the weakly compressible boundary flux information. They are used for specifying in flux
      64             :   // boundary conditions for advection physics in WCNSFV
      65        1163 :   params += NSFVBase::commonMomentumBoundaryFluxesParams();
      66        2326 :   params.addParam<std::vector<std::vector<MooseFunctorName>>>(
      67             :       "momentum_wall_functors",
      68             :       {},
      69             :       "Functors for each component of the velocity value on walls. This is only necessary for the "
      70             :       "fixed-velocity momentum wall types.");
      71             : 
      72             :   // Most downstream physics implementations are valid for porous media too
      73             :   // If yours is not, please remember to disable the 'porous_medium_treatment' parameter
      74        1163 :   params.transferParam<bool>(NSFVBase::validParams(), "porous_medium_treatment");
      75        1163 :   params.transferParam<MooseFunctorName>(NSFVBase::validParams(), "porosity");
      76             : 
      77             :   // Initialization parameters
      78        1163 :   params.transferParam<std::vector<FunctionName>>(NSFVBase::validParams(), "initial_velocity");
      79        1163 :   params.transferParam<FunctionName>(NSFVBase::validParams(), "initial_pressure");
      80             : 
      81             :   // Spatial discretization scheme
      82             :   // Specify the numerical schemes for interpolations of velocity and pressure
      83        1163 :   params.transferParam<MooseEnum>(NSFVBase::validParams(), "velocity_interpolation");
      84        1163 :   params.transferParam<MooseEnum>(NSFVBase::validParams(), "momentum_advection_interpolation");
      85        1163 :   params.transferParam<MooseEnum>(NSFVBase::validParams(), "momentum_face_interpolation");
      86        1163 :   params.transferParam<bool>(NSFVBase::validParams(), "momentum_two_term_bc_expansion");
      87        1163 :   params.transferParam<bool>(NSFVBase::validParams(), "pressure_two_term_bc_expansion");
      88        2326 :   MooseEnum coeff_interp_method("average harmonic", "harmonic");
      89        2326 :   params.addParam<MooseEnum>("mu_interp_method",
      90             :                              coeff_interp_method,
      91             :                              "Switch that can select face interpolation method for the viscosity.");
      92             : 
      93             :   // Fluid properties
      94        1163 :   params.addParam<UserObjectName>(NS::fluid, "Fluid properties userobject");
      95        2326 :   params.addParam<FunctionName>(
      96        2326 :       "mu_rampdown", 1, "A function describing a ramp down of viscosity over time");
      97        2326 :   params.addParamNamesToGroup(NS::fluid + " mu_rampdown", "Material properties");
      98             : 
      99             :   // Parameter groups
     100        2326 :   params.addParamNamesToGroup(
     101             :       "velocity_variable pressure_variable initial_pressure initial_velocity", "Variables");
     102        2326 :   params.addParamNamesToGroup("density dynamic_viscosity", "Material properties");
     103        2326 :   params.addParamNamesToGroup("inlet_boundaries momentum_inlet_types momentum_inlet_functors",
     104             :                               "Inlet boundary conditions");
     105        2326 :   params.addParamNamesToGroup("outlet_boundaries momentum_outlet_types pressure_functors",
     106             :                               "Outlet boundary conditions");
     107        2326 :   params.addParamNamesToGroup("wall_boundaries momentum_wall_types momentum_wall_functors",
     108             :                               "Wall boundary conditions");
     109        2326 :   params.addParamNamesToGroup(
     110             :       "include_symmetrized_viscous_stress include_isotropic_viscous_stress velocity_interpolation "
     111             :       "momentum_advection_interpolation momentum_two_term_bc_expansion "
     112             :       "pressure_two_term_bc_expansion mu_interp_method momentum_face_interpolation",
     113             :       "Numerical scheme");
     114        2326 :   params.addParamNamesToGroup("thermal_expansion", "Gravity treatment");
     115             : 
     116        1163 :   return params;
     117        1163 : }
     118             : 
     119        1163 : WCNSFVFlowPhysicsBase::WCNSFVFlowPhysicsBase(const InputParameters & parameters)
     120             :   : NavierStokesPhysicsBase(parameters),
     121        2326 :     _has_flow_equations(getParam<bool>("add_flow_equations")),
     122        2326 :     _add_rz_viscous_source(getParam<bool>("add_rz_viscous_source")),
     123        2326 :     _compressibility(getParam<MooseEnum>("compressibility")),
     124        2326 :     _solve_for_dynamic_pressure(getParam<bool>("solve_for_dynamic_pressure")),
     125        2326 :     _porous_medium_treatment(getParam<bool>("porous_medium_treatment")),
     126        2326 :     _porosity_name(getParam<MooseFunctorName>("porosity")),
     127             :     _flow_porosity_functor_name(_porosity_name),
     128        2521 :     _velocity_names(
     129        1163 :         isParamValid("velocity_variable")
     130        1163 :             ? getParam<std::vector<std::string>>("velocity_variable")
     131         968 :             : (_porous_medium_treatment
     132         968 :                    ? std::vector<std::string>(NS::superficial_velocity_vector,
     133             :                                               NS::superficial_velocity_vector + 3)
     134             :                    : std::vector<std::string>(NS::velocity_vector, NS::velocity_vector + 3))),
     135        2476 :     _pressure_name(isParamValid("pressure_variable")
     136        1463 :                        ? getParam<NonlinearVariableName>("pressure_variable")
     137             :                        : NS::pressure),
     138        2358 :     _fluid_temperature_name(isParamValid("fluid_temperature_variable")
     139        1227 :                                 ? getParam<NonlinearVariableName>("fluid_temperature_variable")
     140             :                                 : NS::T_fluid),
     141        1163 :     _density_name(getParam<MooseFunctorName>("density")),
     142        2326 :     _density_gravity_name(isParamValid("density_for_gravity_terms")
     143        1163 :                               ? getParam<MooseFunctorName>("density_for_gravity_terms")
     144        3489 :                               : getParam<MooseFunctorName>("density")),
     145        1163 :     _dynamic_viscosity_name(getParam<MooseFunctorName>("dynamic_viscosity")),
     146        2326 :     _include_symmetrized_viscous_stress(getParam<bool>("include_symmetrized_viscous_stress")),
     147        2326 :     _include_isotropic_viscous_stress(getParam<bool>("include_isotropic_viscous_stress")),
     148        2332 :     _rc_uo_name(isParamValid("rhie_chow_uo_name")
     149        1163 :                     ? getParam<UserObjectName>("rhie_chow_uo_name")
     150        1157 :                     : (_porous_medium_treatment ? "pins_rhie_chow_interpolator"
     151             :                                                 : "ins_rhie_chow_interpolator")),
     152        2326 :     _velocity_interpolation(getParam<MooseEnum>("velocity_interpolation")),
     153        2326 :     _momentum_advection_interpolation(getParam<MooseEnum>("momentum_advection_interpolation")),
     154        2326 :     _momentum_face_interpolation(getParam<MooseEnum>("momentum_face_interpolation")),
     155        2326 :     _friction_blocks(getParam<std::vector<std::vector<SubdomainName>>>("friction_blocks")),
     156        2326 :     _friction_types(getParam<std::vector<std::vector<std::string>>>("friction_types")),
     157        2326 :     _friction_coeffs(getParam<std::vector<std::vector<std::string>>>("friction_coeffs")),
     158        2326 :     _inlet_boundaries(getParam<std::vector<BoundaryName>>("inlet_boundaries")),
     159        2326 :     _outlet_boundaries(getParam<std::vector<BoundaryName>>("outlet_boundaries")),
     160        2326 :     _wall_boundaries(getParam<std::vector<BoundaryName>>("wall_boundaries")),
     161        3489 :     _hydraulic_separators(getParam<std::vector<BoundaryName>>("hydraulic_separator_sidesets")),
     162        2326 :     _flux_inlet_pps(getParam<std::vector<PostprocessorName>>("flux_inlet_pps")),
     163        4652 :     _flux_inlet_directions(getParam<std::vector<Point>>("flux_inlet_directions"))
     164             : {
     165             :   // Inlet boundary parameter checking
     166        2326 :   checkSecondParamSetOnlyIfFirstOneSet("flux_inlet_pps", "flux_inlet_directions");
     167        1163 :   if (_flux_inlet_directions.size())
     168          28 :     checkVectorParamsSameLengthIfSet<PostprocessorName, Point>("flux_inlet_pps",
     169             :                                                                "flux_inlet_directions");
     170             : 
     171             :   // Boussinesq parameters checks
     172        2326 :   checkSecondParamSetOnlyIfFirstOneTrue("boussinesq_approximation", "ref_temperature");
     173        2326 :   checkSecondParamSetOnlyIfFirstOneSet("gravity", "boussinesq_approximation");
     174             : 
     175             :   // Dynamic pressure parameter checks
     176        1163 :   if (_compressibility != "incompressible" && _solve_for_dynamic_pressure)
     177           0 :     paramError("compressibility",
     178             :                "Solving for dynamic pressure is only implemented for incompressible flow");
     179             : 
     180             :   // Boundary parameters checking
     181        2324 :   checkVectorParamAndMultiMooseEnumLength<BoundaryName>("inlet_boundaries", "momentum_inlet_types");
     182        2320 :   checkVectorParamAndMultiMooseEnumLength<BoundaryName>("outlet_boundaries",
     183             :                                                         "momentum_outlet_types");
     184        2316 :   checkVectorParamAndMultiMooseEnumLength<BoundaryName>("wall_boundaries", "momentum_wall_types");
     185             :   checkVectorParamLengthSameAsCombinedOthers<BoundaryName,
     186             :                                              std::vector<MooseFunctorName>,
     187        2312 :                                              PostprocessorName>(
     188             :       "inlet_boundaries", "momentum_inlet_functors", "flux_inlet_pps");
     189        1155 :   checkVectorParamsNoOverlap<BoundaryName>(
     190             :       {"inlet_boundaries", "outlet_boundaries", "wall_boundaries"});
     191             : 
     192             :   // Porous media parameters
     193        2310 :   checkSecondParamSetOnlyIfFirstOneTrue("porous_medium_treatment", "porosity");
     194             : 
     195        1155 :   if (_define_variables && _porous_medium_treatment)
     196        1774 :     for (const auto & name : NS::velocity_vector)
     197             :     {
     198        1331 :       const auto & it = std::find(_velocity_names.begin(), _velocity_names.end(), name);
     199        1331 :       if (it != _velocity_names.end())
     200           2 :         paramError("velocity_variable",
     201           2 :                    "For porous medium simulations, functor name " + *it +
     202             :                        " is already reserved for the automatically-computed interstitial velocity. "
     203             :                        "Please choose another name for your external velocity variable!");
     204             :     }
     205             : 
     206             :   // Friction parameter checks
     207        1153 :   if (_friction_blocks.size())
     208         228 :     checkVectorParamsSameLength<std::vector<SubdomainName>, std::vector<std::string>>(
     209             :         "friction_blocks", "friction_types");
     210        2304 :   checkTwoDVectorParamsSameLength<std::string, std::string>("friction_types", "friction_coeffs");
     211             : 
     212             :   // Create maps for boundary-restricted parameters
     213        2302 :   _momentum_inlet_types = Moose::createMapFromVectorAndMultiMooseEnum<BoundaryName>(
     214             :       _inlet_boundaries, getParam<MultiMooseEnum>("momentum_inlet_types"));
     215        2302 :   _momentum_outlet_types = Moose::createMapFromVectorAndMultiMooseEnum<BoundaryName>(
     216             :       _outlet_boundaries, getParam<MultiMooseEnum>("momentum_outlet_types"));
     217        2302 :   _momentum_wall_types = Moose::createMapFromVectorAndMultiMooseEnum<BoundaryName>(
     218             :       _wall_boundaries, getParam<MultiMooseEnum>("momentum_wall_types"));
     219        2302 :   if (isParamSetByUser("momentum_inlet_functors"))
     220             :   {
     221             :     // Not all inlet boundary types require the specification of an inlet functor
     222             :     std::vector<BoundaryName> inlet_boundaries_with_functors;
     223        2382 :     for (const auto & boundary : _inlet_boundaries)
     224        1386 :       if (libmesh_map_find(_momentum_inlet_types, boundary) == "fixed-velocity" ||
     225          18 :           libmesh_map_find(_momentum_inlet_types, boundary) == "fixed-pressure")
     226        1368 :         inlet_boundaries_with_functors.push_back(boundary);
     227             :     _momentum_inlet_functors =
     228        2028 :         Moose::createMapFromVectors<BoundaryName, std::vector<MooseFunctorName>>(
     229             :             inlet_boundaries_with_functors,
     230             :             getParam<std::vector<std::vector<MooseFunctorName>>>("momentum_inlet_functors"));
     231        1014 :   }
     232        2302 :   if (isParamSetByUser("pressure_functors"))
     233             :   {
     234             :     // Not all outlet boundary types require the specification of an inlet functor
     235             :     std::vector<BoundaryName> outlet_boundaries_with_functors;
     236        2024 :     for (const auto & boundary : _outlet_boundaries)
     237        2027 :       if (libmesh_map_find(_momentum_outlet_types, boundary) == "fixed-pressure-zero-gradient" ||
     238         997 :           libmesh_map_find(_momentum_outlet_types, boundary) == "fixed-pressure")
     239        1021 :         outlet_boundaries_with_functors.push_back(boundary);
     240        1988 :     const auto & pressure_functors = getParam<std::vector<MooseFunctorName>>("pressure_functors");
     241         994 :     if (outlet_boundaries_with_functors.size() != pressure_functors.size())
     242           4 :       paramError("pressure_functors",
     243           2 :                  "Size (" + std::to_string(pressure_functors.size()) +
     244             :                      ") is not the same as the number of pressure outlet boundaries in "
     245           2 :                      "'fixed-pressure/fixed-pressure-zero-gradient' (size " +
     246           2 :                      std::to_string(outlet_boundaries_with_functors.size()) + ")");
     247         992 :     _pressure_functors = Moose::createMapFromVectors<BoundaryName, MooseFunctorName>(
     248             :         outlet_boundaries_with_functors, pressure_functors);
     249         992 :   }
     250             : 
     251        2298 :   if (isParamSetByUser("momentum_wall_functors"))
     252             :   {
     253             :     // Not all wall boundary types require the specification of an inlet functor
     254             :     std::vector<BoundaryName> wall_boundaries_with_functors;
     255         333 :     for (const auto & boundary : _wall_boundaries)
     256         264 :       if (libmesh_map_find(_momentum_wall_types, boundary) == "noslip")
     257         234 :         wall_boundaries_with_functors.push_back(boundary);
     258             :     const auto & momentum_wall_functors =
     259         138 :         getParam<std::vector<std::vector<MooseFunctorName>>>("momentum_wall_functors");
     260          69 :     if (wall_boundaries_with_functors.size() != momentum_wall_functors.size())
     261           0 :       paramError("momentum_wall_functors",
     262           0 :                  "Size (" + std::to_string(momentum_wall_functors.size()) +
     263             :                      ") is not the same as the number of momentum_wall wall boundaries with "
     264           0 :                      "no-slip boundary conditions ' (size " +
     265           0 :                      std::to_string(wall_boundaries_with_functors.size()) + ")");
     266             : 
     267             :     _momentum_wall_functors =
     268          69 :         Moose::createMapFromVectors<BoundaryName, std::vector<MooseFunctorName>>(
     269             :             wall_boundaries_with_functors, momentum_wall_functors);
     270          69 :   }
     271             : 
     272        1149 :   addRequiredPhysicsTask("add_geometric_rm");
     273        1149 :   addRequiredPhysicsTask("add_variables_physics");
     274        1149 :   addRequiredPhysicsTask("add_ics_physics");
     275        1149 :   addRequiredPhysicsTask("add_materials_physics");
     276        1149 :   addRequiredPhysicsTask("add_user_object");
     277        1149 :   addRequiredPhysicsTask("add_postprocessor");
     278        1149 :   addRequiredPhysicsTask("add_corrector");
     279        1149 :   addRequiredPhysicsTask("get_turbulence_physics");
     280        1149 : }
     281             : 
     282             : void
     283        1119 : WCNSFVFlowPhysicsBase::initializePhysicsAdditional()
     284             : {
     285        1119 :   getProblem().needFV();
     286        1119 : }
     287             : 
     288             : void
     289       14528 : WCNSFVFlowPhysicsBase::actOnAdditionalTasks()
     290             : {
     291             :   // Turbulence physics would not be initialized before this task
     292       14528 :   if (_current_task == "get_turbulence_physics")
     293        1111 :     _turbulence_physics = getCoupledTurbulencePhysics();
     294       14528 : }
     295             : 
     296             : void
     297        1089 : WCNSFVFlowPhysicsBase::addFVBCs()
     298             : {
     299        1089 :   addInletBC();
     300        1087 :   addOutletBC();
     301        1087 :   addWallsBC();
     302        1087 :   addSeparatorBC();
     303        1087 : }
     304             : 
     305             : void
     306        1097 : WCNSFVFlowPhysicsBase::addMaterials()
     307             : {
     308        1097 :   if (hasForchheimerFriction() || _porous_medium_treatment)
     309         461 :     addPorousMediumSpeedMaterial();
     310             :   else
     311         636 :     addNonPorousMediumSpeedMaterial();
     312             : 
     313        1097 :   if (isParamValid(NS::fluid))
     314           9 :     addFluidPropertiesFunctorMaterial();
     315        1097 : }
     316             : 
     317             : void
     318         461 : WCNSFVFlowPhysicsBase::addPorousMediumSpeedMaterial()
     319             : {
     320         461 :   InputParameters params = getFactory().getValidParams("PINSFVSpeedFunctorMaterial");
     321         461 :   assignBlocks(params, _blocks);
     322             : 
     323        1383 :   for (unsigned int dim_i = 0; dim_i < dimension(); ++dim_i)
     324        1844 :     params.set<MooseFunctorName>(NS::superficial_velocity_vector[dim_i]) = _velocity_names[dim_i];
     325         461 :   if (_porous_medium_treatment)
     326         443 :     params.set<MooseFunctorName>(NS::porosity) = _flow_porosity_functor_name;
     327             :   else
     328          36 :     params.set<MooseFunctorName>(NS::porosity) = "1";
     329         461 :   params.set<bool>("define_interstitial_velocity_components") = _porous_medium_treatment;
     330             : 
     331        1383 :   getProblem().addFunctorMaterial(
     332         461 :       "PINSFVSpeedFunctorMaterial", prefix() + "pins_speed_material", params);
     333         461 : }
     334             : 
     335             : void
     336         636 : WCNSFVFlowPhysicsBase::addNonPorousMediumSpeedMaterial()
     337             : {
     338         636 :   const std::string class_name = "ADVectorMagnitudeFunctorMaterial";
     339         636 :   InputParameters params = getFactory().getValidParams(class_name);
     340         636 :   assignBlocks(params, _blocks);
     341             : 
     342        2544 :   const std::vector<std::string> param_names{"x_functor", "y_functor", "z_functor"};
     343        1873 :   for (unsigned int dim_i = 0; dim_i < dimension(); ++dim_i)
     344        2474 :     params.set<MooseFunctorName>(param_names[dim_i]) = _velocity_names[dim_i];
     345        1272 :   params.set<MooseFunctorName>("vector_magnitude_name") = NS::speed;
     346             : 
     347        1272 :   getProblem().addFunctorMaterial(class_name, prefix() + "ins_speed_material", params);
     348        2544 : }
     349             : 
     350             : void
     351           9 : WCNSFVFlowPhysicsBase::addFluidPropertiesFunctorMaterial()
     352             : {
     353             :   // Not very future-proof but it works
     354           9 :   const bool use_ad = !dynamic_cast<WCNSLinearFVFlowPhysics *>(this);
     355             :   const std::string class_name =
     356           9 :       use_ad ? "GeneralFunctorFluidProps" : "NonADGeneralFunctorFluidProps";
     357           9 :   InputParameters params = getFactory().getValidParams(class_name);
     358           9 :   assignBlocks(params, _blocks);
     359             : 
     360           9 :   params.set<MooseFunctorName>(NS::pressure) = _pressure_name;
     361          18 :   params.set<MooseFunctorName>(NS::T_fluid) = _fluid_temperature_name;
     362           9 :   params.set<MooseFunctorName>(NS::speed) = NS::speed;
     363          36 :   params.applySpecificParameters(parameters(), {NS::fluid, NS::density, "mu_rampdown"});
     364           9 :   if (!MooseUtils::parsesToReal(_density_name))
     365           9 :     params.set<bool>("force_define_density") = true;
     366           9 :   if (!_porous_medium_treatment)
     367             :   {
     368          18 :     params.set<MooseFunctorName>(NS::porosity) = "1";
     369          18 :     params.set<MooseFunctorName>("characteristic_length") = "1";
     370             :   }
     371             :   else
     372             :     // not implemented yet
     373           0 :     paramWarning(
     374             :         NS::fluid,
     375             :         "Specifying the fluid properties user object does not define the GeneralFunctorFluidProps "
     376             :         "when using the porous medium treatment. You have to define this object in the input");
     377             : 
     378             :   // Dynamic pressure
     379           9 :   params.set<bool>("solving_for_dynamic_pressure") = _solve_for_dynamic_pressure;
     380           9 :   if (_solve_for_dynamic_pressure)
     381             :   {
     382           0 :     params.set<Point>("reference_pressure_point") = getParam<Point>("reference_pressure_point");
     383           0 :     if (!isParamSetByUser("reference_pressure_point"))
     384           0 :       paramWarning("reference_pressure_point",
     385             :                    "Default value of (0,0,0) used. If this point is outside the flow domain, the "
     386             :                    "simulation will error");
     387           0 :     params.set<Real>("reference_pressure") = getParam<Real>("reference_pressure");
     388             :   }
     389          18 :   params.set<Point>("gravity") = getParam<RealVectorValue>("gravity");
     390             : 
     391           9 :   if (!_porous_medium_treatment)
     392          27 :     getProblem().addFunctorMaterial(class_name, prefix() + "functor_fluidprops", params);
     393          36 : }
     394             : 
     395             : void
     396        1105 : WCNSFVFlowPhysicsBase::addInitialConditions()
     397             : {
     398        1113 :   if (!_define_variables && parameters().isParamSetByUser("initial_velocity") &&
     399        2214 :       parameters().isParamSetByUser("velocity_variable") &&
     400        1109 :       getParam<std::vector<FunctionName>>("initial_velocity").size() != 0)
     401             :     // TODO: Rework and remove this last statement once the NSFV action is removed
     402           2 :     paramError("initial_velocity",
     403             :                "Velocity is defined externally of WCNSFVFlowPhysicsBase, so should the inital "
     404             :                "conditions");
     405        2206 :   if (!_define_variables && parameters().isParamSetByUser("initial_pressure") &&
     406        1105 :       parameters().isParamSetByUser("pressure_variable"))
     407           2 :     paramError("initial_pressure",
     408             :                "Pressure is defined externally of WCNSFVFlowPhysicsBase, so should the inital "
     409             :                "condition");
     410             : 
     411             :   // Check dimension
     412        4398 :   if (getParam<std::vector<FunctionName>>("initial_velocity").size() != dimension() &&
     413        2204 :       getParam<std::vector<FunctionName>>("initial_velocity").size() != 3 &&
     414        1105 :       getParam<std::vector<FunctionName>>("initial_velocity").size() != 0)
     415             :     // TODO: Rework and remove this last statement once the NSFV action is removed
     416           2 :     paramError("initial_velocity",
     417           4 :                "The number of velocity components in the " + type() + " initial condition is not " +
     418           2 :                    std::to_string(dimension()) + " or 3!");
     419             : 
     420        1099 :   InputParameters params = getFactory().getValidParams("FVFunctionIC");
     421        1099 :   assignBlocks(params, _blocks);
     422        2198 :   auto vvalue = getParam<std::vector<FunctionName>>("initial_velocity");
     423             : 
     424        4361 :   for (const auto d : make_range(dimension()))
     425             :   {
     426        4326 :     params.set<VariableName>("variable") = _velocity_names[d];
     427        2163 :     params.set<FunctionName>("function") = vvalue[d];
     428             : 
     429        4326 :     if (shouldCreateIC(_velocity_names[d],
     430             :                        _blocks,
     431        6489 :                        /*whether IC is a default*/ !isParamSetByUser("initial_velocity"),
     432        4326 :                        /*error if already an IC*/ isParamSetByUser("initial_velocity")))
     433        6183 :       getProblem().addFVInitialCondition(
     434        4122 :           "FVFunctionIC", prefix() + _velocity_names[d] + "_ic", params);
     435             :   }
     436             : 
     437        2198 :   if (shouldCreateIC(_pressure_name,
     438             :                      _blocks,
     439        3297 :                      /*whether IC is a default*/ !isParamSetByUser("initial_pressure"),
     440        2198 :                      /*error if already an IC*/ isParamSetByUser("initial_pressure")))
     441             :   {
     442        2090 :     params.set<VariableName>("variable") = _pressure_name;
     443        3135 :     params.set<FunctionName>("function") = getParam<FunctionName>("initial_pressure");
     444             : 
     445        4180 :     getProblem().addFVInitialCondition("FVFunctionIC", prefix() + _pressure_name + "_ic", params);
     446             :   }
     447        1099 : }
     448             : 
     449             : unsigned short
     450        8235 : WCNSFVFlowPhysicsBase::getNumberAlgebraicGhostingLayersNeeded() const
     451             : {
     452             :   unsigned short ghost_layers = 2;
     453        8235 :   return ghost_layers;
     454             : }
     455             : 
     456             : void
     457        1097 : WCNSFVFlowPhysicsBase::addPostprocessors()
     458             : {
     459        2194 :   const auto momentum_inlet_types = getParam<MultiMooseEnum>("momentum_inlet_types");
     460             : 
     461        2478 :   for (unsigned int bc_ind = 0; bc_ind < momentum_inlet_types.size(); ++bc_ind)
     462        1381 :     if (momentum_inlet_types[bc_ind] == "flux-mass" ||
     463        1353 :         momentum_inlet_types[bc_ind] == "flux-velocity")
     464             :     {
     465          67 :       const std::string pp_type = "AreaPostprocessor";
     466          67 :       InputParameters params = getFactory().getValidParams(pp_type);
     467         201 :       params.set<std::vector<BoundaryName>>("boundary") = {_inlet_boundaries[bc_ind]};
     468         134 :       params.set<ExecFlagEnum>("execute_on") = EXEC_INITIAL;
     469             : 
     470          67 :       const auto name_pp = "area_pp_" + _inlet_boundaries[bc_ind];
     471          67 :       if (!getProblem().hasUserObject(name_pp))
     472          67 :         getProblem().addPostprocessor(pp_type, name_pp, params);
     473          67 :     }
     474        1097 : }
     475             : 
     476             : VariableName
     477           0 : WCNSFVFlowPhysicsBase::getFlowVariableName(const std::string & short_name) const
     478             : {
     479           0 :   if (short_name == NS::pressure)
     480           0 :     return getPressureName();
     481           0 :   else if (short_name == NS::velocity_x && dimension() > 0)
     482             :     return getVelocityNames()[0];
     483           0 :   else if (short_name == NS::velocity_y && dimension() > 1)
     484             :     return getVelocityNames()[1];
     485           0 :   else if (short_name == NS::velocity_z && dimension() > 2)
     486             :     return getVelocityNames()[2];
     487           0 :   else if (short_name == NS::temperature)
     488           0 :     return getFluidTemperatureName();
     489             :   else
     490           0 :     mooseError("Short Variable name '", short_name, "' not recognized.");
     491             : }
     492             : 
     493             : MooseFunctorName
     494         177 : WCNSFVFlowPhysicsBase::getPorosityFunctorName(bool smoothed) const
     495             : {
     496         177 :   if (smoothed)
     497             :     return _flow_porosity_functor_name;
     498             :   else
     499             :     return _porosity_name;
     500             : }
     501             : 
     502             : const WCNSFVTurbulencePhysicsBase *
     503        1111 : WCNSFVFlowPhysicsBase::getCoupledTurbulencePhysics() const
     504             : {
     505             :   // User passed it, just use that
     506        2222 :   if (isParamValid("coupled_turbulence_physics"))
     507           0 :     return getCoupledPhysics<WCNSFVTurbulencePhysicsBase>(
     508             :         getParam<PhysicsName>("coupled_turbulence_physics"));
     509             :   // Look for any physics of the right type, and check the block restriction
     510             :   else
     511             :   {
     512        1111 :     const auto all_turbulence_physics = getCoupledPhysics<const WCNSFVTurbulencePhysicsBase>(true);
     513        1111 :     for (const auto physics : all_turbulence_physics)
     514             :     {
     515         614 :       if (checkBlockRestrictionIdentical(
     516             :               physics->name(), physics->blocks(), /*error_if_not_identical=*/false))
     517             :         return physics;
     518           0 :       else if (_verbose)
     519           0 :         mooseInfoRepeated("Detected Turbulence Physics '" + physics->name() +
     520             :                           "' with an incompatible block restriction. It will thus not be coupled "
     521             :                           "to this flow equations physics");
     522             :     }
     523        1111 :   }
     524             :   // Did not find one
     525         497 :   return nullptr;
     526             : }
     527             : 
     528             : const UserObjectName &
     529        7283 : WCNSFVFlowPhysicsBase::rhieChowUOName() const
     530             : {
     531             :   mooseAssert(!_rc_uo_name.empty(), "The Rhie-Chow user-object name should be set!");
     532        7283 :   return _rc_uo_name;
     533             : }
     534             : 
     535             : std::vector<SubdomainName>
     536         997 : WCNSFVFlowPhysicsBase::getAxisymmetricRZBlocks() const
     537             : {
     538             :   std::vector<SubdomainName> rz_blocks;
     539         997 :   const auto & mesh = getProblem().mesh();
     540             : 
     541             :   const bool use_all_blocks =
     542         997 :       _blocks.empty() || allMeshBlocks(_blocks) ||
     543         997 :       std::find(_blocks.begin(), _blocks.end(), "ANY_BLOCK_ID") != _blocks.end();
     544             : 
     545             :   std::vector<SubdomainID> block_ids;
     546         997 :   if (use_all_blocks)
     547             :   {
     548         989 :     const auto & mesh_blocks = mesh.meshSubdomains();
     549         989 :     block_ids.insert(block_ids.end(), mesh_blocks.begin(), mesh_blocks.end());
     550             :   }
     551             :   else
     552          16 :     block_ids = mesh.getSubdomainIDs(_blocks);
     553             : 
     554        2249 :   for (const auto subdomain_id : block_ids)
     555        1252 :     if (mesh.getCoordSystem(subdomain_id) == Moose::COORD_RZ)
     556             :     {
     557          45 :       auto name = mesh.getSubdomainName(subdomain_id);
     558          45 :       if (name.empty())
     559          90 :         name = Moose::stringify(subdomain_id);
     560          45 :       rz_blocks.push_back(name);
     561             :     }
     562             : 
     563         997 :   return rz_blocks;
     564         997 : }
     565             : 
     566             : void
     567         937 : WCNSFVFlowPhysicsBase::addAxisymmetricViscousSource()
     568             : {
     569         937 :   if (!_has_flow_equations || !_add_rz_viscous_source)
     570         892 :     return;
     571             : 
     572         937 :   const auto rz_blocks = getAxisymmetricRZBlocks();
     573         937 :   if (rz_blocks.empty())
     574             :     return;
     575             : 
     576          45 :   const auto radial_index = getProblem().mesh().getAxisymmetricRadialCoord();
     577          45 :   addAxisymmetricViscousSourceKernel(rz_blocks, radial_index);
     578         937 : }

Generated by: LCOV version 1.14