Repository navigation
Faster hydrodynamic kernels: convolutions, wave set-up and nonlinear mesh loops - #25
Merged
Merged
Conversation
dav-og
force-pushed
the
perf/numerical-kernels
branch
from
December 3, 2026 14:27
ccd7341 to
1169769
Compare
RadiationRirfConvolution had no unit test. test_radiation_rirf_convolution checks it on synthetic kernels against a term-by-term evaluation of F_i = sum_j sum_k K_ij(tau_k) w_k v_j(t - tau_k): time steps equal to, an integer fraction of and not commensurate with the lag spacing, a variable step, a non-uniform lag grid, start-up, two bodies, a truncated kernel and rejected inputs. test_radiation_component checks RadiationComponent on the bundled sphere and RM3 kernels, as stored, smoothed, truncated and with a yawed body.
Builds a HydroModel from each demo BEM file with HydroModelBuilder and times radiation, excitation and hydrostatics / nonlinear Froude-Krylov through HydroForces' profiling counters, with a prescribed body motion. Prints microseconds per evaluation as CSV. Run by hand; not a CTest test.
The 'Chrono Solver' line was the loop time minus hydrostatics, radiation and excitation, so it also held MoorDyn and the damping and external components. HydroForces now times damping and external components as well, the profile lists 'Mooring' and 'Damping + External' when present, and 'Chrono Solver' excludes them.
Chrono regenerates the geometry of every point-to-point visual shape on a link at each time step, drawn or not; a SPRING coil is rebuilt point by point with heap allocation. With --nogui this took 10% of the loop for RM3 (one PTO spring) and 22% for 5SA regular waves (16 ram springs). RemoveLinkVisualShapes() clears the link shapes; run_seastack calls it for headless runs once the replay scene is written, and the 5SA demos and benchmark call it when no viewer is requested. VizExtractor reads a link's shape once and afterwards uses only its end points, so replay data is unchanged. Results are bit-identical.
…velocity record. The convolution term of the Cummins equation is now computed with one dot product per non-zero kernel K_ij against the lagged velocity of degree of freedom j. Trapezoid weights are folded into the stored kernel, identically zero kernels and degrees of freedom that have not moved are skipped, and the velocity record (new class VelocityHistory) is a contiguous array in time order. When the recorded samples coincide with the lag grid the lagged velocities are read directly from the record; otherwise they are interpolated linearly as before. The quadrature is unchanged; results differ from the previous implementation by rounding only. The kernel runs on one thread and gives the same result for any OMP_NUM_THREADS. Interface: RadiationRirfConvolution::ComputeForces(callback, kernel) is replaced by SetKernel() and ComputeForces(). The lag grid must be non-negative and strictly increasing. A time earlier than the newest sample (a repeated integrator step) discards the samples at or after it, with a warning reported once; an equal time still throws.
For a wave made of components the sum over the kernel lags is carried out once, giving per-component coefficients C_i and S_i, so that F(t) = sum_i A_i [C_i cos(theta_i) - S_i sin(theta_i)] with theta_i = phi_i - omega_i t. The lags still inside the start-up ramp are corrected with a direct sum over those lags only. This is the same quadrature in another order; results differ from the direct sum by rounding. The direct sum is kept for eta-table waves, while every lag is inside the ramp, while a change of wave height is inside the kernel window, and for live period or direction changes. AmplitudeEnvelope::IsConstantOver() identifies the intervals on which the wave-height factor is constant, so a schedule that leaves the wave height unchanged stays bit-identical to a run without one.
Components of equal frequency are added together when the component is built, giving F(t) = sum_m [P_m cos(omega_m t) + Q_m sin(omega_m t)] over the distinct frequencies. A sea with directional spreading has n_omega x n_theta components but n_omega frequencies, so each time step needs n_theta times fewer cosines and sines. The terms are those of the sum over components in another order; results differ by rounding. The sum over components is kept during and after a live change of wave period or direction.
…d count. The coefficients were formed with one matrix-matrix product, which Eigen splits between the OpenMP threads; the rounding then depended on the number of threads (differences of 1e-11 in the excitation force). They are now formed with one matrix-vector product per wave component, which runs on one thread. Results are bit-identical for any OMP_NUM_THREADS.
…ation series. BuildFromEtaFile: every angle of the transform at the Fourier frequencies is a multiple of 2 pi / N, so the cosines and sines are taken from a table of N values in place of two library calls per term, and the frequencies are summed in parallel (one thread per frequency, so the result does not depend on the thread count). Component amplitudes and phases differ from the previous values by rounding. ComputeElevationTimeSeries is now virtual. LinearDirectionalWaveField adds the components of equal frequency into one cosine before the time loop: a sea with directional spreading needs one cosine per frequency and time instead of one per component. For a long-crested sea the series is identical to the previous one.
…e-Krylov. The submerged-volume and pressure integrals and the vertex transform now work on plain doubles (internal type Vec3). The same formulas written with Eigen::Vector3d took about ten times as long per mesh face in the Windows release build. The per-face heap allocations of the waterline clipping are gone. Results differ from the previous ones by rounding. LinearDirectionalWaveField::GetElevationAndPressureHead works through the points one component at a time for a regular wave or up to 8 components, so each cosine and exponential is one array operation over all mesh vertices. Seas with more components keep the point-by-point loop. TriangleMesh gains TransformVertices().
…ows. A regular wave now costs about 0.1 ms per time step for the 8064-face sphere mesh, and the wave evaluation runs in parallel only for more than 8 wave components.
… over the lags. While some lags still look back into the start-up ramp, the excitation convolution was corrected with a direct sum over all of those lags at every step. The ramp factor r(t - tau) of the linear and cosine ramps is a sum of a few products of a function of t and a function of tau, so the contribution of the ramping lags is a combination of sums over ranges of lags. These are now taken from partial sums stored at every 16th lag (or a larger spacing, to keep the tables below 64 MB); only the lags between a range end and the nearest stored sum are summed directly. The result is the same sum in another order and differs by rounding. After the ramp window the evaluation is unchanged. The case in which every lag is still inside the ramp, which used the direct sum, is evaluated in the same way.
dav-og
force-pushed
the
perf/numerical-kernels
branch
from
December 3, 2026 18:57
1169769 to
5434c88
Compare
dav-og
marked this pull request as ready for review
December 3, 2026 20:11
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.
Summary
[IMPROVEMENT]Restructures the numerical kernels that dominate a SEA-Stack run. Thephysics, numerical methods, defaults, YAML inputs and results-file layout are unchanged:
each kernel computes the same sum as before in a different order or with a different data
layout, so results agree with v1.2.0 to rounding.
VelocityHistory); trapezoid weights folded into the stored kernel; recorded samples used directly when they fall on the lag grid; single-threaded[BUG FIX]Chrono no longer regenerates spring visual shapes at every step when there is no viewerAlso adds
bench_hydro_kernels(force-component timing without Chrono) and separate"Mooring" and "Damping + External" lines in
run_seastack --profile.Effect
Measured on a 16-core Windows desktop over the 43 demo cases:
about 2.2x); the two crane cases and the state-space and constant-coefficient cases are
essentially unchanged.
larger factor and concurrent runs (campaigns) no longer compete for threads.
OMP_NUM_THREADS: runs with 1, 8 and 32 threads arebit-identical. This removes the limitation "Joint reaction loads and thread count" of
the v1.2.0 release notes.
iterative linear solver the difference is of the size v1.2.0 itself shows between two
thread counts.
Compatibility
[COMPATIBILITY]RadiationRirfConvolution::ComputeForces(callback, kernel)is replaced bySetKernel()(once) andComputeForces(). The header is installed; code that usesthis class directly must be adapted.
RadiationComponentand the YAML interface areunchanged.
throws otherwise.
the samples at or after it and logs one warning. An equal time still throws.
run_seastack --profile: "Chrono Solver" no longer includes mooring and damping time.WaveBase::ComputeElevationTimeSeries()is now virtual. New public interface:VelocityHistory,AmplitudeEnvelope::IsConstantOver(),TriangleMesh::TransformVertices(),RemoveLinkVisualShapes().Testing
(15), comparison (30) and external-module (3) suites pass. No reference data was
regenerated and no tolerance was changed.
same sum:
test_radiation_component,test_excitation_irf_closed_form,test_excitation_frequency_sums,test_eta_file_components,test_elevation_time_series;test_radiation_rirf_convolution,test_amplitude_envelope,test_wave_pressureandtest_viz_extractorare extended.carries the
full-testslabel so that verification and comparison run on everyplatform.
Suggested release-note entries
nonlinear hydrostatics and Froude-Krylov mesh loops were restructured. Typical runs are
about twice as fast and use a single core; results agree with v1.2.0 to rounding.
run_seastack --profilelists mooring and damping time separately.RadiationRirfConvolutiontakes its kernel throughSetKernel()andComputeForces()has no arguments.