From 514fd95bdff231a6758f43151006b3d2862ac988 Mon Sep 17 00:00:00 2001 From: Nitish Anand Date: Wed, 6 Jul 2022 17:38:20 +0200 Subject: [PATCH 01/36] NS iso thermal implementation working --- Common/include/option_structure.hpp | 1 + Common/src/CConfig.cpp | 2 +- .../include/numerics/flow/flow_sources.hpp | 1 + SU2_CFD/src/numerics/flow/flow_sources.cpp | 20 ++++- SU2_CFD/src/solvers/CIncEulerSolver.cpp | 1 + SU2_CFD/src/solvers/CIncNSSolver.cpp | 89 +++++++++++++++++++ 6 files changed, 109 insertions(+), 5 deletions(-) diff --git a/Common/include/option_structure.hpp b/Common/include/option_structure.hpp index 296dc05a594..0b6607d9926 100644 --- a/Common/include/option_structure.hpp +++ b/Common/include/option_structure.hpp @@ -2256,6 +2256,7 @@ struct StreamwisePeriodicValues { su2double Streamwise_Periodic_InletTemperature; /*!< \brief Area avg static Temp [K] at the periodic inlet. Used for adaptive outlet heatsink. */ su2double Streamwise_Periodic_BoundaryArea; /*!< \brief Global Surface area of the streamwise periodic interface. */ su2double Streamwise_Periodic_AvgDensity; /*!< \brief Area avg density on the periodic interface. */ + su2double Streamwise_Periodic_LambdaL; /*!< \brief Temperature Gradient in iso-thermal BCs. */ }; /*! diff --git a/Common/src/CConfig.cpp b/Common/src/CConfig.cpp index 180c2df7715..e7dfc6f74eb 100644 --- a/Common/src/CConfig.cpp +++ b/Common/src/CConfig.cpp @@ -4821,7 +4821,7 @@ void CConfig::SetPostprocessing(SU2_COMPONENT val_software, unsigned short val_i SU2_MPI::Error("Streamwise Periodic Flow + Incompressible Euler: Not tested yet.", CURRENT_FUNCTION); if (nMarker_PerBound == 0) SU2_MPI::Error("A MARKER_PERIODIC pair has to be set with KIND_STREAMWISE_PERIODIC != NONE.", CURRENT_FUNCTION); - if (Energy_Equation && Streamwise_Periodic_Temperature && nMarker_Isothermal != 0) + if (Energy_Equation && Streamwise_Periodic_Temperature && nMarker_Isothermal != 1) SU2_MPI::Error("No MARKER_ISOTHERMAL marker allowed with STREAMWISE_PERIODIC_TEMPERATURE= YES, only MARKER_HEATFLUX & MARKER_SYM.", CURRENT_FUNCTION); if (Ref_Inc_NonDim != DIMENSIONAL) SU2_MPI::Error("Streamwise Periodicity only works with \"INC_NONDIM= DIMENSIONAL\", the nondimensionalization with source terms doesn;t work in general.", CURRENT_FUNCTION); diff --git a/SU2_CFD/include/numerics/flow/flow_sources.hpp b/SU2_CFD/include/numerics/flow/flow_sources.hpp index 7bdfbde7a73..cc50cae66eb 100644 --- a/SU2_CFD/include/numerics/flow/flow_sources.hpp +++ b/SU2_CFD/include/numerics/flow/flow_sources.hpp @@ -343,6 +343,7 @@ class CSourceIncStreamwise_Periodic final : public CSourceBase_Flow { bool turbulent; /*!< \brief Turbulence model used. */ bool energy; /*!< \brief Energy equation on. */ bool streamwisePeriodic_temperature; /*!< \brief Periodicity in energy equation */ + bool heat_flux_bc; /*!< \brief HEAT Flux BC is active. */ su2double Streamwise_Coord_Vector[MAXNDIM] = {0.0}; /*!< \brief Translation vector between streamwise periodic surfaces. */ su2double norm2_translation, /*!< \brief Square of distance between the 2 periodic surfaces. */ diff --git a/SU2_CFD/src/numerics/flow/flow_sources.cpp b/SU2_CFD/src/numerics/flow/flow_sources.cpp index 97a7b61701f..bfafdcaa413 100644 --- a/SU2_CFD/src/numerics/flow/flow_sources.cpp +++ b/SU2_CFD/src/numerics/flow/flow_sources.cpp @@ -703,6 +703,8 @@ CSourceIncStreamwise_Periodic::CSourceIncStreamwise_Periodic(unsigned short val_ turbulent = (config->GetKind_Turb_Model() != TURB_MODEL::NONE); energy = config->GetEnergy_Equation(); streamwisePeriodic_temperature = config->GetStreamwise_Periodic_Temperature(); + // nMarker = config->GetnMarker_HeatFlux + heat_flux_bc = (config->GetnMarker_HeatFlux() > 0); for (unsigned short iDim = 0; iDim < nDim; iDim++) Streamwise_Coord_Vector[iDim] = config->GetPeriodic_Translation(0)[iDim]; @@ -729,12 +731,22 @@ CNumerics::ResidualType<> CSourceIncStreamwise_Periodic::ComputeResidual(const C /*--- Compute the periodic temperature contribution to the energy equation, if energy equation is considered ---*/ if (energy && streamwisePeriodic_temperature) { - scalar_factor = SPvals.Streamwise_Periodic_IntegratedHeatFlow * DensityInc_i / (SPvals.Streamwise_Periodic_MassFlow * norm2_translation); - + if (heat_flux_bc) + scalar_factor = SPvals.Streamwise_Periodic_IntegratedHeatFlow * DensityInc_i / (SPvals.Streamwise_Periodic_MassFlow * norm2_translation); + else { + su2double temp_grad = 0.0; + dot_product = GeometryToolbox::DotProduct(nDim, Streamwise_Coord_Vector, PrimVar_Grad_i[3]); + su2double term1 = 2 * Thermal_Conductivity_i * dot_product; + su2double term2 = - SPvals.Streamwise_Periodic_LambdaL * Thermal_Conductivity_i * V_i[3]; + dot_product = GeometryToolbox::DotProduct(nDim, Streamwise_Coord_Vector, &V_i[1]); + su2double term3 = - V_i[3] * V_i[1] * DensityInc_i * config->GetSpecific_Heat_Cp(); + + scalar_factor = SPvals.Streamwise_Periodic_LambdaL * (term1 + term2 + term3); + } /*--- Compute scalar-product dot_prod(v*t) ---*/ - dot_product = GeometryToolbox::DotProduct(nDim, Streamwise_Coord_Vector, &V_i[1]); + // dot_product = GeometryToolbox::DotProduct(nDim, Streamwise_Coord_Vector, &V_i[1]); - residual[nDim+1] = Volume * scalar_factor * dot_product; + residual[nDim+1] = Volume * scalar_factor;// * dot_product; /*--- If a RANS turbulence model is used, an additional source term, based on the eddy viscosity gradient is added. ---*/ if(turbulent) { diff --git a/SU2_CFD/src/solvers/CIncEulerSolver.cpp b/SU2_CFD/src/solvers/CIncEulerSolver.cpp index b288df95ef8..1a4e8619712 100644 --- a/SU2_CFD/src/solvers/CIncEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CIncEulerSolver.cpp @@ -1660,6 +1660,7 @@ void CIncEulerSolver::Source_Residual(CGeometry *geometry, CSolver **solver_cont /*--- Load the aux variable gradient that we already computed. ---*/ if(streamwise_periodic_temperature && turbulent) numerics->SetAuxVarGrad(nodes->GetAuxVarGradient(iPoint), nullptr); + numerics->SetPrimVarGradient(nodes->GetGradient_Primitive(iPoint), nullptr); /*--- Compute the streamwise periodic source residual and add to the total ---*/ auto residual = numerics->ComputeResidual(config); diff --git a/SU2_CFD/src/solvers/CIncNSSolver.cpp b/SU2_CFD/src/solvers/CIncNSSolver.cpp index 7f444e46276..552227f0543 100644 --- a/SU2_CFD/src/solvers/CIncNSSolver.cpp +++ b/SU2_CFD/src/solvers/CIncNSSolver.cpp @@ -202,6 +202,33 @@ void CIncNSSolver::GetStreamwise_Periodic_Properties(const CGeometry *geometry, /*---------------------------------------------------------------------------------------------*/ su2double HeatFlow_Local = 0.0, HeatFlow_Global = 0.0; + su2double dTdn_Local = 0.0, dTdn_Global = 0.0; + su2double Volume_Temp_Local = 0.0, Volume_Temp_Global = 0.0; + su2double Volume_TempS_Local = 0.0, Volume_TempS_Global = 0.0; + su2double Volume_Local = 0.0, Volume_Global = 0.0; + su2double Volume_VTemp_Local = 0.0, Volume_VTemp_Global = 0.0; + + for (unsigned long iPoint = 0; iPoint < geometry->GetnPoint(); iPoint++) { + + // if (!geometry->nodes->GetDomain(iPoint)) continue; + + su2double volume = geometry->nodes->GetVolume(iPoint); + + su2double Temp = nodes->GetTemperature(iPoint); + + Volume_Local += volume; + + Volume_TempS_Local += Temp * volume; + } + + SU2_MPI::Allreduce(&Volume_Local, &Volume_Global, 1, MPI_DOUBLE, MPI_SUM, SU2_MPI::GetComm()); + SU2_MPI::Allreduce(&Volume_TempS_Local, &Volume_TempS_Global, 1, MPI_DOUBLE, MPI_SUM, SU2_MPI::GetComm()); + + auto theta_scaling = Volume_TempS_Global/Volume_Global; + cout<<"======== Theta_scaling :: "<GetnPoint(); iPoint++) { + nodes->SetStreamwise_Periodic_RecoveredTemperature(iPoint, nodes->GetTemperature(iPoint)/theta_scaling); + } /*--- Loop over all heatflux Markers ---*/ for (auto iMarker = 0; iMarker < config->GetnMarker_All(); iMarker++) { @@ -225,13 +252,75 @@ void CIncNSSolver::GetStreamwise_Periodic_Properties(const CGeometry *geometry, HeatFlow_Local += FaceArea * (-1.0) * Wall_HeatFlux/config->GetHeat_Flux_Ref();; } // loop Vertices } // loop Heatflux marker + + if (config->GetMarker_All_KindBC(iMarker) == ISOTHERMAL) { + /*--- Identify the boundary by string name and retrive heatflux from config ---*/ + su2double *Normal, GradT[3] = {0.0,0.0,0.0}, UnitNormal[3] = {0.0,0.0,0.0}; + + for (auto iVertex = 0ul; iVertex < geometry->nVertex[iMarker]; iVertex++) { + + auto iPoint = geometry->vertex[iMarker][iVertex]->GetNode(); + + if (!geometry->nodes->GetDomain(iPoint)) continue; + + const auto AreaNormal = geometry->vertex[iMarker][iVertex]->GetNormal(); + + const su2double FaceArea = GeometryToolbox::Norm(nDim, AreaNormal); + + /*Compute wall heat flux (normal to the wall) based on computed temperature gradient*/ + for(auto iDim=0; iDim < nDim; iDim++) { + GradT[iDim] = nodes->GetGradient_Primitive(iPoint, 3, iDim); + dTdn_Local += GradT[iDim]*AreaNormal[iDim]*nodes->GetThermalConductivity(iPoint); + } + } + } } // loop AllMarker + + for (unsigned long iPoint = 0; iPoint < geometry->GetnPoint(); iPoint++) { + + if (!geometry->nodes->GetDomain(iPoint)) continue; + + su2double volume = geometry->nodes->GetVolume(iPoint); + + su2double Temp = nodes->GetTemperature(iPoint); + + Volume_Local += volume; + + Volume_TempS_Local += volume * Temp; + + Volume_Temp_Local += volume * Temp * nodes->GetThermalConductivity(iPoint); + + Volume_VTemp_Local += volume * Temp * nodes->GetVelocity(iPoint, 0) * nodes->GetDensity(iPoint); + + }// points + /*--- MPI Communication sum up integrated Heatflux from all processes ---*/ SU2_MPI::Allreduce(&HeatFlow_Local, &HeatFlow_Global, 1, MPI_DOUBLE, MPI_SUM, SU2_MPI::GetComm()); + SU2_MPI::Allreduce(&dTdn_Local, &dTdn_Global, 1, MPI_DOUBLE, MPI_SUM, SU2_MPI::GetComm()); + SU2_MPI::Allreduce(&Volume_Temp_Local, &Volume_Temp_Global, 1, MPI_DOUBLE, MPI_SUM, SU2_MPI::GetComm()); + SU2_MPI::Allreduce(&Volume_VTemp_Local, &Volume_VTemp_Global, 1, MPI_DOUBLE, MPI_SUM, SU2_MPI::GetComm()); + // SU2_MPI::Allreduce(&Volume_Local, &Volume_Global, 1, MPI_DOUBLE, MPI_SUM, SU2_MPI::GetComm()); + // SU2_MPI::Allreduce(&Volume_TempS_Local, &Volume_TempS_Global, 1, MPI_DOUBLE, MPI_SUM, SU2_MPI::GetComm()); + + /*--- Set the solver variable Integrated Heatflux ---*/ SPvals.Streamwise_Periodic_IntegratedHeatFlow = HeatFlow_Global; + /*--- Set the solver variable Lambda_L for iso-thermal BCs ---*/ + auto b0_coeff = Volume_Temp_Global; + auto b1_coeff = Volume_VTemp_Global * config->GetSpecific_Heat_Cp(); + auto b2_coeff = -dTdn_Global; + auto pred_lambda_1 = (- b1_coeff - sqrt(b1_coeff * b1_coeff - 4 * b0_coeff * b2_coeff))/(2 * b0_coeff); + auto pred_lambda_2 = (- b1_coeff + sqrt(b1_coeff * b1_coeff - 4 * b0_coeff * b2_coeff))/(2 * b0_coeff); + auto pred_lambda = pred_lambda_2; + if (!isnan(pred_lambda)) { + SPvals.Streamwise_Periodic_LambdaL = SPvals.Streamwise_Periodic_LambdaL - 0.1 * (SPvals.Streamwise_Periodic_LambdaL - pred_lambda); + cout<<"b0_coeff :: "< Date: Wed, 6 Jul 2022 21:01:26 +0200 Subject: [PATCH 02/36] Volume averaged temperature computation shifted --- SU2_CFD/src/solvers/CIncNSSolver.cpp | 32 ++++++---------------------- 1 file changed, 7 insertions(+), 25 deletions(-) diff --git a/SU2_CFD/src/solvers/CIncNSSolver.cpp b/SU2_CFD/src/solvers/CIncNSSolver.cpp index be66181a856..0b7f9e8af79 100644 --- a/SU2_CFD/src/solvers/CIncNSSolver.cpp +++ b/SU2_CFD/src/solvers/CIncNSSolver.cpp @@ -208,28 +208,6 @@ void CIncNSSolver::GetStreamwise_Periodic_Properties(const CGeometry *geometry, su2double Volume_Local = 0.0, Volume_Global = 0.0; su2double Volume_VTemp_Local = 0.0, Volume_VTemp_Global = 0.0; - for (unsigned long iPoint = 0; iPoint < geometry->GetnPoint(); iPoint++) { - - // if (!geometry->nodes->GetDomain(iPoint)) continue; - - su2double volume = geometry->nodes->GetVolume(iPoint); - - su2double Temp = nodes->GetTemperature(iPoint); - - Volume_Local += volume; - - Volume_TempS_Local += Temp * volume; - } - - SU2_MPI::Allreduce(&Volume_Local, &Volume_Global, 1, MPI_DOUBLE, MPI_SUM, SU2_MPI::GetComm()); - SU2_MPI::Allreduce(&Volume_TempS_Local, &Volume_TempS_Global, 1, MPI_DOUBLE, MPI_SUM, SU2_MPI::GetComm()); - - auto theta_scaling = Volume_TempS_Global/Volume_Global; - cout<<"======== Theta_scaling :: "<GetnPoint(); iPoint++) { - nodes->SetStreamwise_Periodic_RecoveredTemperature(iPoint, nodes->GetTemperature(iPoint)/theta_scaling); - } - /*--- Loop over all heatflux Markers ---*/ for (auto iMarker = 0; iMarker < config->GetnMarker_All(); iMarker++) { @@ -300,10 +278,14 @@ void CIncNSSolver::GetStreamwise_Periodic_Properties(const CGeometry *geometry, SU2_MPI::Allreduce(&dTdn_Local, &dTdn_Global, 1, MPI_DOUBLE, MPI_SUM, SU2_MPI::GetComm()); SU2_MPI::Allreduce(&Volume_Temp_Local, &Volume_Temp_Global, 1, MPI_DOUBLE, MPI_SUM, SU2_MPI::GetComm()); SU2_MPI::Allreduce(&Volume_VTemp_Local, &Volume_VTemp_Global, 1, MPI_DOUBLE, MPI_SUM, SU2_MPI::GetComm()); - // SU2_MPI::Allreduce(&Volume_Local, &Volume_Global, 1, MPI_DOUBLE, MPI_SUM, SU2_MPI::GetComm()); - // SU2_MPI::Allreduce(&Volume_TempS_Local, &Volume_TempS_Global, 1, MPI_DOUBLE, MPI_SUM, SU2_MPI::GetComm()); - + SU2_MPI::Allreduce(&Volume_Local, &Volume_Global, 1, MPI_DOUBLE, MPI_SUM, SU2_MPI::GetComm()); + SU2_MPI::Allreduce(&Volume_TempS_Local, &Volume_TempS_Global, 1, MPI_DOUBLE, MPI_SUM, SU2_MPI::GetComm()); + auto theta_scaling = Volume_TempS_Global/Volume_Global; + cout<<"======== Theta_scaling :: "<GetnPoint(); iPoint++) { + nodes->SetStreamwise_Periodic_RecoveredTemperature(iPoint, nodes->GetTemperature(iPoint)/theta_scaling); + } /*--- Set the solver variable Integrated Heatflux ---*/ SPvals.Streamwise_Periodic_IntegratedHeatFlow = HeatFlow_Global; From fa1f38a2704c109f7e18c1c35861ff29b085f215 Mon Sep 17 00:00:00 2001 From: Nitish Annad Date: Thu, 7 Jul 2022 14:08:10 +0200 Subject: [PATCH 03/36] clean-up and seperation of iso-thermal and heat flux SWP sources, both BCs are working, verification study to follow --- Common/include/CConfig.hpp | 6 ++ Common/src/CConfig.cpp | 4 +- .../include/numerics/flow/flow_sources.hpp | 3 +- SU2_CFD/src/numerics/flow/flow_sources.cpp | 27 ++++--- SU2_CFD/src/solvers/CIncEulerSolver.cpp | 4 +- SU2_CFD/src/solvers/CIncNSSolver.cpp | 80 ++++++++++--------- 6 files changed, 73 insertions(+), 51 deletions(-) diff --git a/Common/include/CConfig.hpp b/Common/include/CConfig.hpp index 05a1a74d270..c46c589965e 100644 --- a/Common/include/CConfig.hpp +++ b/Common/include/CConfig.hpp @@ -3029,6 +3029,12 @@ class CConfig { */ unsigned short GetnMarker_HeatFlux(void) const { return nMarker_HeatFlux; } + /*! + * \brief Get the total (local) number of isothermal markers. + * \return Total number of isothermal markers. + */ + unsigned short GetnMarker_Isothermal(void) const { return nMarker_Isothermal; } + /*! * \brief Get the total number of rough markers. * \return Total number of heat flux markers. diff --git a/Common/src/CConfig.cpp b/Common/src/CConfig.cpp index 2b2fbe80651..0171db1de53 100644 --- a/Common/src/CConfig.cpp +++ b/Common/src/CConfig.cpp @@ -4865,8 +4865,8 @@ void CConfig::SetPostprocessing(SU2_COMPONENT val_software, unsigned short val_i SU2_MPI::Error("Streamwise Periodic Flow + Incompressible Euler: Not tested yet.", CURRENT_FUNCTION); if (nMarker_PerBound == 0) SU2_MPI::Error("A MARKER_PERIODIC pair has to be set with KIND_STREAMWISE_PERIODIC != NONE.", CURRENT_FUNCTION); - if (Energy_Equation && Streamwise_Periodic_Temperature && nMarker_Isothermal != 1) - SU2_MPI::Error("No MARKER_ISOTHERMAL marker allowed with STREAMWISE_PERIODIC_TEMPERATURE= YES, only MARKER_HEATFLUX & MARKER_SYM.", CURRENT_FUNCTION); + // if (Energy_Equation && Streamwise_Periodic_Temperature && nMarker_Isothermal != 1) + // SU2_MPI::Error("No MARKER_ISOTHERMAL marker allowed with STREAMWISE_PERIODIC_TEMPERATURE= YES, only MARKER_HEATFLUX & MARKER_SYM.", CURRENT_FUNCTION); if (Ref_Inc_NonDim != DIMENSIONAL) SU2_MPI::Error("Streamwise Periodicity only works with \"INC_NONDIM= DIMENSIONAL\", the nondimensionalization with source terms doesn;t work in general.", CURRENT_FUNCTION); if (Axisymmetric) diff --git a/SU2_CFD/include/numerics/flow/flow_sources.hpp b/SU2_CFD/include/numerics/flow/flow_sources.hpp index 7dffab2b1bd..cd56f8c7701 100644 --- a/SU2_CFD/include/numerics/flow/flow_sources.hpp +++ b/SU2_CFD/include/numerics/flow/flow_sources.hpp @@ -343,7 +343,8 @@ class CSourceIncStreamwise_Periodic final : public CSourceBase_Flow { bool turbulent; /*!< \brief Turbulence model used. */ bool energy; /*!< \brief Energy equation on. */ bool streamwisePeriodic_temperature; /*!< \brief Periodicity in energy equation */ - bool heat_flux_bc; /*!< \brief HEAT Flux BC is active. */ + bool bool_heat_flux_bc; /*!< \brief HEAT Flux BC boolean. */ + bool bool_isotherml_bc; /*!< \brief ISO THERMAL BC boolean. */ su2double Streamwise_Coord_Vector[MAXNDIM] = {0.0}; /*!< \brief Translation vector between streamwise periodic surfaces. */ su2double norm2_translation, /*!< \brief Square of distance between the 2 periodic surfaces. */ diff --git a/SU2_CFD/src/numerics/flow/flow_sources.cpp b/SU2_CFD/src/numerics/flow/flow_sources.cpp index bfafdcaa413..c029bdb65e8 100644 --- a/SU2_CFD/src/numerics/flow/flow_sources.cpp +++ b/SU2_CFD/src/numerics/flow/flow_sources.cpp @@ -703,8 +703,8 @@ CSourceIncStreamwise_Periodic::CSourceIncStreamwise_Periodic(unsigned short val_ turbulent = (config->GetKind_Turb_Model() != TURB_MODEL::NONE); energy = config->GetEnergy_Equation(); streamwisePeriodic_temperature = config->GetStreamwise_Periodic_Temperature(); - // nMarker = config->GetnMarker_HeatFlux - heat_flux_bc = (config->GetnMarker_HeatFlux() > 0); + bool_heat_flux_bc = (config->GetnMarker_HeatFlux() > 0); + bool_isotherml_bc = (config->GetnMarker_Isothermal() > 0); for (unsigned short iDim = 0; iDim < nDim; iDim++) Streamwise_Coord_Vector[iDim] = config->GetPeriodic_Translation(0)[iDim]; @@ -731,22 +731,29 @@ CNumerics::ResidualType<> CSourceIncStreamwise_Periodic::ComputeResidual(const C /*--- Compute the periodic temperature contribution to the energy equation, if energy equation is considered ---*/ if (energy && streamwisePeriodic_temperature) { - if (heat_flux_bc) + /*--- Compute scalar factors, if there is a HEAT FLUX BC ---*/ + if (bool_heat_flux_bc) { scalar_factor = SPvals.Streamwise_Periodic_IntegratedHeatFlow * DensityInc_i / (SPvals.Streamwise_Periodic_MassFlow * norm2_translation); - else { - su2double temp_grad = 0.0; + + /*--- Compute scalar-product dot_prod(v*t) ---*/ + dot_product = GeometryToolbox::DotProduct(nDim, Streamwise_Coord_Vector, &V_i[1]); + } + + /*--- Compute scalar factors, if there is an ISOTHERMAL BC ---*/ + if (bool_isotherml_bc) { + + /*--- Compute three terms associated with the source terms for iso-thermal BCs ---*/ + // Reference Eq(20) Stalio et. al, doi:10.1115/1.2717235 + dot_product = GeometryToolbox::DotProduct(nDim, Streamwise_Coord_Vector, PrimVar_Grad_i[3]); su2double term1 = 2 * Thermal_Conductivity_i * dot_product; su2double term2 = - SPvals.Streamwise_Periodic_LambdaL * Thermal_Conductivity_i * V_i[3]; - dot_product = GeometryToolbox::DotProduct(nDim, Streamwise_Coord_Vector, &V_i[1]); su2double term3 = - V_i[3] * V_i[1] * DensityInc_i * config->GetSpecific_Heat_Cp(); - scalar_factor = SPvals.Streamwise_Periodic_LambdaL * (term1 + term2 + term3); + dot_product = 1.0; } - /*--- Compute scalar-product dot_prod(v*t) ---*/ - // dot_product = GeometryToolbox::DotProduct(nDim, Streamwise_Coord_Vector, &V_i[1]); - residual[nDim+1] = Volume * scalar_factor;// * dot_product; + residual[nDim+1] = Volume * scalar_factor * dot_product; /*--- If a RANS turbulence model is used, an additional source term, based on the eddy viscosity gradient is added. ---*/ if(turbulent) { diff --git a/SU2_CFD/src/solvers/CIncEulerSolver.cpp b/SU2_CFD/src/solvers/CIncEulerSolver.cpp index 06b7541fb5e..85e71a41d47 100644 --- a/SU2_CFD/src/solvers/CIncEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CIncEulerSolver.cpp @@ -1692,7 +1692,9 @@ void CIncEulerSolver::Source_Residual(CGeometry *geometry, CSolver **solver_cont /*--- Load the aux variable gradient that we already computed. ---*/ if(streamwise_periodic_temperature && turbulent) numerics->SetAuxVarGrad(nodes->GetAuxVarGradient(iPoint), nullptr); - numerics->SetPrimVarGradient(nodes->GetGradient_Primitive(iPoint), nullptr); + + /*--- Load the Prim variable gradient that we already computed. ---*/ + numerics->SetPrimVarGradient(nodes->GetGradient_Primitive(iPoint), nullptr); /*--- Compute the streamwise periodic source residual and add to the total ---*/ auto residual = numerics->ComputeResidual(config); diff --git a/SU2_CFD/src/solvers/CIncNSSolver.cpp b/SU2_CFD/src/solvers/CIncNSSolver.cpp index 0b7f9e8af79..f668558986d 100644 --- a/SU2_CFD/src/solvers/CIncNSSolver.cpp +++ b/SU2_CFD/src/solvers/CIncNSSolver.cpp @@ -232,8 +232,8 @@ void CIncNSSolver::GetStreamwise_Periodic_Properties(const CGeometry *geometry, } // loop Heatflux marker if (config->GetMarker_All_KindBC(iMarker) == ISOTHERMAL) { - /*--- Identify the boundary by string name and retrive heatflux from config ---*/ - su2double *Normal, GradT[3] = {0.0,0.0,0.0}, UnitNormal[3] = {0.0,0.0,0.0}; + /*--- Identify the boundary by string name and retrive ISOTHERMAL from config ---*/ + su2double GradT[3] = {0.0,0.0,0.0}; for (auto iVertex = 0ul; iVertex < geometry->nVertex[iMarker]; iVertex++) { @@ -243,18 +243,16 @@ void CIncNSSolver::GetStreamwise_Periodic_Properties(const CGeometry *geometry, const auto AreaNormal = geometry->vertex[iMarker][iVertex]->GetNormal(); - const su2double FaceArea = GeometryToolbox::Norm(nDim, AreaNormal); - /*Compute wall heat flux (normal to the wall) based on computed temperature gradient*/ for(auto iDim=0; iDim < nDim; iDim++) { GradT[iDim] = nodes->GetGradient_Primitive(iPoint, 3, iDim); dTdn_Local += GradT[iDim]*AreaNormal[iDim]*nodes->GetThermalConductivity(iPoint); - } - } - } + } // loop dim + } // loop Vertices + } // loop Isothermal Marker } // loop AllMarker - + /*--- Loop over all heatflux Markers ---*/ for (unsigned long iPoint = 0; iPoint < geometry->GetnPoint(); iPoint++) { if (!geometry->nodes->GetDomain(iPoint)) continue; @@ -271,38 +269,46 @@ void CIncNSSolver::GetStreamwise_Periodic_Properties(const CGeometry *geometry, Volume_VTemp_Local += volume * Temp * nodes->GetVelocity(iPoint, 0) * nodes->GetDensity(iPoint); - }// points + } // points - /*--- MPI Communication sum up integrated Heatflux from all processes ---*/ - SU2_MPI::Allreduce(&HeatFlow_Local, &HeatFlow_Global, 1, MPI_DOUBLE, MPI_SUM, SU2_MPI::GetComm()); - SU2_MPI::Allreduce(&dTdn_Local, &dTdn_Global, 1, MPI_DOUBLE, MPI_SUM, SU2_MPI::GetComm()); - SU2_MPI::Allreduce(&Volume_Temp_Local, &Volume_Temp_Global, 1, MPI_DOUBLE, MPI_SUM, SU2_MPI::GetComm()); - SU2_MPI::Allreduce(&Volume_VTemp_Local, &Volume_VTemp_Global, 1, MPI_DOUBLE, MPI_SUM, SU2_MPI::GetComm()); - SU2_MPI::Allreduce(&Volume_Local, &Volume_Global, 1, MPI_DOUBLE, MPI_SUM, SU2_MPI::GetComm()); - SU2_MPI::Allreduce(&Volume_TempS_Local, &Volume_TempS_Global, 1, MPI_DOUBLE, MPI_SUM, SU2_MPI::GetComm()); + if (config->GetnMarker_HeatFlux() > 0) { + /*--- MPI Communication sum up integrated Heatflux from all processes ---*/ + SU2_MPI::Allreduce(&HeatFlow_Local, &HeatFlow_Global, 1, MPI_DOUBLE, MPI_SUM, SU2_MPI::GetComm()); - auto theta_scaling = Volume_TempS_Global/Volume_Global; - cout<<"======== Theta_scaling :: "<GetnPoint(); iPoint++) { - nodes->SetStreamwise_Periodic_RecoveredTemperature(iPoint, nodes->GetTemperature(iPoint)/theta_scaling); - } + /*--- Set the solver variable Integrated Heatflux ---*/ + SPvals.Streamwise_Periodic_IntegratedHeatFlow = HeatFlow_Global; + } // if heat flux - /*--- Set the solver variable Integrated Heatflux ---*/ - SPvals.Streamwise_Periodic_IntegratedHeatFlow = HeatFlow_Global; - /*--- Set the solver variable Lambda_L for iso-thermal BCs ---*/ - auto b0_coeff = Volume_Temp_Global; - auto b1_coeff = Volume_VTemp_Global * config->GetSpecific_Heat_Cp(); - auto b2_coeff = -dTdn_Global; - auto pred_lambda_1 = (- b1_coeff - sqrt(b1_coeff * b1_coeff - 4 * b0_coeff * b2_coeff))/(2 * b0_coeff); - auto pred_lambda_2 = (- b1_coeff + sqrt(b1_coeff * b1_coeff - 4 * b0_coeff * b2_coeff))/(2 * b0_coeff); - auto pred_lambda = pred_lambda_2; - if (!isnan(pred_lambda)) { - SPvals.Streamwise_Periodic_LambdaL = SPvals.Streamwise_Periodic_LambdaL - 0.1 * (SPvals.Streamwise_Periodic_LambdaL - pred_lambda); - cout<<"b0_coeff :: "<GetnMarker_Isothermal() > 0) { + SU2_MPI::Allreduce(&dTdn_Local, &dTdn_Global, 1, MPI_DOUBLE, MPI_SUM, SU2_MPI::GetComm()); + SU2_MPI::Allreduce(&Volume_Temp_Local, &Volume_Temp_Global, 1, MPI_DOUBLE, MPI_SUM, SU2_MPI::GetComm()); + SU2_MPI::Allreduce(&Volume_VTemp_Local, &Volume_VTemp_Global, 1, MPI_DOUBLE, MPI_SUM, SU2_MPI::GetComm()); + SU2_MPI::Allreduce(&Volume_Local, &Volume_Global, 1, MPI_DOUBLE, MPI_SUM, SU2_MPI::GetComm()); + SU2_MPI::Allreduce(&Volume_TempS_Local, &Volume_TempS_Global, 1, MPI_DOUBLE, MPI_SUM, SU2_MPI::GetComm()); + + auto theta_scaling = Volume_TempS_Global/Volume_Global; + + for (unsigned long iPoint = 0; iPoint < geometry->GetnPoint(); iPoint++) { + nodes->SetStreamwise_Periodic_RecoveredTemperature(iPoint, nodes->GetTemperature(iPoint)/theta_scaling); + } // points + + /*--- Set the solver variable Lambda_L for iso-thermal BCs ---*/ + auto b0_coeff = Volume_Temp_Global; + auto b1_coeff = Volume_VTemp_Global * config->GetSpecific_Heat_Cp(); + auto b2_coeff = -dTdn_Global; + + /*--- Find the value of Lambda L by solving the quadratic equation ---*/ + auto pred_lambda_2 = (- b1_coeff + sqrt(b1_coeff * b1_coeff - 4 * b0_coeff * b2_coeff))/(2 * b0_coeff); + auto pred_lambda = pred_lambda_2; + if (!isnan(pred_lambda)) { + SPvals.Streamwise_Periodic_LambdaL = SPvals.Streamwise_Periodic_LambdaL - 0.1 * (SPvals.Streamwise_Periodic_LambdaL - pred_lambda); + // FOR Debugging, will be removed later on + // cout<<"b0_coeff :: "< Date: Thu, 14 Jul 2022 13:15:52 +0200 Subject: [PATCH 04/36] iso-thermal objectives still not getting validated --- Common/include/option_structure.hpp | 2 ++ SU2_CFD/src/solvers/CIncNSSolver.cpp | 49 +++++++++++++++------------- 2 files changed, 28 insertions(+), 23 deletions(-) diff --git a/Common/include/option_structure.hpp b/Common/include/option_structure.hpp index e590326aff2..4837750e3e3 100644 --- a/Common/include/option_structure.hpp +++ b/Common/include/option_structure.hpp @@ -2442,6 +2442,8 @@ struct StreamwisePeriodicValues { su2double Streamwise_Periodic_BoundaryArea; /*!< \brief Global Surface area of the streamwise periodic interface. */ su2double Streamwise_Periodic_AvgDensity; /*!< \brief Area avg density on the periodic interface. */ su2double Streamwise_Periodic_LambdaL; /*!< \brief Temperature Gradient in iso-thermal BCs. */ + su2double Streamwise_Periodic_LambdaL_update; /*!< \brief Temperature Gradient in iso-thermal BCs. */ + su2double Streamwise_Periodic_ThetaScaling; /*!< \brief Temperature Gradient in iso-thermal BCs. */ }; /*! diff --git a/SU2_CFD/src/solvers/CIncNSSolver.cpp b/SU2_CFD/src/solvers/CIncNSSolver.cpp index f668558986d..9c98202e2ba 100644 --- a/SU2_CFD/src/solvers/CIncNSSolver.cpp +++ b/SU2_CFD/src/solvers/CIncNSSolver.cpp @@ -271,43 +271,46 @@ void CIncNSSolver::GetStreamwise_Periodic_Properties(const CGeometry *geometry, } // points - if (config->GetnMarker_HeatFlux() > 0) { /*--- MPI Communication sum up integrated Heatflux from all processes ---*/ SU2_MPI::Allreduce(&HeatFlow_Local, &HeatFlow_Global, 1, MPI_DOUBLE, MPI_SUM, SU2_MPI::GetComm()); - - /*--- Set the solver variable Integrated Heatflux ---*/ - SPvals.Streamwise_Periodic_IntegratedHeatFlow = HeatFlow_Global; - } // if heat flux - - if (config->GetnMarker_Isothermal() > 0) { SU2_MPI::Allreduce(&dTdn_Local, &dTdn_Global, 1, MPI_DOUBLE, MPI_SUM, SU2_MPI::GetComm()); SU2_MPI::Allreduce(&Volume_Temp_Local, &Volume_Temp_Global, 1, MPI_DOUBLE, MPI_SUM, SU2_MPI::GetComm()); SU2_MPI::Allreduce(&Volume_VTemp_Local, &Volume_VTemp_Global, 1, MPI_DOUBLE, MPI_SUM, SU2_MPI::GetComm()); SU2_MPI::Allreduce(&Volume_Local, &Volume_Global, 1, MPI_DOUBLE, MPI_SUM, SU2_MPI::GetComm()); SU2_MPI::Allreduce(&Volume_TempS_Local, &Volume_TempS_Global, 1, MPI_DOUBLE, MPI_SUM, SU2_MPI::GetComm()); - auto theta_scaling = Volume_TempS_Global/Volume_Global; + if (config->GetnMarker_HeatFlux() > 0) { + /*--- Set the solver variable Integrated Heatflux ---*/ + SPvals.Streamwise_Periodic_IntegratedHeatFlow = HeatFlow_Global; + } // if heat flux + + if (config->GetnMarker_Isothermal() > 0) { + SPvals.Streamwise_Periodic_ThetaScaling = Volume_TempS_Global/Volume_Global; - for (unsigned long iPoint = 0; iPoint < geometry->GetnPoint(); iPoint++) { - nodes->SetStreamwise_Periodic_RecoveredTemperature(iPoint, nodes->GetTemperature(iPoint)/theta_scaling); - } // points + for (unsigned long iPoint = 0; iPoint < geometry->GetnPoint(); iPoint++) + nodes->SetStreamwise_Periodic_RecoveredTemperature(iPoint, nodes->GetTemperature(iPoint)/SPvals.Streamwise_Periodic_ThetaScaling); /*--- Set the solver variable Lambda_L for iso-thermal BCs ---*/ - auto b0_coeff = Volume_Temp_Global; - auto b1_coeff = Volume_VTemp_Global * config->GetSpecific_Heat_Cp(); - auto b2_coeff = -dTdn_Global; - + su2double b0_coeff = Volume_Temp_Global; + su2double b1_coeff = Volume_VTemp_Global * config->GetSpecific_Heat_Cp(); + su2double b2_coeff = -dTdn_Global; + // cout<GetSpecific_Heat_Cp()<<" "<GetDiscrete_Adjoint()) + SPvals.Streamwise_Periodic_LambdaL_update -= 0.1 * (SPvals.Streamwise_Periodic_LambdaL - pred_lambda); + else + SPvals.Streamwise_Periodic_LambdaL_update = pred_lambda; + SPvals.Streamwise_Periodic_LambdaL = SPvals.Streamwise_Periodic_LambdaL_update; + cout<<"Values of Lambda :: "< Date: Tue, 19 Jul 2022 09:51:57 +0200 Subject: [PATCH 05/36] Turbulent isothermal source terms added, validation pending --- SU2_CFD/src/numerics/flow/flow_sources.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/SU2_CFD/src/numerics/flow/flow_sources.cpp b/SU2_CFD/src/numerics/flow/flow_sources.cpp index c029bdb65e8..7b82582b8ea 100644 --- a/SU2_CFD/src/numerics/flow/flow_sources.cpp +++ b/SU2_CFD/src/numerics/flow/flow_sources.cpp @@ -757,12 +757,18 @@ CNumerics::ResidualType<> CSourceIncStreamwise_Periodic::ComputeResidual(const C /*--- If a RANS turbulence model is used, an additional source term, based on the eddy viscosity gradient is added. ---*/ if(turbulent) { + if (bool_heat_flux_bc) { + /*--- Compute a scalar factor ---*/ + scalar_factor = SPvals.Streamwise_Periodic_IntegratedHeatFlow / (SPvals.Streamwise_Periodic_MassFlow * sqrt(norm2_translation) * Prandtl_Turb); + } + + if (bool_isotherml_bc) { + dot_product = GeometryToolbox::DotProduct(nDim, Streamwise_Coord_Vector, PrimVar_Grad_i[3]); + scalar_factor -= (V_i[3] * SPvals.Streamwise_Periodic_LambdaL + dot_product) / (DensityInc_i * Prandtl_Turb); + } - /*--- Compute a scalar factor ---*/ - scalar_factor = SPvals.Streamwise_Periodic_IntegratedHeatFlow / (SPvals.Streamwise_Periodic_MassFlow * sqrt(norm2_translation) * Prandtl_Turb); - - /*--- Compute scalar product between periodic translation vector and eddy viscosity gradient. ---*/ - dot_product = GeometryToolbox::DotProduct(nDim, Streamwise_Coord_Vector, AuxVar_Grad_i[0]); + /*--- Compute scalar product between periodic translation vector and eddy viscosity gradient. ---*/ + dot_product = GeometryToolbox::DotProduct(nDim, Streamwise_Coord_Vector, AuxVar_Grad_i[0]); residual[nDim+1] -= Volume * scalar_factor * dot_product; } // if turbulent From 988b5a956937eedec1eb920745b3401261be0d2f Mon Sep 17 00:00:00 2001 From: Nitish Annad Date: Tue, 19 Jul 2022 16:28:35 +0200 Subject: [PATCH 06/36] Quadratic term for turbulent equations, solution verification and gradient validation pending --- SU2_CFD/src/numerics/flow/flow_sources.cpp | 2 +- SU2_CFD/src/solvers/CIncNSSolver.cpp | 32 ++++++++++++++++++---- 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/SU2_CFD/src/numerics/flow/flow_sources.cpp b/SU2_CFD/src/numerics/flow/flow_sources.cpp index 7b82582b8ea..ffd45a7c26e 100644 --- a/SU2_CFD/src/numerics/flow/flow_sources.cpp +++ b/SU2_CFD/src/numerics/flow/flow_sources.cpp @@ -764,7 +764,7 @@ CNumerics::ResidualType<> CSourceIncStreamwise_Periodic::ComputeResidual(const C if (bool_isotherml_bc) { dot_product = GeometryToolbox::DotProduct(nDim, Streamwise_Coord_Vector, PrimVar_Grad_i[3]); - scalar_factor -= (V_i[3] * SPvals.Streamwise_Periodic_LambdaL + dot_product) / (DensityInc_i * Prandtl_Turb); + scalar_factor -= (V_i[3] * SPvals.Streamwise_Periodic_LambdaL + dot_product) * config->GetSpecific_Heat_Cp() / Prandtl_Turb; } /*--- Compute scalar product between periodic translation vector and eddy viscosity gradient. ---*/ diff --git a/SU2_CFD/src/solvers/CIncNSSolver.cpp b/SU2_CFD/src/solvers/CIncNSSolver.cpp index 9c98202e2ba..cea7163861e 100644 --- a/SU2_CFD/src/solvers/CIncNSSolver.cpp +++ b/SU2_CFD/src/solvers/CIncNSSolver.cpp @@ -123,7 +123,7 @@ void CIncNSSolver::Preprocessing(CGeometry *geometry, CSolver **solver_container void CIncNSSolver::GetStreamwise_Periodic_Properties(const CGeometry *geometry, CConfig *config, const unsigned short iMesh) { - + bool turbulent = (config->GetKind_Turb_Model() != TURB_MODEL::NONE); /*---------------------------------------------------------------------------------------------*/ // 1. Evaluate massflow, area avg density & Temperature and Area at streamwise periodic outlet. // 2. Update delta_p is target massflow is chosen. @@ -207,6 +207,8 @@ void CIncNSSolver::GetStreamwise_Periodic_Properties(const CGeometry *geometry, su2double Volume_TempS_Local = 0.0, Volume_TempS_Global = 0.0; su2double Volume_Local = 0.0, Volume_Global = 0.0; su2double Volume_VTemp_Local = 0.0, Volume_VTemp_Global = 0.0; + su2double turb_b1_coeff_Local = 0.0, turb_b1_coeff_Global = 0.0; + su2double turb_b2_coeff_Local = 0.0, turb_b2_coeff_Global = 0.0; /*--- Loop over all heatflux Markers ---*/ for (auto iMarker = 0; iMarker < config->GetnMarker_All(); iMarker++) { @@ -267,6 +269,18 @@ void CIncNSSolver::GetStreamwise_Periodic_Properties(const CGeometry *geometry, Volume_Temp_Local += volume * Temp * nodes->GetThermalConductivity(iPoint); + if (turbulent && (config->GetnMarker_Isothermal() != 0)) { + + // To be added to coeff_b1 + turb_b1_coeff_Local += Temp * nodes->GetAuxVarGradient(iPoint, 0, 0) * config->GetSpecific_Heat_Cp() * volume / config->GetPrandtl_Turb(); + + // To be added to coeff_b2 + su2double dot_product = 0.0; + for (unsigned short iDim = 0; iDim < nDim; iDim++) + dot_product += nodes->GetGradient_Primitive(iPoint, 3, iDim) * nodes->GetAuxVarGradient(iPoint, 0, iDim); + turb_b2_coeff_Local += dot_product * volume * config->GetSpecific_Heat_Cp() / config->GetPrandtl_Turb(); + } + Volume_VTemp_Local += volume * Temp * nodes->GetVelocity(iPoint, 0) * nodes->GetDensity(iPoint); } // points @@ -278,6 +292,8 @@ void CIncNSSolver::GetStreamwise_Periodic_Properties(const CGeometry *geometry, SU2_MPI::Allreduce(&Volume_VTemp_Local, &Volume_VTemp_Global, 1, MPI_DOUBLE, MPI_SUM, SU2_MPI::GetComm()); SU2_MPI::Allreduce(&Volume_Local, &Volume_Global, 1, MPI_DOUBLE, MPI_SUM, SU2_MPI::GetComm()); SU2_MPI::Allreduce(&Volume_TempS_Local, &Volume_TempS_Global, 1, MPI_DOUBLE, MPI_SUM, SU2_MPI::GetComm()); + SU2_MPI::Allreduce(&turb_b1_coeff_Local, &turb_b1_coeff_Global, 1, MPI_DOUBLE, MPI_SUM, SU2_MPI::GetComm()); + SU2_MPI::Allreduce(&turb_b2_coeff_Local, &turb_b2_coeff_Global, 1, MPI_DOUBLE, MPI_SUM, SU2_MPI::GetComm()); if (config->GetnMarker_HeatFlux() > 0) { /*--- Set the solver variable Integrated Heatflux ---*/ @@ -287,13 +303,17 @@ void CIncNSSolver::GetStreamwise_Periodic_Properties(const CGeometry *geometry, if (config->GetnMarker_Isothermal() > 0) { SPvals.Streamwise_Periodic_ThetaScaling = Volume_TempS_Global/Volume_Global; - for (unsigned long iPoint = 0; iPoint < geometry->GetnPoint(); iPoint++) - nodes->SetStreamwise_Periodic_RecoveredTemperature(iPoint, nodes->GetTemperature(iPoint)/SPvals.Streamwise_Periodic_ThetaScaling); + // for (unsigned long iPoint = 0; iPoint < geometry->GetnPoint(); iPoint++) + // nodes->SetStreamwise_Periodic_RecoveredTemperature(iPoint, nodes->GetTemperature(iPoint)/SPvals.Streamwise_Periodic_ThetaScaling); /*--- Set the solver variable Lambda_L for iso-thermal BCs ---*/ su2double b0_coeff = Volume_Temp_Global; - su2double b1_coeff = Volume_VTemp_Global * config->GetSpecific_Heat_Cp(); - su2double b2_coeff = -dTdn_Global; + su2double b1_coeff = Volume_VTemp_Global * config->GetSpecific_Heat_Cp() + turb_b1_coeff_Global; + su2double b2_coeff = -dTdn_Global + turb_b2_coeff_Global; + + // if(turbulent) { + + // } // cout<GetSpecific_Heat_Cp()<<" "< Date: Fri, 12 Aug 2022 14:08:56 +0200 Subject: [PATCH 07/36] Gradient Validation for Lambda L is working for Laminar and Turbulent flow cases --- Common/include/CConfig.hpp | 13 +++++++++++++ Common/include/option_structure.hpp | 2 ++ SU2_CFD/include/solvers/CFVMFlowSolverBase.inl | 2 ++ SU2_CFD/src/output/CFlowIncOutput.cpp | 4 ++++ SU2_CFD/src/output/CFlowOutput.cpp | 2 +- SU2_CFD/src/solvers/CIncNSSolver.cpp | 3 ++- 6 files changed, 24 insertions(+), 2 deletions(-) diff --git a/Common/include/CConfig.hpp b/Common/include/CConfig.hpp index c46c589965e..596d034661c 100644 --- a/Common/include/CConfig.hpp +++ b/Common/include/CConfig.hpp @@ -1040,6 +1040,7 @@ class CConfig { su2double Streamwise_Periodic_PressureDrop; /*!< \brief Value of prescribed pressure drop [Pa] which results in an artificial body force vector. */ su2double Streamwise_Periodic_TargetMassFlow; /*!< \brief Value of prescribed massflow [kg/s] which results in an delta p and therefore an artificial body force vector. */ su2double Streamwise_Periodic_OutletHeat; /*!< /brief Heatflux boundary [W/m^2] imposed at streamwise periodic outlet. */ + su2double Streamwise_Periodic_LambdaL; /*!< /brief Exp coefficient for iso-thermal BCs Streamwise Periodic. */ su2double *FreeStreamTurboNormal; /*!< \brief Direction to initialize the flow in turbomachinery computation */ su2double Restart_Bandwidth_Agg; /*!< \brief The aggregate of the bandwidth for writing binary restarts (to be averaged later). */ @@ -9639,4 +9640,16 @@ class CConfig { */ SA_ParsedOptions GetSAParsedOptions() const { return saParsedOptions; } + /*! + * \brief Set Lambda L for Streamwise Periodic + * \return bool + */ + void SetStreamwise_Periodic_LamdaL(su2double value) { Streamwise_Periodic_LambdaL = value; } + + /*! + * \brief Set Lambda L for Streamwise Periodic + * \return bool + */ + su2double GetStreamwise_Periodic_LamdaL(void) const { return Streamwise_Periodic_LambdaL; } + }; diff --git a/Common/include/option_structure.hpp b/Common/include/option_structure.hpp index 4837750e3e3..8cb11c58269 100644 --- a/Common/include/option_structure.hpp +++ b/Common/include/option_structure.hpp @@ -1762,6 +1762,7 @@ enum ENUM_OBJECTIVE { TOPOL_DISCRETENESS = 63, /*!< \brief Measure of the discreteness of the current topology. */ TOPOL_COMPLIANCE = 64, /*!< \brief Measure of the discreteness of the current topology. */ STRESS_PENALTY = 65, /*!< \brief Penalty function of VM stresses above a maximum value. */ + STREAMWISE_PERIODIC_LAMBDAL= 71, }; static const MapType Objective_Map = { MakePair("DRAG", DRAG_COEFFICIENT) @@ -1797,6 +1798,7 @@ static const MapType Objective_Map = { MakePair("SURFACE_PRESSURE_DROP", SURFACE_PRESSURE_DROP) MakePair("SURFACE_SPECIES_0", SURFACE_SPECIES_0) MakePair("SURFACE_SPECIES_VARIANCE", SURFACE_SPECIES_VARIANCE) + MakePair("STREAMWISE_PERIODIC_LAMBDAL", STREAMWISE_PERIODIC_LAMBDAL) MakePair("CUSTOM_OBJFUNC", CUSTOM_OBJFUNC) MakePair("FLOW_ANGLE_OUT", FLOW_ANGLE_OUT) MakePair("MASS_FLOW_IN", MASS_FLOW_IN) diff --git a/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl b/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl index bf589df95a7..27b441dc5c5 100644 --- a/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl +++ b/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl @@ -2985,6 +2985,8 @@ su2double CFVMFlowSolverBase::EvaluateCommonObjFunc(const CConfig& config) case SURFACE_SPECIES_VARIANCE: objFun += weight * config.GetSurface_Species_Variance(0); break; + case STREAMWISE_PERIODIC_LAMBDAL: + objFun += weight * config.GetStreamwise_Periodic_LamdaL(); case CUSTOM_OBJFUNC: objFun += weight * Total_Custom_ObjFunc; break; diff --git a/SU2_CFD/src/output/CFlowIncOutput.cpp b/SU2_CFD/src/output/CFlowIncOutput.cpp index 3ba641f2f88..2937efa54f1 100644 --- a/SU2_CFD/src/output/CFlowIncOutput.cpp +++ b/SU2_CFD/src/output/CFlowIncOutput.cpp @@ -178,6 +178,8 @@ void CFlowIncOutput::SetHistoryOutputFields(CConfig *config){ AddHistoryOutput("STREAMWISE_MASSFLOW", "SWMassflow", ScreenOutputFormat::FIXED, "STREAMWISE_PERIODIC", "Massflow in streamwise periodic flow"); AddHistoryOutput("STREAMWISE_DP", "SWDeltaP", ScreenOutputFormat::FIXED, "STREAMWISE_PERIODIC", "Pressure drop in streamwise periodic flow"); AddHistoryOutput("STREAMWISE_HEAT", "SWHeat", ScreenOutputFormat::FIXED, "STREAMWISE_PERIODIC", "Integrated heat for streamwise periodic flow"); + if(config->GetnMarker_Isothermal() > 0) + AddHistoryOutput("STREAMWISE_LAMBDAL", "SWLambdaL", ScreenOutputFormat::FIXED, "STREAMWISE_PERIODIC", "Exponential factor for iso-thermal temperature gradient"); } AddAnalyzeSurfaceOutput(config); @@ -262,6 +264,8 @@ void CFlowIncOutput::LoadHistoryData(CConfig *config, CGeometry *geometry, CSolv SetHistoryOutputValue("STREAMWISE_MASSFLOW", flow_solver->GetStreamwisePeriodicValues().Streamwise_Periodic_MassFlow); SetHistoryOutputValue("STREAMWISE_DP", flow_solver->GetStreamwisePeriodicValues().Streamwise_Periodic_PressureDrop); SetHistoryOutputValue("STREAMWISE_HEAT", flow_solver->GetStreamwisePeriodicValues().Streamwise_Periodic_IntegratedHeatFlow); + if(config->GetnMarker_Isothermal() > 0) + SetHistoryOutputValue("STREAMWISE_LAMBDAL", flow_solver->GetStreamwisePeriodicValues().Streamwise_Periodic_LambdaL); } /*--- Set the analyse surface history values --- */ diff --git a/SU2_CFD/src/output/CFlowOutput.cpp b/SU2_CFD/src/output/CFlowOutput.cpp index 5107727ffbf..db6bf079dff 100644 --- a/SU2_CFD/src/output/CFlowOutput.cpp +++ b/SU2_CFD/src/output/CFlowOutput.cpp @@ -462,7 +462,7 @@ void CFlowOutput::SetAnalyzeSurface(const CSolver* const*solver, const CGeometry Tot_Surface_Temperature += Temperature; config->SetSurface_Temperature(iMarker_Analyze, Temperature); - su2double Pressure = Surface_Pressure_Total[iMarker_Analyze] * config->GetPressure_Ref(); + su2double Pressure = Surface_Pressure[iMarker_Analyze] * config->GetPressure_Ref(); SetHistoryOutputPerSurfaceValue("SURFACE_STATIC_PRESSURE", Pressure, iMarker_Analyze); Tot_Surface_Pressure += Pressure; config->SetSurface_Pressure(iMarker_Analyze, Pressure); diff --git a/SU2_CFD/src/solvers/CIncNSSolver.cpp b/SU2_CFD/src/solvers/CIncNSSolver.cpp index cea7163861e..2ccf159dc46 100644 --- a/SU2_CFD/src/solvers/CIncNSSolver.cpp +++ b/SU2_CFD/src/solvers/CIncNSSolver.cpp @@ -324,7 +324,8 @@ void CIncNSSolver::GetStreamwise_Periodic_Properties(const CGeometry *geometry, else SPvals.Streamwise_Periodic_LambdaL_update = pred_lambda; SPvals.Streamwise_Periodic_LambdaL = SPvals.Streamwise_Periodic_LambdaL_update; - // cout<<"Values of Lambda :: "<SetStreamwise_Periodic_LamdaL(SPvals.Streamwise_Periodic_LambdaL); + // cout<<"Values of Lambda :: "< Date: Fri, 12 Aug 2022 15:02:16 +0200 Subject: [PATCH 08/36] cleaning and comments --- Common/include/option_structure.hpp | 3 +- SU2_CFD/src/solvers/CIncNSSolver.cpp | 52 +++++++++++----------------- 2 files changed, 22 insertions(+), 33 deletions(-) diff --git a/Common/include/option_structure.hpp b/Common/include/option_structure.hpp index 8cb11c58269..7e933c30f95 100644 --- a/Common/include/option_structure.hpp +++ b/Common/include/option_structure.hpp @@ -2444,8 +2444,7 @@ struct StreamwisePeriodicValues { su2double Streamwise_Periodic_BoundaryArea; /*!< \brief Global Surface area of the streamwise periodic interface. */ su2double Streamwise_Periodic_AvgDensity; /*!< \brief Area avg density on the periodic interface. */ su2double Streamwise_Periodic_LambdaL; /*!< \brief Temperature Gradient in iso-thermal BCs. */ - su2double Streamwise_Periodic_LambdaL_update; /*!< \brief Temperature Gradient in iso-thermal BCs. */ - su2double Streamwise_Periodic_ThetaScaling; /*!< \brief Temperature Gradient in iso-thermal BCs. */ + su2double Streamwise_Periodic_ThetaScaling; /*!< \brief Scaled Temperature for iso-thermal BCs. */ }; /*! diff --git a/SU2_CFD/src/solvers/CIncNSSolver.cpp b/SU2_CFD/src/solvers/CIncNSSolver.cpp index 2ccf159dc46..119638200fc 100644 --- a/SU2_CFD/src/solvers/CIncNSSolver.cpp +++ b/SU2_CFD/src/solvers/CIncNSSolver.cpp @@ -247,13 +247,20 @@ void CIncNSSolver::GetStreamwise_Periodic_Properties(const CGeometry *geometry, /*Compute wall heat flux (normal to the wall) based on computed temperature gradient*/ for(auto iDim=0; iDim < nDim; iDim++) { + GradT[iDim] = nodes->GetGradient_Primitive(iPoint, 3, iDim); + dTdn_Local += GradT[iDim]*AreaNormal[iDim]*nodes->GetThermalConductivity(iPoint); + } // loop dim } // loop Vertices } // loop Isothermal Marker } // loop AllMarker + /*--- MPI Communication sum up integrated Heatflux from all processes ---*/ + SU2_MPI::Allreduce(&HeatFlow_Local, &HeatFlow_Global, 1, MPI_DOUBLE, MPI_SUM, SU2_MPI::GetComm()); + SU2_MPI::Allreduce(&dTdn_Local, &dTdn_Global, 1, MPI_DOUBLE, MPI_SUM, SU2_MPI::GetComm()); + /*--- Loop over all heatflux Markers ---*/ for (unsigned long iPoint = 0; iPoint < geometry->GetnPoint(); iPoint++) { @@ -271,10 +278,10 @@ void CIncNSSolver::GetStreamwise_Periodic_Properties(const CGeometry *geometry, if (turbulent && (config->GetnMarker_Isothermal() != 0)) { - // To be added to coeff_b1 + // coeff_b1 for turbulence turb_b1_coeff_Local += Temp * nodes->GetAuxVarGradient(iPoint, 0, 0) * config->GetSpecific_Heat_Cp() * volume / config->GetPrandtl_Turb(); - // To be added to coeff_b2 + // coeff_b2 for turbulence su2double dot_product = 0.0; for (unsigned short iDim = 0; iDim < nDim; iDim++) dot_product += nodes->GetGradient_Primitive(iPoint, 3, iDim) * nodes->GetAuxVarGradient(iPoint, 0, iDim); @@ -285,20 +292,17 @@ void CIncNSSolver::GetStreamwise_Periodic_Properties(const CGeometry *geometry, } // points - /*--- MPI Communication sum up integrated Heatflux from all processes ---*/ - SU2_MPI::Allreduce(&HeatFlow_Local, &HeatFlow_Global, 1, MPI_DOUBLE, MPI_SUM, SU2_MPI::GetComm()); - SU2_MPI::Allreduce(&dTdn_Local, &dTdn_Global, 1, MPI_DOUBLE, MPI_SUM, SU2_MPI::GetComm()); - SU2_MPI::Allreduce(&Volume_Temp_Local, &Volume_Temp_Global, 1, MPI_DOUBLE, MPI_SUM, SU2_MPI::GetComm()); - SU2_MPI::Allreduce(&Volume_VTemp_Local, &Volume_VTemp_Global, 1, MPI_DOUBLE, MPI_SUM, SU2_MPI::GetComm()); - SU2_MPI::Allreduce(&Volume_Local, &Volume_Global, 1, MPI_DOUBLE, MPI_SUM, SU2_MPI::GetComm()); - SU2_MPI::Allreduce(&Volume_TempS_Local, &Volume_TempS_Global, 1, MPI_DOUBLE, MPI_SUM, SU2_MPI::GetComm()); - SU2_MPI::Allreduce(&turb_b1_coeff_Local, &turb_b1_coeff_Global, 1, MPI_DOUBLE, MPI_SUM, SU2_MPI::GetComm()); - SU2_MPI::Allreduce(&turb_b2_coeff_Local, &turb_b2_coeff_Global, 1, MPI_DOUBLE, MPI_SUM, SU2_MPI::GetComm()); - - if (config->GetnMarker_HeatFlux() > 0) { - /*--- Set the solver variable Integrated Heatflux ---*/ + /*--- MPI Communication sum up integrated Heatflux from all processes ---*/ + SU2_MPI::Allreduce(&Volume_Temp_Local, &Volume_Temp_Global, 1, MPI_DOUBLE, MPI_SUM, SU2_MPI::GetComm()); + SU2_MPI::Allreduce(&Volume_VTemp_Local, &Volume_VTemp_Global, 1, MPI_DOUBLE, MPI_SUM, SU2_MPI::GetComm()); + SU2_MPI::Allreduce(&Volume_Local, &Volume_Global, 1, MPI_DOUBLE, MPI_SUM, SU2_MPI::GetComm()); + SU2_MPI::Allreduce(&Volume_TempS_Local, &Volume_TempS_Global, 1, MPI_DOUBLE, MPI_SUM, SU2_MPI::GetComm()); + SU2_MPI::Allreduce(&turb_b1_coeff_Local, &turb_b1_coeff_Global, 1, MPI_DOUBLE, MPI_SUM, SU2_MPI::GetComm()); + SU2_MPI::Allreduce(&turb_b2_coeff_Local, &turb_b2_coeff_Global, 1, MPI_DOUBLE, MPI_SUM, SU2_MPI::GetComm()); + + /*--- Set the solver variable Integrated Heatflux ---*/ + if (config->GetnMarker_HeatFlux() > 0) SPvals.Streamwise_Periodic_IntegratedHeatFlow = HeatFlow_Global; - } // if heat flux if (config->GetnMarker_Isothermal() > 0) { SPvals.Streamwise_Periodic_ThetaScaling = Volume_TempS_Global/Volume_Global; @@ -311,27 +315,13 @@ void CIncNSSolver::GetStreamwise_Periodic_Properties(const CGeometry *geometry, su2double b1_coeff = Volume_VTemp_Global * config->GetSpecific_Heat_Cp() + turb_b1_coeff_Global; su2double b2_coeff = -dTdn_Global + turb_b2_coeff_Global; - // if(turbulent) { - - // } - // cout<GetSpecific_Heat_Cp()<<" "<GetDiscrete_Adjoint()) - SPvals.Streamwise_Periodic_LambdaL_update -= 0.1 * (SPvals.Streamwise_Periodic_LambdaL - pred_lambda); + SPvals.Streamwise_Periodic_LambdaL -= 0.1 * (SPvals.Streamwise_Periodic_LambdaL - pred_lambda); else - SPvals.Streamwise_Periodic_LambdaL_update = pred_lambda; - SPvals.Streamwise_Periodic_LambdaL = SPvals.Streamwise_Periodic_LambdaL_update; + SPvals.Streamwise_Periodic_LambdaL = pred_lambda; config->SetStreamwise_Periodic_LamdaL(SPvals.Streamwise_Periodic_LambdaL); - // cout<<"Values of Lambda :: "< Date: Sat, 20 Aug 2022 18:38:01 +0200 Subject: [PATCH 09/36] Small correction to the source terms --- SU2_CFD/src/numerics/flow/flow_sources.cpp | 2 +- SU2_CFD/src/solvers/CIncNSSolver.cpp | 19 +++++++++++-------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/SU2_CFD/src/numerics/flow/flow_sources.cpp b/SU2_CFD/src/numerics/flow/flow_sources.cpp index ffd45a7c26e..d25da0ca2e6 100644 --- a/SU2_CFD/src/numerics/flow/flow_sources.cpp +++ b/SU2_CFD/src/numerics/flow/flow_sources.cpp @@ -764,7 +764,7 @@ CNumerics::ResidualType<> CSourceIncStreamwise_Periodic::ComputeResidual(const C if (bool_isotherml_bc) { dot_product = GeometryToolbox::DotProduct(nDim, Streamwise_Coord_Vector, PrimVar_Grad_i[3]); - scalar_factor -= (V_i[3] * SPvals.Streamwise_Periodic_LambdaL + dot_product) * config->GetSpecific_Heat_Cp() / Prandtl_Turb; + scalar_factor = (-V_i[3] * SPvals.Streamwise_Periodic_LambdaL + dot_product) * config->GetSpecific_Heat_Cp() / Prandtl_Turb; } /*--- Compute scalar product between periodic translation vector and eddy viscosity gradient. ---*/ diff --git a/SU2_CFD/src/solvers/CIncNSSolver.cpp b/SU2_CFD/src/solvers/CIncNSSolver.cpp index 119638200fc..1f48114a26f 100644 --- a/SU2_CFD/src/solvers/CIncNSSolver.cpp +++ b/SU2_CFD/src/solvers/CIncNSSolver.cpp @@ -297,8 +297,10 @@ void CIncNSSolver::GetStreamwise_Periodic_Properties(const CGeometry *geometry, SU2_MPI::Allreduce(&Volume_VTemp_Local, &Volume_VTemp_Global, 1, MPI_DOUBLE, MPI_SUM, SU2_MPI::GetComm()); SU2_MPI::Allreduce(&Volume_Local, &Volume_Global, 1, MPI_DOUBLE, MPI_SUM, SU2_MPI::GetComm()); SU2_MPI::Allreduce(&Volume_TempS_Local, &Volume_TempS_Global, 1, MPI_DOUBLE, MPI_SUM, SU2_MPI::GetComm()); - SU2_MPI::Allreduce(&turb_b1_coeff_Local, &turb_b1_coeff_Global, 1, MPI_DOUBLE, MPI_SUM, SU2_MPI::GetComm()); - SU2_MPI::Allreduce(&turb_b2_coeff_Local, &turb_b2_coeff_Global, 1, MPI_DOUBLE, MPI_SUM, SU2_MPI::GetComm()); + if (turbulent && (config->GetnMarker_Isothermal() != 0)) { + SU2_MPI::Allreduce(&turb_b1_coeff_Local, &turb_b1_coeff_Global, 1, MPI_DOUBLE, MPI_SUM, SU2_MPI::GetComm()); + SU2_MPI::Allreduce(&turb_b2_coeff_Local, &turb_b2_coeff_Global, 1, MPI_DOUBLE, MPI_SUM, SU2_MPI::GetComm()); + } /*--- Set the solver variable Integrated Heatflux ---*/ if (config->GetnMarker_HeatFlux() > 0) @@ -307,8 +309,8 @@ void CIncNSSolver::GetStreamwise_Periodic_Properties(const CGeometry *geometry, if (config->GetnMarker_Isothermal() > 0) { SPvals.Streamwise_Periodic_ThetaScaling = Volume_TempS_Global/Volume_Global; - // for (unsigned long iPoint = 0; iPoint < geometry->GetnPoint(); iPoint++) - // nodes->SetStreamwise_Periodic_RecoveredTemperature(iPoint, nodes->GetTemperature(iPoint)/SPvals.Streamwise_Periodic_ThetaScaling); + for (unsigned long iPoint = 0; iPoint < geometry->GetnPoint(); iPoint++) + nodes->SetStreamwise_Periodic_RecoveredTemperature(iPoint, nodes->GetTemperature(iPoint)/SPvals.Streamwise_Periodic_ThetaScaling); /*--- Set the solver variable Lambda_L for iso-thermal BCs ---*/ su2double b0_coeff = Volume_Temp_Global; @@ -317,11 +319,12 @@ void CIncNSSolver::GetStreamwise_Periodic_Properties(const CGeometry *geometry, /*--- Find the value of Lambda L by solving the quadratic equation ---*/ su2double pred_lambda = (- b1_coeff + sqrt(b1_coeff * b1_coeff - 4 * b0_coeff * b2_coeff))/(2 * b0_coeff); - if (!config->GetDiscrete_Adjoint()) - SPvals.Streamwise_Periodic_LambdaL -= 0.1 * (SPvals.Streamwise_Periodic_LambdaL - pred_lambda); - else + if (!config->GetDiscrete_Adjoint()) + SPvals.Streamwise_Periodic_LambdaL -= 0.01 * (SPvals.Streamwise_Periodic_LambdaL - pred_lambda); + else SPvals.Streamwise_Periodic_LambdaL = pred_lambda; - config->SetStreamwise_Periodic_LamdaL(SPvals.Streamwise_Periodic_LambdaL); + cout<<"Lambda :: "<SetStreamwise_Periodic_LamdaL(SPvals.Streamwise_Periodic_LambdaL); } // if isothermal } // if energy } From c6e12776eb5717dfb2ee7ee8421ddff29dc2b584 Mon Sep 17 00:00:00 2001 From: Nitish Annad Date: Wed, 12 Oct 2022 11:53:04 +0200 Subject: [PATCH 10/36] Correction to the SourceTerms to compute turbulent Lambda --- SU2_CFD/src/numerics/flow/flow_sources.cpp | 6 ++---- SU2_CFD/src/solvers/CIncNSSolver.cpp | 20 +++++--------------- 2 files changed, 7 insertions(+), 19 deletions(-) diff --git a/SU2_CFD/src/numerics/flow/flow_sources.cpp b/SU2_CFD/src/numerics/flow/flow_sources.cpp index d25da0ca2e6..1c013301ea9 100644 --- a/SU2_CFD/src/numerics/flow/flow_sources.cpp +++ b/SU2_CFD/src/numerics/flow/flow_sources.cpp @@ -762,10 +762,8 @@ CNumerics::ResidualType<> CSourceIncStreamwise_Periodic::ComputeResidual(const C scalar_factor = SPvals.Streamwise_Periodic_IntegratedHeatFlow / (SPvals.Streamwise_Periodic_MassFlow * sqrt(norm2_translation) * Prandtl_Turb); } - if (bool_isotherml_bc) { - dot_product = GeometryToolbox::DotProduct(nDim, Streamwise_Coord_Vector, PrimVar_Grad_i[3]); - scalar_factor = (-V_i[3] * SPvals.Streamwise_Periodic_LambdaL + dot_product) * config->GetSpecific_Heat_Cp() / Prandtl_Turb; - } + if (bool_isotherml_bc) + scalar_factor = (-V_i[3] * SPvals.Streamwise_Periodic_LambdaL) * config->GetSpecific_Heat_Cp() / Prandtl_Turb; /*--- Compute scalar product between periodic translation vector and eddy viscosity gradient. ---*/ dot_product = GeometryToolbox::DotProduct(nDim, Streamwise_Coord_Vector, AuxVar_Grad_i[0]); diff --git a/SU2_CFD/src/solvers/CIncNSSolver.cpp b/SU2_CFD/src/solvers/CIncNSSolver.cpp index 1f48114a26f..bef05e89d34 100644 --- a/SU2_CFD/src/solvers/CIncNSSolver.cpp +++ b/SU2_CFD/src/solvers/CIncNSSolver.cpp @@ -276,17 +276,9 @@ void CIncNSSolver::GetStreamwise_Periodic_Properties(const CGeometry *geometry, Volume_Temp_Local += volume * Temp * nodes->GetThermalConductivity(iPoint); - if (turbulent && (config->GetnMarker_Isothermal() != 0)) { - - // coeff_b1 for turbulence + // coeff_b1 for turbulence + if (turbulent && (config->GetnMarker_Isothermal() != 0)) turb_b1_coeff_Local += Temp * nodes->GetAuxVarGradient(iPoint, 0, 0) * config->GetSpecific_Heat_Cp() * volume / config->GetPrandtl_Turb(); - - // coeff_b2 for turbulence - su2double dot_product = 0.0; - for (unsigned short iDim = 0; iDim < nDim; iDim++) - dot_product += nodes->GetGradient_Primitive(iPoint, 3, iDim) * nodes->GetAuxVarGradient(iPoint, 0, iDim); - turb_b2_coeff_Local += dot_product * volume * config->GetSpecific_Heat_Cp() / config->GetPrandtl_Turb(); - } Volume_VTemp_Local += volume * Temp * nodes->GetVelocity(iPoint, 0) * nodes->GetDensity(iPoint); @@ -297,10 +289,8 @@ void CIncNSSolver::GetStreamwise_Periodic_Properties(const CGeometry *geometry, SU2_MPI::Allreduce(&Volume_VTemp_Local, &Volume_VTemp_Global, 1, MPI_DOUBLE, MPI_SUM, SU2_MPI::GetComm()); SU2_MPI::Allreduce(&Volume_Local, &Volume_Global, 1, MPI_DOUBLE, MPI_SUM, SU2_MPI::GetComm()); SU2_MPI::Allreduce(&Volume_TempS_Local, &Volume_TempS_Global, 1, MPI_DOUBLE, MPI_SUM, SU2_MPI::GetComm()); - if (turbulent && (config->GetnMarker_Isothermal() != 0)) { + if (turbulent && (config->GetnMarker_Isothermal() != 0)) SU2_MPI::Allreduce(&turb_b1_coeff_Local, &turb_b1_coeff_Global, 1, MPI_DOUBLE, MPI_SUM, SU2_MPI::GetComm()); - SU2_MPI::Allreduce(&turb_b2_coeff_Local, &turb_b2_coeff_Global, 1, MPI_DOUBLE, MPI_SUM, SU2_MPI::GetComm()); - } /*--- Set the solver variable Integrated Heatflux ---*/ if (config->GetnMarker_HeatFlux() > 0) @@ -315,7 +305,7 @@ void CIncNSSolver::GetStreamwise_Periodic_Properties(const CGeometry *geometry, /*--- Set the solver variable Lambda_L for iso-thermal BCs ---*/ su2double b0_coeff = Volume_Temp_Global; su2double b1_coeff = Volume_VTemp_Global * config->GetSpecific_Heat_Cp() + turb_b1_coeff_Global; - su2double b2_coeff = -dTdn_Global + turb_b2_coeff_Global; + su2double b2_coeff = -dTdn_Global; /*--- Find the value of Lambda L by solving the quadratic equation ---*/ su2double pred_lambda = (- b1_coeff + sqrt(b1_coeff * b1_coeff - 4 * b0_coeff * b2_coeff))/(2 * b0_coeff); @@ -323,7 +313,7 @@ void CIncNSSolver::GetStreamwise_Periodic_Properties(const CGeometry *geometry, SPvals.Streamwise_Periodic_LambdaL -= 0.01 * (SPvals.Streamwise_Periodic_LambdaL - pred_lambda); else SPvals.Streamwise_Periodic_LambdaL = pred_lambda; - cout<<"Lambda :: "<SetStreamwise_Periodic_LamdaL(SPvals.Streamwise_Periodic_LambdaL); } // if isothermal } // if energy From 3eaa05e0789e074a05adff1301a9a4dbba3f583a Mon Sep 17 00:00:00 2001 From: Nitish Annad Date: Wed, 12 Oct 2022 16:11:35 +0200 Subject: [PATCH 11/36] Merged with develop, minor verification in process --- externals/codi | 2 +- externals/opdi | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/externals/codi b/externals/codi index 96ac78ec5bc..3c3211fef2e 160000 --- a/externals/codi +++ b/externals/codi @@ -1 +1 @@ -Subproject commit 96ac78ec5bcc5ac25b785e79b16ed76fca22d736 +Subproject commit 3c3211fef2e225ab89680a4063b62bb3bb38a7e4 diff --git a/externals/opdi b/externals/opdi index 1aabf5bd1ed..6fb2691b8e4 160000 --- a/externals/opdi +++ b/externals/opdi @@ -1 +1 @@ -Subproject commit 1aabf5bd1ed77611742eb655002f2ac7a3dddef9 +Subproject commit 6fb2691b8e4a8f00f47d2a27740fa890df0b5405 From e383836ffbaf46e9f8beb27327a8a484a2e85c1d Mon Sep 17 00:00:00 2001 From: NAnand-TUD Date: Thu, 27 Oct 2022 16:22:10 +0200 Subject: [PATCH 12/36] complying with the PR suggestions --- 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 fe2ad8512ed..c77c94a3157 100644 --- a/Common/include/option_structure.hpp +++ b/Common/include/option_structure.hpp @@ -1778,7 +1778,7 @@ enum ENUM_OBJECTIVE { TOPOL_DISCRETENESS = 63, /*!< \brief Measure of the discreteness of the current topology. */ TOPOL_COMPLIANCE = 64, /*!< \brief Measure of the discreteness of the current topology. */ STRESS_PENALTY = 65, /*!< \brief Penalty function of VM stresses above a maximum value. */ - STREAMWISE_PERIODIC_LAMBDAL= 71, + STREAMWISE_PERIODIC_LAMBDAL= 71, /*!< /brief temp. expo. coefficient for iso-thermal BCs Streamwise Periodic. */ }; static const MapType Objective_Map = { MakePair("DRAG", DRAG_COEFFICIENT) From 5651b3de507896718c124f1574d6faec83541800 Mon Sep 17 00:00:00 2001 From: NAnand-TUD Date: Thu, 27 Oct 2022 18:35:06 +0200 Subject: [PATCH 13/36] Build failing due to errors. This should pass hopefully 1 --- SU2_CFD/include/solvers/CFVMFlowSolverBase.inl | 3 ++- SU2_CFD/src/solvers/CIncNSSolver.cpp | 1 - 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl b/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl index 618acc625f9..3b0ccdfb865 100644 --- a/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl +++ b/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl @@ -2981,7 +2981,8 @@ su2double CFVMFlowSolverBase::EvaluateCommonObjFunc(const CConfig& config) objFun += weight * config.GetSurface_Species_Variance(0); break; case STREAMWISE_PERIODIC_LAMBDAL: - objFun += weight * config.GetStreamwise_Periodic_LamdaL(); + objFun += weight * config.GetStreamwise_Periodic_LamdaL(); + break; case CUSTOM_OBJFUNC: objFun += weight * Total_Custom_ObjFunc; break; diff --git a/SU2_CFD/src/solvers/CIncNSSolver.cpp b/SU2_CFD/src/solvers/CIncNSSolver.cpp index cf9bbc2be3f..8faf0703367 100644 --- a/SU2_CFD/src/solvers/CIncNSSolver.cpp +++ b/SU2_CFD/src/solvers/CIncNSSolver.cpp @@ -205,7 +205,6 @@ void CIncNSSolver::GetStreamwise_Periodic_Properties(const CGeometry *geometry, su2double Volume_Local = 0.0, Volume_Global = 0.0; su2double Volume_VTemp_Local = 0.0, Volume_VTemp_Global = 0.0; su2double turb_b1_coeff_Local = 0.0, turb_b1_coeff_Global = 0.0; - su2double turb_b2_coeff_Local = 0.0, turb_b2_coeff_Global = 0.0; /*--- Loop over all heatflux Markers ---*/ for (auto iMarker = 0; iMarker < config->GetnMarker_All(); iMarker++) { From f0a817c47a5e4455136c4bef657f851f33412041 Mon Sep 17 00:00:00 2001 From: NAnand-TUD Date: Thu, 27 Oct 2022 20:05:23 +0200 Subject: [PATCH 14/36] Build failing due to errors. This should pass hopefully 2 --- SU2_CFD/src/numerics/flow/flow_sources.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/SU2_CFD/src/numerics/flow/flow_sources.cpp b/SU2_CFD/src/numerics/flow/flow_sources.cpp index 07e08e8ce89..ecff60269c9 100644 --- a/SU2_CFD/src/numerics/flow/flow_sources.cpp +++ b/SU2_CFD/src/numerics/flow/flow_sources.cpp @@ -762,11 +762,12 @@ CNumerics::ResidualType<> CSourceIncStreamwise_Periodic::ComputeResidual(const C scalar_factor = SPvals.Streamwise_Periodic_IntegratedHeatFlow / (SPvals.Streamwise_Periodic_MassFlow * sqrt(norm2_translation) * Prandtl_Turb); } - if (bool_isotherml_bc) + if (bool_isotherml_bc) { scalar_factor = (-V_i[3] * SPvals.Streamwise_Periodic_LambdaL) * config->GetSpecific_Heat_Cp() / Prandtl_Turb; - - /*--- Compute scalar product between periodic translation vector and eddy viscosity gradient. ---*/ - dot_product = GeometryToolbox::DotProduct(nDim, Streamwise_Coord_Vector, AuxVar_Grad_i[0]); + } + + /*--- Compute scalar product between periodic translation vector and eddy viscosity gradient. ---*/ + dot_product = GeometryToolbox::DotProduct(nDim, Streamwise_Coord_Vector, AuxVar_Grad_i[0]); residual[nDim+1] -= Volume * scalar_factor * dot_product; } // if turbulent From 2f4888fdb54473f10203059b0415153075534f2b Mon Sep 17 00:00:00 2001 From: NAnand-TUD Date: Fri, 28 Oct 2022 20:28:05 +0200 Subject: [PATCH 15/36] Build failing due to errors. This should pass hopefully 3, unit test was failing, this should fix it. --- SU2_CFD/src/output/CFlowOutput.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SU2_CFD/src/output/CFlowOutput.cpp b/SU2_CFD/src/output/CFlowOutput.cpp index 8911f2e75cc..7b8fb2e2be9 100644 --- a/SU2_CFD/src/output/CFlowOutput.cpp +++ b/SU2_CFD/src/output/CFlowOutput.cpp @@ -451,7 +451,7 @@ void CFlowOutput::SetAnalyzeSurface(const CSolver* const*solver, const CGeometry Tot_Surface_Temperature += Temperature; config->SetSurface_Temperature(iMarker_Analyze, Temperature); - su2double Pressure = Surface_Pressure[iMarker_Analyze] * config->GetPressure_Ref(); + su2double Pressure = Surface_Pressure_Total[iMarker_Analyze] * config->GetPressure_Ref(); SetHistoryOutputPerSurfaceValue("SURFACE_STATIC_PRESSURE", Pressure, iMarker_Analyze); Tot_Surface_Pressure += Pressure; config->SetSurface_Pressure(iMarker_Analyze, Pressure); From 19e3f419482926817977818ffd6174f0b33b4adc Mon Sep 17 00:00:00 2001 From: NAnand-TUD Date: Wed, 9 Nov 2022 09:54:37 +0100 Subject: [PATCH 16/36] complying with the PR suggestions, Pedro comments. --- Common/include/CConfig.hpp | 4 +-- SU2_CFD/src/output/CFlowIncOutput.cpp | 8 +++--- SU2_CFD/src/solvers/CIncNSSolver.cpp | 38 +++++++++++++-------------- 3 files changed, 25 insertions(+), 25 deletions(-) diff --git a/Common/include/CConfig.hpp b/Common/include/CConfig.hpp index 951fbba6fc5..379cc708069 100644 --- a/Common/include/CConfig.hpp +++ b/Common/include/CConfig.hpp @@ -9646,8 +9646,8 @@ class CConfig { void SetStreamwise_Periodic_LamdaL(su2double value) { Streamwise_Periodic_LambdaL = value; } /*! - * \brief Set Lambda L for Streamwise Periodic - * \return bool + * \brief Get Lambda L for Streamwise Periodic + * \return su2double */ su2double GetStreamwise_Periodic_LamdaL(void) const { return Streamwise_Periodic_LambdaL; } diff --git a/SU2_CFD/src/output/CFlowIncOutput.cpp b/SU2_CFD/src/output/CFlowIncOutput.cpp index 40e203b4f90..797ab84e89f 100644 --- a/SU2_CFD/src/output/CFlowIncOutput.cpp +++ b/SU2_CFD/src/output/CFlowIncOutput.cpp @@ -178,8 +178,8 @@ void CFlowIncOutput::SetHistoryOutputFields(CConfig *config){ AddHistoryOutput("STREAMWISE_MASSFLOW", "SWMassflow", ScreenOutputFormat::FIXED, "STREAMWISE_PERIODIC", "Massflow in streamwise periodic flow"); AddHistoryOutput("STREAMWISE_DP", "SWDeltaP", ScreenOutputFormat::FIXED, "STREAMWISE_PERIODIC", "Pressure drop in streamwise periodic flow"); AddHistoryOutput("STREAMWISE_HEAT", "SWHeat", ScreenOutputFormat::FIXED, "STREAMWISE_PERIODIC", "Integrated heat for streamwise periodic flow"); - if(config->GetnMarker_Isothermal() > 0) - AddHistoryOutput("STREAMWISE_LAMBDAL", "SWLambdaL", ScreenOutputFormat::FIXED, "STREAMWISE_PERIODIC", "Exponential factor for iso-thermal temperature gradient"); + if (config->GetnMarker_Isothermal() > 0) + AddHistoryOutput("STREAMWISE_LAMBDAL", "SWLambdaL", ScreenOutputFormat::FIXED, "STREAMWISE_PERIODIC", "Exponential factor for iso-thermal temperature gradient"); } AddAnalyzeSurfaceOutput(config); @@ -260,11 +260,11 @@ void CFlowIncOutput::LoadHistoryData(CConfig *config, CGeometry *geometry, CSolv LoadHistoryData_Scalar(config, solver); - if(streamwisePeriodic) { + if (streamwisePeriodic) { SetHistoryOutputValue("STREAMWISE_MASSFLOW", flow_solver->GetStreamwisePeriodicValues().Streamwise_Periodic_MassFlow); SetHistoryOutputValue("STREAMWISE_DP", flow_solver->GetStreamwisePeriodicValues().Streamwise_Periodic_PressureDrop); SetHistoryOutputValue("STREAMWISE_HEAT", flow_solver->GetStreamwisePeriodicValues().Streamwise_Periodic_IntegratedHeatFlow); - if(config->GetnMarker_Isothermal() > 0) + if (config->GetnMarker_Isothermal() > 0) SetHistoryOutputValue("STREAMWISE_LAMBDAL", flow_solver->GetStreamwisePeriodicValues().Streamwise_Periodic_LambdaL); } diff --git a/SU2_CFD/src/solvers/CIncNSSolver.cpp b/SU2_CFD/src/solvers/CIncNSSolver.cpp index a2a7ce412f4..14bfe4a5230 100644 --- a/SU2_CFD/src/solvers/CIncNSSolver.cpp +++ b/SU2_CFD/src/solvers/CIncNSSolver.cpp @@ -120,7 +120,7 @@ void CIncNSSolver::Preprocessing(CGeometry *geometry, CSolver **solver_container void CIncNSSolver::GetStreamwise_Periodic_Properties(const CGeometry *geometry, CConfig *config, const unsigned short iMesh) { - bool turbulent = (config->GetKind_Turb_Model() != TURB_MODEL::NONE); + const bool turbulent = (config->GetKind_Turb_Model() != TURB_MODEL::NONE); /*---------------------------------------------------------------------------------------------*/ // 1. Evaluate massflow, area avg density & Temperature and Area at streamwise periodic outlet. // 2. Update delta_p is target massflow is chosen. @@ -200,11 +200,6 @@ void CIncNSSolver::GetStreamwise_Periodic_Properties(const CGeometry *geometry, su2double HeatFlow_Local = 0.0, HeatFlow_Global = 0.0; su2double dTdn_Local = 0.0, dTdn_Global = 0.0; - su2double Volume_Temp_Local = 0.0, Volume_Temp_Global = 0.0; - su2double Volume_TempS_Local = 0.0, Volume_TempS_Global = 0.0; - su2double Volume_Local = 0.0, Volume_Global = 0.0; - su2double Volume_VTemp_Local = 0.0, Volume_VTemp_Global = 0.0; - su2double turb_b1_coeff_Local = 0.0, turb_b1_coeff_Global = 0.0; /*--- Loop over all heatflux Markers ---*/ for (auto iMarker = 0; iMarker < config->GetnMarker_All(); iMarker++) { @@ -242,11 +237,12 @@ void CIncNSSolver::GetStreamwise_Periodic_Properties(const CGeometry *geometry, const auto AreaNormal = geometry->vertex[iMarker][iVertex]->GetNormal(); /*Compute wall heat flux (normal to the wall) based on computed temperature gradient*/ + CIncNSVariable::CIndices indices(nDim, 0); for(auto iDim=0; iDim < nDim; iDim++) { + + GradT[iDim] = nodes->GetGradient_Primitive(iPoint, indices.Temperature(), iDim); - GradT[iDim] = nodes->GetGradient_Primitive(iPoint, 3, iDim); - - dTdn_Local += GradT[iDim]*AreaNormal[iDim]*nodes->GetThermalConductivity(iPoint); + dTdn_Local += GeometryToolbox::DotProduct(nDim, GradT, AreaNormal) * nodes->GetThermalConductivity(iPoint); } // loop dim } // loop Vertices @@ -257,14 +253,18 @@ void CIncNSSolver::GetStreamwise_Periodic_Properties(const CGeometry *geometry, SU2_MPI::Allreduce(&HeatFlow_Local, &HeatFlow_Global, 1, MPI_DOUBLE, MPI_SUM, SU2_MPI::GetComm()); SU2_MPI::Allreduce(&dTdn_Local, &dTdn_Global, 1, MPI_DOUBLE, MPI_SUM, SU2_MPI::GetComm()); + su2double Volume_Temp_Local = 0.0, Volume_Temp_Global = 0.0; + su2double Volume_TempS_Local = 0.0, Volume_TempS_Global = 0.0; + su2double Volume_Local = 0.0, Volume_Global = 0.0; + su2double Volume_VTemp_Local = 0.0, Volume_VTemp_Global = 0.0; + su2double turb_b1_coeff_Local = 0.0, turb_b1_coeff_Global = 0.0; + /*--- Loop over all heatflux Markers ---*/ - for (unsigned long iPoint = 0; iPoint < geometry->GetnPoint(); iPoint++) { - - if (!geometry->nodes->GetDomain(iPoint)) continue; + for (unsigned long iPoint = 0; iPoint < geometry->GetnPointDomain(); iPoint++) { - su2double volume = geometry->nodes->GetVolume(iPoint); + const su2double volume = geometry->nodes->GetVolume(iPoint); - su2double Temp = nodes->GetTemperature(iPoint); + const su2double Temp = nodes->GetTemperature(iPoint); Volume_Local += volume; @@ -299,17 +299,17 @@ void CIncNSSolver::GetStreamwise_Periodic_Properties(const CGeometry *geometry, nodes->SetStreamwise_Periodic_RecoveredTemperature(iPoint, nodes->GetTemperature(iPoint)/SPvals.Streamwise_Periodic_ThetaScaling); /*--- Set the solver variable Lambda_L for iso-thermal BCs ---*/ - su2double b0_coeff = Volume_Temp_Global; - su2double b1_coeff = Volume_VTemp_Global * config->GetSpecific_Heat_Cp() + turb_b1_coeff_Global; - su2double b2_coeff = -dTdn_Global; + const su2double b0_coeff = Volume_Temp_Global; + const su2double b1_coeff = Volume_VTemp_Global * config->GetSpecific_Heat_Cp() + turb_b1_coeff_Global; + const su2double b2_coeff = -dTdn_Global; /*--- Find the value of Lambda L by solving the quadratic equation ---*/ - su2double pred_lambda = (- b1_coeff + sqrt(b1_coeff * b1_coeff - 4 * b0_coeff * b2_coeff))/(2 * b0_coeff); + const su2double pred_lambda = (- b1_coeff + sqrt(b1_coeff * b1_coeff - 4 * b0_coeff * b2_coeff))/(2 * b0_coeff); if (!config->GetDiscrete_Adjoint()) SPvals.Streamwise_Periodic_LambdaL -= 0.01 * (SPvals.Streamwise_Periodic_LambdaL - pred_lambda); else SPvals.Streamwise_Periodic_LambdaL = pred_lambda; - // cout<<"Lambda :: "<SetStreamwise_Periodic_LamdaL(SPvals.Streamwise_Periodic_LambdaL); } // if isothermal } // if energy From 757c6b28cd8076f10a7c02b730a8e41e6bebbe7b Mon Sep 17 00:00:00 2001 From: NAnand-TUD Date: Wed, 9 Nov 2022 15:49:43 +0100 Subject: [PATCH 17/36] Objective functions exclusive to Streamwise Periodic flow added --- Common/include/CConfig.hpp | 12 ++++++++++++ Common/include/option_structure.hpp | 4 ++++ SU2_CFD/include/solvers/CFVMFlowSolverBase.inl | 6 ++++++ SU2_CFD/src/solvers/CIncEulerSolver.cpp | 1 + 4 files changed, 23 insertions(+) diff --git a/Common/include/CConfig.hpp b/Common/include/CConfig.hpp index 379cc708069..a62409ff847 100644 --- a/Common/include/CConfig.hpp +++ b/Common/include/CConfig.hpp @@ -1042,6 +1042,7 @@ class CConfig { bool Streamwise_Periodic_Temperature; /*!< \brief Use real periodicity for Energy equation or otherwise outlet source term. */ su2double Streamwise_Periodic_PressureDrop; /*!< \brief Value of prescribed pressure drop [Pa] which results in an artificial body force vector. */ su2double Streamwise_Periodic_TargetMassFlow; /*!< \brief Value of prescribed massflow [kg/s] which results in an delta p and therefore an artificial body force vector. */ + su2double Streamwise_Periodic_ComputedMassFlow; /*!< \brief Value of computed massflow [kg/s] corresponding to a prescribed delta p. */ su2double Streamwise_Periodic_OutletHeat; /*!< /brief Heatflux boundary [W/m^2] imposed at streamwise periodic outlet. */ su2double Streamwise_Periodic_LambdaL; /*!< /brief Exp coefficient for iso-thermal BCs Streamwise Periodic. */ @@ -5988,6 +5989,17 @@ class CConfig { */ void SetStreamwise_Periodic_PressureDrop(su2double Streamwise_Periodic_PressureDrop_) { Streamwise_Periodic_PressureDrop = Streamwise_Periodic_PressureDrop_; } + /*! + * \brief Get the value of the MassFlow from which body force vector is computed. + * \return MassFlow for body force computation. + */ + su2double GetStreamwise_Periodic_ComputedMassFlow(void) const { return Streamwise_Periodic_ComputedMassFlow; } + + /*! + * \brief Set the value of the MassFlow from which body force vector is computed. Necessary for Restart metadata?? + */ + void SetStreamwise_Periodic_ComputedMassFlow(su2double Streamwise_Periodic_MassFlow_) { Streamwise_Periodic_ComputedMassFlow = Streamwise_Periodic_MassFlow_; } + /*! * \brief Get the value of the massflow from which body force vector is computed. * \return Massflow for body force computation. diff --git a/Common/include/option_structure.hpp b/Common/include/option_structure.hpp index c77c94a3157..6ec41b7e251 100644 --- a/Common/include/option_structure.hpp +++ b/Common/include/option_structure.hpp @@ -1779,6 +1779,8 @@ enum ENUM_OBJECTIVE { TOPOL_COMPLIANCE = 64, /*!< \brief Measure of the discreteness of the current topology. */ STRESS_PENALTY = 65, /*!< \brief Penalty function of VM stresses above a maximum value. */ STREAMWISE_PERIODIC_LAMBDAL= 71, /*!< /brief temp. expo. coefficient for iso-thermal BCs Streamwise Periodic. */ + STREAMWISE_PERIODIC_DP= 72, /*!< /brief pressure drop in Streamwise Periodic flow domain. */ + STREAMWISE_PERIODIC_MASSFLOW= 73, /*!< /brief massflow rate in Streamwise Periodic flow domain. */ }; static const MapType Objective_Map = { MakePair("DRAG", DRAG_COEFFICIENT) @@ -1815,6 +1817,8 @@ static const MapType Objective_Map = { MakePair("SURFACE_SPECIES_0", SURFACE_SPECIES_0) MakePair("SURFACE_SPECIES_VARIANCE", SURFACE_SPECIES_VARIANCE) MakePair("STREAMWISE_PERIODIC_LAMBDAL", STREAMWISE_PERIODIC_LAMBDAL) + MakePair("STREAMWISE_PERIODIC_DP", STREAMWISE_PERIODIC_DP) + MakePair("STREAMWISE_PERIODIC_MASSFLOW", STREAMWISE_PERIODIC_MASSFLOW) MakePair("CUSTOM_OBJFUNC", CUSTOM_OBJFUNC) MakePair("FLOW_ANGLE_OUT", FLOW_ANGLE_OUT) MakePair("MASS_FLOW_IN", MASS_FLOW_IN) diff --git a/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl b/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl index a8c8bbdd374..bf11b44c5ab 100644 --- a/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl +++ b/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl @@ -3003,6 +3003,12 @@ su2double CFVMFlowSolverBase::EvaluateCommonObjFunc(const CConfig& config) case STREAMWISE_PERIODIC_LAMBDAL: objFun += weight * config.GetStreamwise_Periodic_LamdaL(); break; + case STREAMWISE_PERIODIC_DP: + objFun += weight * config.GetStreamwise_Periodic_PressureDrop(); + break; + case STREAMWISE_PERIODIC_MASSFLOW: + objFun += weight * config.GetStreamwise_Periodic_ComputedMassFlow(); + break; case CUSTOM_OBJFUNC: objFun += weight * Total_Custom_ObjFunc; break; diff --git a/SU2_CFD/src/solvers/CIncEulerSolver.cpp b/SU2_CFD/src/solvers/CIncEulerSolver.cpp index 3a181d77ff1..6b4932503c8 100644 --- a/SU2_CFD/src/solvers/CIncEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CIncEulerSolver.cpp @@ -1622,6 +1622,7 @@ void CIncEulerSolver::Source_Residual(CGeometry *geometry, CSolver **solver_cont } else { numerics->SetStreamwisePeriodicValues(SPvals); + config->SetStreamwise_Periodic_ComputedMassFlow(SPvals.Streamwise_Periodic_MassFlow); } AD::StartNoSharedReading(); From 8ef2141a9c99a45687a25f37df86869799f3e80e Mon Sep 17 00:00:00 2001 From: Nitish Anand Date: Thu, 10 Nov 2022 19:22:25 +0100 Subject: [PATCH 18/36] Update SU2_CFD/src/solvers/CIncNSSolver.cpp Co-authored-by: Pedro Gomes <38071223+pcarruscag@users.noreply.github.com> --- SU2_CFD/src/solvers/CIncNSSolver.cpp | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/SU2_CFD/src/solvers/CIncNSSolver.cpp b/SU2_CFD/src/solvers/CIncNSSolver.cpp index 14bfe4a5230..666486e3d85 100644 --- a/SU2_CFD/src/solvers/CIncNSSolver.cpp +++ b/SU2_CFD/src/solvers/CIncNSSolver.cpp @@ -235,15 +235,9 @@ void CIncNSSolver::GetStreamwise_Periodic_Properties(const CGeometry *geometry, if (!geometry->nodes->GetDomain(iPoint)) continue; const auto AreaNormal = geometry->vertex[iMarker][iVertex]->GetNormal(); - - /*Compute wall heat flux (normal to the wall) based on computed temperature gradient*/ - CIncNSVariable::CIndices indices(nDim, 0); - for(auto iDim=0; iDim < nDim; iDim++) { - - GradT[iDim] = nodes->GetGradient_Primitive(iPoint, indices.Temperature(), iDim); - - dTdn_Local += GeometryToolbox::DotProduct(nDim, GradT, AreaNormal) * nodes->GetThermalConductivity(iPoint); - + /*--- Compute wall heat flux (normal to the wall) based on computed temperature gradient ---*/ + const auto GradT = nodes->GetGradient_Primitive(iPoint, prim_idx.Temperature()); + dTdn_Local += nodes->GetThermalConductivity(iPoint) * GeometryToolbox::DotProduct(nDim, GradT, AreaNormal); } // loop dim } // loop Vertices } // loop Isothermal Marker From 02f61e5c7accb90d0c6c3f979bc855e139633ca2 Mon Sep 17 00:00:00 2001 From: Nitish Anand Date: Thu, 10 Nov 2022 19:22:50 +0100 Subject: [PATCH 19/36] Update SU2_CFD/src/solvers/CIncNSSolver.cpp Co-authored-by: Pedro Gomes <38071223+pcarruscag@users.noreply.github.com> --- SU2_CFD/src/solvers/CIncNSSolver.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SU2_CFD/src/solvers/CIncNSSolver.cpp b/SU2_CFD/src/solvers/CIncNSSolver.cpp index 666486e3d85..6a422ebd3c9 100644 --- a/SU2_CFD/src/solvers/CIncNSSolver.cpp +++ b/SU2_CFD/src/solvers/CIncNSSolver.cpp @@ -230,7 +230,7 @@ void CIncNSSolver::GetStreamwise_Periodic_Properties(const CGeometry *geometry, for (auto iVertex = 0ul; iVertex < geometry->nVertex[iMarker]; iVertex++) { - auto iPoint = geometry->vertex[iMarker][iVertex]->GetNode(); + const auto iPoint = geometry->vertex[iMarker][iVertex]->GetNode(); if (!geometry->nodes->GetDomain(iPoint)) continue; From c931b98f9811547aade26317c24156da9ceadf55 Mon Sep 17 00:00:00 2001 From: Nitish Anand Date: Thu, 10 Nov 2022 19:23:32 +0100 Subject: [PATCH 20/36] Update SU2_CFD/src/output/CFlowIncOutput.cpp Co-authored-by: Pedro Gomes <38071223+pcarruscag@users.noreply.github.com> --- SU2_CFD/src/output/CFlowIncOutput.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SU2_CFD/src/output/CFlowIncOutput.cpp b/SU2_CFD/src/output/CFlowIncOutput.cpp index 797ab84e89f..2e79eee235a 100644 --- a/SU2_CFD/src/output/CFlowIncOutput.cpp +++ b/SU2_CFD/src/output/CFlowIncOutput.cpp @@ -265,7 +265,7 @@ void CFlowIncOutput::LoadHistoryData(CConfig *config, CGeometry *geometry, CSolv SetHistoryOutputValue("STREAMWISE_DP", flow_solver->GetStreamwisePeriodicValues().Streamwise_Periodic_PressureDrop); SetHistoryOutputValue("STREAMWISE_HEAT", flow_solver->GetStreamwisePeriodicValues().Streamwise_Periodic_IntegratedHeatFlow); if (config->GetnMarker_Isothermal() > 0) - SetHistoryOutputValue("STREAMWISE_LAMBDAL", flow_solver->GetStreamwisePeriodicValues().Streamwise_Periodic_LambdaL); + SetHistoryOutputValue("STREAMWISE_LAMBDAL", flow_solver->GetStreamwisePeriodicValues().Streamwise_Periodic_LambdaL); } /*--- Set the analyse surface history values --- */ From 03fe2ad5b897503fcfad2eadeea08ed3662a2feb Mon Sep 17 00:00:00 2001 From: Nitish Anand Date: Thu, 10 Nov 2022 19:23:51 +0100 Subject: [PATCH 21/36] Update SU2_CFD/src/output/CFlowIncOutput.cpp Co-authored-by: Pedro Gomes <38071223+pcarruscag@users.noreply.github.com> --- SU2_CFD/src/output/CFlowIncOutput.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SU2_CFD/src/output/CFlowIncOutput.cpp b/SU2_CFD/src/output/CFlowIncOutput.cpp index 2e79eee235a..ed798a93d43 100644 --- a/SU2_CFD/src/output/CFlowIncOutput.cpp +++ b/SU2_CFD/src/output/CFlowIncOutput.cpp @@ -179,7 +179,7 @@ void CFlowIncOutput::SetHistoryOutputFields(CConfig *config){ AddHistoryOutput("STREAMWISE_DP", "SWDeltaP", ScreenOutputFormat::FIXED, "STREAMWISE_PERIODIC", "Pressure drop in streamwise periodic flow"); AddHistoryOutput("STREAMWISE_HEAT", "SWHeat", ScreenOutputFormat::FIXED, "STREAMWISE_PERIODIC", "Integrated heat for streamwise periodic flow"); if (config->GetnMarker_Isothermal() > 0) - AddHistoryOutput("STREAMWISE_LAMBDAL", "SWLambdaL", ScreenOutputFormat::FIXED, "STREAMWISE_PERIODIC", "Exponential factor for iso-thermal temperature gradient"); + AddHistoryOutput("STREAMWISE_LAMBDAL", "SWLambdaL", ScreenOutputFormat::FIXED, "STREAMWISE_PERIODIC", "Exponential factor for iso-thermal temperature gradient"); } AddAnalyzeSurfaceOutput(config); From 78b0ab069c22807cea647c2d728bccdf3fbe7810 Mon Sep 17 00:00:00 2001 From: NAnand-TUD Date: Thu, 10 Nov 2022 20:55:50 +0100 Subject: [PATCH 22/36] V_i suggestion and CConfig fixed --- Common/src/CConfig.cpp | 4 ++-- SU2_CFD/src/numerics/flow/flow_sources.cpp | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Common/src/CConfig.cpp b/Common/src/CConfig.cpp index 86a01dd8584..5d03a81d73c 100644 --- a/Common/src/CConfig.cpp +++ b/Common/src/CConfig.cpp @@ -4962,8 +4962,8 @@ void CConfig::SetPostprocessing(SU2_COMPONENT val_software, unsigned short val_i SU2_MPI::Error("Streamwise Periodic Flow + Incompressible Euler: Not tested yet.", CURRENT_FUNCTION); if (nMarker_PerBound == 0) SU2_MPI::Error("A MARKER_PERIODIC pair has to be set with KIND_STREAMWISE_PERIODIC != NONE.", CURRENT_FUNCTION); - // if (Energy_Equation && Streamwise_Periodic_Temperature && nMarker_Isothermal != 1) - // SU2_MPI::Error("No MARKER_ISOTHERMAL marker allowed with STREAMWISE_PERIODIC_TEMPERATURE= YES, only MARKER_HEATFLUX & MARKER_SYM.", CURRENT_FUNCTION); + if (Energy_Equation && Streamwise_Periodic_Temperature && nMarker_Isothermal > 0 && nMarker_HeatFlux > 0) + SU2_MPI::Error("MARKER_ISOTHERMAL and MARKER_HEATFLUX are not allowed simultaneously with STREAMWISE_PERIODIC_TEMPERATURE= YES, only one of these is allowed MARKER_ISOTHERMAL, MARKER_HEATFLUX in a fluid zone.", CURRENT_FUNCTION); if (Ref_Inc_NonDim != DIMENSIONAL) SU2_MPI::Error("Streamwise Periodicity only works with \"INC_NONDIM= DIMENSIONAL\", the nondimensionalization with source terms doesn;t work in general.", CURRENT_FUNCTION); if (Axisymmetric) diff --git a/SU2_CFD/src/numerics/flow/flow_sources.cpp b/SU2_CFD/src/numerics/flow/flow_sources.cpp index ecff60269c9..d95dbbbd5fb 100644 --- a/SU2_CFD/src/numerics/flow/flow_sources.cpp +++ b/SU2_CFD/src/numerics/flow/flow_sources.cpp @@ -746,9 +746,10 @@ CNumerics::ResidualType<> CSourceIncStreamwise_Periodic::ComputeResidual(const C // Reference Eq(20) Stalio et. al, doi:10.1115/1.2717235 dot_product = GeometryToolbox::DotProduct(nDim, Streamwise_Coord_Vector, PrimVar_Grad_i[3]); + su2double u_i = V_i[1], temp_i = V_i[nDim + 1]; su2double term1 = 2 * Thermal_Conductivity_i * dot_product; - su2double term2 = - SPvals.Streamwise_Periodic_LambdaL * Thermal_Conductivity_i * V_i[3]; - su2double term3 = - V_i[3] * V_i[1] * DensityInc_i * config->GetSpecific_Heat_Cp(); + su2double term2 = - SPvals.Streamwise_Periodic_LambdaL * Thermal_Conductivity_i * temp_i; + su2double term3 = - temp_i * u_i * DensityInc_i * config->GetSpecific_Heat_Cp(); scalar_factor = SPvals.Streamwise_Periodic_LambdaL * (term1 + term2 + term3); dot_product = 1.0; } From 50360deddf5bb1b8c849723c624306cb5959aae0 Mon Sep 17 00:00:00 2001 From: NAnand-TUD Date: Thu, 10 Nov 2022 22:58:15 +0100 Subject: [PATCH 23/36] fixed error with DotProduct --- SU2_CFD/src/solvers/CIncNSSolver.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/SU2_CFD/src/solvers/CIncNSSolver.cpp b/SU2_CFD/src/solvers/CIncNSSolver.cpp index 6a422ebd3c9..cc498de37bc 100644 --- a/SU2_CFD/src/solvers/CIncNSSolver.cpp +++ b/SU2_CFD/src/solvers/CIncNSSolver.cpp @@ -191,6 +191,9 @@ void CIncNSSolver::GetStreamwise_Periodic_Properties(const CGeometry *geometry, SPvals.Streamwise_Periodic_BoundaryArea = Area_Global; SPvals.Streamwise_Periodic_AvgDensity = Average_Density_Global; + su2double HeatFlow_Local = 0.0, HeatFlow_Global = 0.0; + su2double dTdn_Local = 0.0, dTdn_Global = 0.0; + if (config->GetEnergy_Equation()) { /*---------------------------------------------------------------------------------------------*/ /*--- 3. Compute the integrated Heatflow [W] for the energy equation source term, heatflux ---*/ @@ -198,9 +201,6 @@ void CIncNSSolver::GetStreamwise_Periodic_Properties(const CGeometry *geometry, /*--- Here the Heatflux from all Boundary markers in the config-file is used. ---*/ /*---------------------------------------------------------------------------------------------*/ - su2double HeatFlow_Local = 0.0, HeatFlow_Global = 0.0; - su2double dTdn_Local = 0.0, dTdn_Global = 0.0; - /*--- Loop over all heatflux Markers ---*/ for (auto iMarker = 0; iMarker < config->GetnMarker_All(); iMarker++) { @@ -226,19 +226,21 @@ void CIncNSSolver::GetStreamwise_Periodic_Properties(const CGeometry *geometry, if (config->GetMarker_All_KindBC(iMarker) == ISOTHERMAL) { /*--- Identify the boundary by string name and retrive ISOTHERMAL from config ---*/ - su2double GradT[3] = {0.0,0.0,0.0}; - + for (auto iVertex = 0ul; iVertex < geometry->nVertex[iMarker]; iVertex++) { const auto iPoint = geometry->vertex[iMarker][iVertex]->GetNode(); if (!geometry->nodes->GetDomain(iPoint)) continue; - const auto AreaNormal = geometry->vertex[iMarker][iVertex]->GetNormal(); /*--- Compute wall heat flux (normal to the wall) based on computed temperature gradient ---*/ - const auto GradT = nodes->GetGradient_Primitive(iPoint, prim_idx.Temperature()); + const auto AreaNormal = geometry->vertex[iMarker][iVertex]->GetNormal(); + + su2double GradT[MAXNDIM] = {0.0,0.0,0.0}; + for (auto iDim = 0u; iDim < nDim; iDim++) + GradT[iDim] = nodes->GetGradient_Primitive(iPoint, prim_idx.Temperature(), iDim); + dTdn_Local += nodes->GetThermalConductivity(iPoint) * GeometryToolbox::DotProduct(nDim, GradT, AreaNormal); - } // loop dim } // loop Vertices } // loop Isothermal Marker } // loop AllMarker From d67666bee565045974e8246f770ad24d93eb85e9 Mon Sep 17 00:00:00 2001 From: NAnand-TUD Date: Thu, 10 Nov 2022 22:59:35 +0100 Subject: [PATCH 24/36] Submodule commits updated --- externals/codi | 2 +- externals/opdi | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/externals/codi b/externals/codi index 3c3211fef2e..96ac78ec5bc 160000 --- a/externals/codi +++ b/externals/codi @@ -1 +1 @@ -Subproject commit 3c3211fef2e225ab89680a4063b62bb3bb38a7e4 +Subproject commit 96ac78ec5bcc5ac25b785e79b16ed76fca22d736 diff --git a/externals/opdi b/externals/opdi index 6fb2691b8e4..1aabf5bd1ed 160000 --- a/externals/opdi +++ b/externals/opdi @@ -1 +1 @@ -Subproject commit 6fb2691b8e4a8f00f47d2a27740fa890df0b5405 +Subproject commit 1aabf5bd1ed77611742eb655002f2ac7a3dddef9 From 99e39e876058be30942587ca5bbd0340ce1af968 Mon Sep 17 00:00:00 2001 From: Nitish Annad Date: Fri, 11 Nov 2022 11:04:39 +0100 Subject: [PATCH 25/36] CConfig error tested and CIncNSSolver implemented --- SU2_CFD/src/solvers/CIncNSSolver.cpp | 4 +--- externals/codi | 2 +- externals/opdi | 2 +- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/SU2_CFD/src/solvers/CIncNSSolver.cpp b/SU2_CFD/src/solvers/CIncNSSolver.cpp index cc498de37bc..0269232b224 100644 --- a/SU2_CFD/src/solvers/CIncNSSolver.cpp +++ b/SU2_CFD/src/solvers/CIncNSSolver.cpp @@ -236,9 +236,7 @@ void CIncNSSolver::GetStreamwise_Periodic_Properties(const CGeometry *geometry, /*--- Compute wall heat flux (normal to the wall) based on computed temperature gradient ---*/ const auto AreaNormal = geometry->vertex[iMarker][iVertex]->GetNormal(); - su2double GradT[MAXNDIM] = {0.0,0.0,0.0}; - for (auto iDim = 0u; iDim < nDim; iDim++) - GradT[iDim] = nodes->GetGradient_Primitive(iPoint, prim_idx.Temperature(), iDim); + const auto GradT = nodes->GetGradient_Primitive(iPoint)[prim_idx.Temperature()]; dTdn_Local += nodes->GetThermalConductivity(iPoint) * GeometryToolbox::DotProduct(nDim, GradT, AreaNormal); } // loop Vertices diff --git a/externals/codi b/externals/codi index 96ac78ec5bc..3c3211fef2e 160000 --- a/externals/codi +++ b/externals/codi @@ -1 +1 @@ -Subproject commit 96ac78ec5bcc5ac25b785e79b16ed76fca22d736 +Subproject commit 3c3211fef2e225ab89680a4063b62bb3bb38a7e4 diff --git a/externals/opdi b/externals/opdi index 1aabf5bd1ed..6fb2691b8e4 160000 --- a/externals/opdi +++ b/externals/opdi @@ -1 +1 @@ -Subproject commit 1aabf5bd1ed77611742eb655002f2ac7a3dddef9 +Subproject commit 6fb2691b8e4a8f00f47d2a27740fa890df0b5405 From 8c5f3f464e4f30d0fb9c2819a6bc069253a1556c Mon Sep 17 00:00:00 2001 From: NAnand-TUD Date: Tue, 11 Jul 2023 12:23:01 +0200 Subject: [PATCH 26/36] Merged with develop, submodules updated --- externals/codi | 2 +- externals/opdi | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/externals/codi b/externals/codi index 3c3211fef2e..96ac78ec5bc 160000 --- a/externals/codi +++ b/externals/codi @@ -1 +1 @@ -Subproject commit 3c3211fef2e225ab89680a4063b62bb3bb38a7e4 +Subproject commit 96ac78ec5bcc5ac25b785e79b16ed76fca22d736 diff --git a/externals/opdi b/externals/opdi index 6fb2691b8e4..1aabf5bd1ed 160000 --- a/externals/opdi +++ b/externals/opdi @@ -1 +1 @@ -Subproject commit 6fb2691b8e4a8f00f47d2a27740fa890df0b5405 +Subproject commit 1aabf5bd1ed77611742eb655002f2ac7a3dddef9 From b1f7acb5eda51ccc92dffaeaff83ad472804f311 Mon Sep 17 00:00:00 2001 From: Nitish Anand Date: Wed, 9 Aug 2023 21:51:06 +0200 Subject: [PATCH 27/36] Changes to make z direction flow work --- Common/include/option_structure.hpp | 4 +- Common/src/CConfig.cpp | 4 +- .../src/grid_movement/CVolumetricMovement.cpp | 1 + SU2_CFD/include/interfaces/CInterface.hpp | 3 + .../cht/CConjugateHeatInterface.hpp | 3 + .../include/solvers/CFVMFlowSolverBase.inl | 2 +- SU2_CFD/include/solvers/CHeatSolver.hpp | 16 +++++ .../cht/CConjugateHeatInterface.cpp | 44 +++++++++++++ SU2_CFD/src/numerics/flow/flow_sources.cpp | 27 ++++++-- SU2_CFD/src/solvers/CHeatSolver.cpp | 63 ++++++++++++++++++- SU2_CFD/src/solvers/CIncNSSolver.cpp | 26 ++++---- 11 files changed, 171 insertions(+), 22 deletions(-) diff --git a/Common/include/option_structure.hpp b/Common/include/option_structure.hpp index 8e8a8da464f..359bad2c1ca 100644 --- a/Common/include/option_structure.hpp +++ b/Common/include/option_structure.hpp @@ -1879,7 +1879,7 @@ enum ENUM_OBJECTIVE { TOPOL_DISCRETENESS = 63, /*!< \brief Measure of the discreteness of the current topology. */ TOPOL_COMPLIANCE = 64, /*!< \brief Measure of the discreteness of the current topology. */ STRESS_PENALTY = 65, /*!< \brief Penalty function of VM stresses above a maximum value. */ - STREAMWISE_PERIODIC_LAMBDAL= 71, /*!< /brief temp. expo. coefficient for iso-thermal BCs Streamwise Periodic. */ + STREAMWISE_LAMBDAL= 71, /*!< /brief temp. expo. coefficient for iso-thermal BCs Streamwise Periodic. */ STREAMWISE_PERIODIC_DP= 72, /*!< /brief pressure drop in Streamwise Periodic flow domain. */ STREAMWISE_PERIODIC_MASSFLOW= 73, /*!< /brief massflow rate in Streamwise Periodic flow domain. */ }; @@ -1917,7 +1917,7 @@ static const MapType Objective_Map = { MakePair("SURFACE_PRESSURE_DROP", SURFACE_PRESSURE_DROP) MakePair("SURFACE_SPECIES_0", SURFACE_SPECIES_0) MakePair("SURFACE_SPECIES_VARIANCE", SURFACE_SPECIES_VARIANCE) - MakePair("STREAMWISE_PERIODIC_LAMBDAL", STREAMWISE_PERIODIC_LAMBDAL) + MakePair("STREAMWISE_LAMBDAL", STREAMWISE_LAMBDAL) MakePair("STREAMWISE_PERIODIC_DP", STREAMWISE_PERIODIC_DP) MakePair("STREAMWISE_PERIODIC_MASSFLOW", STREAMWISE_PERIODIC_MASSFLOW) MakePair("CUSTOM_OBJFUNC", CUSTOM_OBJFUNC) diff --git a/Common/src/CConfig.cpp b/Common/src/CConfig.cpp index 16f3927218a..1e25848e559 100644 --- a/Common/src/CConfig.cpp +++ b/Common/src/CConfig.cpp @@ -5012,8 +5012,8 @@ void CConfig::SetPostprocessing(SU2_COMPONENT val_software, unsigned short val_i SU2_MPI::Error("Streamwise Periodic Flow + Incompressible Euler: Not tested yet.", CURRENT_FUNCTION); if (nMarker_PerBound == 0) SU2_MPI::Error("A MARKER_PERIODIC pair has to be set with KIND_STREAMWISE_PERIODIC != NONE.", CURRENT_FUNCTION); - if (Energy_Equation && Streamwise_Periodic_Temperature && nMarker_Isothermal > 0 && nMarker_HeatFlux > 0) - SU2_MPI::Error("MARKER_ISOTHERMAL and MARKER_HEATFLUX are not allowed simultaneously with STREAMWISE_PERIODIC_TEMPERATURE= YES, only one of these is allowed MARKER_ISOTHERMAL, MARKER_HEATFLUX in a fluid zone.", CURRENT_FUNCTION); + // if (Energy_Equation && Streamwise_Periodic_Temperature && nMarker_Isothermal > 0 && nMarker_HeatFlux > 0) + // SU2_MPI::Error("MARKER_ISOTHERMAL and MARKER_HEATFLUX are not allowed simultaneously with STREAMWISE_PERIODIC_TEMPERATURE= YES, only one of these is allowed MARKER_ISOTHERMAL, MARKER_HEATFLUX in a fluid zone.", CURRENT_FUNCTION); if (Ref_Inc_NonDim != DIMENSIONAL) SU2_MPI::Error("Streamwise Periodicity only works with \"INC_NONDIM= DIMENSIONAL\", the nondimensionalization with source terms doesn;t work in general.", CURRENT_FUNCTION); if (Axisymmetric) diff --git a/Common/src/grid_movement/CVolumetricMovement.cpp b/Common/src/grid_movement/CVolumetricMovement.cpp index ef7e3d423af..acd18902a15 100644 --- a/Common/src/grid_movement/CVolumetricMovement.cpp +++ b/Common/src/grid_movement/CVolumetricMovement.cpp @@ -1621,6 +1621,7 @@ void CVolumetricMovement::SetBoundaryDisplacements(CGeometry *geometry, CConfig for (iMarker = 0; iMarker < config->GetnMarker_All(); iMarker++) { if ((config->GetMarker_All_KindBC(iMarker) == SYMMETRY_PLANE) ) { + // if ((config->GetMarker_All_Deform_Mesh_Sym_Plane(iMarker))) { su2double *Coord_0 = nullptr; diff --git a/SU2_CFD/include/interfaces/CInterface.hpp b/SU2_CFD/include/interfaces/CInterface.hpp index 49deb7dbe31..5dd25c6ed55 100644 --- a/SU2_CFD/include/interfaces/CInterface.hpp +++ b/SU2_CFD/include/interfaces/CInterface.hpp @@ -228,4 +228,7 @@ class CInterface { */ void GatherAverageTurboGeoValues(CGeometry *donor_geometry, CGeometry *target_geometry, unsigned short donorZone); + inline virtual void SetLambdaL(CSolver *target_solution, CGeometry *target_geometry, const CConfig *target_config, + unsigned long Marker_Target) {}; + }; diff --git a/SU2_CFD/include/interfaces/cht/CConjugateHeatInterface.hpp b/SU2_CFD/include/interfaces/cht/CConjugateHeatInterface.hpp index 9cc42f8d20f..0a8a68dbf4e 100644 --- a/SU2_CFD/include/interfaces/cht/CConjugateHeatInterface.hpp +++ b/SU2_CFD/include/interfaces/cht/CConjugateHeatInterface.hpp @@ -70,4 +70,7 @@ class CConjugateHeatInterface : public CInterface { */ void SetTarget_Variable(CSolver *target_solution, CGeometry *target_geometry, const CConfig *target_config, unsigned long Marker_Target, unsigned long Vertex_Target, unsigned long Point_Target) override; + + void SetLambdaL(CSolver *target_solution, CGeometry *target_geometry, const CConfig *target_config, + unsigned long Marker_Target) override; }; diff --git a/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl b/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl index 3d911754633..c62aabd0900 100644 --- a/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl +++ b/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl @@ -2981,7 +2981,7 @@ su2double CFVMFlowSolverBase::EvaluateCommonObjFunc(const CConfig& config) case SURFACE_SPECIES_VARIANCE: objFun += weight * config.GetSurface_Species_Variance(0); break; - case STREAMWISE_PERIODIC_LAMBDAL: + case STREAMWISE_LAMBDAL: objFun += weight * config.GetStreamwise_Periodic_LamdaL(); break; case STREAMWISE_PERIODIC_DP: diff --git a/SU2_CFD/include/solvers/CHeatSolver.hpp b/SU2_CFD/include/solvers/CHeatSolver.hpp index 2074d479a6a..539f9a2dca2 100644 --- a/SU2_CFD/include/solvers/CHeatSolver.hpp +++ b/SU2_CFD/include/solvers/CHeatSolver.hpp @@ -318,6 +318,20 @@ class CHeatSolver final : public CScalarSolver { CSolver **solver_container, CConfig *config) override; +/*! + * \brief Compute the viscous residuals for the turbulent equation. + * \param[in] geometry - Geometrical definition of the problem. + * \param[in] solver_container - Container vector with all the solutions. + * \param[in] numerics_container - Description of the numerical method. + * \param[in] config - Definition of the particular problem. + * \param[in] iMesh - Index of the mesh in multigrid computations. + * \param[in] iRKStep - Current step of the Runge-Kutta iteration. + */ + void Source_Residual(CGeometry *geometry, + CSolver **solver_container, + CNumerics **numerics_container, + CConfig *config, + unsigned short iMesh) override; /*! * \brief Get value of the heat load (integrated heat flux). * \return Value of the heat load (integrated heat flux). @@ -402,4 +416,6 @@ class CHeatSolver final : public CScalarSolver { * \return Value of the heat flux. */ inline su2double GetHeatFlux(unsigned short val_marker, unsigned long val_vertex) const override { return HeatFlux[val_marker][val_vertex]; } + +// su2double GetLambdaL(CGeometry *geometry, CSolver **solver_container, CConfig *config); }; diff --git a/SU2_CFD/src/interfaces/cht/CConjugateHeatInterface.cpp b/SU2_CFD/src/interfaces/cht/CConjugateHeatInterface.cpp index 56fcea263e2..d3b48aaa6c8 100644 --- a/SU2_CFD/src/interfaces/cht/CConjugateHeatInterface.cpp +++ b/SU2_CFD/src/interfaces/cht/CConjugateHeatInterface.cpp @@ -169,3 +169,47 @@ void CConjugateHeatInterface::SetTarget_Variable(CSolver *target_solution, CGeom target_config->GetRelaxation_Factor_CHT(), Target_Variable[3]); } } + +void CConjugateHeatInterface::SetLambdaL(CSolver *target_solution, CGeometry *target_geometry, + const CConfig *target_config, unsigned long Marker_Target) { + unsigned short iPoint, iMarker, iVertex; + su2double term1=0.0, term2=0.0, term3=0.0; + auto nDim = target_geometry->GetnDim(); + + /*--- Loop over all heatflux Markers ---*/ + for (iMarker = 0; iMarker < target_config->GetnMarker_All(); iMarker++) { + + if (target_config->GetMarker_All_KindBC(iMarker) == CHT_WALL_INTERFACE) { + + /*--- Identify the boundary by string name and retrive heatflux from config ---*/ + const auto Marker_StringTag = target_config->GetMarker_All_TagBound(iMarker); + const su2double Wall_HeatFlux = target_config->GetWall_HeatFlux(Marker_StringTag); + + for (iVertex = 0ul; iVertex < target_geometry->nVertex[iMarker]; iVertex++) { + + auto iPoint = target_geometry->vertex[iMarker][iVertex]->GetNode(); + + if (!target_geometry->nodes->GetDomain(iPoint)) continue; + + const auto AreaNormal = target_geometry->vertex[iMarker][iVertex]->GetNormal(); + + const su2double FaceArea = GeometryToolbox::Norm(nDim, AreaNormal); + + // compute the constant + const auto GradT = target_solution->GetNodes()->GetGradient_Primitive(iPoint)[0]; //TODO: check index + + term1 += GeometryToolbox::DotProduct(nDim, GradT, AreaNormal); + + // compute coefficient of lambda + term2 += target_solution->GetNodes()->GetTemperature(iPoint) * FaceArea; + } + } // loop Vertices + } + + // compute coefficient of lambda^2 +for (iPoint = 0; iPoint<=target_geometry->GetnPointDomain(); iPoint++) { + term3 += target_solution->GetNodes()->GetTemperature(iPoint) * target_geometry->nodes->GetVolume(iPoint); +} + + // Compute LambdaL using the quadratic equation +} \ No newline at end of file diff --git a/SU2_CFD/src/numerics/flow/flow_sources.cpp b/SU2_CFD/src/numerics/flow/flow_sources.cpp index d669b0258fa..973a53d3395 100644 --- a/SU2_CFD/src/numerics/flow/flow_sources.cpp +++ b/SU2_CFD/src/numerics/flow/flow_sources.cpp @@ -818,6 +818,7 @@ CNumerics::ResidualType<> CSourceIncStreamwise_Periodic::ComputeResidual(const C /* Value of prescribed pressure drop which results in an artificial body force vector. */ const su2double delta_p = SPvals.Streamwise_Periodic_PressureDrop; + auto implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); for (unsigned short iVar = 0; iVar < nVar; iVar++) residual[iVar] = 0.0; @@ -844,8 +845,10 @@ CNumerics::ResidualType<> CSourceIncStreamwise_Periodic::ComputeResidual(const C /*--- Compute three terms associated with the source terms for iso-thermal BCs ---*/ // Reference Eq(20) Stalio et. al, doi:10.1115/1.2717235 - dot_product = GeometryToolbox::DotProduct(nDim, Streamwise_Coord_Vector, PrimVar_Grad_i[3]); - su2double u_i = V_i[1], temp_i = V_i[nDim + 1]; + // Displacement with temperature + dot_product = GeometryToolbox::DotProduct(nDim, Streamwise_Coord_Vector, PrimVar_Grad_i[nDim+1]); + + su2double u_i = V_i[3], temp_i = V_i[nDim+1]; su2double term1 = 2 * Thermal_Conductivity_i * dot_product; su2double term2 = - SPvals.Streamwise_Periodic_LambdaL * Thermal_Conductivity_i * temp_i; su2double term3 = - temp_i * u_i * DensityInc_i * config->GetSpecific_Heat_Cp(); @@ -855,6 +858,14 @@ CNumerics::ResidualType<> CSourceIncStreamwise_Periodic::ComputeResidual(const C residual[nDim+1] = Volume * scalar_factor * dot_product; + // if (implicit) { + + // /*--- Jacobian is set to zero on initialization. ---*/ + + // jacobian[nDim+1][nDim+1] = Volume * scalar_factor * dot_product; + + // } + /*--- If a RANS turbulence model is used, an additional source term, based on the eddy viscosity gradient is added. ---*/ if(turbulent) { if (bool_heat_flux_bc) { @@ -863,13 +874,21 @@ CNumerics::ResidualType<> CSourceIncStreamwise_Periodic::ComputeResidual(const C } if (bool_isotherml_bc) { - scalar_factor = (-V_i[3] * SPvals.Streamwise_Periodic_LambdaL) * config->GetSpecific_Heat_Cp() / Prandtl_Turb; + scalar_factor = (-V_i[nDim + 1] * SPvals.Streamwise_Periodic_LambdaL) * config->GetSpecific_Heat_Cp() / Prandtl_Turb; } /*--- Compute scalar product between periodic translation vector and eddy viscosity gradient. ---*/ dot_product = GeometryToolbox::DotProduct(nDim, Streamwise_Coord_Vector, AuxVar_Grad_i[0]); residual[nDim+1] -= Volume * scalar_factor * dot_product; + + // if (implicit) { + + // /*--- Jacobian is set to zero on initialization. ---*/ + + // jacobian[nDim+1][nDim+1] -= Volume * scalar_factor * dot_product; + + // } } // if turbulent } // if energy @@ -886,7 +905,7 @@ CNumerics::ResidualType<> CSourceIncStreamwisePeriodic_Outlet::ComputeResidual(c for (unsigned short iVar = 0; iVar < nVar; iVar++) residual[iVar] = 0.0; /*--- m_dot_local = rho * dot_prod(n_A*v), with n_A beeing the area-normal ---*/ - const su2double local_Massflow = DensityInc_i * GeometryToolbox::DotProduct(nDim, Normal, &V_i[1]); + const su2double local_Massflow = DensityInc_i * GeometryToolbox::DotProduct(nDim, Normal, &V_i[3]); // Massflow weighted heat sink, which takes out // a) the integrated amount over the Heatflux marker diff --git a/SU2_CFD/src/solvers/CHeatSolver.cpp b/SU2_CFD/src/solvers/CHeatSolver.cpp index a7a3b1e30d3..5f0f29adfcc 100644 --- a/SU2_CFD/src/solvers/CHeatSolver.cpp +++ b/SU2_CFD/src/solvers/CHeatSolver.cpp @@ -704,6 +704,42 @@ void CHeatSolver::Heat_Fluxes(CGeometry *geometry, CSolver **solver_container, C Total_HeatFlux = AllBound_HeatFlux; } +void CHeatSolver::Source_Residual(CGeometry *geometry, + CSolver **solver_container, + CNumerics **numerics_container, + CConfig *config, + unsigned short iMesh) { +auto HeatGen = 0.0; //config->GetSolid_Heat_Generation(); +auto streamwise_periodic = (config->GetKind_Streamwise_Periodic() != ENUM_STREAMWISE_PERIODIC::NONE); +unsigned long nPointDomain = geometry->GetnPointDomain(), iPoint; +unsigned short iVar; + +if (HeatGen != 0.0) { + /*--- loop over points ---*/ + SU2_OMP_FOR_STAT(omp_chunk_size) + for (iPoint = 0; iPoint < nPointDomain; iPoint++) { + + /*--- Get control volume ---*/ + su2double Volume = geometry->nodes->GetVolume(iPoint); + + /*--- Get volumetric heat generation term and add to residual ---*/ + for (iVar = 0; iVar < nVar; iVar++) { + LinSysRes(iPoint,iVar) -= Volume * HeatGen; + } + } + END_SU2_OMP_FOR + } +if (streamwise_periodic) { + su2double lambda_l = 0.0, term1= 0.0, term2=0.0, grad_T=0.0, Volume=0.0, T = 0.0; + term1 = lambda_l * 2 * grad_T; + term2 = lambda_l * lambda_l * T; + + for (iVar = 0; iVar < nVar; iVar++) { + LinSysRes(iPoint,iVar) -= Volume * (term1 - term2); + } + } +} + void CHeatSolver::SetTime_Step(CGeometry *geometry, CSolver **solver_container, CConfig *config, unsigned short iMesh, unsigned long Iteration) { @@ -729,7 +765,7 @@ void CHeatSolver::SetTime_Step(CGeometry *geometry, CSolver **solver_container, } END_SU2_OMP_SAFE_GLOBAL_ACCESS /*--- Loop domain points. ---*/ - + SU2_OMP_FOR_DYN(omp_chunk_size) for (auto iPoint = 0ul; iPoint < nPointDomain; ++iPoint) { @@ -1021,3 +1057,28 @@ void CHeatSolver::SetResidual_DualTime(CGeometry *geometry, CSolver **solver_con AD::EndNoSharedReading(); } +// su2double CHeatSolver::GetLambdaL(CGeometry *geometry, CSolver **solver_container, CConfig *config) { + + +// /*--- Loop over all heatflux Markers ---*/ +// for (unsigned long iPoint = 0; iPoint < geometry->GetnPointDomain(); iPoint++) { + +// const su2double volume = geometry->nodes->GetVolume(iPoint); + +// const su2double Temp = nodes->GetTemperature(iPoint); + +// Volume_Local += volume; + +// Volume_TempS_Local += volume * Temp; + +// Volume_Temp_Local += volume * Temp * nodes->GetThermalConductivity(iPoint); + +// // coeff_b1 for turbulence +// if (turbulent && (config->GetnMarker_Isothermal() != 0)) +// turb_b1_coeff_Local += Temp * nodes->GetAuxVarGradient(iPoint, 0, 0) * config->GetSpecific_Heat_Cp() * volume / config->GetPrandtl_Turb(); + +// Volume_VTemp_Local += volume * Temp * nodes->GetVelocity(iPoint, 2) * nodes->GetDensity(iPoint); + +// } // points + +// } \ No newline at end of file diff --git a/SU2_CFD/src/solvers/CIncNSSolver.cpp b/SU2_CFD/src/solvers/CIncNSSolver.cpp index 539d9073164..4176ceb2f54 100644 --- a/SU2_CFD/src/solvers/CIncNSSolver.cpp +++ b/SU2_CFD/src/solvers/CIncNSSolver.cpp @@ -267,10 +267,12 @@ void CIncNSSolver::GetStreamwise_Periodic_Properties(const CGeometry *geometry, Volume_Temp_Local += volume * Temp * nodes->GetThermalConductivity(iPoint); // coeff_b1 for turbulence - if (turbulent && (config->GetnMarker_Isothermal() != 0)) - turb_b1_coeff_Local += Temp * nodes->GetAuxVarGradient(iPoint, 0, 0) * config->GetSpecific_Heat_Cp() * volume / config->GetPrandtl_Turb(); + if (turbulent && (config->GetnMarker_Isothermal() != 0)) { + // su2doule dot_product = GeometryToolbox::DotProduct(nDim, Streamwise_Coord_Vector, nodes->GetAuxVarGradient(iPoint, 0)); + turb_b1_coeff_Local += Temp * nodes->GetAuxVarGradient(iPoint, 0, 2) * config->GetSpecific_Heat_Cp() * volume / config->GetPrandtl_Turb(); + } - Volume_VTemp_Local += volume * Temp * nodes->GetVelocity(iPoint, 0) * nodes->GetDensity(iPoint); + Volume_VTemp_Local += volume * Temp * nodes->GetVelocity(iPoint, 2) * nodes->GetDensity(iPoint) * config->GetSpecific_Heat_Cp(); } // points @@ -294,7 +296,7 @@ void CIncNSSolver::GetStreamwise_Periodic_Properties(const CGeometry *geometry, /*--- Set the solver variable Lambda_L for iso-thermal BCs ---*/ const su2double b0_coeff = Volume_Temp_Global; - const su2double b1_coeff = Volume_VTemp_Global * config->GetSpecific_Heat_Cp() + turb_b1_coeff_Global; + const su2double b1_coeff = Volume_VTemp_Global + turb_b1_coeff_Global; const su2double b2_coeff = -dTdn_Global; /*--- Find the value of Lambda L by solving the quadratic equation ---*/ @@ -337,12 +339,12 @@ void CIncNSSolver::Compute_Streamwise_Periodic_Recovered_Values(CConfig *config, nodes->SetStreamwise_Periodic_RecoveredPressure(iPoint, Pressure_Recovered); /*--- InnerIter > 0 as otherwise MassFlow in the denominator would be zero ---*/ - if (energy && InnerIter > 0) { - su2double Temperature_Recovered = nodes->GetTemperature(iPoint); - Temperature_Recovered += SPvals.Streamwise_Periodic_IntegratedHeatFlow / - (SPvals.Streamwise_Periodic_MassFlow * nodes->GetSpecificHeatCp(iPoint) * norm2_translation) * dot_product; - nodes->SetStreamwise_Periodic_RecoveredTemperature(iPoint, Temperature_Recovered); - } + // if (energy && InnerIter > 0) { + // su2double Temperature_Recovered = nodes->GetTemperature(iPoint); + // Temperature_Recovered += SPvals.Streamwise_Periodic_IntegratedHeatFlow / + // (SPvals.Streamwise_Periodic_MassFlow * nodes->GetSpecificHeatCp(iPoint) * norm2_translation) * dot_product; + // nodes->SetStreamwise_Periodic_RecoveredTemperature(iPoint, Temperature_Recovered); + // } } // for iPoint END_SU2_OMP_FOR @@ -559,8 +561,8 @@ void CIncNSSolver::BC_Wall_Generic(const CGeometry *geometry, const CConfig *con /*--- Apply a weak boundary condition for the energy equation. Compute the residual due to the prescribed heat flux. ---*/ - - LinSysRes(iPoint, nDim+1) -= thermal_conductivity*dTdn*Area; + // Test with relaxation factor with a factor of 0.5 + LinSysRes(iPoint, nDim+1) -= 0.5*thermal_conductivity*dTdn*Area; /*--- Jacobian contribution for temperature equation. ---*/ From 2f95ece169599f59419488b23eb390b1b0230871 Mon Sep 17 00:00:00 2001 From: Nitish Anand Date: Wed, 9 Aug 2023 21:54:23 +0200 Subject: [PATCH 28/36] sdsd --- su2preconfig.timestamp | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 su2preconfig.timestamp diff --git a/su2preconfig.timestamp b/su2preconfig.timestamp new file mode 100644 index 00000000000..e69de29bb2d From 5ef89a535c3bc1a1d8687b06f118ffae46ec4703 Mon Sep 17 00:00:00 2001 From: Nitish Anand Date: Thu, 7 Sep 2023 13:27:03 +0200 Subject: [PATCH 29/36] 2D/3D SWP-isothermal generalized, 2D- periodic direction y, 3D- periodic direction z --- SU2_CFD/src/numerics/flow/flow_sources.cpp | 2 +- SU2_CFD/src/solvers/CIncNSSolver.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/SU2_CFD/src/numerics/flow/flow_sources.cpp b/SU2_CFD/src/numerics/flow/flow_sources.cpp index 973a53d3395..130d5c0c82a 100644 --- a/SU2_CFD/src/numerics/flow/flow_sources.cpp +++ b/SU2_CFD/src/numerics/flow/flow_sources.cpp @@ -848,7 +848,7 @@ CNumerics::ResidualType<> CSourceIncStreamwise_Periodic::ComputeResidual(const C // Displacement with temperature dot_product = GeometryToolbox::DotProduct(nDim, Streamwise_Coord_Vector, PrimVar_Grad_i[nDim+1]); - su2double u_i = V_i[3], temp_i = V_i[nDim+1]; + su2double u_i = V_i[nDim==2? 1 : 3], temp_i = V_i[nDim+1]; su2double term1 = 2 * Thermal_Conductivity_i * dot_product; su2double term2 = - SPvals.Streamwise_Periodic_LambdaL * Thermal_Conductivity_i * temp_i; su2double term3 = - temp_i * u_i * DensityInc_i * config->GetSpecific_Heat_Cp(); diff --git a/SU2_CFD/src/solvers/CIncNSSolver.cpp b/SU2_CFD/src/solvers/CIncNSSolver.cpp index 4176ceb2f54..5410553b0f3 100644 --- a/SU2_CFD/src/solvers/CIncNSSolver.cpp +++ b/SU2_CFD/src/solvers/CIncNSSolver.cpp @@ -269,10 +269,10 @@ void CIncNSSolver::GetStreamwise_Periodic_Properties(const CGeometry *geometry, // coeff_b1 for turbulence if (turbulent && (config->GetnMarker_Isothermal() != 0)) { // su2doule dot_product = GeometryToolbox::DotProduct(nDim, Streamwise_Coord_Vector, nodes->GetAuxVarGradient(iPoint, 0)); - turb_b1_coeff_Local += Temp * nodes->GetAuxVarGradient(iPoint, 0, 2) * config->GetSpecific_Heat_Cp() * volume / config->GetPrandtl_Turb(); + turb_b1_coeff_Local += Temp * nodes->GetAuxVarGradient(iPoint, 0, nDim==2? 0:2) * config->GetSpecific_Heat_Cp() * volume / config->GetPrandtl_Turb(); } - Volume_VTemp_Local += volume * Temp * nodes->GetVelocity(iPoint, 2) * nodes->GetDensity(iPoint) * config->GetSpecific_Heat_Cp(); + Volume_VTemp_Local += volume * Temp * nodes->GetVelocity(iPoint, nDim==2? 0:2) * nodes->GetDensity(iPoint) * config->GetSpecific_Heat_Cp(); } // points From 688d8eaff11ff35e8defc91bc4f1a96a835c8f1f Mon Sep 17 00:00:00 2001 From: Nitish Anand Date: Mon, 30 Oct 2023 23:14:23 +0100 Subject: [PATCH 30/36] Bug fix --- SU2_CFD/src/numerics/flow/flow_sources.cpp | 2 +- externals/codi | 2 +- externals/medi | 2 +- externals/opdi | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/SU2_CFD/src/numerics/flow/flow_sources.cpp b/SU2_CFD/src/numerics/flow/flow_sources.cpp index 130d5c0c82a..bb8758b49cd 100644 --- a/SU2_CFD/src/numerics/flow/flow_sources.cpp +++ b/SU2_CFD/src/numerics/flow/flow_sources.cpp @@ -905,7 +905,7 @@ CNumerics::ResidualType<> CSourceIncStreamwisePeriodic_Outlet::ComputeResidual(c for (unsigned short iVar = 0; iVar < nVar; iVar++) residual[iVar] = 0.0; /*--- m_dot_local = rho * dot_prod(n_A*v), with n_A beeing the area-normal ---*/ - const su2double local_Massflow = DensityInc_i * GeometryToolbox::DotProduct(nDim, Normal, &V_i[3]); + const su2double local_Massflow = DensityInc_i * GeometryToolbox::DotProduct(nDim, Normal, &V_i[1]); // Massflow weighted heat sink, which takes out // a) the integrated amount over the Heatflux marker diff --git a/externals/codi b/externals/codi index 427c2dc754a..96ac78ec5bc 160000 --- a/externals/codi +++ b/externals/codi @@ -1 +1 @@ -Subproject commit 427c2dc754a628ad3c9310c766c988ac5ce21bc7 +Subproject commit 96ac78ec5bcc5ac25b785e79b16ed76fca22d736 diff --git a/externals/medi b/externals/medi index aafc2d1966b..6aef76912e7 160000 --- a/externals/medi +++ b/externals/medi @@ -1 +1 @@ -Subproject commit aafc2d1966ba1233640af737e71c77c1a86183fd +Subproject commit 6aef76912e7099c4f08c9705848797ca9e8070da diff --git a/externals/opdi b/externals/opdi index f33b507c24f..1aabf5bd1ed 160000 --- a/externals/opdi +++ b/externals/opdi @@ -1 +1 @@ -Subproject commit f33b507c24f7448d4cf4df16ab5c53ea254b8774 +Subproject commit 1aabf5bd1ed77611742eb655002f2ac7a3dddef9 From 0f2e6427464561f9883b641d2fc8fa1f73739c41 Mon Sep 17 00:00:00 2001 From: Nitish Anand Date: Mon, 30 Oct 2023 23:29:31 +0100 Subject: [PATCH 31/36] submodules updated --- externals/codi | 2 +- externals/opdi | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/externals/codi b/externals/codi index 427c2dc754a..eee1b5eea2d 160000 --- a/externals/codi +++ b/externals/codi @@ -1 +1 @@ -Subproject commit 427c2dc754a628ad3c9310c766c988ac5ce21bc7 +Subproject commit eee1b5eea2ded8126c34c1415e3b9cf15a3e70f2 diff --git a/externals/opdi b/externals/opdi index f33b507c24f..c42cca71a3d 160000 --- a/externals/opdi +++ b/externals/opdi @@ -1 +1 @@ -Subproject commit f33b507c24f7448d4cf4df16ab5c53ea254b8774 +Subproject commit c42cca71a3d0b44fb482e268ecd40b623e71776b From 93532b27a9d405183bc06e6c5a7520ab40ea2153 Mon Sep 17 00:00:00 2001 From: Nitish Anand Date: Tue, 31 Oct 2023 09:48:27 +0100 Subject: [PATCH 32/36] addressing warnings --- SU2_CFD/src/numerics/flow/flow_sources.cpp | 12 ++++++------ SU2_CFD/src/solvers/CIncNSSolver.cpp | 3 --- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/SU2_CFD/src/numerics/flow/flow_sources.cpp b/SU2_CFD/src/numerics/flow/flow_sources.cpp index b417824d178..d7fe398fe07 100644 --- a/SU2_CFD/src/numerics/flow/flow_sources.cpp +++ b/SU2_CFD/src/numerics/flow/flow_sources.cpp @@ -779,13 +779,13 @@ CNumerics::ResidualType<> CSourceIncStreamwise_Periodic::ComputeResidual(const C residual[nDim+1] = Volume * scalar_factor * dot_product; - // if (implicit) { + if (implicit) { - // /*--- Jacobian is set to zero on initialization. ---*/ + // /*--- Jacobian is set to zero on initialization. ---*/ - // jacobian[nDim+1][nDim+1] = Volume * scalar_factor * dot_product; + // jacobian[nDim+1][nDim+1] = Volume * scalar_factor * dot_product; - // } + } /*--- If a RANS turbulence model is used, an additional source term, based on the eddy viscosity gradient is added. ---*/ if(turbulent) { @@ -803,13 +803,13 @@ CNumerics::ResidualType<> CSourceIncStreamwise_Periodic::ComputeResidual(const C residual[nDim+1] -= Volume * scalar_factor * dot_product; - // if (implicit) { + if (implicit) { // /*--- Jacobian is set to zero on initialization. ---*/ // jacobian[nDim+1][nDim+1] -= Volume * scalar_factor * dot_product; - // } + } } // if turbulent } // if energy diff --git a/SU2_CFD/src/solvers/CIncNSSolver.cpp b/SU2_CFD/src/solvers/CIncNSSolver.cpp index 11c2975f588..7e75ccd419a 100644 --- a/SU2_CFD/src/solvers/CIncNSSolver.cpp +++ b/SU2_CFD/src/solvers/CIncNSSolver.cpp @@ -315,9 +315,6 @@ void CIncNSSolver::GetStreamwise_Periodic_Properties(const CGeometry *geometry, void CIncNSSolver::Compute_Streamwise_Periodic_Recovered_Values(CConfig *config, const CGeometry *geometry, const unsigned short iMesh) { - const bool energy = (config->GetEnergy_Equation() && config->GetStreamwise_Periodic_Temperature()); - const auto InnerIter = config->GetInnerIter(); - /*--- Reference node on inlet periodic marker to compute relative distance along periodic translation vector. ---*/ const auto ReferenceNode = geometry->GetStreamwise_Periodic_RefNode(); From 52fc4857be93a565e9c936982fb1d6cb89d591ac Mon Sep 17 00:00:00 2001 From: Nitish Anand Date: Tue, 30 Jan 2024 12:48:37 +0100 Subject: [PATCH 33/36] 3D Generalization - testing --- SU2_CFD/src/numerics/flow/flow_sources.cpp | 3 ++- SU2_CFD/src/solvers/CIncNSSolver.cpp | 14 +++++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/SU2_CFD/src/numerics/flow/flow_sources.cpp b/SU2_CFD/src/numerics/flow/flow_sources.cpp index d7fe398fe07..a478250a5a8 100644 --- a/SU2_CFD/src/numerics/flow/flow_sources.cpp +++ b/SU2_CFD/src/numerics/flow/flow_sources.cpp @@ -769,7 +769,8 @@ CNumerics::ResidualType<> CSourceIncStreamwise_Periodic::ComputeResidual(const C // Displacement with temperature dot_product = GeometryToolbox::DotProduct(nDim, Streamwise_Coord_Vector, PrimVar_Grad_i[nDim+1]); - su2double u_i = V_i[nDim==2? 1 : 3], temp_i = V_i[nDim+1]; + su2double u_i = GeometryToolbox::DotProduct(nDim, Streamwise_Coord_Vector, &V_i[1]); + su2double temp_i = V_i[nDim+1]; su2double term1 = 2 * Thermal_Conductivity_i * dot_product; su2double term2 = - SPvals.Streamwise_Periodic_LambdaL * Thermal_Conductivity_i * temp_i; su2double term3 = - temp_i * u_i * DensityInc_i * config->GetSpecific_Heat_Cp(); diff --git a/SU2_CFD/src/solvers/CIncNSSolver.cpp b/SU2_CFD/src/solvers/CIncNSSolver.cpp index 7e75ccd419a..f240e0114cf 100644 --- a/SU2_CFD/src/solvers/CIncNSSolver.cpp +++ b/SU2_CFD/src/solvers/CIncNSSolver.cpp @@ -268,11 +268,19 @@ void CIncNSSolver::GetStreamwise_Periodic_Properties(const CGeometry *geometry, // coeff_b1 for turbulence if (turbulent && (config->GetnMarker_Isothermal() != 0)) { - // su2doule dot_product = GeometryToolbox::DotProduct(nDim, Streamwise_Coord_Vector, nodes->GetAuxVarGradient(iPoint, 0)); - turb_b1_coeff_Local += Temp * nodes->GetAuxVarGradient(iPoint, 0, nDim==2? 0:2) * config->GetSpecific_Heat_Cp() * volume / config->GetPrandtl_Turb(); + su2double dot_product= 0.0; + for (unsigned short iDim = 0; iDim < nDim; iDim++) { + dot_product += config->GetPeriodic_Translation(0)[iDim]* nodes->GetAuxVarGradient(iPoint, 0, iDim); + } + // su2double dot_product = GeometryToolbox::DotProduct(nDim, config->GetPeriodic_Translation(0), nodes->GetAuxVarGradient(iPoint, 0)); + turb_b1_coeff_Local += Temp * dot_product * config->GetSpecific_Heat_Cp() * volume / config->GetPrandtl_Turb(); } + su2double dot_product_vel= 0.0; + for (unsigned short iDim = 0; iDim < nDim; iDim++) { + dot_product_vel += config->GetPeriodic_Translation(0)[iDim]* nodes->GetVelocity(iPoint, iDim); + } - Volume_VTemp_Local += volume * Temp * nodes->GetVelocity(iPoint, nDim==2? 0:2) * nodes->GetDensity(iPoint) * config->GetSpecific_Heat_Cp(); + Volume_VTemp_Local += volume * Temp * dot_product_vel * nodes->GetDensity(iPoint) * config->GetSpecific_Heat_Cp(); } // points From 804d89d390f70d2cd09fb82cdba35271ec6a7eed Mon Sep 17 00:00:00 2001 From: Nitish Anand Date: Thu, 11 Apr 2024 16:19:35 +0200 Subject: [PATCH 34/36] writing and raeding LAMBDAL into the flow.meta file --- SU2_CFD/src/output/CFlowOutput.cpp | 1 + SU2_CFD/src/solvers/CIncNSSolver.cpp | 4 +++- SU2_CFD/src/solvers/CSolver.cpp | 10 ++++++++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/SU2_CFD/src/output/CFlowOutput.cpp b/SU2_CFD/src/output/CFlowOutput.cpp index 75bd80feebb..68bae8d1cb3 100644 --- a/SU2_CFD/src/output/CFlowOutput.cpp +++ b/SU2_CFD/src/output/CFlowOutput.cpp @@ -2395,6 +2395,7 @@ void CFlowOutput::WriteMetaData(const CConfig *config){ if(config->GetKind_Streamwise_Periodic() == ENUM_STREAMWISE_PERIODIC::MASSFLOW) { meta_file << "STREAMWISE_PERIODIC_PRESSURE_DROP=" << GetHistoryFieldValue("STREAMWISE_DP") << endl; + meta_file << "STREAMWISE_PERIODIC_LAMBDAL=" << GetHistoryFieldValue("STREAMWISE_LAMBDAL") << endl; } } diff --git a/SU2_CFD/src/solvers/CIncNSSolver.cpp b/SU2_CFD/src/solvers/CIncNSSolver.cpp index f240e0114cf..2db3d8ee9b4 100644 --- a/SU2_CFD/src/solvers/CIncNSSolver.cpp +++ b/SU2_CFD/src/solvers/CIncNSSolver.cpp @@ -55,9 +55,11 @@ CIncNSSolver::CIncNSSolver(CGeometry *geometry, CConfig *config, unsigned short /*--- Set the initial Streamwise periodic pressure drop value. ---*/ - if (config->GetKind_Streamwise_Periodic() != ENUM_STREAMWISE_PERIODIC::NONE) + if (config->GetKind_Streamwise_Periodic() != ENUM_STREAMWISE_PERIODIC::NONE){ // Note during restarts, the flow.meta is read first. But that sets the cfg-value so we are good here. SPvals.Streamwise_Periodic_PressureDrop = config->GetStreamwise_Periodic_PressureDrop(); + SPvals.Streamwise_Periodic_LambdaL = config->GetStreamwise_Periodic_LamdaL(); + } } void CIncNSSolver::Preprocessing(CGeometry *geometry, CSolver **solver_container, CConfig *config, unsigned short iMesh, diff --git a/SU2_CFD/src/solvers/CSolver.cpp b/SU2_CFD/src/solvers/CSolver.cpp index 5cd2fd93425..cd7fc1eb976 100644 --- a/SU2_CFD/src/solvers/CSolver.cpp +++ b/SU2_CFD/src/solvers/CSolver.cpp @@ -3331,6 +3331,7 @@ void CSolver::Read_SU2_Restart_Metadata(CGeometry *geometry, CConfig *config, bo su2double dCMy_dCL_ = config->GetdCMy_dCL(); su2double dCMz_dCL_ = config->GetdCMz_dCL(); su2double SPPressureDrop_ = config->GetStreamwise_Periodic_PressureDrop(); + su2double SPLambdaL_ = config->GetStreamwise_Periodic_LamdaL(); string::size_type position; unsigned long InnerIter_ = 0; ifstream restart_file; @@ -3417,6 +3418,12 @@ void CSolver::Read_SU2_Restart_Metadata(CGeometry *geometry, CConfig *config, bo text_line.erase (0,34); SPPressureDrop_ = atof(text_line.c_str()); } + position = text_line.find ("STREAMWISE_PERIODIC_LAMBDAL=",0); + if (position != string::npos) { + // Erase the name from the line, 'STREAMWISE_PERIODIC_LAMBDAL=' has 28 chars. + text_line.erase (0,28); SPLambdaL_ = atof(text_line.c_str()); + } + } /*--- Close the restart meta file. ---*/ @@ -3512,6 +3519,9 @@ void CSolver::Read_SU2_Restart_Metadata(CGeometry *geometry, CConfig *config, bo if ((config->GetStreamwise_Periodic_PressureDrop() != SPPressureDrop_) && (rank == MASTER_NODE)) cout <<"WARNING: SU2 will use the STREAMWISE_PERIODIC_PRESSURE_DROP provided in the direct solution file: " << std::setprecision(16) << SPPressureDrop_ << endl; config->SetStreamwise_Periodic_PressureDrop(SPPressureDrop_); + if ((config->GetStreamwise_Periodic_LamdaL() != SPLambdaL_) && (rank == MASTER_NODE)) + cout <<"WARNING: SU2 will use the STREAMWISE_PERIODIC_LAMBDAL provided in the direct solution file: " << std::setprecision(16) << SPLambdaL_ << endl; + config->SetStreamwise_Periodic_LamdaL(SPLambdaL_); } else { if ((config->GetStreamwise_Periodic_PressureDrop() != SPPressureDrop_) && (rank == MASTER_NODE)) From ce08528688768968508225dbf63cf0a92765c881 Mon Sep 17 00:00:00 2001 From: Nitish Anand Date: Wed, 24 Apr 2024 10:50:27 +0200 Subject: [PATCH 35/36] Fix: Gradient Validation for Massflow based SWP Solver --- SU2_CFD/src/solvers/CDiscAdjSolver.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/SU2_CFD/src/solvers/CDiscAdjSolver.cpp b/SU2_CFD/src/solvers/CDiscAdjSolver.cpp index c42e2b4925f..9de0bf18df7 100644 --- a/SU2_CFD/src/solvers/CDiscAdjSolver.cpp +++ b/SU2_CFD/src/solvers/CDiscAdjSolver.cpp @@ -87,7 +87,7 @@ CDiscAdjSolver::CDiscAdjSolver(CGeometry *geometry, CConfig *config, CSolver *di /*--- Allocate extra solution variables, if any are in use. ---*/ - const auto nVarExtra = direct_solver->RegisterSolutionExtra(true, config); + const auto nVarExtra = direct_solver->RegisterSolutionExtra(true, config); // TODO: Do we need this? I think no. Nitish nodes->AllocateAdjointSolutionExtra(nVarExtra); switch(KindDirect_Solver){ @@ -162,7 +162,7 @@ void CDiscAdjSolver::RegisterSolution(CGeometry *geometry, CConfig *config) { /*--- Boolean true indicates that an input is registered ---*/ direct_solver->GetNodes()->RegisterSolution(true); - direct_solver->RegisterSolutionExtra(true, config); +// direct_solver->RegisterSolutionExtra(true, config); if (time_n_needed) direct_solver->GetNodes()->RegisterSolution_time_n(); @@ -261,6 +261,8 @@ void CDiscAdjSolver::RegisterVariables(CGeometry *geometry, CConfig *config, boo config->SetIncPressureOut_BC(BPressure); config->SetIncTemperature_BC(Temperature); + direct_solver->RegisterSolutionExtra(reset, config); + } /*--- Register incompressible radiation values as input ---*/ @@ -299,7 +301,7 @@ void CDiscAdjSolver::RegisterOutput(CGeometry *geometry, CConfig *config) { direct_solver->GetNodes()->RegisterSolution(false); - direct_solver->RegisterSolutionExtra(false, config); +// direct_solver->RegisterSolutionExtra(false, config); } void CDiscAdjSolver::ExtractAdjoint_Solution(CGeometry *geometry, CConfig *config, bool CrossTerm) { From 33df3db3c780372cef5b186119cf2ee8d7e91dd9 Mon Sep 17 00:00:00 2001 From: Nitish Anand Date: Wed, 7 Aug 2024 15:58:40 +0200 Subject: [PATCH 36/36] submodule updated --- externals/codi | 2 +- externals/medi | 2 +- externals/opdi | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/externals/codi b/externals/codi index eee1b5eea2d..c6b039e5c9e 160000 --- a/externals/codi +++ b/externals/codi @@ -1 +1 @@ -Subproject commit eee1b5eea2ded8126c34c1415e3b9cf15a3e70f2 +Subproject commit c6b039e5c9edb7675f90ffc725f9dd8e66571264 diff --git a/externals/medi b/externals/medi index 6aef76912e7..ab3a7688f6d 160000 --- a/externals/medi +++ b/externals/medi @@ -1 +1 @@ -Subproject commit 6aef76912e7099c4f08c9705848797ca9e8070da +Subproject commit ab3a7688f6d518f8d940eb61a341d89f51922ba4 diff --git a/externals/opdi b/externals/opdi index c42cca71a3d..8c897988172 160000 --- a/externals/opdi +++ b/externals/opdi @@ -1 +1 @@ -Subproject commit c42cca71a3d0b44fb482e268ecd40b623e71776b +Subproject commit 8c89798817253abb017d857a0ae7f0520187645c