Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Isothermal streamwise periodicity #1799

Draft
wants to merge 48 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 28 commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
514fd95
NS iso thermal implementation working
NAnand-TUD Jul 6, 2022
449c16a
Merge branch 'develop' into feature_isothermalSWP
NAnand-TUD Jul 6, 2022
97820a2
Volume averaged temperature computation shifted
NAnand-TUD Jul 6, 2022
fa1f38a
clean-up and seperation of iso-thermal and heat flux SWP sources, bot…
Jul 7, 2022
15a5eb2
iso-thermal objectives still not getting validated
Jul 14, 2022
fd9afe2
Turbulent isothermal source terms added, validation pending
Jul 19, 2022
988b5a9
Quadratic term for turbulent equations, solution verification and gra…
Jul 19, 2022
978a87f
Gradient Validation for Lambda L is working for Laminar and Turbulent…
Aug 12, 2022
26f3339
cleaning and comments
Aug 12, 2022
9799d82
Small correction to the source terms
Aug 20, 2022
c6e1277
Correction to the SourceTerms to compute turbulent Lambda
Oct 12, 2022
0425778
Merge remote-tracking branch 'origin/develop' into feature_isothermalSWP
Oct 12, 2022
3eaa05e
Merged with develop, minor verification in process
Oct 12, 2022
e383836
complying with the PR suggestions
NAnand-TUD Oct 27, 2022
5651b3d
Build failing due to errors. This should pass hopefully 1
NAnand-TUD Oct 27, 2022
f0a817c
Build failing due to errors. This should pass hopefully 2
NAnand-TUD Oct 27, 2022
71c3d95
Merge branch 'develop' into feature_isothermalSWP
bigfooted Oct 27, 2022
2f4888f
Build failing due to errors. This should pass hopefully 3, unit test …
NAnand-TUD Oct 28, 2022
a777bd6
Merge branch 'feature_isothermalSWP' of https://github.com/su2code/SU…
NAnand-TUD Oct 28, 2022
19e3f41
complying with the PR suggestions, Pedro comments.
NAnand-TUD Nov 9, 2022
757c6b2
Objective functions exclusive to Streamwise Periodic flow added
NAnand-TUD Nov 9, 2022
8ef2141
Update SU2_CFD/src/solvers/CIncNSSolver.cpp
NAnand-TUD Nov 10, 2022
02f61e5
Update SU2_CFD/src/solvers/CIncNSSolver.cpp
NAnand-TUD Nov 10, 2022
c931b98
Update SU2_CFD/src/output/CFlowIncOutput.cpp
NAnand-TUD Nov 10, 2022
03fe2ad
Update SU2_CFD/src/output/CFlowIncOutput.cpp
NAnand-TUD Nov 10, 2022
78b0ab0
V_i suggestion and CConfig fixed
NAnand-TUD Nov 10, 2022
0f4bb42
Merge branch 'feature_isothermalSWP' of https://github.com/su2code/SU…
NAnand-TUD Nov 10, 2022
50360de
fixed error with DotProduct
NAnand-TUD Nov 10, 2022
d67666b
Submodule commits updated
NAnand-TUD Nov 10, 2022
99e39e8
CConfig error tested and CIncNSSolver implemented
Nov 11, 2022
bec2016
Merged with develop
Feb 16, 2023
5e4b0a8
Merge branch 'develop' into feature_isothermalSWP
NAnand-TUD Jul 11, 2023
c0ae9fd
Merge branch 'feature_isothermalSWP' of https://github.com/su2code/SU…
NAnand-TUD Jul 11, 2023
8c5f3f4
Merged with develop, submodules updated
NAnand-TUD Jul 11, 2023
b1f7acb
Changes to make z direction flow work
NAnand-TUD Aug 9, 2023
2f95ece
sdsd
NAnand-TUD Aug 9, 2023
fc0caaf
Merge branch 'feature_isothermalSWP' of https://github.com/su2code/SU…
NAnand-TUD Aug 9, 2023
5ef89a5
2D/3D SWP-isothermal generalized, 2D- periodic direction y, 3D- perio…
NAnand-TUD Sep 7, 2023
abfa537
Merge branch 'develop' into feature_isothermalSWP
NAnand-TUD Oct 30, 2023
688d8ea
Bug fix
NAnand-TUD Oct 30, 2023
6f80a62
merged with develop
NAnand-TUD Oct 30, 2023
0f2e642
submodules updated
NAnand-TUD Oct 30, 2023
93532b2
addressing warnings
NAnand-TUD Oct 31, 2023
52fc485
3D Generalization - testing
NAnand-TUD Jan 30, 2024
804d89d
writing and raeding LAMBDAL into the flow.meta file
NAnand-TUD Apr 11, 2024
ce08528
Fix: Gradient Validation for Massflow based SWP Solver
NAnand-TUD Apr 24, 2024
2b6a2ea
Merged with develop
Aug 7, 2024
33df3db
submodule updated
Aug 7, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions Common/include/CConfig.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1042,7 +1042,9 @@ 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. */

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). */
Expand Down Expand Up @@ -3000,6 +3002,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.
Expand Down Expand Up @@ -5981,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.
Expand Down Expand Up @@ -9632,4 +9651,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 Get Lambda L for Streamwise Periodic
* \return su2double
*/
su2double GetStreamwise_Periodic_LamdaL(void) const { return Streamwise_Periodic_LambdaL; }

};
8 changes: 8 additions & 0 deletions Common/include/option_structure.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1778,6 +1778,9 @@ 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_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<std::string, ENUM_OBJECTIVE> Objective_Map = {
MakePair("DRAG", DRAG_COEFFICIENT)
Expand Down Expand Up @@ -1813,6 +1816,9 @@ static const MapType<std::string, ENUM_OBJECTIVE> 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_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)
Expand Down Expand Up @@ -2457,6 +2463,8 @@ 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. */
su2double Streamwise_Periodic_ThetaScaling; /*!< \brief Scaled Temperature for iso-thermal BCs. */
};

