From 76c1f27c88e53203a4d11c1accf61d80177fd9c8 Mon Sep 17 00:00:00 2001 From: bigfooted Date: Mon, 4 Jul 2022 08:38:58 +0200 Subject: [PATCH 01/48] working commit for incompressible --- SU2_CFD/include/numerics/CNumerics.hpp | 8 ++++++++ .../include/numerics/scalar/scalar_convection.hpp | 4 ++++ SU2_CFD/include/solvers/CScalarSolver.hpp | 5 ++++- SU2_CFD/include/solvers/CScalarSolver.inl | 12 ++++++++++-- SU2_CFD/include/solvers/CSolver.hpp | 11 ++++++++++- SU2_CFD/src/solvers/CIncEulerSolver.cpp | 6 ++++++ SU2_CFD/src/solvers/CIncNSSolver.cpp | 9 +++++++++ SU2_CFD/src/solvers/CSpeciesSolver.cpp | 8 ++++++-- 8 files changed, 57 insertions(+), 6 deletions(-) diff --git a/SU2_CFD/include/numerics/CNumerics.hpp b/SU2_CFD/include/numerics/CNumerics.hpp index 3d2dbd7dde5..af190b46116 100644 --- a/SU2_CFD/include/numerics/CNumerics.hpp +++ b/SU2_CFD/include/numerics/CNumerics.hpp @@ -55,6 +55,7 @@ class CNumerics { su2double Gas_Constant; /*!< \brief Gas constant. */ su2double Prandtl_Lam; /*!< \brief Laminar Prandtl's number. */ su2double Prandtl_Turb; /*!< \brief Turbulent Prandtl's number. */ + su2double MassFlux; /*!< \brief Mass flux across edge. */ su2double *Proj_Flux_Tensor; /*!< \brief Flux tensor projected in a direction. */ su2double **tau; /*!< \brief Viscous stress tensor. */ @@ -1598,6 +1599,13 @@ class CNumerics { * \param[in] SolverSPvals - Struct holding the values. */ virtual void SetStreamwisePeriodicValues(const StreamwisePeriodicValues SolverSPvals) { } + + /*! + * \brief SetMassFlux + * \param[in] val_MassFlux: Mass flux across the edge + */ + inline void SetMassFlux(const su2double val_MassFlux) {MassFlux = val_MassFlux;} + }; /*! diff --git a/SU2_CFD/include/numerics/scalar/scalar_convection.hpp b/SU2_CFD/include/numerics/scalar/scalar_convection.hpp index 99c9314adbf..8894793a65d 100644 --- a/SU2_CFD/include/numerics/scalar/scalar_convection.hpp +++ b/SU2_CFD/include/numerics/scalar/scalar_convection.hpp @@ -133,6 +133,10 @@ class CUpwScalar : public CNumerics { a0 = 0.5 * (q_ij + fabs(q_ij)); a1 = 0.5 * (q_ij - fabs(q_ij)); + cout << "a0 massflux = " << max(0.0,MassFlux) << " " << 0.5 * (q_ij + fabs(q_ij)) << endl; + cout << "a1 massflux = " << min(0.0,MassFlux) << " " << 0.5 * (q_ij - fabs(q_ij)) << endl; + //a0 = max(0.0, MassFlux); + //a1 = min(0.0, MassFlux); FinishResidualCalc(config); diff --git a/SU2_CFD/include/solvers/CScalarSolver.hpp b/SU2_CFD/include/solvers/CScalarSolver.hpp index 6f7b5dee537..a24cae385a6 100644 --- a/SU2_CFD/include/solvers/CScalarSolver.hpp +++ b/SU2_CFD/include/solvers/CScalarSolver.hpp @@ -112,6 +112,9 @@ class CScalarSolver : public CSolver { numerics->SetPrimitive(flowNodes->GetPrimitive(iPoint), flowNodes->GetPrimitive(jPoint)); + su2double EdgeMassFlux = solver_container[FLOW_SOL]->GetEdgeMassFlux(iEdge); + numerics->SetMassFlux(EdgeMassFlux); + /*--- Turbulent variables w/o reconstruction, and its gradients ---*/ numerics->SetScalarVar(nodes->GetSolution(iPoint), nodes->GetSolution(jPoint)); @@ -122,7 +125,7 @@ class CScalarSolver : public CSolver { SolverSpecificNumerics(iPoint, jPoint); /*--- Compute residual, and Jacobians ---*/ - + cout << "computing viscous residual" << endl; auto residual = numerics->ComputeResidual(config); if (ReducerStrategy) { diff --git a/SU2_CFD/include/solvers/CScalarSolver.inl b/SU2_CFD/include/solvers/CScalarSolver.inl index 6aa0ecfbb37..bca79792d98 100644 --- a/SU2_CFD/include/solvers/CScalarSolver.inl +++ b/SU2_CFD/include/solvers/CScalarSolver.inl @@ -119,6 +119,9 @@ template void CScalarSolver::Upwind_Residual(CGeometry* geometry, CSolver** solver_container, CNumerics** numerics_container, CConfig* config, unsigned short iMesh) { + + su2double EdgeMassFlux, Project_Grad_i, Project_Grad_j; + /*--- Define booleans that are solver specific through CConfig's GlobalParams which have to be set in CFluidIteration * before calling these solver functions. ---*/ const bool implicit = (config->GetKind_TimeIntScheme() == EULER_IMPLICIT); @@ -164,7 +167,7 @@ void CScalarSolver::Upwind_Residual(CGeometry* geometry, CSolver** auto jPoint = geometry->edges->GetNode(iEdge, 1); numerics->SetNormal(geometry->edges->GetNormal(iEdge)); - + /*--- Primitive variables w/o reconstruction ---*/ const auto V_i = flowNodes->GetPrimitive(iPoint); @@ -249,10 +252,15 @@ void CScalarSolver::Upwind_Residual(CGeometry* geometry, CSolver** } } - /*--- Update convective residual value ---*/ + /*--- Convective flux ---*/ + EdgeMassFlux = solver_container[FLOW_SOL]->GetEdgeMassFlux(iEdge); + numerics->SetMassFlux(EdgeMassFlux); + cout << "massflux=" <ComputeResidual(config); + if (ReducerStrategy) { EdgeFluxes.SetBlock(iEdge, residual); if (implicit) Jacobian.SetBlocks(iEdge, residual.jacobian_i, residual.jacobian_j); diff --git a/SU2_CFD/include/solvers/CSolver.hpp b/SU2_CFD/include/solvers/CSolver.hpp index 6e0e720101d..8c2e6d49675 100644 --- a/SU2_CFD/include/solvers/CSolver.hpp +++ b/SU2_CFD/include/solvers/CSolver.hpp @@ -127,6 +127,8 @@ class CSolver { **Jacobian_ji, /*!< \brief Auxiliary matrices for storing point to point Jacobians. */ **Jacobian_jj; /*!< \brief Auxiliary matrices for storing point to point Jacobians. */ + su2double *EdgeMassFluxes; /*!< \brief Mass fluxes across each edge, for discretization of passive scalars. */ + /*--- End variables that need to go. ---*/ su2activevector iPoint_UndLapl; /*!< \brief Auxiliary variable for the undivided Laplacians. */ @@ -4311,9 +4313,16 @@ class CSolver { * \param[in] geometry - Geometrical definition of the problem. * \param[in] config - Definition of the particular problem. * \param[in] converged - Whether or not solution has converged. - */ + */ void SavelibROM(CGeometry *geometry, CConfig *config, bool converged); + /*! + * \brief Get the mass flux across an edge (computed and stored during the discretization of convective fluxes). + * \param[in] iEdge - Index of the edge. + * \return The mass flux across the edge. + */ + inline su2double GetEdgeMassFlux(const unsigned long iEdge) const {return EdgeMassFluxes[iEdge];} + protected: /*! * \brief Allocate the memory for the verification solution, if necessary. diff --git a/SU2_CFD/src/solvers/CIncEulerSolver.cpp b/SU2_CFD/src/solvers/CIncEulerSolver.cpp index f25de61df84..aee5e86bc8d 100644 --- a/SU2_CFD/src/solvers/CIncEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CIncEulerSolver.cpp @@ -1316,6 +1316,12 @@ void CIncEulerSolver::Upwind_Residual(CGeometry *geometry, CSolver **solver_cont Viscous_Residual(iEdge, geometry, solver_container, numerics_container[VISC_TERM + omp_get_thread_num()*MAX_TERMS], config); + + //if (rans && (iMesh == MESH_0)) EdgeMassFluxes[iEdge] = Res_Conv[0]; + if (iMesh == MESH_0) { + EdgeMassFluxes[iEdge] = residual[0]; + } + } END_SU2_OMP_FOR } // end color loop diff --git a/SU2_CFD/src/solvers/CIncNSSolver.cpp b/SU2_CFD/src/solvers/CIncNSSolver.cpp index 43c5d160a40..da5d1e58ba8 100644 --- a/SU2_CFD/src/solvers/CIncNSSolver.cpp +++ b/SU2_CFD/src/solvers/CIncNSSolver.cpp @@ -43,6 +43,15 @@ CIncNSSolver::CIncNSSolver(CGeometry *geometry, CConfig *config, unsigned short Viscosity_Inf = config->GetViscosity_FreeStreamND(); Tke_Inf = config->GetTke_FreeStreamND(); + //if (rans && (iMesh == MESH_0)) { + if (iMesh == MESH_0) { + EdgeMassFluxes = new su2double [geometry->GetnEdge()]; + + for(unsigned long iEdge = 0; iEdge < geometry->GetnEdge(); ++iEdge) + EdgeMassFluxes[iEdge] = 0.0; + } + + /*--- Initialize the secondary values for direct derivative approximations ---*/ switch (config->GetDirectDiff()) { diff --git a/SU2_CFD/src/solvers/CSpeciesSolver.cpp b/SU2_CFD/src/solvers/CSpeciesSolver.cpp index ba1a298fb1f..fcafc10891f 100644 --- a/SU2_CFD/src/solvers/CSpeciesSolver.cpp +++ b/SU2_CFD/src/solvers/CSpeciesSolver.cpp @@ -384,9 +384,13 @@ void CSpeciesSolver::BC_Inlet(CGeometry* geometry, CSolver** solver_container, C if (dynamic_grid) conv_numerics->SetGridVel(geometry->nodes->GetGridVel(iPoint), geometry->nodes->GetGridVel(iPoint)); + + //su2double EdgeMassFlux = solver_container[FLOW_SOL]->GetEdgeMassFlux(iEdge); + //conv_numerics->SetMassFlux(EdgeMassFlux); + //cout << "massflux=" <ComputeResidual(config); LinSysRes.AddBlock(iPoint, residual); @@ -531,7 +535,7 @@ void CSpeciesSolver::BC_Outlet(CGeometry* geometry, CSolver** solver_container, conv_numerics->SetGridVel(geometry->nodes->GetGridVel(iPoint), geometry->nodes->GetGridVel(iPoint)); /*--- Compute the residual using an upwind scheme ---*/ - + cout << "computing outlet residual" << endl; auto residual = conv_numerics->ComputeResidual(config); LinSysRes.AddBlock(iPoint, residual); From 182a4b0b48d4938abb7286d006b82292501bc235 Mon Sep 17 00:00:00 2001 From: bigfooted Date: Mon, 4 Jul 2022 08:49:09 +0200 Subject: [PATCH 02/48] adding/removing comments on what still needs to be implemented --- .../include/numerics/scalar/scalar_convection.hpp | 13 ++++++------- SU2_CFD/include/solvers/CScalarSolver.hpp | 1 - SU2_CFD/include/solvers/CScalarSolver.inl | 3 +-- SU2_CFD/src/solvers/CIncEulerSolver.cpp | 1 + SU2_CFD/src/solvers/CIncNSSolver.cpp | 1 + SU2_CFD/src/solvers/CSpeciesSolver.cpp | 10 ++++++---- 6 files changed, 15 insertions(+), 14 deletions(-) diff --git a/SU2_CFD/include/numerics/scalar/scalar_convection.hpp b/SU2_CFD/include/numerics/scalar/scalar_convection.hpp index 8894793a65d..07651a4d41d 100644 --- a/SU2_CFD/include/numerics/scalar/scalar_convection.hpp +++ b/SU2_CFD/include/numerics/scalar/scalar_convection.hpp @@ -118,6 +118,7 @@ class CUpwScalar : public CNumerics { ExtraADPreaccIn(); + /* su2double q_ij = 0.0; if (dynamic_grid) { for (unsigned short iDim = 0; iDim < nDim; iDim++) { @@ -130,13 +131,11 @@ class CUpwScalar : public CNumerics { q_ij += 0.5 * (V_i[iDim + idx.Velocity()] + V_j[iDim + idx.Velocity()]) * Normal[iDim]; } } - - a0 = 0.5 * (q_ij + fabs(q_ij)); - a1 = 0.5 * (q_ij - fabs(q_ij)); - cout << "a0 massflux = " << max(0.0,MassFlux) << " " << 0.5 * (q_ij + fabs(q_ij)) << endl; - cout << "a1 massflux = " << min(0.0,MassFlux) << " " << 0.5 * (q_ij - fabs(q_ij)) << endl; - //a0 = max(0.0, MassFlux); - //a1 = min(0.0, MassFlux); + */ + //a0 = 0.5 * (q_ij + fabs(q_ij)); + //a1 = 0.5 * (q_ij - fabs(q_ij)); + a0 = max(0.0, MassFlux); + a1 = min(0.0, MassFlux); FinishResidualCalc(config); diff --git a/SU2_CFD/include/solvers/CScalarSolver.hpp b/SU2_CFD/include/solvers/CScalarSolver.hpp index a24cae385a6..cc8dd49e591 100644 --- a/SU2_CFD/include/solvers/CScalarSolver.hpp +++ b/SU2_CFD/include/solvers/CScalarSolver.hpp @@ -125,7 +125,6 @@ class CScalarSolver : public CSolver { SolverSpecificNumerics(iPoint, jPoint); /*--- Compute residual, and Jacobians ---*/ - cout << "computing viscous residual" << endl; auto residual = numerics->ComputeResidual(config); if (ReducerStrategy) { diff --git a/SU2_CFD/include/solvers/CScalarSolver.inl b/SU2_CFD/include/solvers/CScalarSolver.inl index bca79792d98..048c9d09a2e 100644 --- a/SU2_CFD/include/solvers/CScalarSolver.inl +++ b/SU2_CFD/include/solvers/CScalarSolver.inl @@ -252,10 +252,9 @@ void CScalarSolver::Upwind_Residual(CGeometry* geometry, CSolver** } } - /*--- Convective flux ---*/ + /*--- Convective flux ---*/ EdgeMassFlux = solver_container[FLOW_SOL]->GetEdgeMassFlux(iEdge); numerics->SetMassFlux(EdgeMassFlux); - cout << "massflux=" <ComputeResidual(config); diff --git a/SU2_CFD/src/solvers/CIncEulerSolver.cpp b/SU2_CFD/src/solvers/CIncEulerSolver.cpp index aee5e86bc8d..2c10f7b7f32 100644 --- a/SU2_CFD/src/solvers/CIncEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CIncEulerSolver.cpp @@ -1318,6 +1318,7 @@ void CIncEulerSolver::Upwind_Residual(CGeometry *geometry, CSolver **solver_cont numerics_container[VISC_TERM + omp_get_thread_num()*MAX_TERMS], config); //if (rans && (iMesh == MESH_0)) EdgeMassFluxes[iEdge] = Res_Conv[0]; + /* only when we solve additional scalars? So turbulence and species? */ if (iMesh == MESH_0) { EdgeMassFluxes[iEdge] = residual[0]; } diff --git a/SU2_CFD/src/solvers/CIncNSSolver.cpp b/SU2_CFD/src/solvers/CIncNSSolver.cpp index da5d1e58ba8..94fed00b45d 100644 --- a/SU2_CFD/src/solvers/CIncNSSolver.cpp +++ b/SU2_CFD/src/solvers/CIncNSSolver.cpp @@ -44,6 +44,7 @@ CIncNSSolver::CIncNSSolver(CGeometry *geometry, CConfig *config, unsigned short Tke_Inf = config->GetTke_FreeStreamND(); //if (rans && (iMesh == MESH_0)) { + // only when we solve additional scalars? if (iMesh == MESH_0) { EdgeMassFluxes = new su2double [geometry->GetnEdge()]; diff --git a/SU2_CFD/src/solvers/CSpeciesSolver.cpp b/SU2_CFD/src/solvers/CSpeciesSolver.cpp index fcafc10891f..97d7290eeec 100644 --- a/SU2_CFD/src/solvers/CSpeciesSolver.cpp +++ b/SU2_CFD/src/solvers/CSpeciesSolver.cpp @@ -384,13 +384,12 @@ void CSpeciesSolver::BC_Inlet(CGeometry* geometry, CSolver** solver_container, C if (dynamic_grid) conv_numerics->SetGridVel(geometry->nodes->GetGridVel(iPoint), geometry->nodes->GetGridVel(iPoint)); - + + /* nijso: TODO we have to compute mass flux here as well */ //su2double EdgeMassFlux = solver_container[FLOW_SOL]->GetEdgeMassFlux(iEdge); //conv_numerics->SetMassFlux(EdgeMassFlux); - //cout << "massflux=" <ComputeResidual(config); LinSysRes.AddBlock(iPoint, residual); @@ -534,8 +533,11 @@ void CSpeciesSolver::BC_Outlet(CGeometry* geometry, CSolver** solver_container, if (dynamic_grid) conv_numerics->SetGridVel(geometry->nodes->GetGridVel(iPoint), geometry->nodes->GetGridVel(iPoint)); + /* nijso: TODO we have to compute mass flux here as well */ + //su2double EdgeMassFlux = solver_container[FLOW_SOL]->GetEdgeMassFlux(iEdge); + //conv_numerics->SetMassFlux(EdgeMassFlux); + /*--- Compute the residual using an upwind scheme ---*/ - cout << "computing outlet residual" << endl; auto residual = conv_numerics->ComputeResidual(config); LinSysRes.AddBlock(iPoint, residual); From 38e396bcb6fa099078d1f96dd6ee31c878024754 Mon Sep 17 00:00:00 2001 From: bigfooted Date: Mon, 4 Jul 2022 09:38:56 +0200 Subject: [PATCH 03/48] small cleanup --- SU2_CFD/include/solvers/CScalarSolver.hpp | 1 + SU2_CFD/include/solvers/CScalarSolver.inl | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/SU2_CFD/include/solvers/CScalarSolver.hpp b/SU2_CFD/include/solvers/CScalarSolver.hpp index cc8dd49e591..8291d6b6522 100644 --- a/SU2_CFD/include/solvers/CScalarSolver.hpp +++ b/SU2_CFD/include/solvers/CScalarSolver.hpp @@ -125,6 +125,7 @@ class CScalarSolver : public CSolver { SolverSpecificNumerics(iPoint, jPoint); /*--- Compute residual, and Jacobians ---*/ + auto residual = numerics->ComputeResidual(config); if (ReducerStrategy) { diff --git a/SU2_CFD/include/solvers/CScalarSolver.inl b/SU2_CFD/include/solvers/CScalarSolver.inl index 048c9d09a2e..e42272bd37d 100644 --- a/SU2_CFD/include/solvers/CScalarSolver.inl +++ b/SU2_CFD/include/solvers/CScalarSolver.inl @@ -259,7 +259,6 @@ void CScalarSolver::Upwind_Residual(CGeometry* geometry, CSolver** /*--- Update convective residual value ---*/ auto residual = numerics->ComputeResidual(config); - if (ReducerStrategy) { EdgeFluxes.SetBlock(iEdge, residual); if (implicit) Jacobian.SetBlocks(iEdge, residual.jacobian_i, residual.jacobian_j); From 2ad9eb667a975438aa14df5b4d8cc144d80debea Mon Sep 17 00:00:00 2001 From: bigfooted Date: Mon, 4 Jul 2022 09:40:08 +0200 Subject: [PATCH 04/48] small cleanup --- SU2_CFD/include/numerics/scalar/scalar_convection.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/SU2_CFD/include/numerics/scalar/scalar_convection.hpp b/SU2_CFD/include/numerics/scalar/scalar_convection.hpp index 07651a4d41d..f021ccfb670 100644 --- a/SU2_CFD/include/numerics/scalar/scalar_convection.hpp +++ b/SU2_CFD/include/numerics/scalar/scalar_convection.hpp @@ -132,6 +132,7 @@ class CUpwScalar : public CNumerics { } } */ + //a0 = 0.5 * (q_ij + fabs(q_ij)); //a1 = 0.5 * (q_ij - fabs(q_ij)); a0 = max(0.0, MassFlux); From 809a6d92706cded4970ff4dec82dcf6514932c2f Mon Sep 17 00:00:00 2001 From: bigfooted Date: Mon, 4 Jul 2022 11:45:24 +0200 Subject: [PATCH 05/48] remove unused variable --- SU2_CFD/include/solvers/CScalarSolver.inl | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/SU2_CFD/include/solvers/CScalarSolver.inl b/SU2_CFD/include/solvers/CScalarSolver.inl index e42272bd37d..9414590c7e7 100644 --- a/SU2_CFD/include/solvers/CScalarSolver.inl +++ b/SU2_CFD/include/solvers/CScalarSolver.inl @@ -120,8 +120,6 @@ void CScalarSolver::Upwind_Residual(CGeometry* geometry, CSolver** CNumerics** numerics_container, CConfig* config, unsigned short iMesh) { - su2double EdgeMassFlux, Project_Grad_i, Project_Grad_j; - /*--- Define booleans that are solver specific through CConfig's GlobalParams which have to be set in CFluidIteration * before calling these solver functions. ---*/ const bool implicit = (config->GetKind_TimeIntScheme() == EULER_IMPLICIT); @@ -253,7 +251,7 @@ void CScalarSolver::Upwind_Residual(CGeometry* geometry, CSolver** } /*--- Convective flux ---*/ - EdgeMassFlux = solver_container[FLOW_SOL]->GetEdgeMassFlux(iEdge); + su2double EdgeMassFlux = solver_container[FLOW_SOL]->GetEdgeMassFlux(iEdge); numerics->SetMassFlux(EdgeMassFlux); /*--- Update convective residual value ---*/ From 52606aef2ce6ad2a40c849edc3a48d333cb2b480 Mon Sep 17 00:00:00 2001 From: Evert Date: Mon, 4 Jul 2022 12:09:50 +0200 Subject: [PATCH 06/48] Added correction factor to scalar convective residual to negate the effects of nonzero flow divergence on the scalar solver residual --- SU2_CFD/include/solvers/CScalarSolver.inl | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/SU2_CFD/include/solvers/CScalarSolver.inl b/SU2_CFD/include/solvers/CScalarSolver.inl index e42272bd37d..4ef3d6656bb 100644 --- a/SU2_CFD/include/solvers/CScalarSolver.inl +++ b/SU2_CFD/include/solvers/CScalarSolver.inl @@ -120,7 +120,7 @@ void CScalarSolver::Upwind_Residual(CGeometry* geometry, CSolver** CNumerics** numerics_container, CConfig* config, unsigned short iMesh) { - su2double EdgeMassFlux, Project_Grad_i, Project_Grad_j; + su2double EdgeMassFlux, Project_Grad_i, Project_Grad_j, FluxCorrection_i, FluxCorrection_j; /*--- Define booleans that are solver specific through CConfig's GlobalParams which have to be set in CFluidIteration * before calling these solver functions. ---*/ @@ -268,6 +268,14 @@ void CScalarSolver::Upwind_Residual(CGeometry* geometry, CSolver** if (implicit) Jacobian.UpdateBlocks(iEdge, iPoint, jPoint, residual.jacobian_i, residual.jacobian_j); } + /*--- Applying convective flux correction to negate the effects of flow divergence ---*/ + for(iVar=0; iVarGetSolution(iPoint, iVar) * EdgeMassFlux; + FluxCorrection_j = GetNodes()->GetSolution(jPoint, iVar) * EdgeMassFlux; + + LinSysRes(iPoint, iVar) -= FluxCorrection_i; + LinSysRes(jPoint, iVar) += FluxCorrection_j; + } /*--- Viscous contribution. ---*/ Viscous_Residual(iEdge, geometry, solver_container, From 6ab207635893cdf5c274664415da2a78d1cac606 Mon Sep 17 00:00:00 2001 From: Evert Date: Mon, 4 Jul 2022 12:42:42 +0200 Subject: [PATCH 07/48] Fixed unused variable warnings --- SU2_CFD/include/solvers/CScalarSolver.inl | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/SU2_CFD/include/solvers/CScalarSolver.inl b/SU2_CFD/include/solvers/CScalarSolver.inl index 56b698a98ff..0ec7a85dde5 100644 --- a/SU2_CFD/include/solvers/CScalarSolver.inl +++ b/SU2_CFD/include/solvers/CScalarSolver.inl @@ -207,7 +207,8 @@ void CScalarSolver::Upwind_Residual(CGeometry* geometry, CSolver** } for (iVar = 0; iVar < solver_container[FLOW_SOL]->GetnPrimVarGrad(); iVar++) { - su2double Project_Grad_i = 0.0, Project_Grad_j = 0.0; + Project_Grad_i = 0.0; + Project_Grad_j = 0.0; for (iDim = 0; iDim < nDim; iDim++) { Project_Grad_i += Vector_ij[iDim] * Gradient_i[iVar][iDim]; Project_Grad_j -= Vector_ij[iDim] * Gradient_j[iVar][iDim]; @@ -253,7 +254,7 @@ void CScalarSolver::Upwind_Residual(CGeometry* geometry, CSolver** } /*--- Convective flux ---*/ - su2double EdgeMassFlux = solver_container[FLOW_SOL]->GetEdgeMassFlux(iEdge); + EdgeMassFlux = solver_container[FLOW_SOL]->GetEdgeMassFlux(iEdge); numerics->SetMassFlux(EdgeMassFlux); /*--- Update convective residual value ---*/ From ffb1a24501304017ad233f1a52ffa6b306cac791 Mon Sep 17 00:00:00 2001 From: Nijso Date: Thu, 7 Jul 2022 21:43:53 +0200 Subject: [PATCH 08/48] Update SU2_CFD/include/solvers/CSolver.hpp Co-authored-by: Pedro Gomes <38071223+pcarruscag@users.noreply.github.com> --- SU2_CFD/include/solvers/CSolver.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SU2_CFD/include/solvers/CSolver.hpp b/SU2_CFD/include/solvers/CSolver.hpp index 8c2e6d49675..e309cfaab4f 100644 --- a/SU2_CFD/include/solvers/CSolver.hpp +++ b/SU2_CFD/include/solvers/CSolver.hpp @@ -127,7 +127,7 @@ class CSolver { **Jacobian_ji, /*!< \brief Auxiliary matrices for storing point to point Jacobians. */ **Jacobian_jj; /*!< \brief Auxiliary matrices for storing point to point Jacobians. */ - su2double *EdgeMassFluxes; /*!< \brief Mass fluxes across each edge, for discretization of passive scalars. */ + su2activevector EdgeMassFluxes; /*!< \brief Mass fluxes across each edge, for discretization of passive scalars. */ /*--- End variables that need to go. ---*/ From f4ddbcf1d0017d9933747cde7508b73d40be1bd9 Mon Sep 17 00:00:00 2001 From: bigfooted Date: Sat, 9 Jul 2022 08:01:39 +0200 Subject: [PATCH 09/48] clean up --- .../numerics/scalar/scalar_convection.hpp | 4 ++-- SU2_CFD/include/solvers/CFVMFlowSolverBase.hpp | 11 +++++++++++ SU2_CFD/include/solvers/CScalarSolver.hpp | 2 +- SU2_CFD/include/solvers/CScalarSolver.inl | 2 ++ SU2_CFD/include/solvers/CSolver.hpp | 16 +++++++--------- SU2_CFD/src/solvers/CIncNSSolver.cpp | 5 +---- 6 files changed, 24 insertions(+), 16 deletions(-) diff --git a/SU2_CFD/include/numerics/scalar/scalar_convection.hpp b/SU2_CFD/include/numerics/scalar/scalar_convection.hpp index f021ccfb670..e6ba47a7aa5 100644 --- a/SU2_CFD/include/numerics/scalar/scalar_convection.hpp +++ b/SU2_CFD/include/numerics/scalar/scalar_convection.hpp @@ -118,7 +118,7 @@ class CUpwScalar : public CNumerics { ExtraADPreaccIn(); - /* + su2double q_ij = 0.0; if (dynamic_grid) { for (unsigned short iDim = 0; iDim < nDim; iDim++) { @@ -131,7 +131,7 @@ class CUpwScalar : public CNumerics { q_ij += 0.5 * (V_i[iDim + idx.Velocity()] + V_j[iDim + idx.Velocity()]) * Normal[iDim]; } } - */ + //a0 = 0.5 * (q_ij + fabs(q_ij)); //a1 = 0.5 * (q_ij - fabs(q_ij)); diff --git a/SU2_CFD/include/solvers/CFVMFlowSolverBase.hpp b/SU2_CFD/include/solvers/CFVMFlowSolverBase.hpp index 25c4bca3787..d585efe9d11 100644 --- a/SU2_CFD/include/solvers/CFVMFlowSolverBase.hpp +++ b/SU2_CFD/include/solvers/CFVMFlowSolverBase.hpp @@ -55,6 +55,9 @@ class CFVMFlowSolverBase : public CSolver { unsigned long omp_chunk_size; /*!< \brief Chunk size used in light point loops. */ + su2activevector EdgeMassFluxes; /*!< \brief Mass fluxes across each edge, for discretization of transported scalars. */ + + /*! * \brief Utility to set the value of a member variables safely, and so that the new values are seen by all threads. * \param[in] lhsRhsPairs - Pairs of destination and source e.g. a,0,b,-1. @@ -2371,4 +2374,12 @@ class CFVMFlowSolverBase : public CSolver { inline su2double GetEddyViscWall(unsigned short val_marker, unsigned long val_vertex) const final { return EddyViscWall[val_marker][val_vertex]; } + + /*! + * \brief Get the mass flux across an edge (computed and stored during the discretization of convective fluxes). + * \param[in] iEdge - Index of the edge. + * \return The mass flux across the edge. + */ + inline su2double GetEdgeMassFlux(const unsigned long iEdge) const {return EdgeMassFluxes[iEdge];} + }; diff --git a/SU2_CFD/include/solvers/CScalarSolver.hpp b/SU2_CFD/include/solvers/CScalarSolver.hpp index 8291d6b6522..01a4e049109 100644 --- a/SU2_CFD/include/solvers/CScalarSolver.hpp +++ b/SU2_CFD/include/solvers/CScalarSolver.hpp @@ -125,7 +125,7 @@ class CScalarSolver : public CSolver { SolverSpecificNumerics(iPoint, jPoint); /*--- Compute residual, and Jacobians ---*/ - + auto residual = numerics->ComputeResidual(config); if (ReducerStrategy) { diff --git a/SU2_CFD/include/solvers/CScalarSolver.inl b/SU2_CFD/include/solvers/CScalarSolver.inl index 0ec7a85dde5..360db4d96c4 100644 --- a/SU2_CFD/include/solvers/CScalarSolver.inl +++ b/SU2_CFD/include/solvers/CScalarSolver.inl @@ -270,6 +270,7 @@ void CScalarSolver::Upwind_Residual(CGeometry* geometry, CSolver** } /*--- Applying convective flux correction to negate the effects of flow divergence ---*/ + for(iVar=0; iVarGetSolution(iPoint, iVar) * EdgeMassFlux; FluxCorrection_j = GetNodes()->GetSolution(jPoint, iVar) * EdgeMassFlux; @@ -277,6 +278,7 @@ void CScalarSolver::Upwind_Residual(CGeometry* geometry, CSolver** LinSysRes(iPoint, iVar) -= FluxCorrection_i; LinSysRes(jPoint, iVar) += FluxCorrection_j; } + /*--- Viscous contribution. ---*/ Viscous_Residual(iEdge, geometry, solver_container, diff --git a/SU2_CFD/include/solvers/CSolver.hpp b/SU2_CFD/include/solvers/CSolver.hpp index e309cfaab4f..4b4847ddb57 100644 --- a/SU2_CFD/include/solvers/CSolver.hpp +++ b/SU2_CFD/include/solvers/CSolver.hpp @@ -127,8 +127,6 @@ class CSolver { **Jacobian_ji, /*!< \brief Auxiliary matrices for storing point to point Jacobians. */ **Jacobian_jj; /*!< \brief Auxiliary matrices for storing point to point Jacobians. */ - su2activevector EdgeMassFluxes; /*!< \brief Mass fluxes across each edge, for discretization of passive scalars. */ - /*--- End variables that need to go. ---*/ su2activevector iPoint_UndLapl; /*!< \brief Auxiliary variable for the undivided Laplacians. */ @@ -3001,6 +2999,13 @@ class CSolver { */ inline virtual su2double GetEddyViscWall(unsigned short val_marker, unsigned long val_vertex) const { return 0; } + /*! + * \brief A virtual member + * \param[in] iEdge - Index of the edge. + * \return The mass flux across the edge. + */ + inline virtual su2double GetEdgeMassFlux(const unsigned long iEdge) const {return 0;} + /*! * \brief A virtual member. * \return Value of the StrainMag_Max @@ -4316,13 +4321,6 @@ class CSolver { */ void SavelibROM(CGeometry *geometry, CConfig *config, bool converged); - /*! - * \brief Get the mass flux across an edge (computed and stored during the discretization of convective fluxes). - * \param[in] iEdge - Index of the edge. - * \return The mass flux across the edge. - */ - inline su2double GetEdgeMassFlux(const unsigned long iEdge) const {return EdgeMassFluxes[iEdge];} - protected: /*! * \brief Allocate the memory for the verification solution, if necessary. diff --git a/SU2_CFD/src/solvers/CIncNSSolver.cpp b/SU2_CFD/src/solvers/CIncNSSolver.cpp index 94fed00b45d..1fd59100256 100644 --- a/SU2_CFD/src/solvers/CIncNSSolver.cpp +++ b/SU2_CFD/src/solvers/CIncNSSolver.cpp @@ -46,10 +46,7 @@ CIncNSSolver::CIncNSSolver(CGeometry *geometry, CConfig *config, unsigned short //if (rans && (iMesh == MESH_0)) { // only when we solve additional scalars? if (iMesh == MESH_0) { - EdgeMassFluxes = new su2double [geometry->GetnEdge()]; - - for(unsigned long iEdge = 0; iEdge < geometry->GetnEdge(); ++iEdge) - EdgeMassFluxes[iEdge] = 0.0; + EdgeMassFluxes.resize(geometry->GetnEdge()) = su2double(0.0); } From c929e65e8fab359ffabea1c5ae56f85eeb358e50 Mon Sep 17 00:00:00 2001 From: Evert Date: Thu, 28 Jul 2022 11:26:14 +0200 Subject: [PATCH 10/48] Added SCALAR_ADVECTION option for the scalar convective numerical method which enables the correction terms to negate the effects of flow divergence on the scalar solution --- Common/include/option_structure.hpp | 4 +- .../numerics/species/species_convection.hpp | 2 +- SU2_CFD/include/solvers/CScalarSolver.inl | 40 +++++++++++++++---- .../DAspecies3_primitiveVenturi.cfg | 4 +- config_template.cfg | 4 +- 5 files changed, 41 insertions(+), 13 deletions(-) diff --git a/Common/include/option_structure.hpp b/Common/include/option_structure.hpp index 21dbf108bf2..7b9e9062774 100644 --- a/Common/include/option_structure.hpp +++ b/Common/include/option_structure.hpp @@ -826,7 +826,8 @@ enum ENUM_UPWIND { LAX_FRIEDRICH = 15, /*!< \brief Lax-Friedrich numerical method. */ AUSMPLUSUP = 16, /*!< \brief AUSM+ -up numerical method (All Speed) */ AUSMPLUSUP2 = 17, /*!< \brief AUSM+ -up2 numerical method (All Speed) */ - AUSMPWPLUS = 18 /*!< \brief AUSMplus numerical method. (MAYBE for TNE2 ONLY)*/ + AUSMPWPLUS = 18, /*!< \brief AUSMplus numerical method. (MAYBE for TNE2 ONLY)*/ + SCALAR_ADVECTION = 19 }; static const MapType Upwind_Map = { MakePair("NONE", NO_UPWIND) @@ -842,6 +843,7 @@ static const MapType Upwind_Map = { MakePair("MSW", MSW) MakePair("CUSP", CUSP) MakePair("SCALAR_UPWIND", SCALAR_UPWIND) + MakePair("SCALAR_ADVECTION", SCALAR_ADVECTION) MakePair("CONVECTIVE_TEMPLATE", CONVECTIVE_TEMPLATE) MakePair("L2ROE", L2ROE) MakePair("LMROE", LMROE) diff --git a/SU2_CFD/include/numerics/species/species_convection.hpp b/SU2_CFD/include/numerics/species/species_convection.hpp index 506dd163963..1e23d097881 100644 --- a/SU2_CFD/include/numerics/species/species_convection.hpp +++ b/SU2_CFD/include/numerics/species/species_convection.hpp @@ -66,7 +66,7 @@ class CUpwSca_Species final : public CUpwScalar { */ void FinishResidualCalc(const CConfig* config) override { for (auto iVar = 0u; iVar < nVar; iVar++) { - Flux[iVar] = a0 * V_i[idx.Density()] * ScalarVar_i[iVar] + a1 * V_j[idx.Density()] * ScalarVar_j[iVar]; + Flux[iVar] = a0 * ScalarVar_i[iVar] + a1 * ScalarVar_j[iVar]; /*--- Jacobians are taken wrt rho*Y not Y alone in the species solver. ---*/ /*--- Off-diagonal entries are zero. ---*/ diff --git a/SU2_CFD/include/solvers/CScalarSolver.inl b/SU2_CFD/include/solvers/CScalarSolver.inl index 0ec7a85dde5..bbc3224dfa4 100644 --- a/SU2_CFD/include/solvers/CScalarSolver.inl +++ b/SU2_CFD/include/solvers/CScalarSolver.inl @@ -122,6 +122,17 @@ void CScalarSolver::Upwind_Residual(CGeometry* geometry, CSolver** su2double EdgeMassFlux, Project_Grad_i, Project_Grad_j, FluxCorrection_i, FluxCorrection_j; + su2double **Jacobian_i_correction, **Jacobian_j_correction; + Jacobian_i_correction = new su2double*[nVar]; + Jacobian_j_correction = new su2double*[nVar]; + for (unsigned short iVar=0; iVarGetKind_TimeIntScheme() == EULER_IMPLICIT); @@ -152,6 +163,10 @@ void CScalarSolver::Upwind_Residual(CGeometry* geometry, CSolver** else AD::StartNoSharedReading(); + bool advection{false}; + + if(config->GetKind_Upwind_Species() == SCALAR_ADVECTION) advection = true; + /*--- Loop over edge colors. ---*/ for (auto color : EdgeColoring) { /*--- Chunk size is at least OMP_MIN_SIZE and a multiple of the color group size. ---*/ @@ -270,13 +285,17 @@ void CScalarSolver::Upwind_Residual(CGeometry* geometry, CSolver** } /*--- Applying convective flux correction to negate the effects of flow divergence ---*/ - for(iVar=0; iVarGetSolution(iPoint, iVar) * EdgeMassFlux; - FluxCorrection_j = GetNodes()->GetSolution(jPoint, iVar) * EdgeMassFlux; - - LinSysRes(iPoint, iVar) -= FluxCorrection_i; - LinSysRes(jPoint, iVar) += FluxCorrection_j; - } + if(advection){ + for(iVar=0; iVarGetSolution(iPoint, iVar) * EdgeMassFlux; + FluxCorrection_j = GetNodes()->GetSolution(jPoint, iVar) * EdgeMassFlux; + + LinSysRes(iPoint, iVar) -= FluxCorrection_i; + LinSysRes(jPoint, iVar) += FluxCorrection_j; + Jacobian_i_correction[iVar][iVar] = max(0.0, EdgeMassFlux);; + Jacobian_j_correction[iVar][iVar] = min(0.0, EdgeMassFlux); + } + }if (implicit) Jacobian.UpdateBlocks(iEdge, iPoint, jPoint, Jacobian_i_correction, Jacobian_j_correction); /*--- Viscous contribution. ---*/ Viscous_Residual(iEdge, geometry, solver_container, @@ -293,6 +312,13 @@ void CScalarSolver::Upwind_Residual(CGeometry* geometry, CSolver** SumEdgeFluxes(geometry); if (implicit) Jacobian.SetDiagonalAsColumnSum(); } + + for(unsigned short iVar=0; iVar diff --git a/TestCases/species_transport/venturi_primitive_3species/DAspecies3_primitiveVenturi.cfg b/TestCases/species_transport/venturi_primitive_3species/DAspecies3_primitiveVenturi.cfg index c1d04b899ca..f8ac3590903 100644 --- a/TestCases/species_transport/venturi_primitive_3species/DAspecies3_primitiveVenturi.cfg +++ b/TestCases/species_transport/venturi_primitive_3species/DAspecies3_primitiveVenturi.cfg @@ -53,7 +53,7 @@ INLET_FILENAME= inlet_venturi.dat INC_INLET_TYPE= VELOCITY_INLET VELOCITY_INLET MARKER_INLET= ( gas_inlet, 300, 1.0, 1.0, 0.0, 0.0,\ air_axial_inlet, 300, 1.0, 0.0, -1.0, 0.0 ) -SPECIES_USE_STRONG_BC= NO +SPECIES_USE_STRONG_BC= YES MARKER_INLET_SPECIES= (gas_inlet, 0.5, 0.5,\ air_axial_inlet, 0.6, 0.0 ) % @@ -128,7 +128,7 @@ CONV_FILENAME= history MARKER_ANALYZE= outlet MARKER_ANALYZE_AVERAGE= MASSFLUX % -OUTPUT_FILES= RESTART_ASCII, PARAVIEW_MULTIBLOCK +OUTPUT_FILES= RESTART_ASCII, PARAVIEW VOLUME_OUTPUT= RESIDUAL, PRIMITIVE OUTPUT_WRT_FREQ= 1000 % diff --git a/config_template.cfg b/config_template.cfg index 5609f60dccb..a0aa1864eae 100644 --- a/config_template.cfg +++ b/config_template.cfg @@ -715,7 +715,7 @@ MARKER_INLET_SPECIES= (inlet, 0.5, ..., inlet2, 0.6, ...) % Use strong inlet and outlet BC in the species solver SPECIES_USE_STRONG_BC= NO % -% Convective numerical method for species transport (SCALAR_UPWIND) +% Convective numerical method for species transport (SCALAR_UPWIND, SCALAR_ADVECTION) CONV_NUM_METHOD_SPECIES= SCALAR_UPWIND % % Monotonic Upwind Scheme for Conservation Laws (TVD) in the species equations. @@ -1272,7 +1272,7 @@ KIND_MATRIX_COLORING= GREEDY_COLORING % -------------------- TURBULENT NUMERICAL METHOD DEFINITION ------------------% % -% Convective numerical method (SCALAR_UPWIND) +% Convective numerical method (SCALAR_UPWIND, SCALAR_ADVECTION) CONV_NUM_METHOD_TURB= SCALAR_UPWIND % % Time discretization (EULER_IMPLICIT, EULER_EXPLICIT) From caa9a6faee3ab196445aa66189b8021c120b36eb Mon Sep 17 00:00:00 2001 From: Evert Date: Wed, 24 Aug 2022 14:53:04 +0200 Subject: [PATCH 11/48] Changed the upwind and centered convective enums to enum class --- Common/include/CConfig.hpp | 62 +++++----- Common/include/option_structure.hpp | 112 +++++++++--------- Common/include/option_structure.inl | 14 +-- Common/src/CConfig.cpp | 68 +++++------ .../include/numerics_simd/CNumericsSIMD.cpp | 14 +-- SU2_CFD/include/solvers/CScalarSolver.inl | 2 +- SU2_CFD/src/drivers/CDriver.cpp | 66 +++++------ SU2_CFD/src/solvers/CAdjEulerSolver.cpp | 4 +- SU2_CFD/src/solvers/CAdjNSSolver.cpp | 2 +- SU2_CFD/src/solvers/CEulerSolver.cpp | 16 +-- SU2_CFD/src/solvers/CFEM_DG_EulerSolver.cpp | 4 +- SU2_CFD/src/solvers/CIncEulerSolver.cpp | 4 +- SU2_CFD/src/solvers/CNEMOEulerSolver.cpp | 6 +- 13 files changed, 190 insertions(+), 184 deletions(-) diff --git a/Common/include/CConfig.hpp b/Common/include/CConfig.hpp index f3115f09f99..79c31e5384f 100644 --- a/Common/include/CConfig.hpp +++ b/Common/include/CConfig.hpp @@ -530,28 +530,34 @@ class CConfig { Kind_ConvNumScheme_AdjTurb, /*!< \brief Centered or upwind scheme for the adjoint turbulence model. */ Kind_ConvNumScheme_Species, /*!< \brief Centered or upwind scheme for the species model. */ Kind_ConvNumScheme_Template, /*!< \brief Centered or upwind scheme for the level set equation. */ + Kind_FEM, /*!< \brief Finite element scheme for the flow equations. */ + Kind_FEM_Flow, /*!< \brief Finite element scheme for the flow equations. */ + Kind_Matrix_Coloring; /*!< \brief Type of matrix coloring for sparse Jacobian computation. */ + + CENTERED Kind_Centered, /*!< \brief Centered scheme. */ Kind_Centered_Flow, /*!< \brief Centered scheme for the flow equations. */ Kind_Centered_AdjFlow, /*!< \brief Centered scheme for the adjoint flow equations. */ Kind_Centered_Turb, /*!< \brief Centered scheme for the turbulence model. */ Kind_Centered_AdjTurb, /*!< \brief Centered scheme for the adjoint turbulence model. */ Kind_Centered_Species, /*!< \brief Centered scheme for the species model. */ - Kind_Centered_Template, /*!< \brief Centered scheme for the template model. */ + Kind_Centered_Template; /*!< \brief Centered scheme for the template model. */ + + + FEM_SHOCK_CAPTURING_DG Kind_FEM_Shock_Capturing_DG; /*!< \brief Shock capturing method for the FEM DG solver. */ + BGS_RELAXATION Kind_BGS_RelaxMethod; /*!< \brief Kind of relaxation method for Block Gauss Seidel method in FSI problems. */ + bool ReconstructionGradientRequired; /*!< \brief Enable or disable a second gradient calculation for upwind reconstruction only. */ + bool LeastSquaresRequired; /*!< \brief Enable or disable memory allocation for least-squares gradient methods. */ + bool Energy_Equation; /*!< \brief Solve the energy equation for incompressible flows. */ + + UPWIND Kind_Upwind, /*!< \brief Upwind scheme. */ Kind_Upwind_Flow, /*!< \brief Upwind scheme for the flow equations. */ Kind_Upwind_AdjFlow, /*!< \brief Upwind scheme for the adjoint flow equations. */ Kind_Upwind_Turb, /*!< \brief Upwind scheme for the turbulence model. */ Kind_Upwind_AdjTurb, /*!< \brief Upwind scheme for the adjoint turbulence model. */ Kind_Upwind_Species, /*!< \brief Upwind scheme for the species model. */ - Kind_Upwind_Template, /*!< \brief Upwind scheme for the template model. */ - Kind_FEM, /*!< \brief Finite element scheme for the flow equations. */ - Kind_FEM_Flow, /*!< \brief Finite element scheme for the flow equations. */ - Kind_Matrix_Coloring; /*!< \brief Type of matrix coloring for sparse Jacobian computation. */ - FEM_SHOCK_CAPTURING_DG Kind_FEM_Shock_Capturing_DG; /*!< \brief Shock capturing method for the FEM DG solver. */ - BGS_RELAXATION Kind_BGS_RelaxMethod; /*!< \brief Kind of relaxation method for Block Gauss Seidel method in FSI problems. */ - bool ReconstructionGradientRequired; /*!< \brief Enable or disable a second gradient calculation for upwind reconstruction only. */ - bool LeastSquaresRequired; /*!< \brief Enable or disable memory allocation for least-squares gradient methods. */ - bool Energy_Equation; /*!< \brief Solve the energy equation for incompressible flows. */ + Kind_Upwind_Template; /*!< \brief Upwind scheme for the template model. */ bool MUSCL, /*!< \brief MUSCL scheme .*/ MUSCL_Flow, /*!< \brief MUSCL scheme for the flow equations.*/ @@ -1099,7 +1105,7 @@ class CConfig { hs_axes[3], /*!< \brief principal axes (x, y, z) of the ellipsoid containing the heat source. */ hs_center[3]; /*!< \brief position of the center of the heat source. */ - unsigned short Riemann_Solver_FEM; /*!< \brief Riemann solver chosen for the DG method. */ + UPWIND Riemann_Solver_FEM; /*!< \brief Riemann solver chosen for the DG method. */ su2double Quadrature_Factor_Straight; /*!< \brief Factor applied during quadrature of elements with a constant Jacobian. */ su2double Quadrature_Factor_Curved; /*!< \brief Factor applied during quadrature of elements with a non-constant Jacobian. */ su2double Quadrature_Factor_Time_ADER_DG; /*!< \brief Factor applied during quadrature in time for ADER-DG. */ @@ -1266,7 +1272,7 @@ class CConfig { void addStringListOption(const string name, unsigned short & num_marker, string* & option_field); - void addConvectOption(const string name, unsigned short & space_field, unsigned short & centered_field, unsigned short & upwind_field); + void addConvectOption(const string name, unsigned short & space_field, CENTERED & centered_field, UPWIND & upwind_field); void addConvectFEMOption(const string name, unsigned short & space_field, unsigned short & fem_field); @@ -2298,8 +2304,8 @@ class CConfig { * \param[in] val_muscl - Define if we apply a MUSCL scheme or not. * \param[in] val_kind_fem - If FEM, what kind of FEM discretization. */ - void SetKind_ConvNumScheme(unsigned short val_kind_convnumscheme, unsigned short val_kind_centered, - unsigned short val_kind_upwind, LIMITER val_kind_slopelimit, + void SetKind_ConvNumScheme(unsigned short val_kind_convnumscheme, CENTERED val_kind_centered, + UPWIND val_kind_upwind, LIMITER val_kind_slopelimit, bool val_muscl, unsigned short val_kind_fem); /*! @@ -3704,7 +3710,7 @@ class CConfig { */ bool GetAUSMMethod(void) const { switch (Kind_Upwind_Flow) { - case AUSM : case AUSMPLUSUP: case AUSMPLUSUP2: case AUSMPWPLUS: + case UPWIND::AUSM : case UPWIND::AUSMPLUSUP: case UPWIND::AUSMPLUSUP2: case UPWIND::AUSMPWPLUS: return true; default: return false; @@ -4347,7 +4353,7 @@ class CConfig { * linearized) that is being solved. * \return Kind of center scheme for the convective terms. */ - unsigned short GetKind_Centered(void) const { return Kind_Centered; } + CENTERED GetKind_Centered(void) const { return Kind_Centered; } /*! * \brief Get kind of upwind scheme for the convective terms. @@ -4356,7 +4362,7 @@ class CConfig { * linearized) that is being solved. * \return Kind of upwind scheme for the convective terms. */ - unsigned short GetKind_Upwind(void) const { return Kind_Upwind; } + UPWIND GetKind_Upwind(void) const { return Kind_Upwind; } /*! * \brief Get if the upwind scheme used MUSCL or not. @@ -4527,7 +4533,7 @@ class CConfig { * during the computation. * \return Kind of center convective numerical scheme for the flow equations. */ - ENUM_CENTERED GetKind_Centered_Flow(void) const { return static_cast(Kind_Centered_Flow); } + CENTERED GetKind_Centered_Flow(void) const { return static_cast(Kind_Centered_Flow); } /*! * \brief Get the kind of center convective numerical scheme for the plasma equations. @@ -4543,7 +4549,7 @@ class CConfig { * during the computation. * \return Kind of upwind convective numerical scheme for the flow equations. */ - unsigned short GetKind_Upwind_Flow(void) const { return Kind_Upwind_Flow; } + UPWIND GetKind_Upwind_Flow(void) const { return Kind_Upwind_Flow; } /*! * \brief Get the kind of finite element convective numerical scheme for the flow equations. @@ -4672,7 +4678,7 @@ class CConfig { * during the computation. * \return Kind of center convective numerical scheme for the adjoint flow equations. */ - unsigned short GetKind_Centered_AdjFlow(void) const { return Kind_Centered_AdjFlow; } + CENTERED GetKind_Centered_AdjFlow(void) const { return Kind_Centered_AdjFlow; } /*! * \brief Get the kind of upwind convective numerical scheme for the adjoint flow equations. @@ -4680,7 +4686,7 @@ class CConfig { * during the computation. * \return Kind of upwind convective numerical scheme for the adjoint flow equations. */ - unsigned short GetKind_Upwind_AdjFlow(void) const { return Kind_Upwind_AdjFlow; } + UPWIND GetKind_Upwind_AdjFlow(void) const { return Kind_Upwind_AdjFlow; } /*! * \brief Value of the calibrated constant for the high order method (center scheme). @@ -4724,7 +4730,7 @@ class CConfig { * during the computation. * \return Kind of center convective numerical scheme for the turbulence equations. */ - unsigned short GetKind_Centered_Turb(void) const { return Kind_Centered_Turb; } + CENTERED GetKind_Centered_Turb(void) const { return Kind_Centered_Turb; } /*! * \brief Get the kind of upwind convective numerical scheme for the turbulence equations. @@ -4732,7 +4738,7 @@ class CConfig { * during the computation. * \return Kind of upwind convective numerical scheme for the turbulence equations. */ - unsigned short GetKind_Upwind_Turb(void) const { return Kind_Upwind_Turb; } + UPWIND GetKind_Upwind_Turb(void) const { return Kind_Upwind_Turb; } /*! * \brief Get the kind of integration scheme (explicit or implicit) @@ -4776,7 +4782,7 @@ class CConfig { * during the computation. * \return Kind of center convective numerical scheme for the Species equations. */ - unsigned short GetKind_Centered_Species() const { return Kind_Centered_Species; } + CENTERED GetKind_Centered_Species() const { return Kind_Centered_Species; } /*! * \brief Get the kind of upwind convective numerical scheme for the Species equations. @@ -4784,7 +4790,7 @@ class CConfig { * during the computation. * \return Kind of upwind convective numerical scheme for the Species equations. */ - unsigned short GetKind_Upwind_Species() const { return Kind_Upwind_Species; } + UPWIND GetKind_Upwind_Species() const { return Kind_Upwind_Species; } /*! * \brief Get the kind of convective numerical scheme for the heat equation. @@ -4800,7 +4806,7 @@ class CConfig { * during the computation. * \return Kind of center convective numerical scheme for the adjoint turbulence equations. */ - unsigned short GetKind_Centered_AdjTurb(void) const { return Kind_Centered_AdjTurb; } + CENTERED GetKind_Centered_AdjTurb(void) const { return Kind_Centered_AdjTurb; } /*! * \brief Get the kind of upwind convective numerical scheme for the adjoint turbulence equations. @@ -4808,7 +4814,7 @@ class CConfig { * during the computation. * \return Kind of upwind convective numerical scheme for the adjoint turbulence equations. */ - unsigned short GetKind_Upwind_AdjTurb(void) const { return Kind_Upwind_AdjTurb; } + UPWIND GetKind_Upwind_AdjTurb(void) const { return Kind_Upwind_AdjTurb; } /*! * \brief Provides information about the way in which the turbulence will be treated by the @@ -8886,7 +8892,7 @@ class CConfig { * \note This value is obtained from the config file, and it is constant during the computation. * \return Kind of Riemann solver for the DG method (FEM flow solver). */ - unsigned short GetRiemann_Solver_FEM(void) const { return Riemann_Solver_FEM; } + UPWIND GetRiemann_Solver_FEM(void) const { return Riemann_Solver_FEM; } /*! * \brief Get the factor applied during quadrature of straight elements. diff --git a/Common/include/option_structure.hpp b/Common/include/option_structure.hpp index 321fb6139a2..d93670d2ce2 100644 --- a/Common/include/option_structure.hpp +++ b/Common/include/option_structure.hpp @@ -789,69 +789,69 @@ static const MapType Gust_Dir_Map = { /*! * \brief Types of centered spatial discretizations */ -enum ENUM_CENTERED { - NO_CENTERED = 0, /*!< \brief No centered scheme is used. */ - JST = 1, /*!< \brief Jameson-Smith-Turkel centered numerical method. */ - LAX = 2, /*!< \brief Lax-Friedrich centered numerical method. */ - JST_MAT = 3, /*!< \brief JST with matrix dissipation. */ - JST_KE = 4 /*!< \brief Kinetic Energy preserving Jameson-Smith-Turkel centered numerical method. */ +enum class CENTERED { + NO_CENTERED, /*!< \brief No centered scheme is used. */ + JST, /*!< \brief Jameson-Smith-Turkel centered numerical method. */ + 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. */ }; -static const MapType Centered_Map = { - MakePair("NONE", NO_CENTERED) - MakePair("JST", JST) - MakePair("JST_KE", JST_KE) - MakePair("JST_MAT", JST_MAT) - MakePair("LAX-FRIEDRICH", LAX) +static const MapType Centered_Map = { + MakePair("NONE", CENTERED::NO_CENTERED) + MakePair("JST", CENTERED::JST) + MakePair("JST_KE", CENTERED::JST_KE) + MakePair("JST_MAT", CENTERED::JST_MAT) + MakePair("LAX-FRIEDRICH", CENTERED::LAX) }; -// If you add to ENUM_UPWIND, you must also add the option to ENUM_CONVECTIVE +// If you add to UPWIND, you must also add the option to ENUM_CONVECTIVE /*! * \brief Types of upwind spatial discretizations */ -enum ENUM_UPWIND { - NO_UPWIND = 0, /*!< \brief No upwind scheme is used. */ - ROE = 1, /*!< \brief Roe's upwind numerical method. */ - SCALAR_UPWIND = 2, /*!< \brief Scalar upwind numerical method. */ - AUSM = 3, /*!< \brief AUSM numerical method. */ - HLLC = 4, /*!< \brief HLLC numerical method. */ - SW = 5, /*!< \brief Steger-Warming method. */ - MSW = 6, /*!< \brief Modified Steger-Warming method. */ - TURKEL = 7, /*!< \brief Roe-Turkel's upwind numerical method. */ - SLAU = 8, /*!< \brief Simple Low-Dissipation AUSM numerical method. */ - CUSP = 9, /*!< \brief Convective upwind and split pressure numerical method. */ - CONVECTIVE_TEMPLATE = 10, /*!< \brief Template for new numerical method . */ - L2ROE = 11, /*!< \brief L2ROE numerical method . */ - LMROE = 12, /*!< \brief Rieper's Low Mach ROE numerical method . */ - SLAU2 = 13, /*!< \brief Simple Low-Dissipation AUSM 2 numerical method. */ - FDS = 14, /*!< \brief Flux difference splitting upwind method (incompressible flows). */ - LAX_FRIEDRICH = 15, /*!< \brief Lax-Friedrich numerical method. */ - AUSMPLUSUP = 16, /*!< \brief AUSM+ -up numerical method (All Speed) */ - AUSMPLUSUP2 = 17, /*!< \brief AUSM+ -up2 numerical method (All Speed) */ - AUSMPWPLUS = 18, /*!< \brief AUSMplus numerical method. (MAYBE for TNE2 ONLY)*/ - SCALAR_ADVECTION = 19 -}; -static const MapType Upwind_Map = { - MakePair("NONE", NO_UPWIND) - MakePair("ROE", ROE) - MakePair("TURKEL_PREC", TURKEL) - MakePair("AUSM", AUSM) - MakePair("AUSMPLUSUP", AUSMPLUSUP) - MakePair("AUSMPLUSUP2", AUSMPLUSUP2) - MakePair("AUSMPWPLUS", AUSMPWPLUS) - MakePair("SLAU", SLAU) - MakePair("HLLC", HLLC) - MakePair("SW", SW) - MakePair("MSW", MSW) - MakePair("CUSP", CUSP) - MakePair("SCALAR_UPWIND", SCALAR_UPWIND) - MakePair("SCALAR_ADVECTION", SCALAR_ADVECTION) - MakePair("CONVECTIVE_TEMPLATE", CONVECTIVE_TEMPLATE) - MakePair("L2ROE", L2ROE) - MakePair("LMROE", LMROE) - MakePair("SLAU2", SLAU2) - MakePair("FDS", FDS) - MakePair("LAX-FRIEDRICH", LAX_FRIEDRICH) +enum class UPWIND { + NO_UPWIND, /*!< \brief No upwind scheme is used. */ + ROE, /*!< \brief Roe's upwind numerical method. */ + SCALAR_UPWIND, /*!< \brief Scalar upwind numerical method. */ + AUSM, /*!< \brief AUSM numerical method. */ + HLLC, /*!< \brief HLLC numerical method. */ + SW, /*!< \brief Steger-Warming method. */ + MSW, /*!< \brief Modified Steger-Warming method. */ + TURKEL, /*!< \brief Roe-Turkel's upwind numerical method. */ + SLAU, /*!< \brief Simple Low-Dissipation AUSM numerical method. */ + CUSP, /*!< \brief Convective upwind and split pressure numerical method. */ + CONVECTIVE_TEMPLATE, /*!< \brief Template for new numerical method . */ + L2ROE, /*!< \brief L2ROE numerical method . */ + LMROE, /*!< \brief Rieper's Low Mach ROE numerical method . */ + SLAU2, /*!< \brief Simple Low-Dissipation AUSM 2 numerical method. */ + FDS, /*!< \brief Flux difference splitting upwind method (incompressible flows). */ + LAX_FRIEDRICH, /*!< \brief Lax-Friedrich numerical method. */ + AUSMPLUSUP, /*!< \brief AUSM+ -up numerical method (All Speed) */ + AUSMPLUSUP2, /*!< \brief AUSM+ -up2 numerical method (All Speed) */ + AUSMPWPLUS, /*!< \brief AUSMplus numerical method. (MAYBE for TNE2 ONLY)*/ + SCALAR_ADVECTION /*!< \brief Scalar advection numerical method. */ +}; +static const MapType Upwind_Map = { + MakePair("NONE", UPWIND::NO_UPWIND) + MakePair("ROE", UPWIND::ROE) + MakePair("TURKEL_PREC", UPWIND::TURKEL) + MakePair("AUSM", UPWIND::AUSM) + MakePair("AUSMPLUSUP", UPWIND::AUSMPLUSUP) + MakePair("AUSMPLUSUP2", UPWIND::AUSMPLUSUP2) + MakePair("AUSMPWPLUS", UPWIND::AUSMPWPLUS) + MakePair("SLAU", UPWIND::SLAU) + MakePair("HLLC", UPWIND::HLLC) + MakePair("SW", UPWIND::SW) + MakePair("MSW", UPWIND::MSW) + MakePair("CUSP", UPWIND::CUSP) + MakePair("SCALAR_UPWIND", UPWIND::SCALAR_UPWIND) + MakePair("SCALAR_ADVECTION", UPWIND::SCALAR_ADVECTION) + MakePair("CONVECTIVE_TEMPLATE", UPWIND::CONVECTIVE_TEMPLATE) + MakePair("L2ROE", UPWIND::L2ROE) + MakePair("LMROE", UPWIND::LMROE) + MakePair("SLAU2", UPWIND::SLAU2) + MakePair("FDS", UPWIND::FDS) + MakePair("LAX-FRIEDRICH", UPWIND::LAX_FRIEDRICH) }; /*! diff --git a/Common/include/option_structure.inl b/Common/include/option_structure.inl index 4973de92cb3..9dc297957c1 100644 --- a/Common/include/option_structure.inl +++ b/Common/include/option_structure.inl @@ -406,11 +406,11 @@ public: class COptionConvect : public COptionBase { string name; // identifier for the option unsigned short & space; - unsigned short & centered; - unsigned short & upwind; + CENTERED & centered; + UPWIND & upwind; public: - COptionConvect(string option_field_name, unsigned short & space_field, unsigned short & centered_field, unsigned short & upwind_field) + COptionConvect(string option_field_name, unsigned short & space_field, CENTERED & centered_field, UPWIND & upwind_field) : name(option_field_name), space(space_field), centered(centered_field), upwind(upwind_field) { } string SetValue(const vector& option_value) override { @@ -424,13 +424,13 @@ public: if (Centered_Map.count(option_value[0])) { this->space = Space_Map.find("SPACE_CENTERED")->second; this->centered = Centered_Map.find(option_value[0])->second; - this->upwind = NO_UPWIND; + this->upwind = UPWIND::NO_UPWIND; return ""; } if (Upwind_Map.count(option_value[0])) { this->space = Space_Map.find("SPACE_UPWIND")->second; this->upwind = Upwind_Map.find(option_value[0])->second; - this->centered = NO_CENTERED; + this->centered = CENTERED::NO_CENTERED; return ""; } // Make them defined in case something weird happens @@ -440,8 +440,8 @@ public: } void SetDefault() override { - this->centered = NO_CENTERED; - this->upwind = NO_UPWIND; + this->centered = CENTERED::NO_CENTERED; + this->upwind = UPWIND::NO_UPWIND; this->space = NO_CONVECTIVE; } }; diff --git a/Common/src/CConfig.cpp b/Common/src/CConfig.cpp index b90f1d48a04..ed80ed2cd21 100644 --- a/Common/src/CConfig.cpp +++ b/Common/src/CConfig.cpp @@ -414,7 +414,7 @@ void CConfig::addStringListOption(const string name, unsigned short & num_marker option_map.insert(pair(name, val)); } -void CConfig::addConvectOption(const string name, unsigned short & space_field, unsigned short & centered_field, unsigned short & upwind_field) { +void CConfig::addConvectOption(const string name, unsigned short & space_field, CENTERED & centered_field, UPWIND & upwind_field) { assert(option_map.find(name) == option_map.end()); all_options.insert(pair(name, true)); COptionBase* val = new COptionConvect(name, space_field, centered_field, upwind_field); @@ -2300,7 +2300,7 @@ void CConfig::SetConfig_Options() { /*--- Options related to the finite element flow solver---*/ /* DESCRIPTION: Riemann solver used for DG (ROE, LAX-FRIEDRICH, AUSM, AUSMPW+, HLLC, VAN_LEER) */ - addEnumOption("RIEMANN_SOLVER_FEM", Riemann_Solver_FEM, Upwind_Map, ROE); + addEnumOption("RIEMANN_SOLVER_FEM", Riemann_Solver_FEM, Upwind_Map, UPWIND::ROE); /* DESCRIPTION: Constant factor applied for quadrature with straight elements (2.0 by default) */ addDoubleOption("QUADRATURE_FACTOR_STRAIGHT_FEM", Quadrature_Factor_Straight, 2.0); /* DESCRIPTION: Constant factor applied for quadrature with curved elements (3.0 by default) */ @@ -3803,13 +3803,13 @@ void CConfig::SetPostprocessing(SU2_COMPONENT val_software, unsigned short val_i } if (!ideal_gas && !nemo) { - if (Kind_Upwind_Flow != ROE && Kind_Upwind_Flow != HLLC && Kind_Centered_Flow != JST) { + if (Kind_Upwind_Flow != UPWIND::ROE && Kind_Upwind_Flow != UPWIND::HLLC && Kind_Centered_Flow != CENTERED::JST) { SU2_MPI::Error("Only ROE Upwind, HLLC Upwind scheme, and JST scheme can be used for Non-Ideal Compressible Fluids", CURRENT_FUNCTION); } } if (nemo){ - if (Kind_Upwind_Flow == AUSMPWPLUS) + if (Kind_Upwind_Flow == UPWIND::AUSMPWPLUS) SU2_MPI::Error("AUSMPW+ is extremely unstable. Feel free to fix me!", CURRENT_FUNCTION); } @@ -6482,7 +6482,7 @@ void CConfig::SetOutput(SU2_COMPONENT val_software, unsigned short val_izone) { (Kind_Solver == MAIN_SOLVER::DISC_ADJ_EULER) || (Kind_Solver == MAIN_SOLVER::DISC_ADJ_NAVIER_STOKES) || (Kind_Solver == MAIN_SOLVER::DISC_ADJ_RANS) ) { if (Kind_ConvNumScheme_Flow == SPACE_CENTERED) { - if (Kind_Centered_Flow == LAX) { + if (Kind_Centered_Flow == CENTERED::LAX) { cout << "Lax-Friedrich scheme (1st order in space) for the flow inviscid terms.\n"; cout << "Lax viscous coefficients (1st): " << Kappa_1st_Flow << ".\n"; cout << "First order integration." << endl; @@ -6495,21 +6495,21 @@ void CConfig::SetOutput(SU2_COMPONENT val_software, unsigned short val_izone) { } if (Kind_ConvNumScheme_Flow == SPACE_UPWIND) { - if (Kind_Upwind_Flow == ROE) cout << "Roe (with entropy fix = "<< EntropyFix_Coeff <<") solver for the flow inviscid terms."<< endl; - if (Kind_Upwind_Flow == TURKEL) cout << "Roe-Turkel solver for the flow inviscid terms."<< endl; - if (Kind_Upwind_Flow == AUSM) cout << "AUSM solver for the flow inviscid terms."<< endl; - if (Kind_Upwind_Flow == HLLC) cout << "HLLC solver for the flow inviscid terms."<< endl; - if (Kind_Upwind_Flow == SW) cout << "Steger-Warming solver for the flow inviscid terms."<< endl; - if (Kind_Upwind_Flow == MSW) cout << "Modified Steger-Warming solver for the flow inviscid terms."<< endl; - if (Kind_Upwind_Flow == CUSP) cout << "CUSP solver for the flow inviscid terms."<< endl; - if (Kind_Upwind_Flow == L2ROE) cout << "L2ROE Low Mach ROE solver for the flow inviscid terms."<< endl; - if (Kind_Upwind_Flow == LMROE) cout << "Rieper Low Mach ROE solver for the flow inviscid terms."<< endl; - if (Kind_Upwind_Flow == SLAU) cout << "Simple Low-Dissipation AUSM solver for the flow inviscid terms."<< endl; - if (Kind_Upwind_Flow == SLAU2) cout << "Simple Low-Dissipation AUSM 2 solver for the flow inviscid terms."<< endl; - if (Kind_Upwind_Flow == FDS) cout << "Flux difference splitting (FDS) upwind scheme for the flow inviscid terms."<< endl; - if (Kind_Upwind_Flow == AUSMPLUSUP) cout << "AUSM+-up solver for the flow inviscid terms."<< endl; - if (Kind_Upwind_Flow == AUSMPLUSUP2) cout << "AUSM+-up2 solver for the flow inviscid terms."<< endl; - if (Kind_Upwind_Flow == AUSMPWPLUS) cout << "AUSMPWPLUS solver for the flow inviscid terms."<< endl; + if (Kind_Upwind_Flow == UPWIND::ROE) cout << "Roe (with entropy fix = "<< EntropyFix_Coeff <<") solver for the flow inviscid terms."<< endl; + if (Kind_Upwind_Flow == UPWIND::TURKEL) cout << "Roe-Turkel solver for the flow inviscid terms."<< endl; + if (Kind_Upwind_Flow == UPWIND::AUSM) cout << "AUSM solver for the flow inviscid terms."<< endl; + if (Kind_Upwind_Flow == UPWIND::HLLC) cout << "HLLC solver for the flow inviscid terms."<< endl; + if (Kind_Upwind_Flow == UPWIND::SW) cout << "Steger-Warming solver for the flow inviscid terms."<< endl; + if (Kind_Upwind_Flow == UPWIND::MSW) cout << "Modified Steger-Warming solver for the flow inviscid terms."<< endl; + if (Kind_Upwind_Flow == UPWIND::CUSP) cout << "CUSP solver for the flow inviscid terms."<< endl; + if (Kind_Upwind_Flow == UPWIND::L2ROE) cout << "L2ROE Low Mach ROE solver for the flow inviscid terms."<< endl; + if (Kind_Upwind_Flow == UPWIND::LMROE) cout << "Rieper Low Mach ROE solver for the flow inviscid terms."<< endl; + if (Kind_Upwind_Flow == UPWIND::SLAU) cout << "Simple Low-Dissipation AUSM solver for the flow inviscid terms."<< endl; + if (Kind_Upwind_Flow == UPWIND::SLAU2) cout << "Simple Low-Dissipation AUSM 2 solver for the flow inviscid terms."<< endl; + if (Kind_Upwind_Flow == UPWIND::FDS) cout << "Flux difference splitting (FDS) upwind scheme for the flow inviscid terms."<< endl; + if (Kind_Upwind_Flow == UPWIND::AUSMPLUSUP) cout << "AUSM+-up solver for the flow inviscid terms."<< endl; + if (Kind_Upwind_Flow == UPWIND::AUSMPLUSUP2) cout << "AUSM+-up2 solver for the flow inviscid terms."<< endl; + if (Kind_Upwind_Flow == UPWIND::AUSMPWPLUS) cout << "AUSMPWPLUS solver for the flow inviscid terms."<< endl; if (Kind_Solver == MAIN_SOLVER::EULER || Kind_Solver == MAIN_SOLVER::DISC_ADJ_EULER || Kind_Solver == MAIN_SOLVER::NAVIER_STOKES || Kind_Solver == MAIN_SOLVER::DISC_ADJ_NAVIER_STOKES || @@ -6535,7 +6535,7 @@ void CConfig::SetOutput(SU2_COMPONENT val_software, unsigned short val_izone) { if ((Kind_Solver == MAIN_SOLVER::RANS) || (Kind_Solver == MAIN_SOLVER::DISC_ADJ_RANS)) { if (Kind_ConvNumScheme_Turb == SPACE_UPWIND) { - if (Kind_Upwind_Turb == SCALAR_UPWIND) cout << "Scalar upwind solver for the turbulence model." << endl; + if (Kind_Upwind_Turb == UPWIND::SCALAR_UPWIND) cout << "Scalar upwind solver for the turbulence model." << endl; if (MUSCL_Turb) { PrintLimiterInfo(Kind_SlopeLimit_Turb); } else { @@ -6547,21 +6547,21 @@ void CConfig::SetOutput(SU2_COMPONENT val_software, unsigned short val_izone) { if ((Kind_Solver == MAIN_SOLVER::ADJ_EULER) || (Kind_Solver == MAIN_SOLVER::ADJ_NAVIER_STOKES) || (Kind_Solver == MAIN_SOLVER::ADJ_RANS)) { if (Kind_ConvNumScheme_AdjFlow == SPACE_CENTERED) { - if (Kind_Centered_AdjFlow == JST) { + if (Kind_Centered_AdjFlow == CENTERED::JST) { cout << "Jameson-Schmidt-Turkel scheme for the adjoint inviscid terms."<< endl; cout << "JST viscous coefficients (1st, 2nd, & 4th): " << Kappa_1st_AdjFlow << ", " << Kappa_2nd_AdjFlow << ", " << Kappa_4th_AdjFlow <<"."<< endl; cout << "The method includes a grid stretching correction (p = 0.3)."<< endl; cout << "Second order integration." << endl; } - if (Kind_Centered_AdjFlow == LAX) { + if (Kind_Centered_AdjFlow == CENTERED::LAX) { cout << "Lax-Friedrich scheme for the adjoint inviscid terms."<< endl; cout << "First order integration." << endl; } } if (Kind_ConvNumScheme_AdjFlow == SPACE_UPWIND) { - if (Kind_Upwind_AdjFlow == ROE) cout << "Roe (with entropy fix = "<< EntropyFix_Coeff <<") solver for the adjoint inviscid terms."<< endl; + if (Kind_Upwind_AdjFlow == UPWIND::ROE) cout << "Roe (with entropy fix = "<< EntropyFix_Coeff <<") solver for the adjoint inviscid terms."<< endl; if (MUSCL_AdjFlow) { PrintLimiterInfo(Kind_SlopeLimit_AdjFlow); } else { @@ -6575,7 +6575,7 @@ void CConfig::SetOutput(SU2_COMPONENT val_software, unsigned short val_izone) { if ((Kind_Solver == MAIN_SOLVER::ADJ_RANS) && (!Frozen_Visc_Cont)) { if (Kind_ConvNumScheme_AdjTurb == SPACE_UPWIND) { - if (Kind_Upwind_Turb == SCALAR_UPWIND) cout << "Scalar upwind solver for the adjoint turbulence model." << endl; + if (Kind_Upwind_Turb == UPWIND::SCALAR_UPWIND) cout << "Scalar upwind solver for the adjoint turbulence model." << endl; if (MUSCL_AdjTurb) { PrintLimiterInfo(Kind_SlopeLimit_AdjTurb); } else { @@ -6634,10 +6634,10 @@ void CConfig::SetOutput(SU2_COMPONENT val_software, unsigned short val_izone) { cout << "Discontinuous Galerkin Finite element solver" << endl; switch( Riemann_Solver_FEM ) { - case ROE: cout << "Roe (with entropy fix) solver for inviscid fluxes over the faces" << endl; break; - case LAX_FRIEDRICH: cout << "Lax-Friedrich solver for inviscid fluxes over the faces" << endl; break; - case AUSM: cout << "AUSM solver inviscid fluxes over the faces" << endl; break; - case HLLC: cout << "HLLC solver inviscid fluxes over the faces" << endl; break; + case UPWIND::ROE: cout << "Roe (with entropy fix) solver for inviscid fluxes over the faces" << endl; break; + case UPWIND::LAX_FRIEDRICH: cout << "Lax-Friedrich solver for inviscid fluxes over the faces" << endl; break; + case UPWIND::AUSM: cout << "AUSM solver inviscid fluxes over the faces" << endl; break; + case UPWIND::HLLC: cout << "HLLC solver inviscid fluxes over the faces" << endl; break; } if(Kind_Solver != MAIN_SOLVER::FEM_EULER && Kind_Solver != MAIN_SOLVER::DISC_ADJ_FEM_EULER) { @@ -8164,7 +8164,7 @@ unsigned short CConfig::GetContainerPosition(unsigned short val_eqsystem) { } void CConfig::SetKind_ConvNumScheme(unsigned short val_kind_convnumscheme, - unsigned short val_kind_centered, unsigned short val_kind_upwind, + CENTERED val_kind_centered, UPWIND val_kind_upwind, LIMITER val_kind_slopelimit, bool val_muscl, unsigned short val_kind_fem) { Kind_ConvNumScheme = val_kind_convnumscheme; @@ -8231,7 +8231,7 @@ void CConfig::SetGlobalParam(MAIN_SOLVER val_solver, SetSpeciesParam(); if (val_system == RUNTIME_HEAT_SYS) { - SetKind_ConvNumScheme(Kind_ConvNumScheme_Heat, NONE, NONE, LIMITER::NONE, NONE, NONE); + SetKind_ConvNumScheme(Kind_ConvNumScheme_Heat, CENTERED::NO_CENTERED, UPWIND::NO_UPWIND, LIMITER::NONE, NONE, NONE); SetKind_TimeIntScheme(Kind_TimeIntScheme_Heat); } break; @@ -8247,7 +8247,7 @@ void CConfig::SetGlobalParam(MAIN_SOLVER val_solver, SetKind_TimeIntScheme(Kind_TimeIntScheme_Turb); } if (val_system == RUNTIME_HEAT_SYS) { - SetKind_ConvNumScheme(Kind_ConvNumScheme_Heat, NONE, NONE, LIMITER::NONE, NONE, NONE); + SetKind_ConvNumScheme(Kind_ConvNumScheme_Heat, CENTERED::NO_CENTERED, UPWIND::NO_UPWIND, LIMITER::NONE, NONE, NONE); SetKind_TimeIntScheme(Kind_TimeIntScheme_Heat); } break; @@ -8280,7 +8280,7 @@ void CConfig::SetGlobalParam(MAIN_SOLVER val_solver, break; case MAIN_SOLVER::HEAT_EQUATION: if (val_system == RUNTIME_HEAT_SYS) { - SetKind_ConvNumScheme(NONE, NONE, NONE, LIMITER::NONE, NONE, NONE); + SetKind_ConvNumScheme(NONE, CENTERED::NO_CENTERED, UPWIND::NO_UPWIND, LIMITER::NONE, NONE, NONE); SetKind_TimeIntScheme(Kind_TimeIntScheme_Heat); } break; @@ -8290,7 +8290,7 @@ void CConfig::SetGlobalParam(MAIN_SOLVER val_solver, Current_DynTime = static_cast(TimeIter)*Delta_DynTime; if (val_system == RUNTIME_FEA_SYS) { - SetKind_ConvNumScheme(NONE, NONE, NONE, LIMITER::NONE , NONE, NONE); + SetKind_ConvNumScheme(NONE, CENTERED::NO_CENTERED, UPWIND::NO_UPWIND, LIMITER::NONE , NONE, NONE); SetKind_TimeIntScheme(NONE); } break; diff --git a/SU2_CFD/include/numerics_simd/CNumericsSIMD.cpp b/SU2_CFD/include/numerics_simd/CNumericsSIMD.cpp index e930f214db0..90cfb5eb912 100644 --- a/SU2_CFD/include/numerics_simd/CNumericsSIMD.cpp +++ b/SU2_CFD/include/numerics_simd/CNumericsSIMD.cpp @@ -41,7 +41,7 @@ template CNumericsSIMD* createUpwindIdealNumerics(const CConfig& config, int iMesh, const CVariable* turbVars) { CNumericsSIMD* obj = nullptr; switch (config.GetKind_Upwind_Flow()) { - case ROE: + case UPWIND::ROE: obj = new CRoeScheme(config, iMesh, turbVars); break; } @@ -62,19 +62,19 @@ CNumericsSIMD* createUpwindGeneralNumerics(const CConfig& config, int iMesh, con template CNumericsSIMD* createCenteredNumerics(const CConfig& config, int iMesh, const CVariable* turbVars) { CNumericsSIMD* obj = nullptr; - switch ((iMesh==MESH_0)? config.GetKind_Centered_Flow() : LAX) { - case NO_CENTERED: + switch ((iMesh==MESH_0)? config.GetKind_Centered_Flow() : CENTERED::LAX) { + case CENTERED::NO_CENTERED: break; - case LAX: + case CENTERED::LAX: obj = new CLaxScheme(config, iMesh, turbVars); break; - case JST: + case CENTERED::JST: obj = new CJSTScheme(config, iMesh, turbVars); break; - case JST_KE: + case CENTERED::JST_KE: obj = new CJSTkeScheme(config, iMesh, turbVars); break; - case JST_MAT: + case CENTERED::JST_MAT: obj = new CJSTmatScheme(config, iMesh, turbVars); break; } diff --git a/SU2_CFD/include/solvers/CScalarSolver.inl b/SU2_CFD/include/solvers/CScalarSolver.inl index 253dbfb2b9c..2e44afe2e71 100644 --- a/SU2_CFD/include/solvers/CScalarSolver.inl +++ b/SU2_CFD/include/solvers/CScalarSolver.inl @@ -165,7 +165,7 @@ void CScalarSolver::Upwind_Residual(CGeometry* geometry, CSolver** bool advection{false}; - if(config->GetKind_Upwind_Species() == SCALAR_ADVECTION) advection = true; + if(config->GetKind_Upwind_Species() == UPWIND::SCALAR_ADVECTION) advection = true; /*--- Loop over edge colors. ---*/ for (auto color : EdgeColoring) { diff --git a/SU2_CFD/src/drivers/CDriver.cpp b/SU2_CFD/src/drivers/CDriver.cpp index a2671967095..0c9b45ed024 100644 --- a/SU2_CFD/src/drivers/CDriver.cpp +++ b/SU2_CFD/src/drivers/CDriver.cpp @@ -1256,7 +1256,7 @@ void CDriver::InstantiateTurbulentNumerics(unsigned short nVar_Turb, int offset, /*--- Definition of the convective scheme for each equation and mesh level ---*/ switch (config->GetKind_ConvNumScheme_Turb()) { - case NO_UPWIND: + case NO_CONVECTIVE: SU2_MPI::Error("Config file is missing the CONV_NUM_METHOD_TURB option.", CURRENT_FUNCTION); break; case SPACE_UPWIND : @@ -1614,8 +1614,8 @@ void CDriver::Numerics_Preprocessing(CConfig *config, CGeometry **geometry, CSol if (incompressible) { /*--- Incompressible flow, use preconditioning method ---*/ switch (config->GetKind_Centered_Flow()) { - case LAX : numerics[MESH_0][FLOW_SOL][conv_term] = new CCentLaxInc_Flow(nDim, nVar_Flow, config); break; - case JST : numerics[MESH_0][FLOW_SOL][conv_term] = new CCentJSTInc_Flow(nDim, nVar_Flow, config); break; + case CENTERED::LAX : numerics[MESH_0][FLOW_SOL][conv_term] = new CCentLaxInc_Flow(nDim, nVar_Flow, config); break; + 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; @@ -1633,7 +1633,7 @@ void CDriver::Numerics_Preprocessing(CConfig *config, CGeometry **geometry, CSol if (compressible) { /*--- Compressible flow ---*/ switch (config->GetKind_Upwind_Flow()) { - case ROE: + case UPWIND::ROE: if (ideal_gas) { for (iMGlevel = 0; iMGlevel <= config->GetnMGLevels(); iMGlevel++) { @@ -1649,62 +1649,62 @@ void CDriver::Numerics_Preprocessing(CConfig *config, CGeometry **geometry, CSol } break; - case AUSM: + case UPWIND::AUSM: for (iMGlevel = 0; iMGlevel <= config->GetnMGLevels(); iMGlevel++) { numerics[iMGlevel][FLOW_SOL][conv_term] = new CUpwAUSM_Flow(nDim, nVar_Flow, config); numerics[iMGlevel][FLOW_SOL][conv_bound_term] = new CUpwAUSM_Flow(nDim, nVar_Flow, config); } break; - case AUSMPLUSUP: + case UPWIND::AUSMPLUSUP: for (iMGlevel = 0; iMGlevel <= config->GetnMGLevels(); iMGlevel++) { numerics[iMGlevel][FLOW_SOL][conv_term] = new CUpwAUSMPLUSUP_Flow(nDim, nVar_Flow, config); numerics[iMGlevel][FLOW_SOL][conv_bound_term] = new CUpwAUSMPLUSUP_Flow(nDim, nVar_Flow, config); } break; - case AUSMPLUSUP2: + case UPWIND::AUSMPLUSUP2: for (iMGlevel = 0; iMGlevel <= config->GetnMGLevels(); iMGlevel++) { numerics[iMGlevel][FLOW_SOL][conv_term] = new CUpwAUSMPLUSUP2_Flow(nDim, nVar_Flow, config); numerics[iMGlevel][FLOW_SOL][conv_bound_term] = new CUpwAUSMPLUSUP2_Flow(nDim, nVar_Flow, config); } break; - case TURKEL: + case UPWIND::TURKEL: for (iMGlevel = 0; iMGlevel <= config->GetnMGLevels(); iMGlevel++) { numerics[iMGlevel][FLOW_SOL][conv_term] = new CUpwTurkel_Flow(nDim, nVar_Flow, config); numerics[iMGlevel][FLOW_SOL][conv_bound_term] = new CUpwTurkel_Flow(nDim, nVar_Flow, config); } break; - case L2ROE: + case UPWIND::L2ROE: for (iMGlevel = 0; iMGlevel <= config->GetnMGLevels(); iMGlevel++) { numerics[iMGlevel][FLOW_SOL][conv_term] = new CUpwL2Roe_Flow(nDim, nVar_Flow, config); numerics[iMGlevel][FLOW_SOL][conv_bound_term] = new CUpwL2Roe_Flow(nDim, nVar_Flow, config); } break; - case LMROE: + case UPWIND::LMROE: for (iMGlevel = 0; iMGlevel <= config->GetnMGLevels(); iMGlevel++) { numerics[iMGlevel][FLOW_SOL][conv_term] = new CUpwLMRoe_Flow(nDim, nVar_Flow, config); numerics[iMGlevel][FLOW_SOL][conv_bound_term] = new CUpwLMRoe_Flow(nDim, nVar_Flow, config); } break; - case SLAU: + case UPWIND::SLAU: for (iMGlevel = 0; iMGlevel <= config->GetnMGLevels(); iMGlevel++) { numerics[iMGlevel][FLOW_SOL][conv_term] = new CUpwSLAU_Flow(nDim, nVar_Flow, config, roe_low_dissipation); numerics[iMGlevel][FLOW_SOL][conv_bound_term] = new CUpwSLAU_Flow(nDim, nVar_Flow, config, false); } break; - case SLAU2: + case UPWIND::SLAU2: for (iMGlevel = 0; iMGlevel <= config->GetnMGLevels(); iMGlevel++) { numerics[iMGlevel][FLOW_SOL][conv_term] = new CUpwSLAU2_Flow(nDim, nVar_Flow, config, roe_low_dissipation); numerics[iMGlevel][FLOW_SOL][conv_bound_term] = new CUpwSLAU2_Flow(nDim, nVar_Flow, config, false); } break; - case HLLC: + case UPWIND::HLLC: if (ideal_gas) { for (iMGlevel = 0; iMGlevel <= config->GetnMGLevels(); iMGlevel++) { numerics[iMGlevel][FLOW_SOL][conv_term] = new CUpwHLLC_Flow(nDim, nVar_Flow, config); @@ -1719,14 +1719,14 @@ void CDriver::Numerics_Preprocessing(CConfig *config, CGeometry **geometry, CSol } break; - case MSW: + case UPWIND::MSW: for (iMGlevel = 0; iMGlevel <= config->GetnMGLevels(); iMGlevel++) { numerics[iMGlevel][FLOW_SOL][conv_term] = new CUpwMSW_Flow(nDim, nVar_Flow, config); numerics[iMGlevel][FLOW_SOL][conv_bound_term] = new CUpwMSW_Flow(nDim, nVar_Flow, config); } break; - case CUSP: + case UPWIND::CUSP: for (iMGlevel = 0; iMGlevel <= config->GetnMGLevels(); iMGlevel++) { numerics[iMGlevel][FLOW_SOL][conv_term] = new CUpwCUSP_Flow(nDim, nVar_Flow, config); numerics[iMGlevel][FLOW_SOL][conv_bound_term] = new CUpwCUSP_Flow(nDim, nVar_Flow, config); @@ -1742,7 +1742,7 @@ void CDriver::Numerics_Preprocessing(CConfig *config, CGeometry **geometry, CSol if (incompressible) { /*--- Incompressible flow, use artificial compressibility method ---*/ switch (config->GetKind_Upwind_Flow()) { - case FDS: + 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); @@ -1862,7 +1862,7 @@ void CDriver::Numerics_Preprocessing(CConfig *config, CGeometry **geometry, CSol if (compressible) { /*--- Compressible flow ---*/ switch (config->GetKind_Centered_Flow()) { - case LAX : numerics[MESH_0][FLOW_SOL][conv_term] = new CCentLax_NEMO(nDim, nVar_NEMO, nPrimVar_NEMO, nPrimVarGrad_NEMO, config); break; + case CENTERED::LAX : numerics[MESH_0][FLOW_SOL][conv_term] = new CCentLax_NEMO(nDim, nVar_NEMO, nPrimVar_NEMO, nPrimVarGrad_NEMO, config); break; default: SU2_MPI::Error("Invalid centered scheme or not implemented.", CURRENT_FUNCTION); break; @@ -1880,35 +1880,35 @@ void CDriver::Numerics_Preprocessing(CConfig *config, CGeometry **geometry, CSol if (compressible) { /*--- Compressible flow ---*/ switch (config->GetKind_Upwind_Flow()) { - case ROE: + case UPWIND::ROE: for (iMGlevel = 0; iMGlevel <= config->GetnMGLevels(); iMGlevel++) { numerics[iMGlevel][FLOW_SOL][conv_term] = new CUpwRoe_NEMO(nDim, nVar_NEMO, nPrimVar_NEMO, nPrimVarGrad_NEMO, config); numerics[iMGlevel][FLOW_SOL][conv_bound_term] = new CUpwRoe_NEMO(nDim, nVar_NEMO, nPrimVar_NEMO, nPrimVarGrad_NEMO, config); } break; - case AUSM: + case UPWIND::AUSM: for (iMGlevel = 0; iMGlevel <= config->GetnMGLevels(); iMGlevel++) { numerics[iMGlevel][FLOW_SOL][conv_term] = new CUpwAUSM_NEMO(nDim, nVar_NEMO, nPrimVar_NEMO, nPrimVarGrad_NEMO, config); numerics[iMGlevel][FLOW_SOL][conv_bound_term] = new CUpwAUSM_NEMO(nDim, nVar_NEMO, nPrimVar_NEMO, nPrimVarGrad_NEMO, config); } break; - case AUSMPLUSUP2: + case UPWIND::AUSMPLUSUP2: for (iMGlevel = 0; iMGlevel <= config->GetnMGLevels(); iMGlevel++) { numerics[iMGlevel][FLOW_SOL][conv_term] = new CUpwAUSMPLUSUP2_NEMO(nDim, nVar_NEMO, nPrimVar_NEMO, nPrimVarGrad_NEMO, config); numerics[iMGlevel][FLOW_SOL][conv_bound_term] = new CUpwAUSMPLUSUP2_NEMO(nDim, nVar_NEMO, nPrimVar_NEMO, nPrimVarGrad_NEMO, config); } break; - case MSW: + case UPWIND::MSW: for (iMGlevel = 0; iMGlevel <= config->GetnMGLevels(); iMGlevel++) { numerics[iMGlevel][FLOW_SOL][conv_term] = new CUpwMSW_NEMO(nDim, nVar_NEMO, nPrimVar_NEMO, nPrimVarGrad_NEMO, config); numerics[iMGlevel][FLOW_SOL][conv_bound_term] = new CUpwMSW_NEMO(nDim, nVar_NEMO, nPrimVar_NEMO, nPrimVarGrad_NEMO, config); } break; - case AUSMPWPLUS: + case UPWIND::AUSMPWPLUS: for (iMGlevel = 0; iMGlevel <= config->GetnMGLevels(); iMGlevel++) { numerics[iMGlevel][FLOW_SOL][conv_term] = new CUpwAUSMPWplus_NEMO(nDim, nVar_NEMO, nPrimVar_NEMO, nPrimVarGrad_NEMO, config); numerics[iMGlevel][FLOW_SOL][conv_bound_term] = new CUpwAUSMPWplus_NEMO(nDim, nVar_NEMO, nPrimVar_NEMO, nPrimVarGrad_NEMO, config); @@ -1952,41 +1952,41 @@ void CDriver::Numerics_Preprocessing(CConfig *config, CGeometry **geometry, CSol if ((fem_euler) || (fem_ns)) { switch (config->GetRiemann_Solver_FEM()) { - case ROE: - case LAX_FRIEDRICH: + case UPWIND::ROE: + case UPWIND::LAX_FRIEDRICH: /* Hard coded optimized implementation is used in the DG solver. No need to allocate the corresponding entry in numerics. */ break; - case AUSM: + case UPWIND::AUSM: for (iMGlevel = 0; iMGlevel <= config->GetnMGLevels(); iMGlevel++) { numerics[iMGlevel][FLOW_SOL][conv_term] = new CUpwAUSM_Flow(nDim, nVar_Flow, config); numerics[iMGlevel][FLOW_SOL][conv_bound_term] = new CUpwAUSM_Flow(nDim, nVar_Flow, config); } break; - case TURKEL: + case UPWIND::TURKEL: for (iMGlevel = 0; iMGlevel <= config->GetnMGLevels(); iMGlevel++) { numerics[iMGlevel][FLOW_SOL][conv_term] = new CUpwTurkel_Flow(nDim, nVar_Flow, config); numerics[iMGlevel][FLOW_SOL][conv_bound_term] = new CUpwTurkel_Flow(nDim, nVar_Flow, config); } break; - case HLLC: + case UPWIND::HLLC: for (iMGlevel = 0; iMGlevel <= config->GetnMGLevels(); iMGlevel++) { numerics[iMGlevel][FLOW_SOL][conv_term] = new CUpwHLLC_Flow(nDim, nVar_Flow, config); numerics[iMGlevel][FLOW_SOL][conv_bound_term] = new CUpwHLLC_Flow(nDim, nVar_Flow, config); } break; - case MSW: + case UPWIND::MSW: for (iMGlevel = 0; iMGlevel <= config->GetnMGLevels(); iMGlevel++) { numerics[iMGlevel][FLOW_SOL][conv_term] = new CUpwMSW_Flow(nDim, nVar_Flow, config); numerics[iMGlevel][FLOW_SOL][conv_bound_term] = new CUpwMSW_Flow(nDim, nVar_Flow, config); } break; - case CUSP: + case UPWIND::CUSP: for (iMGlevel = 0; iMGlevel <= config->GetnMGLevels(); iMGlevel++) { numerics[iMGlevel][FLOW_SOL][conv_term] = new CUpwCUSP_Flow(nDim, nVar_Flow, config); numerics[iMGlevel][FLOW_SOL][conv_bound_term] = new CUpwCUSP_Flow(nDim, nVar_Flow, config); @@ -2019,7 +2019,7 @@ void CDriver::Numerics_Preprocessing(CConfig *config, CGeometry **geometry, CSol /*--- Definition of the convective scheme for each equation and mesh level ---*/ switch (config->GetKind_ConvNumScheme_Turb()) { - case NO_UPWIND: + case NO_CONVECTIVE: SU2_MPI::Error("Config file is missing the CONV_NUM_METHOD_TURB option.", CURRENT_FUNCTION); break; case SPACE_UPWIND: @@ -2124,8 +2124,8 @@ void CDriver::Numerics_Preprocessing(CConfig *config, CGeometry **geometry, CSol /*--- Compressible flow ---*/ switch (config->GetKind_Centered_AdjFlow()) { - case LAX : numerics[MESH_0][ADJFLOW_SOL][conv_term] = new CCentLax_AdjFlow(nDim, nVar_Adj_Flow, config); break; - case JST : numerics[MESH_0][ADJFLOW_SOL][conv_term] = new CCentJST_AdjFlow(nDim, nVar_Adj_Flow, config); break; + case CENTERED::LAX : numerics[MESH_0][ADJFLOW_SOL][conv_term] = new CCentLax_AdjFlow(nDim, nVar_Adj_Flow, config); break; + case CENTERED::JST : numerics[MESH_0][ADJFLOW_SOL][conv_term] = new CCentJST_AdjFlow(nDim, nVar_Adj_Flow, config); break; default: SU2_MPI::Error("Centered scheme not implemented.", CURRENT_FUNCTION); break; @@ -2147,7 +2147,7 @@ void CDriver::Numerics_Preprocessing(CConfig *config, CGeometry **geometry, CSol /*--- Compressible flow ---*/ switch (config->GetKind_Upwind_AdjFlow()) { - case ROE: + case UPWIND::ROE: for (iMGlevel = 0; iMGlevel <= config->GetnMGLevels(); iMGlevel++) { numerics[iMGlevel][ADJFLOW_SOL][conv_term] = new CUpwRoe_AdjFlow(nDim, nVar_Adj_Flow, config); numerics[iMGlevel][ADJFLOW_SOL][conv_bound_term] = new CUpwRoe_AdjFlow(nDim, nVar_Adj_Flow, config); diff --git a/SU2_CFD/src/solvers/CAdjEulerSolver.cpp b/SU2_CFD/src/solvers/CAdjEulerSolver.cpp index 93bd29fa9bf..1faf9717561 100644 --- a/SU2_CFD/src/solvers/CAdjEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CAdjEulerSolver.cpp @@ -951,7 +951,7 @@ void CAdjEulerSolver::Preprocessing(CGeometry *geometry, CSolver **solver_contai bool muscl = config->GetMUSCL_AdjFlow(); bool limiter = (config->GetKind_SlopeLimit_AdjFlow() != LIMITER::NONE); bool center = (config->GetKind_ConvNumScheme_AdjFlow() == SPACE_CENTERED); - bool center_jst = (config->GetKind_Centered_AdjFlow() == JST); + bool center_jst = (config->GetKind_Centered_AdjFlow() == CENTERED::JST); bool fixed_cl = config->GetFixed_CL_Mode(); bool eval_dof_dcx = config->GetEval_dOF_dCX(); @@ -1034,7 +1034,7 @@ void CAdjEulerSolver::Centered_Residual(CGeometry *geometry, CSolver **solver_co unsigned long iEdge, iPoint, jPoint; bool implicit = (config->GetKind_TimeIntScheme() == EULER_IMPLICIT); - bool jst_scheme = ((config->GetKind_Centered_AdjFlow() == JST) && (iMesh == MESH_0)); + bool jst_scheme = ((config->GetKind_Centered_AdjFlow() == CENTERED::JST) && (iMesh == MESH_0)); bool grid_movement = config->GetGrid_Movement(); for (iEdge = 0; iEdge < geometry->GetnEdge(); iEdge++) { diff --git a/SU2_CFD/src/solvers/CAdjNSSolver.cpp b/SU2_CFD/src/solvers/CAdjNSSolver.cpp index d2d34572ead..a0a0c8f5b0c 100644 --- a/SU2_CFD/src/solvers/CAdjNSSolver.cpp +++ b/SU2_CFD/src/solvers/CAdjNSSolver.cpp @@ -323,7 +323,7 @@ void CAdjNSSolver::Preprocessing(CGeometry *geometry, CSolver **solver_container bool implicit = (config->GetKind_TimeIntScheme() == EULER_IMPLICIT); bool limiter = (config->GetKind_SlopeLimit_AdjFlow() != LIMITER::NONE); - bool center_jst = (config->GetKind_Centered_AdjFlow() == JST); + bool center_jst = (config->GetKind_Centered_AdjFlow() == CENTERED::JST); bool fixed_cl = config->GetFixed_CL_Mode(); bool eval_dof_dcx = config->GetEval_dOF_dCX(); diff --git a/SU2_CFD/src/solvers/CEulerSolver.cpp b/SU2_CFD/src/solvers/CEulerSolver.cpp index 10b52f29cc2..e647b2aa4ec 100644 --- a/SU2_CFD/src/solvers/CEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CEulerSolver.cpp @@ -1482,17 +1482,17 @@ void CEulerSolver::CommonPreprocessing(CGeometry *geometry, CSolver **solver_con bool disc_adjoint = config->GetDiscrete_Adjoint(); bool implicit = (config->GetKind_TimeIntScheme() == EULER_IMPLICIT); bool center = (config->GetKind_ConvNumScheme_Flow() == SPACE_CENTERED); - bool center_jst = (config->GetKind_Centered_Flow() == JST) && (iMesh == MESH_0); - bool center_jst_ke = (config->GetKind_Centered_Flow() == JST_KE) && (iMesh == MESH_0); - bool center_jst_mat = (config->GetKind_Centered_Flow() == JST_MAT) && (iMesh == MESH_0); + bool center_jst = (config->GetKind_Centered_Flow() == CENTERED::JST) && (iMesh == MESH_0); + bool center_jst_ke = (config->GetKind_Centered_Flow() == CENTERED::JST_KE) && (iMesh == MESH_0); + bool center_jst_mat = (config->GetKind_Centered_Flow() == CENTERED::JST_MAT) && (iMesh == MESH_0); bool engine = ((config->GetnMarker_EngineInflow() != 0) || (config->GetnMarker_EngineExhaust() != 0)); bool actuator_disk = ((config->GetnMarker_ActDiskInlet() != 0) || (config->GetnMarker_ActDiskOutlet() != 0)); bool fixed_cl = config->GetFixed_CL_Mode(); unsigned short kind_row_dissipation = config->GetKind_RoeLowDiss(); bool roe_low_dissipation = (kind_row_dissipation != NO_ROELOWDISS) && - (config->GetKind_Upwind_Flow() == ROE || - config->GetKind_Upwind_Flow() == SLAU || - config->GetKind_Upwind_Flow() == SLAU2); + (config->GetKind_Upwind_Flow() == UPWIND::ROE || + config->GetKind_Upwind_Flow() == UPWIND::SLAU || + config->GetKind_Upwind_Flow() == UPWIND::SLAU2); /*--- Set the primitive variables ---*/ @@ -1689,7 +1689,7 @@ void CEulerSolver::Upwind_Residual(CGeometry *geometry, CSolver **solver_contain const bool ideal_gas = (config->GetKind_FluidModel() == STANDARD_AIR) || (config->GetKind_FluidModel() == IDEAL_GAS); - const bool roe_turkel = (config->GetKind_Upwind_Flow() == TURKEL); + const bool roe_turkel = (config->GetKind_Upwind_Flow() == UPWIND::TURKEL); const bool low_mach_corr = config->Low_Mach_Correction(); const auto kind_dissipation = config->GetKind_RoeLowDiss(); @@ -2404,7 +2404,7 @@ void CEulerSolver::PrepareImplicitIteration(CGeometry *geometry, CSolver**, CCon return matrix; } - } precond(this, config->Low_Mach_Preconditioning() || (config->GetKind_Upwind_Flow() == TURKEL), nVar); + } precond(this, config->Low_Mach_Preconditioning() || (config->GetKind_Upwind_Flow() == UPWIND::TURKEL), nVar); PrepareImplicitIteration_impl(precond, geometry, config); } diff --git a/SU2_CFD/src/solvers/CFEM_DG_EulerSolver.cpp b/SU2_CFD/src/solvers/CFEM_DG_EulerSolver.cpp index f5e04fdd048..5cd091e2ebe 100644 --- a/SU2_CFD/src/solvers/CFEM_DG_EulerSolver.cpp +++ b/SU2_CFD/src/solvers/CFEM_DG_EulerSolver.cpp @@ -8878,7 +8878,7 @@ void CFEM_DG_EulerSolver::ComputeInviscidFluxesFace(CConfig *config /* Make a distinction between the several Riemann solvers. */ switch( config->GetRiemann_Solver_FEM() ) { - case ROE: { + case UPWIND::ROE: { /* Roe's approximate Riemann solver. Easier storage of the cut off value for the entropy correction. */ @@ -9123,7 +9123,7 @@ void CFEM_DG_EulerSolver::ComputeInviscidFluxesFace(CConfig *config /*------------------------------------------------------------------------*/ - case LAX_FRIEDRICH: { + case UPWIND::LAX_FRIEDRICH: { /* Local Lax-Friedrich (Rusanov) flux Make a distinction between two and three space dimensions in order to have the most efficient code. */ diff --git a/SU2_CFD/src/solvers/CIncEulerSolver.cpp b/SU2_CFD/src/solvers/CIncEulerSolver.cpp index 609fd7ad9b5..b3e01a2be6a 100644 --- a/SU2_CFD/src/solvers/CIncEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CIncEulerSolver.cpp @@ -898,7 +898,7 @@ void CIncEulerSolver::CommonPreprocessing(CGeometry *geometry, CSolver **solver_ const bool implicit = (config->GetKind_TimeIntScheme() == EULER_IMPLICIT); const bool center = (config->GetKind_ConvNumScheme_Flow() == SPACE_CENTERED); - const bool center_jst = (config->GetKind_Centered_Flow() == JST) && (iMesh == MESH_0); + const bool center_jst = (config->GetKind_Centered_Flow() == CENTERED::JST) && (iMesh == MESH_0); const bool outlet = (config->GetnMarker_Outlet() != 0); /*--- Set the primitive variables ---*/ @@ -1067,7 +1067,7 @@ void CIncEulerSolver::Centered_Residual(CGeometry *geometry, CSolver **solver_co unsigned long iPoint, jPoint; bool implicit = (config->GetKind_TimeIntScheme() == EULER_IMPLICIT); - bool jst_scheme = ((config->GetKind_Centered_Flow() == JST) && (iMesh == MESH_0)); + bool jst_scheme = ((config->GetKind_Centered_Flow() == CENTERED::JST) && (iMesh == MESH_0)); /*--- For hybrid parallel AD, pause preaccumulation if there is shared reading of * variables, otherwise switch to the faster adjoint evaluation mode. ---*/ diff --git a/SU2_CFD/src/solvers/CNEMOEulerSolver.cpp b/SU2_CFD/src/solvers/CNEMOEulerSolver.cpp index 6add0038013..1c21b48ca94 100644 --- a/SU2_CFD/src/solvers/CNEMOEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CNEMOEulerSolver.cpp @@ -248,8 +248,8 @@ void CNEMOEulerSolver::CommonPreprocessing(CGeometry *geometry, CSolver **solver bool implicit = (config->GetKind_TimeIntScheme() == EULER_IMPLICIT); bool center = (config->GetKind_ConvNumScheme_Flow() == SPACE_CENTERED); - bool center_jst = (config->GetKind_Centered_Flow() == JST) && (iMesh == MESH_0); - bool center_jst_ke = (config->GetKind_Centered_Flow() == JST_KE) && (iMesh == MESH_0); + bool center_jst = (config->GetKind_Centered_Flow() == CENTERED::JST) && (iMesh == MESH_0); + bool center_jst_ke = (config->GetKind_Centered_Flow() == CENTERED::JST_KE) && (iMesh == MESH_0); /*--- Set the primitive variables ---*/ ompMasterAssignBarrier(ErrorCounter,0); @@ -595,7 +595,7 @@ void CNEMOEulerSolver::Upwind_Residual(CGeometry *geometry, CSolver **solver_con if (!chk_err_j) Gamma_j = ComputeConsistentExtrapolation(GetFluidModel(), nSpecies, Primitive_j, dPdU_j, dTdU_j, dTvedU_j, Eve_j, Cvve_j); /*--- Recompute Conserved variables if Roe or MSW scheme ---*/ - if ((config->GetKind_Upwind_Flow() == ROE) || (config->GetKind_Upwind_Flow() == MSW)){ + if ((config->GetKind_Upwind_Flow() == UPWIND::ROE) || (config->GetKind_Upwind_Flow() == UPWIND::MSW)){ if (!chk_err_i) RecomputeConservativeVector(Conserved_i, Primitive_i); if (!chk_err_j) RecomputeConservativeVector(Conserved_j, Primitive_j); } From 70a43d18eb42831347c4007973702ca5b67dc363 Mon Sep 17 00:00:00 2001 From: Evert Date: Thu, 25 Aug 2022 16:05:41 +0200 Subject: [PATCH 12/48] Added 'default' case to Rieman_Solver_FEM switch in CConfig.cpp --- Common/src/CConfig.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/Common/src/CConfig.cpp b/Common/src/CConfig.cpp index ed80ed2cd21..84995ce726e 100644 --- a/Common/src/CConfig.cpp +++ b/Common/src/CConfig.cpp @@ -6638,6 +6638,7 @@ void CConfig::SetOutput(SU2_COMPONENT val_software, unsigned short val_izone) { case UPWIND::LAX_FRIEDRICH: cout << "Lax-Friedrich solver for inviscid fluxes over the faces" << endl; break; case UPWIND::AUSM: cout << "AUSM solver inviscid fluxes over the faces" << endl; break; case UPWIND::HLLC: cout << "HLLC solver inviscid fluxes over the faces" << endl; break; + default: break; } if(Kind_Solver != MAIN_SOLVER::FEM_EULER && Kind_Solver != MAIN_SOLVER::DISC_ADJ_FEM_EULER) { From 3dea05b87929710441bc9f0f8a2733aaa1ad8ab0 Mon Sep 17 00:00:00 2001 From: EvertBunschoten Date: Fri, 9 Sep 2022 13:34:17 +0200 Subject: [PATCH 13/48] Added default in CNumericsSIMD.cpp switch for convective numerics container creation --- SU2_CFD/include/numerics_simd/CNumericsSIMD.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/SU2_CFD/include/numerics_simd/CNumericsSIMD.cpp b/SU2_CFD/include/numerics_simd/CNumericsSIMD.cpp index 90cfb5eb912..f076dbfad3b 100644 --- a/SU2_CFD/include/numerics_simd/CNumericsSIMD.cpp +++ b/SU2_CFD/include/numerics_simd/CNumericsSIMD.cpp @@ -44,6 +44,8 @@ CNumericsSIMD* createUpwindIdealNumerics(const CConfig& config, int iMesh, const case UPWIND::ROE: obj = new CRoeScheme(config, iMesh, turbVars); break; + default: + break; } return obj; } @@ -117,6 +119,8 @@ CNumericsSIMD* createNumerics(const CConfig& config, int iMesh, const CVariable* obj = createCenteredNumerics >(config, iMesh, turbVars); } break; + default: + break; } return obj; From f39f1ab2fae7d98885364cdf66d59481c3e15b48 Mon Sep 17 00:00:00 2001 From: EvertBunschoten Date: Fri, 9 Sep 2022 15:29:50 +0200 Subject: [PATCH 14/48] Fixed bug resulting from merge, enabled storage of edge mass fluxes for the compressible Euler solver --- Common/src/CConfig.cpp | 2 +- SU2_CFD/include/solvers/CFVMFlowSolverBase.hpp | 2 +- SU2_CFD/src/solvers/CEulerSolver.cpp | 5 +++++ TestCases/vandv/rans/30p30n/config.cfg | 2 +- 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/Common/src/CConfig.cpp b/Common/src/CConfig.cpp index 3652a9337e0..de782013d26 100644 --- a/Common/src/CConfig.cpp +++ b/Common/src/CConfig.cpp @@ -3884,6 +3884,7 @@ void CConfig::SetPostprocessing(SU2_COMPONENT val_software, unsigned short val_i if (Kind_Upwind_Flow != UPWIND::ROE && Kind_Upwind_Flow != UPWIND::HLLC && Kind_Centered_Flow != CENTERED::JST) { SU2_MPI::Error("Only ROE Upwind, HLLC Upwind scheme, and JST scheme can be used for Non-Ideal Compressible Fluids", CURRENT_FUNCTION); } + } if (nemo){ if (Kind_Upwind_Flow == UPWIND::AUSMPWPLUS) @@ -5407,7 +5408,6 @@ void CConfig::SetPostprocessing(SU2_COMPONENT val_software, unsigned short val_i } // species transport checks } -} void CConfig::SetMarkers(SU2_COMPONENT val_software) { diff --git a/SU2_CFD/include/solvers/CFVMFlowSolverBase.hpp b/SU2_CFD/include/solvers/CFVMFlowSolverBase.hpp index bf94be58471..31939a03b87 100644 --- a/SU2_CFD/include/solvers/CFVMFlowSolverBase.hpp +++ b/SU2_CFD/include/solvers/CFVMFlowSolverBase.hpp @@ -2373,6 +2373,6 @@ class CFVMFlowSolverBase : public CSolver { * \param[in] iEdge - Index of the edge. * \return The mass flux across the edge. */ - inline su2double GetEdgeMassFlux(const unsigned long iEdge) const {return EdgeMassFluxes[iEdge];} + inline su2double GetEdgeMassFlux(const unsigned long iEdge) const final { return EdgeMassFluxes[iEdge]; } }; diff --git a/SU2_CFD/src/solvers/CEulerSolver.cpp b/SU2_CFD/src/solvers/CEulerSolver.cpp index d37ec666b22..8d739d6067a 100644 --- a/SU2_CFD/src/solvers/CEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CEulerSolver.cpp @@ -336,6 +336,10 @@ CEulerSolver::CEulerSolver(CGeometry *geometry, CConfig *config, * check at the bottom to make sure we consider the "final" values). ---*/ if((nDim > MAXNDIM) || (nPrimVar > MAXNVAR) || (nSecondaryVar > MAXNVAR)) SU2_MPI::Error("Oops! The CEulerSolver static array sizes are not large enough.",CURRENT_FUNCTION); + + if (iMesh == MESH_0) { + EdgeMassFluxes.resize(geometry->GetnEdge()) = su2double(0.0); + } } CEulerSolver::~CEulerSolver(void) { @@ -1873,6 +1877,7 @@ void CEulerSolver::Upwind_Residual(CGeometry *geometry, CSolver **solver_contain Jacobian.UpdateBlocks(iEdge, iPoint, jPoint, residual.jacobian_i, residual.jacobian_j); } + EdgeMassFluxes[iEdge] = residual.residual[0]; /*--- Viscous contribution. ---*/ Viscous_Residual(iEdge, geometry, solver_container, diff --git a/TestCases/vandv/rans/30p30n/config.cfg b/TestCases/vandv/rans/30p30n/config.cfg index 067f93c3fb1..3f48da2e045 100644 --- a/TestCases/vandv/rans/30p30n/config.cfg +++ b/TestCases/vandv/rans/30p30n/config.cfg @@ -77,7 +77,7 @@ NEWTON_KRYLOV_DPARAM= ( 0.0, 1e-20, -3, 1e-5 ) % r0, tp, rf, e % % ------------------------ CONVERGENCE CRITERIA ------------------------- % % -ITER= 10000 +ITER= 20 CONV_RESIDUAL_MINVAL= -11.5 % % --------------------------- INPUT / OUTPUT ---------------------------- % From 5cf5435632f73783c7b12b9397befdce545c96d6 Mon Sep 17 00:00:00 2001 From: Nijso Date: Sun, 11 Sep 2022 00:34:43 +0200 Subject: [PATCH 15/48] Update SU2_CFD/include/solvers/CScalarSolver.inl Co-authored-by: Pedro Gomes <38071223+pcarruscag@users.noreply.github.com> --- SU2_CFD/include/solvers/CScalarSolver.inl | 1 - 1 file changed, 1 deletion(-) diff --git a/SU2_CFD/include/solvers/CScalarSolver.inl b/SU2_CFD/include/solvers/CScalarSolver.inl index 2e44afe2e71..6a6208fc7d5 100644 --- a/SU2_CFD/include/solvers/CScalarSolver.inl +++ b/SU2_CFD/include/solvers/CScalarSolver.inl @@ -182,7 +182,6 @@ void CScalarSolver::Upwind_Residual(CGeometry* geometry, CSolver** auto jPoint = geometry->edges->GetNode(iEdge, 1); numerics->SetNormal(geometry->edges->GetNormal(iEdge)); - /*--- Primitive variables w/o reconstruction ---*/ const auto V_i = flowNodes->GetPrimitive(iPoint); From 109aa8a8293391c9a8d8497afa217ea418d96198 Mon Sep 17 00:00:00 2001 From: Nijso Date: Sun, 11 Sep 2022 00:34:50 +0200 Subject: [PATCH 16/48] Update SU2_CFD/include/solvers/CSolver.hpp Co-authored-by: Pedro Gomes <38071223+pcarruscag@users.noreply.github.com> --- SU2_CFD/include/solvers/CSolver.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SU2_CFD/include/solvers/CSolver.hpp b/SU2_CFD/include/solvers/CSolver.hpp index 53fa7123492..0248ceb9c3c 100644 --- a/SU2_CFD/include/solvers/CSolver.hpp +++ b/SU2_CFD/include/solvers/CSolver.hpp @@ -3004,7 +3004,7 @@ class CSolver { * \param[in] iEdge - Index of the edge. * \return The mass flux across the edge. */ - inline virtual su2double GetEdgeMassFlux(const unsigned long iEdge) const {return 0;} + inline virtual su2double GetEdgeMassFlux(const unsigned long iEdge) const { return 0; } /*! * \brief A virtual member. From 22dbc19a465e794ca53ae1d276917ff27de846c2 Mon Sep 17 00:00:00 2001 From: Nijso Date: Tue, 20 Sep 2022 11:39:05 +0200 Subject: [PATCH 17/48] Update Common/include/option_structure.hpp Co-authored-by: Pedro Gomes <38071223+pcarruscag@users.noreply.github.com> --- Common/include/option_structure.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Common/include/option_structure.hpp b/Common/include/option_structure.hpp index 4e18510aff3..09f20dfb2aa 100644 --- a/Common/include/option_structure.hpp +++ b/Common/include/option_structure.hpp @@ -822,7 +822,7 @@ static const MapType Centered_Map = { * \brief Types of upwind spatial discretizations */ enum class UPWIND { - NO_UPWIND, /*!< \brief No upwind scheme is used. */ + NONE, /*!< \brief No upwind scheme is used. */ ROE, /*!< \brief Roe's upwind numerical method. */ SCALAR_UPWIND, /*!< \brief Scalar upwind numerical method. */ AUSM, /*!< \brief AUSM numerical method. */ From c42ede61df77afadcea49a7a1b7a250a0097886e Mon Sep 17 00:00:00 2001 From: Nijso Date: Tue, 20 Sep 2022 11:39:12 +0200 Subject: [PATCH 18/48] Update Common/include/option_structure.hpp Co-authored-by: Pedro Gomes <38071223+pcarruscag@users.noreply.github.com> --- Common/include/option_structure.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Common/include/option_structure.hpp b/Common/include/option_structure.hpp index 09f20dfb2aa..b766b38b53d 100644 --- a/Common/include/option_structure.hpp +++ b/Common/include/option_structure.hpp @@ -802,7 +802,7 @@ static const MapType Gust_Dir_Map = { * \brief Types of centered spatial discretizations */ enum class CENTERED { - NO_CENTERED, /*!< \brief No centered scheme is used. */ + NONE, /*!< \brief No centered scheme is used. */ JST, /*!< \brief Jameson-Smith-Turkel centered numerical method. */ LAX, /*!< \brief Lax-Friedrich centered numerical method. */ JST_MAT, /*!< \brief JST with matrix dissipation. */ From 839c0996d77d6cb03a11b6e6123587c32a21d6f9 Mon Sep 17 00:00:00 2001 From: Nijso Date: Tue, 20 Sep 2022 11:39:33 +0200 Subject: [PATCH 19/48] Update Common/include/CConfig.hpp Co-authored-by: Pedro Gomes <38071223+pcarruscag@users.noreply.github.com> --- Common/include/CConfig.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Common/include/CConfig.hpp b/Common/include/CConfig.hpp index 640f78e0836..6c025274134 100644 --- a/Common/include/CConfig.hpp +++ b/Common/include/CConfig.hpp @@ -4523,7 +4523,7 @@ class CConfig { * during the computation. * \return Kind of center convective numerical scheme for the flow equations. */ - CENTERED GetKind_Centered_Flow(void) const { return static_cast(Kind_Centered_Flow); } + CENTERED GetKind_Centered_Flow(void) const { return Kind_Centered_Flow; } /*! * \brief Get the kind of center convective numerical scheme for the plasma equations. From 2e9f06907027c1099fe209bd68b2ca7c7446ca89 Mon Sep 17 00:00:00 2001 From: Evert Date: Wed, 5 Oct 2022 12:14:21 +0200 Subject: [PATCH 20/48] Changed SCALAR_ADVECTION upwind option to BOUNDED_SCALAR, added weak inlet boundary condition for BOUNDED_SCALAR option for the species solver --- Common/include/option_structure.hpp | 4 +- .../numerics/scalar/scalar_convection.hpp | 12 ++-- SU2_CFD/include/solvers/CScalarSolver.inl | 33 ++++----- SU2_CFD/src/solvers/CSpeciesSolver.cpp | 70 +++++++++++++------ config_template.cfg | 2 +- 5 files changed, 75 insertions(+), 46 deletions(-) diff --git a/Common/include/option_structure.hpp b/Common/include/option_structure.hpp index c4267d7008b..dd039985aef 100644 --- a/Common/include/option_structure.hpp +++ b/Common/include/option_structure.hpp @@ -841,7 +841,7 @@ enum class UPWIND { AUSMPLUSUP, /*!< \brief AUSM+ -up numerical method (All Speed) */ AUSMPLUSUP2, /*!< \brief AUSM+ -up2 numerical method (All Speed) */ AUSMPWPLUS, /*!< \brief AUSMplus numerical method. (MAYBE for TNE2 ONLY)*/ - SCALAR_ADVECTION /*!< \brief Scalar advection numerical method. */ + BOUNDED_SCALAR /*!< \brief Scalar advection numerical method. */ }; static const MapType Upwind_Map = { MakePair("NONE", UPWIND::NONE) @@ -857,7 +857,7 @@ static const MapType Upwind_Map = { MakePair("MSW", UPWIND::MSW) MakePair("CUSP", UPWIND::CUSP) MakePair("SCALAR_UPWIND", UPWIND::SCALAR_UPWIND) - MakePair("SCALAR_ADVECTION", UPWIND::SCALAR_ADVECTION) + MakePair("BOUNDED_SCALAR", UPWIND::BOUNDED_SCALAR) MakePair("CONVECTIVE_TEMPLATE", UPWIND::CONVECTIVE_TEMPLATE) MakePair("L2ROE", UPWIND::L2ROE) MakePair("LMROE", UPWIND::LMROE) diff --git a/SU2_CFD/include/numerics/scalar/scalar_convection.hpp b/SU2_CFD/include/numerics/scalar/scalar_convection.hpp index 763da3faabe..67dccf45497 100644 --- a/SU2_CFD/include/numerics/scalar/scalar_convection.hpp +++ b/SU2_CFD/include/numerics/scalar/scalar_convection.hpp @@ -132,11 +132,13 @@ class CUpwScalar : public CNumerics { } } - - //a0 = 0.5 * (q_ij + fabs(q_ij)); - //a1 = 0.5 * (q_ij - fabs(q_ij)); - a0 = max(0.0, MassFlux); - a1 = min(0.0, MassFlux); + if(config->GetKind_Upwind_Species() == UPWIND::BOUNDED_SCALAR){ + a0 = max(0.0, MassFlux); + a1 = min(0.0, MassFlux); + }else{ + a0 = 0.5 * (q_ij + fabs(q_ij)); + a1 = 0.5 * (q_ij - fabs(q_ij)); + } FinishResidualCalc(config); diff --git a/SU2_CFD/include/solvers/CScalarSolver.inl b/SU2_CFD/include/solvers/CScalarSolver.inl index 5a09d91b642..348925c5b8e 100644 --- a/SU2_CFD/include/solvers/CScalarSolver.inl +++ b/SU2_CFD/include/solvers/CScalarSolver.inl @@ -120,19 +120,6 @@ void CScalarSolver::Upwind_Residual(CGeometry* geometry, CSolver** CNumerics** numerics_container, CConfig* config, unsigned short iMesh) { - su2double EdgeMassFlux, Project_Grad_i, Project_Grad_j, FluxCorrection_i, FluxCorrection_j; - - su2double **Jacobian_i_correction, **Jacobian_j_correction; - Jacobian_i_correction = new su2double*[nVar]; - Jacobian_j_correction = new su2double*[nVar]; - for (unsigned short iVar=0; iVarGetKind_TimeIntScheme() == EULER_IMPLICIT); @@ -163,9 +150,23 @@ void CScalarSolver::Upwind_Residual(CGeometry* geometry, CSolver** else AD::StartNoSharedReading(); - bool advection{false}; - if(config->GetKind_Upwind_Species() == UPWIND::SCALAR_ADVECTION) advection = true; + bool bounded_scalar{false}; + if(config->GetKind_Upwind_Species() == UPWIND::BOUNDED_SCALAR) bounded_scalar = true; + + su2double EdgeMassFlux, Project_Grad_i, Project_Grad_j, FluxCorrection_i, FluxCorrection_j; + + su2double **Jacobian_i_correction, **Jacobian_j_correction; + Jacobian_i_correction = new su2double*[nVar]; + Jacobian_j_correction = new su2double*[nVar]; + for (unsigned short iVar=0; iVar::Upwind_Residual(CGeometry* geometry, CSolver** } /*--- Applying convective flux correction to negate the effects of flow divergence ---*/ - if(advection){ + if(bounded_scalar){ for(iVar=0; iVarGetSolution(iPoint, iVar) * EdgeMassFlux; FluxCorrection_j = GetNodes()->GetSolution(jPoint, iVar) * EdgeMassFlux; diff --git a/SU2_CFD/src/solvers/CSpeciesSolver.cpp b/SU2_CFD/src/solvers/CSpeciesSolver.cpp index 97769cc4e7a..509cf7cf857 100644 --- a/SU2_CFD/src/solvers/CSpeciesSolver.cpp +++ b/SU2_CFD/src/solvers/CSpeciesSolver.cpp @@ -335,6 +335,8 @@ void CSpeciesSolver::BC_Inlet(CGeometry* geometry, CSolver** solver_container, C CNumerics* visc_numerics, CConfig* config, unsigned short val_marker) { string Marker_Tag = config->GetMarker_All_TagBound(val_marker); + bool bounded_scalar = (config->GetKind_Upwind_Species() == UPWIND::BOUNDED_SCALAR); + /*--- Loop over all the vertices on this boundary marker ---*/ SU2_OMP_FOR_STAT(OMP_MIN_SIZE) @@ -360,42 +362,66 @@ void CSpeciesSolver::BC_Inlet(CGeometry* geometry, CSolver** solver_container, C su2double Normal[MAXNDIM] = {0.0}; for (auto iDim = 0u; iDim < nDim; iDim++) Normal[iDim] = -geometry->vertex[val_marker][iVertex]->GetNormal(iDim); - conv_numerics->SetNormal(Normal); - /*--- Allocate the value at the inlet ---*/ + if(bounded_scalar){ - auto V_inlet = solver_container[FLOW_SOL]->GetCharacPrimVar(val_marker, iVertex); + /*--- Obtain flow velocity vector at inlet boundary node ---*/ + su2double Velocity_Inlet[MAXNDIM] = {0.0}, density_inlet, mflux_inlet; + for (auto iDim = 0u; iDim < nDim; iDim++) Velocity_Inlet[iDim] = solver_container[FLOW_SOL]->GetNodes()->GetVelocity(iPoint, iDim); + + /*--- Obtain density at inlet boundary node ---*/ + density_inlet = solver_container[FLOW_SOL]->GetNodes()->GetDensity(iPoint); - /*--- Retrieve solution at the farfield boundary node ---*/ + /*--- Compute mass flux on current node ---*/ + mflux_inlet = density_inlet * GeometryToolbox::DotProduct(nDim, Velocity_Inlet, Normal); - auto V_domain = solver_container[FLOW_SOL]->GetNodes()->GetPrimitive(iPoint); + /*--- Compute convective species residual ---*/ + su2double delta_species; + for(auto iVar = 0u; iVar < nVar; iVar++){ + delta_species = Inlet_SpeciesVars[val_marker][iVertex][iVar] - nodes->GetSolution(iPoint, iVar); + LinSysRes(iPoint, iVar) += mflux_inlet * delta_species; + } - /*--- Set various quantities in the solver class ---*/ + }else{ // bounded_scalar - conv_numerics->SetPrimitive(V_domain, V_inlet); + conv_numerics->SetNormal(Normal); - /*--- Set the species variable state at the inlet. ---*/ + /*--- Allocate the value at the inlet ---*/ - conv_numerics->SetScalarVar(nodes->GetSolution(iPoint), Inlet_SpeciesVars[val_marker][iVertex]); + auto V_inlet = solver_container[FLOW_SOL]->GetCharacPrimVar(val_marker, iVertex); - /*--- Set various other quantities in the solver class ---*/ + /*--- Retrieve solution at the farfield boundary node ---*/ - if (dynamic_grid) - conv_numerics->SetGridVel(geometry->nodes->GetGridVel(iPoint), geometry->nodes->GetGridVel(iPoint)); + auto V_domain = solver_container[FLOW_SOL]->GetNodes()->GetPrimitive(iPoint); - /* nijso: TODO we have to compute mass flux here as well */ - //su2double EdgeMassFlux = solver_container[FLOW_SOL]->GetEdgeMassFlux(iEdge); - //conv_numerics->SetMassFlux(EdgeMassFlux); + /*--- Set various quantities in the solver class ---*/ - /*--- Compute the residual using an upwind scheme ---*/ - auto residual = conv_numerics->ComputeResidual(config); - LinSysRes.AddBlock(iPoint, residual); + conv_numerics->SetPrimitive(V_domain, V_inlet); - /*--- Jacobian contribution for implicit integration ---*/ - const bool implicit = (config->GetKind_TimeIntScheme() == EULER_IMPLICIT); - if (implicit) Jacobian.AddBlock2Diag(iPoint, residual.jacobian_i); + /*--- Set the species variable state at the inlet. ---*/ + + conv_numerics->SetScalarVar(nodes->GetSolution(iPoint), Inlet_SpeciesVars[val_marker][iVertex]); + + /*--- Set various other quantities in the solver class ---*/ + + if (dynamic_grid) + conv_numerics->SetGridVel(geometry->nodes->GetGridVel(iPoint), geometry->nodes->GetGridVel(iPoint)); + + /* nijso: TODO we have to compute mass flux here as well */ + //su2double EdgeMassFlux = solver_container[FLOW_SOL]->GetEdgeMassFlux(iEdge); + //conv_numerics->SetMassFlux(EdgeMassFlux); + + /*--- Compute the residual using an upwind scheme ---*/ + auto residual = conv_numerics->ComputeResidual(config); + LinSysRes.AddBlock(iPoint, residual); + + /*--- Jacobian contribution for implicit integration ---*/ + const bool implicit = (config->GetKind_TimeIntScheme() == EULER_IMPLICIT); + if (implicit) Jacobian.AddBlock2Diag(iPoint, residual.jacobian_i); + + // Unfinished viscous contribution removed before right after d8a0da9a00. Further testing required. + } // bounded_scalar - // Unfinished viscous contribution removed before right after d8a0da9a00. Further testing required. } } END_SU2_OMP_FOR diff --git a/config_template.cfg b/config_template.cfg index 340192b61fc..a7a58b5c4ac 100644 --- a/config_template.cfg +++ b/config_template.cfg @@ -715,7 +715,7 @@ MARKER_INLET_SPECIES= (inlet, 0.5, ..., inlet2, 0.6, ...) % Use strong inlet and outlet BC in the species solver SPECIES_USE_STRONG_BC= NO % -% Convective numerical method for species transport (SCALAR_UPWIND, SCALAR_ADVECTION) +% Convective numerical method for species transport (SCALAR_UPWIND, BOUNDED_SCALAR) CONV_NUM_METHOD_SPECIES= SCALAR_UPWIND % % Monotonic Upwind Scheme for Conservation Laws (TVD) in the species equations. From 0b427c50331d3378604b3b2ab1ad4b0267c96992 Mon Sep 17 00:00:00 2001 From: Evert Date: Wed, 5 Oct 2022 13:45:39 +0200 Subject: [PATCH 21/48] Added bounded scalar conditional statements to Upwind_Residual to ensure multi-grid compatibility --- SU2_CFD/src/solvers/CEulerSolver.cpp | 7 ++++--- SU2_CFD/src/solvers/CIncEulerSolver.cpp | 13 ++++++++----- SU2_CFD/src/solvers/CIncNSSolver.cpp | 6 ++---- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/SU2_CFD/src/solvers/CEulerSolver.cpp b/SU2_CFD/src/solvers/CEulerSolver.cpp index 9379e7a8b22..bc5d5215a04 100644 --- a/SU2_CFD/src/solvers/CEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CEulerSolver.cpp @@ -339,9 +339,8 @@ CEulerSolver::CEulerSolver(CGeometry *geometry, CConfig *config, if((nDim > MAXNDIM) || (nPrimVar > MAXNVAR) || (nSecondaryVar > MAXNVAR)) SU2_MPI::Error("Oops! The CEulerSolver static array sizes are not large enough.",CURRENT_FUNCTION); - if (iMesh == MESH_0) { + if((config->GetKind_Upwind_Species() == UPWIND::BOUNDED_SCALAR) || (config->GetKind_Upwind_Turb() == UPWIND::BOUNDED_SCALAR)) EdgeMassFluxes.resize(geometry->GetnEdge()) = su2double(0.0); - } } CEulerSolver::~CEulerSolver(void) { @@ -1688,6 +1687,8 @@ void CEulerSolver::Upwind_Residual(CGeometry *geometry, CSolver **solver_contain const bool limiter = (config->GetKind_SlopeLimit_Flow() != LIMITER::NONE); const bool van_albada = (config->GetKind_SlopeLimit_Flow() == LIMITER::VAN_ALBADA_EDGE); + const bool bounded_scalar = ((config->GetKind_Upwind_Species() == UPWIND::BOUNDED_SCALAR) || + (config->GetKind_Upwind_Turb() == UPWIND::BOUNDED_SCALAR)); /*--- Non-physical counter. ---*/ unsigned long counter_local = 0; SU2_OMP_MASTER @@ -1875,7 +1876,7 @@ void CEulerSolver::Upwind_Residual(CGeometry *geometry, CSolver **solver_contain Jacobian.UpdateBlocks(iEdge, iPoint, jPoint, residual.jacobian_i, residual.jacobian_j); } - EdgeMassFluxes[iEdge] = residual.residual[0]; + if (bounded_scalar) EdgeMassFluxes[iEdge] = residual.residual[0]; /*--- Viscous contribution. ---*/ Viscous_Residual(iEdge, geometry, solver_container, diff --git a/SU2_CFD/src/solvers/CIncEulerSolver.cpp b/SU2_CFD/src/solvers/CIncEulerSolver.cpp index e2b3e4a335f..fe8f7e05c00 100644 --- a/SU2_CFD/src/solvers/CIncEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CIncEulerSolver.cpp @@ -222,6 +222,10 @@ CIncEulerSolver::CIncEulerSolver(CGeometry *geometry, CConfig *config, unsigned CommunicateInitialState(geometry, config); + /*--- Sizing edge mass flux array ---*/ + if((config->GetKind_Upwind_Species() == UPWIND::BOUNDED_SCALAR) || (config->GetKind_Upwind_Turb() == UPWIND::BOUNDED_SCALAR)) + EdgeMassFluxes.resize(geometry->GetnEdge()) = su2double(0.0); + /*--- Add the solver name (max 8 characters) ---*/ SolverName = "INC.FLOW"; @@ -1156,6 +1160,8 @@ void CIncEulerSolver::Upwind_Residual(CGeometry *geometry, CSolver **solver_cont const bool muscl = (config->GetMUSCL_Flow() && (iMesh == MESH_0)); const bool limiter = (config->GetKind_SlopeLimit_Flow() != LIMITER::NONE); const bool van_albada = (config->GetKind_SlopeLimit_Flow() == LIMITER::VAN_ALBADA_EDGE); + const bool bounded_scalar = ((config->GetKind_Upwind_Species() == UPWIND::BOUNDED_SCALAR) || + (config->GetKind_Upwind_Turb() == UPWIND::BOUNDED_SCALAR)); /*--- For hybrid parallel AD, pause preaccumulation if there is shared reading of * variables, otherwise switch to the faster adjoint evaluation mode. ---*/ @@ -1295,11 +1301,8 @@ void CIncEulerSolver::Upwind_Residual(CGeometry *geometry, CSolver **solver_cont Viscous_Residual(iEdge, geometry, solver_container, numerics_container[VISC_TERM + omp_get_thread_num()*MAX_TERMS], config); - //if (rans && (iMesh == MESH_0)) EdgeMassFluxes[iEdge] = Res_Conv[0]; - /* only when we solve additional scalars? So turbulence and species? */ - if (iMesh == MESH_0) { - EdgeMassFluxes[iEdge] = residual[0]; - } + if (bounded_scalar) EdgeMassFluxes[iEdge] = residual[0]; + } END_SU2_OMP_FOR diff --git a/SU2_CFD/src/solvers/CIncNSSolver.cpp b/SU2_CFD/src/solvers/CIncNSSolver.cpp index b6fa8669c0c..944291de084 100644 --- a/SU2_CFD/src/solvers/CIncNSSolver.cpp +++ b/SU2_CFD/src/solvers/CIncNSSolver.cpp @@ -43,11 +43,9 @@ CIncNSSolver::CIncNSSolver(CGeometry *geometry, CConfig *config, unsigned short Viscosity_Inf = config->GetViscosity_FreeStreamND(); Tke_Inf = config->GetTke_FreeStreamND(); - //if (rans && (iMesh == MESH_0)) { - // only when we solve additional scalars? - if (iMesh == MESH_0) { + /*--- Sizing edge mass flux array ---*/ + if(config->GetKind_Upwind_Species() == UPWIND::BOUNDED_SCALAR) EdgeMassFluxes.resize(geometry->GetnEdge()) = su2double(0.0); - } /*--- Initialize the secondary values for direct derivative approximations ---*/ From 97b81387d61d3a9c3b8318a9460c6342a1a56d80 Mon Sep 17 00:00:00 2001 From: Evert Date: Wed, 5 Oct 2022 15:44:13 +0200 Subject: [PATCH 22/48] Added more conditional statements regarding the scalar upwind scheme for the turbulence or species solver, fixing some of the segmentation fauts arising in the test cases --- SU2_CFD/include/solvers/CScalarSolver.hpp | 3 --- SU2_CFD/include/solvers/CScalarSolver.inl | 11 +++++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/SU2_CFD/include/solvers/CScalarSolver.hpp b/SU2_CFD/include/solvers/CScalarSolver.hpp index 4cbe9a9d99a..053f7704e04 100644 --- a/SU2_CFD/include/solvers/CScalarSolver.hpp +++ b/SU2_CFD/include/solvers/CScalarSolver.hpp @@ -112,9 +112,6 @@ class CScalarSolver : public CSolver { numerics->SetPrimitive(flowNodes->GetPrimitive(iPoint), flowNodes->GetPrimitive(jPoint)); - su2double EdgeMassFlux = solver_container[FLOW_SOL]->GetEdgeMassFlux(iEdge); - numerics->SetMassFlux(EdgeMassFlux); - /*--- Turbulent variables w/o reconstruction, and its gradients ---*/ numerics->SetScalarVar(nodes->GetSolution(iPoint), nodes->GetSolution(jPoint)); diff --git a/SU2_CFD/include/solvers/CScalarSolver.inl b/SU2_CFD/include/solvers/CScalarSolver.inl index 348925c5b8e..4233f198e30 100644 --- a/SU2_CFD/include/solvers/CScalarSolver.inl +++ b/SU2_CFD/include/solvers/CScalarSolver.inl @@ -152,7 +152,8 @@ void CScalarSolver::Upwind_Residual(CGeometry* geometry, CSolver** bool bounded_scalar{false}; - if(config->GetKind_Upwind_Species() == UPWIND::BOUNDED_SCALAR) bounded_scalar = true; + if((config->GetKind_Upwind_Species() == UPWIND::BOUNDED_SCALAR) || + (config->GetKind_Upwind_Turb() == UPWIND::BOUNDED_SCALAR)) bounded_scalar = true; su2double EdgeMassFlux, Project_Grad_i, Project_Grad_j, FluxCorrection_i, FluxCorrection_j; @@ -269,9 +270,11 @@ void CScalarSolver::Upwind_Residual(CGeometry* geometry, CSolver** } /*--- Convective flux ---*/ - EdgeMassFlux = solver_container[FLOW_SOL]->GetEdgeMassFlux(iEdge); - numerics->SetMassFlux(EdgeMassFlux); - + if(bounded_scalar){ + EdgeMassFlux = solver_container[FLOW_SOL]->GetEdgeMassFlux(iEdge); + numerics->SetMassFlux(EdgeMassFlux); + } + /*--- Update convective residual value ---*/ auto residual = numerics->ComputeResidual(config); From 56e3ca665cded960ee52a5c70e5af8f6054b63e8 Mon Sep 17 00:00:00 2001 From: Nijso Date: Wed, 5 Oct 2022 23:25:20 +0200 Subject: [PATCH 23/48] Update SU2_CFD/include/numerics/CNumerics.hpp Co-authored-by: Pedro Gomes <38071223+pcarruscag@users.noreply.github.com> --- SU2_CFD/include/numerics/CNumerics.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SU2_CFD/include/numerics/CNumerics.hpp b/SU2_CFD/include/numerics/CNumerics.hpp index 4ef6fb81bc2..7509ec90856 100644 --- a/SU2_CFD/include/numerics/CNumerics.hpp +++ b/SU2_CFD/include/numerics/CNumerics.hpp @@ -1604,7 +1604,7 @@ class CNumerics { * \brief SetMassFlux * \param[in] val_MassFlux: Mass flux across the edge */ - inline void SetMassFlux(const su2double val_MassFlux) {MassFlux = val_MassFlux;} + inline void SetMassFlux(const su2double val_MassFlux) { MassFlux = val_MassFlux; } }; From 540bd0f35a9db9df1f1ebf2af6a3f84bb094f14b Mon Sep 17 00:00:00 2001 From: Nijso Date: Wed, 5 Oct 2022 23:25:34 +0200 Subject: [PATCH 24/48] Update SU2_CFD/include/solvers/CFVMFlowSolverBase.hpp Co-authored-by: Pedro Gomes <38071223+pcarruscag@users.noreply.github.com> --- SU2_CFD/include/solvers/CFVMFlowSolverBase.hpp | 1 - 1 file changed, 1 deletion(-) diff --git a/SU2_CFD/include/solvers/CFVMFlowSolverBase.hpp b/SU2_CFD/include/solvers/CFVMFlowSolverBase.hpp index 1dd37ad7771..f2143089889 100644 --- a/SU2_CFD/include/solvers/CFVMFlowSolverBase.hpp +++ b/SU2_CFD/include/solvers/CFVMFlowSolverBase.hpp @@ -57,7 +57,6 @@ class CFVMFlowSolverBase : public CSolver { su2activevector EdgeMassFluxes; /*!< \brief Mass fluxes across each edge, for discretization of transported scalars. */ - /*! * \brief Utility to set the value of a member variables safely, and so that the new values are seen by all threads. * \param[in] lhsRhsPairs - Pairs of destination and source e.g. a,0,b,-1. From 50deb720619bd0da1dfa269794e6e8e5fe2d3a46 Mon Sep 17 00:00:00 2001 From: Nijso Date: Wed, 5 Oct 2022 23:25:52 +0200 Subject: [PATCH 25/48] Update SU2_CFD/include/solvers/CScalarSolver.inl Co-authored-by: Pedro Gomes <38071223+pcarruscag@users.noreply.github.com> --- SU2_CFD/include/solvers/CScalarSolver.inl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SU2_CFD/include/solvers/CScalarSolver.inl b/SU2_CFD/include/solvers/CScalarSolver.inl index 4233f198e30..e8f03575624 100644 --- a/SU2_CFD/include/solvers/CScalarSolver.inl +++ b/SU2_CFD/include/solvers/CScalarSolver.inl @@ -270,7 +270,7 @@ void CScalarSolver::Upwind_Residual(CGeometry* geometry, CSolver** } /*--- Convective flux ---*/ - if(bounded_scalar){ + if (bounded_scalar) { EdgeMassFlux = solver_container[FLOW_SOL]->GetEdgeMassFlux(iEdge); numerics->SetMassFlux(EdgeMassFlux); } From f6c67a05acd1aa6ff5f2e84407a4d4709dcd2f84 Mon Sep 17 00:00:00 2001 From: Nijso Date: Wed, 5 Oct 2022 23:26:34 +0200 Subject: [PATCH 26/48] Update Common/include/option_structure.hpp Co-authored-by: Pedro Gomes <38071223+pcarruscag@users.noreply.github.com> --- Common/include/option_structure.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Common/include/option_structure.hpp b/Common/include/option_structure.hpp index 5d3623f057c..bebfc4dcfa9 100644 --- a/Common/include/option_structure.hpp +++ b/Common/include/option_structure.hpp @@ -802,7 +802,7 @@ static const MapType Gust_Dir_Map = { * \brief Types of centered spatial discretizations */ enum class CENTERED { - NONE, /*!< \brief No centered scheme is used. */ + NONE, /*!< \brief No centered scheme is used. */ JST, /*!< \brief Jameson-Smith-Turkel centered numerical method. */ LAX, /*!< \brief Lax-Friedrich centered numerical method. */ JST_MAT, /*!< \brief JST with matrix dissipation. */ From 44e1e1850ada39defa7c9848c3588f832ed30c07 Mon Sep 17 00:00:00 2001 From: Nijso Date: Wed, 5 Oct 2022 23:26:41 +0200 Subject: [PATCH 27/48] Update SU2_CFD/include/numerics/scalar/scalar_convection.hpp Co-authored-by: Pedro Gomes <38071223+pcarruscag@users.noreply.github.com> --- SU2_CFD/include/numerics/scalar/scalar_convection.hpp | 1 - 1 file changed, 1 deletion(-) diff --git a/SU2_CFD/include/numerics/scalar/scalar_convection.hpp b/SU2_CFD/include/numerics/scalar/scalar_convection.hpp index 67dccf45497..f024d9b4fbd 100644 --- a/SU2_CFD/include/numerics/scalar/scalar_convection.hpp +++ b/SU2_CFD/include/numerics/scalar/scalar_convection.hpp @@ -118,7 +118,6 @@ class CUpwScalar : public CNumerics { ExtraADPreaccIn(); - su2double q_ij = 0.0; if (dynamic_grid) { for (unsigned short iDim = 0; iDim < nDim; iDim++) { From 2ad40dd8095338cab54437832b7d228504a6df47 Mon Sep 17 00:00:00 2001 From: Nijso Date: Wed, 5 Oct 2022 23:26:52 +0200 Subject: [PATCH 28/48] Update Common/include/option_structure.hpp Co-authored-by: Pedro Gomes <38071223+pcarruscag@users.noreply.github.com> --- Common/include/option_structure.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Common/include/option_structure.hpp b/Common/include/option_structure.hpp index bebfc4dcfa9..2f2ddfa9b49 100644 --- a/Common/include/option_structure.hpp +++ b/Common/include/option_structure.hpp @@ -822,7 +822,7 @@ static const MapType Centered_Map = { * \brief Types of upwind spatial discretizations */ enum class UPWIND { - NONE, /*!< \brief No upwind scheme is used. */ + NONE, /*!< \brief No upwind scheme is used. */ ROE, /*!< \brief Roe's upwind numerical method. */ SCALAR_UPWIND, /*!< \brief Scalar upwind numerical method. */ AUSM, /*!< \brief AUSM numerical method. */ From e9382b52f0a663165f99e078907a986cbd206011 Mon Sep 17 00:00:00 2001 From: Nijso Date: Thu, 13 Oct 2022 11:59:12 +0200 Subject: [PATCH 29/48] Update SU2_CFD/include/numerics/scalar/scalar_convection.hpp Co-authored-by: Pedro Gomes <38071223+pcarruscag@users.noreply.github.com> --- SU2_CFD/include/numerics/scalar/scalar_convection.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SU2_CFD/include/numerics/scalar/scalar_convection.hpp b/SU2_CFD/include/numerics/scalar/scalar_convection.hpp index f024d9b4fbd..30a6b17132e 100644 --- a/SU2_CFD/include/numerics/scalar/scalar_convection.hpp +++ b/SU2_CFD/include/numerics/scalar/scalar_convection.hpp @@ -132,8 +132,8 @@ class CUpwScalar : public CNumerics { } if(config->GetKind_Upwind_Species() == UPWIND::BOUNDED_SCALAR){ - a0 = max(0.0, MassFlux); - a1 = min(0.0, MassFlux); + a0 = max(0.0, MassFlux) / Density_i; + a1 = min(0.0, MassFlux) / Density_j; }else{ a0 = 0.5 * (q_ij + fabs(q_ij)); a1 = 0.5 * (q_ij - fabs(q_ij)); From bdfbdc806d0ee27c9d208ff81a96e1395f7a78ad Mon Sep 17 00:00:00 2001 From: EvertBunschoten Date: Thu, 13 Oct 2022 13:39:37 +0200 Subject: [PATCH 30/48] Finalized weak inlet and outlet boundary conditions for scalar solvers using the BOUNDED_SCALAR upwind method --- SU2_CFD/include/numerics/CNumerics.hpp | 13 ++ .../numerics/scalar/scalar_convection.hpp | 2 +- SU2_CFD/include/solvers/CScalarSolver.inl | 8 +- SU2_CFD/src/drivers/CDriver.cpp | 20 ++- SU2_CFD/src/solvers/CSpeciesSolver.cpp | 152 ++++++++++++------ SU2_CFD/src/solvers/CTurbSASolver.cpp | 83 ++++++++++ SU2_CFD/src/solvers/CTurbSSTSolver.cpp | 83 ++++++++++ ...pecies2_primitiveVenturi_boundedscalar.cfg | 132 +++++++++++++++ 8 files changed, 439 insertions(+), 54 deletions(-) create mode 100644 TestCases/species_transport/venturi_primitive_3species/species2_primitiveVenturi_boundedscalar.cfg diff --git a/SU2_CFD/include/numerics/CNumerics.hpp b/SU2_CFD/include/numerics/CNumerics.hpp index 7509ec90856..7f03da1468c 100644 --- a/SU2_CFD/include/numerics/CNumerics.hpp +++ b/SU2_CFD/include/numerics/CNumerics.hpp @@ -189,6 +189,8 @@ class CNumerics { bool uq_permute; /*!< \brief Flag for eigenvector permutation */ bool nemo; /*!< \brief Flag for NEMO problems */ + + bool bounded_scalar = false; /*!< \brief Flag for bounded scalar problem */ public: /*! @@ -1606,6 +1608,17 @@ class CNumerics { */ inline void SetMassFlux(const su2double val_MassFlux) { MassFlux = val_MassFlux; } + /*! + * \brief Set bounded scalar transport problem + * \param[in] is_bounded_scalar : scalar solver uses bounded scalar convective transport + */ + inline void SetBoundedScalar(const bool is_bounded_scalar) {bounded_scalar = is_bounded_scalar; } + + /*! + * \brief Obtain information on bounded scalar problem + * \return is_bounded_scalar : scalar solver uses bounded scalar convective transport + */ + inline bool GetBoundedScalar() const {return bounded_scalar;} }; /*! diff --git a/SU2_CFD/include/numerics/scalar/scalar_convection.hpp b/SU2_CFD/include/numerics/scalar/scalar_convection.hpp index f024d9b4fbd..90569ba2b9e 100644 --- a/SU2_CFD/include/numerics/scalar/scalar_convection.hpp +++ b/SU2_CFD/include/numerics/scalar/scalar_convection.hpp @@ -131,7 +131,7 @@ class CUpwScalar : public CNumerics { } } - if(config->GetKind_Upwind_Species() == UPWIND::BOUNDED_SCALAR){ + if(bounded_scalar){ a0 = max(0.0, MassFlux); a1 = min(0.0, MassFlux); }else{ diff --git a/SU2_CFD/include/solvers/CScalarSolver.inl b/SU2_CFD/include/solvers/CScalarSolver.inl index e8f03575624..035be87b1dd 100644 --- a/SU2_CFD/include/solvers/CScalarSolver.inl +++ b/SU2_CFD/include/solvers/CScalarSolver.inl @@ -138,6 +138,9 @@ void CScalarSolver::Upwind_Residual(CGeometry* geometry, CSolver** /*--- Pick one numerics object per thread. ---*/ auto* numerics = numerics_container[CONV_TERM + omp_get_thread_num() * MAX_TERMS]; + /*--- Apply scalar advection correction terms for bounded scalar problems ---*/ + const bool bounded_scalar = numerics->GetBoundedScalar(); + /*--- Static arrays of MUSCL-reconstructed flow primitives and turbulence variables (thread safety). ---*/ su2double solution_i[MAXNVAR] = {0.0}, flowPrimVar_i[MAXNVARFLOW] = {0.0}; su2double solution_j[MAXNVAR] = {0.0}, flowPrimVar_j[MAXNVARFLOW] = {0.0}; @@ -150,11 +153,6 @@ void CScalarSolver::Upwind_Residual(CGeometry* geometry, CSolver** else AD::StartNoSharedReading(); - - bool bounded_scalar{false}; - if((config->GetKind_Upwind_Species() == UPWIND::BOUNDED_SCALAR) || - (config->GetKind_Upwind_Turb() == UPWIND::BOUNDED_SCALAR)) bounded_scalar = true; - su2double EdgeMassFlux, Project_Grad_i, Project_Grad_j, FluxCorrection_i, FluxCorrection_j; su2double **Jacobian_i_correction, **Jacobian_j_correction; diff --git a/SU2_CFD/src/drivers/CDriver.cpp b/SU2_CFD/src/drivers/CDriver.cpp index 0c9b45ed024..0794ca8fcd4 100644 --- a/SU2_CFD/src/drivers/CDriver.cpp +++ b/SU2_CFD/src/drivers/CDriver.cpp @@ -1266,6 +1266,11 @@ void CDriver::InstantiateTurbulentNumerics(unsigned short nVar_Turb, int offset, } else if (menter_sst) numerics[iMGlevel][TURB_SOL][conv_term] = new CUpwSca_TurbSST(nDim, nVar_Turb, config); + + /*--- Define bounded turbulent scalar problem ---*/ + if(config->GetKind_Upwind_Turb() == UPWIND::BOUNDED_SCALAR){ + numerics[iMGlevel][TURB_SOL][conv_term]->SetBoundedScalar(true); + }else numerics[iMGlevel][TURB_SOL][conv_term]->SetBoundedScalar(false); } break; default: @@ -1318,7 +1323,11 @@ void CDriver::InstantiateTurbulentNumerics(unsigned short nVar_Turb, int offset, numerics[iMGlevel][TURB_SOL][visc_bound_term] = new CAvgGrad_TurbSST(nDim, nVar_Turb, constants, false, config); } - } + + if(config->GetKind_Upwind_Turb() == UPWIND::BOUNDED_SCALAR){ + numerics[iMGlevel][TURB_SOL][conv_bound_term]->SetBoundedScalar(true); + }else numerics[iMGlevel][TURB_SOL][conv_bound_term]->SetBoundedScalar(false); + } } /*--- Explicit instantiation of the template above, needed because it is defined in a cpp file, instead of hpp. ---*/ template void CDriver::InstantiateTurbulentNumerics>( @@ -1350,7 +1359,16 @@ void CDriver::InstantiateSpeciesNumerics(unsigned short nVar_Species, int offset case SPACE_UPWIND : for (auto iMGlevel = 0; iMGlevel <= config->GetnMGLevels(); iMGlevel++) { numerics[iMGlevel][SPECIES_SOL][conv_term] = new CUpwSca_Species(nDim, nVar_Species, config); + if(config->GetKind_Upwind_Species() == UPWIND::BOUNDED_SCALAR){ + numerics[iMGlevel][SPECIES_SOL][conv_term]->SetBoundedScalar(true); + }else numerics[iMGlevel][SPECIES_SOL][conv_term]->SetBoundedScalar(false); + numerics[iMGlevel][SPECIES_SOL][conv_bound_term] = new CUpwSca_Species(nDim, nVar_Species, config); + + /*--- Define bounded scalar problem ---*/ + if(config->GetKind_Upwind_Species() == UPWIND::BOUNDED_SCALAR){ + numerics[iMGlevel][SPECIES_SOL][conv_bound_term]->SetBoundedScalar(true); + }else numerics[iMGlevel][SPECIES_SOL][conv_bound_term]->SetBoundedScalar(false); } break; default : diff --git a/SU2_CFD/src/solvers/CSpeciesSolver.cpp b/SU2_CFD/src/solvers/CSpeciesSolver.cpp index 3df6bee82e3..988cce1f201 100644 --- a/SU2_CFD/src/solvers/CSpeciesSolver.cpp +++ b/SU2_CFD/src/solvers/CSpeciesSolver.cpp @@ -335,7 +335,18 @@ void CSpeciesSolver::BC_Inlet(CGeometry* geometry, CSolver** solver_container, C CNumerics* visc_numerics, CConfig* config, unsigned short val_marker) { string Marker_Tag = config->GetMarker_All_TagBound(val_marker); - bool bounded_scalar = (config->GetKind_Upwind_Species() == UPWIND::BOUNDED_SCALAR); + /*--- Bounded scalar problem ---*/ + bool bounded_scalar = conv_numerics->GetBoundedScalar(); + + su2double EdgeMassFlux; + su2double **Jacobian_i_correction; + Jacobian_i_correction = new su2double*[nVar]; + for (unsigned short iVar=0; iVarvertex[val_marker][iVertex]->GetNormal(iDim); - if(bounded_scalar){ - - /*--- Obtain flow velocity vector at inlet boundary node ---*/ - su2double Velocity_Inlet[MAXNDIM] = {0.0}, density_inlet, mflux_inlet; - for (auto iDim = 0u; iDim < nDim; iDim++) Velocity_Inlet[iDim] = solver_container[FLOW_SOL]->GetNodes()->GetVelocity(iPoint, iDim); - - /*--- Obtain density at inlet boundary node ---*/ - density_inlet = solver_container[FLOW_SOL]->GetNodes()->GetDensity(iPoint); - /*--- Compute mass flux on current node ---*/ - mflux_inlet = density_inlet * GeometryToolbox::DotProduct(nDim, Velocity_Inlet, Normal); + conv_numerics->SetNormal(Normal); - /*--- Compute convective species residual ---*/ - su2double delta_species; - for(auto iVar = 0u; iVar < nVar; iVar++){ - delta_species = Inlet_SpeciesVars[val_marker][iVertex][iVar] - nodes->GetSolution(iPoint, iVar); - LinSysRes(iPoint, iVar) += mflux_inlet * delta_species; - } + /*--- Allocate the value at the inlet ---*/ - }else{ // bounded_scalar + auto V_inlet = solver_container[FLOW_SOL]->GetCharacPrimVar(val_marker, iVertex); - conv_numerics->SetNormal(Normal); + /*--- Retrieve solution at the farfield boundary node ---*/ - /*--- Allocate the value at the inlet ---*/ + auto V_domain = solver_container[FLOW_SOL]->GetNodes()->GetPrimitive(iPoint); - auto V_inlet = solver_container[FLOW_SOL]->GetCharacPrimVar(val_marker, iVertex); + /*--- Set various quantities in the solver class ---*/ - /*--- Retrieve solution at the farfield boundary node ---*/ + conv_numerics->SetPrimitive(V_domain, V_inlet); - auto V_domain = solver_container[FLOW_SOL]->GetNodes()->GetPrimitive(iPoint); + /*--- Set the species variable state at the inlet. ---*/ - /*--- Set various quantities in the solver class ---*/ + conv_numerics->SetScalarVar(nodes->GetSolution(iPoint), Inlet_SpeciesVars[val_marker][iVertex]); - conv_numerics->SetPrimitive(V_domain, V_inlet); + /*--- Set various other quantities in the solver class ---*/ - /*--- Set the species variable state at the inlet. ---*/ + if (dynamic_grid) + conv_numerics->SetGridVel(geometry->nodes->GetGridVel(iPoint), geometry->nodes->GetGridVel(iPoint)); - conv_numerics->SetScalarVar(nodes->GetSolution(iPoint), Inlet_SpeciesVars[val_marker][iVertex]); + if(bounded_scalar){ + /*--- Obtain flow velocity vector at inlet boundary node ---*/ + su2double Velocity_Inlet[MAXNDIM] = {0.0}, density_inlet; + for (auto iDim = 0u; iDim < nDim; iDim++) Velocity_Inlet[iDim] = solver_container[FLOW_SOL]->GetNodes()->GetVelocity(iPoint, iDim); + + /*--- Obtain density at inlet boundary node ---*/ + density_inlet = solver_container[FLOW_SOL]->GetNodes()->GetDensity(iPoint); - /*--- Set various other quantities in the solver class ---*/ + /*--- Compute mass flux on current node ---*/ + EdgeMassFlux = density_inlet * GeometryToolbox::DotProduct(nDim, Velocity_Inlet, Normal); + + /*--- Communicate inlet mass flux to numerics ---*/ + conv_numerics->SetMassFlux(EdgeMassFlux); + } - if (dynamic_grid) - conv_numerics->SetGridVel(geometry->nodes->GetGridVel(iPoint), geometry->nodes->GetGridVel(iPoint)); + /*--- Compute the residual using an upwind scheme ---*/ + auto residual = conv_numerics->ComputeResidual(config); + LinSysRes.AddBlock(iPoint, residual); - /* nijso: TODO we have to compute mass flux here as well */ - //su2double EdgeMassFlux = solver_container[FLOW_SOL]->GetEdgeMassFlux(iEdge); - //conv_numerics->SetMassFlux(EdgeMassFlux); + /*--- Jacobian contribution for implicit integration ---*/ + const bool implicit = (config->GetKind_TimeIntScheme() == EULER_IMPLICIT); + if (implicit) Jacobian.AddBlock2Diag(iPoint, residual.jacobian_i); - /*--- Compute the residual using an upwind scheme ---*/ - auto residual = conv_numerics->ComputeResidual(config); - LinSysRes.AddBlock(iPoint, residual); + /*--- Applying convective flux correction to negate the effects of flow divergence ---*/ + if(bounded_scalar){ + for(unsigned short iVar=0; iVarGetSolution(iPoint, iVar) * EdgeMassFlux; - /*--- Jacobian contribution for implicit integration ---*/ - const bool implicit = (config->GetKind_TimeIntScheme() == EULER_IMPLICIT); - if (implicit) Jacobian.AddBlock2Diag(iPoint, residual.jacobian_i); + LinSysRes(iPoint, iVar) -= FluxCorrection_i; + Jacobian_i_correction[iVar][iVar] = max(0.0, EdgeMassFlux); + } + }if (implicit) Jacobian.AddBlock2Diag(iPoint, Jacobian_i_correction); - // Unfinished viscous contribution removed before right after d8a0da9a00. Further testing required. - } // bounded_scalar + // Unfinished viscous contribution removed before right after d8a0da9a00. Further testing required. } } END_SU2_OMP_FOR + + /*--- Delete jacobian correction variable ---*/ + for (unsigned short iVar=0; iVarGetBoundedScalar(); + su2double EdgeMassFlux; + su2double **Jacobian_i_correction; + Jacobian_i_correction = new su2double*[nVar]; + for (unsigned short iVar=0; iVarGetCharacPrimVar(val_marker, iVertex); /*--- Retrieve solution at the farfield boundary node ---*/ @@ -543,8 +574,8 @@ void CSpeciesSolver::BC_Outlet(CGeometry* geometry, CSolver** solver_container, conv_numerics->SetPrimitive(V_domain, V_outlet); /*--- Set the species variables. Here we use a Neumann BC such - that the species variable is copied from the interior of the - domain to the outlet before computing the residual. ---*/ + that the species variable is copied from the interior of the + domain to the outlet before computing the residual. ---*/ conv_numerics->SetScalarVar(nodes->GetSolution(iPoint), nodes->GetSolution(iPoint)); @@ -557,9 +588,19 @@ void CSpeciesSolver::BC_Outlet(CGeometry* geometry, CSolver** solver_container, if (dynamic_grid) conv_numerics->SetGridVel(geometry->nodes->GetGridVel(iPoint), geometry->nodes->GetGridVel(iPoint)); - /* nijso: TODO we have to compute mass flux here as well */ - //su2double EdgeMassFlux = solver_container[FLOW_SOL]->GetEdgeMassFlux(iEdge); - //conv_numerics->SetMassFlux(EdgeMassFlux); + if(bounded_scalar){ + /*--- Obtain flow velocity vector at inlet boundary node ---*/ + su2double Velocity_Outlet[MAXNDIM] = {0.0}, density_outlet; + for (auto iDim = 0u; iDim < nDim; iDim++) Velocity_Outlet[iDim] = solver_container[FLOW_SOL]->GetNodes()->GetVelocity(iPoint, iDim); + + /*--- Obtain density at inlet boundary node ---*/ + density_outlet = solver_container[FLOW_SOL]->GetNodes()->GetDensity(iPoint); + + /*--- Compute mass flux on current node ---*/ + EdgeMassFlux = density_outlet * GeometryToolbox::DotProduct(nDim, Velocity_Outlet, Normal); + + conv_numerics->SetMassFlux(EdgeMassFlux); + } /*--- Compute the residual using an upwind scheme ---*/ auto residual = conv_numerics->ComputeResidual(config); @@ -569,8 +610,25 @@ void CSpeciesSolver::BC_Outlet(CGeometry* geometry, CSolver** solver_container, const bool implicit = (config->GetKind_TimeIntScheme() == EULER_IMPLICIT); if (implicit) Jacobian.AddBlock2Diag(iPoint, residual.jacobian_i); + /*--- Applying convective flux correction to negate the effects of flow divergence ---*/ + if(bounded_scalar){ + for(unsigned short iVar=0; iVarGetSolution(iPoint, iVar) * EdgeMassFlux; + + LinSysRes(iPoint, iVar) -= FluxCorrection_i; + Jacobian_i_correction[iVar][iVar] = max(0.0, EdgeMassFlux); + } + }if (implicit) Jacobian.AddBlock2Diag(iPoint, Jacobian_i_correction); + // Unfinished viscous contribution removed before right after d8a0da9a00. Further testing required. + } } END_SU2_OMP_FOR + + for (unsigned short iVar=0; iVarGetKind_TimeIntScheme() == EULER_IMPLICIT); + /*--- Bounded scalar problem ---*/ + bool bounded_scalar = conv_numerics->GetBoundedScalar(); + + su2double EdgeMassFlux; + su2double **Jacobian_i_correction; + Jacobian_i_correction = new su2double*[nVar]; + for (unsigned short iVar=0; iVarSetGridVel(geometry->nodes->GetGridVel(iPoint), geometry->nodes->GetGridVel(iPoint)); + if(bounded_scalar){ + /*--- Obtain flow velocity vector at inlet boundary node ---*/ + su2double Velocity_Inlet[MAXNDIM] = {0.0}, density_inlet; + for (auto iDim = 0u; iDim < nDim; iDim++) Velocity_Inlet[iDim] = solver_container[FLOW_SOL]->GetNodes()->GetVelocity(iPoint, iDim); + + /*--- Obtain density at inlet boundary node ---*/ + density_inlet = solver_container[FLOW_SOL]->GetNodes()->GetDensity(iPoint); + + /*--- Compute mass flux on current node ---*/ + EdgeMassFlux = density_inlet * GeometryToolbox::DotProduct(nDim, Velocity_Inlet, Normal); + + /*--- Communicate inlet mass flux to numerics ---*/ + conv_numerics->SetMassFlux(EdgeMassFlux); + } + /*--- Compute the residual using an upwind scheme ---*/ auto residual = conv_numerics->ComputeResidual(config); @@ -581,6 +609,16 @@ void CTurbSASolver::BC_Inlet(CGeometry *geometry, CSolver **solver_container, CN if (implicit) Jacobian.AddBlock2Diag(iPoint, residual.jacobian_i); + /*--- Applying convective flux correction to negate the effects of flow divergence ---*/ + if(bounded_scalar){ + for(unsigned short iVar=0; iVarGetSolution(iPoint, iVar) * EdgeMassFlux; + + LinSysRes(iPoint, iVar) -= FluxCorrection_i; + Jacobian_i_correction[iVar][iVar] = max(0.0, EdgeMassFlux); + } + }if (implicit) Jacobian.AddBlock2Diag(iPoint, Jacobian_i_correction); + // /*--- Viscous contribution, commented out because serious convergence problems ---*/ // // su2double Coord_Reflected[MAXNDIM]; @@ -611,11 +649,27 @@ void CTurbSASolver::BC_Inlet(CGeometry *geometry, CSolver **solver_container, CN } END_SU2_OMP_FOR + /*--- Delete jacobian correction variable ---*/ + for (unsigned short iVar=0; iVarGetBoundedScalar(); + su2double EdgeMassFlux; + su2double **Jacobian_i_correction; + Jacobian_i_correction = new su2double*[nVar]; + for (unsigned short iVar=0; iVarGetKind_TimeIntScheme() == EULER_IMPLICIT); /*--- Loop over all the vertices on this boundary marker ---*/ @@ -658,6 +712,20 @@ void CTurbSASolver::BC_Outlet(CGeometry *geometry, CSolver **solver_container, C conv_numerics->SetGridVel(geometry->nodes->GetGridVel(iPoint), geometry->nodes->GetGridVel(iPoint)); + if(bounded_scalar){ + /*--- Obtain flow velocity vector at inlet boundary node ---*/ + su2double Velocity_Outlet[MAXNDIM] = {0.0}, density_outlet; + for (auto iDim = 0u; iDim < nDim; iDim++) Velocity_Outlet[iDim] = solver_container[FLOW_SOL]->GetNodes()->GetVelocity(iPoint, iDim); + + /*--- Obtain density at inlet boundary node ---*/ + density_outlet = solver_container[FLOW_SOL]->GetNodes()->GetDensity(iPoint); + + /*--- Compute mass flux on current node ---*/ + EdgeMassFlux = density_outlet * GeometryToolbox::DotProduct(nDim, Velocity_Outlet, Normal); + + conv_numerics->SetMassFlux(EdgeMassFlux); + } + /*--- Compute the residual using an upwind scheme ---*/ auto residual = conv_numerics->ComputeResidual(config); @@ -667,6 +735,16 @@ void CTurbSASolver::BC_Outlet(CGeometry *geometry, CSolver **solver_container, C if (implicit) Jacobian.AddBlock2Diag(iPoint, residual.jacobian_i); + /*--- Applying convective flux correction to negate the effects of flow divergence ---*/ + if(bounded_scalar){ + for(unsigned short iVar=0; iVarGetSolution(iPoint, iVar) * EdgeMassFlux; + + LinSysRes(iPoint, iVar) -= FluxCorrection_i; + Jacobian_i_correction[iVar][iVar] = max(0.0, EdgeMassFlux); + } + }if (implicit) Jacobian.AddBlock2Diag(iPoint, Jacobian_i_correction); + // /*--- Viscous contribution, commented out because serious convergence problems ---*/ // // su2double Coord_Reflected[MAXNDIM]; @@ -697,6 +775,11 @@ void CTurbSASolver::BC_Outlet(CGeometry *geometry, CSolver **solver_container, C } END_SU2_OMP_FOR + /*--- Delete jacobian correction variable ---*/ + for (unsigned short iVar=0; iVarGetKind_TimeIntScheme() == EULER_IMPLICIT); + /*--- Bounded scalar problem ---*/ + bool bounded_scalar = conv_numerics->GetBoundedScalar(); + + su2double EdgeMassFlux; + su2double **Jacobian_i_correction; + Jacobian_i_correction = new su2double*[nVar]; + for (unsigned short iVar=0; iVarSetGridVel(geometry->nodes->GetGridVel(iPoint), geometry->nodes->GetGridVel(iPoint)); + if(bounded_scalar){ + /*--- Obtain flow velocity vector at inlet boundary node ---*/ + su2double Velocity_Inlet[MAXNDIM] = {0.0}, density_inlet; + for (auto iDim = 0u; iDim < nDim; iDim++) Velocity_Inlet[iDim] = solver_container[FLOW_SOL]->GetNodes()->GetVelocity(iPoint, iDim); + + /*--- Obtain density at inlet boundary node ---*/ + density_inlet = solver_container[FLOW_SOL]->GetNodes()->GetDensity(iPoint); + + /*--- Compute mass flux on current node ---*/ + EdgeMassFlux = density_inlet * GeometryToolbox::DotProduct(nDim, Velocity_Inlet, Normal); + + /*--- Communicate inlet mass flux to numerics ---*/ + conv_numerics->SetMassFlux(EdgeMassFlux); + } + /*--- Compute the residual using an upwind scheme ---*/ auto residual = conv_numerics->ComputeResidual(config); @@ -631,6 +659,16 @@ void CTurbSSTSolver::BC_Inlet(CGeometry *geometry, CSolver **solver_container, C if (implicit) Jacobian.AddBlock2Diag(iPoint, residual.jacobian_i); + /*--- Applying convective flux correction to negate the effects of flow divergence ---*/ + if(bounded_scalar){ + for(unsigned short iVar=0; iVarGetSolution(iPoint, iVar) * EdgeMassFlux; + + LinSysRes(iPoint, iVar) -= FluxCorrection_i; + Jacobian_i_correction[iVar][iVar] = max(0.0, EdgeMassFlux); + } + }if (implicit) Jacobian.AddBlock2Diag(iPoint, Jacobian_i_correction); + // /*--- Viscous contribution, commented out because serious convergence problems ---*/ // // su2double Coord_Reflected[MAXNDIM]; @@ -666,6 +704,12 @@ void CTurbSSTSolver::BC_Inlet(CGeometry *geometry, CSolver **solver_container, C } END_SU2_OMP_FOR + /*--- Delete jacobian correction variable ---*/ + for (unsigned short iVar=0; iVarGetKind_TimeIntScheme() == EULER_IMPLICIT); + const bool bounded_scalar = conv_numerics->GetBoundedScalar(); + su2double EdgeMassFlux; + su2double **Jacobian_i_correction; + Jacobian_i_correction = new su2double*[nVar]; + for (unsigned short iVar=0; iVarSetGridVel(geometry->nodes->GetGridVel(iPoint), geometry->nodes->GetGridVel(iPoint)); + if(bounded_scalar){ + /*--- Obtain flow velocity vector at inlet boundary node ---*/ + su2double Velocity_Outlet[MAXNDIM] = {0.0}, density_outlet; + for (auto iDim = 0u; iDim < nDim; iDim++) Velocity_Outlet[iDim] = solver_container[FLOW_SOL]->GetNodes()->GetVelocity(iPoint, iDim); + + /*--- Obtain density at inlet boundary node ---*/ + density_outlet = solver_container[FLOW_SOL]->GetNodes()->GetDensity(iPoint); + + /*--- Compute mass flux on current node ---*/ + EdgeMassFlux = density_outlet * GeometryToolbox::DotProduct(nDim, Velocity_Outlet, Normal); + + conv_numerics->SetMassFlux(EdgeMassFlux); + } + /*--- Compute the residual using an upwind scheme ---*/ auto residual = conv_numerics->ComputeResidual(config); @@ -723,6 +792,16 @@ void CTurbSSTSolver::BC_Outlet(CGeometry *geometry, CSolver **solver_container, if (implicit) Jacobian.AddBlock2Diag(iPoint, residual.jacobian_i); + /*--- Applying convective flux correction to negate the effects of flow divergence ---*/ + if(bounded_scalar){ + for(unsigned short iVar=0; iVarGetSolution(iPoint, iVar) * EdgeMassFlux; + + LinSysRes(iPoint, iVar) -= FluxCorrection_i; + Jacobian_i_correction[iVar][iVar] = max(0.0, EdgeMassFlux); + } + }if (implicit) Jacobian.AddBlock2Diag(iPoint, Jacobian_i_correction); + // /*--- Viscous contribution, commented out because serious convergence problems ---*/ // // su2double Coord_Reflected[MAXNDIM]; @@ -757,6 +836,10 @@ void CTurbSSTSolver::BC_Outlet(CGeometry *geometry, CSolver **solver_container, } END_SU2_OMP_FOR + for (unsigned short iVar=0; iVar Date: Thu, 13 Oct 2022 13:58:09 +0200 Subject: [PATCH 31/48] Initialized the edge flux variable in the inlet and outlet boundary conditions for the scalar solvers --- SU2_CFD/src/solvers/CSpeciesSolver.cpp | 4 ++-- SU2_CFD/src/solvers/CTurbSASolver.cpp | 4 ++-- SU2_CFD/src/solvers/CTurbSSTSolver.cpp | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/SU2_CFD/src/solvers/CSpeciesSolver.cpp b/SU2_CFD/src/solvers/CSpeciesSolver.cpp index 18dec4940b5..f7992647566 100644 --- a/SU2_CFD/src/solvers/CSpeciesSolver.cpp +++ b/SU2_CFD/src/solvers/CSpeciesSolver.cpp @@ -338,7 +338,7 @@ void CSpeciesSolver::BC_Inlet(CGeometry* geometry, CSolver** solver_container, C /*--- Bounded scalar problem ---*/ bool bounded_scalar = conv_numerics->GetBoundedScalar(); - su2double EdgeMassFlux; + su2double EdgeMassFlux = 0.0; su2double **Jacobian_i_correction; Jacobian_i_correction = new su2double*[nVar]; for (unsigned short iVar=0; iVarGetBoundedScalar(); - su2double EdgeMassFlux; + su2double EdgeMassFlux = 0.0; su2double **Jacobian_i_correction; Jacobian_i_correction = new su2double*[nVar]; for (unsigned short iVar=0; iVarGetBoundedScalar(); - su2double EdgeMassFlux; + su2double EdgeMassFlux = 0.0; su2double **Jacobian_i_correction; Jacobian_i_correction = new su2double*[nVar]; for (unsigned short iVar=0; iVarGetBoundedScalar(); - su2double EdgeMassFlux; + su2double EdgeMassFlux = 0.0; su2double **Jacobian_i_correction; Jacobian_i_correction = new su2double*[nVar]; for (unsigned short iVar=0; iVarGetBoundedScalar(); - su2double EdgeMassFlux; + su2double EdgeMassFlux = 0.0; su2double **Jacobian_i_correction; Jacobian_i_correction = new su2double*[nVar]; for (unsigned short iVar=0; iVarGetKind_TimeIntScheme() == EULER_IMPLICIT); const bool bounded_scalar = conv_numerics->GetBoundedScalar(); - su2double EdgeMassFlux; + su2double EdgeMassFlux = 0.0; su2double **Jacobian_i_correction; Jacobian_i_correction = new su2double*[nVar]; for (unsigned short iVar=0; iVar Date: Fri, 14 Oct 2022 10:42:04 +0200 Subject: [PATCH 32/48] Fixed units issue with the density in the flux calculation of the species and SST convection numerics classes --- .../numerics/species/species_convection.hpp | 21 ++++++++++---- .../numerics/turbulent/turb_convection.hpp | 29 ++++++++++++++----- 2 files changed, 37 insertions(+), 13 deletions(-) diff --git a/SU2_CFD/include/numerics/species/species_convection.hpp b/SU2_CFD/include/numerics/species/species_convection.hpp index f71f78ef38e..8f906291210 100644 --- a/SU2_CFD/include/numerics/species/species_convection.hpp +++ b/SU2_CFD/include/numerics/species/species_convection.hpp @@ -51,6 +51,7 @@ class CUpwSca_Species final : public CUpwScalar { using Base::ScalarVar_i; using Base::ScalarVar_j; using Base::idx; + using Base::bounded_scalar; /*! * \brief Adds any extra variables to AD @@ -66,12 +67,22 @@ class CUpwSca_Species final : public CUpwScalar { */ void FinishResidualCalc(const CConfig* config) override { for (auto iVar = 0u; iVar < nVar; iVar++) { - Flux[iVar] = a0 * ScalarVar_i[iVar] + a1 * ScalarVar_j[iVar]; + if(bounded_scalar){ + Flux[iVar] = a0 * ScalarVar_i[iVar] + a1 * ScalarVar_j[iVar]; - /*--- Jacobians are taken wrt rho*Y not Y alone in the species solver. ---*/ - /*--- Off-diagonal entries are zero. ---*/ - Jacobian_i[iVar][iVar] = a0; - Jacobian_j[iVar][iVar] = a1; + /*--- Jacobians are taken wrt rho*Y not Y alone in the species solver. ---*/ + /*--- Off-diagonal entries are zero. ---*/ + Jacobian_i[iVar][iVar] = a0; + Jacobian_j[iVar][iVar] = a1; + }else{ + Flux[iVar] = a0 * V_i[idx.Density()] * ScalarVar_i[iVar] + a1 * V_j[idx.Density()] * ScalarVar_j[iVar]; + + /*--- Jacobians are taken wrt rho*Y not Y alone in the species solver. ---*/ + /*--- Off-diagonal entries are zero. ---*/ + Jacobian_i[iVar][iVar] = a0; + Jacobian_j[iVar][iVar] = a1; + } + } // iVar } diff --git a/SU2_CFD/include/numerics/turbulent/turb_convection.hpp b/SU2_CFD/include/numerics/turbulent/turb_convection.hpp index b107cdff54a..0b73f79268e 100644 --- a/SU2_CFD/include/numerics/turbulent/turb_convection.hpp +++ b/SU2_CFD/include/numerics/turbulent/turb_convection.hpp @@ -100,7 +100,7 @@ class CUpwSca_TurbSST final : public CUpwScalar { using Base::ScalarVar_j; using Base::implicit; using Base::idx; - + using Base::bounded_scalar; /*! * \brief Adds any extra variables to AD */ @@ -114,15 +114,28 @@ class CUpwSca_TurbSST final : public CUpwScalar { * \param[in] config - Definition of the particular problem. */ void FinishResidualCalc(const CConfig* config) override { - Flux[0] = a0*V_i[idx.Density()]*ScalarVar_i[0] + a1*V_j[idx.Density()]*ScalarVar_j[0]; - Flux[1] = a0*V_i[idx.Density()]*ScalarVar_i[1] + a1*V_j[idx.Density()]*ScalarVar_j[1]; - + if(bounded_scalar){ + Flux[0] = a0*ScalarVar_i[0] + a1*ScalarVar_j[0]; + Flux[1] = a0*ScalarVar_i[1] + a1*ScalarVar_j[1]; + }else{ + Flux[0] = a0*V_i[idx.Density()]*ScalarVar_i[0] + a1*V_j[idx.Density()]*ScalarVar_j[0]; + Flux[1] = a0*V_i[idx.Density()]*ScalarVar_i[1] + a1*V_j[idx.Density()]*ScalarVar_j[1]; + } if (implicit) { - Jacobian_i[0][0] = a0; Jacobian_i[0][1] = 0.0; - Jacobian_i[1][0] = 0.0; Jacobian_i[1][1] = a0; + if(bounded_scalar){ + Jacobian_i[0][0] = a0/V_i[idx.Density()]; Jacobian_i[0][1] = 0.0; + Jacobian_i[1][0] = 0.0; Jacobian_i[1][1] = a0/V_i[idx.Density()]; + + Jacobian_j[0][0] = a1/V_j[idx.Density()]*ScalarVar_j[0]; Jacobian_j[0][1] = 0.0; + Jacobian_j[1][0] = 0.0; Jacobian_j[1][1] = a1/V_j[idx.Density()]*ScalarVar_j[0]; + }else{ + Jacobian_i[0][0] = a0; Jacobian_i[0][1] = 0.0; + Jacobian_i[1][0] = 0.0; Jacobian_i[1][1] = a0; - Jacobian_j[0][0] = a1; Jacobian_j[0][1] = 0.0; - Jacobian_j[1][0] = 0.0; Jacobian_j[1][1] = a1; + Jacobian_j[0][0] = a1; Jacobian_j[0][1] = 0.0; + Jacobian_j[1][0] = 0.0; Jacobian_j[1][1] = a1; + } + } } From 7d3b4b054c69df130f600e22c347ba299d42d2bc Mon Sep 17 00:00:00 2001 From: EvertBunschoten Date: Fri, 14 Oct 2022 11:56:04 +0200 Subject: [PATCH 33/48] Added BOUNDED_SCALAR test cases under parallel regression for both constant density and species mixing model --- TestCases/parallel_regression.py | 18 +++ ...itiveVenturi_mixingmodel_boundedscalar.cfg | 142 ++++++++++++++++++ 2 files changed, 160 insertions(+) create mode 100644 TestCases/species_transport/venturi_primitive_3species/species2_primitiveVenturi_mixingmodel_boundedscalar.cfg diff --git a/TestCases/parallel_regression.py b/TestCases/parallel_regression.py index 87b77b8e87d..8ca373f94bd 100644 --- a/TestCases/parallel_regression.py +++ b/TestCases/parallel_regression.py @@ -1344,6 +1344,15 @@ def main(): species2_primitiveVenturi_mixingmodel.new_output = True test_list.append(species2_primitiveVenturi_mixingmodel) + # 2 species (1 eq) primitive venturi mixing using mixing model and bounded scalar transport + species2_primitiveVenturi_mixingmodel_boundedscalar = TestCase('species2_primitiveVenturi_mixingmodel_boundedscalar') + species2_primitiveVenturi_mixingmodel_boundedscalar.cfg_dir = "species_transport/venturi_primitive_3species" + species2_primitiveVenturi_mixingmodel_boundedscalar.cfg_file = "species2_primitiveVenturi_mixingmodel_boundedscalar.cfg" + species2_primitiveVenturi_mixingmodel_boundedscalar.test_iter = 50 + species2_primitiveVenturi_mixingmodel_boundedscalar.test_vals = [-5.373927, -4.466593, -4.463893, -5.860614, -0.161944, -5.711591, 5.000000, -1.877285, 5.000000, -4.712579, 5.000000, -1.784465, 0.000211, 0.000211, 0.000000, 0.000000] + species2_primitiveVenturi_mixingmodel_boundedscalar.new_output = True + test_list.append(species2_primitiveVenturi_mixingmodel_boundedscalar) + # 2 species (1 eq) primitive venturi mixing using mixing model including viscosity and thermal conductivity species2_primitiveVenturi_mixingmodel_viscosity = TestCase('species2_primitiveVenturi_mixingmodel_viscosity') species2_primitiveVenturi_mixingmodel_viscosity.cfg_dir = "species_transport/venturi_primitive_3species" @@ -1386,6 +1395,15 @@ def main(): species2_primitiveVenturi.new_output = True test_list.append(species2_primitiveVenturi) + # 2 species (1 eq) primitive venturi mixing with bounded scalar transport + species_primitiveVenturi_boundedscalar = TestCase('species2_primitiveVenturi_bounded_scalar') + species_primitiveVenturi_boundedscalar.cfg_dir = "species_transport/venturi_primitive_3species" + species_primitiveVenturi_boundedscalar.cfg_file = "species2_primitiveVenturi_boundedscalar.cfg" + species_primitiveVenturi_boundedscalar.test_iter = 50 + species_primitiveVenturi_boundedscalar.test_vals = [-5.532478, -4.805561, -4.621048, -5.502216, -1.220972, -6.297465, 5.000000, -1.127514, 5.000000, -2.566223, 5.000000, -1.070083, 0.000098, 0.000098, 0.000000, 0.000000] + species_primitiveVenturi_boundedscalar.new_output = True + test_list.append(species_primitiveVenturi_boundedscalar) + # 3 species (2 eq) primitive venturi mixing with inlet files. # Note that the residuals are exactly the same as for the non-inlet case which should be the case for a fresh inlet file. species3_primitiveVenturi_inletFile = TestCase('species3_primitiveVenturi_inletFile') diff --git a/TestCases/species_transport/venturi_primitive_3species/species2_primitiveVenturi_mixingmodel_boundedscalar.cfg b/TestCases/species_transport/venturi_primitive_3species/species2_primitiveVenturi_mixingmodel_boundedscalar.cfg new file mode 100644 index 00000000000..4c668a8ca0a --- /dev/null +++ b/TestCases/species_transport/venturi_primitive_3species/species2_primitiveVenturi_mixingmodel_boundedscalar.cfg @@ -0,0 +1,142 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% % +% SU2 configuration file % +% Case description: Species mixing with 2 species, i.e. 1 transport equations % +% Including mixture dependent density, viscosity, thermal % +% conductivity % +% Author: Cristopher Morales Ubal % +% Institution: Eindhoven University of Technology % +% Date: 2022/06/15 % +% File Version 7.4.0 "Blackbird" % +% % +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +% ------------- DIRECT, ADJOINT, AND LINEARIZED PROBLEM DEFINITION ------------% +% +SOLVER= INC_RANS +KIND_TURB_MODEL= SST +% +% ---------------- INCOMPRESSIBLE FLOW CONDITION DEFINITION -------------------% +% +INC_DENSITY_MODEL= VARIABLE +INC_DENSITY_INIT= 1.1766 +% +INC_VELOCITY_INIT= ( 1.00, 0.0, 0.0 ) +% +INC_ENERGY_EQUATION= YES +INC_TEMPERATURE_INIT= 300.0 +% +INC_NONDIM= DIMENSIONAL +% +% -------------------- FLUID PROPERTIES ------------------------------------- % +% +FLUID_MODEL= FLUID_MIXTURE +% +MOLECULAR_WEIGHT= 28.96, 16.043 +% +SPECIFIC_HEAT_CP = 1009.39, 1009.39 +% +CONDUCTIVITY_MODEL= CONSTANT_CONDUCTIVITY +THERMAL_CONDUCTIVITY_CONSTANT= 0.0357, 0.0357 +% +PRANDTL_LAM= 0.72, 0.72 +TURBULENT_CONDUCTIVITY_MODEL= NONE +PRANDTL_TURB= 0.90, 0.90 +% --------------------------- VISCOSITY MODEL ---------------------------------% +% +VISCOSITY_MODEL= CONSTANT_VISCOSITY +% +MU_CONSTANT= 1.716E-5, 1.716E-5 +% +% -------------------- BOUNDARY CONDITION DEFINITION --------------------------% +% +MARKER_HEATFLUX= ( wall, 0.0 ) +MARKER_SYM= ( axis ) +% +SPECIFIED_INLET_PROFILE= NO +INLET_FILENAME= inlet_venturi.dat +INC_INLET_TYPE= VELOCITY_INLET VELOCITY_INLET +MARKER_INLET= ( gas_inlet, 300, 1.0, 1.0, 0.0, 0.0,\ + air_axial_inlet, 300, 1.0, 0.0, -1.0, 0.0 ) +SPECIES_USE_STRONG_BC= NO +MARKER_INLET_SPECIES= (gas_inlet, 1.0,\ + air_axial_inlet, 0.6) +% +INC_OUTLET_TYPE= PRESSURE_OUTLET +MARKER_OUTLET= ( outlet, 0.0) +% +% ------------- COMMON PARAMETERS DEFINING THE NUMERICAL METHOD ---------------% +% +NUM_METHOD_GRAD= WEIGHTED_LEAST_SQUARES +% +CFL_NUMBER= 60 +CFL_REDUCTION_SPECIES= 1.0 +CFL_REDUCTION_TURB= 1.0 +% +ITER= 1000 +% +% ------------------------ LINEAR SOLVER DEFINITION ---------------------------% +% +LINEAR_SOLVER= FGMRES +LINEAR_SOLVER_PREC= ILU +LINEAR_SOLVER_ERROR= 1E-8 +LINEAR_SOLVER_ITER= 5 + +% -------------------- FLOW NUMERICAL METHOD DEFINITION -----------------------% +% +CONV_NUM_METHOD_FLOW= FDS +MUSCL_FLOW= YES +SLOPE_LIMITER_FLOW = NONE +TIME_DISCRE_FLOW= EULER_IMPLICIT +% +% -------------------- SCALAR TRANSPORT ---------------------------------------% +% +KIND_SCALAR_MODEL= SPECIES_TRANSPORT +DIFFUSIVITY_MODEL= CONSTANT_DIFFUSIVITY +DIFFUSIVITY_CONSTANT= 0.001 +% +CONV_NUM_METHOD_SPECIES= BOUNDED_SCALAR +MUSCL_SPECIES= NO +SLOPE_LIMITER_SPECIES = NONE +% +TIME_DISCRE_SPECIES= EULER_IMPLICIT +% +SPECIES_INIT= 1.0 +SPECIES_CLIPPING= YES +SPECIES_CLIPPING_MIN= 0.0 +SPECIES_CLIPPING_MAX= 1.0 +% +% -------------------- TURBULENT TRANSPORT ---------------------------------------% +% +CONV_NUM_METHOD_TURB= BOUNDED_SCALAR +MUSCL_TURB= NO +% +% --------------------------- CONVERGENCE PARAMETERS --------------------------% +% +CONV_FIELD= RMS_PRESSURE, RMS_VELOCITY-X, RMS_VELOCITY-Y, RMS_TKE, RMS_SPECIES +CONV_RESIDUAL_MINVAL= -18 +CONV_STARTITER= 10 +% +% ------------------------- INPUT/OUTPUT INFORMATION --------------------------% +% +MESH_FILENAME= primitiveVenturi.su2 +% +SCREEN_OUTPUT= INNER_ITER WALL_TIME \ + RMS_PRESSURE RMS_VELOCITY-X RMS_VELOCITY-Y RMS_TKE RMS_DISSIPATION RMS_SPECIES_0 \ + LINSOL_ITER LINSOL_RESIDUAL \ + LINSOL_ITER_TURB LINSOL_RESIDUAL_TURB \ + LINSOL_ITER_SPECIES LINSOL_RESIDUAL_SPECIES SURFACE_SPECIES_VARIANCE +SCREEN_WRT_FREQ_INNER= 10 +% +HISTORY_OUTPUT= RMS_RES FLOW_COEFF LINSOL SPECIES_COEFF SPECIES_COEFF_SURF +MARKER_ANALYZE= outlet gas_inlet air_axial_inlet +% +OUTPUT_FILES= RESTART_ASCII, PARAVIEW_MULTIBLOCK +VOLUME_OUTPUT= RESIDUAL, PRIMITIVE +OUTPUT_WRT_FREQ= 1000 +% +RESTART_SOL= NO +SOLUTION_FILENAME= solution +RESTART_FILENAME= restart.dat +% +WRT_PERFORMANCE= YES From c2f3a35f576cc2affb3fecf47042d2a9fc9946b5 Mon Sep 17 00:00:00 2001 From: EvertBunschoten Date: Fri, 14 Oct 2022 13:38:30 +0200 Subject: [PATCH 34/48] Changed regression test values for bounded scalar test cases --- TestCases/parallel_regression.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/TestCases/parallel_regression.py b/TestCases/parallel_regression.py index 8ca373f94bd..b302c92af3a 100644 --- a/TestCases/parallel_regression.py +++ b/TestCases/parallel_regression.py @@ -1340,7 +1340,7 @@ def main(): species2_primitiveVenturi_mixingmodel.cfg_dir = "species_transport/venturi_primitive_3species" species2_primitiveVenturi_mixingmodel.cfg_file = "species2_primitiveVenturi_mixingmodel.cfg" species2_primitiveVenturi_mixingmodel.test_iter = 50 - species2_primitiveVenturi_mixingmodel.test_vals = [-5.476961, -4.584495, -4.579154, -5.694241, -0.069527, -5.630550, 5.000000, -1.667301, 5.000000, -4.865917, 5.000000, -1.168657, 0.000426, 0.000405, 0.000020, 0.000000] + species2_primitiveVenturi_mixingmodel.test_vals = [-5.404946, -4.460179, -4.469851, -5.821773, -0.164394, -5.721980, 5.000000, -1.768764, 5.000000, -4.734637, 5.000000, -1.839654, 0.000210, 0.000210, 0.000000, 0.000000] species2_primitiveVenturi_mixingmodel.new_output = True test_list.append(species2_primitiveVenturi_mixingmodel) @@ -1400,7 +1400,7 @@ def main(): species_primitiveVenturi_boundedscalar.cfg_dir = "species_transport/venturi_primitive_3species" species_primitiveVenturi_boundedscalar.cfg_file = "species2_primitiveVenturi_boundedscalar.cfg" species_primitiveVenturi_boundedscalar.test_iter = 50 - species_primitiveVenturi_boundedscalar.test_vals = [-5.532478, -4.805561, -4.621048, -5.502216, -1.220972, -6.297465, 5.000000, -1.127514, 5.000000, -2.566223, 5.000000, -1.070083, 0.000098, 0.000098, 0.000000, 0.000000] + species_primitiveVenturi_boundedscalar.test_vals = [-5.579922, -4.827356, -4.678887, -5.511866, -1.175961, -6.343029, 5.000000, -1.081957, 5.000000, -2.772109, 5.000000, -1.011926, 0.000095, 0.000095, 0.000000, 0.000000] species_primitiveVenturi_boundedscalar.new_output = True test_list.append(species_primitiveVenturi_boundedscalar) From a955bb37ee6b912d49e5378f4bebef6e831a93b6 Mon Sep 17 00:00:00 2001 From: EvertBunschoten Date: Tue, 18 Oct 2022 09:19:20 +0200 Subject: [PATCH 35/48] Changed test values for primitiveVenturi test case according to the comment from Christopher --- TestCases/parallel_regression.py | 4 ++-- config_template.cfg | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/TestCases/parallel_regression.py b/TestCases/parallel_regression.py index b302c92af3a..b2be35abc9b 100644 --- a/TestCases/parallel_regression.py +++ b/TestCases/parallel_regression.py @@ -1340,7 +1340,7 @@ def main(): species2_primitiveVenturi_mixingmodel.cfg_dir = "species_transport/venturi_primitive_3species" species2_primitiveVenturi_mixingmodel.cfg_file = "species2_primitiveVenturi_mixingmodel.cfg" species2_primitiveVenturi_mixingmodel.test_iter = 50 - species2_primitiveVenturi_mixingmodel.test_vals = [-5.404946, -4.460179, -4.469851, -5.821773, -0.164394, -5.721980, 5.000000, -1.768764, 5.000000, -4.734637, 5.000000, -1.839654, 0.000210, 0.000210, 0.000000, 0.000000] + species2_primitiveVenturi_mixingmodel.test_vals = [-5.476961, -4.584495, -4.579154, -5.694241, -0.069527, -5.630550, 5.000000, -1.667301, 5.000000, -4.865917, 5.000000, -1.168657, 0.000426, 0.000405, 0.000020, 0.000000] species2_primitiveVenturi_mixingmodel.new_output = True test_list.append(species2_primitiveVenturi_mixingmodel) @@ -1349,7 +1349,7 @@ def main(): species2_primitiveVenturi_mixingmodel_boundedscalar.cfg_dir = "species_transport/venturi_primitive_3species" species2_primitiveVenturi_mixingmodel_boundedscalar.cfg_file = "species2_primitiveVenturi_mixingmodel_boundedscalar.cfg" species2_primitiveVenturi_mixingmodel_boundedscalar.test_iter = 50 - species2_primitiveVenturi_mixingmodel_boundedscalar.test_vals = [-5.373927, -4.466593, -4.463893, -5.860614, -0.161944, -5.711591, 5.000000, -1.877285, 5.000000, -4.712579, 5.000000, -1.784465, 0.000211, 0.000211, 0.000000, 0.000000] + species2_primitiveVenturi_mixingmodel_boundedscalar.test_vals = [-5.404946, -4.460179, -4.469851, -5.821773, -0.164394, -5.721980, 5.000000, -1.768764, 5.000000, -4.734637, 5.000000, -1.839654, 0.000210, 0.000210, 0.000000, 0.000000] species2_primitiveVenturi_mixingmodel_boundedscalar.new_output = True test_list.append(species2_primitiveVenturi_mixingmodel_boundedscalar) diff --git a/config_template.cfg b/config_template.cfg index cf5fa9ebe19..5bced5fc7c7 100644 --- a/config_template.cfg +++ b/config_template.cfg @@ -1273,7 +1273,7 @@ KIND_MATRIX_COLORING= GREEDY_COLORING % -------------------- TURBULENT NUMERICAL METHOD DEFINITION ------------------% % -% Convective numerical method (SCALAR_UPWIND, SCALAR_ADVECTION) +% Convective numerical method (SCALAR_UPWIND, BOUNDED_SCALAR) CONV_NUM_METHOD_TURB= SCALAR_UPWIND % % Time discretization (EULER_IMPLICIT, EULER_EXPLICIT) From dac57426f6b7c535276ad716b79a0acc50bf172a Mon Sep 17 00:00:00 2001 From: bigfooted Date: Tue, 18 Oct 2022 16:13:11 +0200 Subject: [PATCH 36/48] remove spacmove variable declaration to where they are used --- SU2_CFD/include/solvers/CScalarSolver.inl | 18 ++++++++++-------- SU2_CFD/include/solvers/CSolver.hpp | 2 +- config_template.cfg | 2 +- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/SU2_CFD/include/solvers/CScalarSolver.inl b/SU2_CFD/include/solvers/CScalarSolver.inl index e8f03575624..a97c0f067d9 100644 --- a/SU2_CFD/include/solvers/CScalarSolver.inl +++ b/SU2_CFD/include/solvers/CScalarSolver.inl @@ -155,8 +155,6 @@ void CScalarSolver::Upwind_Residual(CGeometry* geometry, CSolver** if((config->GetKind_Upwind_Species() == UPWIND::BOUNDED_SCALAR) || (config->GetKind_Upwind_Turb() == UPWIND::BOUNDED_SCALAR)) bounded_scalar = true; - su2double EdgeMassFlux, Project_Grad_i, Project_Grad_j, FluxCorrection_i, FluxCorrection_j; - su2double **Jacobian_i_correction, **Jacobian_j_correction; Jacobian_i_correction = new su2double*[nVar]; Jacobian_j_correction = new su2double*[nVar]; @@ -223,8 +221,8 @@ void CScalarSolver::Upwind_Residual(CGeometry* geometry, CSolver** } for (iVar = 0; iVar < solver_container[FLOW_SOL]->GetnPrimVarGrad(); iVar++) { - Project_Grad_i = 0.0; - Project_Grad_j = 0.0; + su2double Project_Grad_i = 0.0; + su2double Project_Grad_j = 0.0; for (iDim = 0; iDim < nDim; iDim++) { Project_Grad_i += Vector_ij[iDim] * Gradient_i[iVar][iDim]; Project_Grad_j -= Vector_ij[iDim] * Gradient_j[iVar][iDim]; @@ -270,6 +268,7 @@ void CScalarSolver::Upwind_Residual(CGeometry* geometry, CSolver** } /*--- Convective flux ---*/ + su2double EdgeMassFlux = 0.0; if (bounded_scalar) { EdgeMassFlux = solver_container[FLOW_SOL]->GetEdgeMassFlux(iEdge); numerics->SetMassFlux(EdgeMassFlux); @@ -290,13 +289,16 @@ void CScalarSolver::Upwind_Residual(CGeometry* geometry, CSolver** /*--- Applying convective flux correction to negate the effects of flow divergence ---*/ if(bounded_scalar){ for(iVar=0; iVarGetSolution(iPoint, iVar) * EdgeMassFlux; - FluxCorrection_j = GetNodes()->GetSolution(jPoint, iVar) * EdgeMassFlux; + su2double FluxCorrection_i = GetNodes()->GetSolution(iPoint, iVar) * EdgeMassFlux; + su2double FluxCorrection_j = GetNodes()->GetSolution(jPoint, iVar) * EdgeMassFlux; LinSysRes(iPoint, iVar) -= FluxCorrection_i; LinSysRes(jPoint, iVar) += FluxCorrection_j; - Jacobian_i_correction[iVar][iVar] = max(0.0, EdgeMassFlux);; - Jacobian_j_correction[iVar][iVar] = min(0.0, EdgeMassFlux); + + //Jacobian_i_correction[iVar][iVar] = max(0.0, EdgeMassFlux);; + //Jacobian_j_correction[iVar][iVar] = min(0.0, EdgeMassFlux); + Jacobian.AddVal2Diag(iPoint, -EdgeMassFlux); + Jacobian.AddVal2Diag(jPoint, EdgeMassFlux); } }if (implicit) Jacobian.UpdateBlocks(iEdge, iPoint, jPoint, Jacobian_i_correction, Jacobian_j_correction); /*--- Viscous contribution. ---*/ diff --git a/SU2_CFD/include/solvers/CSolver.hpp b/SU2_CFD/include/solvers/CSolver.hpp index 0248ceb9c3c..4133fee2d9e 100644 --- a/SU2_CFD/include/solvers/CSolver.hpp +++ b/SU2_CFD/include/solvers/CSolver.hpp @@ -3004,7 +3004,7 @@ class CSolver { * \param[in] iEdge - Index of the edge. * \return The mass flux across the edge. */ - inline virtual su2double GetEdgeMassFlux(const unsigned long iEdge) const { return 0; } + inline virtual su2double GetEdgeMassFlux(const unsigned long iEdge) const final { return 0; } /*! * \brief A virtual member. diff --git a/config_template.cfg b/config_template.cfg index cf5fa9ebe19..5bced5fc7c7 100644 --- a/config_template.cfg +++ b/config_template.cfg @@ -1273,7 +1273,7 @@ KIND_MATRIX_COLORING= GREEDY_COLORING % -------------------- TURBULENT NUMERICAL METHOD DEFINITION ------------------% % -% Convective numerical method (SCALAR_UPWIND, SCALAR_ADVECTION) +% Convective numerical method (SCALAR_UPWIND, BOUNDED_SCALAR) CONV_NUM_METHOD_TURB= SCALAR_UPWIND % % Time discretization (EULER_IMPLICIT, EULER_EXPLICIT) From 1b35499f0107101d2ca3b7c1631c14857b745ddf Mon Sep 17 00:00:00 2001 From: EvertBunschoten Date: Wed, 9 Nov 2022 13:14:47 +0100 Subject: [PATCH 37/48] Disabed axisymmetric source term for bounded scalar simulations --- SU2_CFD/src/drivers/CDriver.cpp | 7 +++++++ .../src/numerics/species/species_sources.cpp | 19 ++++++++++--------- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/SU2_CFD/src/drivers/CDriver.cpp b/SU2_CFD/src/drivers/CDriver.cpp index 0794ca8fcd4..89d61ee3709 100644 --- a/SU2_CFD/src/drivers/CDriver.cpp +++ b/SU2_CFD/src/drivers/CDriver.cpp @@ -1393,6 +1393,13 @@ void CDriver::InstantiateSpeciesNumerics(unsigned short nVar_Species, int offset numerics[iMGlevel][SPECIES_SOL][source_first_term] = new CSourceNothing(nDim, nVar_Species, config); } numerics[iMGlevel][SPECIES_SOL][source_second_term] = new CSourceNothing(nDim, nVar_Species, config); + if(config->GetKind_Upwind_Species() == UPWIND::BOUNDED_SCALAR){ + numerics[iMGlevel][SPECIES_SOL][source_first_term]->SetBoundedScalar(true); + numerics[iMGlevel][SPECIES_SOL][source_second_term]->SetBoundedScalar(true); + }else{ + numerics[iMGlevel][SPECIES_SOL][source_first_term]->SetBoundedScalar(false); + numerics[iMGlevel][SPECIES_SOL][source_second_term]->SetBoundedScalar(false); + } } } /*--- Explicit instantiation of the template above, needed because it is defined in a cpp file, instead of hpp. ---*/ diff --git a/SU2_CFD/src/numerics/species/species_sources.cpp b/SU2_CFD/src/numerics/species/species_sources.cpp index 1198e6c757b..a063a726514 100644 --- a/SU2_CFD/src/numerics/species/species_sources.cpp +++ b/SU2_CFD/src/numerics/species/species_sources.cpp @@ -105,18 +105,18 @@ CNumerics::ResidualType<> CSourceAxisymmetric_Species::ComputeResidual(const Velocity_i[iDim] = V_i[idx.Velocity() + iDim]; /*--- Inviscid component of the source term. ---*/ + if(!bounded_scalar){ + for (auto iVar = 0u; iVar < nVar; iVar++) + residual[iVar] -= yinv * Volume * Density_i * ScalarVar_i[iVar] * Velocity_i[1]; - for (auto iVar = 0u; iVar < nVar; iVar++) - residual[iVar] -= yinv * Volume * Density_i * ScalarVar_i[iVar] * Velocity_i[1]; - - if (implicit) { - for (auto iVar = 0u; iVar < nVar; iVar++) { - jacobian[iVar][iVar] -= yinv * Volume * Velocity_i[1]; + if (implicit) { + for (auto iVar = 0u; iVar < nVar; iVar++) { + jacobian[iVar][iVar] -= yinv * Volume * Velocity_i[1]; + } } } - - /*--- Add the viscous terms if necessary. ---*/ - + /*--- Add the viscous terms if necessary. ---*/ + if (config->GetViscous()) { su2double Mass_Diffusivity_Tur = 0.0; if (turbulence) @@ -126,6 +126,7 @@ CNumerics::ResidualType<> CSourceAxisymmetric_Species::ComputeResidual(const residual[iVar] += yinv * Volume * (Density_i * Diffusion_Coeff_i[iVar] + Mass_Diffusivity_Tur) * ScalarVar_Grad_i[iVar][1]; } } + } AD::SetPreaccOut(residual, nVar); From c3a8e1921e547b8c29e9090cb7a0207b2ef7b0ca Mon Sep 17 00:00:00 2001 From: EvertBunschoten Date: Wed, 9 Nov 2022 13:49:02 +0100 Subject: [PATCH 38/48] Fixed build error --- Common/include/CConfig.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Common/include/CConfig.hpp b/Common/include/CConfig.hpp index b5daaa3254f..50aa5887db4 100644 --- a/Common/include/CConfig.hpp +++ b/Common/include/CConfig.hpp @@ -4780,7 +4780,7 @@ class CConfig { */ UPWIND GetKind_Upwind_Species() const { return Kind_Upwind_Species; } - const bool GetBounded_Scalar() const { return ((Kind_Upwind_Turb == UPWIND::BOUNDED_SCALAR) + bool GetBounded_Scalar() const { return ((Kind_Upwind_Turb == UPWIND::BOUNDED_SCALAR) || (Kind_Upwind_Species == UPWIND::BOUNDED_SCALAR)); } /*! From 9eb67d09d901390bd3f56bc339692dd0e9c215c1 Mon Sep 17 00:00:00 2001 From: EvertBunschoten Date: Wed, 9 Nov 2022 15:17:57 +0100 Subject: [PATCH 39/48] Reduced CFL number for species bounded scalar test case to prevent divergence --- Common/include/CConfig.hpp | 6 ++++++ TestCases/parallel_regression.py | 2 +- .../species2_primitiveVenturi_boundedscalar.cfg | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Common/include/CConfig.hpp b/Common/include/CConfig.hpp index 50aa5887db4..b9f6df82bb9 100644 --- a/Common/include/CConfig.hpp +++ b/Common/include/CConfig.hpp @@ -4780,6 +4780,12 @@ class CConfig { */ UPWIND GetKind_Upwind_Species() const { return Kind_Upwind_Species; } + /*! + * \brief Get bounded scalar problem for species or turbulence + * \note This value is obtained from the config file, and it is constant + * during the computation. + * \return Bounded scalar problem for turbulence or species transport. + */ bool GetBounded_Scalar() const { return ((Kind_Upwind_Turb == UPWIND::BOUNDED_SCALAR) || (Kind_Upwind_Species == UPWIND::BOUNDED_SCALAR)); } diff --git a/TestCases/parallel_regression.py b/TestCases/parallel_regression.py index b2be35abc9b..6d550d7f0d7 100644 --- a/TestCases/parallel_regression.py +++ b/TestCases/parallel_regression.py @@ -1349,7 +1349,7 @@ def main(): species2_primitiveVenturi_mixingmodel_boundedscalar.cfg_dir = "species_transport/venturi_primitive_3species" species2_primitiveVenturi_mixingmodel_boundedscalar.cfg_file = "species2_primitiveVenturi_mixingmodel_boundedscalar.cfg" species2_primitiveVenturi_mixingmodel_boundedscalar.test_iter = 50 - species2_primitiveVenturi_mixingmodel_boundedscalar.test_vals = [-5.404946, -4.460179, -4.469851, -5.821773, -0.164394, -5.721980, 5.000000, -1.768764, 5.000000, -4.734637, 5.000000, -1.839654, 0.000210, 0.000210, 0.000000, 0.000000] + species2_primitiveVenturi_mixingmodel_boundedscalar.test_vals = [-5.415390, -4.470360, -4.481026, -5.766360, -0.118573, -5.603467, 5.000000, -1.790744, 5.000000, -4.793799, 5.000000, -2.264601, 0.000273, 0.000273, 0.000000, 0.000000] species2_primitiveVenturi_mixingmodel_boundedscalar.new_output = True test_list.append(species2_primitiveVenturi_mixingmodel_boundedscalar) diff --git a/TestCases/species_transport/venturi_primitive_3species/species2_primitiveVenturi_boundedscalar.cfg b/TestCases/species_transport/venturi_primitive_3species/species2_primitiveVenturi_boundedscalar.cfg index 5698eb883fd..8c8e8e409ef 100644 --- a/TestCases/species_transport/venturi_primitive_3species/species2_primitiveVenturi_boundedscalar.cfg +++ b/TestCases/species_transport/venturi_primitive_3species/species2_primitiveVenturi_boundedscalar.cfg @@ -59,7 +59,7 @@ MARKER_OUTLET= ( outlet, 0.0) % NUM_METHOD_GRAD= WEIGHTED_LEAST_SQUARES % -CFL_NUMBER= 1000 +CFL_NUMBER= 60 CFL_REDUCTION_SPECIES= 1.0 CFL_REDUCTION_TURB= 1.0 % From 924ba51ff7eaaf28bbf6101dd7ba7b7428448f0e Mon Sep 17 00:00:00 2001 From: EvertBunschoten Date: Thu, 10 Nov 2022 09:51:03 +0100 Subject: [PATCH 40/48] Updated regression test values for venturi test case with bounded scalar --- TestCases/parallel_regression.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TestCases/parallel_regression.py b/TestCases/parallel_regression.py index 6d550d7f0d7..f1bc1561547 100644 --- a/TestCases/parallel_regression.py +++ b/TestCases/parallel_regression.py @@ -1400,7 +1400,7 @@ def main(): species_primitiveVenturi_boundedscalar.cfg_dir = "species_transport/venturi_primitive_3species" species_primitiveVenturi_boundedscalar.cfg_file = "species2_primitiveVenturi_boundedscalar.cfg" species_primitiveVenturi_boundedscalar.test_iter = 50 - species_primitiveVenturi_boundedscalar.test_vals = [-5.579922, -4.827356, -4.678887, -5.511866, -1.175961, -6.343029, 5.000000, -1.081957, 5.000000, -2.772109, 5.000000, -1.011926, 0.000095, 0.000095, 0.000000, 0.000000] + species_primitiveVenturi_boundedscalar.test_vals = [-5.284619, -4.338169, -4.332983, -5.830310, -0.940580, -5.478797, 5.000000, -1.804797, 5.000000, -4.055686, 5.000000, -2.187465, 0.000428, 0.000428, 0.000000, 0.000000] species_primitiveVenturi_boundedscalar.new_output = True test_list.append(species_primitiveVenturi_boundedscalar) From c0eb4aae04f9d50244db787176ac00de13180546 Mon Sep 17 00:00:00 2001 From: EvertBunschoten Date: Fri, 18 Nov 2022 11:19:16 +0100 Subject: [PATCH 41/48] Updated test values for bounded_scalar test cases --- TestCases/parallel_regression.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/TestCases/parallel_regression.py b/TestCases/parallel_regression.py index c74861b660e..3c9e0d0a439 100644 --- a/TestCases/parallel_regression.py +++ b/TestCases/parallel_regression.py @@ -1339,7 +1339,7 @@ def main(): species2_primitiveVenturi_mixingmodel_boundedscalar.cfg_dir = "species_transport/venturi_primitive_3species" species2_primitiveVenturi_mixingmodel_boundedscalar.cfg_file = "species2_primitiveVenturi_mixingmodel_boundedscalar.cfg" species2_primitiveVenturi_mixingmodel_boundedscalar.test_iter = 50 - species2_primitiveVenturi_mixingmodel_boundedscalar.test_vals = [-5.415390, -4.470360, -4.481026, -5.766360, -0.118573, -5.603467, 5.000000, -1.790744, 5.000000, -4.793799, 5.000000, -2.264601, 0.000273, 0.000273, 0.000000, 0.000000] + species2_primitiveVenturi_mixingmodel_boundedscalar.test_vals = [-5.415851, -4.473176, -4.483304, -5.749018, -0.118137, -5.603635, 5.000000, -1.792516, 5.000000, -4.814091, 5.000000, -2.262333, 0.000273, 0.000273, 0.000000, 0.000000] species2_primitiveVenturi_mixingmodel_boundedscalar.new_output = True test_list.append(species2_primitiveVenturi_mixingmodel_boundedscalar) @@ -1390,7 +1390,7 @@ def main(): species_primitiveVenturi_boundedscalar.cfg_dir = "species_transport/venturi_primitive_3species" species_primitiveVenturi_boundedscalar.cfg_file = "species2_primitiveVenturi_boundedscalar.cfg" species_primitiveVenturi_boundedscalar.test_iter = 50 - species_primitiveVenturi_boundedscalar.test_vals = [-5.284619, -4.338169, -4.332983, -5.830310, -0.940580, -5.478797, 5.000000, -1.804797, 5.000000, -4.055686, 5.000000, -2.187465, 0.000428, 0.000428, 0.000000, 0.000000] + species_primitiveVenturi_boundedscalar.test_vals = [-5.282401, -4.333110, -4.328952, -5.872802, -0.937267, -5.480719, 5.000000, -1.786802, 5.000000, -3.993190, 5.000000, -2.112418, 0.000413, 0.000413, 0.000000, 0.000000] species_primitiveVenturi_boundedscalar.new_output = True test_list.append(species_primitiveVenturi_boundedscalar) From 7d1c511a81c73f72d97eecd789dffa75ee5836b7 Mon Sep 17 00:00:00 2001 From: Pedro Gomes <38071223+pcarruscag@users.noreply.github.com> Date: Mon, 21 Nov 2022 14:17:41 -0800 Subject: [PATCH 42/48] Apply suggestions from code review --- Common/include/CConfig.hpp | 5 +++-- SU2_CFD/include/numerics/CNumerics.hpp | 4 ++-- SU2_CFD/include/numerics/scalar/scalar_convection.hpp | 4 ++-- .../include/numerics/species/species_convection.hpp | 3 --- SU2_CFD/include/numerics/turbulent/turb_convection.hpp | 4 ---- SU2_CFD/include/solvers/CScalarSolver.inl | 2 +- SU2_CFD/src/drivers/CDriver.cpp | 10 +++------- 7 files changed, 11 insertions(+), 21 deletions(-) diff --git a/Common/include/CConfig.hpp b/Common/include/CConfig.hpp index 61f16138a79..63ede4f35a1 100644 --- a/Common/include/CConfig.hpp +++ b/Common/include/CConfig.hpp @@ -4792,8 +4792,9 @@ class CConfig { * during the computation. * \return Bounded scalar problem for turbulence or species transport. */ - bool GetBounded_Scalar() const { return ((Kind_Upwind_Turb == UPWIND::BOUNDED_SCALAR) - || (Kind_Upwind_Species == UPWIND::BOUNDED_SCALAR)); } + bool GetBounded_Scalar() const { + return (Kind_Upwind_Turb == UPWIND::BOUNDED_SCALAR) || (Kind_Upwind_Species == UPWIND::BOUNDED_SCALAR); + } /*! * \brief Get the kind of convective numerical scheme for the heat equation. diff --git a/SU2_CFD/include/numerics/CNumerics.hpp b/SU2_CFD/include/numerics/CNumerics.hpp index 0d47a0b2523..337ca9051a2 100644 --- a/SU2_CFD/include/numerics/CNumerics.hpp +++ b/SU2_CFD/include/numerics/CNumerics.hpp @@ -1622,13 +1622,13 @@ class CNumerics { * \brief Set bounded scalar transport problem * \param[in] is_bounded_scalar : scalar solver uses bounded scalar convective transport */ - inline void SetBoundedScalar(const bool is_bounded_scalar) {bounded_scalar = is_bounded_scalar; } + inline void SetBoundedScalar(const bool is_bounded_scalar) { bounded_scalar = is_bounded_scalar; } /*! * \brief Obtain information on bounded scalar problem * \return is_bounded_scalar : scalar solver uses bounded scalar convective transport */ - inline bool GetBoundedScalar() const {return bounded_scalar;} + inline bool GetBoundedScalar() const { return bounded_scalar;} }; /*! diff --git a/SU2_CFD/include/numerics/scalar/scalar_convection.hpp b/SU2_CFD/include/numerics/scalar/scalar_convection.hpp index ad906de2886..07799d73f6e 100644 --- a/SU2_CFD/include/numerics/scalar/scalar_convection.hpp +++ b/SU2_CFD/include/numerics/scalar/scalar_convection.hpp @@ -134,10 +134,10 @@ class CUpwScalar : public CNumerics { } } - if(bounded_scalar){ + if (bounded_scalar) { a0 = max(0.0, MassFlux) / V_i[idx.Density()]; a1 = min(0.0, MassFlux) / V_j[idx.Density()]; - }else{ + } else { a0 = 0.5 * (q_ij + fabs(q_ij)); a1 = 0.5 * (q_ij - fabs(q_ij)); } diff --git a/SU2_CFD/include/numerics/species/species_convection.hpp b/SU2_CFD/include/numerics/species/species_convection.hpp index 0bcdea963ce..3308a8cd691 100644 --- a/SU2_CFD/include/numerics/species/species_convection.hpp +++ b/SU2_CFD/include/numerics/species/species_convection.hpp @@ -51,7 +51,6 @@ class CUpwSca_Species final : public CUpwScalar { using Base::ScalarVar_i; using Base::ScalarVar_j; using Base::idx; - using Base::bounded_scalar; /*! * \brief Adds any extra variables to AD @@ -67,14 +66,12 @@ class CUpwSca_Species final : public CUpwScalar { */ void FinishResidualCalc(const CConfig* config) override { for (auto iVar = 0u; iVar < nVar; iVar++) { - Flux[iVar] = a0 * V_i[idx.Density()] * ScalarVar_i[iVar] + a1 * V_j[idx.Density()] * ScalarVar_j[iVar]; /*--- Jacobians are taken wrt rho*Y not Y alone in the species solver. ---*/ /*--- Off-diagonal entries are zero. ---*/ Jacobian_i[iVar][iVar] = a0; Jacobian_j[iVar][iVar] = a1; - } // iVar } diff --git a/SU2_CFD/include/numerics/turbulent/turb_convection.hpp b/SU2_CFD/include/numerics/turbulent/turb_convection.hpp index ea456a29f57..3fb232a729c 100644 --- a/SU2_CFD/include/numerics/turbulent/turb_convection.hpp +++ b/SU2_CFD/include/numerics/turbulent/turb_convection.hpp @@ -114,18 +114,14 @@ class CUpwSca_TurbSST final : public CUpwScalar { * \param[in] config - Definition of the particular problem. */ void FinishResidualCalc(const CConfig* config) override { - Flux[0] = a0*V_i[idx.Density()]*ScalarVar_i[0] + a1*V_j[idx.Density()]*ScalarVar_j[0]; Flux[1] = a0*V_i[idx.Density()]*ScalarVar_i[1] + a1*V_j[idx.Density()]*ScalarVar_j[1]; - if (implicit) { - Jacobian_i[0][0] = a0; Jacobian_i[0][1] = 0.0; Jacobian_i[1][0] = 0.0; Jacobian_i[1][1] = a0; Jacobian_j[0][0] = a1; Jacobian_j[0][1] = 0.0; Jacobian_j[1][0] = 0.0; Jacobian_j[1][1] = a1; - } } diff --git a/SU2_CFD/include/solvers/CScalarSolver.inl b/SU2_CFD/include/solvers/CScalarSolver.inl index 47eff52acc8..a09bd1e3e21 100644 --- a/SU2_CFD/include/solvers/CScalarSolver.inl +++ b/SU2_CFD/include/solvers/CScalarSolver.inl @@ -119,7 +119,6 @@ template void CScalarSolver::Upwind_Residual(CGeometry* geometry, CSolver** solver_container, CNumerics** numerics_container, CConfig* config, unsigned short iMesh) { - /*--- Define booleans that are solver specific through CConfig's GlobalParams which have to be set in CFluidIteration * before calling these solver functions. ---*/ const bool implicit = (config->GetKind_TimeIntScheme() == EULER_IMPLICIT); @@ -180,6 +179,7 @@ void CScalarSolver::Upwind_Residual(CGeometry* geometry, CSolver** auto jPoint = geometry->edges->GetNode(iEdge, 1); numerics->SetNormal(geometry->edges->GetNormal(iEdge)); + /*--- Primitive variables w/o reconstruction ---*/ const auto V_i = flowNodes->GetPrimitive(iPoint); diff --git a/SU2_CFD/src/drivers/CDriver.cpp b/SU2_CFD/src/drivers/CDriver.cpp index 252582203fb..d2d87b57653 100644 --- a/SU2_CFD/src/drivers/CDriver.cpp +++ b/SU2_CFD/src/drivers/CDriver.cpp @@ -1271,9 +1271,7 @@ void CDriver::InstantiateTurbulentNumerics(unsigned short nVar_Turb, int offset, numerics[iMGlevel][TURB_SOL][conv_term] = new CUpwSca_TurbSST(nDim, nVar_Turb, config); /*--- Define bounded turbulent scalar problem ---*/ - if(config->GetKind_Upwind_Turb() == UPWIND::BOUNDED_SCALAR){ - numerics[iMGlevel][TURB_SOL][conv_term]->SetBoundedScalar(true); - }else numerics[iMGlevel][TURB_SOL][conv_term]->SetBoundedScalar(false); + numerics[iMGlevel][TURB_SOL][conv_term]->SetBoundedScalar(config->GetKind_Upwind_Turb() == UPWIND::BOUNDED_SCALAR); } break; default: @@ -1327,10 +1325,8 @@ void CDriver::InstantiateTurbulentNumerics(unsigned short nVar_Turb, int offset, config); } - if(config->GetKind_Upwind_Turb() == UPWIND::BOUNDED_SCALAR){ - numerics[iMGlevel][TURB_SOL][conv_bound_term]->SetBoundedScalar(true); - }else numerics[iMGlevel][TURB_SOL][conv_bound_term]->SetBoundedScalar(false); - } + numerics[iMGlevel][TURB_SOL][conv_term]->SetBoundedScalar(config->GetKind_Upwind_Turb() == UPWIND::BOUNDED_SCALAR); + } } /*--- Explicit instantiation of the template above, needed because it is defined in a cpp file, instead of hpp. ---*/ template void CDriver::InstantiateTurbulentNumerics>( From 930d34ac2c5368836cc9e37efac127a0394f259c Mon Sep 17 00:00:00 2001 From: EvertBunschoten Date: Wed, 23 Nov 2022 11:55:37 +0100 Subject: [PATCH 43/48] Reduced code duplication, changed inlet and outlet turbulent and species solutions to use inlet and outlet characteristic flow variables instead of the local flow variables when computing the mass flux. --- SU2_CFD/include/solvers/CScalarSolver.hpp | 4 ++ SU2_CFD/include/solvers/CScalarSolver.inl | 30 +++----------- SU2_CFD/src/solvers/CSpeciesSolver.cpp | 40 +++---------------- SU2_CFD/src/solvers/CTurbSASolver.cpp | 39 +++--------------- SU2_CFD/src/solvers/CTurbSSTSolver.cpp | 40 +++---------------- TestCases/parallel_regression.py | 4 +- ...pecies2_primitiveVenturi_boundedscalar.cfg | 2 +- 7 files changed, 28 insertions(+), 131 deletions(-) diff --git a/SU2_CFD/include/solvers/CScalarSolver.hpp b/SU2_CFD/include/solvers/CScalarSolver.hpp index e5e10611296..0cf644b83ce 100644 --- a/SU2_CFD/include/solvers/CScalarSolver.hpp +++ b/SU2_CFD/include/solvers/CScalarSolver.hpp @@ -61,6 +61,10 @@ class CScalarSolver : public CSolver { vector > SlidingState; // vector of matrix of pointers... inner dim alloc'd elsewhere (welcome, to the twilight zone) vector > SlidingStateNodes; + /*!< \brief Jacobian correction terms for bounded scalar problems. */ + // su2activematrix Jacobian_correction_i, + // Jacobian_correction_j; + /*--- Shallow copy of grid coloring for OpenMP parallelization. ---*/ #ifdef HAVE_OMP diff --git a/SU2_CFD/include/solvers/CScalarSolver.inl b/SU2_CFD/include/solvers/CScalarSolver.inl index a09bd1e3e21..cde43a835f0 100644 --- a/SU2_CFD/include/solvers/CScalarSolver.inl +++ b/SU2_CFD/include/solvers/CScalarSolver.inl @@ -70,6 +70,10 @@ CScalarSolver::CScalarSolver(CGeometry* geometry, CConfig* config, lowerlimit[iVar] = std::numeric_limits::lowest(); upperlimit[iVar] = std::numeric_limits::max(); } + + // /*--- Setting size for bounded scalar Jacobian correction ---*/ + // Jacobian_correction_i.resize(nVar, nVar); + // Jacobian_correction_j.resize(nVar, nVar); } template @@ -152,18 +156,6 @@ void CScalarSolver::Upwind_Residual(CGeometry* geometry, CSolver** else AD::StartNoSharedReading(); - su2double **Jacobian_i_correction, **Jacobian_j_correction; - Jacobian_i_correction = new su2double*[nVar]; - Jacobian_j_correction = new su2double*[nVar]; - for (unsigned short iVar=0; iVar::Upwind_Residual(CGeometry* geometry, CSolver** LinSysRes(iPoint, iVar) -= FluxCorrection_i; LinSysRes(jPoint, iVar) += FluxCorrection_j; - - //Jacobian_i_correction[iVar][iVar] = max(0.0, EdgeMassFlux);; - //Jacobian_j_correction[iVar][iVar] = min(0.0, EdgeMassFlux); - //Jacobian.AddVal2Diag(iPoint, -EdgeMassFlux); - //Jacobian.AddVal2Diag(jPoint, EdgeMassFlux); } Jacobian.AddVal2Diag(iPoint, -EdgeMassFlux); Jacobian.AddVal2Diag(jPoint, EdgeMassFlux); - }if (implicit) Jacobian.UpdateBlocks(iEdge, iPoint, jPoint, Jacobian_i_correction, Jacobian_j_correction); + } /*--- Viscous contribution. ---*/ Viscous_Residual(iEdge, geometry, solver_container, @@ -317,13 +304,6 @@ void CScalarSolver::Upwind_Residual(CGeometry* geometry, CSolver** SumEdgeFluxes(geometry); if (implicit) Jacobian.SetDiagonalAsColumnSum(); } - - for(unsigned short iVar=0; iVar diff --git a/SU2_CFD/src/solvers/CSpeciesSolver.cpp b/SU2_CFD/src/solvers/CSpeciesSolver.cpp index 3c2832ee5e7..fe1cdbdc7d9 100644 --- a/SU2_CFD/src/solvers/CSpeciesSolver.cpp +++ b/SU2_CFD/src/solvers/CSpeciesSolver.cpp @@ -349,14 +349,6 @@ void CSpeciesSolver::BC_Inlet(CGeometry* geometry, CSolver** solver_container, C bool bounded_scalar = conv_numerics->GetBoundedScalar(); su2double EdgeMassFlux = 0.0; - su2double **Jacobian_i_correction; - Jacobian_i_correction = new su2double*[nVar]; - for (unsigned short iVar=0; iVarGetNodes()->GetVelocity(iPoint, iDim); + for (auto iDim = 0u; iDim < nDim; iDim++) Velocity_Inlet[iDim] = V_inlet[iDim + 1];//solver_container[FLOW_SOL]->GetNodes()->GetVelocity(iPoint, iDim); /*--- Obtain density at inlet boundary node ---*/ density_inlet = solver_container[FLOW_SOL]->GetNodes()->GetDensity(iPoint); @@ -437,22 +429,14 @@ void CSpeciesSolver::BC_Inlet(CGeometry* geometry, CSolver** solver_container, C su2double FluxCorrection_i = GetNodes()->GetSolution(iPoint, iVar) * EdgeMassFlux; LinSysRes(iPoint, iVar) -= FluxCorrection_i; - Jacobian_i_correction[iVar][iVar] = max(0.0, EdgeMassFlux); } - }if (implicit) Jacobian.AddBlock2Diag(iPoint, Jacobian_i_correction); + }if (implicit) Jacobian.AddVal2Diag(iPoint, max(0.0, EdgeMassFlux)); // Unfinished viscous contribution removed before right after d8a0da9a00. Further testing required. } } END_SU2_OMP_FOR - - /*--- Delete jacobian correction variable ---*/ - for (unsigned short iVar=0; iVarGetBoundedScalar(); + su2double EdgeMassFlux = 0.0; - su2double **Jacobian_i_correction; - Jacobian_i_correction = new su2double*[nVar]; - for (unsigned short iVar=0; iVarGetNodes()->GetVelocity(iPoint, iDim); + for (auto iDim = 0u; iDim < nDim; iDim++) Velocity_Outlet[iDim] = V_outlet[iDim + 1]; /*--- Obtain density at inlet boundary node ---*/ density_outlet = solver_container[FLOW_SOL]->GetNodes()->GetDensity(iPoint); @@ -626,21 +603,14 @@ void CSpeciesSolver::BC_Outlet(CGeometry* geometry, CSolver** solver_container, su2double FluxCorrection_i = GetNodes()->GetSolution(iPoint, iVar) * EdgeMassFlux; LinSysRes(iPoint, iVar) -= FluxCorrection_i; - Jacobian_i_correction[iVar][iVar] = max(0.0, EdgeMassFlux); } - }if (implicit) Jacobian.AddBlock2Diag(iPoint, Jacobian_i_correction); + }if(implicit) Jacobian.AddVal2Diag(iPoint, max(0.0, EdgeMassFlux)); // Unfinished viscous contribution removed before right after d8a0da9a00. Further testing required. } } END_SU2_OMP_FOR - - for (unsigned short iVar=0; iVarGetBoundedScalar(); su2double EdgeMassFlux = 0.0; - su2double **Jacobian_i_correction; - Jacobian_i_correction = new su2double*[nVar]; - for (unsigned short iVar=0; iVarGetNodes()->GetVelocity(iPoint, iDim); + for (auto iDim = 0u; iDim < nDim; iDim++) Velocity_Inlet[iDim] = V_inlet[iDim + 1];//solver_container[FLOW_SOL]->GetNodes()->GetVelocity(iPoint, iDim); /*--- Obtain density at inlet boundary node ---*/ density_inlet = solver_container[FLOW_SOL]->GetNodes()->GetDensity(iPoint); @@ -615,9 +607,8 @@ void CTurbSASolver::BC_Inlet(CGeometry *geometry, CSolver **solver_container, CN su2double FluxCorrection_i = GetNodes()->GetSolution(iPoint, iVar) * EdgeMassFlux; LinSysRes(iPoint, iVar) -= FluxCorrection_i; - Jacobian_i_correction[iVar][iVar] = max(0.0, EdgeMassFlux); } - }if (implicit) Jacobian.AddBlock2Diag(iPoint, Jacobian_i_correction); + }if (implicit) Jacobian.AddVal2Diag(iPoint, max(0.0, EdgeMassFlux)); // /*--- Viscous contribution, commented out because serious convergence problems ---*/ // @@ -648,27 +639,14 @@ void CTurbSASolver::BC_Inlet(CGeometry *geometry, CSolver **solver_container, CN } } END_SU2_OMP_FOR - - /*--- Delete jacobian correction variable ---*/ - for (unsigned short iVar=0; iVarGetBoundedScalar(); + su2double EdgeMassFlux = 0.0; - su2double **Jacobian_i_correction; - Jacobian_i_correction = new su2double*[nVar]; - for (unsigned short iVar=0; iVarGetKind_TimeIntScheme() == EULER_IMPLICIT); @@ -715,7 +693,7 @@ void CTurbSASolver::BC_Outlet(CGeometry *geometry, CSolver **solver_container, C if(bounded_scalar){ /*--- Obtain flow velocity vector at inlet boundary node ---*/ su2double Velocity_Outlet[MAXNDIM] = {0.0}, density_outlet; - for (auto iDim = 0u; iDim < nDim; iDim++) Velocity_Outlet[iDim] = solver_container[FLOW_SOL]->GetNodes()->GetVelocity(iPoint, iDim); + for (auto iDim = 0u; iDim < nDim; iDim++) Velocity_Outlet[iDim] = V_outlet[iDim + 1]; /*--- Obtain density at inlet boundary node ---*/ density_outlet = solver_container[FLOW_SOL]->GetNodes()->GetDensity(iPoint); @@ -741,9 +719,8 @@ void CTurbSASolver::BC_Outlet(CGeometry *geometry, CSolver **solver_container, C su2double FluxCorrection_i = GetNodes()->GetSolution(iPoint, iVar) * EdgeMassFlux; LinSysRes(iPoint, iVar) -= FluxCorrection_i; - Jacobian_i_correction[iVar][iVar] = max(0.0, EdgeMassFlux); } - }if (implicit) Jacobian.AddBlock2Diag(iPoint, Jacobian_i_correction); + }if (implicit) Jacobian.AddVal2Diag(iPoint, max(0.0, EdgeMassFlux)); // /*--- Viscous contribution, commented out because serious convergence problems ---*/ // @@ -774,12 +751,6 @@ void CTurbSASolver::BC_Outlet(CGeometry *geometry, CSolver **solver_container, C } } END_SU2_OMP_FOR - - /*--- Delete jacobian correction variable ---*/ - for (unsigned short iVar=0; iVarGetBoundedScalar(); su2double EdgeMassFlux = 0.0; - su2double **Jacobian_i_correction; - Jacobian_i_correction = new su2double*[nVar]; - for (unsigned short iVar=0; iVar prim_idx(config->GetKind_Regime() == ENUM_REGIME::INCOMPRESSIBLE, config->GetNEMOProblem(), nDim, config->GetnSpecies()); @@ -673,7 +666,7 @@ void CTurbSSTSolver::BC_Inlet(CGeometry *geometry, CSolver **solver_container, C if(bounded_scalar){ /*--- Obtain flow velocity vector at inlet boundary node ---*/ su2double Velocity_Inlet[MAXNDIM] = {0.0}, density_inlet; - for (auto iDim = 0u; iDim < nDim; iDim++) Velocity_Inlet[iDim] = solver_container[FLOW_SOL]->GetNodes()->GetVelocity(iPoint, iDim); + for (auto iDim = 0u; iDim < nDim; iDim++) Velocity_Inlet[iDim] = V_inlet[iDim + 1];//solver_container[FLOW_SOL]->GetNodes()->GetVelocity(iPoint, iDim); /*--- Obtain density at inlet boundary node ---*/ density_inlet = solver_container[FLOW_SOL]->GetNodes()->GetDensity(iPoint); @@ -700,9 +693,8 @@ void CTurbSSTSolver::BC_Inlet(CGeometry *geometry, CSolver **solver_container, C su2double FluxCorrection_i = GetNodes()->GetSolution(iPoint, iVar) * EdgeMassFlux; LinSysRes(iPoint, iVar) -= FluxCorrection_i; - Jacobian_i_correction[iVar][iVar] = max(0.0, EdgeMassFlux); } - }if (implicit) Jacobian.AddBlock2Diag(iPoint, Jacobian_i_correction); + }if (implicit) Jacobian.AddVal2Diag(iPoint, max(0.0, EdgeMassFlux)); // /*--- Viscous contribution, commented out because serious convergence problems ---*/ // @@ -738,13 +730,6 @@ void CTurbSSTSolver::BC_Inlet(CGeometry *geometry, CSolver **solver_container, C } END_SU2_OMP_FOR - - /*--- Delete jacobian correction variable ---*/ - for (unsigned short iVar=0; iVarGetKind_TimeIntScheme() == EULER_IMPLICIT); const bool bounded_scalar = conv_numerics->GetBoundedScalar(); + su2double EdgeMassFlux = 0.0; - su2double **Jacobian_i_correction; - Jacobian_i_correction = new su2double*[nVar]; - for (unsigned short iVar=0; iVarGetNodes()->GetVelocity(iPoint, iDim); + for (auto iDim = 0u; iDim < nDim; iDim++) Velocity_Outlet[iDim] = V_outlet[iDim + 1]; /*--- Obtain density at inlet boundary node ---*/ density_outlet = solver_container[FLOW_SOL]->GetNodes()->GetDensity(iPoint); @@ -833,9 +811,8 @@ void CTurbSSTSolver::BC_Outlet(CGeometry *geometry, CSolver **solver_container, su2double FluxCorrection_i = GetNodes()->GetSolution(iPoint, iVar) * EdgeMassFlux; LinSysRes(iPoint, iVar) -= FluxCorrection_i; - Jacobian_i_correction[iVar][iVar] = max(0.0, EdgeMassFlux); } - }if (implicit) Jacobian.AddBlock2Diag(iPoint, Jacobian_i_correction); + }if (implicit) Jacobian.AddVal2Diag(iPoint, max(0.0, EdgeMassFlux)); // /*--- Viscous contribution, commented out because serious convergence problems ---*/ // @@ -870,11 +847,6 @@ void CTurbSSTSolver::BC_Outlet(CGeometry *geometry, CSolver **solver_container, } } END_SU2_OMP_FOR - - for (unsigned short iVar=0; iVar Date: Fri, 25 Nov 2022 11:29:21 +0100 Subject: [PATCH 44/48] pulled develop --- TestCases/parallel_regression.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/TestCases/parallel_regression.py b/TestCases/parallel_regression.py index 40e3eaead21..a88117e7161 100644 --- a/TestCases/parallel_regression.py +++ b/TestCases/parallel_regression.py @@ -1339,7 +1339,7 @@ def main(): species2_primitiveVenturi_mixingmodel_boundedscalar.cfg_dir = "species_transport/venturi_primitive_3species" species2_primitiveVenturi_mixingmodel_boundedscalar.cfg_file = "species2_primitiveVenturi_mixingmodel_boundedscalar.cfg" species2_primitiveVenturi_mixingmodel_boundedscalar.test_iter = 50 - species2_primitiveVenturi_mixingmodel_boundedscalar.test_vals = [-5.455291, -4.498666, -4.519242, -5.704567, -0.119829, -5.607849, 5.000000, -1.989997, 5.000000, -5.220908, 5.000000, -2.564004, 0.000273, 0.000273, 0.000000, 0.000000] + species2_primitiveVenturi_mixingmodel_boundedscalar.test_vals = [-5.415205, -4.481321, -4.488545, -5.717240, -0.115974, -5.604208, 5.000000, -1.793666, 5.000000, -4.746865, 5.000000, -2.251480, 0.000276, 0.000276, 0.000000, 0.000000] species2_primitiveVenturi_mixingmodel_boundedscalar.new_output = True test_list.append(species2_primitiveVenturi_mixingmodel_boundedscalar) @@ -1390,7 +1390,7 @@ def main(): species_primitiveVenturi_boundedscalar.cfg_dir = "species_transport/venturi_primitive_3species" species_primitiveVenturi_boundedscalar.cfg_file = "species2_primitiveVenturi_boundedscalar.cfg" species_primitiveVenturi_boundedscalar.test_iter = 50 - species_primitiveVenturi_boundedscalar.test_vals = [-5.316921, -4.348960, -4.354985, -5.811668, -0.958752, -5.489816, 5.000000, -1.982307, 5.000000, -4.457756, 5.000000, -2.359724, 0.000390, 0.0003840, 0.000000, 0.000000] + species_primitiveVenturi_boundedscalar.test_vals = [-5.281748, -4.335720, -4.330212, -5.877476, -0.944352, -5.476891, 5.000000, -1.790723, 5.000000, -4.055926, 5.000000, -2.225729, 0.000435, 0.000435, 0.000000, 0.000000] species_primitiveVenturi_boundedscalar.new_output = True test_list.append(species_primitiveVenturi_boundedscalar) From 09cadc64b819bc8e192970c4b71f4651748d5079 Mon Sep 17 00:00:00 2001 From: Pedro Gomes Date: Fri, 25 Nov 2022 12:24:31 -0800 Subject: [PATCH 45/48] fix bounded scalars for OpenMP, improve efficiency, fix for centered discretization, bounded scalars not compatible with compressible flows, fix formatting and trailing spaces --- Common/include/CConfig.hpp | 27 ++++----- Common/src/CConfig.cpp | 4 ++ SU2_CFD/include/numerics/CNumerics.hpp | 8 +-- .../numerics/scalar/scalar_convection.hpp | 33 ++++++----- .../numerics/species/species_convection.hpp | 5 +- .../numerics/turbulent/turb_convection.hpp | 5 +- .../include/solvers/CFVMFlowSolverBase.hpp | 6 +- SU2_CFD/include/solvers/CScalarSolver.hpp | 4 -- SU2_CFD/include/solvers/CScalarSolver.inl | 56 ++++++++++++++----- SU2_CFD/include/solvers/CSolver.hpp | 8 +-- SU2_CFD/src/drivers/CDriver.cpp | 4 +- .../src/numerics/species/species_sources.cpp | 25 ++++----- SU2_CFD/src/solvers/CEulerSolver.cpp | 6 -- SU2_CFD/src/solvers/CIncEulerSolver.cpp | 20 ++++--- SU2_CFD/src/solvers/CIncNSSolver.cpp | 9 +-- 15 files changed, 106 insertions(+), 114 deletions(-) diff --git a/Common/include/CConfig.hpp b/Common/include/CConfig.hpp index 15c712b1f9a..1e501b3e4ea 100644 --- a/Common/include/CConfig.hpp +++ b/Common/include/CConfig.hpp @@ -543,15 +543,15 @@ class CConfig { Kind_Centered_AdjTurb, /*!< \brief Centered scheme for the adjoint turbulence model. */ Kind_Centered_Species, /*!< \brief Centered scheme for the species model. */ Kind_Centered_Template; /*!< \brief Centered scheme for the template model. */ - - + + FEM_SHOCK_CAPTURING_DG Kind_FEM_Shock_Capturing_DG; /*!< \brief Shock capturing method for the FEM DG solver. */ BGS_RELAXATION Kind_BGS_RelaxMethod; /*!< \brief Kind of relaxation method for Block Gauss Seidel method in FSI problems. */ bool ReconstructionGradientRequired; /*!< \brief Enable or disable a second gradient calculation for upwind reconstruction only. */ bool LeastSquaresRequired; /*!< \brief Enable or disable memory allocation for least-squares gradient methods. */ bool Energy_Equation; /*!< \brief Solve the energy equation for incompressible flows. */ - UPWIND + UPWIND Kind_Upwind, /*!< \brief Upwind scheme. */ Kind_Upwind_Flow, /*!< \brief Upwind scheme for the flow equations. */ Kind_Upwind_AdjFlow, /*!< \brief Upwind scheme for the adjoint flow equations. */ @@ -4787,27 +4787,20 @@ class CConfig { UPWIND GetKind_Upwind_Species() const { return Kind_Upwind_Species; } /*! - * \brief Get bounded scalar problem for species or turbulence - * \note This value is obtained from the config file, and it is constant - * during the computation. - * \return Bounded scalar problem for turbulence or species transport. + * \brief Returns true if bounded scalar mode is on for species transport. */ - bool GetBounded_Scalar() const { - return (Kind_Upwind_Turb == UPWIND::BOUNDED_SCALAR) || (Kind_Upwind_Species == UPWIND::BOUNDED_SCALAR); - } + bool GetBounded_Species() const { return (Kind_Upwind_Species == UPWIND::BOUNDED_SCALAR); } /*! - * \brief Get bounded scalar problem for species transport. - * \return Bounded scalar problem for species transport. + * \brief Returns true if bounded scalar mode is on for turbulence transport. */ - bool GetBounded_Species() const { return (Kind_Upwind_Species == UPWIND::BOUNDED_SCALAR); } + bool GetBounded_Turb() const { return (Kind_Upwind_Turb == UPWIND::BOUNDED_SCALAR); } /*! - * \brief Get bounded scalar problem for turbulent transport. - * \return Bounded scalar problem for turbulent transport. + * \brief Returns true if bounded scalar mode is used for any equation. */ - bool GetBounded_Turb() const { return (Kind_Upwind_Turb == UPWIND::BOUNDED_SCALAR); } - + bool GetBounded_Scalar() const { return GetBounded_Species() || GetBounded_Turb(); } + /*! * \brief Get the kind of convective numerical scheme for the heat equation. * \note This value is obtained from the config file, and it is constant diff --git a/Common/src/CConfig.cpp b/Common/src/CConfig.cpp index a8433958655..ef395ab0203 100644 --- a/Common/src/CConfig.cpp +++ b/Common/src/CConfig.cpp @@ -5431,6 +5431,10 @@ void CConfig::SetPostprocessing(SU2_COMPONENT val_software, unsigned short val_i } } // species transport checks + + if (Kind_Regime == ENUM_REGIME::COMPRESSIBLE && GetBounded_Scalar()) { + SU2_MPI::Error("BOUNDED_SCALAR discretization can only be used for incompressible problems.", CURRENT_FUNCTION); + } } void CConfig::SetMarkers(SU2_COMPONENT val_software) { diff --git a/SU2_CFD/include/numerics/CNumerics.hpp b/SU2_CFD/include/numerics/CNumerics.hpp index 337ca9051a2..d493ac5c365 100644 --- a/SU2_CFD/include/numerics/CNumerics.hpp +++ b/SU2_CFD/include/numerics/CNumerics.hpp @@ -191,7 +191,7 @@ class CNumerics { bool uq_permute; /*!< \brief Flag for eigenvector permutation */ bool nemo; /*!< \brief Flag for NEMO problems */ - + bool bounded_scalar = false; /*!< \brief Flag for bounded scalar problem */ public: @@ -1618,12 +1618,6 @@ class CNumerics { */ inline void SetMassFlux(const su2double val_MassFlux) { MassFlux = val_MassFlux; } - /*! - * \brief Set bounded scalar transport problem - * \param[in] is_bounded_scalar : scalar solver uses bounded scalar convective transport - */ - inline void SetBoundedScalar(const bool is_bounded_scalar) { bounded_scalar = is_bounded_scalar; } - /*! * \brief Obtain information on bounded scalar problem * \return is_bounded_scalar : scalar solver uses bounded scalar convective transport diff --git a/SU2_CFD/include/numerics/scalar/scalar_convection.hpp b/SU2_CFD/include/numerics/scalar/scalar_convection.hpp index 07799d73f6e..0bee8810425 100644 --- a/SU2_CFD/include/numerics/scalar/scalar_convection.hpp +++ b/SU2_CFD/include/numerics/scalar/scalar_convection.hpp @@ -121,25 +121,24 @@ class CUpwScalar : public CNumerics { ExtraADPreaccIn(); - su2double q_ij = 0.0; - if (dynamic_grid) { - for (unsigned short iDim = 0; iDim < nDim; iDim++) { - su2double Velocity_i = V_i[iDim + idx.Velocity()] - GridVel_i[iDim]; - su2double Velocity_j = V_j[iDim + idx.Velocity()] - GridVel_j[iDim]; - q_ij += 0.5 * (Velocity_i + Velocity_j) * Normal[iDim]; - } - } else { - for (unsigned short iDim = 0; iDim < nDim; iDim++) { - q_ij += 0.5 * (V_i[iDim + idx.Velocity()] + V_j[iDim + idx.Velocity()]) * Normal[iDim]; - } - } - if (bounded_scalar) { - a0 = max(0.0, MassFlux) / V_i[idx.Density()]; - a1 = min(0.0, MassFlux) / V_j[idx.Density()]; + a0 = fmax(0.0, MassFlux) / V_i[idx.Density()]; + a1 = fmin(0.0, MassFlux) / V_j[idx.Density()]; } else { - a0 = 0.5 * (q_ij + fabs(q_ij)); - a1 = 0.5 * (q_ij - fabs(q_ij)); + su2double q_ij = 0.0; + if (dynamic_grid) { + for (unsigned short iDim = 0; iDim < nDim; iDim++) { + su2double Velocity_i = V_i[iDim + idx.Velocity()] - GridVel_i[iDim]; + su2double Velocity_j = V_j[iDim + idx.Velocity()] - GridVel_j[iDim]; + q_ij += 0.5 * (Velocity_i + Velocity_j) * Normal[iDim]; + } + } else { + for (unsigned short iDim = 0; iDim < nDim; iDim++) { + q_ij += 0.5 * (V_i[iDim + idx.Velocity()] + V_j[iDim + idx.Velocity()]) * Normal[iDim]; + } + } + a0 = fmax(0.0, q_ij); + a1 = fmin(0.0, q_ij); } FinishResidualCalc(config); diff --git a/SU2_CFD/include/numerics/species/species_convection.hpp b/SU2_CFD/include/numerics/species/species_convection.hpp index b02226f34bd..64f296faff8 100644 --- a/SU2_CFD/include/numerics/species/species_convection.hpp +++ b/SU2_CFD/include/numerics/species/species_convection.hpp @@ -56,10 +56,7 @@ class CUpwSca_Species final : public CUpwScalar { /*! * \brief Adds any extra variables to AD */ - void ExtraADPreaccIn() override { - AD::SetPreaccIn(V_i[idx.Density()]); - AD::SetPreaccIn(V_j[idx.Density()]); - }; + void ExtraADPreaccIn() override {} /*! * \brief Species transport specific steps in the ComputeResidual method diff --git a/SU2_CFD/include/numerics/turbulent/turb_convection.hpp b/SU2_CFD/include/numerics/turbulent/turb_convection.hpp index 867b555a513..652a0c907b4 100644 --- a/SU2_CFD/include/numerics/turbulent/turb_convection.hpp +++ b/SU2_CFD/include/numerics/turbulent/turb_convection.hpp @@ -106,10 +106,7 @@ class CUpwSca_TurbSST final : public CUpwScalar { /*! * \brief Adds any extra variables to AD */ - void ExtraADPreaccIn() override { - AD::SetPreaccIn(V_i[idx.Density()]); - AD::SetPreaccIn(V_j[idx.Density()]); - } + void ExtraADPreaccIn() override {} /*! * \brief SST specific steps in the ComputeResidual method diff --git a/SU2_CFD/include/solvers/CFVMFlowSolverBase.hpp b/SU2_CFD/include/solvers/CFVMFlowSolverBase.hpp index b15d22acb57..0b52f52d90b 100644 --- a/SU2_CFD/include/solvers/CFVMFlowSolverBase.hpp +++ b/SU2_CFD/include/solvers/CFVMFlowSolverBase.hpp @@ -2405,10 +2405,8 @@ class CFVMFlowSolverBase : public CSolver { } /*! - * \brief Get the mass flux across an edge (computed and stored during the discretization of convective fluxes). - * \param[in] iEdge - Index of the edge. - * \return The mass flux across the edge. + * \brief Get the mass fluxes across the edges (computed and stored during the discretization of convective fluxes). */ - inline su2double GetEdgeMassFlux(const unsigned long iEdge) const final { return EdgeMassFluxes[iEdge]; } + inline const su2activevector* GetEdgeMassFluxes() const final { return &EdgeMassFluxes; } }; diff --git a/SU2_CFD/include/solvers/CScalarSolver.hpp b/SU2_CFD/include/solvers/CScalarSolver.hpp index 0cf644b83ce..e5e10611296 100644 --- a/SU2_CFD/include/solvers/CScalarSolver.hpp +++ b/SU2_CFD/include/solvers/CScalarSolver.hpp @@ -61,10 +61,6 @@ class CScalarSolver : public CSolver { vector > SlidingState; // vector of matrix of pointers... inner dim alloc'd elsewhere (welcome, to the twilight zone) vector > SlidingStateNodes; - /*!< \brief Jacobian correction terms for bounded scalar problems. */ - // su2activematrix Jacobian_correction_i, - // Jacobian_correction_j; - /*--- Shallow copy of grid coloring for OpenMP parallelization. ---*/ #ifdef HAVE_OMP diff --git a/SU2_CFD/include/solvers/CScalarSolver.inl b/SU2_CFD/include/solvers/CScalarSolver.inl index cde43a835f0..39563925cea 100644 --- a/SU2_CFD/include/solvers/CScalarSolver.inl +++ b/SU2_CFD/include/solvers/CScalarSolver.inl @@ -70,10 +70,6 @@ CScalarSolver::CScalarSolver(CGeometry* geometry, CConfig* config, lowerlimit[iVar] = std::numeric_limits::lowest(); upperlimit[iVar] = std::numeric_limits::max(); } - - // /*--- Setting size for bounded scalar Jacobian correction ---*/ - // Jacobian_correction_i.resize(nVar, nVar); - // Jacobian_correction_j.resize(nVar, nVar); } template @@ -137,6 +133,7 @@ void CScalarSolver::Upwind_Residual(CGeometry* geometry, CSolver** (config->GetKind_SlopeLimit_Flow() != LIMITER::NONE) && (config->GetKind_SlopeLimit_Flow() != LIMITER::VAN_ALBADA_EDGE); auto* flowNodes = su2staticcast_p(solver_container[FLOW_SOL]->GetNodes()); + const auto& edgeMassFluxes = *(solver_container[FLOW_SOL]->GetEdgeMassFluxes()); /*--- Pick one numerics object per thread. ---*/ auto* numerics = numerics_container[CONV_TERM + omp_get_thread_num() * MAX_TERMS]; @@ -199,8 +196,10 @@ void CScalarSolver::Upwind_Residual(CGeometry* geometry, CSolver** Vector_ij[iDim] = 0.5 * (Coord_j[iDim] - Coord_i[iDim]); } - if (musclFlow) { - /*--- Reconstruct mean flow primitive variables. ---*/ + if (musclFlow && !bounded_scalar) { + /*--- Reconstruct mean flow primitive variables, note that in bounded scalar mode this is + * not necessary because the edge mass flux is read directly from the flow solver, instead + * of being computed from the primitive flow variables. ---*/ auto Gradient_i = flowNodes->GetGradient_Reconstruction(iPoint); auto Gradient_j = flowNodes->GetGradient_Reconstruction(jPoint); @@ -260,11 +259,12 @@ void CScalarSolver::Upwind_Residual(CGeometry* geometry, CSolver** /*--- Convective flux ---*/ su2double EdgeMassFlux = 0.0; if (bounded_scalar) { - EdgeMassFlux = solver_container[FLOW_SOL]->GetEdgeMassFlux(iEdge); + EdgeMassFlux = edgeMassFluxes[iEdge]; numerics->SetMassFlux(EdgeMassFlux); } - + /*--- Update convective residual value ---*/ + auto residual = numerics->ComputeResidual(config); if (ReducerStrategy) { @@ -276,18 +276,24 @@ void CScalarSolver::Upwind_Residual(CGeometry* geometry, CSolver** if (implicit) Jacobian.UpdateBlocks(iEdge, iPoint, jPoint, residual.jacobian_i, residual.jacobian_j); } - /*--- Applying convective flux correction to negate the effects of flow divergence ---*/ - if(bounded_scalar){ - for(iVar=0; iVarGetSolution(iPoint, iVar) * EdgeMassFlux; - su2double FluxCorrection_j = GetNodes()->GetSolution(jPoint, iVar) * EdgeMassFlux; + /*--- Apply convective flux correction to negate the effects of flow divergence. + * If the ReducerStrategy is used, the corrections need to be applied in a loop over nodes + * to avoid race conditions in accessing nodes shared by edges handled by different threads. ---*/ + + if (bounded_scalar && !ReducerStrategy) { + for (iVar = 0; iVar < nVar; iVar++) { + const su2double FluxCorrection_i = nodes->GetSolution(iPoint, iVar) * EdgeMassFlux; + const su2double FluxCorrection_j = nodes->GetSolution(jPoint, iVar) * EdgeMassFlux; LinSysRes(iPoint, iVar) -= FluxCorrection_i; LinSysRes(jPoint, iVar) += FluxCorrection_j; } - Jacobian.AddVal2Diag(iPoint, -EdgeMassFlux); - Jacobian.AddVal2Diag(jPoint, EdgeMassFlux); + if (implicit) { + Jacobian.AddVal2Diag(iPoint, -EdgeMassFlux); + Jacobian.AddVal2Diag(jPoint, EdgeMassFlux); + } } + /*--- Viscous contribution. ---*/ Viscous_Residual(iEdge, geometry, solver_container, @@ -303,6 +309,26 @@ void CScalarSolver::Upwind_Residual(CGeometry* geometry, CSolver** if (ReducerStrategy) { SumEdgeFluxes(geometry); if (implicit) Jacobian.SetDiagonalAsColumnSum(); + + /*--- Bounded scalar correction that cannot be applied in the edge loop when using the ReducerStrategy. ---*/ + if (bounded_scalar) { + SU2_OMP_FOR_STAT(omp_chunk_size) + for (unsigned long iPoint = 0; iPoint < nPoint; ++iPoint) { + const auto* solution = nodes->GetSolution(iPoint); + su2double divergence = 0; + + for (auto iEdge : geometry->nodes->GetEdges(iPoint)) { + const auto sign = (iPoint == geometry->edges->GetNode(iEdge,0)) ? 1 : -1; + const su2double EdgeMassFlux = sign * edgeMassFluxes[iEdge]; + divergence += EdgeMassFlux; + LinSysRes.AddBlock(iPoint, solution, -EdgeMassFlux); + } + if (implicit) { + Jacobian.AddVal2Diag(iPoint, -divergence); + } + } + END_SU2_OMP_FOR + } } } diff --git a/SU2_CFD/include/solvers/CSolver.hpp b/SU2_CFD/include/solvers/CSolver.hpp index 0fede683cdf..36c541117e5 100644 --- a/SU2_CFD/include/solvers/CSolver.hpp +++ b/SU2_CFD/include/solvers/CSolver.hpp @@ -30,6 +30,7 @@ #include "../../../Common/include/parallelization/mpi_structure.hpp" #include +#include #include #include #include @@ -3000,11 +3001,10 @@ class CSolver { inline virtual su2double GetEddyViscWall(unsigned short val_marker, unsigned long val_vertex) const { return 0; } /*! - * \brief A virtual member - * \param[in] iEdge - Index of the edge. - * \return The mass flux across the edge. + * \brief A virtual member + * \return The mass fluxes (from flow solvers) across the edges. */ - inline virtual su2double GetEdgeMassFlux(const unsigned long iEdge) const { return 0; } + inline virtual const su2activevector* GetEdgeMassFluxes() const { return nullptr; } /*! * \brief A virtual member. diff --git a/SU2_CFD/src/drivers/CDriver.cpp b/SU2_CFD/src/drivers/CDriver.cpp index 5ba2ae2f221..4eed3037c64 100644 --- a/SU2_CFD/src/drivers/CDriver.cpp +++ b/SU2_CFD/src/drivers/CDriver.cpp @@ -1269,7 +1269,6 @@ void CDriver::InstantiateTurbulentNumerics(unsigned short nVar_Turb, int offset, } else if (menter_sst) numerics[iMGlevel][TURB_SOL][conv_term] = new CUpwSca_TurbSST(nDim, nVar_Turb, config); - } break; default: @@ -1322,8 +1321,7 @@ void CDriver::InstantiateTurbulentNumerics(unsigned short nVar_Turb, int offset, numerics[iMGlevel][TURB_SOL][visc_bound_term] = new CAvgGrad_TurbSST(nDim, nVar_Turb, constants, false, config); } - - } + } } /*--- Explicit instantiation of the template above, needed because it is defined in a cpp file, instead of hpp. ---*/ template void CDriver::InstantiateTurbulentNumerics>( diff --git a/SU2_CFD/src/numerics/species/species_sources.cpp b/SU2_CFD/src/numerics/species/species_sources.cpp index 64239886bbd..8df8cafb4f0 100644 --- a/SU2_CFD/src/numerics/species/species_sources.cpp +++ b/SU2_CFD/src/numerics/species/species_sources.cpp @@ -68,13 +68,11 @@ CSourceAxisymmetric_Species::CSourceAxisymmetric_Species(unsigned short val_n template CNumerics::ResidualType<> CSourceAxisymmetric_Species::ComputeResidual(const CConfig* config) { - - /*--- Preaccumulation ---*/ AD::StartPreacc(); AD::SetPreaccIn(ScalarVar_i, nVar); - AD::SetPreaccIn(Volume); - + AD::SetPreaccIn(Volume); + if (incompressible) { AD::SetPreaccIn(V_i, nDim+6); } @@ -95,29 +93,30 @@ CNumerics::ResidualType<> CSourceAxisymmetric_Species::ComputeResidual(const AD::SetPreaccIn(Coord_i[1]); AD::SetPreaccIn(Diffusion_Coeff_i, nVar); - AD::SetPreaccIn(ScalarVar_Grad_i, nVar, nDim); + AD::SetPreaccIn(ScalarVar_Grad_i, nVar, nDim); const su2double yinv = 1.0 / Coord_i[1]; const su2double Density_i = V_i[idx.Density()]; - + su2double Velocity_i[3]; for (auto iDim = 0u; iDim < nDim; iDim++) Velocity_i[iDim] = V_i[idx.Velocity() + iDim]; /*--- Inviscid component of the source term. ---*/ - if(!bounded_scalar){ + if (!bounded_scalar) { for (auto iVar = 0u; iVar < nVar; iVar++) residual[iVar] -= yinv * Volume * Density_i * ScalarVar_i[iVar] * Velocity_i[1]; - + if (implicit) { for (auto iVar = 0u; iVar < nVar; iVar++) { jacobian[iVar][iVar] -= yinv * Volume * Velocity_i[1]; } } } - /*--- Add the viscous terms if necessary. ---*/ - + + /*--- Add the viscous terms if necessary. ---*/ + if (config->GetViscous()) { su2double Mass_Diffusivity_Tur = 0.0; if (turbulence) @@ -125,11 +124,11 @@ CNumerics::ResidualType<> CSourceAxisymmetric_Species::ComputeResidual(const for (auto iVar=0u; iVar < nVar; iVar++){ residual[iVar] += yinv * Volume * (Density_i * Diffusion_Coeff_i[iVar] + Mass_Diffusivity_Tur) * ScalarVar_Grad_i[iVar][1]; - } + } } - + } - + AD::SetPreaccOut(residual, nVar); AD::EndPreacc(); diff --git a/SU2_CFD/src/solvers/CEulerSolver.cpp b/SU2_CFD/src/solvers/CEulerSolver.cpp index 04159b3e4ca..caff7e53f0d 100644 --- a/SU2_CFD/src/solvers/CEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CEulerSolver.cpp @@ -339,9 +339,6 @@ CEulerSolver::CEulerSolver(CGeometry *geometry, CConfig *config, * check at the bottom to make sure we consider the "final" values). ---*/ if((nDim > MAXNDIM) || (nPrimVar > MAXNVAR) || (nSecondaryVar > MAXNVAR)) SU2_MPI::Error("Oops! The CEulerSolver static array sizes are not large enough.",CURRENT_FUNCTION); - - if(config->GetBounded_Scalar()) - EdgeMassFluxes.resize(geometry->GetnEdge()) = su2double(0.0); } CEulerSolver::~CEulerSolver(void) { @@ -1739,8 +1736,6 @@ void CEulerSolver::Upwind_Residual(CGeometry *geometry, CSolver **solver_contain const bool limiter = (config->GetKind_SlopeLimit_Flow() != LIMITER::NONE); const bool van_albada = (config->GetKind_SlopeLimit_Flow() == LIMITER::VAN_ALBADA_EDGE); - const bool bounded_scalar = config->GetBounded_Scalar(); - /*--- Non-physical counter. ---*/ unsigned long counter_local = 0; SU2_OMP_MASTER @@ -1928,7 +1923,6 @@ void CEulerSolver::Upwind_Residual(CGeometry *geometry, CSolver **solver_contain Jacobian.UpdateBlocks(iEdge, iPoint, jPoint, residual.jacobian_i, residual.jacobian_j); } - if (bounded_scalar) EdgeMassFluxes[iEdge] = residual.residual[0]; /*--- Viscous contribution. ---*/ Viscous_Residual(iEdge, geometry, solver_container, diff --git a/SU2_CFD/src/solvers/CIncEulerSolver.cpp b/SU2_CFD/src/solvers/CIncEulerSolver.cpp index 62009b26311..07f2ea97b87 100644 --- a/SU2_CFD/src/solvers/CIncEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CIncEulerSolver.cpp @@ -223,7 +223,7 @@ CIncEulerSolver::CIncEulerSolver(CGeometry *geometry, CConfig *config, unsigned CommunicateInitialState(geometry, config); /*--- Sizing edge mass flux array ---*/ - if(config->GetBounded_Scalar()) + if (config->GetBounded_Scalar()) EdgeMassFluxes.resize(geometry->GetnEdge()) = su2double(0.0); /*--- Add the solver name (max 8 characters) ---*/ @@ -1055,8 +1055,9 @@ void CIncEulerSolver::Centered_Residual(CGeometry *geometry, CSolver **solver_co unsigned long iPoint, jPoint; - bool implicit = (config->GetKind_TimeIntScheme() == EULER_IMPLICIT); - bool jst_scheme = ((config->GetKind_Centered_Flow() == CENTERED::JST) && (iMesh == MESH_0)); + const bool implicit = (config->GetKind_TimeIntScheme() == EULER_IMPLICIT); + const bool jst_scheme = ((config->GetKind_Centered_Flow() == CENTERED::JST) && (iMesh == MESH_0)); + const bool bounded_scalar = config->GetBounded_Scalar(); /*--- For hybrid parallel AD, pause preaccumulation if there is shared reading of * variables, otherwise switch to the faster adjoint evaluation mode. ---*/ @@ -1104,6 +1105,8 @@ void CIncEulerSolver::Centered_Residual(CGeometry *geometry, CSolver **solver_co auto residual = numerics->ComputeResidual(config); + if (bounded_scalar) EdgeMassFluxes[iEdge] = residual[0]; + /*--- Update residual value ---*/ if (ReducerStrategy) { @@ -1159,7 +1162,7 @@ void CIncEulerSolver::Upwind_Residual(CGeometry *geometry, CSolver **solver_cont const bool muscl = (config->GetMUSCL_Flow() && (iMesh == MESH_0)); const bool limiter = (config->GetKind_SlopeLimit_Flow() != LIMITER::NONE); const bool van_albada = (config->GetKind_SlopeLimit_Flow() == LIMITER::VAN_ALBADA_EDGE); - const bool bounded_scalar = (config->GetBounded_Scalar()); + const bool bounded_scalar = config->GetBounded_Scalar(); /*--- For hybrid parallel AD, pause preaccumulation if there is shared reading of * variables, otherwise switch to the faster adjoint evaluation mode. ---*/ @@ -1278,6 +1281,8 @@ void CIncEulerSolver::Upwind_Residual(CGeometry *geometry, CSolver **solver_cont auto residual = numerics->ComputeResidual(config); + if (bounded_scalar) EdgeMassFluxes[iEdge] = residual[0]; + /*--- Update residual value ---*/ if (ReducerStrategy) { @@ -1299,9 +1304,6 @@ void CIncEulerSolver::Upwind_Residual(CGeometry *geometry, CSolver **solver_cont Viscous_Residual(iEdge, geometry, solver_container, numerics_container[VISC_TERM + omp_get_thread_num()*MAX_TERMS], config); - if (bounded_scalar) EdgeMassFluxes[iEdge] = residual[0]; - - } END_SU2_OMP_FOR } // end color loop @@ -2895,7 +2897,7 @@ void CIncEulerSolver::GetOutlet_Properties(CGeometry *geometry, CConfig *config, geometry->vertex[iMarker][iVertex]->GetNormal(Vector); - su2double AxiFactor = 1.0; + su2double AxiFactor = 1.0; if (axisymmetric) { if (geometry->nodes->GetCoord(iPoint, 1) > EPS) AxiFactor = 2.0*PI_NUMBER*geometry->nodes->GetCoord(iPoint, 1); @@ -2906,7 +2908,7 @@ void CIncEulerSolver::GetOutlet_Properties(CGeometry *geometry, CConfig *config, } } } - } + } Density = V_outlet[prim_idx.Density()]; diff --git a/SU2_CFD/src/solvers/CIncNSSolver.cpp b/SU2_CFD/src/solvers/CIncNSSolver.cpp index 7fa2c87b303..79063af583b 100644 --- a/SU2_CFD/src/solvers/CIncNSSolver.cpp +++ b/SU2_CFD/src/solvers/CIncNSSolver.cpp @@ -43,11 +43,6 @@ CIncNSSolver::CIncNSSolver(CGeometry *geometry, CConfig *config, unsigned short Viscosity_Inf = config->GetViscosity_FreeStreamND(); Tke_Inf = config->GetTke_FreeStreamND(); - /*--- Sizing edge mass flux array ---*/ - if(config->GetBounded_Scalar()) - EdgeMassFluxes.resize(geometry->GetnEdge()) = su2double(0.0); - - /*--- Initialize the secondary values for direct derivative approximations ---*/ switch (config->GetDirectDiff()) { @@ -314,7 +309,7 @@ unsigned long CIncNSSolver::SetPrimitive_Variables(CSolver **solver_container, c if (species_model != SPECIES_MODEL::NONE && solver_container[SPECIES_SOL] != nullptr) { scalar = solver_container[SPECIES_SOL]->GetNodes()->GetSolution(iPoint); } - + /*--- Incompressible flow, primitive variables --- */ bool physical = static_cast(nodes)->SetPrimVar(iPoint,eddy_visc, turb_ke, GetFluidModel(), scalar); @@ -738,7 +733,7 @@ void CIncNSSolver::SetTau_Wall_WF(CGeometry *geometry, CSolver **solver_containe const su2double U_Plus = VelTangMod / U_Tau; /*--- Y+ defined by White & Christoph ---*/ - + const su2double kUp = kappa * U_Plus; // incompressible adiabatic result From 16f7c4c077df803b99d3e25c8dac2ab7155d3046 Mon Sep 17 00:00:00 2001 From: Pedro Gomes Date: Fri, 25 Nov 2022 23:08:12 -0800 Subject: [PATCH 46/48] avoid bounded scalar code duplication in BC's --- SU2_CFD/include/solvers/CScalarSolver.hpp | 53 +++++++-- SU2_CFD/include/solvers/CScalarSolver.inl | 73 +++++++++++-- SU2_CFD/include/solvers/CTransLMSolver.hpp | 18 +--- SU2_CFD/include/solvers/CTurbSASolver.hpp | 16 --- SU2_CFD/include/solvers/CTurbSSTSolver.hpp | 16 --- SU2_CFD/src/solvers/CSpeciesSolver.cpp | 69 +++--------- SU2_CFD/src/solvers/CTransLMSolver.cpp | 87 +++------------ SU2_CFD/src/solvers/CTurbSASolver.cpp | 115 ++------------------ SU2_CFD/src/solvers/CTurbSSTSolver.cpp | 119 ++------------------- 9 files changed, 154 insertions(+), 412 deletions(-) diff --git a/SU2_CFD/include/solvers/CScalarSolver.hpp b/SU2_CFD/include/solvers/CScalarSolver.hpp index e5e10611296..542a18315bf 100644 --- a/SU2_CFD/include/solvers/CScalarSolver.hpp +++ b/SU2_CFD/include/solvers/CScalarSolver.hpp @@ -31,6 +31,8 @@ #include "../../../Common/include/parallelization/omp_structure.hpp" #include "../../../Common/include/toolboxes/geometry_toolbox.hpp" #include "../variables/CScalarVariable.hpp" +#include "../variables/CFlowVariable.hpp" +#include "../variables/CPrimitiveIndices.hpp" #include "CSolver.hpp" /*! @@ -50,14 +52,15 @@ class CScalarSolver : public CSolver { unsigned long omp_chunk_size; /*!< \brief Chunk size used in light point loops. */ - su2double lowerlimit[MAXNVAR]; /*!< \brief contains lower limits for turbulence variables. Note that ::min() - returns the smallest positive value for floats. */ - su2double upperlimit[MAXNVAR]; /*!< \brief contains upper limits for turbulence variables. */ + su2double lowerlimit[MAXNVAR]; /*!< \brief contains lower limits for scalar variables. */ + su2double upperlimit[MAXNVAR]; /*!< \brief contains upper limits for scalar variables. */ su2double Solution_Inf[MAXNVAR]; /*!< \brief Far-field solution. */ const bool Conservative; /*!< \brief Transported Variable is conservative. Solution has to be multiplied with rho. */ + const CPrimitiveIndices prim_idx; /*!< \brief Indices of the primitive flow variables. */ + vector > SlidingState; // vector of matrix of pointers... inner dim alloc'd elsewhere (welcome, to the twilight zone) vector > SlidingStateNodes; @@ -86,7 +89,7 @@ class CScalarSolver : public CSolver { inline CVariable* GetBaseClassPointerToNodes() final { return nodes; } /*! - * \brief Compute the viscous flux for the turbulent equation at a particular edge. + * \brief Compute the viscous flux for the scalar equation at a particular edge. * \tparam SolverSpecificNumericsFunc - lambda-function, that implements solver specific contributions to numerics. * \note The functor has to implement (iPoint, jPoint) * \param[in] iEdge - Edge for which we want to compute the flux @@ -100,7 +103,7 @@ class CScalarSolver : public CSolver { CGeometry* geometry, CSolver** solver_container, CNumerics* numerics, CConfig* config) { const bool implicit = (config->GetKind_TimeIntScheme() == EULER_IMPLICIT); - CVariable* flowNodes = solver_container[FLOW_SOL]->GetNodes(); + auto* flowNodes = su2staticcast_p(solver_container[FLOW_SOL]->GetNodes()); /*--- Points in edge ---*/ @@ -177,7 +180,7 @@ class CScalarSolver : public CSolver { su2double* PrimVar_i = solver_container[FLOW_SOL]->GetNodes()->GetPrimitive(iPoint); - auto Jacobian_i = Jacobian.GetBlock(iPoint,iPoint); + auto* Jacobian_i = Jacobian.GetBlock(iPoint, iPoint); /*--- Loop over the nDonorVertexes and compute the averaged flux ---*/ @@ -208,6 +211,12 @@ class CScalarSolver : public CSolver { if (dynamic_grid) conv_numerics->SetGridVel(geometry->nodes->GetGridVel(iPoint), geometry->nodes->GetGridVel(iPoint)); + if (conv_numerics->GetBoundedScalar()) { + const su2double* velocity = &PrimVar_j[prim_idx.Velocity()]; + const su2double density = solver_container[FLOW_SOL]->GetNodes()->GetDensity(iPoint); + conv_numerics->SetMassFlux(BoundedScalarBCFlux(iPoint, true, density, velocity, Normal)); + } + auto residual = conv_numerics->ComputeResidual(config); /*--- Accumulate the residuals to compute the average ---*/ @@ -255,6 +264,20 @@ class CScalarSolver : public CSolver { } } + /*! + * \brief Applies a convective flux correction to negate the effects of flow divergence at a BC node. + * \note This function should be used for nodes that are part of a boundary marker, it computes a mass flux + * from density and velocity at the node, and the outward-poiting normal (-1 * normal of vertex). + * \return The mass flux. + */ + inline su2double BoundedScalarBCFlux(unsigned long iPoint, bool implicit, const su2double& density, + const su2double* velocity, const su2double* normal) { + const su2double edgeMassFlux = density * GeometryToolbox::DotProduct(nDim, velocity, normal); + LinSysRes.AddBlock(iPoint, nodes->GetSolution(iPoint), -edgeMassFlux); + if (implicit) Jacobian.AddVal2Diag(iPoint, -edgeMassFlux); + return edgeMassFlux; + } + /*! * \brief Gradient and Limiter computation. * \param[in] geometry - Geometrical definition of the problem. @@ -265,7 +288,7 @@ class CScalarSolver : public CSolver { private: /*! - * \brief Compute the viscous flux for the turbulent equation at a particular edge. + * \brief Compute the viscous flux for the scalar equation at a particular edge. * \param[in] iEdge - Edge for which we want to compute the flux * \param[in] geometry - Geometrical definition of the problem. * \param[in] solver_container - Container vector with all the solutions. @@ -319,8 +342,20 @@ class CScalarSolver : public CSolver { * \param[in] config - Definition of the particular problem. * \param[in] iMesh - Index of the mesh in multigrid computations. */ - void Upwind_Residual(CGeometry* geometry, CSolver** solver_container, CNumerics** numerics_container, CConfig* config, - unsigned short iMesh) override; + void Upwind_Residual(CGeometry* geometry, CSolver** solver_container, CNumerics** numerics_container, + CConfig* config, unsigned short iMesh) override; + + /*! + * \brief Impose the Far Field boundary condition. + * \param[in] geometry - Geometrical definition of the problem. + * \param[in] solver_container - Container vector with all the solutions. + * \param[in] conv_numerics - Description of the numerical method. + * \param[in] visc_numerics - Description of the numerical method. + * \param[in] config - Definition of the particular problem. + * \param[in] val_marker - Surface marker where the boundary condition is applied. + */ + void BC_Far_Field(CGeometry *geometry, CSolver **solver_container, CNumerics *conv_numerics, + CNumerics *visc_numerics, CConfig *config, unsigned short val_marker) final; /*! * \brief Impose the Symmetry Plane boundary condition. diff --git a/SU2_CFD/include/solvers/CScalarSolver.inl b/SU2_CFD/include/solvers/CScalarSolver.inl index 39563925cea..06cc3acad67 100644 --- a/SU2_CFD/include/solvers/CScalarSolver.inl +++ b/SU2_CFD/include/solvers/CScalarSolver.inl @@ -31,7 +31,9 @@ template CScalarSolver::CScalarSolver(CGeometry* geometry, CConfig* config, bool conservative) - : CSolver(), Conservative(conservative) { + : CSolver(), Conservative(conservative), + prim_idx(config->GetKind_Regime() == ENUM_REGIME::INCOMPRESSIBLE, + config->GetNEMOProblem(), geometry->GetnDim(), config->GetnSpecies()) { nMarker = config->GetnMarker_All(); /*--- Store the number of vertices on each marker for deallocation later ---*/ @@ -281,13 +283,9 @@ void CScalarSolver::Upwind_Residual(CGeometry* geometry, CSolver** * to avoid race conditions in accessing nodes shared by edges handled by different threads. ---*/ if (bounded_scalar && !ReducerStrategy) { - for (iVar = 0; iVar < nVar; iVar++) { - const su2double FluxCorrection_i = nodes->GetSolution(iPoint, iVar) * EdgeMassFlux; - const su2double FluxCorrection_j = nodes->GetSolution(jPoint, iVar) * EdgeMassFlux; + LinSysRes.AddBlock(iPoint, nodes->GetSolution(iPoint), -EdgeMassFlux); + LinSysRes.AddBlock(jPoint, nodes->GetSolution(jPoint), EdgeMassFlux); - LinSysRes(iPoint, iVar) -= FluxCorrection_i; - LinSysRes(jPoint, iVar) += FluxCorrection_j; - } if (implicit) { Jacobian.AddVal2Diag(iPoint, -EdgeMassFlux); Jacobian.AddVal2Diag(jPoint, EdgeMassFlux); @@ -363,6 +361,67 @@ void CScalarSolver::BC_Periodic(CGeometry* geometry, CSolver** sol } } +template +void CScalarSolver::BC_Far_Field(CGeometry* geometry, CSolver** solver_container, + CNumerics* conv_numerics, CNumerics*, CConfig *config, + unsigned short val_marker) { + + const bool implicit = (config->GetKind_TimeIntScheme() == EULER_IMPLICIT); + + SU2_OMP_FOR_STAT(OMP_MIN_SIZE) + for (auto iVertex = 0u; iVertex < geometry->nVertex[val_marker]; iVertex++) { + + const auto iPoint = geometry->vertex[val_marker][iVertex]->GetNode(); + + /*--- Check if the node belongs to the domain (i.e, not a halo node) ---*/ + + if (geometry->nodes->GetDomain(iPoint)) { + + /*--- Allocate the value at the infinity ---*/ + + auto V_infty = solver_container[FLOW_SOL]->GetCharacPrimVar(val_marker, iVertex); + + /*--- Retrieve solution at the farfield boundary node ---*/ + + auto V_domain = solver_container[FLOW_SOL]->GetNodes()->GetPrimitive(iPoint); + + /*--- Grid Movement ---*/ + + if (dynamic_grid) + conv_numerics->SetGridVel(geometry->nodes->GetGridVel(iPoint), geometry->nodes->GetGridVel(iPoint)); + + conv_numerics->SetPrimitive(V_domain, V_infty); + + /*--- Set turbulent variable at the wall, and at infinity ---*/ + + conv_numerics->SetScalarVar(nodes->GetSolution(iPoint), Solution_Inf); + + /*--- Set Normal (it is necessary to change the sign) ---*/ + + su2double Normal[MAXNDIM] = {0.0}; + for (auto iDim = 0u; iDim < nDim; iDim++) + Normal[iDim] = -geometry->vertex[val_marker][iVertex]->GetNormal(iDim); + conv_numerics->SetNormal(Normal); + + if (conv_numerics->GetBoundedScalar()) { + const su2double* velocity = &V_infty[prim_idx.Velocity()]; + const su2double density = solver_container[FLOW_SOL]->GetNodes()->GetDensity(iPoint); + conv_numerics->SetMassFlux(BoundedScalarBCFlux(iPoint, implicit, density, velocity, Normal)); + } + + /*--- Compute residuals and Jacobians ---*/ + + auto residual = conv_numerics->ComputeResidual(config); + + /*--- Add residuals and Jacobians ---*/ + + LinSysRes.AddBlock(iPoint, residual); + if (implicit) Jacobian.AddBlock2Diag(iPoint, residual.jacobian_i); + } + } + END_SU2_OMP_FOR +} + template void CScalarSolver::PrepareImplicitIteration(CGeometry* geometry, CSolver** solver_container, CConfig* config) { diff --git a/SU2_CFD/include/solvers/CTransLMSolver.hpp b/SU2_CFD/include/solvers/CTransLMSolver.hpp index 36d29ee1a31..1ced793c9ac 100644 --- a/SU2_CFD/include/solvers/CTransLMSolver.hpp +++ b/SU2_CFD/include/solvers/CTransLMSolver.hpp @@ -153,23 +153,7 @@ class CTransLMSolver final : public CTurbSolver { CNumerics *conv_numerics, CNumerics *visc_numerics, CConfig *config, - unsigned short val_marker) override; - - /*! - * \brief Impose the Far Field boundary condition. - * \param[in] geometry - Geometrical definition of the problem. - * \param[in] solver_container - Container vector with all the solutions. - * \param[in] conv_numerics - Description of the numerical method. - * \param[in] visc_numerics - Description of the numerical method. - * \param[in] config - Definition of the particular problem. - * \param[in] val_marker - Surface marker where the boundary condition is applied. - */ - void BC_Far_Field(CGeometry *geometry, - CSolver **solver_container, - CNumerics *conv_numerics, - CNumerics *visc_numerics, - CConfig *config, - unsigned short val_marker) override; + unsigned short val_marker) override; /*! * \brief Impose the inlet boundary condition. diff --git a/SU2_CFD/include/solvers/CTurbSASolver.hpp b/SU2_CFD/include/solvers/CTurbSASolver.hpp index 8868f822263..8a09ad00cff 100644 --- a/SU2_CFD/include/solvers/CTurbSASolver.hpp +++ b/SU2_CFD/include/solvers/CTurbSASolver.hpp @@ -188,22 +188,6 @@ class CTurbSASolver final : public CTurbSolver { CConfig *config, unsigned short val_marker) override; - /*! - * \brief Impose the Far Field boundary condition. - * \param[in] geometry - Geometrical definition of the problem. - * \param[in] solver_container - Container vector with all the solutions. - * \param[in] conv_numerics - Description of the numerical method. - * \param[in] visc_numerics - Description of the numerical method. - * \param[in] config - Definition of the particular problem. - * \param[in] val_marker - Surface marker where the boundary condition is applied. - */ - void BC_Far_Field(CGeometry *geometry, - CSolver **solver_container, - CNumerics *conv_numerics, - CNumerics *visc_numerics, - CConfig *config, - unsigned short val_marker) override; - /*! * \brief Impose the inlet boundary condition. * \param[in] geometry - Geometrical definition of the problem. diff --git a/SU2_CFD/include/solvers/CTurbSSTSolver.hpp b/SU2_CFD/include/solvers/CTurbSSTSolver.hpp index cc881bfa6a3..c4b4625744d 100644 --- a/SU2_CFD/include/solvers/CTurbSSTSolver.hpp +++ b/SU2_CFD/include/solvers/CTurbSSTSolver.hpp @@ -169,22 +169,6 @@ class CTurbSSTSolver final : public CTurbSolver { CConfig *config, unsigned short val_marker) override; - /*! - * \brief Impose the Far Field boundary condition. - * \param[in] geometry - Geometrical definition of the problem. - * \param[in] solver_container - Container vector with all the solutions. - * \param[in] conv_numerics - Description of the numerical method. - * \param[in] visc_numerics - Description of the numerical method. - * \param[in] config - Definition of the particular problem. - * \param[in] val_marker - Surface marker where the boundary condition is applied. - */ - void BC_Far_Field(CGeometry *geometry, - CSolver **solver_container, - CNumerics *conv_numerics, - CNumerics *visc_numerics, - CConfig *config, - unsigned short val_marker) override; - /*! * \brief Impose the inlet boundary condition. * \param[in] geometry - Geometrical definition of the problem. diff --git a/SU2_CFD/src/solvers/CSpeciesSolver.cpp b/SU2_CFD/src/solvers/CSpeciesSolver.cpp index fe1cdbdc7d9..743ccb73f89 100644 --- a/SU2_CFD/src/solvers/CSpeciesSolver.cpp +++ b/SU2_CFD/src/solvers/CSpeciesSolver.cpp @@ -345,10 +345,7 @@ void CSpeciesSolver::BC_Inlet(CGeometry* geometry, CSolver** solver_container, C CNumerics* visc_numerics, CConfig* config, unsigned short val_marker) { string Marker_Tag = config->GetMarker_All_TagBound(val_marker); - /*--- Bounded scalar problem ---*/ - bool bounded_scalar = conv_numerics->GetBoundedScalar(); - - su2double EdgeMassFlux = 0.0; + const bool implicit = (config->GetKind_TimeIntScheme() == EULER_IMPLICIT); /*--- Loop over all the vertices on this boundary marker ---*/ @@ -375,8 +372,6 @@ void CSpeciesSolver::BC_Inlet(CGeometry* geometry, CSolver** solver_container, C su2double Normal[MAXNDIM] = {0.0}; for (auto iDim = 0u; iDim < nDim; iDim++) Normal[iDim] = -geometry->vertex[val_marker][iVertex]->GetNormal(iDim); - - conv_numerics->SetNormal(Normal); /*--- Allocate the value at the inlet ---*/ @@ -400,37 +395,20 @@ void CSpeciesSolver::BC_Inlet(CGeometry* geometry, CSolver** solver_container, C if (dynamic_grid) conv_numerics->SetGridVel(geometry->nodes->GetGridVel(iPoint), geometry->nodes->GetGridVel(iPoint)); - if(bounded_scalar){ - /*--- Obtain flow velocity vector at inlet boundary node ---*/ - su2double Velocity_Inlet[MAXNDIM] = {0.0}, density_inlet; - for (auto iDim = 0u; iDim < nDim; iDim++) Velocity_Inlet[iDim] = V_inlet[iDim + 1];//solver_container[FLOW_SOL]->GetNodes()->GetVelocity(iPoint, iDim); - - /*--- Obtain density at inlet boundary node ---*/ - density_inlet = solver_container[FLOW_SOL]->GetNodes()->GetDensity(iPoint); - - /*--- Compute mass flux on current node ---*/ - EdgeMassFlux = density_inlet * GeometryToolbox::DotProduct(nDim, Velocity_Inlet, Normal); - - /*--- Communicate inlet mass flux to numerics ---*/ - conv_numerics->SetMassFlux(EdgeMassFlux); + if (conv_numerics->GetBoundedScalar()) { + const su2double* velocity = &V_inlet[prim_idx.Velocity()]; + const su2double density = solver_container[FLOW_SOL]->GetNodes()->GetDensity(iPoint); + conv_numerics->SetMassFlux(BoundedScalarBCFlux(iPoint, implicit, density, velocity, Normal)); } /*--- Compute the residual using an upwind scheme ---*/ + auto residual = conv_numerics->ComputeResidual(config); LinSysRes.AddBlock(iPoint, residual); /*--- Jacobian contribution for implicit integration ---*/ - const bool implicit = (config->GetKind_TimeIntScheme() == EULER_IMPLICIT); - if (implicit) Jacobian.AddBlock2Diag(iPoint, residual.jacobian_i); - - /*--- Applying convective flux correction to negate the effects of flow divergence ---*/ - if(bounded_scalar){ - for(unsigned short iVar=0; iVarGetSolution(iPoint, iVar) * EdgeMassFlux; - LinSysRes(iPoint, iVar) -= FluxCorrection_i; - } - }if (implicit) Jacobian.AddVal2Diag(iPoint, max(0.0, EdgeMassFlux)); + if (implicit) Jacobian.AddBlock2Diag(iPoint, residual.jacobian_i); // Unfinished viscous contribution removed before right after d8a0da9a00. Further testing required. @@ -517,10 +495,8 @@ void CSpeciesSolver::SetUniformInlet(const CConfig* config, unsigned short iMark void CSpeciesSolver::BC_Outlet(CGeometry* geometry, CSolver** solver_container, CNumerics* conv_numerics, CNumerics* visc_numerics, CConfig* config, unsigned short val_marker) { - - const bool bounded_scalar = conv_numerics->GetBoundedScalar(); - su2double EdgeMassFlux = 0.0; + const bool implicit = (config->GetKind_TimeIntScheme() == EULER_IMPLICIT); /*--- Loop over all the vertices on this boundary marker ---*/ @@ -548,7 +524,6 @@ void CSpeciesSolver::BC_Outlet(CGeometry* geometry, CSolver** solver_container, } } else { // weak BC - /*--- Allocate the value at the outlet ---*/ auto V_outlet = solver_container[FLOW_SOL]->GetCharacPrimVar(val_marker, iVertex); @@ -575,18 +550,10 @@ void CSpeciesSolver::BC_Outlet(CGeometry* geometry, CSolver** solver_container, if (dynamic_grid) conv_numerics->SetGridVel(geometry->nodes->GetGridVel(iPoint), geometry->nodes->GetGridVel(iPoint)); - if(bounded_scalar){ - /*--- Obtain flow velocity vector at inlet boundary node ---*/ - su2double Velocity_Outlet[MAXNDIM] = {0.0}, density_outlet; - for (auto iDim = 0u; iDim < nDim; iDim++) Velocity_Outlet[iDim] = V_outlet[iDim + 1]; - - /*--- Obtain density at inlet boundary node ---*/ - density_outlet = solver_container[FLOW_SOL]->GetNodes()->GetDensity(iPoint); - - /*--- Compute mass flux on current node ---*/ - EdgeMassFlux = density_outlet * GeometryToolbox::DotProduct(nDim, Velocity_Outlet, Normal); - - conv_numerics->SetMassFlux(EdgeMassFlux); + if (conv_numerics->GetBoundedScalar()) { + const su2double* velocity = &V_outlet[prim_idx.Velocity()]; + const su2double density = solver_container[FLOW_SOL]->GetNodes()->GetDensity(iPoint); + conv_numerics->SetMassFlux(BoundedScalarBCFlux(iPoint, implicit, density, velocity, Normal)); } /*--- Compute the residual using an upwind scheme ---*/ @@ -594,20 +561,10 @@ void CSpeciesSolver::BC_Outlet(CGeometry* geometry, CSolver** solver_container, LinSysRes.AddBlock(iPoint, residual); /*--- Jacobian contribution for implicit integration ---*/ - const bool implicit = (config->GetKind_TimeIntScheme() == EULER_IMPLICIT); if (implicit) Jacobian.AddBlock2Diag(iPoint, residual.jacobian_i); - /*--- Applying convective flux correction to negate the effects of flow divergence ---*/ - if(bounded_scalar){ - for(unsigned short iVar=0; iVarGetSolution(iPoint, iVar) * EdgeMassFlux; - - LinSysRes(iPoint, iVar) -= FluxCorrection_i; - } - }if(implicit) Jacobian.AddVal2Diag(iPoint, max(0.0, EdgeMassFlux)); - // Unfinished viscous contribution removed before right after d8a0da9a00. Further testing required. - + } } END_SU2_OMP_FOR diff --git a/SU2_CFD/src/solvers/CTransLMSolver.cpp b/SU2_CFD/src/solvers/CTransLMSolver.cpp index 2f15bf8ba59..4aa62c917b7 100644 --- a/SU2_CFD/src/solvers/CTransLMSolver.cpp +++ b/SU2_CFD/src/solvers/CTransLMSolver.cpp @@ -203,18 +203,18 @@ void CTransLMSolver::Postprocessing(CGeometry *geometry, CSolver **solver_contai const su2double mu = flowNodes->GetLaminarViscosity(iPoint); const su2double dist = geometry->nodes->GetWall_Distance(iPoint); su2double VorticityMag = GeometryToolbox::Norm(3, flowNodes->GetVorticity(iPoint)); - su2double StrainMag =flowNodes->GetStrainMag(iPoint); + su2double StrainMag =flowNodes->GetStrainMag(iPoint); VorticityMag = max(VorticityMag, 1e-12); StrainMag = max(StrainMag, 1e-12); // safety against division by zero const su2double Intermittecy = nodes->GetSolution(iPoint,0); const su2double Re_t = nodes->GetSolution(iPoint,1); - const su2double Re_v = rho*dist*dist*StrainMag/mu; + const su2double Re_v = rho*dist*dist*StrainMag/mu; const su2double omega = solver_container[TURB_SOL]->GetNodes()->GetSolution(iPoint,1); const su2double k = solver_container[TURB_SOL]->GetNodes()->GetSolution(iPoint,0); su2double Corr_Rec = 0.0; if(Re_t <= 1870){ - Corr_Rec = Re_t - (396.035e-02 + (-120.656e-04)*Re_t + (868.230e-06)*pow(Re_t, 2.) + Corr_Rec = Re_t - (396.035e-02 + (-120.656e-04)*Re_t + (868.230e-06)*pow(Re_t, 2.) +( -696.506e-09)*pow(Re_t, 3.) + (174.105e-12)*pow(Re_t, 4.)); } else { Corr_Rec = Re_t - ( 593.11 + (Re_t - 1870.0) * 0.482); @@ -262,7 +262,7 @@ void CTransLMSolver::Viscous_Residual(unsigned long iEdge, CGeometry* geometry, void CTransLMSolver::Source_Residual(CGeometry *geometry, CSolver **solver_container, CNumerics **numerics_container, CConfig *config, unsigned short iMesh) { - + const bool implicit = (config->GetKind_TimeIntScheme() == EULER_IMPLICIT); auto* flowNodes = su2staticcast_p(solver_container[FLOW_SOL]->GetNodes()); @@ -279,7 +279,7 @@ void CTransLMSolver::Source_Residual(CGeometry *geometry, CSolver **solver_conta SU2_OMP_FOR_DYN(omp_chunk_size) for (unsigned long iPoint = 0; iPoint < nPointDomain; iPoint++) { - + /*--- Conservative variables w/o reconstruction ---*/ @@ -295,7 +295,7 @@ void CTransLMSolver::Source_Residual(CGeometry *geometry, CSolver **solver_conta numerics->SetScalarVar(turbNodes->GetSolution(iPoint), nullptr); numerics->SetScalarVarGradient(turbNodes->GetGradient(iPoint), nullptr); - /*--- Transition variables w/o reconstruction, and its gradient ---*/ + /*--- Transition variables w/o reconstruction, and its gradient ---*/ numerics->SetTransVar(nodes->GetSolution(iPoint), nullptr); numerics->SetTransVarGradient(nodes->GetGradient(iPoint), nullptr); @@ -307,7 +307,7 @@ void CTransLMSolver::Source_Residual(CGeometry *geometry, CSolver **solver_conta /*--- Set distance to the surface ---*/ numerics->SetDistance(geometry->nodes->GetWall_Distance(iPoint), 0.0); - + /*--- Set vorticity and strain rate magnitude ---*/ numerics->SetVorticity(flowNodes->GetVorticity(iPoint), nullptr); @@ -316,7 +316,7 @@ void CTransLMSolver::Source_Residual(CGeometry *geometry, CSolver **solver_conta /*--- Set coordnate (for debugging) ---*/ numerics->SetCoord(geometry->nodes->GetCoord(iPoint), nullptr); - + /*--- Compute the source term ---*/ auto residual = numerics->ComputeResidual(config); @@ -400,62 +400,6 @@ void CTransLMSolver::BC_Isothermal_Wall(CGeometry *geometry, CSolver **solver_co } - - -void CTransLMSolver::BC_Far_Field(CGeometry *geometry, CSolver **solver_container, CNumerics *conv_numerics, CNumerics *visc_numerics, CConfig *config, unsigned short val_marker) { - - const bool implicit = (config->GetKind_TimeIntScheme() == EULER_IMPLICIT); - - SU2_OMP_FOR_STAT(OMP_MIN_SIZE) - for (auto iVertex = 0u; iVertex < geometry->nVertex[val_marker]; iVertex++) { - - const auto iPoint = geometry->vertex[val_marker][iVertex]->GetNode(); - - /*--- Check if the node belongs to the domain (i.e, not a halo node) ---*/ - - if (geometry->nodes->GetDomain(iPoint)) { - - /*--- Allocate the value at the infinity ---*/ - - auto V_infty = solver_container[FLOW_SOL]->GetCharacPrimVar(val_marker, iVertex); - - /*--- Retrieve solution at the farfield boundary node ---*/ - - auto V_domain = solver_container[FLOW_SOL]->GetNodes()->GetPrimitive(iPoint); - - conv_numerics->SetPrimitive(V_domain, V_infty); - - /*--- Set turbulent variable at the wall, and at infinity ---*/ - - conv_numerics->SetScalarVar(nodes->GetSolution(iPoint), Solution_Inf); - - /*--- Set Normal (it is necessary to change the sign) ---*/ - - su2double Normal[MAXNDIM] = {0.0}; - for (auto iDim = 0u; iDim < nDim; iDim++) - Normal[iDim] = -geometry->vertex[val_marker][iVertex]->GetNormal(iDim); - conv_numerics->SetNormal(Normal); - - /*--- Grid Movement ---*/ - - if (dynamic_grid) - conv_numerics->SetGridVel(geometry->nodes->GetGridVel(iPoint), - geometry->nodes->GetGridVel(iPoint)); - - /*--- Compute residuals and Jacobians ---*/ - - auto residual = conv_numerics->ComputeResidual(config); - - /*--- Add residuals and Jacobians ---*/ - - LinSysRes.AddBlock(iPoint, residual); - if (implicit) Jacobian.AddBlock2Diag(iPoint, residual.jacobian_i); - } - } - END_SU2_OMP_FOR - -} - void CTransLMSolver::BC_Inlet(CGeometry *geometry, CSolver **solver_container, CNumerics *conv_numerics, CNumerics *visc_numerics, CConfig *config, unsigned short val_marker) { const bool implicit = (config->GetKind_TimeIntScheme() == EULER_IMPLICIT); @@ -524,15 +468,12 @@ void CTransLMSolver::BC_Inlet(CGeometry *geometry, CSolver **solver_container, C } -void CTransLMSolver::BC_Outlet(CGeometry *geometry, CSolver **solver_container, CNumerics *conv_numerics, CNumerics *visc_numerics, - CConfig *config, unsigned short val_marker) { - -BC_Far_Field(geometry, solver_container, conv_numerics, visc_numerics, config, val_marker); - +void CTransLMSolver::BC_Outlet(CGeometry *geometry, CSolver **solver_container, CNumerics *conv_numerics, + CNumerics *visc_numerics, CConfig *config, unsigned short val_marker) { + BC_Far_Field(geometry, solver_container, conv_numerics, visc_numerics, config, val_marker); } - -void CTransLMSolver::LoadRestart(CGeometry** geometry, CSolver*** solver, CConfig* config, int val_iter, +void CTransLMSolver::LoadRestart(CGeometry** geometry, CSolver*** solver, CConfig* config, int val_iter, bool val_update_geo) { const string restart_filename = config->GetFilename(config->GetSolution_FileName(), "", val_iter); @@ -561,7 +502,7 @@ void CTransLMSolver::LoadRestart(CGeometry** geometry, CSolver*** solver, CConfi const bool energy = config->GetEnergy_Equation(); const bool weakly_coupled_heat = config->GetWeakly_Coupled_Heat(); - if (incompressible && ((!energy) && (!weakly_coupled_heat))) skipVars--; + if (incompressible && ((!energy) && (!weakly_coupled_heat))) skipVars--; /*--- Load data from the restart into correct containers. ---*/ @@ -652,5 +593,5 @@ void CTransLMSolver::LoadRestart(CGeometry** geometry, CSolver*** solver, CConfi Restart_Data = nullptr; } END_SU2_OMP_SAFE_GLOBAL_ACCESS - + } \ No newline at end of file diff --git a/SU2_CFD/src/solvers/CTurbSASolver.cpp b/SU2_CFD/src/solvers/CTurbSASolver.cpp index c15fc9bae5b..2913591606a 100644 --- a/SU2_CFD/src/solvers/CTurbSASolver.cpp +++ b/SU2_CFD/src/solvers/CTurbSASolver.cpp @@ -464,71 +464,11 @@ void CTurbSASolver::BC_Isothermal_Wall(CGeometry *geometry, CSolver **solver_con } -void CTurbSASolver::BC_Far_Field(CGeometry *geometry, CSolver **solver_container, CNumerics *conv_numerics, - CNumerics *visc_numerics, CConfig *config, unsigned short val_marker) { - - const bool implicit = (config->GetKind_TimeIntScheme() == EULER_IMPLICIT); - - SU2_OMP_FOR_STAT(OMP_MIN_SIZE) - for (auto iVertex = 0u; iVertex < geometry->nVertex[val_marker]; iVertex++) { - - const auto iPoint = geometry->vertex[val_marker][iVertex]->GetNode(); - - /*--- Check if the node belongs to the domain (i.e, not a halo node) ---*/ - - if (geometry->nodes->GetDomain(iPoint)) { - - /*--- Allocate the value at the infinity ---*/ - - auto V_infty = solver_container[FLOW_SOL]->GetCharacPrimVar(val_marker, iVertex); - - /*--- Retrieve solution at the farfield boundary node ---*/ - - auto V_domain = solver_container[FLOW_SOL]->GetNodes()->GetPrimitive(iPoint); - - /*--- Grid Movement ---*/ - - if (dynamic_grid) - conv_numerics->SetGridVel(geometry->nodes->GetGridVel(iPoint), geometry->nodes->GetGridVel(iPoint)); - - conv_numerics->SetPrimitive(V_domain, V_infty); - - /*--- Set turbulent variable at the wall, and at infinity ---*/ - - conv_numerics->SetScalarVar(nodes->GetSolution(iPoint), Solution_Inf); - - /*--- Set Normal (it is necessary to change the sign) ---*/ - - su2double Normal[MAXNDIM] = {0.0}; - for (auto iDim = 0u; iDim < nDim; iDim++) - Normal[iDim] = -geometry->vertex[val_marker][iVertex]->GetNormal(iDim); - conv_numerics->SetNormal(Normal); - - /*--- Compute residuals and Jacobians ---*/ - - auto residual = conv_numerics->ComputeResidual(config); - - /*--- Add residuals and Jacobians ---*/ - - LinSysRes.AddBlock(iPoint, residual); - if (implicit) Jacobian.AddBlock2Diag(iPoint, residual.jacobian_i); - - } - } - END_SU2_OMP_FOR - -} - void CTurbSASolver::BC_Inlet(CGeometry *geometry, CSolver **solver_container, CNumerics *conv_numerics, CNumerics *visc_numerics, CConfig *config, unsigned short val_marker) { const bool implicit = (config->GetKind_TimeIntScheme() == EULER_IMPLICIT); - /*--- Bounded scalar problem ---*/ - bool bounded_scalar = conv_numerics->GetBoundedScalar(); - - su2double EdgeMassFlux = 0.0; - /*--- Loop over all the vertices on this boundary marker ---*/ SU2_OMP_FOR_STAT(OMP_MIN_SIZE) @@ -577,19 +517,10 @@ void CTurbSASolver::BC_Inlet(CGeometry *geometry, CSolver **solver_container, CN conv_numerics->SetGridVel(geometry->nodes->GetGridVel(iPoint), geometry->nodes->GetGridVel(iPoint)); - if(bounded_scalar){ - /*--- Obtain flow velocity vector at inlet boundary node ---*/ - su2double Velocity_Inlet[MAXNDIM] = {0.0}, density_inlet; - for (auto iDim = 0u; iDim < nDim; iDim++) Velocity_Inlet[iDim] = V_inlet[iDim + 1];//solver_container[FLOW_SOL]->GetNodes()->GetVelocity(iPoint, iDim); - - /*--- Obtain density at inlet boundary node ---*/ - density_inlet = solver_container[FLOW_SOL]->GetNodes()->GetDensity(iPoint); - - /*--- Compute mass flux on current node ---*/ - EdgeMassFlux = density_inlet * GeometryToolbox::DotProduct(nDim, Velocity_Inlet, Normal); - - /*--- Communicate inlet mass flux to numerics ---*/ - conv_numerics->SetMassFlux(EdgeMassFlux); + if (conv_numerics->GetBoundedScalar()) { + const su2double* velocity = &V_inlet[prim_idx.Velocity()]; + const su2double density = solver_container[FLOW_SOL]->GetNodes()->GetDensity(iPoint); + conv_numerics->SetMassFlux(BoundedScalarBCFlux(iPoint, implicit, density, velocity, Normal)); } /*--- Compute the residual using an upwind scheme ---*/ @@ -601,15 +532,6 @@ void CTurbSASolver::BC_Inlet(CGeometry *geometry, CSolver **solver_container, CN if (implicit) Jacobian.AddBlock2Diag(iPoint, residual.jacobian_i); - /*--- Applying convective flux correction to negate the effects of flow divergence ---*/ - if(bounded_scalar){ - for(unsigned short iVar=0; iVarGetSolution(iPoint, iVar) * EdgeMassFlux; - - LinSysRes(iPoint, iVar) -= FluxCorrection_i; - } - }if (implicit) Jacobian.AddVal2Diag(iPoint, max(0.0, EdgeMassFlux)); - // /*--- Viscous contribution, commented out because serious convergence problems ---*/ // // su2double Coord_Reflected[MAXNDIM]; @@ -644,10 +566,6 @@ void CTurbSASolver::BC_Inlet(CGeometry *geometry, CSolver **solver_container, CN void CTurbSASolver::BC_Outlet(CGeometry *geometry, CSolver **solver_container, CNumerics *conv_numerics, CNumerics *visc_numerics, CConfig *config, unsigned short val_marker) { - const bool bounded_scalar = conv_numerics->GetBoundedScalar(); - - su2double EdgeMassFlux = 0.0; - const bool implicit = (config->GetKind_TimeIntScheme() == EULER_IMPLICIT); /*--- Loop over all the vertices on this boundary marker ---*/ @@ -690,18 +608,10 @@ void CTurbSASolver::BC_Outlet(CGeometry *geometry, CSolver **solver_container, C conv_numerics->SetGridVel(geometry->nodes->GetGridVel(iPoint), geometry->nodes->GetGridVel(iPoint)); - if(bounded_scalar){ - /*--- Obtain flow velocity vector at inlet boundary node ---*/ - su2double Velocity_Outlet[MAXNDIM] = {0.0}, density_outlet; - for (auto iDim = 0u; iDim < nDim; iDim++) Velocity_Outlet[iDim] = V_outlet[iDim + 1]; - - /*--- Obtain density at inlet boundary node ---*/ - density_outlet = solver_container[FLOW_SOL]->GetNodes()->GetDensity(iPoint); - - /*--- Compute mass flux on current node ---*/ - EdgeMassFlux = density_outlet * GeometryToolbox::DotProduct(nDim, Velocity_Outlet, Normal); - - conv_numerics->SetMassFlux(EdgeMassFlux); + if (conv_numerics->GetBoundedScalar()) { + const su2double* velocity = &V_outlet[prim_idx.Velocity()]; + const su2double density = solver_container[FLOW_SOL]->GetNodes()->GetDensity(iPoint); + conv_numerics->SetMassFlux(BoundedScalarBCFlux(iPoint, implicit, density, velocity, Normal)); } /*--- Compute the residual using an upwind scheme ---*/ @@ -713,15 +623,6 @@ void CTurbSASolver::BC_Outlet(CGeometry *geometry, CSolver **solver_container, C if (implicit) Jacobian.AddBlock2Diag(iPoint, residual.jacobian_i); - /*--- Applying convective flux correction to negate the effects of flow divergence ---*/ - if(bounded_scalar){ - for(unsigned short iVar=0; iVarGetSolution(iPoint, iVar) * EdgeMassFlux; - - LinSysRes(iPoint, iVar) -= FluxCorrection_i; - } - }if (implicit) Jacobian.AddVal2Diag(iPoint, max(0.0, EdgeMassFlux)); - // /*--- Viscous contribution, commented out because serious convergence problems ---*/ // // su2double Coord_Reflected[MAXNDIM]; diff --git a/SU2_CFD/src/solvers/CTurbSSTSolver.cpp b/SU2_CFD/src/solvers/CTurbSSTSolver.cpp index 447e92f652b..7b20fa1f44f 100644 --- a/SU2_CFD/src/solvers/CTurbSSTSolver.cpp +++ b/SU2_CFD/src/solvers/CTurbSSTSolver.cpp @@ -28,7 +28,6 @@ #include "../../include/solvers/CTurbSSTSolver.hpp" #include "../../include/variables/CTurbSSTVariable.hpp" #include "../../include/variables/CFlowVariable.hpp" -#include "../../include/variables/CPrimitiveIndices.hpp" #include "../../../Common/include/parallelization/omp_structure.hpp" #include "../../../Common/include/toolboxes/geometry_toolbox.hpp" @@ -519,74 +518,11 @@ void CTurbSSTSolver::BC_Isothermal_Wall(CGeometry *geometry, CSolver **solver_co } -void CTurbSSTSolver::BC_Far_Field(CGeometry *geometry, CSolver **solver_container, CNumerics *conv_numerics, - CNumerics *visc_numerics, CConfig *config, unsigned short val_marker) { - - const bool implicit = (config->GetKind_TimeIntScheme() == EULER_IMPLICIT); - - SU2_OMP_FOR_STAT(OMP_MIN_SIZE) - for (auto iVertex = 0u; iVertex < geometry->nVertex[val_marker]; iVertex++) { - - const auto iPoint = geometry->vertex[val_marker][iVertex]->GetNode(); - - /*--- Check if the node belongs to the domain (i.e, not a halo node) ---*/ - - if (geometry->nodes->GetDomain(iPoint)) { - - /*--- Allocate the value at the infinity ---*/ - - auto V_infty = solver_container[FLOW_SOL]->GetCharacPrimVar(val_marker, iVertex); - - /*--- Retrieve solution at the farfield boundary node ---*/ - - auto V_domain = solver_container[FLOW_SOL]->GetNodes()->GetPrimitive(iPoint); - - conv_numerics->SetPrimitive(V_domain, V_infty); - - /*--- Set turbulent variable at the wall, and at infinity ---*/ - - conv_numerics->SetScalarVar(nodes->GetSolution(iPoint), Solution_Inf); - - /*--- Set Normal (it is necessary to change the sign) ---*/ - - su2double Normal[MAXNDIM] = {0.0}; - for (auto iDim = 0u; iDim < nDim; iDim++) - Normal[iDim] = -geometry->vertex[val_marker][iVertex]->GetNormal(iDim); - conv_numerics->SetNormal(Normal); - - /*--- Grid Movement ---*/ - - if (dynamic_grid) - conv_numerics->SetGridVel(geometry->nodes->GetGridVel(iPoint), - geometry->nodes->GetGridVel(iPoint)); - - /*--- Compute residuals and Jacobians ---*/ - - auto residual = conv_numerics->ComputeResidual(config); - - /*--- Add residuals and Jacobians ---*/ - - LinSysRes.AddBlock(iPoint, residual); - if (implicit) Jacobian.AddBlock2Diag(iPoint, residual.jacobian_i); - } - } - END_SU2_OMP_FOR - -} - void CTurbSSTSolver::BC_Inlet(CGeometry *geometry, CSolver **solver_container, CNumerics *conv_numerics, CNumerics *visc_numerics, CConfig *config, unsigned short val_marker) { const bool implicit = (config->GetKind_TimeIntScheme() == EULER_IMPLICIT); - /*--- Bounded scalar problem ---*/ - bool bounded_scalar = conv_numerics->GetBoundedScalar(); - - su2double EdgeMassFlux = 0.0; - - const CPrimitiveIndices prim_idx(config->GetKind_Regime() == ENUM_REGIME::INCOMPRESSIBLE, - config->GetNEMOProblem(), nDim, config->GetnSpecies()); - /*--- Loop over all the vertices on this boundary marker ---*/ SU2_OMP_FOR_STAT(OMP_MIN_SIZE) @@ -663,19 +599,10 @@ void CTurbSSTSolver::BC_Inlet(CGeometry *geometry, CSolver **solver_container, C conv_numerics->SetGridVel(geometry->nodes->GetGridVel(iPoint), geometry->nodes->GetGridVel(iPoint)); - if(bounded_scalar){ - /*--- Obtain flow velocity vector at inlet boundary node ---*/ - su2double Velocity_Inlet[MAXNDIM] = {0.0}, density_inlet; - for (auto iDim = 0u; iDim < nDim; iDim++) Velocity_Inlet[iDim] = V_inlet[iDim + 1];//solver_container[FLOW_SOL]->GetNodes()->GetVelocity(iPoint, iDim); - - /*--- Obtain density at inlet boundary node ---*/ - density_inlet = solver_container[FLOW_SOL]->GetNodes()->GetDensity(iPoint); - - /*--- Compute mass flux on current node ---*/ - EdgeMassFlux = density_inlet * GeometryToolbox::DotProduct(nDim, Velocity_Inlet, Normal); - - /*--- Communicate inlet mass flux to numerics ---*/ - conv_numerics->SetMassFlux(EdgeMassFlux); + if (conv_numerics->GetBoundedScalar()) { + const su2double* velocity = &V_inlet[prim_idx.Velocity()]; + const su2double density = solver_container[FLOW_SOL]->GetNodes()->GetDensity(iPoint); + conv_numerics->SetMassFlux(BoundedScalarBCFlux(iPoint, implicit, density, velocity, Normal)); } /*--- Compute the residual using an upwind scheme ---*/ @@ -687,15 +614,6 @@ void CTurbSSTSolver::BC_Inlet(CGeometry *geometry, CSolver **solver_container, C if (implicit) Jacobian.AddBlock2Diag(iPoint, residual.jacobian_i); - /*--- Applying convective flux correction to negate the effects of flow divergence ---*/ - if(bounded_scalar){ - for(unsigned short iVar=0; iVarGetSolution(iPoint, iVar) * EdgeMassFlux; - - LinSysRes(iPoint, iVar) -= FluxCorrection_i; - } - }if (implicit) Jacobian.AddVal2Diag(iPoint, max(0.0, EdgeMassFlux)); - // /*--- Viscous contribution, commented out because serious convergence problems ---*/ // // su2double Coord_Reflected[MAXNDIM]; @@ -737,10 +655,6 @@ void CTurbSSTSolver::BC_Outlet(CGeometry *geometry, CSolver **solver_container, const bool implicit = (config->GetKind_TimeIntScheme() == EULER_IMPLICIT); - const bool bounded_scalar = conv_numerics->GetBoundedScalar(); - - su2double EdgeMassFlux = 0.0; - /*--- Loop over all the vertices on this boundary marker ---*/ SU2_OMP_FOR_STAT(OMP_MIN_SIZE) @@ -782,18 +696,10 @@ void CTurbSSTSolver::BC_Outlet(CGeometry *geometry, CSolver **solver_container, conv_numerics->SetGridVel(geometry->nodes->GetGridVel(iPoint), geometry->nodes->GetGridVel(iPoint)); - if(bounded_scalar){ - /*--- Obtain flow velocity vector at inlet boundary node ---*/ - su2double Velocity_Outlet[MAXNDIM] = {0.0}, density_outlet; - for (auto iDim = 0u; iDim < nDim; iDim++) Velocity_Outlet[iDim] = V_outlet[iDim + 1]; - - /*--- Obtain density at inlet boundary node ---*/ - density_outlet = solver_container[FLOW_SOL]->GetNodes()->GetDensity(iPoint); - - /*--- Compute mass flux on current node ---*/ - EdgeMassFlux = density_outlet * GeometryToolbox::DotProduct(nDim, Velocity_Outlet, Normal); - - conv_numerics->SetMassFlux(EdgeMassFlux); + if (conv_numerics->GetBoundedScalar()) { + const su2double* velocity = &V_outlet[prim_idx.Velocity()]; + const su2double density = solver_container[FLOW_SOL]->GetNodes()->GetDensity(iPoint); + conv_numerics->SetMassFlux(BoundedScalarBCFlux(iPoint, implicit, density, velocity, Normal)); } /*--- Compute the residual using an upwind scheme ---*/ @@ -805,15 +711,6 @@ void CTurbSSTSolver::BC_Outlet(CGeometry *geometry, CSolver **solver_container, if (implicit) Jacobian.AddBlock2Diag(iPoint, residual.jacobian_i); - /*--- Applying convective flux correction to negate the effects of flow divergence ---*/ - if(bounded_scalar){ - for(unsigned short iVar=0; iVarGetSolution(iPoint, iVar) * EdgeMassFlux; - - LinSysRes(iPoint, iVar) -= FluxCorrection_i; - } - }if (implicit) Jacobian.AddVal2Diag(iPoint, max(0.0, EdgeMassFlux)); - // /*--- Viscous contribution, commented out because serious convergence problems ---*/ // // su2double Coord_Reflected[MAXNDIM]; From 5cee01acca3725e987b55d89005e4b68531c42d8 Mon Sep 17 00:00:00 2001 From: bigfooted Date: Mon, 28 Nov 2022 09:46:21 +0100 Subject: [PATCH 47/48] add additional comments, update target mass flow rate output message --- SU2_CFD/include/solvers/CScalarSolver.hpp | 2 +- SU2_CFD/include/solvers/CScalarSolver.inl | 3 ++- SU2_CFD/src/numerics/species/species_sources.cpp | 3 ++- SU2_CFD/src/solvers/CIncEulerSolver.cpp | 9 ++++++--- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/SU2_CFD/include/solvers/CScalarSolver.hpp b/SU2_CFD/include/solvers/CScalarSolver.hpp index 542a18315bf..5301fef5ad3 100644 --- a/SU2_CFD/include/solvers/CScalarSolver.hpp +++ b/SU2_CFD/include/solvers/CScalarSolver.hpp @@ -267,7 +267,7 @@ class CScalarSolver : public CSolver { /*! * \brief Applies a convective flux correction to negate the effects of flow divergence at a BC node. * \note This function should be used for nodes that are part of a boundary marker, it computes a mass flux - * from density and velocity at the node, and the outward-poiting normal (-1 * normal of vertex). + * from density and velocity at the node, and the outward-pointing normal (-1 * normal of vertex). * \return The mass flux. */ inline su2double BoundedScalarBCFlux(unsigned long iPoint, bool implicit, const su2double& density, diff --git a/SU2_CFD/include/solvers/CScalarSolver.inl b/SU2_CFD/include/solvers/CScalarSolver.inl index 06cc3acad67..099e2268069 100644 --- a/SU2_CFD/include/solvers/CScalarSolver.inl +++ b/SU2_CFD/include/solvers/CScalarSolver.inl @@ -278,7 +278,8 @@ void CScalarSolver::Upwind_Residual(CGeometry* geometry, CSolver** if (implicit) Jacobian.UpdateBlocks(iEdge, iPoint, jPoint, residual.jacobian_i, residual.jacobian_j); } - /*--- Apply convective flux correction to negate the effects of flow divergence. + /*--- Apply convective flux correction to negate the effects of flow divergence in case of incompressible flow. + * Note that for the bounded scalar model, we explicitly put div(v)=0. * If the ReducerStrategy is used, the corrections need to be applied in a loop over nodes * to avoid race conditions in accessing nodes shared by edges handled by different threads. ---*/ diff --git a/SU2_CFD/src/numerics/species/species_sources.cpp b/SU2_CFD/src/numerics/species/species_sources.cpp index 8df8cafb4f0..50183ac85ea 100644 --- a/SU2_CFD/src/numerics/species/species_sources.cpp +++ b/SU2_CFD/src/numerics/species/species_sources.cpp @@ -103,7 +103,8 @@ CNumerics::ResidualType<> CSourceAxisymmetric_Species::ComputeResidual(const for (auto iDim = 0u; iDim < nDim; iDim++) Velocity_i[iDim] = V_i[idx.Velocity() + iDim]; - /*--- Inviscid component of the source term. ---*/ + /*--- Inviscid component of the source term. When div(v)=0, this term does not occur ---*/ + if (!bounded_scalar) { for (auto iVar = 0u; iVar < nVar; iVar++) residual[iVar] -= yinv * Volume * Density_i * ScalarVar_i[iVar] * Velocity_i[1]; diff --git a/SU2_CFD/src/solvers/CIncEulerSolver.cpp b/SU2_CFD/src/solvers/CIncEulerSolver.cpp index 07f2ea97b87..41586b2e086 100644 --- a/SU2_CFD/src/solvers/CIncEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CIncEulerSolver.cpp @@ -3013,10 +3013,13 @@ void CIncEulerSolver::GetOutlet_Properties(CGeometry *geometry, CConfig *config, cout <<"Length (m): " << config->GetOutlet_Area(Outlet_TagBound) << "." << endl; } - cout << setprecision(5) << "Outlet Avg. Density (kg/m^3): " << config->GetOutlet_Density(Outlet_TagBound) * config->GetDensity_Ref() << endl; + cout << setprecision(5) << "Outlet Avg. Density (kg/m^3): " << config->GetOutlet_Density(Outlet_TagBound) * config->GetDensity_Ref() << endl; su2double Outlet_mDot = fabs(config->GetOutlet_MassFlow(Outlet_TagBound)) * config->GetDensity_Ref() * config->GetVelocity_Ref(); - cout << "Outlet mass flow (kg/s): "; cout << setprecision(5) << Outlet_mDot; - + su2double Outlet_mDot_Target = fabs(config->GetOutlet_Pressure(Outlet_TagBound)) / (config->GetDensity_Ref() * config->GetVelocity_Ref()); + cout << "Outlet mass flow (kg/s): " << setprecision(5) << Outlet_mDot << endl; + cout << "target mass flow (kg/s): " << setprecision(5) << Outlet_mDot_Target << endl; + su2double goal = 100.0*Outlet_mDot/Outlet_mDot_Target; + cout << "Target achieved:" << setprecision(5) << goal << " % "<< endl; } } From 32da59e2c1d4659675e6acdf94980af593284fff Mon Sep 17 00:00:00 2001 From: bigfooted Date: Mon, 28 Nov 2022 11:01:38 +0100 Subject: [PATCH 48/48] changed regression test results --- TestCases/parallel_regression.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/TestCases/parallel_regression.py b/TestCases/parallel_regression.py index a88117e7161..98252028972 100644 --- a/TestCases/parallel_regression.py +++ b/TestCases/parallel_regression.py @@ -1339,7 +1339,7 @@ def main(): species2_primitiveVenturi_mixingmodel_boundedscalar.cfg_dir = "species_transport/venturi_primitive_3species" species2_primitiveVenturi_mixingmodel_boundedscalar.cfg_file = "species2_primitiveVenturi_mixingmodel_boundedscalar.cfg" species2_primitiveVenturi_mixingmodel_boundedscalar.test_iter = 50 - species2_primitiveVenturi_mixingmodel_boundedscalar.test_vals = [-5.415205, -4.481321, -4.488545, -5.717240, -0.115974, -5.604208, 5.000000, -1.793666, 5.000000, -4.746865, 5.000000, -2.251480, 0.000276, 0.000276, 0.000000, 0.000000] + species2_primitiveVenturi_mixingmodel_boundedscalar.test_vals = [-5.419758, -4.490843, -4.496264, -5.724852, -0.120393, -5.693152, 5.000000, -1.766881, 5.000000, -4.958352, 5.000000, -2.150266, 0.000300, 0.000300, 0.000000, 0.000000] species2_primitiveVenturi_mixingmodel_boundedscalar.new_output = True test_list.append(species2_primitiveVenturi_mixingmodel_boundedscalar) @@ -1390,7 +1390,7 @@ def main(): species_primitiveVenturi_boundedscalar.cfg_dir = "species_transport/venturi_primitive_3species" species_primitiveVenturi_boundedscalar.cfg_file = "species2_primitiveVenturi_boundedscalar.cfg" species_primitiveVenturi_boundedscalar.test_iter = 50 - species_primitiveVenturi_boundedscalar.test_vals = [-5.281748, -4.335720, -4.330212, -5.877476, -0.944352, -5.476891, 5.000000, -1.790723, 5.000000, -4.055926, 5.000000, -2.225729, 0.000435, 0.000435, 0.000000, 0.000000] + species_primitiveVenturi_boundedscalar.test_vals = [-5.297585, -4.397797, -4.377086, -5.593131, -1.011782, -5.623540, 5.000000, -1.775123, 5.000000, -4.086339, 5.000000, -2.080187, 0.000424, 0.000424, 0.000000, 0.000000] species_primitiveVenturi_boundedscalar.new_output = True test_list.append(species_primitiveVenturi_boundedscalar)