Repository navigation
Physics wake: shores, depth and the wake in water_at (C5's gaps, C6) - #1532
Merged
Merged
Conversation
Fill the open gaps in the opt-in physics wake (wake_push), the "Not in C5"
list of OCEAN-AND-WEATHER-ROADMAP.md:
- Shores (C6). field_wake::shore (a wake_shore, field.h) masks the window
from the coast wherever it goes, each cell from its world cell. With a mask
the window steps by ewave's no-flux step in whole substeps of the wave
step, sources go in times the mask, and reads beside a wall are one-sided.
shore_grid_mask (shore_mask.h) is the drawn window's mask over a
water_bodies shore grid: 0 on land, a 3 m beach ramp to 0.5, 1 to the
waterline where steep. The water node's wake_push takes its coast's mask.
- Depth. Each wave state keeps its motion at 1-5 depths below the top (per
mode e^{-kd}, or cosh/sinh over the window's depth; extended past walls by
the ghosts), as deep as the bodies in the window reach. Cells' drag, hull
triangles' velocity terms and the Froude-Krylov push (at the displaced
water's centroid depth) read it at their depth.
- water_at. world::water_at(p) adds every body's waves; water_at(p, self)
the others'. A boat's propeller and rudder read the others' waves (in
boat.cpp only the hull body is passed to its two water reads), and
dyn_boat_plant's books read them at the same points.
The wake section is CVCWAKE2 (each wake's shore digest and the depths kept);
CVCWAKE1 states restore as wakes without shores.
With wake_push off nothing new runs: physics_replay's trace and every other
golden stand. PhysicsFieldWake.CrossPlatformGoldenHash is re-pinned from
0x7a5a40b81d1d2433 to 0xc72e26b4ef0f764a because depth decay is on for every
wake: the crates' and the boat's reads of the others' waves now decay below
the top (without a shore the wave step itself is unchanged). The new
PhysicsFieldWakeShore.CrossPlatformGoldenHash pins a wake with a coast at
0x89789ba92fbd1853. Both measured on Windows; CI checks Linux, macOS and wasm.
ADroppedCratesRingRocksItsNeighbour now asks that both crates made waves
during the run, not that both hold a slot at the last step: the dropped crate
is put to sleep and woken again and again by its neighbour's waves, and with
depth it happens to be asleep at step 900. AWindowOutOfRangeIsRefused follows
the CVCWAKE2 layout.
GCC and Clang refuse a default argument `= {}` of a class nested in the
class whose member function declares it, when that nested class has default
member initializers ("default member initializer for 'on' needed within
definition of enclosing class"); MSVC takes it. Every Linux and wasm job of
#1532 failed on it in field_step.h. The struct is now
detail::water_wake_read, declared before field_set, with
field_set::wake_read kept as an alias, so boat.cpp is unchanged.
Checked with clang-cl 19 (/Zs) over every file the PR touches, which
reproduces the CI error on the old form.
This was referenced Nov 26, 2026
transfix
added a commit
that referenced
this pull request
Nov 26, 2026
…d on #1532) (#1540) * Physics wake: shores, depth and the wake in water_at (C5's gaps, C6) Fill the open gaps in the opt-in physics wake (wake_push), the "Not in C5" list of OCEAN-AND-WEATHER-ROADMAP.md: - Shores (C6). field_wake::shore (a wake_shore, field.h) masks the window from the coast wherever it goes, each cell from its world cell. With a mask the window steps by ewave's no-flux step in whole substeps of the wave step, sources go in times the mask, and reads beside a wall are one-sided. shore_grid_mask (shore_mask.h) is the drawn window's mask over a water_bodies shore grid: 0 on land, a 3 m beach ramp to 0.5, 1 to the waterline where steep. The water node's wake_push takes its coast's mask. - Depth. Each wave state keeps its motion at 1-5 depths below the top (per mode e^{-kd}, or cosh/sinh over the window's depth; extended past walls by the ghosts), as deep as the bodies in the window reach. Cells' drag, hull triangles' velocity terms and the Froude-Krylov push (at the displaced water's centroid depth) read it at their depth. - water_at. world::water_at(p) adds every body's waves; water_at(p, self) the others'. A boat's propeller and rudder read the others' waves (in boat.cpp only the hull body is passed to its two water reads), and dyn_boat_plant's books read them at the same points. The wake section is CVCWAKE2 (each wake's shore digest and the depths kept); CVCWAKE1 states restore as wakes without shores. With wake_push off nothing new runs: physics_replay's trace and every other golden stand. PhysicsFieldWake.CrossPlatformGoldenHash is re-pinned from 0x7a5a40b81d1d2433 to 0xc72e26b4ef0f764a because depth decay is on for every wake: the crates' and the boat's reads of the others' waves now decay below the top (without a shore the wave step itself is unchanged). The new PhysicsFieldWakeShore.CrossPlatformGoldenHash pins a wake with a coast at 0x89789ba92fbd1853. Both measured on Windows; CI checks Linux, macOS and wasm. ADroppedCratesRingRocksItsNeighbour now asks that both crates made waves during the run, not that both hold a slot at the last step: the dropped crate is put to sleep and woken again and again by its neighbour's waves, and with depth it happens to be asleep at step 900. AWindowOutOfRangeIsRefused follows the CVCWAKE2 layout. * field_set::water_at: default its wake read from a namespace-scope struct GCC and Clang refuse a default argument `= {}` of a class nested in the class whose member function declares it, when that nested class has default member initializers ("default member initializer for 'on' needed within definition of enclosing class"); MSVC takes it. Every Linux and wasm job of #1532 failed on it in field_step.h. The struct is now detail::water_wake_read, declared before field_set, with field_set::wake_read kept as an alias, so boat.cpp is unchanged. Checked with clang-cl 19 (/Zs) over every file the PR touches, which reproduces the CI error on the old form. * water node: the drawn wake window's mask from shore_grid_mask The GPU wake window in src/cvcGL/ariadne/water_node.cpp built its mask with its own copy of the formula that cvc::physics::shore_grid_mask (#1532) uses for the physics wake: 0 on land, a 3 m beach ramp from 1 down to 0.5, 1 up to the waterline where the shore layer's K_r or the ground's slope says it is steep. place_wake now makes one shore_grid_mask per coast and reads it at each window cell. The copy and its grid_sample are gone, so the drawn mask and the physics mask can't drift apart. The window's mean water depth over its wet cells stays in water_node.cpp. It samples the grid's depth with shore_grid_mask::sample, which is now public. The window holds the coast it took its mask from as a shared_ptr, so a new coast at a freed one's address can't be taken for it. The old formula and the new path match bit for bit at every window cell and in the mean depth. That covers 1.39e9 cells over 33,856 windows on terrain_lab's coasts, a beach with a cliff and synthetic grids with NaN, inf and K_r above 1, and 166 window placements in a rendered water node with body: over a lake and an island with a swell.
transfix
added a commit
that referenced
this pull request
Nov 27, 2026
…cally, same bits) (#1562) PhysicsFieldWake.PackedBodiesStayBoundedAndSleep took 581-747 s of its 1200 s ctest budget on package-linux / libcvc-debug and timed out three times on a slow runner (#1550's). It took 269 s there on #1344; #1532 made every wake test 2.5-2.8x slower in Debug (the ring 3.0 to 8.2 s, the golden 2.4 to 5.8 s, this one 269 to 702 s). The test itself is as #1344 wrote it. Profiled locally (Debug, MSVC /Od): the calm run with a wake is 62% of the test, and 87% of that is the wake's wave step: deepen, the motion below the top that #1532 added (2 forward and ~3 inverse 64 x 64 FFTs a state a wave step), 51%; the ewave step 21%; sum, which now adds the depths, 9%. In an unoptimized build std::vector's operator[] is a call per element, and these passes made ~400k of them a state a wave step. And once every crate sleeps (~90 s into the calm run) the wake made depths for ~30 s more, while its waves died away, with nothing reading them. - fluid_wake::ready_depths: the depths are made at the first read after a wave step (in field_set::apply before the field workers' reads, when an awake body is in the wake's field, and in field_set::water_at), not at every wave step. The same inputs in the same order: the same bits. motion() reads only the layers that were made. - The wake's per-cell passes (deepen, derive, sum, the wave step's dh/dt) and fft_plan::run_2d's gather and scatter index through raw pointers: the same operations in the same order. On their own, 28% off a 20 s calm run with a wake in Debug (37.5 s to 27.1 s, three interleaved runs, the same peaks to 17 digits). - The test is two: the calm half keeps its name (and #1557's 3600 s), the swell's half is PackedBodiesStayBoundedInASwell, so each has its own ctest budget and ctest runs them side by side. What the comments claimed is now asserted too: every crate sleeps on calm water (9 of 9) and none in the swell (0 and 0). "Without one they sleep within 40" is 3 (2.55 s). Measured locally, Debug, the old and new builds run side by side on one loaded box: 283.6 s before; after, the calm half 72.5 s and the swell's 87.8 s (160.3 s). Every value the test prints is the same to the digit. No pinned hash moves: the wake golden 0xc72e26b4ef0f764a, the shore golden 0x89789ba92fbd1853, the swell and ocean scenes.
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.
Fills the open gaps in the opt-in physics wake (C5,
wake_push) listed under "Not in C5" indocs/roadmap/OCEAN-AND-WEATHER-ROADMAP.md: shores (C6), depth, and the wake inworld::water_at.What changed
Shores (C6).
field_wake::shore(a newwake_shoreinterface infield.h) masks the wake's window from the coast wherever the window goes. Each window cell takes the mask of its world cell, so the waves that move with the window keep their walls. With a mask, the window steps by eWave's no-flux step (O8c: ghosts, symmetric operator) in whole substeps of the wave step, so the shared engine carries no remainder from one state to the next. Sources are multiplied by the mask, and reads beside a wall use one-sided differences.shore_grid_mask(inc/cvc/physics/shore_mask.h, new) is the drawn window's mask formula (the water node'swake_mask, lsystem_coast's seaWakeMask) over awater_bodiesshore grid. It is 0 on land, a 3 m beach ramp from 1 down to 0.5, and 1 up to the waterline where the shore is steep.wake_pushnow gives its wake the coast's mask: one mask per coast, so a new keyframe of the sea keeps the waves.Depth. Each wave state keeps its motion (∇φ, dh/dt and ∇h) at 1–5 depths below the top, as deep as the bodies in the window reach. Each depth is filtered per mode: e^{−kd} in deep water, cosh and sinh over the window's depth otherwise. The fields are extended past the walls by the ghosts first, so the walls stay no-flux at depth.
The wake in
water_at.world::water_at(p)now adds every body's waves (height into the top, motion at the point's depth). The newworld::water_at(p, self)adds only the others' waves. A boat's propeller and rudder read the others' waves, never the boat's own.boat.cpp: the only change is passing the hull body to its two water reads (prop and rudder), 6 lines. The hull-lift session working inhull.cpp/boat.cppshould see no overlap.dyn_boat_plant: its books read the same points, with the hull body passed.World state. The wake section is now
CVCWAKE2: each wake's shore flag and digest, and the count of depths kept. A world with another shore, or none, refuses the state.CVCWAKE1states restore as wakes without a shore.Hashes
wake_pushoff nothing new runs:physics_replay_test's trace matches at all 1240 steps, and every other golden stands.PhysicsFieldWake.CrossPlatformGoldenHashis re-pinned 0x7a5a40b81d1d2433 → 0xc72e26b4ef0f764a. Depth decay is on for every wake: the crates' and the boat's reads of the others' waves now decay below the top. The wave step itself is unchanged without a shore.PhysicsFieldWakeShore.CrossPlatformGoldenHash: a wake with a coast, at 0x89789ba92fbd1853.Tests (each fails with its change switched off)
AWakeReflectsOffACliffAndSoaksIntoABeach: the cliff's reflection is 100 % of the image ring's RMS, correlation 0.997 (a crest comes back a crest). The beach leaves 39 % of that. The land holds 0 at every step; on open water the ring reaches 0.0365 m there.APondReflectsOffAllItsBanks: late waves halfway to each bank are ≥ 27.8× open water's. The land holds 0. The sea past 8 m of land gets 2.4 % of the pond's peak (the spectral operator's known leak through land).ADeepBodyFeelsLessOfTheWavesThanOneAfloat: a cube 3.5 m down is pushed 15.8 N against 162 N for one just under the surface, and moves 0.0084 m against 0.0285 m. With depth switched off both cubes move alike.APropellerInAnotherBoatsWakeReadsItsOrbitalMotion: a moored launch's propeller reads 0.152 m/s of a passing launch's wake (0 before), and the boat's step matcheswater_atexactly. The runner reads 0.309 m/s of all the waves at its own propeller and 0.0038 m/s of the others'.CVCWAKE1state restores.Changed expectations in existing tests
ADroppedCratesRingRocksItsNeighbournow checks that both crates made waves during the run, not at the last step. The dropped crate is put to sleep and woken again and again by its neighbour's waves; with depth it happens to be asleep at step 900.AWindowOutOfRangeIsRefusedreads the save layout, so it now followsCVCWAKE2.Run locally (Windows, MSVC Release, Jolt, cvcGL off)
All
physics_*suites (physics_field_test 52),physics_replay_testwith its trace, allocean_*suites (ocean_ewave_test 18), andariadne_scene_world_test(135 passed, the fleet benchmark skipped as usual). In the lake scene, the moored launch in the runner's wake now heaves 0.035 m, drifts 0.169 m and rolls 0.045 rad (0.037 m, 0.131 m and 0.046 rad before), with the lake's banks masked. Cost: one source by a cliff costs 0.140 ms of field push a step, against 0.114 ms on open water; two sources on still water cost 0.296 ms with depth, against 0.233 ms before.Not done / limits
vehicle.cpp) still reads the water without the wake.dyn_boat_plant's books read at the step's start, so at a wave step they are one wave step behind what the boat reads.wake_mask(cvcGLwater_node.cpp) keeps its own copy of the formula; cvcGL was not built here..arikey, so no schema change.field::wake, andfield_wake::shoreis new for it.