/*!
Expand Down
4 changes: 2 additions & 2 deletions Common/src/CConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 != 0)
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);
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you see any edge case that might pass this?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks ok but @TobiKattmann should know better

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)
Expand Down
2 changes: 2 additions & 0 deletions SU2_CFD/include/numerics/flow/flow_sources.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +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 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. */
Expand Down
9 changes: 9 additions & 0 deletions SU2_CFD/include/solvers/CFVMFlowSolverBase.inl
Original file line number Diff line number Diff line change
Expand Up @@ -3000,6 +3000,15 @@ su2double CFVMFlowSolverBase<V,R>::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();
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;
Expand Down
39 changes: 32 additions & 7 deletions SU2_CFD/src/numerics/flow/flow_sources.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
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];
Expand All @@ -729,19 +731,42 @@ 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);
/*--- 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);

/*--- Compute scalar-product dot_prod(v*t) ---*/
dot_product = GeometryToolbox::DotProduct(nDim, Streamwise_Coord_Vector, &V_i[1]);
/*--- 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 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 * 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;
}

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) {

/*--- Compute a scalar factor ---*/
scalar_factor = SPvals.Streamwise_Periodic_IntegratedHeatFlow / (SPvals.Streamwise_Periodic_MassFlow * sqrt(norm2_translation) * Prandtl_Turb);

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) {
pcarruscag marked this conversation as resolved.
Show resolved Hide resolved
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]);

Expand Down
6 changes: 5 additions & 1 deletion SU2_CFD/src/output/CFlowIncOutput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -258,10 +260,12 @@ 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)
SetHistoryOutputValue("STREAMWISE_LAMBDAL", flow_solver->GetStreamwisePeriodicValues().Streamwise_Periodic_LambdaL);
}

/*--- Set the analyse surface history values --- */
Expand Down
4 changes: 4 additions & 0 deletions SU2_CFD/src/solvers/CIncEulerSolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -1643,6 +1644,9 @@ void CIncEulerSolver::Source_Residual(CGeometry *geometry, CSolver **solver_cont
if(streamwise_periodic_temperature && turbulent)
numerics->SetAuxVarGrad(nodes->GetAuxVarGradient(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);
LinSysRes.AddBlock(iPoint, residual);
Expand Down
87 changes: 83 additions & 4 deletions SU2_CFD/src/solvers/CIncNSSolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {

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.
Expand Down Expand Up @@ -191,15 +191,16 @@ 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 ---*/
/*--- boundary term and recovered Temperature. The computation is not completely clear. ---*/
/*--- Here the Heatflux from all Boundary markers in the config-file is used. ---*/
/*---------------------------------------------------------------------------------------------*/

su2double HeatFlow_Local = 0.0, HeatFlow_Global = 0.0;

/*--- Loop over all heatflux Markers ---*/
for (auto iMarker = 0; iMarker < config->GetnMarker_All(); iMarker++) {

Expand All @@ -222,13 +223,91 @@ 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 ISOTHERMAL from config ---*/

for (auto iVertex = 0ul; iVertex < geometry->nVertex[iMarker]; iVertex++) {

const auto iPoint = geometry->vertex[iMarker][iVertex]->GetNode();

if (!geometry->nodes->GetDomain(iPoint)) continue;

/*--- 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++)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I have to revert this as GetGradient_Primitive gives a Matrix su2double which does not comply with DotProduct. I saw at other parts of the code for loop being used to construct a variable and then do DotProduct.

Do you know a better way to handle this?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, slightly wrong suggestion, do this instead please:

const auto GradT = nodes->GetGradient_Primitive(iPoint)[prim_idx.Temperature()];

GradT[iDim] = nodes->GetGradient_Primitive(iPoint, prim_idx.Temperature(), iDim);

dTdn_Local += nodes->GetThermalConductivity(iPoint) * GeometryToolbox::DotProduct(nDim, GradT, AreaNormal);
} // 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());

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->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, 0) * nodes->GetDensity(iPoint);

} // points

/*--- 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());
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());

/*--- Set the solver variable Integrated Heatflux ---*/
SPvals.Streamwise_Periodic_IntegratedHeatFlow = HeatFlow_Global;
if (config->GetnMarker_HeatFlux() > 0)
SPvals.Streamwise_Periodic_IntegratedHeatFlow = HeatFlow_Global;

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);

/*--- 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 b2_coeff = -dTdn_Global;

/*--- Find the value of Lambda L by solving the quadratic equation ---*/
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;

config->SetStreamwise_Periodic_LamdaL(SPvals.Streamwise_Periodic_LambdaL);
} // if isothermal
} // if energy
}

Expand Down
2 changes: 1 addition & 1 deletion externals/opdi
Submodule opdi updated 176 files