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 "WCNSFVTurbulencePhysicsBase.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_variables_physics"); \ 19 : registerMooseAction(app_name, derived_name, "add_ics_physics"); \ 20 : registerMooseAction(app_name, derived_name, "add_materials_physics"); \ 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 740 : bool hasFlowEquations() const { return _has_flow_equations; } 38 : /// Whether the cylindrical viscous source helper is enabled 39 60 : bool addAxisymmetricViscousSourceEnabled() const { return _add_rz_viscous_source; } 40 : /// Whether to include the symmetrized contribution in the viscous stress 41 1133 : bool includeSymmetrizedViscousStress() const { return _include_symmetrized_viscous_stress; } 42 : /// Whether to include the isotropic viscous stress contribution 43 997 : bool includeIsotropicStress() const { return _include_isotropic_viscous_stress; } 44 : 45 : /// To interface with other Physics 46 2060 : const std::vector<std::string> & getVelocityNames() const { return _velocity_names; } 47 : const NonlinearVariableName & getPressureName() const { return _pressure_name; } 48 : const NonlinearVariableName & getFluidTemperatureName() const { return _fluid_temperature_name; } 49 : MooseFunctorName getPorosityFunctorName(const bool smoothed) const; 50 : 51 : // Getters to interact with other WCNSFVPhysics classes 52 : /// Return the compressibility of the flow equations selected 53 2060 : const MooseEnum & compressibility() const { return _compressibility; } 54 : /// Return whether a porous medium treatment is applied 55 2060 : bool porousMediumTreatment() const { return _porous_medium_treatment; } 56 : /// Return the gravity vector 57 166 : RealVectorValue gravityVector() const { return getParam<RealVectorValue>("gravity"); } 58 : /// Return the name of the density functor 59 : const MooseFunctorName & densityName() const { return _density_name; } 60 : /// Return the name of the dynamic viscosity functor 61 : const MooseFunctorName & dynamicViscosityName() const { return _dynamic_viscosity_name; } 62 : /// Get the face interpolation method for velocity 63 2078 : const MooseEnum & getVelocityFaceInterpolationMethod() const { return _velocity_interpolation; } 64 : /// Get the face interpolation method for momentum in the advection term 65 : const MooseEnum & getMomentumAdvectionFaceInterpolationMethod() const 66 : { 67 : return _momentum_advection_interpolation; 68 : } 69 : /// Get the face interpolation method for momentum (mostly used in the stress terms) 70 : const MooseEnum & getMomentumFaceInterpolationMethod() const 71 : { 72 78 : return _momentum_face_interpolation; 73 : } 74 : /// Get the inlet boundaries 75 : const std::vector<BoundaryName> & getInletBoundaries() const { return _inlet_boundaries; } 76 : /// Get the outlet boundaries 77 : const std::vector<BoundaryName> & getOutletBoundaries() const { return _outlet_boundaries; } 78 : /// Get the wall boundaries 79 414 : const std::vector<BoundaryName> & getWallBoundaries() const { return _wall_boundaries; } 80 : /// Get the hydraulic separator boundaries 81 9 : const std::vector<BoundaryName> & getHydraulicSeparators() const { return _hydraulic_separators; } 82 : /// Get the type of the inlet BC 83 : NS::MomentumInletTypes inletBoundaryType(const BoundaryName & boundary_name) const 84 : { 85 : return NS::MomentumInletTypes( 86 204 : static_cast<int>(libmesh_map_find(_momentum_inlet_types, boundary_name))); 87 : } 88 : /// Get the inlet direction if using a flux inlet 89 42 : const std::vector<Point> & getFluxInletDirections() const { return _flux_inlet_directions; } 90 : /// Get the inlet flux postprocessor if using a flux inlet 91 42 : const std::vector<PostprocessorName> & getFluxInletPPs() const { return _flux_inlet_pps; } 92 : /// Get the name of the linear friction coefficient. Returns an empty string if no friction. 93 : virtual MooseFunctorName getLinearFrictionCoefName() const = 0; 94 : /// Return the name of the Rhie Chow user object 95 : const UserObjectName & rhieChowUOName() const; 96 : /// Return the number of algebraic ghosting layers needed 97 : unsigned short getNumberAlgebraicGhostingLayersNeeded() const override; 98 : 99 : protected: 100 : virtual void initializePhysicsAdditional() override; 101 : virtual void actOnAdditionalTasks() override; 102 : virtual void addSolverVariables() override = 0; 103 : virtual void addInitialConditions() override; 104 : virtual void addFVKernels() override = 0; 105 : virtual void addFVBCs() override; 106 : virtual void addMaterials() override; 107 : virtual void addUserObjects() override = 0; 108 : virtual void addPostprocessors() override; 109 : 110 : /** 111 : * Functions adding kernels for the flow momentum equations 112 : * If the material properties are not constant, these can be used for 113 : * weakly-compressible simulations (except the Boussinesq kernel) as well. 114 : */ 115 : virtual void addMomentumTimeKernels() = 0; 116 : virtual void addMomentumPressureKernels() = 0; 117 : virtual void addMomentumGravityKernels() = 0; 118 : virtual void addMomentumFrictionKernels() = 0; 119 : virtual void addMomentumBoussinesqKernels() = 0; 120 : /// Adds the cylindrical source kernel for the radial momentum equation when requested and valid 121 : void addAxisymmetricViscousSource(); 122 : /** 123 : * Derived classes must override this hook to add the actual object that implements the 124 : * axisymmetric viscous source term for their formulation once the helper has determined the 125 : * relevant blocks and radial component. 126 : */ 127 0 : virtual void addAxisymmetricViscousSourceKernel(const std::vector<SubdomainName> & /*rz_blocks*/, 128 : unsigned int /*radial_index*/) 129 : { 130 0 : } 131 : 132 : /// Functions adding boundary conditions for the flow simulation. 133 : /// These are used for weakly-compressible simulations as well. 134 : virtual void addInletBC() = 0; 135 : virtual void addOutletBC() = 0; 136 : virtual void addWallsBC() = 0; 137 : virtual void addSeparatorBC() = 0; 138 : 139 : /// Return whether a Forchheimer friction model is in use 140 : virtual bool hasForchheimerFriction() const = 0; 141 : 142 : /// Add material to define the local speed in porous medium flows 143 : void addPorousMediumSpeedMaterial(); 144 : /// Add material to define the local speed with no porous medium treatment 145 : void addNonPorousMediumSpeedMaterial(); 146 : /// Function which adds the general functor fluid properties functor material to define fluid functor material property 147 : void addFluidPropertiesFunctorMaterial(); 148 : 149 : /// Function which adds the RhieChow interpolator user objects for weakly and incompressible formulations 150 : virtual void addRhieChowUserObjects() = 0; 151 : 152 : /// Convenience routine to be able to retrieve the actual variable names from their default names 153 : VariableName getFlowVariableName(const std::string & default_name) const; 154 : 155 : /// Whether a turbulence Physics has been coupled in, to know which viscosity to pick on symmetry boundary conditions 156 218 : bool hasTurbulencePhysics() const 157 : { 158 218 : if (_turbulence_physics) 159 154 : return _turbulence_physics->hasTurbulenceModel(); 160 : else 161 : return false; 162 : } 163 : 164 : /// Find the turbulence physics 165 : const WCNSFVTurbulencePhysicsBase * getCoupledTurbulencePhysics() const; 166 : 167 : /// Return the set of blocks restricted to an RZ coordinate system 168 : std::vector<SubdomainName> getAxisymmetricRZBlocks() const; 169 : 170 : /// Name of the vector to hold pressure momentum equation contributions 171 : const TagName _pressure_tag = "p_tag"; 172 : 173 : /// Boolean to keep track of whether the flow equations should be created 174 : const bool _has_flow_equations; 175 : /// Whether to automatically add the cylindrical viscous source term 176 : const bool _add_rz_viscous_source; 177 : 178 : /// Compressibility type, can be compressible, incompressible or weakly-compressible 179 : const MooseEnum _compressibility; 180 : /// Whether we are solving for the total or dynamic pressure 181 : const bool _solve_for_dynamic_pressure; 182 : 183 : /// Whether to use the porous medium treatment 184 : const bool _porous_medium_treatment; 185 : /// Name of the porosity functor 186 : const MooseFunctorName _porosity_name; 187 : /// Name of the porosity functor for the flow equations (if smoothed) 188 : MooseFunctorName _flow_porosity_functor_name; 189 : 190 : /// Velocity names 191 : const std::vector<std::string> _velocity_names; 192 : /// Pressure name 193 : const NonlinearVariableName _pressure_name; 194 : /// Fluid temperature name 195 : const NonlinearVariableName _fluid_temperature_name; 196 : 197 : /// Name of the density material property 198 : const MooseFunctorName _density_name; 199 : /// Name of the density material property used for gravity and Boussinesq terms 200 : const MooseFunctorName _density_gravity_name; 201 : /// Name of the dynamic viscosity material property 202 : const MooseFunctorName _dynamic_viscosity_name; 203 : /// Whether to include the symmetrized viscous stress contribution 204 : const bool _include_symmetrized_viscous_stress; 205 : /// Whether to include the isotropic viscous stress contribution 206 : const bool _include_isotropic_viscous_stress; 207 : 208 : /// name of the Rhie Chow user object 209 : UserObjectName _rc_uo_name; 210 : /// The velocity face interpolation method for advecting other quantities 211 : const MooseEnum _velocity_interpolation; 212 : /// The momentum face interpolation method for being advected 213 : const MooseEnum _momentum_advection_interpolation; 214 : /// The momentum face interpolation method for stress terms 215 : const MooseEnum _momentum_face_interpolation; 216 : 217 : /// Can be set to a coupled turbulence physics 218 : const WCNSFVTurbulencePhysicsBase * _turbulence_physics; 219 : 220 : /// Subdomains where we want to have volumetric friction 221 : std::vector<std::vector<SubdomainName>> _friction_blocks; 222 : /// The friction correlation types used for each block 223 : std::vector<std::vector<std::string>> _friction_types; 224 : /// The coefficients used for each item if friction type 225 : std::vector<std::vector<std::string>> _friction_coeffs; 226 : 227 : /// Boundaries with a flow inlet specified on them 228 : const std::vector<BoundaryName> _inlet_boundaries; 229 : /// Boundaries with a flow outlet specified on them 230 : const std::vector<BoundaryName> _outlet_boundaries; 231 : /// Boundaries which define a wall (slip/noslip/etc.) 232 : const std::vector<BoundaryName> _wall_boundaries; 233 : /// Hydraulic separator boundaries 234 : const std::vector<BoundaryName> _hydraulic_separators; 235 : 236 : /// Momentum inlet boundary types 237 : std::map<BoundaryName, MooseEnum> _momentum_inlet_types; 238 : /// Momentum outlet boundary types 239 : std::map<BoundaryName, MooseEnum> _momentum_outlet_types; 240 : /// Momentum wall boundary types 241 : std::map<BoundaryName, MooseEnum> _momentum_wall_types; 242 : 243 : /// Postprocessors describing the momentum inlet for each boundary. Indexing based on the number of flux boundaries 244 : std::vector<PostprocessorName> _flux_inlet_pps; 245 : /// Direction of each flux inlet. Indexing based on the number of flux boundaries 246 : std::vector<Point> _flux_inlet_directions; 247 : 248 : /// Functors describing the momentum inlet for each boundary 249 : std::map<BoundaryName, std::vector<MooseFunctorName>> _momentum_inlet_functors; 250 : /// Functors describing the outlet pressure on each boundary 251 : std::map<BoundaryName, MooseFunctorName> _pressure_functors; 252 : /// Functors describing the momentum for each wall boundary 253 : std::map<BoundaryName, std::vector<MooseFunctorName>> _momentum_wall_functors; 254 : 255 : friend class WCNSFVTurbulencePhysics; 256 : };