LCOV - code coverage report
Current view: top level - include/physics - WCNSFVFlowPhysicsBase.h (source / functions) Hit Total Coverage
Test: idaholab/moose navier_stokes: #31730 (e8b711) with base e0c998 Lines: 15 15 100.0 %
Date: 2025-10-29 16:52:29 Functions: 2 2 100.0 %
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             : #pragma once
      11             : 
      12             : #include "NavierStokesPhysicsBase.h"
      13             : #include "WCNSFVTurbulencePhysics.h"
      14             : 
      15             : #define registerWCNSFVFlowPhysicsBaseTasks(app_name, derived_name)                                 \
      16             :   registerPhysicsBaseTasks(app_name, derived_name);                                                \
      17             :   registerMooseAction(app_name, derived_name, "add_geometric_rm");                                 \
      18             :   registerMooseAction(app_name, derived_name, "add_variable");                                     \
      19             :   registerMooseAction(app_name, derived_name, "add_fv_ic");                                        \
      20             :   registerMooseAction(app_name, derived_name, "add_material");                                     \
      21             :   registerMooseAction(app_name, derived_name, "add_user_object");                                  \
      22             :   registerMooseAction(app_name, derived_name, "add_postprocessor");                                \
      23             :   registerMooseAction(app_name, derived_name, "add_corrector");                                    \
      24             :   registerMooseAction(app_name, derived_name, "get_turbulence_physics")
      25             : 
      26             : /**
      27             :  * Base class for Physics which create the Navier Stokes flow equations
      28             :  */
      29             : class WCNSFVFlowPhysicsBase : public NavierStokesPhysicsBase
      30             : {
      31             : public:
      32             :   static InputParameters validParams();
      33             : 
      34             :   WCNSFVFlowPhysicsBase(const InputParameters & parameters);
      35             : 
      36             :   /// Whether the physics is actually creating the flow equations
      37        1225 :   bool hasFlowEquations() const { return _has_flow_equations; }
      38             : 
      39             :   /// To interface with other Physics
      40        3663 :   const std::vector<std::string> & getVelocityNames() const { return _velocity_names; }
      41             :   const NonlinearVariableName & getPressureName() const { return _pressure_name; }
      42             :   const NonlinearVariableName & getFluidTemperatureName() const { return _fluid_temperature_name; }
      43             :   MooseFunctorName getPorosityFunctorName(const bool smoothed) const;
      44             : 
      45             :   // Getters to interact with other WCNSFVPhysics classes
      46             :   /// Return the compressibility of the flow equations selected
      47        3663 :   const MooseEnum & compressibility() const { return _compressibility; }
      48             :   /// Return whether a porous medium treatment is applied
      49        3663 :   bool porousMediumTreatment() const { return _porous_medium_treatment; }
      50             :   /// Return the gravity vector
      51         352 :   RealVectorValue gravityVector() const { return getParam<RealVectorValue>("gravity"); }
      52             :   /// Return the name of the density functor
      53             :   const MooseFunctorName & densityName() const { return _density_name; }
      54             :   /// Return the name of the dynamic viscosity functor
      55             :   const MooseFunctorName & dynamicViscosityName() const { return _dynamic_viscosity_name; }
      56             :   /// Get the face interpolation method for velocity
      57        3701 :   const MooseEnum & getVelocityFaceInterpolationMethod() const { return _velocity_interpolation; }
      58             :   /// Get the face interpolation method for momentum in the advection term
      59             :   const MooseEnum & getMomentumAdvectionFaceInterpolationMethod() const
      60             :   {
      61             :     return _momentum_advection_interpolation;
      62             :   }
      63             :   /// Get the face interpolation method for momentum (mostly used in the stress terms)
      64             :   const MooseEnum & getMomentumFaceInterpolationMethod() const
      65             :   {
      66         160 :     return _momentum_face_interpolation;
      67             :   }
      68             :   /// Get the inlet boundaries
      69             :   const std::vector<BoundaryName> & getInletBoundaries() const { return _inlet_boundaries; }
      70             :   /// Get the outlet boundaries
      71             :   const std::vector<BoundaryName> & getOutletBoundaries() const { return _outlet_boundaries; }
      72             :   /// Get the wall boundaries
      73         701 :   const std::vector<BoundaryName> & getWallBoundaries() const { return _wall_boundaries; }
      74             :   /// Get the hydraulic separator boundaries
      75          19 :   const std::vector<BoundaryName> & getHydraulicSeparators() const { return _hydraulic_separators; }
      76             :   /// Get the type of the inlet BC
      77             :   NS::MomentumInletTypes inletBoundaryType(const BoundaryName & boundary_name) const
      78             :   {
      79             :     return NS::MomentumInletTypes(
      80         375 :         static_cast<int>(libmesh_map_find(_momentum_inlet_types, boundary_name)));
      81             :   }
      82             :   /// Get the inlet direction if using a flux inlet
      83          54 :   const std::vector<Point> & getFluxInletDirections() const { return _flux_inlet_directions; }
      84             :   /// Get the inlet flux postprocessor if using a flux inlet
      85          54 :   const std::vector<PostprocessorName> & getFluxInletPPs() const { return _flux_inlet_pps; }
      86             :   /// Get the name of the linear friction coefficient. Returns an empty string if no friction.
      87             :   virtual MooseFunctorName getLinearFrictionCoefName() const = 0;
      88             :   /// Return the name of the Rhie Chow user object
      89             :   virtual UserObjectName rhieChowUOName() const = 0;
      90             :   /// Return the number of algebraic ghosting layers needed
      91             :   unsigned short getNumberAlgebraicGhostingLayersNeeded() const override;
      92             : 
      93             : protected:
      94             :   virtual void initializePhysicsAdditional() override;
      95             :   virtual void actOnAdditionalTasks() override;
      96             :   virtual void addSolverVariables() override = 0;
      97             :   virtual void addInitialConditions() override;
      98             :   virtual void addFVKernels() override = 0;
      99             :   virtual void addFVBCs() override;
     100             :   virtual void addMaterials() override;
     101             :   virtual void addUserObjects() override = 0;
     102             :   virtual void addPostprocessors() override;
     103             : 
     104             :   /**
     105             :    * Functions adding kernels for the flow momentum equations
     106             :    * If the material properties are not constant, these can be used for
     107             :    * weakly-compressible simulations (except the Boussinesq kernel) as well.
     108             :    */
     109             :   virtual void addMomentumTimeKernels() = 0;
     110             :   virtual void addMomentumPressureKernels() = 0;
     111             :   virtual void addMomentumGravityKernels() = 0;
     112             :   virtual void addMomentumFrictionKernels() = 0;
     113             :   virtual void addMomentumBoussinesqKernels() = 0;
     114             : 
     115             :   /// Functions adding boundary conditions for the flow simulation.
     116             :   /// These are used for weakly-compressible simulations as well.
     117             :   virtual void addInletBC() = 0;
     118             :   virtual void addOutletBC() = 0;
     119             :   virtual void addWallsBC() = 0;
     120             :   virtual void addSeparatorBC() = 0;
     121             : 
     122             :   /// Return whether a Forchheimer friction model is in use
     123             :   virtual bool hasForchheimerFriction() const = 0;
     124             : 
     125             :   /// Add material to define the local speed in porous medium flows
     126             :   void addPorousMediumSpeedMaterial();
     127             :   /// Add material to define the local speed with no porous medium treatment
     128             :   void addNonPorousMediumSpeedMaterial();
     129             : 
     130             :   /// Function which adds the RhieChow interpolator user objects for weakly and incompressible formulations
     131             :   virtual void addRhieChowUserObjects() = 0;
     132             : 
     133             :   /// Convenience routine to be able to retrieve the actual variable names from their default names
     134             :   VariableName getFlowVariableName(const std::string & default_name) const;
     135             : 
     136             :   /// Whether a turbulence Physics has been coupled in, to know which viscosity to pick on symmetry boundary conditions
     137         362 :   bool hasTurbulencePhysics() const
     138             :   {
     139         362 :     if (_turbulence_physics)
     140         296 :       return _turbulence_physics->hasTurbulenceModel();
     141             :     else
     142             :       return false;
     143             :   }
     144             : 
     145             :   /// Find the turbulence physics
     146             :   const WCNSFVTurbulencePhysics * getCoupledTurbulencePhysics() const;
     147             : 
     148             :   /// Name of the vector to hold pressure momentum equation contributions
     149             :   const TagName _pressure_tag = "p_tag";
     150             : 
     151             :   /// Boolean to keep track of whether the flow equations should be created
     152             :   const bool _has_flow_equations;
     153             : 
     154             :   /// Compressibility type, can be compressible, incompressible or weakly-compressible
     155             :   const MooseEnum _compressibility;
     156             :   /// Whether we are solving for the total or dynamic pressure
     157             :   const bool _solve_for_dynamic_pressure;
     158             : 
     159             :   /// Whether to use the porous medium treatment
     160             :   const bool _porous_medium_treatment;
     161             :   /// Name of the porosity functor
     162             :   const MooseFunctorName _porosity_name;
     163             :   /// Name of the porosity functor for the flow equations (if smoothed)
     164             :   MooseFunctorName _flow_porosity_functor_name;
     165             : 
     166             :   /// Velocity names
     167             :   const std::vector<std::string> _velocity_names;
     168             :   /// Pressure name
     169             :   const NonlinearVariableName _pressure_name;
     170             :   /// Fluid temperature name
     171             :   const NonlinearVariableName _fluid_temperature_name;
     172             : 
     173             :   /// Name of the density material property
     174             :   const MooseFunctorName _density_name;
     175             :   /// Name of the density material property used for gravity and Boussinesq terms
     176             :   const MooseFunctorName _density_gravity_name;
     177             :   /// Name of the dynamic viscosity material property
     178             :   const MooseFunctorName _dynamic_viscosity_name;
     179             : 
     180             :   /// The velocity face interpolation method for advecting other quantities
     181             :   const MooseEnum _velocity_interpolation;
     182             :   /// The momentum face interpolation method for being advected
     183             :   const MooseEnum _momentum_advection_interpolation;
     184             :   /// The momentum face interpolation method for stress terms
     185             :   const MooseEnum _momentum_face_interpolation;
     186             : 
     187             :   /// Can be set to a coupled turbulence physics
     188             :   const WCNSFVTurbulencePhysics * _turbulence_physics;
     189             : 
     190             :   /// Subdomains where we want to have volumetric friction
     191             :   std::vector<std::vector<SubdomainName>> _friction_blocks;
     192             :   /// The friction correlation types used for each block
     193             :   std::vector<std::vector<std::string>> _friction_types;
     194             :   /// The coefficients used for each item if friction type
     195             :   std::vector<std::vector<std::string>> _friction_coeffs;
     196             : 
     197             :   /// Boundaries with a flow inlet specified on them
     198             :   const std::vector<BoundaryName> _inlet_boundaries;
     199             :   /// Boundaries with a flow outlet specified on them
     200             :   const std::vector<BoundaryName> _outlet_boundaries;
     201             :   /// Boundaries which define a wall (slip/noslip/etc.)
     202             :   const std::vector<BoundaryName> _wall_boundaries;
     203             :   /// Hydraulic separator boundaries
     204             :   const std::vector<BoundaryName> _hydraulic_separators;
     205             : 
     206             :   /// Momentum inlet boundary types
     207             :   std::map<BoundaryName, MooseEnum> _momentum_inlet_types;
     208             :   /// Momentum outlet boundary types
     209             :   std::map<BoundaryName, MooseEnum> _momentum_outlet_types;
     210             :   /// Momentum wall boundary types
     211             :   std::map<BoundaryName, MooseEnum> _momentum_wall_types;
     212             : 
     213             :   /// Postprocessors describing the momentum inlet for each boundary. Indexing based on the number of flux boundaries
     214             :   std::vector<PostprocessorName> _flux_inlet_pps;
     215             :   /// Direction of each flux inlet. Indexing based on the number of flux boundaries
     216             :   std::vector<Point> _flux_inlet_directions;
     217             : 
     218             :   /// Functors describing the momentum inlet for each boundary
     219             :   std::map<BoundaryName, std::vector<MooseFunctorName>> _momentum_inlet_functors;
     220             :   /// Functors describing the outlet pressure on each boundary
     221             :   std::map<BoundaryName, MooseFunctorName> _pressure_functors;
     222             :   /// Functors describing the momentum for each wall boundary
     223             :   std::map<BoundaryName, std::vector<MooseFunctorName>> _momentum_wall_functors;
     224             : };

Generated by: LCOV version 1.14