FhSim  3.1.0
Marine systems simulation
Loading...
Searching...
No Matches
0065 — Polyplate soil forces allocate on the heap on every right-hand side
ID 0065
Class ARCHITECTURE
Severity 1
Status ready

Models: FlukeAnchor, TorpedoAnchor

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

Decision needed:

Evidence

src/rigidbody/PolyplateEnvironmentForces.cpp:19: SplitPolygon does new double[n] / delete[] per call. :115-116 (CalcSoilforcesPolyplate): two std::vector<double>(numPoints + 40) on every call, also when the plate is far above the seabed, and two more (:122-123) when it touches.

Effect

Several small allocations per plate per right-hand side; measurable only in long anchor runs.

Possible fix

Fixed-size stack buffers (the polygon has at most numPoints + 4 points after two splits), or an early return when the plate's lowest point is above the seabed.

Why it is not fixed here

The allocations are not proven to matter (no timing), and the early return needs the plate's lowest point, new geometry code; the brief allows performance fixes only when bit-identical and certain, and the gain is unmeasured.

Test that would prove it

Bit-identical anchor outputs and a timing before and after.

Risk

Low.