Add OpenMP for force calculation. - #2870
Open
pcarruscag wants to merge 13 commits into
Open
Conversation
… OpenMP These previously ran single-threaded (wrapped in a master-only section by the caller). The per-vertex loop within each marker is now work-shared with SU2_OMP_FOR_STAT, which is the expensive part in Friction_Forces (stress-tensor and heat-flux evaluations). Thread-partial force/moment sums are folded into the shared per-marker/AllBound/Surface totals via a single critical section per marker; nonlinear ratios (CEff, CMerit) are derived once afterwards from the fully-reduced totals. Shared logic (folding a partial contribution, projecting force/moment onto wind axes, MPI-reducing an AllBound/Surface pair, and merging into the running grand totals) is factored into free function templates local to CFVMFlowSolverBase.inl, used identically by all three functions. Also fixes two latent bugs found while restructuring Momentum_Forces and Friction_Forces: AllBoundMntCoeff.CMz was never accumulated (a typo added CMz into CMx twice instead), and the final CMerit in both Momentum_Forces and Friction_Forces used an inconsistent/non-cumulative formula instead of the running TotalCoeff.CT/CQ used everywhere else. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…tion_Forces Per-vertex loop chunking: use a per-marker balanced static chunk size (bounded by OMP_MAX_SIZE) instead of a fixed small OMP_MIN_SIZE chunk, and drop the implicit end-of-loop barrier (SU2_NOWAIT) since each thread only needs its own partial sums before folding them into the shared totals; the safe-global-access section that follows already provides the barrier needed before the fully-reduced totals are read. cos/sin(Alpha/Beta) are now computed once per function call instead of once per monitored marker (ComputeAeroCoeffsFromForceMoment takes the precomputed values). Friction_Forces: marker-level CConfig lookups (GetWallRoughnessProperties, GetWall_HeatFlux, GetIsothermal_Temperature, GetCatalytic_Wall), several of which scan marker lists by string comparison, are now evaluated once per marker instead of once per vertex. The velocity gradient block is fetched once via GetVelocityGradient() instead of nDim*nDim individual GetGradient_Primitive() calls. The already-known Origin/iMarker_Monitoring index is reused when folding heat flux into the surface totals, instead of a second linear scan over monitored markers inside the critical section. The per-marker/per-monitoring-marker portions of the init/finalize blocks (zeroing AeroCoeffsArray slots, deriving per-marker CEff/CMerit) are now real work-shared loops instead of running master-only: each iteration only touches its own disjoint slot, the same pattern already used for the per-vertex writes elsewhere in these functions. AeroCoeffsArray::setZero() work-shares its own loop internally, so callers just call it directly (from every thread, not just master) instead of hand-rolling a loop. Only what must run exactly once (MPI calls, cross-marker accumulation, Buffet_Monitoring) stays master-only. Add Tracy zones (SU2_ZONE_SCOPED) to Pressure_Forces/Momentum_Forces/ Friction_Forces for profiling. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
pcarruscag
commented
Aug 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Proposed Changes
Add OpenMP for force calculation.
PR Checklist
pre-commit run --allto format old commits.