diff --git a/Common/include/CConfig.hpp b/Common/include/CConfig.hpp index 71f780bbed0..9eff410c418 100644 --- a/Common/include/CConfig.hpp +++ b/Common/include/CConfig.hpp @@ -135,7 +135,8 @@ class CConfig { Hold_GridFixed, /*!< \brief Flag hold fixed some part of the mesh during the deformation. */ Axisymmetric, /*!< \brief Flag for axisymmetric calculations */ Enable_Cuda, /*!< \brief Flag for switching GPU computing*/ - Integrated_HeatFlux; /*!< \brief Flag for heat flux BC whether it deals with integrated values.*/ + Integrated_HeatFlux, /*!< \brief Flag for heat flux BC whether it deals with integrated values.*/ + Pressure_based; /*!< \brief FLag to check if we are using a pressure-based system.*/ su2double Buffet_k; /*!< \brief Sharpness coefficient for buffet sensor.*/ su2double Buffet_lambda; /*!< \brief Offset parameter for buffet sensor.*/ su2double Damp_Engine_Inflow; /*!< \brief Damping factor for the engine inlet. */ @@ -538,6 +539,7 @@ class CConfig { Kind_TimeIntScheme_AdjTurb, /*!< \brief Time integration for the adjoint turbulence model. */ Kind_TimeIntScheme_Species, /*!< \brief Time integration for the species model. */ Kind_TimeIntScheme_Heat, /*!< \brief Time integration for the wave equations. */ + Kind_TimeIntScheme_Poisson, /*!< \brief Time integration for the poisson (pressure correction) equation/ */ Kind_TimeStep_Heat, /*!< \brief Time stepping method for the (fvm) heat equation. */ n_Datadriven_files; @@ -587,6 +589,11 @@ class CConfig { Kind_Upwind_Heat, /*!< \brief Upwind scheme for the heat transfer model. */ Kind_Upwind_Template; /*!< \brief Upwind scheme for the template model. */ + ENUM_PBITER /*< \brief Pressure-based solver for incompressible flows. */ + Kind_PBIter; + ENUM_INCOMP_SYSTEM + Kind_Incomp_System; + bool MUSCL, /*!< \brief MUSCL scheme (for the runtime eq. system). */ MUSCL_Flow, /*!< \brief MUSCL scheme for the flow equations.*/ MUSCL_Turb, /*!< \brief MUSCL scheme for the turbulence equations.*/ @@ -640,6 +647,7 @@ class CConfig { su2double Deform_Linear_Solver_Error; /*!< \brief Min error of the linear solver for the implicit formulation. */ su2double Linear_Solver_Smoother_Relaxation; /*!< \brief Relaxation factor for iterative linear smoothers. */ unsigned long Linear_Solver_Iter; /*!< \brief Max iterations of the linear solver for the implicit formulation. */ + unsigned long Poisson_Linear_Solver_Iter; /*!< \brief Max iterations of the linear solver for the poisson solver*/ unsigned long Deform_Linear_Solver_Iter; /*!< \brief Max iterations of the linear solver for the implicit formulation. */ unsigned long Linear_Solver_Restart_Frequency; /*!< \brief Restart frequency of the linear solver for the implicit formulation. */ unsigned long Linear_Solver_Restart_Deflation; /*!< \brief Number of vectors used for deflated restarts. */ @@ -649,6 +657,8 @@ class CConfig { su2double SemiSpan; /*!< \brief Wing Semi span. */ su2double MSW_Alpha; /*!< \brief Coefficient for blending states in the MSW scheme. */ su2double Roe_Kappa; /*!< \brief Relaxation of the Roe scheme. */ + su2double RCFactor; /*!< \brief Relaxation for the Rhie-Chow interpolation contribution. */ + su2double Relaxation_Factor_PBFlow; /*!< \brief Relaxation coefficient of the flow corrections in the PB solver. */ su2double Relaxation_Factor_Adjoint; /*!< \brief Relaxation coefficient for variable updates of adjoint solvers. */ su2double Relaxation_Factor_CHT; /*!< \brief Relaxation coefficient for the update of conjugate heat variables. */ su2double EntropyFix_Coeff; /*!< \brief Entropy fix coefficient. */ @@ -3992,6 +4002,30 @@ class CConfig { */ ENUM_REGIME GetKind_Regime(void) const { return Kind_Regime; } + /*! + * \brief Kind of incompressible solver formulation. + * \return Kind of incompressible solver. + */ + ENUM_INCOMP_SYSTEM GetKind_Incomp_System(void) const { return Kind_Incomp_System; } + + /*! + * \brief Kind of iteration used for pressure based iterations. + * \return Kind of iteration used for pressure based iterations. + */ + ENUM_PBITER GetKind_PBIter(void) const { return Kind_PBIter; } + + /*! + * \brief Set the kind of incompressible solver formulation that is used. + * \param[in] val_system - the type of system to use. + */ + void SetIncomp_System(unsigned short val_system); + + /*! + * \brief Set the pressure based iteration method. + * \param[in] val_PBIter - The iteration method for the pressure based solver. + */ + void SetPBIter(unsigned short val_PBIter); + /*! * \brief Governing equations of the flow (it can be different from the run time equation). * \param[in] val_zone - Zone where the soler is applied. @@ -4366,6 +4400,12 @@ class CConfig { */ unsigned long GetLinear_Solver_Iter(void) const { return Linear_Solver_Iter; } + /*! + * \brief Get max number of iterations of the linear solver for the poisson equation. + * \return Max number of iterations of the linear solver for the poisson equation. + */ + unsigned long GetPoisson_Linear_Solver_Iter(void) const { return Poisson_Linear_Solver_Iter; } + /*! * \brief Get max number of iterations of the linear solver for the implicit formulation. * \return Max number of iterations of the linear solver for the implicit formulation. @@ -4399,6 +4439,18 @@ class CConfig { * \return Relaxation factor. */ su2double GetLinear_Solver_Smoother_Relaxation(void) const { return Linear_Solver_Smoother_Relaxation; } + + /*! + * \brief Get the relaxation coefficient of the flow correction for PB solver. + * \return relaxation coefficient of the flow correction for PB solver + */ + su2double GetRelaxation_Factor_PBFlow(void) const { return Relaxation_Factor_PBFlow; } + + /*! + * \brief Get the relaxation coefficient for the Rhie-Chow interpolation in the PB solver. + * \return relaxation coefficient of the Rhie-Chow interpolation. + */ + su2double GetRCFactor(void) const { return RCFactor; } /*! * \brief Get the relaxation factor for solution updates of adjoint solvers. @@ -4655,6 +4707,15 @@ class CConfig { */ unsigned short GetKind_TimeIntScheme(void) const { return Kind_TimeNumScheme; } + /*! + * \brief Get the kind of integration scheme (explicit or implicit) + * for the poisson/pressure correction equations. + * \note This value is obtained from the config file, and it is constant + * during the computation. + * \return Kind of integration scheme for the poisson/pressure correction equations. + */ + unsigned short GetKind_TimeIntScheme_Poisson(void) const { return Kind_TimeIntScheme_Poisson; } + /*! * \brief Get the kind of convective numerical scheme. * \note This is the information that the code will use, the method will diff --git a/Common/include/option_structure.hpp b/Common/include/option_structure.hpp index 73266c7dacd..c4f70e37eef 100644 --- a/Common/include/option_structure.hpp +++ b/Common/include/option_structure.hpp @@ -77,7 +77,7 @@ const unsigned int MAX_PARAMETERS = 10; /*!< \brief Maximum number of para const unsigned int MAX_NUMBER_PERIODIC = 10; /*!< \brief Maximum number of periodic boundary conditions. */ const unsigned int MAX_STRING_SIZE = 400; /*!< \brief Maximum size of a generic string. */ const unsigned int MAX_NUMBER_FFD = 15; /*!< \brief Maximum number of FFDBoxes for the FFD. */ -enum: unsigned int{MAX_SOLS = 13}; /*!< \brief Maximum number of solutions at the same time (dimension of solution container array). */ +enum: unsigned int{MAX_SOLS = 14}; /*!< \brief Maximum number of solutions at the same time (dimension of solution container array). */ const unsigned int MAX_TERMS = 7; /*!< \brief Maximum number of terms in the numerical equations (dimension of solver container array). */ const unsigned int MAX_ZONES = 3; /*!< \brief Maximum number of zones. */ const unsigned int MAX_FE_KINDS = 7; /*!< \brief Maximum number of Finite Elements. */ @@ -261,6 +261,7 @@ enum class MAIN_SOLVER { FEM_RANS, /*!< \brief Definition of the finite element Reynolds-averaged Navier-Stokes' (RANS) solver. */ FEM_LES, /*!< \brief Definition of the finite element Large Eddy Simulation Navier-Stokes' (LES) solver. */ MULTIPHYSICS, + POISSON_EQUATION, /*!< \brief Definition of the Poisson equation solver. */ NEMO_EULER, /*!< \brief Definition of the NEMO Euler solver. */ NEMO_NAVIER_STOKES, /*!< \brief Definition of the NEMO NS solver. */ }; @@ -336,6 +337,33 @@ static const MapType MatComp_Map = { MakePair("NEARLY_INCOMPRESSIBLE", STRUCT_COMPRESS::NEARLY_INCOMP) }; +/*! + * \brief Type of incompressible solver + */ +enum class ENUM_INCOMP_SYSTEM { + DENSITY_BASED, /*!< \brief Density-based. */ + PRESSURE_BASED, /*!< \brief Pressure-based. */ +}; +static const MapType Incomp_Map = { + MakePair("DENSITY_BASED", ENUM_INCOMP_SYSTEM::DENSITY_BASED) + MakePair("PRESSURE_BASED", ENUM_INCOMP_SYSTEM::PRESSURE_BASED) +}; + +/*! + * \brief Type of iteration + */ +enum class ENUM_PBITER { + SIMPLE, /*!< \brief SIMPLE algorithm. */ + SIMPLEC, /*!< \brief SIMPLE algorithm. */ + PISO, /*!< \brief PISO algorithm. */ +}; + +static const MapType PBIter_Map = { + MakePair("SIMPLE", ENUM_PBITER::SIMPLE) + MakePair("SIMPLEC", ENUM_PBITER::SIMPLEC) + MakePair("PISO", ENUM_PBITER::PISO) +}; + /*! * \brief Types of interpolators */ @@ -476,6 +504,7 @@ enum RUNTIME_TYPE { RUNTIME_ADJRAD_SYS = 24, /*!< \brief One-physics case, the code is solving the adjoint radiation model. */ RUNTIME_SPECIES_SYS = 25, /*!< \brief One-physics case, the code is solving the species model. */ RUNTIME_ADJSPECIES_SYS = 26,/*!< \brief One-physics case, the code is solving the adjoint species model. */ + RUNTIME_POISSON_SYS = 27, /*!< \brief One-physics case, the code is solving the poisson equation. */ }; enum SOLVER_TYPE : const int { @@ -494,6 +523,7 @@ enum RUNTIME_TYPE { ADJSPECIES_SOL=12, /*!< \brief Position of the adjoint of the species solver. */ FEA_SOL=0, /*!< \brief Position of the Finite Element flow solution in the solver container array. */ ADJFEA_SOL=1, /*!< \brief Position of the continuous adjoint Finite Element flow solution in the solver container array. */ + POISSON_SOL=13, /*!< \brief Position of the poisson solution in the solver container array */ TEMPLATE_SOL=0, /*!< \brief Position of the template solution. */ }; @@ -825,7 +855,8 @@ enum class CENTERED { LAX, /*!< \brief Lax-Friedrich centered numerical method. */ JST_MAT, /*!< \brief JST with matrix dissipation. */ JST_KE, /*!< \brief Kinetic Energy preserving Jameson-Smith-Turkel centered numerical method. */ - LD2 /*!< \brief Low-Dissipation Low-Dispersion (LD2) centered scheme. */ + LD2, /*!< \brief Low-Dissipation Low-Dispersion (LD2) centered scheme. */ + CDS /*!< \brief Central Difference Scheme used for pressure based solver. */ }; static const MapType Centered_Map = { MakePair("NONE", CENTERED::NONE) @@ -834,6 +865,7 @@ static const MapType Centered_Map = { MakePair("JST_MAT", CENTERED::JST_MAT) MakePair("LAX-FRIEDRICH", CENTERED::LAX) MakePair("LD2", CENTERED::LD2) + MakePair("CDS", CENTERED::CDS) }; @@ -860,7 +892,8 @@ enum class UPWIND { AUSMPLUSUP, /*!< \brief AUSM+ -up numerical method (All Speed) */ AUSMPLUSUP2, /*!< \brief AUSM+ -up2 numerical method (All Speed) */ AUSMPLUSM, /*!< \breif AUSM+M numerical method. (NEMO Only)*/ - BOUNDED_SCALAR /*!< \brief Scalar advection numerical method. */ + BOUNDED_SCALAR, /*!< \brief Scalar advection numerical method. */ + UDS /*!< \brief Upwind Difference Scheme used for pressure based solver. */ }; static const MapType Upwind_Map = { MakePair("NONE", UPWIND::NONE) @@ -882,6 +915,7 @@ static const MapType Upwind_Map = { MakePair("SLAU2", UPWIND::SLAU2) MakePair("FDS", UPWIND::FDS) MakePair("LAX-FRIEDRICH", UPWIND::LAX_FRIEDRICH) + MakePair("UDS", UPWIND::UDS) }; /*! @@ -2694,6 +2728,7 @@ enum PERIODIC_QUANTITIES { PERIODIC_LIM_PRIM_1 , /*!< \brief Primitive limiter communication phase 1 of 2 (periodic only). */ PERIODIC_LIM_PRIM_2 , /*!< \brief Primitive limiter communication phase 2 of 2 (periodic only). */ PERIODIC_IMPLICIT , /*!< \brief Implicit update communication to ensure consistency across periodic boundaries. */ + PERIODIC_PRESSURE , /*!< \brief Corrected pressure communication. */ }; /*! @@ -2727,6 +2762,9 @@ enum class MPI_QUANTITIES { MESH_DISPLACEMENTS , /*!< \brief Mesh displacements at the interface. */ SOLUTION_TIME_N , /*!< \brief Solution at time n. */ SOLUTION_TIME_N1 , /*!< \brief Solution at time n-1. */ + PRESSURE_VAR , /*!< \brief Primitive variable (pressure) communication. */ + MASS_FUX , /*!< \brief Primitive variable (mass flux) communication. */ + MOM_COEFF , }; /*! diff --git a/Common/src/CConfig.cpp b/Common/src/CConfig.cpp index 0f7a5c6821f..ed2dd388b23 100644 --- a/Common/src/CConfig.cpp +++ b/Common/src/CConfig.cpp @@ -1137,6 +1137,11 @@ void CConfig::SetConfig_Options() { /*!\brief SST_OPTIONS \n DESCRIPTION: Specify SA turbulence model options/corrections. \n Options: see \link SA_Options_Map \endlink \n DEFAULT: NONE \ingroup Config*/ addEnumListOption("SA_OPTIONS", nSA_Options, SA_Options, SA_Options_Map); + /*!\brief KIND_INCOMP_SYSTEM \n DESCRIPTION: Incomp type \n OPTIONS: see \link Incomp_Map \endlink DEFAULT: NONE \ingroup Config*/ + addEnumOption("KIND_INCOMP_SYSTEM", Kind_Incomp_System, Incomp_Map, ENUM_INCOMP_SYSTEM::DENSITY_BASED); + /*!\brief KIND_PB_ITER \n DESCRIPTION: Kind_PBIter \n OPTIONS: see \link PBIter_Map \endlink \ingroup Config*/ + addEnumOption("KIND_PB_ITER", Kind_PBIter, PBIter_Map, ENUM_PBITER::SIMPLE); + /*!\brief ROUGHSST_OPTIONS \n DESCRIPTION: Specify type of boundary condition for rough walls for SST turbulence model. \n Options: see \link ROUGHSST_Options_Map \endlink \n DEFAULT: wilcox1998 \ingroup Config*/ addEnumOption("KIND_ROUGHSST_MODEL", Kind_RoughSST_Model, RoughSST_Model_Map, ROUGHSST_MODEL::WILCOX1998); /*!\brief KIND_TRANS_MODEL \n DESCRIPTION: Specify transition model OPTIONS: see \link Trans_Model_Map \endlink \n DEFAULT: NONE \ingroup Config*/ @@ -1880,6 +1885,8 @@ void CConfig::SetConfig_Options() { addEnumOption("TIME_DISCRE_HEAT", Kind_TimeIntScheme_Heat, Time_Int_Map, EULER_IMPLICIT); /* DESCRIPTION: Time discretization */ addEnumOption("TIMESTEP_HEAT", Kind_TimeStep_Heat, Heat_TimeStep_Map, MINIMUM); + /* DESCRIPTION: Time discretization */ + addEnumOption("TIME_DISCRE_POISSON", Kind_TimeIntScheme_Poisson, Time_Int_Map, EULER_IMPLICIT); /*!\par CONFIG_CATEGORY: Linear solver definition \ingroup Config*/ /*--- Options related to the linear solvers ---*/ @@ -1894,6 +1901,8 @@ void CConfig::SetConfig_Options() { addDoubleOption("LINEAR_SOLVER_ERROR", Linear_Solver_Error, 1E-6); /* DESCRIPTION: Maximum number of iterations of the linear solver for the implicit formulation */ addUnsignedLongOption("LINEAR_SOLVER_ITER", Linear_Solver_Iter, 10); + /* DESCRIPTION: Maximum number of iterations of the poisson linear solver for the implicit formulation */ + addUnsignedLongOption("POISSON_LINEAR_SOLVER_ITER", Poisson_Linear_Solver_Iter, 10); /* DESCRIPTION: Fill in level for the ILU preconditioner */ addUnsignedShortOption("LINEAR_SOLVER_ILU_FILL_IN", Linear_Solver_ILU_n, 0); /* DESCRIPTION: Use level scheduling for OMP parallelization of the ILU preconditioner */ @@ -1908,6 +1917,10 @@ void CConfig::SetConfig_Options() { addUnsignedLongOption("LINEAR_SOLVER_PREC_THREADS", Linear_Solver_Prec_Threads, 0); /* DESCRIPTION: Use an inner linear solver. */ addEnumOption("LINEAR_SOLVER_INNER", Kind_Linear_Solver_Inner, Inner_Linear_Solver_Map, LINEAR_SOLVER_INNER::NONE); + /* DESCRIPTION: Relaxation of the pressure based flow corrections */ + addDoubleOption("RELAXATION_FACTOR_PBFLOW", Relaxation_Factor_PBFlow, 0.5); + /* DESCRIPTION: Relaxation of the Rhie Chow interpolation contribution in pressure based flow. */ + addDoubleOption("RELAXATION_FACTOR_RHIECHOW", RCFactor, 0.0); /* DESCRIPTION: Relaxation factor for updates of adjoint variables. */ addDoubleOption("RELAXATION_FACTOR_ADJOINT", Relaxation_Factor_Adjoint, 1.0); /* DESCRIPTION: Relaxation of the CHT coupling */ @@ -8805,6 +8818,7 @@ unsigned short CConfig::GetContainerPosition(unsigned short val_eqsystem) { case RUNTIME_ADJSPECIES_SYS:return ADJSPECIES_SOL; case RUNTIME_ADJFEA_SYS: return ADJFEA_SOL; case RUNTIME_RADIATION_SYS: return RAD_SOL; + case RUNTIME_POISSON_SYS: return POISSON_SOL; case RUNTIME_MULTIGRID_SYS: return 0; } return 0; @@ -8943,6 +8957,13 @@ void CConfig::SetGlobalParam(MAIN_SOLVER val_solver, } break; + case MAIN_SOLVER::POISSON_EQUATION: + if (val_system == RUNTIME_POISSON_SYS) { + SetKind_ConvNumScheme(NONE, CENTERED::NONE, UPWIND::NONE, LIMITER::NONE, NONE, 0.0, NONE); + SetKind_TimeIntScheme(Kind_TimeIntScheme_Poisson); + } + break; + case MAIN_SOLVER::FEM_ELASTICITY: case MAIN_SOLVER::DISC_ADJ_FEM: if (val_system == RUNTIME_FEA_SYS) { diff --git a/SU2_CFD/include/iteration/CPBFluidIteration.hpp b/SU2_CFD/include/iteration/CPBFluidIteration.hpp new file mode 100644 index 00000000000..a102b9fa2c8 --- /dev/null +++ b/SU2_CFD/include/iteration/CPBFluidIteration.hpp @@ -0,0 +1,75 @@ +/*! + * \file CPBFluidIteration.hpp + * \brief Headers of the pressure based fluid iteration class. + * \author F. Palacios, T. Economon + * \version 8.5.0 "Harrier" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2026, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#pragma once + +#include "CFluidIteration.hpp" + +/*! + * \class CFluidIteration + * \ingroup Drivers + * \brief Class for driving an iteration of the fluid system. + * \author T. Economon + */ +class CPBFluidIteration : public CFluidIteration { +public: + /*! + * \brief Constructor of the class. + * \param[in] config - Definition of the particular problem. + */ + explicit CPBFluidIteration(const CConfig* config) : CFluidIteration(config) {} + + /*! + * \brief Preprocessing to prepare for an iteration of the physics. + * \param[in] ??? - Description here. + */ + void Preprocess(COutput* output, CIntegration**** integration, CGeometry**** geometry, CSolver***** solver, + CNumerics****** numerics, CConfig** config, CSurfaceMovement** surface_movement, + CVolumetricMovement*** grid_movement, CFreeFormDefBox*** FFDBox, unsigned short val_iZone, + unsigned short val_iInst) override; + + /*! + * \brief Perform a single iteration of the fluid system. + * \param[in] output - Pointer to the COutput class. + * \param[in] integration - Container vector with all the integration methods. + * \param[in] geometry - Geometrical definition of the problem. + * \param[in] solver - Container vector with all the solutions. + * \param[in] numerics - Description of the numerical method (the way in which the equations are solved). + * \param[in] config - Definition of the particular problem. + * \param[in] surface_movement - Surface movement classes of the problem. + * \param[in] grid_movement - Volume grid movement classes of the problem. + * \param[in] FFDBox - FFD FFDBoxes of the problem. + * \param[in] val_iZone - Index of the zone. + * \param[in] val_iInst - Index of the instance layer. + */ + void Iterate(COutput* output, CIntegration**** integration, CGeometry**** geometry, CSolver***** solver, + CNumerics****** numerics, CConfig** config, CSurfaceMovement** surface_movement, + CVolumetricMovement*** grid_movement, CFreeFormDefBox*** FFDBox, unsigned short val_iZone, + unsigned short val_iInst) override; + + }; + diff --git a/SU2_CFD/include/solvers/CPBIncEulerSolver.hpp b/SU2_CFD/include/solvers/CPBIncEulerSolver.hpp new file mode 100644 index 00000000000..45add069e71 --- /dev/null +++ b/SU2_CFD/include/solvers/CPBIncEulerSolver.hpp @@ -0,0 +1,72 @@ +/*! + * \file CPBIncEulerSolver.hpp + * \brief Headers of the CPBIncEulerSolver class + * \author F. Palacios, T. Economon, T. Albring + * \version 8.5.0 "Harrier" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2026, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + + +#pragma once + +#include "CFVMFlowSolverBase.hpp" +#include "../variables/CPBIncEulerVariable.hpp" + +class CPBIncEulerSolver : public CFVMFlowSolverBase { +protected: + +public: + /*! + * \brief Constructor of the class. + */ + //CPBIncEulerSolver(CGeometry *geometry, CConfig *config, unsigned short iMesh) {}; + + CPBIncEulerSolver() = delete; + + /*! + * \brief Constructor of the class. + * \param[in] geometry - Geometrical definition of the problem. + * \param[in] config - Definition of the particular problem. + * \param[in] iMesh - Grid level. + * \param[in] navier_stokes - True when the constructor is called by the derived class CPBIncNSSolver. + */ + CPBIncEulerSolver(CGeometry *geometry, CConfig *config, unsigned short iMesh, const bool navier_stokes = false); + + /*! + * \brief Destructor of the class. + */ + ~CPBIncEulerSolver(void) override {} + + /*! + * \brief Set reference values for pressure, forces, etc. + */ + void SetReferenceValues(const CConfig& config) final {} + + /*! + * \brief Print verification error to screen. + * \param[in] config - Definition of the particular problem. + */ + void PrintVerificationError(const CConfig* config) const final {} + + + +}; diff --git a/SU2_CFD/include/solvers/CPBIncNSSolver.hpp b/SU2_CFD/include/solvers/CPBIncNSSolver.hpp new file mode 100644 index 00000000000..c20f69e626a --- /dev/null +++ b/SU2_CFD/include/solvers/CPBIncNSSolver.hpp @@ -0,0 +1,47 @@ +/*! + * \file CPBIncNSSolver.hpp + * \brief Headers of the CPBIncNSSolver class + * \author F. Palacios, T. Economon, T. Albring + * \version 8.5.0 "Harrier" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2026, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#pragma once + +#include "CPBIncEulerSolver.hpp" + +/*! + * \class CPBIncNSSolver + * \brief Main class for defining the pressure based incompressible Navier-Stokes flow solver. + * \ingroup Navier_Stokes_Equations + * \author F. Palacios, T. Economon, T. Albring + */ +class CPBIncNSSolver final : public CPBIncEulerSolver { +public: + + /*! + * \brief Constructor of the class. + */ + CPBIncNSSolver(CGeometry *geometry, CConfig *config, unsigned short iMesh); + + +}; diff --git a/SU2_CFD/include/solvers/CPoissonSolver.hpp b/SU2_CFD/include/solvers/CPoissonSolver.hpp new file mode 100644 index 00000000000..49a9f723e8f --- /dev/null +++ b/SU2_CFD/include/solvers/CPoissonSolver.hpp @@ -0,0 +1,119 @@ +/*! + * \file CPoissonSolver.hpp + * \brief Headers of the CPoissonSolver class + * \author F. Palacios, T. Economon + * \version 8.5.0 "Harrier" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2026, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#pragma once + +#include "CScalarSolver.hpp" +#include "../variables/CPoissonVariable.hpp" + +/*! + * \class CPoissonSolver + * \brief Main class for defining the finite-volume poisson equation solver. + * \author O. Burghardt + * \version 8.5.0 "Harrier" + */ +class CPoissonSolver final : public CScalarSolver { +protected: + +public: + + /*! + * \brief Constructor of the class. + */ + // CPoissonSolver(void); + /* + * \overload + * \param[in] geometry - Geometrical definition of the problem + * \param[in] config - Definition of the particular problem + */ + CPoissonSolver(CGeometry *geometry, CConfig *config, unsigned short iMesh); + + /* + * \brief Destructor of the class. + */ + // ~CPoissonSolver(void); + + /*! + * \brief Load a solution from a restart file. + * \param[in] geometry - Geometrical definition of the problem. + * \param[in] solver - Container vector with all of the solvers. + * \param[in] config - Definition of the particular problem. + * \param[in] val_iter - Current external iteration number. + * \param[in] val_update_geo - Flag for updating coords and grid velocity. + */ + void LoadRestart(CGeometry **geometry, + CSolver ***solver, + CConfig *config, + int val_iter, + bool val_update_geo) override {} + + /*! + * \brief A virtual member. + * \param[in] geometry - Geometrical definition of the problem. + * \param[in] solver_container - Container vector with all the solutions. + * \param[in] config - Definition of the particular problem. + * \param[in] iMesh - Index of the mesh in multigrid computations. + * \param[in] Iteration - Index of the current iteration. + */ + void SetTime_Step(CGeometry *geometry, + CSolver **solver_container, + CConfig *config, + unsigned short iMesh, + unsigned long Iteration) override {} + + /*! + * \brief Set the initial condition for the FEM structural problem. + * \param[in] geometry - Geometrical definition of the problem. + * \param[in] solver_container - Container with all the solutions. + * \param[in] config - Definition of the particular problem. + * \param[in] ExtIter - External iteration. + */ + void SetInitialCondition(CGeometry **geometry, + CSolver ***solver_container, + CConfig *config, + unsigned long TimeIter) override {} + + /*! + * \brief Set the total residual adding the term that comes from the Dual Time-Stepping Strategy. + * \param[in] geometry - Geometric definition of the problem. + * \param[in] solver_container - Container vector with all the solutions. + * \param[in] config - Definition of the particular problem. + * \param[in] iRKStep - Current step of the Runge-Kutta iteration. + * \param[in] iMesh - Index of the mesh in multigrid computations. + * \param[in] RunTime_EqSystem - System of equations which is going to be solved. + */ + void SetResidual_DualTime(CGeometry *geometry, + CSolver **solver_container, + CConfig *config, + unsigned short iRKStep, + unsigned short iMesh, + unsigned short RunTime_EqSystem) override {} + + + + +}; diff --git a/SU2_CFD/include/solvers/CSolverFactory.hpp b/SU2_CFD/include/solvers/CSolverFactory.hpp index e612f3fb1e3..9a89629658e 100644 --- a/SU2_CFD/include/solvers/CSolverFactory.hpp +++ b/SU2_CFD/include/solvers/CSolverFactory.hpp @@ -63,6 +63,7 @@ enum class SUB_SOLVER_TYPE { MESH, /*!< \brief Mesh solver */ RADIATION, /*!< \brief Radiation solver */ DISC_ADJ_RADIATION, /*!< \brief Discrete adjoint radiation solver */ + POISSON, /*!< \breif Poisson equation solver */ NONE }; diff --git a/SU2_CFD/include/variables/CPBIncEulerVariable.hpp b/SU2_CFD/include/variables/CPBIncEulerVariable.hpp new file mode 100644 index 00000000000..b0f098189b8 --- /dev/null +++ b/SU2_CFD/include/variables/CPBIncEulerVariable.hpp @@ -0,0 +1,80 @@ +/*! + * \file CPBIncEulerVariable.hpp + * \brief Class for defining the variables of the pressure based incompressible Euler solver. + * \author F. Palacios, T. Economon + * \version 8.5.0 "Harrier" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2026, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#pragma once + +#include +#include "CFlowVariable.hpp" + +/*! + * \class CPBIncEulerVariable + * \brief Class for defining the variables of the pressure based incompressible Euler solver. + * \ingroup Euler_Equations + * \author F. Palacios, T. Economon, T. Albring + */ +class CPBIncEulerVariable : public CFlowVariable { +public: + static constexpr size_t MAXNVAR = 13; + + template + struct CIndices { + const IndexType nDim; + CIndices(IndexType ndim, IndexType) : nDim(ndim) {} + inline IndexType NDim() const { return nDim; } + inline IndexType NSpecies() const { return 0; } + inline IndexType Pressure() const { return 0; } + inline IndexType Velocity() const { return 1; } + inline IndexType Temperature() const { return nDim+1; } + inline IndexType Density() const { return nDim+2; } + inline IndexType Enthalpy() const { return nDim+3; } + inline IndexType Beta() const { return nDim+4; } + inline IndexType SoundSpeed() const { return Beta(); } + inline IndexType LaminarViscosity() const { return nDim+5; } + inline IndexType EddyViscosity() const { return nDim+6; } + inline IndexType ThermalConductivity() const { return nDim+7; } + inline IndexType CpTotal() const { return nDim+8; } + inline IndexType CvTotal() const { return nDim+9; } + + /*--- For compatible interface with NEMO. ---*/ + inline IndexType SpeciesDensities() const { return std::numeric_limits::max(); } + inline IndexType Temperature_ve() const { return std::numeric_limits::max(); } + }; + +protected: + const CIndices indices; + +public: + + CPBIncEulerVariable(su2double pressure, const su2double *velocity, su2double enthalpy, + unsigned long npoint, unsigned long ndim, unsigned long nvar, const CConfig *config); + + inline CMatrixView GetVelocityGradient(unsigned long iPoint) const final { + return Gradient_Primitive(iPoint, indices.Velocity()); + } + + +}; diff --git a/SU2_CFD/include/variables/CPBIncNSVariable.hpp b/SU2_CFD/include/variables/CPBIncNSVariable.hpp new file mode 100644 index 00000000000..d9837bd9d29 --- /dev/null +++ b/SU2_CFD/include/variables/CPBIncNSVariable.hpp @@ -0,0 +1,59 @@ +/*! + * \file CPBIncNSVariable.hpp + * \brief Class for defining the variables of the pressure based incompressible + Navier-Stokes solver. + * \author F. Palacios, T. Economon + * \version 8.5.0 "Harrier" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2026, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#pragma once + +#include "CPBIncEulerVariable.hpp" + +/*! + * \class CPBIncNSVariable + * \brief Class for defining the variables of the incompressible Navier-Stokes solver. + * \ingroup Navier_Stokes_Equations + * \author F. Palacios, T. Economon, T. Albring + */ +class CPBIncNSVariable final : public CPBIncEulerVariable { +private: + const bool Energy; /*!< \brief Flag for Energy equation in incompressible flows. */ + +public: + + /*! + * \brief Constructor of the class. + * \param[in] pressure - value of the pressure. + * \param[in] velocity - Value of the flow velocity (initialization value). + * \param[in] temperature - Value of the temperature (initialization value). + * \param[in] npoint - Number of points/nodes/vertices in the domain. + * \param[in] ndim - Number of dimensions of the problem. + * \param[in] nvar - Number of variables of the problem. + * \param[in] config - Definition of the particular problem. + */ + CPBIncNSVariable(su2double pressure, const su2double *velocity, su2double temperature, + unsigned long npoint, unsigned long ndim, unsigned long nvar, const CConfig *config); + + +}; diff --git a/SU2_CFD/include/variables/CPoissonVariable.hpp b/SU2_CFD/include/variables/CPoissonVariable.hpp new file mode 100644 index 00000000000..1d730ed5130 --- /dev/null +++ b/SU2_CFD/include/variables/CPoissonVariable.hpp @@ -0,0 +1,59 @@ +/*! + * \file CPoissonVariable.hpp + * \brief Class for defining the variables of the finite-volume heat equation solver. + * \author F. Palacios, T. Economon + * \version 8.5.0 "Harrier" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2026, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#pragma once + +#include "CScalarVariable.hpp" + +/*! + * \class CPoissonVariable + * \brief Class for defining the variables of the finite-volume poisson equation solver. + * \author O. Burghardt + * \version 8.5.0 "Harrier" + */ +class CPoissonVariable final : public CScalarVariable { +public: + static constexpr size_t MAXNVAR = 1; /*!< \brief Max number of variables, for static arrays. */ + + /*! + * \brief Constructor of the class. + * \param[in] heat - Values of the poisson solution (initialization value). + * \param[in] npoint - Number of points/nodes/vertices in the domain. + * \param[in] ndim - Number of dimensions of the problem. + * \param[in] nvar - Number of variables of the problem. + * \param[in] config - Definition of the particular problem. + */ + CPoissonVariable(su2double heat, unsigned long npoint, unsigned long ndim, unsigned long nvar, CConfig *config) + : CScalarVariable(npoint, ndim, nvar, config) {} + + /*! + * \brief Get the temperature of the point. + * \return Value of the temperature of the point. + */ + // inline su2double GetTemperature(unsigned long iPoint) const final { return Solution(iPoint, 0); } + +}; diff --git a/SU2_CFD/src/drivers/CDriver.cpp b/SU2_CFD/src/drivers/CDriver.cpp index 5bdeb9ce1af..9667fdb9393 100644 --- a/SU2_CFD/src/drivers/CDriver.cpp +++ b/SU2_CFD/src/drivers/CDriver.cpp @@ -51,6 +51,7 @@ #include "../../include/variables/CEulerVariable.hpp" #include "../../include/variables/CIncEulerVariable.hpp" +#include "../../include/variables/CPBIncEulerVariable.hpp" #include "../../include/variables/CNEMOEulerVariable.hpp" #include "../../include/numerics/template.hpp" @@ -1447,13 +1448,16 @@ void CDriver::InitializeNumerics(CConfig *config, CGeometry **geometry, CSolver nVar_Adj_Flow = 0, nVar_Adj_Turb = 0, nVar_FEM = 0, - nVar_Rad = 0; + nVar_Rad = 0, + nVar_Poisson = 0; numerics = new CNumerics***[config->GetnMGLevels()+1] (); bool compressible = false; bool incompressible = false; bool ideal_gas = (config->GetKind_FluidModel() == STANDARD_AIR) || (config->GetKind_FluidModel() == IDEAL_GAS); + bool pressure_based = (config->GetKind_Incomp_System() == ENUM_INCOMP_SYSTEM::PRESSURE_BASED); + bool poisson = (config->GetKind_Incomp_System() == ENUM_INCOMP_SYSTEM::PRESSURE_BASED); bool roe_low_dissipation = (config->GetKind_RoeLowDiss() != NO_ROELOWDISS); /*--- Initialize some useful booleans ---*/ @@ -1567,6 +1571,8 @@ void CDriver::InitializeNumerics(CConfig *config, CGeometry **geometry, CSolver if (fem) nVar_FEM = solver[MESH_0][FEA_SOL]->GetnVar(); + if (poisson) nVar_Poisson = solver[MESH_0][POISSON_SOL]->GetnVar(); + if (config->AddRadiation()) nVar_Rad = solver[MESH_0][RAD_SOL]->GetnVar(); /*--- Number of variables for adjoint problem ---*/ @@ -1654,22 +1660,37 @@ void CDriver::InitializeNumerics(CConfig *config, CGeometry **geometry, CSolver } if (incompressible) { - /*--- Incompressible flow, use preconditioning method ---*/ - switch (config->GetKind_Centered_Flow()) { - case CENTERED::LAX : numerics[MESH_0][FLOW_SOL][conv_term] = new CCentLaxInc_Flow(nDim, nVar_Flow, config); break; - case CENTERED::LD2 : - case CENTERED::JST : numerics[MESH_0][FLOW_SOL][conv_term] = new CCentJSTInc_Flow(nDim, nVar_Flow, config); break; - default: - SU2_MPI::Error("Invalid centered scheme or not implemented.\n Currently, only JST and LAX-FRIEDRICH are available for incompressible flows.", CURRENT_FUNCTION); - break; - } - for (iMGlevel = 1; iMGlevel <= config->GetnMGLevels(); iMGlevel++) - numerics[iMGlevel][FLOW_SOL][conv_term] = new CCentLaxInc_Flow(nDim, nVar_Flow, config); + if (!pressure_based) { + /*--- Incompressible flow, use preconditioning method ---*/ + switch (config->GetKind_Centered_Flow()) { + case CENTERED::LAX : numerics[MESH_0][FLOW_SOL][conv_term] = new CCentLaxInc_Flow(nDim, nVar_Flow, config); break; + case CENTERED::LD2 : + case CENTERED::JST : numerics[MESH_0][FLOW_SOL][conv_term] = new CCentJSTInc_Flow(nDim, nVar_Flow, config); break; + default: + SU2_MPI::Error("Invalid centered scheme or not implemented.\n Currently, only JST and LAX-FRIEDRICH are available for density based incompressible flows.", CURRENT_FUNCTION); + break; + } + for (iMGlevel = 1; iMGlevel <= config->GetnMGLevels(); iMGlevel++) + numerics[iMGlevel][FLOW_SOL][conv_term] = new CCentLaxInc_Flow(nDim, nVar_Flow, config); + /*--- Definition of the boundary condition method ---*/ + for (iMGlevel = 0; iMGlevel <= config->GetnMGLevels(); iMGlevel++) + numerics[iMGlevel][FLOW_SOL][conv_bound_term] = new CUpwFDSInc_Flow(nDim, nVar_Flow, config); - /*--- Definition of the boundary condition method ---*/ - for (iMGlevel = 0; iMGlevel <= config->GetnMGLevels(); iMGlevel++) - numerics[iMGlevel][FLOW_SOL][conv_bound_term] = new CUpwFDSInc_Flow(nDim, nVar_Flow, config); + } else { + /*--- Incompressible flow, use pressure-based method ---*/ + switch (config->GetKind_Centered_Flow()) { + case CENTERED::CDS : /* numerics[MESH_0][FLOW_SOL][conv_term] = new CCentPB_Flow(nDim, nVar_Flow, config); */ break; + default: + SU2_MPI::Error("Invalid centered scheme or not implemented.\n Currently, only CDS is available for pressure based incompressible flows.", CURRENT_FUNCTION); + } + // for (iMGlevel = 1; iMGlevel <= config->GetnMGLevels(); iMGlevel++) + // numerics[iMGlevel][FLOW_SOL][conv_term] = new CCentPB_Flow(nDim, nVar_Flow, config); + /*--- Definition of the boundary condition method ---*/ + // for (iMGlevel = 0; iMGlevel <= config->GetnMGLevels(); iMGlevel++) + // numerics[iMGlevel][FLOW_SOL][conv_bound_term] = new CUpwPB_Flow(nDim, nVar_Flow, config); + + } } break; case SPACE_UPWIND : @@ -1776,17 +1797,32 @@ void CDriver::InitializeNumerics(CConfig *config, CGeometry **geometry, CSolver } if (incompressible) { - /*--- Incompressible flow, use artificial compressibility method ---*/ - switch (config->GetKind_Upwind_Flow()) { - case UPWIND::FDS: - for (iMGlevel = 0; iMGlevel <= config->GetnMGLevels(); iMGlevel++) { - numerics[iMGlevel][FLOW_SOL][conv_term] = new CUpwFDSInc_Flow(nDim, nVar_Flow, config); - numerics[iMGlevel][FLOW_SOL][conv_bound_term] = new CUpwFDSInc_Flow(nDim, nVar_Flow, config); - } - break; - default: - SU2_MPI::Error("Invalid upwind scheme or not implemented.\n Currently, only FDS is available for incompressible flows.", CURRENT_FUNCTION); - break; + if (!pressure_based) { + /*--- Incompressible flow, use artificial compressibility method ---*/ + switch (config->GetKind_Upwind_Flow()) { + case UPWIND::FDS: + for (iMGlevel = 0; iMGlevel <= config->GetnMGLevels(); iMGlevel++) { + numerics[iMGlevel][FLOW_SOL][conv_term] = new CUpwFDSInc_Flow(nDim, nVar_Flow, config); + numerics[iMGlevel][FLOW_SOL][conv_bound_term] = new CUpwFDSInc_Flow(nDim, nVar_Flow, config); + } + break; + default: + SU2_MPI::Error("Invalid upwind scheme or not implemented.\n Currently, only FDS is available for density based incompressible flows.", CURRENT_FUNCTION); + break; + } + } else { + /*--- Incompressible flow, use pressure based method ---*/ + switch (config->GetKind_Upwind_Flow()) { + case UPWIND::UDS: + for (iMGlevel = 0; iMGlevel <= config->GetnMGLevels(); iMGlevel++) { + // numerics[iMGlevel][FLOW_SOL][conv_term] = new CUpwPB_Flow(nDim, nVar_Flow, config); + // numerics[iMGlevel][FLOW_SOL][conv_bound_term] = new CUpwPB_Flow(nDim, nVar_Flow, config); + } + break; + default: + SU2_MPI::Error("Invalid upwind scheme or not implemented.\n Currently, only UDS is available for pressure based incompressible flows.", CURRENT_FUNCTION); + break; + } } } break; @@ -1823,14 +1859,25 @@ void CDriver::InitializeNumerics(CConfig *config, CGeometry **geometry, CSolver } } if (incompressible) { - /*--- Incompressible flow, use preconditioning method ---*/ - numerics[MESH_0][FLOW_SOL][visc_term] = new CAvgGradInc_Flow(nDim, nVar_Flow, true, config); - for (iMGlevel = 1; iMGlevel <= config->GetnMGLevels(); iMGlevel++) - numerics[iMGlevel][FLOW_SOL][visc_term] = new CAvgGradInc_Flow(nDim, nVar_Flow, false, config); + if (!pressure_based) { + /*--- Incompressible flow, use preconditioning method ---*/ + numerics[MESH_0][FLOW_SOL][visc_term] = new CAvgGradInc_Flow(nDim, nVar_Flow, true, config); + for (iMGlevel = 1; iMGlevel <= config->GetnMGLevels(); iMGlevel++) + numerics[iMGlevel][FLOW_SOL][visc_term] = new CAvgGradInc_Flow(nDim, nVar_Flow, false, config); - /*--- Definition of the boundary condition method ---*/ - for (iMGlevel = 0; iMGlevel <= config->GetnMGLevels(); iMGlevel++) - numerics[iMGlevel][FLOW_SOL][visc_bound_term] = new CAvgGradInc_Flow(nDim, nVar_Flow, false, config); + /*--- Definition of the boundary condition method ---*/ + for (iMGlevel = 0; iMGlevel <= config->GetnMGLevels(); iMGlevel++) + numerics[iMGlevel][FLOW_SOL][visc_bound_term] = new CAvgGradInc_Flow(nDim, nVar_Flow, false, config); + } else { + /*--- Incompressible flow, use pressure based method ---*/ + // numerics[MESH_0][FLOW_SOL][visc_term] = new CAvgGradCorrectedPBInc_Flow(nDim, nVar_Flow, config); + // for (iMGlevel = 1; iMGlevel <= config->GetnMGLevels(); iMGlevel++) + // numerics[iMGlevel][FLOW_SOL][visc_term] = new CAvgGradPBInc_Flow(nDim, nVar_Flow, config); + + /*--- Definition of the boundary condition method ---*/ + // for (iMGlevel = 0; iMGlevel <= config->GetnMGLevels(); iMGlevel++) + // numerics[iMGlevel][FLOW_SOL][visc_bound_term] = new CAvgGradPBInc_Flow(nDim, nVar_Flow, config); + } } /*--- Definition of the source term integration scheme for each equation and mesh level ---*/ @@ -2035,8 +2082,13 @@ void CDriver::InitializeNumerics(CConfig *config, CGeometry **geometry, CSolver if (turbulent) { if (incompressible) - InstantiateTurbulentNumerics >(nVar_Turb, offset, config, - solver[MESH_0][TURB_SOL], numerics); + if (!pressure_based) + InstantiateTurbulentNumerics >(nVar_Turb, offset, config, + solver[MESH_0][TURB_SOL], numerics); + else + InstantiateTurbulentNumerics >(nVar_Turb, offset, config, + solver[MESH_0][TURB_SOL], numerics); + else if (NEMO_ns) InstantiateTurbulentNumerics >(nVar_Turb, offset, config, solver[MESH_0][TURB_SOL], numerics); @@ -2094,6 +2146,24 @@ void CDriver::InitializeNumerics(CConfig *config, CGeometry **geometry, CSolver } } + /*--- Solver definition for the poisson/pressure correction problem ---*/ + if (poisson) { + /*--- Pressure correction (Poisson) equation ---*/ + // numerics[MESH_0][POISSON_SOL][visc_term] = new CAvgGradCorrected_Poisson(nDim, nVar_Poisson, config); + + for (iMGlevel = 1; iMGlevel <= config->GetnMGLevels(); iMGlevel++) + // numerics[iMGlevel][POISSON_SOL][visc_term] = new CAvgGrad_Poisson(nDim, nVar_Poisson, config); + + /*--- Assign the convective boundary term as well to account for flow BCs as well --*/ + for (iMGlevel = 0; iMGlevel <= config->GetnMGLevels(); iMGlevel++) { + // numerics[iMGlevel][POISSON_SOL][visc_bound_term] = new CAvgGrad_Poisson(nDim, nVar_Poisson, config); + + /*--- Definition of the source term integration scheme for each equation and mesh level ---*/ + // numerics[iMGlevel][POISSON_SOL][source_first_term] = new CSource_PoissonFVM(nDim, nVar_Poisson, config); + // numerics[iMGlevel][POISSON_SOL][source_second_term] = new CSourceNothing(nDim, nVar_Poisson, config); + } + } + /*--- Solver definition for the radiation model problem ---*/ if (config->AddRadiation()) { diff --git a/SU2_CFD/src/iteration/CIterationFactory.cpp b/SU2_CFD/src/iteration/CIterationFactory.cpp index 761ceca98f8..5b5b084fa60 100644 --- a/SU2_CFD/src/iteration/CIterationFactory.cpp +++ b/SU2_CFD/src/iteration/CIterationFactory.cpp @@ -32,6 +32,7 @@ #include "../../include/iteration/CDiscAdjFluidIteration.hpp" #include "../../include/iteration/CDiscAdjHeatIteration.hpp" #include "../../include/iteration/CFluidIteration.hpp" +#include "../../include/iteration/CPBFluidIteration.hpp" #include "../../include/iteration/CFEMFluidIteration.hpp" #include "../../include/iteration/CTurboIteration.hpp" #include "../../include/iteration/CHeatIteration.hpp" @@ -57,6 +58,11 @@ CIteration* CIterationFactory::CreateIteration(MAIN_SOLVER kindSolver, const CCo iteration = new CTurboIteration(config); } + else if (config->GetKind_Incomp_System() == ENUM_INCOMP_SYSTEM::PRESSURE_BASED) { + if (rank == MASTER_NODE) + cout << "Pressure based Euler/Navier-Stokes/RANS fluid iteration." << endl; + iteration = new CPBFluidIteration(config); + } else{ if (rank == MASTER_NODE) cout << "Euler/Navier-Stokes/RANS fluid iteration." << endl; diff --git a/SU2_CFD/src/iteration/CPBFluidIteration.cpp b/SU2_CFD/src/iteration/CPBFluidIteration.cpp new file mode 100644 index 00000000000..9c806e5c5d7 --- /dev/null +++ b/SU2_CFD/src/iteration/CPBFluidIteration.cpp @@ -0,0 +1,64 @@ +/*! + * \file CPBFluidIteration.cpp + * \brief Main subroutines used by SU2_CFD + * \author F. Palacios, T. Economon + * \version 8.5.0 "Harrier" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2026, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#include "../../include/iteration/CPBFluidIteration.hpp" +#include "../../include/output/COutput.hpp" + +void CPBFluidIteration::Preprocess(COutput* output, CIntegration**** integration, CGeometry**** geometry, + CSolver***** solver, CNumerics****** numerics, CConfig** config, + CSurfaceMovement** surface_movement, CVolumetricMovement*** grid_movement, + CFreeFormDefBox*** FFDBox, unsigned short val_iZone, unsigned short val_iInst) { } + +void CPBFluidIteration::Iterate(COutput* output, CIntegration**** integration, CGeometry**** geometry, + CSolver***** solver, CNumerics****** numerics, CConfig** config, + CSurfaceMovement** surface_movement, CVolumetricMovement*** grid_movement, + CFreeFormDefBox*** FFDBox, unsigned short val_iZone, unsigned short val_iInst) { + SU2_ZONE_SCOPED + + const bool unsteady = (config[val_iZone]->GetTime_Marching() == TIME_MARCHING::DT_STEPPING_1ST) || + (config[val_iZone]->GetTime_Marching() == TIME_MARCHING::DT_STEPPING_2ND); + const bool frozen_visc = (config[val_iZone]->GetContinuous_Adjoint() && config[val_iZone]->GetFrozen_Visc_Cont()) || + (config[val_iZone]->GetDiscrete_Adjoint() && config[val_iZone]->GetFrozen_Visc_Disc()); + const bool disc_adj = (config[val_iZone]->GetDiscrete_Adjoint()); + + /*--- Setting up iteration values depending on if this is a + steady or an unsteady simulation */ + + const auto InnerIter = config[val_iZone]->GetInnerIter(); + const auto TimeIter = config[val_iZone]->GetTimeIter(); + + /*--- Solve the Euler, Navier-Stokes, RANS equations. ---*/ + + /*--- Solve the momentum equations. ---*/ + + /*--- Solve the pressure correction (poisson) equation ---*/ + + /*--- Correct pressure and velocities. ---*/ + + /*--- T.B.D. ---*/ + +} diff --git a/SU2_CFD/src/meson.build b/SU2_CFD/src/meson.build index 3b40822a34f..8aee51243dc 100644 --- a/SU2_CFD/src/meson.build +++ b/SU2_CFD/src/meson.build @@ -55,6 +55,7 @@ su2_cfd_src += files(['output/COutputFactory.cpp', 'output/tools/CWindowingTools.cpp']) su2_cfd_src += files(['variables/CIncNSVariable.cpp', + 'variables/CPBIncNSVariable.cpp', 'variables/CTransLMVariable.cpp', 'variables/CAdjEulerVariable.cpp', 'variables/CHeatVariable.cpp', @@ -81,6 +82,8 @@ su2_cfd_src += files(['variables/CIncNSVariable.cpp', 'variables/CAdjTurbVariable.cpp', 'variables/CFlowVariable.cpp', 'variables/CIncEulerVariable.cpp', + 'variables/CPBIncEulerVariable.cpp', + 'variables/CPoissonVariable.cpp', 'variables/CEulerVariable.cpp', 'variables/CNEMOEulerVariable.cpp', 'variables/CNEMONSVariable.cpp', @@ -103,7 +106,10 @@ su2_cfd_src += files(['solvers/CSolverFactory.cpp', 'solvers/CFEM_DG_NSSolver.cpp', 'solvers/CHeatSolver.cpp', 'solvers/CIncEulerSolver.cpp', + 'solvers/CPBIncEulerSolver.cpp', 'solvers/CIncNSSolver.cpp', + 'solvers/CPBIncNSSolver.cpp', + 'solvers/CPoissonSolver.cpp', 'solvers/CMeshSolver.cpp', 'solvers/CNEMOEulerSolver.cpp', 'solvers/CNEMONSSolver.cpp', @@ -184,6 +190,7 @@ su2_cfd_src += files(['iteration/CIteration.cpp', 'iteration/CFEAIteration.cpp', 'iteration/CFEMFluidIteration.cpp', 'iteration/CFluidIteration.cpp', + 'iteration/CPBFluidIteration.cpp', 'iteration/CHeatIteration.cpp', 'iteration/CTurboIteration.cpp']) diff --git a/SU2_CFD/src/solvers/CPBIncEulerSolver.cpp b/SU2_CFD/src/solvers/CPBIncEulerSolver.cpp new file mode 100644 index 00000000000..b402713ceec --- /dev/null +++ b/SU2_CFD/src/solvers/CPBIncEulerSolver.cpp @@ -0,0 +1,232 @@ +/*! + * \file CPBIncEulerSolver.cpp + * \brief Main subroutines for solving pressure based incompressible flow (Euler, Navier-Stokes, etc.). + * \author F. Palacios, T. Economon + * \version 8.5.0 "Harrier" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2026, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#include "../../include/solvers/CPBIncEulerSolver.hpp" +#include "../../../Common/include/toolboxes/printing_toolbox.hpp" +#include "../../include/fluid/CConstantDensity.hpp" +#include "../../include/fluid/CIncIdealGas.hpp" +#include "../../include/fluid/CIncIdealGasPolynomial.hpp" +#include "../../include/variables/CPBIncNSVariable.hpp" +#include "../../../Common/include/toolboxes/geometry_toolbox.hpp" +#include "../../include/fluid/CFluidScalar.hpp" +#include "../../include/fluid/CFluidFlamelet.hpp" +#include "../../include/fluid/CFluidModel.hpp" + +// Temporarily directly copied from CIncEulerSolver's constructor to adhere to necessary +// initializations, +CPBIncEulerSolver::CPBIncEulerSolver(CGeometry *geometry, CConfig *config, unsigned short iMesh, + const bool navier_stokes) : + CFVMFlowSolverBase(*geometry, *config) { + SU2_ZONE_SCOPED + + + /*--- Based on the navier_stokes boolean, determine if this constructor is + * being called by itself, or by its derived class CIncNSSolver. ---*/ + const string description = navier_stokes? "Navier-Stokes" : "Euler"; + + unsigned short iMarker; + ifstream restart_file; + bool restart = (config->GetRestart() || config->GetRestart_Flow()); + int Unst_RestartIter = 0; + bool dual_time = ((config->GetTime_Marching() == TIME_MARCHING::DT_STEPPING_1ST) || + (config->GetTime_Marching() == TIME_MARCHING::DT_STEPPING_2ND)); + bool time_stepping = config->GetTime_Marching() == TIME_MARCHING::TIME_STEPPING; + bool adjoint = (config->GetContinuous_Adjoint()) || (config->GetDiscrete_Adjoint()); + const bool centered = config->GetKind_ConvNumScheme_Flow() == SPACE_CENTERED; + const su2double* scalar_init = nullptr; + + /* A grid is defined as dynamic if there's rigid grid movement or grid deformation AND the problem is time domain */ + dynamic_grid = config->GetDynamic_Grid(); + + /*--- Store the multigrid level. ---*/ + MGLevel = iMesh; + + /*--- Check for a restart file to evaluate if there is a change in the angle of attack + before computing all the non-dimesional quantities. ---*/ + + if (restart) { + + if (iMesh == MESH_0) { + + /*--- Modify file name for a dual-time unsteady restart ---*/ + + if (dual_time) { + if (adjoint) Unst_RestartIter = SU2_TYPE::Int(config->GetUnst_AdjointIter())-1; + else if (config->GetTime_Marching() == TIME_MARCHING::DT_STEPPING_1ST) + Unst_RestartIter = SU2_TYPE::Int(config->GetRestart_Iter())-1; + else Unst_RestartIter = SU2_TYPE::Int(config->GetRestart_Iter())-2; + } + + /*--- Modify file name for a time stepping unsteady restart ---*/ + + if (time_stepping) { + if (adjoint) Unst_RestartIter = SU2_TYPE::Int(config->GetUnst_AdjointIter())-1; + else Unst_RestartIter = SU2_TYPE::Int(config->GetRestart_Iter())-1; + } + + } + + if (config->GetKind_Streamwise_Periodic() == ENUM_STREAMWISE_PERIODIC::MASSFLOW) { + if (rank==MASTER_NODE) cout << "Setting streamwise periodic pressure drop from restart metadata file." << endl; + } + + auto filename_ = config->GetFilename("flow", ".meta", Unst_RestartIter); + Read_SU2_Restart_Metadata(geometry, config, adjoint, filename_); + } + + + /*--- Set the gamma value ---*/ + + Gamma = config->GetGamma(); + Gamma_Minus_One = Gamma - 1.0; + + /*--- Define geometry constants in the solver structure. + * Incompressible flow, primitive variables (P, vx, vy, vz, T, rho, beta, lamMu, EddyMu, Kt_eff, Cp, Cv) ---*/ + + nDim = geometry->GetnDim(); + + /*--- Make sure to align the sizes with the constructor of CIncEulerVariable. ---*/ + nVar = nDim + 2; + nPrimVar = nDim + 10; + /*--- Centered schemes only need gradients for viscous fluxes (T and v, but we need also to include P). ---*/ + nPrimVarGrad = nDim + (centered ? 2 : 4); + + /*--- Initialize nVarGrad for deallocation ---*/ + + nVarGrad = nPrimVarGrad; + + nMarker = config->GetnMarker_All(); + nPoint = geometry->GetnPoint(); + nPointDomain = geometry->GetnPointDomain(); + + /*--- Store the number of vertices on each marker for deallocation later ---*/ + + nVertex.resize(nMarker); + for (iMarker = 0; iMarker < nMarker; iMarker++) + nVertex[iMarker] = geometry->nVertex[iMarker]; + + /*--- Perform the non-dimensionalization for the flow equations using the + specified reference values. ---*/ + + // SetNondimensionalization(config, iMesh); + + /*--- Check if we are executing a verification case. If so, the + VerificationSolution object will be instantiated for a particular + option from the available library of verification solutions. Note + that this is done after SetNondim(), as problem-specific initial + parameters are needed by the solution constructors. ---*/ + + SetVerificationSolution(nDim, nVar, config); + + /*--- Allocate base class members. ---*/ + + Allocate(*config); + + /*--- MPI + OpenMP initialization. ---*/ + + HybridParallelInitialization(*config, *geometry); + + /*--- Jacobians and vector structures for implicit computations ---*/ + + if (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT) { + + if (rank == MASTER_NODE) + cout << "Initialize Jacobian structure (" << description << "). MG level: " << iMesh <<"." << endl; + + Jacobian.Initialize(nPoint, nPointDomain, nVar, nVar, true, geometry, config, ReducerStrategy); + } + else { + if (rank == MASTER_NODE) + cout << "Explicit scheme. No Jacobian structure (" << description << "). MG level: " << iMesh <<"." << endl; + } + + /*--- Read farfield conditions ---*/ + + Density_Inf = config->GetDensity_FreeStreamND(); + Pressure_Inf = config->GetPressure_FreeStreamND(); + Velocity_Inf = config->GetVelocity_FreeStreamND(); + Temperature_Inf = config->GetTemperature_FreeStreamND(); + if (config->GetKind_Species_Model() != SPECIES_MODEL::NONE) scalar_init = config->GetSpecies_Init(); + //GetFluidModel()->SetTDState_T(Temperature_Inf, scalar_init); + //Enthalpy_Inf = GetFluidModel()->GetEnthalpy(); + + /*--- Initialize the secondary values for direct derivative approximations ---*/ + + switch (config->GetDirectDiff()) { + case NO_DERIVATIVE: + /*--- Default ---*/ + break; + case D_DENSITY: + SU2_TYPE::SetDerivative(Density_Inf, 1.0); + break; + case D_PRESSURE: + SU2_TYPE::SetDerivative(Pressure_Inf, 1.0); + break; + case D_TEMPERATURE: + SU2_TYPE::SetDerivative(Temperature_Inf, 1.0); + break; + case D_MACH: case D_AOA: + case D_SIDESLIP: case D_REYNOLDS: + case D_TURB2LAM: case D_DESIGN: + /*--- Already done in postprocessing of config ---*/ + break; + default: + break; + } + + SetReferenceValues(*config); + + /*--- Initialize the solution to the far-field state everywhere. ---*/ + + if (navier_stokes) { + nodes = new CPBIncNSVariable(Pressure_Inf, Velocity_Inf, Enthalpy_Inf, nPoint, nDim, nVar, config); + } else { + nodes = new CPBIncEulerVariable(Pressure_Inf, Velocity_Inf, Enthalpy_Inf, nPoint, nDim, nVar, config); + } + SetBaseClassPointerToNodes(); + + if (iMesh == MESH_0) { + nodes->NonPhysicalEdgeCounter.resize(geometry->GetnEdge()) = 0; + } + + /*--- Initial comms. ---*/ + + CommunicateInitialState(geometry, config); + + /*--- Sizing edge mass flux array ---*/ + if (config->GetBounded_Scalar()) + EdgeMassFluxes.resize(geometry->GetnEdge()) = su2double(0.0); + + /*--- Add the solver name. ---*/ + SolverName = "INC.FLOW"; + + /*--- Finally, check that the static arrays will be large enough (keep this + * check at the bottom to make sure we consider the "final" values). ---*/ + if((nDim > MAXNDIM) || (nPrimVar > MAXNVAR)) + SU2_MPI::Error("Oops! The CPBIncEulerSolver static array sizes are not large enough.", CURRENT_FUNCTION); + +} diff --git a/SU2_CFD/src/solvers/CPBIncNSSolver.cpp b/SU2_CFD/src/solvers/CPBIncNSSolver.cpp new file mode 100644 index 00000000000..91d875acb15 --- /dev/null +++ b/SU2_CFD/src/solvers/CPBIncNSSolver.cpp @@ -0,0 +1,42 @@ +/*! + * \file CPBIncNSSolver.cpp + * \brief Main subroutines for solving pressure based Navier-Stokes incompressible flow. + * \author F. Palacios, T. Economon + * \version 8.5.0 "Harrier" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2026, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#include "../../include/solvers/CPBIncNSSolver.hpp" +#include "../../include/variables/CPBIncNSVariable.hpp" +#include "../../../Common/include/toolboxes/printing_toolbox.hpp" +#include "../../include/solvers/CFVMFlowSolverBase.inl" + +/*--- Explicit instantiation of the parent class of CPBIncEulerSolver, + * to spread the compilation over two cpp files. ---*/ +template class CFVMFlowSolverBase; + + +CPBIncNSSolver::CPBIncNSSolver(CGeometry *geometry, CConfig *config, unsigned short iMesh) : + CPBIncEulerSolver(geometry, config, iMesh, true) { + SU2_ZONE_SCOPED + +} diff --git a/SU2_CFD/src/solvers/CPoissonSolver.cpp b/SU2_CFD/src/solvers/CPoissonSolver.cpp new file mode 100644 index 00000000000..bc076bee896 --- /dev/null +++ b/SU2_CFD/src/solvers/CPoissonSolver.cpp @@ -0,0 +1,41 @@ +/*! + * \file CPoissonSolver.cpp + * \brief Main subroutines for solving the Poisson equation + * \author F. Palacios, T. Economon + * \version 8.5.0 "Harrier" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2026, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#include "../../include/solvers/CPoissonSolver.hpp" +#include +#include "../../../Common/include/toolboxes/geometry_toolbox.hpp" +#include "../../include/solvers/CScalarSolver.inl" + +/*--- Explicit instantiation of the parent class of CPoissonSolver. ---*/ +template class CScalarSolver; + +CPoissonSolver::CPoissonSolver(CGeometry *geometry, CConfig *config, unsigned short iMesh) + : CScalarSolver(geometry, config, false) { + SU2_ZONE_SCOPED + +} + diff --git a/SU2_CFD/src/solvers/CSolverFactory.cpp b/SU2_CFD/src/solvers/CSolverFactory.cpp index a01590c6ab2..7899e5a2911 100644 --- a/SU2_CFD/src/solvers/CSolverFactory.cpp +++ b/SU2_CFD/src/solvers/CSolverFactory.cpp @@ -29,8 +29,11 @@ #include "../../include/solvers/CSolverFactory.hpp" #include "../../include/solvers/CEulerSolver.hpp" #include "../../include/solvers/CIncEulerSolver.hpp" +#include "../../include/solvers/CPBIncEulerSolver.hpp" #include "../../include/solvers/CNSSolver.hpp" #include "../../include/solvers/CIncNSSolver.hpp" +#include "../../include/solvers/CPBIncNSSolver.hpp" +#include "../../include/solvers/CPoissonSolver.hpp" #include "../../include/solvers/CNEMOEulerSolver.hpp" #include "../../include/solvers/CNEMONSSolver.hpp" #include "../../include/solvers/CTurbSASolver.hpp" @@ -69,6 +72,7 @@ CSolver** CSolverFactory::CreateSolverContainer(MAIN_SOLVER kindMainSolver, CCon case MAIN_SOLVER::INC_EULER: solver[FLOW_SOL] = CreateSubSolver(SUB_SOLVER_TYPE::INC_EULER, solver, geometry, config, iMGLevel); solver[RAD_SOL] = CreateSubSolver(SUB_SOLVER_TYPE::RADIATION, solver, geometry, config, iMGLevel); + solver[POISSON_SOL] = CreateSubSolver(SUB_SOLVER_TYPE::POISSON, solver, geometry, config, iMGLevel); break; case MAIN_SOLVER::EULER: solver[FLOW_SOL] = CreateSubSolver(SUB_SOLVER_TYPE::EULER, solver, geometry, config, iMGLevel); @@ -81,6 +85,7 @@ CSolver** CSolverFactory::CreateSolverContainer(MAIN_SOLVER kindMainSolver, CCon solver[HEAT_SOL] = CreateSubSolver(SUB_SOLVER_TYPE::HEAT, solver, geometry, config, iMGLevel); solver[RAD_SOL] = CreateSubSolver(SUB_SOLVER_TYPE::RADIATION, solver, geometry, config, iMGLevel); solver[SPECIES_SOL] = CreateSubSolver(SUB_SOLVER_TYPE::SPECIES, solver, geometry, config, iMGLevel); + solver[POISSON_SOL] = CreateSubSolver(SUB_SOLVER_TYPE::POISSON, solver, geometry, config, iMGLevel); break; case MAIN_SOLVER::NAVIER_STOKES: solver[FLOW_SOL] = CreateSubSolver(SUB_SOLVER_TYPE::NAVIER_STOKES, solver, geometry, config, iMGLevel); @@ -103,6 +108,7 @@ CSolver** CSolverFactory::CreateSolverContainer(MAIN_SOLVER kindMainSolver, CCon solver[TURB_SOL] = CreateSubSolver(SUB_SOLVER_TYPE::TURB, solver, geometry, config, iMGLevel); solver[TRANS_SOL] = CreateSubSolver(SUB_SOLVER_TYPE::TRANSITION, solver, geometry, config, iMGLevel); solver[RAD_SOL] = CreateSubSolver(SUB_SOLVER_TYPE::RADIATION, solver, geometry, config, iMGLevel); + solver[POISSON_SOL] = CreateSubSolver(SUB_SOLVER_TYPE::POISSON, solver, geometry, config, iMGLevel); break; case MAIN_SOLVER::HEAT_EQUATION: solver[HEAT_SOL] = CreateSubSolver(SUB_SOLVER_TYPE::HEAT, solver, geometry, config, iMGLevel); @@ -144,6 +150,7 @@ CSolver** CSolverFactory::CreateSolverContainer(MAIN_SOLVER kindMainSolver, CCon solver[ADJFLOW_SOL] = CreateSubSolver(SUB_SOLVER_TYPE::DISC_ADJ_FLOW, solver, geometry, config, iMGLevel); solver[RAD_SOL] = CreateSubSolver(SUB_SOLVER_TYPE::RADIATION, solver, geometry, config, iMGLevel); solver[ADJRAD_SOL] = CreateSubSolver(SUB_SOLVER_TYPE::DISC_ADJ_RADIATION, solver, geometry, config, iMGLevel); + solver[POISSON_SOL] = CreateSubSolver(SUB_SOLVER_TYPE::POISSON, solver, geometry, config, iMGLevel); break; case MAIN_SOLVER::DISC_ADJ_INC_NAVIER_STOKES: solver[FLOW_SOL] = CreateSubSolver(SUB_SOLVER_TYPE::INC_NAVIER_STOKES, solver, geometry, config, iMGLevel); @@ -154,6 +161,7 @@ CSolver** CSolverFactory::CreateSolverContainer(MAIN_SOLVER kindMainSolver, CCon solver[ADJRAD_SOL] = CreateSubSolver(SUB_SOLVER_TYPE::DISC_ADJ_RADIATION, solver, geometry, config, iMGLevel); solver[SPECIES_SOL] = CreateSubSolver(SUB_SOLVER_TYPE::SPECIES, solver, geometry, config, iMGLevel); solver[ADJSPECIES_SOL] = CreateSubSolver(SUB_SOLVER_TYPE::DISC_ADJ_SPECIES, solver, geometry, config, iMGLevel); + solver[POISSON_SOL] = CreateSubSolver(SUB_SOLVER_TYPE::POISSON, solver, geometry, config, iMGLevel); break; case MAIN_SOLVER::DISC_ADJ_INC_RANS: solver[FLOW_SOL] = CreateSubSolver(SUB_SOLVER_TYPE::INC_NAVIER_STOKES, solver, geometry, config, iMGLevel); @@ -166,6 +174,7 @@ CSolver** CSolverFactory::CreateSolverContainer(MAIN_SOLVER kindMainSolver, CCon solver[ADJTURB_SOL] = CreateSubSolver(SUB_SOLVER_TYPE::DISC_ADJ_TURB, solver, geometry, config, iMGLevel); solver[RAD_SOL] = CreateSubSolver(SUB_SOLVER_TYPE::RADIATION, solver, geometry, config, iMGLevel); solver[ADJRAD_SOL] = CreateSubSolver(SUB_SOLVER_TYPE::DISC_ADJ_RADIATION, solver, geometry, config, iMGLevel); + solver[POISSON_SOL] = CreateSubSolver(SUB_SOLVER_TYPE::POISSON, solver, geometry, config, iMGLevel); break; case MAIN_SOLVER::DISC_ADJ_HEAT: solver[HEAT_SOL] = CreateSubSolver(SUB_SOLVER_TYPE::HEAT, solver, geometry, config, iMGLevel); @@ -331,6 +340,11 @@ CSolver* CSolverFactory::CreateSubSolver(SUB_SOLVER_TYPE kindSolver, CSolver **s } metaData.integrationType = INTEGRATION_TYPE::DEFAULT; break; + case SUB_SOLVER_TYPE::POISSON: + if (config->GetKind_Incomp_System() == ENUM_INCOMP_SYSTEM::PRESSURE_BASED) + genericSolver = new CPoissonSolver(geometry, config, iMGLevel); + metaData.integrationType = INTEGRATION_TYPE::SINGLEGRID; + break; default: SU2_MPI::Error("No proper allocation found for requested sub solver", CURRENT_FUNCTION); break; @@ -491,11 +505,31 @@ CSolver* CSolverFactory::CreateFlowSolver(SUB_SOLVER_TYPE kindFlowSolver, CSolve flowSolver = new CNSSolver(geometry, config, iMGLevel); break; case SUB_SOLVER_TYPE::INC_EULER: - flowSolver = new CIncEulerSolver(geometry, config, iMGLevel); + switch (config->GetKind_Incomp_System()) { + case ENUM_INCOMP_SYSTEM::DENSITY_BASED: + flowSolver = new CIncEulerSolver(geometry, config, iMGLevel); + break; + case ENUM_INCOMP_SYSTEM::PRESSURE_BASED: + flowSolver = new CPBIncEulerSolver(geometry, config, iMGLevel); + break; + default: + SU2_MPI::Error("Flow solver not found due to invalid incompressible method", CURRENT_FUNCTION); + break; + } flowSolver->Preprocessing(geometry, solver, config, iMGLevel, NO_RK_ITER, RUNTIME_FLOW_SYS, false); break; case SUB_SOLVER_TYPE::INC_NAVIER_STOKES: - flowSolver = new CIncNSSolver(geometry, config, iMGLevel); + switch (config->GetKind_Incomp_System()) { + case ENUM_INCOMP_SYSTEM::DENSITY_BASED: + flowSolver = new CIncNSSolver(geometry, config, iMGLevel); + break; + case ENUM_INCOMP_SYSTEM::PRESSURE_BASED: + flowSolver = new CPBIncNSSolver(geometry, config, iMGLevel); + break; + default: + SU2_MPI::Error("Flow solver not found due to invalid incompressible method", CURRENT_FUNCTION); + break; + } break; case SUB_SOLVER_TYPE::NEMO_EULER: flowSolver = new CNEMOEulerSolver(geometry, config, iMGLevel); diff --git a/SU2_CFD/src/variables/CPBIncEulerVariable.cpp b/SU2_CFD/src/variables/CPBIncEulerVariable.cpp new file mode 100644 index 00000000000..e38453ca623 --- /dev/null +++ b/SU2_CFD/src/variables/CPBIncEulerVariable.cpp @@ -0,0 +1,37 @@ +/*! + * \file CPBIncEulerVariable.cpp + * \brief Definition of the variable classes for pressure based incompressible flow. + * \author F. Palacios, T. Economon + * \version 8.5.0 "Harrier" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2026, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#include "../../include/variables/CPBIncEulerVariable.hpp" +#include "../../include/fluid/CFluidModel.hpp" + +CPBIncEulerVariable::CPBIncEulerVariable(su2double pressure, const su2double *velocity, su2double enthalpy, + unsigned long npoint, unsigned long ndim, unsigned long nvar, const CConfig *config) + : CFlowVariable(npoint, ndim, nvar, ndim + 10, + ndim + (config->GetKind_ConvNumScheme_Flow() == SPACE_CENTERED ? 2 : 4), config), + indices(ndim, 0) { + +} diff --git a/SU2_CFD/src/variables/CPBIncNSVariable.cpp b/SU2_CFD/src/variables/CPBIncNSVariable.cpp new file mode 100644 index 00000000000..26c66afbf60 --- /dev/null +++ b/SU2_CFD/src/variables/CPBIncNSVariable.cpp @@ -0,0 +1,38 @@ +/*! + * \file CPBIncNSVariable.cpp + * \brief Definition of the variable classes for incompressible flow. + * \author F. Palacios, T. Economon + * \version 8.5.0 "Harrier" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2026, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#include "../../include/variables/CPBIncNSVariable.hpp" +#include "../../include/fluid/CFluidModel.hpp" + +CPBIncNSVariable::CPBIncNSVariable(su2double pressure, const su2double *velocity, su2double enthalpy, + unsigned long npoint, unsigned long ndim, unsigned long nvar, const CConfig *config) : + CPBIncEulerVariable(pressure, velocity, enthalpy, npoint, ndim, nvar, config), + Energy(config->GetEnergy_Equation()) { + + Vorticity.resize(nPoint, 3); + +} diff --git a/SU2_CFD/src/variables/CPoissonVariable.cpp b/SU2_CFD/src/variables/CPoissonVariable.cpp new file mode 100644 index 00000000000..e69de29bb2d diff --git a/TestCases/incomp_pressure_based/lid_driven_cavity/lid_driven_cavity.cfg b/TestCases/incomp_pressure_based/lid_driven_cavity/lid_driven_cavity.cfg new file mode 100644 index 00000000000..8774c960471 --- /dev/null +++ b/TestCases/incomp_pressure_based/lid_driven_cavity/lid_driven_cavity.cfg @@ -0,0 +1,272 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% % +% SU2 configuration file % +% Case description: Incompressible and laminar lid driven cavity % +% Author: Akshay Koodly % +% Institution: University of Twente % +% File Version 7.0.7 "Blackbird % +% % +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +% ------------- DIRECT, ADJOINT, AND LINEARIZED PROBLEM DEFINITION ------------% +% +% Physical governing equations (EULER, NAVIER_STOKES, +% WAVE_EQUATION, HEAT_EQUATION, FEM_ELASTICITY, +% POISSON_EQUATION) + +SOLVER= INC_NAVIER_STOKES +% +% Incompressible solver (DENSITY_BASED, PRESSURE_BASED) +% DENSITY_BASED is chosen by default +KIND_INCOMP_SYSTEM= PRESSURE_BASED +% +% Gravity force (NO, YES) +GRAVITY_FORCE= NO +% +% Mathematical problem (DIRECT, CONTINUOUS_ADJOINT) +MATH_PROBLEM= DIRECT +% +% Restart solution (NO, YES) +RESTART_SOL= NO + +% ---------------- INCOMPRESSIBLE FLOW CONDITION DEFINITION -------------------% +% +% Density model within the incompressible flow solver. +% Options are CONSTANT (default), BOUSSINESQ, or VARIABLE. If VARIABLE, +% an appropriate fluid model must be selected. +INC_DENSITY_MODEL= CONSTANT +% +% Solve the energy equation in the incompressible flow solver +INC_ENERGY_EQUATION = NO +% +% Initial density for incompressible flows (1.2886 kg/m^3 by default) +INC_DENSITY_INIT= 1.0 +% +% Reference density for incompressible flows (1.0 kg/m^3 by default) +INC_DENSITY_REF= 1.0 +% +% Reference velocity for incompressible flows (1.0 m/s by default) +INC_VELOCITY_REF= 1.0 +% +% Reference temperature for incompressible flows that include the +% energy equation (1.0 K by default) +INC_TEMPERATURE_REF = 1.0 +% Initial velocity for incompressible flows (1.0,0,0 m/s by default) +INC_VELOCITY_INIT= ( 1.0, 0.0, 0.0 ) + +% Non-dimensionalization scheme for incompressible flows. Options are +% INITIAL_VALUES (default), REFERENCE_VALUES, or DIMENSIONAL. +% INC_*_REF values are ignored unless REFERENCE_VALUES is chosen. +%INC_NONDIM= REFERENCE_VALUES +% +% --------------------------- VISCOSITY MODEL ---------------------------------% +% +% Viscosity model (SUTHERLAND, CONSTANT_VISCOSITY). +VISCOSITY_MODEL= CONSTANT_VISCOSITY +% +% Molecular Viscosity thsat would be constant (1.716E-5 by default) +MU_CONSTANT= 2.5E-3 +% +% +% ---------------------- REFERENCE VALUE DEFINITION ---------------------------% +% +% Reference origin for moment computation +REF_ORIGIN_MOMENT_X = 0.25 +REF_ORIGIN_MOMENT_Y = 0.00 +REF_ORIGIN_MOMENT_Z = 0.00 +% +% Reference length for pitching, rolling, and yawing non-dimensional moment +REF_LENGTH= 1.0 +% +% Reference area for force coefficients (0 implies automatic calculation) +REF_AREA= 1.0 + +% ----------------------- BOUNDARY CONDITION DEFINITION -----------------------% +% +% Euler wall boundary marker(s) (NONE = no marker) +MARKER_HEATFLUX= ( Bottom,0.0 , Left, 0.0, Right, 0.0, Top, 0.0) +% +% Incompressible: (inlet marker, NULL, velocity magnitude, flow_direction_x, +% flow_direction_y, flow_direction_z, ... ) where flow_direction is +% a unit vector. +%MARKER_INLET= (Left, 0.0, 1.0, 1.0, 0.0, 0.0 ) +% +%INC_INLET_TYPE= VELOCITY_INLET +% +% Outlet boundary marker(s) (NONE = no marker) +%MARKER_OUTLET= ( Right, 0.0,Top, 0.0, Bottom, 0.0 ) +% +%INC_OUTLET_TYPE= PRESSURE_OUTLET, OPEN, OPEN +% Outlet boundary marker(s) (NONE = no marker) +%MARKER_OUTLET= ( Right, 0.0, Top, 0.0 ) +% +%INC_OUTLET_TYPE= PRESSURE_OUTLET,PRESSURE_OUTLET +% +% Symmetry boundary marker(s) (NONE = no marker) +%MARKER_EULER= ( Bottom) +% +%MARKER_SYM= (Bottom) +% Marker(s) of the surface that is going to be analyzed in detail (massflow, average pressure, distortion, etc) +%MARKER_ANALYZE = ( Left, Right, Top, Bottom ) + +% Method to compute the average value in MARKER_ANALYZE (AREA, MASSFLUX). +%MARKER_ANALYZE_AVERAGE = AREA + +%MARKER_PLOTTING= ( Bottom, Top ) +% +% Marker(s) of the surface where the functional (Cd, Cl, etc.) will be evaluated +MARKER_MONITORING= ( Bottom, Top) + +% ----------------------- DYNAMIC MESH DEFINITION -----------------------------% + +% Type of dynamic mesh (NONE, RIGID_MOTION, DEFORMING, ROTATING_FRAME, +% MOVING_WALL, FLUID_STRUCTURE, AEROELASTIC, EXTERNAL) +SURFACE_MOVEMENT= MOVING_WALL + +MARKER_MOVING= Top +% +% +% Coordinates of the motion origin +SURFACE_MOTION_ORIGIN = 0.0 0.0 0.0 +% +% Angular velocity vector (rad/s) about the motion origin +SURFACE_ROTATION_RATE = 0.0 0.0 0.0 +SURFACE_TRANSLATION_RATE = 1.0 0.0 0.0 + +% ------------- COMMON PARAMETERS TO DEFINE THE NUMERICAL METHOD --------------% +% +% Numerical method for spatial gradients (GREEN_GAUSS, WEIGHTED_LEAST_SQUARES) +%NUM_METHOD_GRAD= GREEN_GAUSS +NUM_METHOD_GRAD= WEIGHTED_LEAST_SQUARES +% +% Courant-Friedrichs-Lewy condition of the finest grid +CFL_NUMBER= 1.0 +% +% Adaptive CFL number (NO, YES) +CFL_ADAPT= NO +% +% Parameters of the adaptive CFL number (factor down, factor up, CFL min value, +% CFL max value ) +CFL_ADAPT_PARAM= ( 1.5, 0.5, 1.0, 100.0 ) +% +% Runge-Kutta alpha coefficients +RK_ALPHA_COEFF= ( 0.66667, 0.66667, 1.000000 ) +% +% Number of total iterations +ITER= 10000 + +% -------------------------- MULTIGRID PARAMETERS -----------------------------% +% +% Multi-Grid Levels (0 = no multi-grid) +MGLEVEL= 0 +% +% Multi-grid cycle (V_CYCLE, W_CYCLE, FULLMG_CYCLE) +MGCYCLE= V_CYCLE +% +% Multi-grid pre-smoothing level +MG_PRE_SMOOTH= ( 1, 2, 3, 3 ) +% +% Multi-grid post-smoothing level +MG_POST_SMOOTH= ( 1, 1, 1, 1 ) +% +% Jacobi implicit smoothing of the correction +MG_CORRECTION_SMOOTH= ( 1, 1, 1, 1 ) +% +% Damping factor for the residual restriction +MG_DAMP_RESTRICTION= 0.85 +% +% Damping factor for the correction prolongation +MG_DAMP_PROLONGATION= 0.85 + +% ------------------------ LINEAR SOLVER DEFINITION ---------------------------% +% +% Linear solver for implicit formulations (BCGSTAB, FGMRES) +LINEAR_SOLVER= FGMRES +% +% Preconditioner of the Krylov linear solver (JACOBI, LINELET, LU_SGS) +LINEAR_SOLVER_PREC= LU_SGS +% +% Minimum error of the linear solver for implicit formulations +LINEAR_SOLVER_ERROR= 1E-6 +% +% Max number of iterations of the linear solver for the implicit formulation +LINEAR_SOLVER_ITER= 20 +% +% Number of iterations for the poisson solver +POISSON_LINEAR_SOLVER_ITER= 50 +% +% Number of iterations for the flow solver +%LINEAR_SOLVER_ITER_FLOW= 25 + +% -------------------- FLOW NUMERICAL METHOD DEFINITION -----------------------% +% +% Convective numerical method (JST, JST_KE, JST_MAT, LAX-FRIEDRICH, CUSP, ROE, AUSM, +% AUSMPLUSUP, AUSMPLUSUP2, AUSMPWPLUS, HLLC, TURKEL_PREC, +% SW, MSW, FDS, SLAU, SLAU2, L2ROE, LMROE, UDS) +CONV_NUM_METHOD_FLOW= UDS +% +% Monotonic Upwind Scheme for Conservation Laws (TVD) in the flow equations. +% Required for 2nd order upwind schemes (NO, YES) +MUSCL_FLOW= YES +% +% Slope limiter (VENKATAKRISHNAN, MINMOD) +SLOPE_LIMITER_FLOW= NONE +% +% Coefficient for the limiter (smooth regions) +VENKAT_LIMITER_COEFF= 0.03 +% +% 2nd and 4th order artificial dissipation coefficients +JST_SENSOR_COEFF= ( 0.5, 0.02 ) +% +% Time discretization (RUNGE-KUTTA_EXPLICIT, EULER_IMPLICIT, EULER_EXPLICIT) +TIME_DISCRE_FLOW= EULER_IMPLICIT + +% -------------------- TURBULENT NUMERICAL METHOD DEFINITION ------------------% +% +% Convective numerical method (SCALAR_UPWIND) +CONV_NUM_METHOD_TURB= SCALAR_UPWIND +% +% Monotonic Upwind Scheme for Conservation Laws (TVD) in the turbulence equations. +% Required for 2nd order upwind schemes (NO, YES) +MUSCL_TURB= NO +% +% Slope limiter (VENKATAKRISHNAN, MINMOD) +SLOPE_LIMITER_TURB= VENKATAKRISHNAN +% +% Time discretization (EULER_IMPLICIT) +TIME_DISCRE_TURB= EULER_IMPLICIT +% --------------------------- CONVERGENCE PARAMETERS --------------------------% +% Convergence criteria (CAUCHY, RESIDUAL) +% +% CONV_CRITERIA= RESIDUAL +% +% Residual reduction (order of magnitude with respect to the initial value) +% RESIDUAL_REDUCTION= 7 +% +% Min value of the residual (log10 of the residual) +CONV_RESIDUAL_MINVAL= -10 +% +% Start Cauchy criteria at iteration number +CONV_STARTITER= 10 +% +% Number of elements to apply the criteria +CONV_CAUCHY_ELEMS= 50 +% +% Epsilon to control the series convergence +CONV_CAUCHY_EPS= 1E-6 +% +% Function to apply the criteria (LIFT, DRAG, SENS_GEOMETRY, SENS_MACH, +% DELTA_LIFT, DELTA_DRAG) +% CAUCHY_FUNC_FLOW= DRAG + +% ------------------------- INPUT/OUTPUT INFORMATION --------------------------% +% +MESH_FILENAME= square_65x65.su2 +MESH_FORMAT= SU2 +SOLUTION_FILENAME= solution_flow +TABULAR_FORMAT= CSV +CONV_FILENAME= history +RESTART_FILENAME= restart_flow +VOLUME_FILENAME= flow +SURFACE_FILENAME= surface_flow +OUTPUT_WRT_FREQ= 50