Repository navigation
pycvc: fields, free surfaces and the field time (O6b) - #1140
Merged
Merged
Conversation
…the same on every platform Before O6 puts the sea into the physics state_hash, h0 and the shore layer must give the same bits on every platform; they called libm, whose transcendentals each platform rounds its own way (docs/roadmap/OCEAN-AND-WEATHER-ROADMAP.md, B1's open item). - cvc::physics's private det_math moves to cvc::algo as cvc/algo/det_math.h (standard library only), and gains exp, log, pow, sinh, cosh, acos and hypot. pow carries log x as a double-double and multiplies it by y exactly, so it stays within 3 ULP of libm even where y log x is large; y = 1, 2, -1 and 0.5 are one correctly rounded operation each. physics/det_math.h is now a namespace alias, so the physics step is unchanged (its bit pins and physics_replay_test hold). - cvc::ocean's spectrum, h0 and shore layer call det:: in place of std::, and are built without FMA contraction. cvc::ocean may now include cvc::algo (which depends on nothing). - algo_det_math_test (was physics_det_math_test) measures each new function against libm over the ranges the ocean uses, checks libm's special cases (pow's C99 Annex F table), and pins bits. ocean_spectrum_test and ocean_shore_test pin digests of the spectrum, h0 and the shore layer's planes, evaluate() and swash(), measured on Windows, for CI to check elsewhere.
…me (O6a) O6 of docs/roadmap/OCEAN-AND-WEATHER-ROADMAP.md, its B5 hook (decision D2, a virtual interface) and B6's tests. - cvc/physics/fluid_surface.h: fluid_surface (level, height, velocity, digest), still_surface (a level and a uniform current) and wave_train_surface (linear Airy trains, finite-depth dispersion, cosh/sinh decay, det_math throughout so it is the same on every platform). - field::surface, on a fluid only: field_set::apply clips each cell's top to the surface's height over its clipped centre, and drag and damping use the surface's velocity in place of the velocity volumes. - world::field_time(): t0 + (tick - tick0) dt. follow()'s first call anchors it to the clock's t(), so physics reads the surface at the time a renderer draws it; set_field_time sets it. - With a free surface, save() appends a section with the field-time anchor and each surface's digest, so state_hash() covers them and restore() refuses other surfaces. Without one the format is unchanged: every existing hash and the replay trace hold. - physics_field_test: half draft on calm water at two levels; heave in a 4 s swell in phase with the surface (correlation > 0.97), about as high, at the swell's period; the field time follows the clock; hashes agree for one surface and differ for another amplitude or field time; a save restores the field time and refuses another surface.
…rface # Conflicts: # src/cvc/CMakeLists.txt
physics_world gains add_field / set_field (a pycvc.volume and field's values, with a surface), remove_field, field_count, field_load_on, follow(clock), field_time and set_field_time; still_surface and wave_train_surface are C++'s classes, shared with the field; and physics_binding gains publish_field. PhysicsFluidSurface.CrossPlatformGoldenHash pins the swell scene's state hash, and test_pycvc_physics.py builds the same scene through pycvc and requires it.
transfix
enabled auto-merge (squash)
November 11, 2026 01:19
…/ocean-fluid-surface-py # Conflicts: # docs/roadmap/OCEAN-AND-WEATHER-ROADMAP.md # src/cvc/tests/physics_field_test.cpp
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.
O6b in
docs/roadmap/OCEAN-AND-WEATHER-ROADMAP.md: pycvc binds the fields, O6a's free surfaces and the field time, so Python can float a body on a sea and read it at the clock's time.#1139 (O6a) has merged and master is merged in, so the diff is O6b alone.
pycvc_physics.iphysics_world.add_field(volume, kind="fluid", velocity=None, drag_coefficient, damping, traction, ruts, rut_cell, surface=None)takes apycvc.volumeandfield's values as keywords. It returns the field's id, an int.velocityis None or three volumes.set_field(id, ...)takes the same keywords and sets the whole field, as C++'sset_fielddoes.remove_field,field_countandfield_load_on(body)(force, torque, immersed volume) work as in C++.physics_binding.publish_field(name, id)names a field in the state tree.still_surface(level, current=None)andwave_train_surface(level=0, depth=0, trains=[...], gravity=9.80665)are C++'s classes, held byshared_ptr.trainsis a list of dicts ofwave_train's fields. A key a dict leaves out keeps the default; an unknown key raises.level,height,velocityanddigest. A wave train also hastrain_count,train(i),wavenumber(i)andomega(i), withirange-checked.follow(clock)takes apycvc.world_clockand releases the GIL, asstepdoes.field_time()andset_field_time(t)are O6a's.Python reads the same values as C++
PhysicsFluidSurface.CrossPlatformGoldenHashpins the swell scene's state hash,f0085b4212e1a8c0. The scene is a slab and a ball in a 0.2 m, 4 s wave train, 300 steps from field time 3 s.det::, so a cross-platform deterministic Jolt should give that hash on every platform. This PR's Linux and macOS jobs are the first check of that.test_pycvc_physics.py. It builds the same scene call for call through pycvc and requires that hash. It also checks:publish_field:set_fieldkeeps the surface, and the run matches a world built with that damping;Checked locally (Windows Release, GL build with pycvc on)
pycvc_physics: 135 checks, including both golden hashes and the parity run.Physics*gtest (134, plus 2 skipped by design), andphysics_field_test(18).git clang-formatis clean.Next