Skip to content

Add OpenMP for force calculation. - #2870

Open
pcarruscag wants to merge 13 commits into
developfrom
pedro/parallel_forces
Open

Add OpenMP for force calculation.#2870
pcarruscag wants to merge 13 commits into
developfrom
pedro/parallel_forces

Conversation

@pcarruscag

Copy link
Copy Markdown
Member

Proposed Changes

Add OpenMP for force calculation.

PR Checklist

  • I am submitting my contribution to the develop branch.
  • My contribution generates no new compiler warnings (try with --warnlevel=3 when using meson).
  • My contribution is commented and consistent with SU2 style (https://su2code.github.io/docs_v7/Style-Guide/).
  • I used the pre-commit hook to prevent dirty commits and used pre-commit run --all to format old commits.
  • I have added a test case that demonstrates my contribution, if necessary.
  • I have updated appropriate documentation (Tutorials, Docs Page, config_template.cpp), if necessary.

pcarruscag and others added 3 commits August 16, 2026 17:48
… 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>
Comment thread SU2_CFD/include/solvers/CFVMFlowSolverBase.hpp Outdated
Comment thread SU2_CFD/include/solvers/CFVMFlowSolverBase.inl Outdated
Comment thread SU2_CFD/include/solvers/CFVMFlowSolverBase.inl Fixed
Comment thread SU2_CFD/include/solvers/CFVMFlowSolverBase.inl Fixed
Comment thread SU2_CFD/include/solvers/CFVMFlowSolverBase.inl Fixed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants