Skip to content

Commit

Permalink
update comments
Browse files Browse the repository at this point in the history
  • Loading branch information
pcarruscag committed Jul 24, 2022
1 parent 3f28140 commit 3babe42
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 40 deletions.
5 changes: 3 additions & 2 deletions SU2_CFD/include/output/CFlowOutput.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,9 @@ class CFlowOutput : public CFVMOutput{
if ("THERMAL_CONDUCTIVITY" == var) return flow_offset + idx.ThermalConductivity();

/*--- Index-based (no name) access to variables of other solvers. ---*/
auto GetIndex = [](const std::string& s, int offset) {
return std::stoi(std::string(s.begin() + offset + 1, s.end() - 1));
auto GetIndex = [](const std::string& s, int nameLen) {
/*--- Extract an int from "name[int]", nameLen is the length of "name". ---*/
return std::stoi(std::string(s.begin() + nameLen + 1, s.end() - 1));
};
if (var.rfind("SPECIES", 0) == 0) return SPECIES_SOL * CustomOutput::MAX_VARS_PER_SOLVER + GetIndex(var, 7);
if (var.rfind("TURB", 0) == 0) return TURB_SOL * CustomOutput::MAX_VARS_PER_SOLVER + GetIndex(var, 4);
Expand Down
78 changes: 40 additions & 38 deletions SU2_CFD/src/output/CFlowOutput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -751,7 +751,7 @@ void CFlowOutput::SetCustomOutputs(const CSolver* const* solver, const CGeometry

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

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

SU2_OMP_PARALLEL {
std::array<su2double, 2> local_integral = {0.0, 0.0};
std::array<su2double, 2> local_integral = {0.0, 0.0};

for (const auto iMarker : output.markerIndices) {
for (const auto iMarker : output.markerIndices) {

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

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

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

su2double weight = 1.0;
if (output.type == OperationType::MASSFLOW_AVG || output.type == OperationType::MASSFLOW_INT) {
weight = flowNodes->GetDensity(iPoint) * flowNodes->GetProjVel(iPoint, normal);
} else {
weight = GeometryToolbox::Norm(nDim, normal);
}
weight *= GetAxiFactor(axisymmetric, *geometry->nodes, iPoint, iMarker);
local_integral[1] += weight;

/*--- Prepare the functor that maps symbol indices to values. For now the only allowed symbols
* are the primitive variables, and thus the indices match the primitive indices. ---*/

auto Functor = [&](unsigned long i) {
if (i < CustomOutput::NOT_A_VARIABLE) {
const auto solIdx = i / CustomOutput::MAX_VARS_PER_SOLVER;
const auto varIdx = i % CustomOutput::MAX_VARS_PER_SOLVER;
if (solIdx == FLOW_SOL) {
return flowNodes->GetPrimitive(iPoint, varIdx);
} else {
return solver[solIdx]->GetNodes()->GetSolution(iPoint, varIdx);
}
su2double weight = 1.0;
if (output.type == OperationType::MASSFLOW_AVG || output.type == OperationType::MASSFLOW_INT) {
weight = flowNodes->GetDensity(iPoint) * flowNodes->GetProjVel(iPoint, normal);
} else {
return *output.otherOutputs[i - CustomOutput::NOT_A_VARIABLE];
weight = GeometryToolbox::Norm(nDim, normal);
}
};
local_integral[0] += weight * output.eval(Functor);
weight *= GetAxiFactor(axisymmetric, *geometry->nodes, iPoint, iMarker);
local_integral[1] += weight;

/*--- Prepare the functor that maps symbol indices to values (see ConvertVariableSymbolsToIndices). ---*/

auto Functor = [&](unsigned long i) {
if (i < CustomOutput::NOT_A_VARIABLE) {
const auto solIdx = i / CustomOutput::MAX_VARS_PER_SOLVER;
const auto varIdx = i % CustomOutput::MAX_VARS_PER_SOLVER;
if (solIdx == FLOW_SOL) {
return flowNodes->GetPrimitive(iPoint, varIdx);
} else {
return solver[solIdx]->GetNodes()->GetSolution(iPoint, varIdx);
}
} else {
return *output.otherOutputs[i - CustomOutput::NOT_A_VARIABLE];
}
};
local_integral[0] += weight * output.eval(Functor);
}
END_SU2_OMP_FOR
}

SU2_OMP_CRITICAL {
integral[0] += local_integral[0];
integral[1] += local_integral[1];
}
END_SU2_OMP_FOR
END_SU2_OMP_CRITICAL
}
SU2_OMP_SAFE_GLOBAL_ACCESS(
integral[0] += local_integral[0];
integral[1] += local_integral[1];
)
} END_SU2_OMP_PARALLEL
END_SU2_OMP_PARALLEL

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

0 comments on commit 3babe42

Please sign in to comment.