FhSim  3.1.0
Marine systems simulation
Loading...
Searching...
No Matches
0064 — Cable evaluates the wave sum three times per segment and right-hand side
ID 0064
Class ARCHITECTURE
Severity 1
Status ready

Models: Cable, FlukeAnchor, TorpedoAnchor

Found: Deep review 2026-09-28, worktrees/nethydro/review/deep/other-hydro-forces.md P1 (performance), at 31210e5

Decision needed:

Evidence

src/cable/Cable.cpp computeSegmentForces: GetSurfaceElevation (:458), GetParticleVelocity (:476) and GetDensity (:478), which recomputes the elevation through marenv GetSubmergence (EnvironmentFacade.cpp:267-273); GetSeaDepth is called as well. Each wave sum is O(N_waves). The Jacobian (addSegmentDragJacobian) repeats all of them. CHydroCylinder calls GetDensity in GetInertiaMatrix and again in GetInternalForces, plus GetSurfaceElevation per Gauss point.

Effect

About one redundant wave sum per segment per call in waves; negligible without waves.

Possible fix

Take the density from the elevation already computed, or from one PointEnvironmentQuery.

Why it is not fixed here

Deriving the density locally would copy marenv's 1025/1.2 rule into fhsim_base, a second source of truth that BASE-0054 (configurable density) would have to chase; a single PointEnvironmentQuery changes which fields are sampled. Both are refactors to do together with BASE-0054, not bit-identical one-liners.

Test that would prove it

Bit-identical ctest outputs, and a timing of a 50-element cable in 20 wave components.

Risk

Low; keep the density semantics of BASE-0054.

Update (R66, 2026-09-28)

Cable::computeSegmentForces no longer calls GetDensity per segment: the drag's density is the water density FinalSetup takes from the environment (as the submerged weight already did), and the surface elevation is skipped for segments below the environment's MaxWaveElevation bound (BASE-0058). CHydroCylinder::GetInternalForces and the polyplate forces likewise use the water density and skip the elevation below the bound; CHydroCylinder::GetInertiaMatrix still calls GetDensity. What remains is the Jacobian's repetition of the wave sums and the separate velocity and elevation sums near the surface. Since R67 (BASE-0059) each wetted segment in waves also evaluates GetParticleAcceleration (one more wave sum; skipped when the environment's bound is 0, i.e. without waves), and its Jacobian again.

Update (BASE-0054, 2026-09-30)

The water density is now the Rho parameter (Cable, CHydroCylinder, CHydroPolyplate), so the concern in "Why it is not fixed here" that the density rule would be copied into fhsim_base is gone: Cable no longer asks the environment for a density, and CHydroCylinder::GetInertiaMatrix and CHydroPolyplate::GetInertiaMatrix ask it once (submergence::MediumDensity) only to tell water from air. What remains is unchanged: the Jacobian repeats the wave sums, and the velocity, acceleration and elevation sums near the surface are separate.