Add hemisphere shell particle cloud packing - #1667
Conversation
|
I don't think this is implemented quite right. The example you added highlights this fact. It defines a hemispherical particle cloud using a cubic domain. I think instead you should add a Edit: Your |
|
Thanks Ben, that makes sense. I agree that the hemisphere shell should be treated as a particle-cloud geometry rather than a packing method. I’ll refactor this so that I’ll also remove or adjust the example so it does not imply that a cubic domain defines the hemispherical cloud. |
81e9038 to
933f66c
Compare
933f66c to
4aff083
Compare
BCKim55
left a comment
There was a problem hiding this comment.
Thanks for the feedback. I updated the hemisphere-shell path to remove the redundant box-bounds logic and rely on the shell radii for the placement region. I also changed the dimensionality checks to use num_dims < 3 and removed the extra direction variables in the 3D sampling path.
sbryngelson
left a comment
There was a problem hiding this comment.
Request changes
-
Missing regression coverage. This PR adds the hemisphere-shell execution path but removes the local example and adds no test fixture. The existing particle-cloud case is box-only, so CI never executes
geometry = 2. Please add a small deterministic 2D or 3D case that checks generated particle positions for shell/plane clearance and non-overlap. -
Documentation was not updated.
docs/documentation/case.mddoes not documentgeometry,shell_inner_radius, orshell_outer_radius, and itslength_[x,y,z]description is inaccurate forgeometry = 2, where those extents are ignored. Please update the Particle Clouds section accordingly.
|
Hi Spencer, I addressed the requested validation, documentation, and regression coverage changes. CI is now passing, and the PR is ready for another look when you have time. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1667 +/- ##
==========================================
+ Coverage 61.59% 61.63% +0.03%
==========================================
Files 84 84
Lines 21493 21567 +74
Branches 3176 3188 +12
==========================================
+ Hits 13239 13293 +54
- Misses 6078 6089 +11
- Partials 2176 2185 +9 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
sbryngelson
left a comment
There was a problem hiding this comment.
Thanks for the revisions. Documentation and validation are genuinely addressed:
case.mdnow documentsgeometry,shell_inner_radius,shell_outer_radius, and qualifieslength_x[y,z]as box-only.- The Python validator and
m_checker.fppnow enforce the same condition, andshell_outer_radius > shell_inner_radius + 2*radiusis exactly the sampler's feasibility requirement (r_outer > r_innerafter the +/- radius insets), so thes_mpi_abortpath is no longer reachable from valid input. geometryand both new reals are broadcast inm_mpi_proxy.fpp.- The sampling math is right: the 2D
sqrtCDF and the 3D cube-root CDF with uniformcos(polar)both give uniform density in the shell.
The test coverage point is not yet addressed, though, and that is the blocking item. Details inline.
|
Hi Spencer, I’ve pushed the latest fixes and the PR is ready for re-review. The blocking regression coverage item is now addressed for particle clouds. The new checks validate generated All GitHub checks are now passing: 60 success, 5 skipped, 0 failures. Thanks again! |
sbryngelson
left a comment
There was a problem hiding this comment.
Thanks for the revisions. The design is now right, and everything from my previous two rounds landed:
- The
geometrytocloud_geometryrename resolves the collision withgeom = 2(circle) andgeom = 8(sphere) in the same routine. - Integer exponents are back in the innermost loop, and
s_get_cloud_binnow runs once per candidate. - The Python mirror implementation is gone in favour of parsing real
ib_state_0.datoutput. - 2D, 3D, and box goldens all exist. All six golden dirs are new, so the squared-distance refactor did not perturb the box path.
- Sampling math verified independently: the 2D sqrt radial CDF and the 3D cube-root CDF with uniform
cos(polar)both give uniform density, and the plane-clearance cut preserves uniformity on the remaining region.
./mfc.sh precheck passes all 7 checks, the 4 new pytest cases pass, and ./mfc.sh test -l lists exactly the 6 new cases matching the 6 new golden dirs.
What is left is one test-fixture problem that undermines the 3D coverage I asked for, a validation-surface gap, and two latent bugs. Details inline.
Blocking
- The 3D particles are sub-cell (
radius = 0.6*dx), so the 3D golden may not be observing the feature it was added to cover. The 2D goldens do carry real signal; only the 3D case needs fixing. - The box branch of the new
ib_stateassertion is only valid forpacking_method = 1. Separately, this exposed what looks like a genuine pre-existing bug ins_particle_cloud_lattice: its outer loops have noymax/zmaxbound, so lattice clouds can place particles outside the declared region and potentially outside the domain. Not yours to fix here, but it should get an issue. - The
m_checkershell-thickness guard is vacuous whenradiusis unset, sincedflt_real = -1.e6_wpswamps the right-hand side. More broadly, nothing requiresradius,mass, ornum_particlesto be set for any cloud. - Domain containment is enforced only in
case_validator.py. Please mirror it intom_checker, same as you did for the radii checks. cloud_geometry = 2is unguarded in 1D.
Design, and the one I would push hardest on
s_particle_cloud_random_hemi_shell is still a near-verbatim copy of s_particle_cloud_random_box. Extracting the overlap check was the right first step, but roughly 60 of its 110 lines are still duplicated. Collapsing both into a single rejection packer with a geometry select case inside the loop removes that and flattens the dispatch in s_generate_particle_clouds. The cloud_geometry enum invites a third geometry, and a third geometry triples the copy.
Housekeeping
The PR description is stale. It still describes particle_cloud(i)%packing_method = 3, which is the design @wilfonba asked you to change, and it lists examples/3D_mibm_particle_cloud_hemi_shell/case.py under Testing though no such example is in the PR. Release notes get assembled from PR bodies, so please fix it before merge.
…state precision Collapse s_particle_cloud_random_box/_hemi_shell into one s_particle_cloud_rejection_pack with a geometry-specific candidate sampler and flat packing-method dispatch (net -254 LOC in simulation/); fix f_xorshift sign-bit fold that could place a NaN centre; drop the dead redundant shell-radii check. Move input-only guards to case_validator.py (radius/mass/num_particles positivity, 1D hemisphere reject, one-radius wall standoff, _is_numeric guards). Make the ib_state test reader key field width and tolerance off the --single build flag only (wp stays double under --mixed), name the record-layout constants, guard file_per_process, and gate the box-bounds assertion on packing_method==1. Give the 3D golden a cell-spanning radius, the 2D case a wall standoff, and the box case ~50 particles. Revert an unrelated lag_params reflow and document the shell orientation/containment rules.
|
Architectural note for after this lands (tracked in #1737): the particle-cloud packer is really geometry preprocessing — rejection/lattice/hemisphere-shell/periodic sampling, spatial hashing — that currently sits in the solver startup only because IBM marker computation is simulation-side. It'd be cleaner to expand the compact |
Description
Adds a hemisphere-shell particle cloud packing option for immersed-boundary particle clouds.
This introduces
particle_cloud(i)%packing_method = 3, which randomly places spherical/circular IBM particles inside a hemisphere-shell region while enforcing:This also adds
shell_inner_radiusandshell_outer_radiusparticle cloud parameters. The local verification example was removed from this PR to avoid introducing a new golden test in the same change.Type of change
Testing
./mfc.sh format./mfc.sh validate examples/*/case.py./mfc.sh validate examples/3D_mibm_particle_cloud_hemi_shell/case.py./mfc.sh run examples/3D_mibm_particle_cloud_hemi_shell/case.py --clean --no-debugAdditional local checks:
ib_state_0.datparticle positions.min_spacing=0.02.min_spacing=0.0.Checklist
GPU changes (expand if you modified
src/simulation/)