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_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 3606 : 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 3606 : const MooseEnum & compressibility() const { return _compressibility; } 48 : /// Return whether a porous medium treatment is applied 49 3606 : 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 3644 : 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 682 : 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 inlet direction if using a flux inlet 77 117 : const std::vector<Point> & getFluxInletDirections() const { return _flux_inlet_directions; } 78 : /// Get the inlet flux postprocessor if using a flux inlet 79 117 : const std::vector<PostprocessorName> & getFluxInletPPs() const { return _flux_inlet_pps; } 80 : /// Get the name of the linear friction coefficient. Returns an empty string if no friction. 81 : virtual MooseFunctorName getLinearFrictionCoefName() const = 0; 82 : /// Return the name of the Rhie Chow user object 83 : virtual UserObjectName rhieChowUOName() const = 0; 84 : /// Return the number of algebraic ghosting layers needed 85 : unsigned short getNumberAlgebraicGhostingLayersNeeded() const override; 86 : 87 : protected: 88 : virtual void initializePhysicsAdditional() override; 89 : virtual void actOnAdditionalTasks() override; 90 : virtual void addSolverVariables() override = 0; 91 : virtual void addInitialConditions() override; 92 : virtual void addFVKernels() override = 0; 93 : virtual void addFVBCs() override; 94 : virtual void addMaterials() override; 95 : virtual void addUserObjects() override = 0; 96 : virtual void addPostprocessors() override; 97 : 98 : /** 99 : * Functions adding kernels for the flow momentum equations 100 : * If the material properties are not constant, these can be used for 101 : * weakly-compressible simulations (except the Boussinesq kernel) as well. 102 : */ 103 : virtual void addMomentumTimeKernels() = 0; 104 : virtual void addMomentumPressureKernels() = 0; 105 : virtual void addMomentumGravityKernels() = 0; 106 : virtual void addMomentumFrictionKernels() = 0; 107 : virtual void addMomentumBoussinesqKernels() = 0; 108 : 109 : /// Functions adding boundary conditions for the flow simulation. 110 : /// These are used for weakly-compressible simulations as well. 111 : virtual void addInletBC() = 0; 112 : virtual void addOutletBC() = 0; 113 : virtual void addWallsBC() = 0; 114 : virtual void addSeparatorBC() = 0; 115 : 116 : /// Return whether a Forchheimer friction model is in use 117 : virtual bool hasForchheimerFriction() const = 0; 118 : 119 : /// Add material to define the local speed in porous medium flows 120 : void addPorousMediumSpeedMaterial(); 121 : /// Add material to define the local speed with no porous medium treatment 122 : void addNonPorousMediumSpeedMaterial(); 123 : 124 : /// Function which adds the RhieChow interpolator user objects for weakly and incompressible formulations 125 : virtual void addRhieChowUserObjects() = 0; 126 : 127 : /// Convenience routine to be able to retrieve the actual variable names from their default names 128 : VariableName getFlowVariableName(const std::string & default_name) const; 129 : 130 : /// Whether a turbulence Physics has been coupled in, to know which viscosity to pick on symmetry boundary conditions 131 362 : bool hasTurbulencePhysics() const 132 : { 133 362 : if (_turbulence_physics) 134 296 : return _turbulence_physics->hasTurbulenceModel(); 135 : else 136 : return false; 137 : } 138 : 139 : /// Find the turbulence physics 140 : const WCNSFVTurbulencePhysics * getCoupledTurbulencePhysics() const; 141 : 142 : /// Name of the vector to hold pressure momentum equation contributions 143 : const TagName _pressure_tag = "p_tag"; 144 : 145 : /// Boolean to keep track of whether the flow equations should be created 146 : const bool _has_flow_equations; 147 : 148 : /// Compressibility type, can be compressible, incompressible or weakly-compressible 149 : const MooseEnum _compressibility; 150 : /// Whether we are solving for the total or dynamic pressure 151 : const bool _solve_for_dynamic_pressure; 152 : 153 : /// Whether to use the porous medium treatment 154 : const bool _porous_medium_treatment; 155 : /// Name of the porosity functor 156 : const MooseFunctorName _porosity_name; 157 : /// Name of the porosity functor for the flow equations (if smoothed) 158 : MooseFunctorName _flow_porosity_functor_name; 159 : 160 : /// Velocity names 161 : const std::vector<std::string> _velocity_names; 162 : /// Pressure name 163 : const NonlinearVariableName _pressure_name; 164 : /// Fluid temperature name 165 : const NonlinearVariableName _fluid_temperature_name; 166 : 167 : /// Name of the density material property 168 : const MooseFunctorName _density_name; 169 : /// Name of the density material property used for gravity and Boussinesq terms 170 : const MooseFunctorName _density_gravity_name; 171 : /// Name of the dynamic viscosity material property 172 : const MooseFunctorName _dynamic_viscosity_name; 173 : 174 : /// The velocity face interpolation method for advecting other quantities 175 : const MooseEnum _velocity_interpolation; 176 : /// The momentum face interpolation method for being advected 177 : const MooseEnum _momentum_advection_interpolation; 178 : /// The momentum face interpolation method for stress terms 179 : const MooseEnum _momentum_face_interpolation; 180 : 181 : /// Can be set to a coupled turbulence physics 182 : const WCNSFVTurbulencePhysics * _turbulence_physics; 183 : 184 : /// Subdomains where we want to have volumetric friction 185 : std::vector<std::vector<SubdomainName>> _friction_blocks; 186 : /// The friction correlation types used for each block 187 : std::vector<std::vector<std::string>> _friction_types; 188 : /// The coefficients used for each item if friction type 189 : std::vector<std::vector<std::string>> _friction_coeffs; 190 : 191 : /// Boundaries with a flow inlet specified on them 192 : const std::vector<BoundaryName> _inlet_boundaries; 193 : /// Boundaries with a flow outlet specified on them 194 : const std::vector<BoundaryName> _outlet_boundaries; 195 : /// Boundaries which define a wall (slip/noslip/etc.) 196 : const std::vector<BoundaryName> _wall_boundaries; 197 : /// Hydraulic separator boundaries 198 : const std::vector<BoundaryName> _hydraulic_separators; 199 : 200 : /// Momentum inlet boundary types 201 : std::map<BoundaryName, MooseEnum> _momentum_inlet_types; 202 : /// Momentum outlet boundary types 203 : std::map<BoundaryName, MooseEnum> _momentum_outlet_types; 204 : /// Momentum wall boundary types 205 : std::map<BoundaryName, MooseEnum> _momentum_wall_types; 206 : 207 : /// Postprocessors describing the momentum inlet for each boundary. Indexing based on the number of flux boundaries 208 : std::vector<PostprocessorName> _flux_inlet_pps; 209 : /// Direction of each flux inlet. Indexing based on the number of flux boundaries 210 : std::vector<Point> _flux_inlet_directions; 211 : 212 : /// Functors describing the momentum inlet for each boundary 213 : std::map<BoundaryName, std::vector<MooseFunctorName>> _momentum_inlet_functors; 214 : /// Functors describing the outlet pressure on each boundary 215 : std::map<BoundaryName, MooseFunctorName> _pressure_functors; 216 : /// Functors describing the momentum for each wall boundary 217 : std::map<BoundaryName, std::vector<MooseFunctorName>> _momentum_wall_functors; 218 : };