Skip to content

Commit 55df581

Browse files
committed
Adress PR comments. Part 2.
1 parent 234fbd1 commit 55df581

11 files changed

Lines changed: 102 additions & 75 deletions

File tree

Common/include/CConfig.hpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5766,12 +5766,6 @@ class CConfig {
57665766
* \return Delta Pressure for body force computation.
57675767
*/
57685768
su2double GetStreamwise_Periodic_PressureDrop(void) const { return Streamwise_Periodic_PressureDrop; }
5769-
5770-
/*!
5771-
* \brief Set the value of the pressure delta from which body force vector is computed.
5772-
* \param[in] delta_p - pressure difference between in- and outlet.
5773-
*/
5774-
void SetStreamwise_Periodic_PressureDrop(su2double delta_p) { Streamwise_Periodic_PressureDrop = delta_p; }
57755769

57765770
/*!
57775771
* \brief Get the value of the massflow from which body force vector is computed.

Common/include/option_structure.hpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2270,6 +2270,16 @@ static const MapType<string, ENUM_STREAMWISE_PERIODIC> Streamwise_Periodic_Map =
22702270
MakePair("MASSFLOW", STREAMWISE_MASSFLOW)
22712271
};
22722272

2273+
/*!
2274+
* \brief Container to hold Variables for streamwise Periodic flow as they are often used together in places.
2275+
*/
2276+
struct StreamwisePeriodicValues {
2277+
su2double Streamwise_Periodic_PressureDrop; /*!< \brief Value of prescribed pressure drop [Pa] which results in an artificial body force vector. */
2278+
su2double Streamwise_Periodic_MassFlow; /*!< \brief Value of current massflow [kg/s] which results in a delta p and therefore an artificial body force vector. */
2279+
su2double Streamwise_Periodic_IntegratedHeatFlow; /*!< \brief Value of of the net sum of heatflow [W] into the domain. */
2280+
su2double Streamwise_Periodic_InletTemperature; /*!< \brief Area avg static Temp [K] at the periodic inlet. Used for adaptive outlet heatsink. */
2281+
};
2282+
22732283
#undef MakePair
22742284
/* END_CONFIG_ENUMS */
22752285

Common/src/geometry/CPhysicalGeometry.cpp

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7473,10 +7473,12 @@ void CPhysicalGeometry::FindUniqueNode_PeriodicBound(const CConfig *config) {
74737473
/*-------------------------------------------------------------------------------------------*/
74747474

74757475
/*--- Initialize/Allocate variables. ---*/
7476-
su2double min_norm = 0.0;
7476+
su2double min_norm = numeric_limits<su2double>::max();
74777477

7478-
vector<su2double> Buffer_Send_RefNode(nDim, 1e300),
7479-
Buffer_Recv_RefNode(static_cast<size_t>(size)*nDim);
7478+
/*--- Communicate Coordinates plus the minimum distance, therefor the nDim+1 ---*/
7479+
vector<su2double> Buffer_Send_RefNode(nDim+1, numeric_limits<su2double>::max());
7480+
su2activematrix Buffer_Recv_RefNode(size,nDim+1);
7481+
unsigned long iPointMin;
74807482

74817483
/*-------------------------------------------------------------------------------------------*/
74827484
/*--- Step 1: Find a unique reference node on each rank and communicate them such that ---*/
@@ -7496,14 +7498,13 @@ void CPhysicalGeometry::FindUniqueNode_PeriodicBound(const CConfig *config) {
74967498

74977499
auto iPoint = vertex[iMarker][iVertex]->GetNode();
74987500

7499-
/*--- Get the squared norm of the current point. ---*/
7501+
/*--- Get the squared norm of the current point. sqrt is a monotonic function in [0,R+) so for comparison we dont need Norm. ---*/
75007502
auto norm = GeometryToolbox::SquaredNorm(nDim, nodes->GetCoord(iPoint));
75017503

7502-
/*--- Check if new unique reference node is found. ---*/
7503-
if (norm < min_norm || iVertex == 0) {
7504+
/*--- Check if new unique reference node is found and store Point ID. ---*/
7505+
if (norm < min_norm) {
75047506
min_norm = norm;
7505-
for (unsigned short iDim = 0; iDim < nDim; iDim++)
7506-
Buffer_Send_RefNode[iDim] = nodes->GetCoord(iPoint,iDim);
7507+
iPointMin = iPoint;
75077508
}
75087509
/*--- The theoretical case, that multiple inlet points with the same distance to the origin exists, remains. ---*/
75097510
}
@@ -7512,26 +7513,32 @@ void CPhysicalGeometry::FindUniqueNode_PeriodicBound(const CConfig *config) {
75127513
} // periodic conditional
75137514
} // marker loop
75147515

7516+
/*--- Copy the Coordinates and norm into send buffer. ---*/
7517+
for (unsigned short iDim = 0; iDim < nDim; iDim++)
7518+
Buffer_Send_RefNode[iDim] = nodes->GetCoord(iPointMin,iDim);
7519+
Buffer_Send_RefNode[nDim] = min_norm;
7520+
75157521
/*--- Communicate unique nodes to all processes. In case of serial mode nothing happens. ---*/
7516-
SU2_MPI::Allgather(Buffer_Send_RefNode.data(), nDim, MPI_DOUBLE,
7517-
Buffer_Recv_RefNode.data(), nDim, MPI_DOUBLE, SU2_MPI::GetComm());
7522+
SU2_MPI::Allgather(Buffer_Send_RefNode.data(), nDim+1, MPI_DOUBLE,
7523+
Buffer_Recv_RefNode.data(), nDim+1, MPI_DOUBLE, SU2_MPI::GetComm());
75187524

75197525
/*-------------------------------------------------------------------------------------------*/
75207526
/*--- Step 2: Amongst all local nodes with the smallest distance to the origin, find the ---*/
75217527
/*--- globally closest to the origin. Store the found node coordinates in the ---*/
75227528
/*--- geometry container. ---*/
75237529
/*-------------------------------------------------------------------------------------------*/
75247530

7531+
min_norm = numeric_limits<su2double>::max();
7532+
75257533
for (int iRank = 0; iRank < size; iRank++) {
75267534

7527-
/*--- Get the norm of the current Point. ---*/
7528-
auto norm = GeometryToolbox::SquaredNorm(nDim, &Buffer_Recv_RefNode[static_cast<size_t>(iRank)*nDim]);
7535+
auto norm = Buffer_Recv_RefNode(iRank,nDim);
75297536

75307537
/*--- Check if new unique reference node is found. ---*/
7531-
if (norm < min_norm || iRank == 0) {
7538+
if (norm < min_norm) {
75327539
min_norm = norm;
75337540
for (unsigned short iDim = 0; iDim < nDim; iDim++)
7534-
Streamwise_Periodic_RefNode[iDim] = Buffer_Recv_RefNode[iRank*nDim + iDim];
7541+
Streamwise_Periodic_RefNode[iDim] = Buffer_Recv_RefNode(iRank,iDim);
75357542
}
75367543
}
75377544

SU2_CFD/include/numerics/CNumerics.hpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1610,9 +1610,10 @@ class CNumerics {
16101610
* \param[in] integratedHeat - integrated heatflow over heatflux boundaries [W].
16111611
* \param[in] inletTemp - massflow averaged periodic inlet temperature [K].
16121612
*/
1613-
virtual inline void SetStreamwise_Periodic_Values(const su2double massflow,
1614-
const su2double integratedHeat,
1615-
const su2double inletTemp) { }
1613+
virtual void SetStreamwisePeriodicValues(const su2double pressureDrop, const su2double massflow,
1614+
const su2double integratedHeat, const su2double inletTemp) {
1615+
1616+
}
16161617
};
16171618

16181619
/*!

SU2_CFD/include/numerics/flow/flow_sources.hpp

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,7 @@ class CSourceBase_Flow : public CNumerics {
4040
protected:
4141
su2double* residual = nullptr;
4242
su2double** jacobian = nullptr;
43-
su2double
44-
Streamwise_Periodic_MassFlow, /*!< \brief Value of current massflow [kg/s] which results in a delta p and therefore an artificial body force vector. */
45-
Streamwise_Periodic_IntegratedHeatFlow, /*!< \brief Value of of the net sum of heatflow [W] into the domain. */
46-
Streamwise_Periodic_InletTemperature; /*!< \brief Area avg static Temp [K] at the periodic inlet. Used for adaptive outlet heatsink. */
43+
struct StreamwisePeriodicValues SPvals;
4744

4845
/*!
4946
* \brief Constructor of the class.
@@ -65,10 +62,11 @@ class CSourceBase_Flow : public CNumerics {
6562
* \param[in] integratedHeat - integrated heatflow over heatflux boundaries [W].
6663
* \param[in] inletTemp - massflow averaged periodic inlet temperature [K].
6764
*/
68-
void SetStreamwise_Periodic_Values(const su2double massflow, const su2double integratedHeat, const su2double inletTemp) {
69-
Streamwise_Periodic_MassFlow = massflow;
70-
Streamwise_Periodic_IntegratedHeatFlow = integratedHeat;
71-
Streamwise_Periodic_InletTemperature = inletTemp;
65+
void SetStreamwisePeriodicValues(const su2double pressureDrop, const su2double massflow, const su2double integratedHeat, const su2double inletTemp) {
66+
SPvals.Streamwise_Periodic_PressureDrop = pressureDrop;
67+
SPvals.Streamwise_Periodic_MassFlow = massflow;
68+
SPvals.Streamwise_Periodic_IntegratedHeatFlow = integratedHeat;
69+
SPvals.Streamwise_Periodic_InletTemperature = inletTemp;
7270
}
7371

7472
};

SU2_CFD/include/solvers/CIncEulerSolver.hpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@
3939
class CIncEulerSolver : public CFVMFlowSolverBase<CIncEulerVariable, INCOMPRESSIBLE> {
4040
protected:
4141
vector<CFluidModel*> FluidModel; /*!< \brief fluid model used in the solver. */
42-
su2double
43-
Streamwise_Periodic_MassFlow, /*!< \brief Value of current massflow [kg/s] which results in a delta p and therefore an artificial body force vector. */
44-
Streamwise_Periodic_IntegratedHeatFlow, /*!< \brief Value of of the net sum of heatflow [W] into the domain. */
45-
Streamwise_Periodic_InletTemperature; /*!< \brief Area avg static Temp [K] at the periodic inlet. Used for adaptive outlet heatsink. */
42+
su2double Streamwise_Periodic_PressureDrop; /*!< \brief Value of prescribed pressure drop [Pa] which results in an artificial body force vector. */
43+
su2double Streamwise_Periodic_MassFlow; /*!< \brief Value of current massflow [kg/s] which results in a delta p and therefore an artificial body force vector. */
44+
su2double Streamwise_Periodic_IntegratedHeatFlow; /*!< \brief Value of of the net sum of heatflow [W] into the domain. */
45+
su2double Streamwise_Periodic_InletTemperature; /*!< \brief Area avg static Temp [K] at the periodic inlet. Used for adaptive outlet heatsink. */
4646

4747
/*!
4848
* \brief Preprocessing actions common to the Euler and NS solvers.
@@ -400,6 +400,12 @@ class CIncEulerSolver : public CFVMFlowSolverBase<CIncEulerVariable, INCOMPRESSI
400400
*/
401401
inline bool GetHasHybridParallel() const final { return true; }
402402

403+
/*!
404+
* \brief Get the massflow of the streamwise periodic donor/outlet boundary.
405+
* \return The streamwise periodic donor/outlet massflow.
406+
*/
407+
su2double GetStreamwise_Periodic_PressureDrop() const { return Streamwise_Periodic_PressureDrop; }
408+
403409
/*!
404410
* \brief Get the massflow of the streamwise periodic donor/outlet boundary.
405411
* \return The streamwise periodic donor/outlet massflow.

SU2_CFD/include/solvers/CSolver.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4411,6 +4411,12 @@ class CSolver {
44114411
*/
44124412
inline virtual bool GetHasHybridParallel() const { return false; }
44134413

4414+
/*!
4415+
* \brief Get the massflow of the streamwise periodic donor/outlet boundary.
4416+
* \return The streamwise periodic donor/outlet massflow.
4417+
*/
4418+
virtual su2double GetStreamwise_Periodic_PressureDrop() const { return 0.0; }
4419+
44144420
/*!
44154421
* \brief Get the massflow of the streamwise periodic donor/outlet boundary.
44164422
* \return The streamwise periodic donor/outlet massflow.

SU2_CFD/src/numerics/flow/flow_sources.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -693,7 +693,7 @@ CSourceIncStreamwise_Periodic::CSourceIncStreamwise_Periodic(unsigned short val_
693693
CNumerics::ResidualType<> CSourceIncStreamwise_Periodic::ComputeResidual(const CConfig *config) {
694694

695695
/* Value of prescribed pressure drop which results in an artificial body force vector. */
696-
const su2double delta_p = config->GetStreamwise_Periodic_PressureDrop() / config->GetPressure_Ref();
696+
const su2double delta_p = SPvals.Streamwise_Periodic_PressureDrop;
697697

698698
for (unsigned short iVar = 0; iVar < nVar; iVar++) residual[iVar] = 0.0;
699699

@@ -706,7 +706,7 @@ CNumerics::ResidualType<> CSourceIncStreamwise_Periodic::ComputeResidual(const C
706706
/*--- Compute the periodic temperature contribution to the energy equation, if energy equation is considered ---*/
707707
if (energy && streamwisePeriodic_temperature) {
708708

709-
scalar_factor = Streamwise_Periodic_IntegratedHeatFlow * DensityInc_i / (Streamwise_Periodic_MassFlow * norm2_translation);
709+
scalar_factor = SPvals.Streamwise_Periodic_IntegratedHeatFlow * DensityInc_i / (SPvals.Streamwise_Periodic_MassFlow * norm2_translation);
710710

711711
/*--- Compute scalar-product dot_prod(v*t) ---*/
712712
dot_product = GeometryToolbox::DotProduct(nDim, Streamwise_Coord_Vector, &V_i[1]);
@@ -717,7 +717,7 @@ CNumerics::ResidualType<> CSourceIncStreamwise_Periodic::ComputeResidual(const C
717717
if(turbulent) {
718718

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

722722
/*--- Compute scalar product between periodic translation vector and eddy viscosity gradient. ---*/
723723
dot_product = GeometryToolbox::DotProduct(nDim, Streamwise_Coord_Vector, PrimVar_Grad_i[nDim+5]);
@@ -746,14 +746,14 @@ CNumerics::ResidualType<> CSourceIncStreamwisePeriodic_Outlet::ComputeResidual(c
746746
// b) a user provided quantity, especially the case for CHT cases
747747
su2double factor;
748748
if (config->GetStreamwise_Periodic_OutletHeat() == 0.0)
749-
factor = Streamwise_Periodic_IntegratedHeatFlow;
749+
factor = SPvals.Streamwise_Periodic_IntegratedHeatFlow;
750750
else
751751
factor = config->GetStreamwise_Periodic_OutletHeat() / config->GetHeat_Flux_Ref();
752752

753-
residual[nDim+1] -= abs(local_Massflow/Streamwise_Periodic_MassFlow) * factor;
753+
residual[nDim+1] -= abs(local_Massflow/SPvals.Streamwise_Periodic_MassFlow) * factor;
754754

755755
/*--- Force the area avg inlet Temp to match the Inc_Temperature_Init with additional residual contribution ---*/
756-
const su2double delta_T = Streamwise_Periodic_InletTemperature - config->GetInc_Temperature_Init()/config->GetTemperature_Ref();
756+
const su2double delta_T = SPvals.Streamwise_Periodic_InletTemperature - config->GetInc_Temperature_Init()/config->GetTemperature_Ref();
757757
residual[nDim+1] += 0.5 * abs(local_Massflow) * SpecificHeat_i * delta_T;
758758

759759
return ResidualType<>(residual, jacobian, nullptr);

SU2_CFD/src/output/CFlowIncOutput.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ void CFlowIncOutput::LoadHistoryData(CConfig *config, CGeometry *geometry, CSolv
343343

344344
if(streamwisePeriodic) {
345345
SetHistoryOutputValue("STREAMWISE_MASSFLOW", flow_solver->GetStreamwise_Periodic_MassFlow());
346-
SetHistoryOutputValue("STREAMWISE_DP", config->GetStreamwise_Periodic_PressureDrop());
346+
SetHistoryOutputValue("STREAMWISE_DP", flow_solver->GetStreamwise_Periodic_PressureDrop());
347347
SetHistoryOutputValue("STREAMWISE_HEAT", flow_solver->GetStreamwise_Periodic_IntegratedHeatFlow());
348348
}
349349

0 commit comments

Comments
 (0)