Skip to content

Commit 3babe42

Browse files
committed
update comments
1 parent 3f28140 commit 3babe42

2 files changed

Lines changed: 43 additions & 40 deletions

File tree

SU2_CFD/include/output/CFlowOutput.hpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,8 +237,9 @@ class CFlowOutput : public CFVMOutput{
237237
if ("THERMAL_CONDUCTIVITY" == var) return flow_offset + idx.ThermalConductivity();
238238

239239
/*--- Index-based (no name) access to variables of other solvers. ---*/
240-
auto GetIndex = [](const std::string& s, int offset) {
241-
return std::stoi(std::string(s.begin() + offset + 1, s.end() - 1));
240+
auto GetIndex = [](const std::string& s, int nameLen) {
241+
/*--- Extract an int from "name[int]", nameLen is the length of "name". ---*/
242+
return std::stoi(std::string(s.begin() + nameLen + 1, s.end() - 1));
242243
};
243244
if (var.rfind("SPECIES", 0) == 0) return SPECIES_SOL * CustomOutput::MAX_VARS_PER_SOLVER + GetIndex(var, 7);
244245
if (var.rfind("TURB", 0) == 0) return TURB_SOL * CustomOutput::MAX_VARS_PER_SOLVER + GetIndex(var, 4);

SU2_CFD/src/output/CFlowOutput.cpp

Lines changed: 40 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -751,7 +751,7 @@ void CFlowOutput::SetCustomOutputs(const CSolver* const* solver, const CGeometry
751751

752752
for (auto& output : customOutputs) {
753753
if (output.varIndices.empty()) {
754-
/*--- Setup indices for the symbols in the expression, for now this only recognizes primitives. ---*/
754+
/*--- Setup indices for the symbols in the expression. ---*/
755755

756756
if (config->GetNEMOProblem()) {
757757
ConvertVariableSymbolsToIndices(
@@ -788,52 +788,54 @@ void CFlowOutput::SetCustomOutputs(const CSolver* const* solver, const CGeometry
788788
std::array<su2double, 2> integral = {0.0, 0.0};
789789

790790
SU2_OMP_PARALLEL {
791-
std::array<su2double, 2> local_integral = {0.0, 0.0};
791+
std::array<su2double, 2> local_integral = {0.0, 0.0};
792792

793-
for (const auto iMarker : output.markerIndices) {
793+
for (const auto iMarker : output.markerIndices) {
794794

795-
SU2_OMP_FOR_(schedule(static) SU2_NOWAIT)
796-
for (auto iVertex = 0ul; iVertex < geometry->nVertex[iMarker]; ++iVertex) {
797-
const auto iPoint = geometry->vertex[iMarker][iVertex]->GetNode();
795+
SU2_OMP_FOR_(schedule(static) SU2_NOWAIT)
796+
for (auto iVertex = 0ul; iVertex < geometry->nVertex[iMarker]; ++iVertex) {
797+
const auto iPoint = geometry->vertex[iMarker][iVertex]->GetNode();
798798

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

801-
const auto* normal = geometry->vertex[iMarker][iVertex]->GetNormal();
801+
const auto* normal = geometry->vertex[iMarker][iVertex]->GetNormal();
802802

803-
su2double weight = 1.0;
804-
if (output.type == OperationType::MASSFLOW_AVG || output.type == OperationType::MASSFLOW_INT) {
805-
weight = flowNodes->GetDensity(iPoint) * flowNodes->GetProjVel(iPoint, normal);
806-
} else {
807-
weight = GeometryToolbox::Norm(nDim, normal);
808-
}
809-
weight *= GetAxiFactor(axisymmetric, *geometry->nodes, iPoint, iMarker);
810-
local_integral[1] += weight;
811-
812-
/*--- Prepare the functor that maps symbol indices to values. For now the only allowed symbols
813-
* are the primitive variables, and thus the indices match the primitive indices. ---*/
814-
815-
auto Functor = [&](unsigned long i) {
816-
if (i < CustomOutput::NOT_A_VARIABLE) {
817-
const auto solIdx = i / CustomOutput::MAX_VARS_PER_SOLVER;
818-
const auto varIdx = i % CustomOutput::MAX_VARS_PER_SOLVER;
819-
if (solIdx == FLOW_SOL) {
820-
return flowNodes->GetPrimitive(iPoint, varIdx);
821-
} else {
822-
return solver[solIdx]->GetNodes()->GetSolution(iPoint, varIdx);
823-
}
803+
su2double weight = 1.0;
804+
if (output.type == OperationType::MASSFLOW_AVG || output.type == OperationType::MASSFLOW_INT) {
805+
weight = flowNodes->GetDensity(iPoint) * flowNodes->GetProjVel(iPoint, normal);
824806
} else {
825-
return *output.otherOutputs[i - CustomOutput::NOT_A_VARIABLE];
807+
weight = GeometryToolbox::Norm(nDim, normal);
826808
}
827-
};
828-
local_integral[0] += weight * output.eval(Functor);
809+
weight *= GetAxiFactor(axisymmetric, *geometry->nodes, iPoint, iMarker);
810+
local_integral[1] += weight;
811+
812+
/*--- Prepare the functor that maps symbol indices to values (see ConvertVariableSymbolsToIndices). ---*/
813+
814+
auto Functor = [&](unsigned long i) {
815+
if (i < CustomOutput::NOT_A_VARIABLE) {
816+
const auto solIdx = i / CustomOutput::MAX_VARS_PER_SOLVER;
817+
const auto varIdx = i % CustomOutput::MAX_VARS_PER_SOLVER;
818+
if (solIdx == FLOW_SOL) {
819+
return flowNodes->GetPrimitive(iPoint, varIdx);
820+
} else {
821+
return solver[solIdx]->GetNodes()->GetSolution(iPoint, varIdx);
822+
}
823+
} else {
824+
return *output.otherOutputs[i - CustomOutput::NOT_A_VARIABLE];
825+
}
826+
};
827+
local_integral[0] += weight * output.eval(Functor);
828+
}
829+
END_SU2_OMP_FOR
830+
}
831+
832+
SU2_OMP_CRITICAL {
833+
integral[0] += local_integral[0];
834+
integral[1] += local_integral[1];
829835
}
830-
END_SU2_OMP_FOR
836+
END_SU2_OMP_CRITICAL
831837
}
832-
SU2_OMP_SAFE_GLOBAL_ACCESS(
833-
integral[0] += local_integral[0];
834-
integral[1] += local_integral[1];
835-
)
836-
} END_SU2_OMP_PARALLEL
838+
END_SU2_OMP_PARALLEL
837839

838840
const auto local = integral;
839841
SU2_MPI::Allreduce(local.data(), integral.data(), 2, MPI_DOUBLE, MPI_SUM, SU2_MPI::GetComm());

0 commit comments

Comments
 (0)