peclet-core 1.3.2__tar.gz → 1.5.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {peclet_core-1.3.2 → peclet_core-1.5.0}/.github/workflows/quality.yml +8 -0
- {peclet_core-1.3.2 → peclet_core-1.5.0}/CITATION.cff +2 -2
- {peclet_core-1.3.2 → peclet_core-1.5.0}/CLAUDE.md +25 -2
- {peclet_core-1.3.2 → peclet_core-1.5.0}/PKG-INFO +8 -3
- {peclet_core-1.3.2 → peclet_core-1.5.0}/README.md +7 -2
- {peclet_core-1.3.2 → peclet_core-1.5.0}/docs/Doxyfile +1 -1
- peclet_core-1.5.0/include/peclet/core/scheme/cut_cell_geometry.hpp +497 -0
- peclet_core-1.5.0/include/peclet/core/scheme/probe_flux.hpp +248 -0
- peclet_core-1.5.0/include/peclet/core/solver/anderson.hpp +892 -0
- peclet_core-1.5.0/include/peclet/core/solver/anderson_mpi.hpp +34 -0
- {peclet_core-1.3.2 → peclet_core-1.5.0}/include/peclet/core/vof/curvature.hpp +322 -17
- {peclet_core-1.3.2 → peclet_core-1.5.0}/packaging/pyproject-core.toml +1 -1
- {peclet_core-1.3.2 → peclet_core-1.5.0}/pyproject.toml +1 -1
- {peclet_core-1.3.2 → peclet_core-1.5.0}/tests/CMakeLists.txt +46 -0
- peclet_core-1.5.0/tests/anderson_test_maps.hpp +96 -0
- peclet_core-1.5.0/tests/test_anderson.cpp +832 -0
- peclet_core-1.5.0/tests/test_anderson_mpi.cpp +248 -0
- peclet_core-1.5.0/tests/test_cut_cell_geometry.cpp +325 -0
- peclet_core-1.5.0/tests/test_probe_flux.cpp +311 -0
- peclet_core-1.5.0/tests/test_vof_pvcache.cpp +862 -0
- peclet_core-1.5.0/tools/check_mpi_manifest.sh +80 -0
- {peclet_core-1.3.2 → peclet_core-1.5.0}/.clang-format +0 -0
- {peclet_core-1.3.2 → peclet_core-1.5.0}/.clang-tidy +0 -0
- {peclet_core-1.3.2 → peclet_core-1.5.0}/.github/ISSUE_TEMPLATE/bug_report.yml +0 -0
- {peclet_core-1.3.2 → peclet_core-1.5.0}/.github/ISSUE_TEMPLATE/feature_request.yml +0 -0
- {peclet_core-1.3.2 → peclet_core-1.5.0}/.github/PULL_REQUEST_TEMPLATE.md +0 -0
- {peclet_core-1.3.2 → peclet_core-1.5.0}/.github/dependabot.yml +0 -0
- {peclet_core-1.3.2 → peclet_core-1.5.0}/.github/workflows/ci.yml +0 -0
- {peclet_core-1.3.2 → peclet_core-1.5.0}/.github/workflows/docs.yml +0 -0
- {peclet_core-1.3.2 → peclet_core-1.5.0}/.github/workflows/release.yml +0 -0
- {peclet_core-1.3.2 → peclet_core-1.5.0}/.gitignore +0 -0
- {peclet_core-1.3.2 → peclet_core-1.5.0}/CMakeLists.txt +0 -0
- {peclet_core-1.3.2 → peclet_core-1.5.0}/LICENSE +0 -0
- {peclet_core-1.3.2 → peclet_core-1.5.0}/benchmarks/CMakeLists.txt +0 -0
- {peclet_core-1.3.2 → peclet_core-1.5.0}/benchmarks/bench_halo.cpp +0 -0
- {peclet_core-1.3.2 → peclet_core-1.5.0}/cmake/PecletCorePinMpiexec.cmake +0 -0
- {peclet_core-1.3.2 → peclet_core-1.5.0}/cmake/PecletCoreTest.cmake +0 -0
- {peclet_core-1.3.2 → peclet_core-1.5.0}/cmake/SuiteNanobind.cmake +0 -0
- {peclet_core-1.3.2 → peclet_core-1.5.0}/cmake/peclet-coreConfig.cmake.in +0 -0
- {peclet_core-1.3.2 → peclet_core-1.5.0}/docs/archive/README.md +0 -0
- {peclet_core-1.3.2 → peclet_core-1.5.0}/docs/archive/cuda-aware-mpi.md +0 -0
- {peclet_core-1.3.2 → peclet_core-1.5.0}/include/peclet/core/common/cpu_budget.hpp +0 -0
- {peclet_core-1.3.2 → peclet_core-1.5.0}/include/peclet/core/common/host_parallel.hpp +0 -0
- {peclet_core-1.3.2 → peclet_core-1.5.0}/include/peclet/core/common/mpi.hpp +0 -0
- {peclet_core-1.3.2 → peclet_core-1.5.0}/include/peclet/core/common/mpi_stub.hpp +0 -0
- {peclet_core-1.3.2 → peclet_core-1.5.0}/include/peclet/core/common/portable.hpp +0 -0
- {peclet_core-1.3.2 → peclet_core-1.5.0}/include/peclet/core/common/types.hpp +0 -0
- {peclet_core-1.3.2 → peclet_core-1.5.0}/include/peclet/core/common/view.hpp +0 -0
- {peclet_core-1.3.2 → peclet_core-1.5.0}/include/peclet/core/decomp/block_decomposer.hpp +0 -0
- {peclet_core-1.3.2 → peclet_core-1.5.0}/include/peclet/core/decomp/block_indexer.hpp +0 -0
- {peclet_core-1.3.2 → peclet_core-1.5.0}/include/peclet/core/decomp/gather_by_global_id.hpp +0 -0
- {peclet_core-1.3.2 → peclet_core-1.5.0}/include/peclet/core/decomp/grid_redistribute.hpp +0 -0
- {peclet_core-1.3.2 → peclet_core-1.5.0}/include/peclet/core/decomp/morton_indexer.hpp +0 -0
- {peclet_core-1.3.2 → peclet_core-1.5.0}/include/peclet/core/decomp/redistribute_topology.hpp +0 -0
- {peclet_core-1.3.2 → peclet_core-1.5.0}/include/peclet/core/decomp/stage_comm.hpp +0 -0
- {peclet_core-1.3.2 → peclet_core-1.5.0}/include/peclet/core/decomp/stage_target.hpp +0 -0
- {peclet_core-1.3.2 → peclet_core-1.5.0}/include/peclet/core/domain.hpp +0 -0
- {peclet_core-1.3.2 → peclet_core-1.5.0}/include/peclet/core/field/field_set.hpp +0 -0
- {peclet_core-1.3.2 → peclet_core-1.5.0}/include/peclet/core/geom/body_properties.hpp +0 -0
- {peclet_core-1.3.2 → peclet_core-1.5.0}/include/peclet/core/geom/device_scene.hpp +0 -0
- {peclet_core-1.3.2 → peclet_core-1.5.0}/include/peclet/core/geom/grid_sdf.hpp +0 -0
- {peclet_core-1.3.2 → peclet_core-1.5.0}/include/peclet/core/geom/primitives.hpp +0 -0
- {peclet_core-1.3.2 → peclet_core-1.5.0}/include/peclet/core/geom/quadrature.hpp +0 -0
- {peclet_core-1.3.2 → peclet_core-1.5.0}/include/peclet/core/geom/scene.hpp +0 -0
- {peclet_core-1.3.2 → peclet_core-1.5.0}/include/peclet/core/geom/scene_builder.hpp +0 -0
- {peclet_core-1.3.2 → peclet_core-1.5.0}/include/peclet/core/geom/scene_query.hpp +0 -0
- {peclet_core-1.3.2 → peclet_core-1.5.0}/include/peclet/core/geom/sdf.hpp +0 -0
- {peclet_core-1.3.2 → peclet_core-1.5.0}/include/peclet/core/geom/vti_io.hpp +0 -0
- {peclet_core-1.3.2 → peclet_core-1.5.0}/include/peclet/core/halo/grid_halo.hpp +0 -0
- {peclet_core-1.3.2 → peclet_core-1.5.0}/include/peclet/core/halo/grid_halo_topology.hpp +0 -0
- {peclet_core-1.3.2 → peclet_core-1.5.0}/include/peclet/core/halo/nbx.hpp +0 -0
- {peclet_core-1.3.2 → peclet_core-1.5.0}/include/peclet/core/halo/particle_halo.hpp +0 -0
- {peclet_core-1.3.2 → peclet_core-1.5.0}/include/peclet/core/halo/particle_halo_topology.hpp +0 -0
- {peclet_core-1.3.2 → peclet_core-1.5.0}/include/peclet/core/halo/particle_migrator.hpp +0 -0
- {peclet_core-1.3.2 → peclet_core-1.5.0}/include/peclet/core/halo/particle_migrator_view.hpp +0 -0
- {peclet_core-1.3.2 → peclet_core-1.5.0}/include/peclet/core/halo/particle_rebalance.hpp +0 -0
- {peclet_core-1.3.2 → peclet_core-1.5.0}/include/peclet/core/interp/particle_grid.hpp +0 -0
- {peclet_core-1.3.2 → peclet_core-1.5.0}/include/peclet/core/python/kokkos_teardown.hpp +0 -0
- {peclet_core-1.3.2 → peclet_core-1.5.0}/include/peclet/core/python/ndarray_interop.hpp +0 -0
- {peclet_core-1.3.2 → peclet_core-1.5.0}/include/peclet/core/scheme/cut_cell_closure.hpp +0 -0
- {peclet_core-1.3.2 → peclet_core-1.5.0}/include/peclet/core/scheme/ghost_closure.hpp +0 -0
- {peclet_core-1.3.2 → peclet_core-1.5.0}/include/peclet/core/solver/coloring.hpp +0 -0
- {peclet_core-1.3.2 → peclet_core-1.5.0}/include/peclet/core/solver/csr_bicgstab.hpp +0 -0
- {peclet_core-1.3.2 → peclet_core-1.5.0}/include/peclet/core/solver/csr_operator.hpp +0 -0
- {peclet_core-1.3.2 → peclet_core-1.5.0}/include/peclet/core/solver/face_csr.hpp +0 -0
- {peclet_core-1.3.2 → peclet_core-1.5.0}/include/peclet/core/solver/graph_amg.hpp +0 -0
- {peclet_core-1.3.2 → peclet_core-1.5.0}/include/peclet/core/solver/graph_amg_device.hpp +0 -0
- {peclet_core-1.3.2 → peclet_core-1.5.0}/include/peclet/core/solver/vector_ops.hpp +0 -0
- {peclet_core-1.3.2 → peclet_core-1.5.0}/include/peclet/core/vof/cutcell.hpp +0 -0
- {peclet_core-1.3.2 → peclet_core-1.5.0}/include/peclet/core/vof/plic.hpp +0 -0
- {peclet_core-1.3.2 → peclet_core-1.5.0}/include/peclet/core/vof/wetting.hpp +0 -0
- {peclet_core-1.3.2 → peclet_core-1.5.0}/packaging/shell/core_geom.py +0 -0
- {peclet_core-1.3.2 → peclet_core-1.5.0}/packaging/shell/core_init.py +0 -0
- {peclet_core-1.3.2 → peclet_core-1.5.0}/packaging/shell/core_mpi.py +0 -0
- {peclet_core-1.3.2 → peclet_core-1.5.0}/python/CMakeLists.txt +0 -0
- {peclet_core-1.3.2 → peclet_core-1.5.0}/python/halo_bindings.cpp +0 -0
- {peclet_core-1.3.2 → peclet_core-1.5.0}/python/packaging/_halo.pyi +0 -0
- {peclet_core-1.3.2 → peclet_core-1.5.0}/python/packaging/halo_init.py +0 -0
- {peclet_core-1.3.2 → peclet_core-1.5.0}/python/state_hash.py +0 -0
- {peclet_core-1.3.2 → peclet_core-1.5.0}/python/state_hash_reference.json +0 -0
- {peclet_core-1.3.2 → peclet_core-1.5.0}/python/test_mpi.py +0 -0
- {peclet_core-1.3.2 → peclet_core-1.5.0}/python/test_shell_deprecation.py +0 -0
- {peclet_core-1.3.2 → peclet_core-1.5.0}/tests/data/rcp_pack_seed3_unit.txt +0 -0
- {peclet_core-1.3.2 → peclet_core-1.5.0}/tests/python/CMakeLists.txt +0 -0
- {peclet_core-1.3.2 → peclet_core-1.5.0}/tests/python/interop_test_module.cpp +0 -0
- {peclet_core-1.3.2 → peclet_core-1.5.0}/tests/python/test_ndarray_interop.py +0 -0
- {peclet_core-1.3.2 → peclet_core-1.5.0}/tests/test_aligned_weighted.cpp +0 -0
- {peclet_core-1.3.2 → peclet_core-1.5.0}/tests/test_aligned_weighted_mpi.cpp +0 -0
- {peclet_core-1.3.2 → peclet_core-1.5.0}/tests/test_cpu_budget.cpp +0 -0
- {peclet_core-1.3.2 → peclet_core-1.5.0}/tests/test_csr_solver.cpp +0 -0
- {peclet_core-1.3.2 → peclet_core-1.5.0}/tests/test_cut_cell_closure.cpp +0 -0
- {peclet_core-1.3.2 → peclet_core-1.5.0}/tests/test_decomposition.cpp +0 -0
- {peclet_core-1.3.2 → peclet_core-1.5.0}/tests/test_diffusion.cpp +0 -0
- {peclet_core-1.3.2 → peclet_core-1.5.0}/tests/test_diffusion_sdf.cpp +0 -0
- {peclet_core-1.3.2 → peclet_core-1.5.0}/tests/test_domain.cpp +0 -0
- {peclet_core-1.3.2 → peclet_core-1.5.0}/tests/test_field_set.cpp +0 -0
- {peclet_core-1.3.2 → peclet_core-1.5.0}/tests/test_geom_batch_device.cpp +0 -0
- {peclet_core-1.3.2 → peclet_core-1.5.0}/tests/test_geom_body.cpp +0 -0
- {peclet_core-1.3.2 → peclet_core-1.5.0}/tests/test_geom_owner.cpp +0 -0
- {peclet_core-1.3.2 → peclet_core-1.5.0}/tests/test_geom_primitives.cpp +0 -0
- {peclet_core-1.3.2 → peclet_core-1.5.0}/tests/test_geom_properties.cpp +0 -0
- {peclet_core-1.3.2 → peclet_core-1.5.0}/tests/test_geom_quadrature.cpp +0 -0
- {peclet_core-1.3.2 → peclet_core-1.5.0}/tests/test_geom_scene.cpp +0 -0
- {peclet_core-1.3.2 → peclet_core-1.5.0}/tests/test_geom_scene_builder.cpp +0 -0
- {peclet_core-1.3.2 → peclet_core-1.5.0}/tests/test_geom_scene_query.cpp +0 -0
- {peclet_core-1.3.2 → peclet_core-1.5.0}/tests/test_geom_tree_grad.cpp +0 -0
- {peclet_core-1.3.2 → peclet_core-1.5.0}/tests/test_ghost_particles_mpi.cpp +0 -0
- {peclet_core-1.3.2 → peclet_core-1.5.0}/tests/test_graph_amg.cpp +0 -0
- {peclet_core-1.3.2 → peclet_core-1.5.0}/tests/test_graph_amg_device.cpp +0 -0
- {peclet_core-1.3.2 → peclet_core-1.5.0}/tests/test_grid_halo.cpp +0 -0
- {peclet_core-1.3.2 → peclet_core-1.5.0}/tests/test_grid_halo_exchange.cpp +0 -0
- {peclet_core-1.3.2 → peclet_core-1.5.0}/tests/test_grid_redistribute_mpi.cpp +0 -0
- {peclet_core-1.3.2 → peclet_core-1.5.0}/tests/test_host_parallel.cpp +0 -0
- {peclet_core-1.3.2 → peclet_core-1.5.0}/tests/test_morton_indexer.cpp +0 -0
- {peclet_core-1.3.2 → peclet_core-1.5.0}/tests/test_nbx_rounds.cpp +0 -0
- {peclet_core-1.3.2 → peclet_core-1.5.0}/tests/test_particle_grid.cpp +0 -0
- {peclet_core-1.3.2 → peclet_core-1.5.0}/tests/test_particle_halo_exchange.cpp +0 -0
- {peclet_core-1.3.2 → peclet_core-1.5.0}/tests/test_particle_halo_images_mpi.cpp +0 -0
- {peclet_core-1.3.2 → peclet_core-1.5.0}/tests/test_particle_halo_mpi.cpp +0 -0
- {peclet_core-1.3.2 → peclet_core-1.5.0}/tests/test_particle_migration.cpp +0 -0
- {peclet_core-1.3.2 → peclet_core-1.5.0}/tests/test_particle_migrator_view_mpi.cpp +0 -0
- {peclet_core-1.3.2 → peclet_core-1.5.0}/tests/test_particle_rebalance.cpp +0 -0
- {peclet_core-1.3.2 → peclet_core-1.5.0}/tests/test_sdf.cpp +0 -0
- {peclet_core-1.3.2 → peclet_core-1.5.0}/tests/test_skip_mpi.hpp +0 -0
- {peclet_core-1.3.2 → peclet_core-1.5.0}/tests/test_stage_redistribute_mpi.cpp +0 -0
- {peclet_core-1.3.2 → peclet_core-1.5.0}/tests/test_stage_repartition_mpi.cpp +0 -0
- {peclet_core-1.3.2 → peclet_core-1.5.0}/tests/test_stage_target.cpp +0 -0
- {peclet_core-1.3.2 → peclet_core-1.5.0}/tests/test_util.hpp +0 -0
- {peclet_core-1.3.2 → peclet_core-1.5.0}/tests/test_vof_pvfit.cpp +0 -0
- {peclet_core-1.3.2 → peclet_core-1.5.0}/tests/test_vti.cpp +0 -0
- {peclet_core-1.3.2 → peclet_core-1.5.0}/tools/cuda_aware_mpi_check.cpp +0 -0
- {peclet_core-1.3.2 → peclet_core-1.5.0}/tools/cudampi-env.sh +0 -0
|
@@ -13,6 +13,14 @@ on:
|
|
|
13
13
|
workflow_dispatch:
|
|
14
14
|
|
|
15
15
|
jobs:
|
|
16
|
+
mpi-manifest:
|
|
17
|
+
name: MPI header manifest
|
|
18
|
+
runs-on: ubuntu-latest
|
|
19
|
+
steps:
|
|
20
|
+
- uses: actions/checkout@v7
|
|
21
|
+
- name: Check MPI-side header manifest (docs/CORE_BOUNDARY.md §1.1, §2.1)
|
|
22
|
+
run: tools/check_mpi_manifest.sh
|
|
23
|
+
|
|
16
24
|
python-lint:
|
|
17
25
|
name: ruff (critical errors)
|
|
18
26
|
runs-on: ubuntu-latest
|
|
@@ -16,8 +16,8 @@ authors:
|
|
|
16
16
|
orcid: "https://orcid.org/0000-0001-6099-3583"
|
|
17
17
|
email: e.a.j.f.peters@tue.nl
|
|
18
18
|
affiliation: "Eindhoven University of Technology"
|
|
19
|
-
version: 1.
|
|
20
|
-
date-released: 2026-10-
|
|
19
|
+
version: 1.5.0
|
|
20
|
+
date-released: 2026-10-09
|
|
21
21
|
license: MIT
|
|
22
22
|
doi: 10.5281/zenodo.21132435
|
|
23
23
|
identifiers:
|
|
@@ -37,7 +37,7 @@ ctest --test-dir build --output-on-failure -LE bench # 76 ctests (77 with `ben
|
|
|
37
37
|
export PATH=/usr/local/cuda-13.2/bin:$PATH # if the Kokkos install targets the CUDA backend
|
|
38
38
|
cmake -S . -B build_kokkos -DPECLET_CORE_ENABLE_KOKKOS=ON \
|
|
39
39
|
-DCMAKE_PREFIX_PATH=../extern/install/nvidia-cuda
|
|
40
|
-
cmake --build build_kokkos -j && ctest --test-dir build_kokkos --output-on-failure -LE bench #
|
|
40
|
+
cmake --build build_kokkos -j && ctest --test-dir build_kokkos --output-on-failure -LE bench # 96 ctests (97 with `bench`): + device halo / geometry / solver / VoF PV fit / Anderson, np=1,2,4,8
|
|
41
41
|
mpirun -np 4 ./build/benchmarks/bench_halo 48 1 300
|
|
42
42
|
|
|
43
43
|
# Python modules + their ctests (test_mpi.py np=1,2,4,8; state_hash; ndarray interop). Release is
|
|
@@ -57,7 +57,10 @@ a LOCAL gate; CI's 4-core runners run `-LE np8`), `bench` (`bench_halo`, exclude
|
|
|
57
57
|
host: `OMP_NUM_THREADS=2 OMP_PROC_BIND=false`, np=8 subset last. CI (`.github/workflows/ci.yml`)
|
|
58
58
|
runs host+MPI (gcc/clang × Debug/Release), Kokkos-OpenMP + Python, and no-MPI, each with the
|
|
59
59
|
`morton` tag checked out as a sibling; the clang-format check (`quality.yml`, clang-format 18.1.8)
|
|
60
|
-
is blocking over `include/ tests/ python/ benchmarks/`.
|
|
60
|
+
is blocking over `include/ tests/ python/ benchmarks/`. `quality.yml` also runs
|
|
61
|
+
`tools/check_mpi_manifest.sh`, which holds the MPI-side header manifest (../docs/CORE_BOUNDARY.md
|
|
62
|
+
§1.1, §2.1) and fails if a header outside it includes `common/mpi.hpp`/`<mpi.h>` or a manifest
|
|
63
|
+
header stops including it — add a newly-MPI-side header to the script's list, not just to the code.
|
|
61
64
|
|
|
62
65
|
The Kokkos halo path is provisioned via `find_package(Kokkos CONFIG)` against a cluster module or the
|
|
63
66
|
suite's local install prefix (`../tools/bootstrap_deps.sh`). The legacy native-CUDA halo was retired.
|
|
@@ -199,6 +202,26 @@ Header-only under `include/peclet/core/`:
|
|
|
199
202
|
`ot_optimizer.hpp` and the AMR package are the consumers. Gate: `tests/test_csr_solver.cpp`
|
|
200
203
|
(Kokkos build) — host row kernel vs device matvec, proper colouring of an asymmetric CSR,
|
|
201
204
|
smoothers, BiCGStab + defect correction.
|
|
205
|
+
`solver/anderson.hpp` is **`AndersonCore`**, type-II Anderson acceleration of a steady march
|
|
206
|
+
(design: `../flow/doc/steady_acceleration.md`; register "AndersonCore lives in core from the
|
|
207
|
+
start"): grid-agnostic over an `AndersonState` (padded state views + roles Velocity / Carried +
|
|
208
|
+
ghost width; the metric is the velocity only, the revision-0 Pressure role, SDF mask, `cP` and
|
|
209
|
+
gauge flag were deleted in WO-3b, rev 1's `innerTolerance` in WO-3c), split `prepare` /
|
|
210
|
+
`complete` around the caller's own step, history `(2m+3)·n_s·8·n_pad` bytes. MPI-free: the
|
|
211
|
+
collectives are two callables in `AndersonComm`; `solver/anderson_mpi.hpp` builds them from an
|
|
212
|
+
`MPI_Comm` and is the MPI side. Rev 2 of the design: **no instability guard** — no Ritz
|
|
213
|
+
estimate, no status "unstable" (`Status` is Active / Disabled); a Ritz value of a non-normal map
|
|
214
|
+
is no stability test, and stability evidence comes from the caller's plain steps. Pass 2 reduces
|
|
215
|
+
RR and b only (2·columns + 2 doubles; no reduction reads dG). A restart (ρ > 4·ρ_min at a mixed
|
|
216
|
+
iterate) **restores the last map output** on every rank (keyed on the broadcast decisions) and
|
|
217
|
+
commits nothing of the rejected evaluation, so the state never holds a rejected output (review
|
|
218
|
+
R2). Gates: `tests/test_anderson.cpp`
|
|
219
|
+
(U1a–c, U2–U6, U4 converges on an unstable map and judges nothing, U4b a stable non-normal map,
|
|
220
|
+
U10 Carried fields, U11 restarts at a noisy near-neutral Carried mode never leave a rejected
|
|
221
|
+
output, metric, memory formula) and `tests/test_anderson_mpi.cpp` (U7, np 1/2/4: γ
|
|
222
|
+
bitwise on all ranks, np = 1 bit-identical to serial; R6: a descriptor invalid on one rank
|
|
223
|
+
throws on every rank); both print a per-test `digest` of every
|
|
224
|
+
iterate for bit-identity checks across builds.
|
|
202
225
|
- **`amr/` is gone (2026-09-10)** — the whole AMR tree (the block-local-Morton octree, the distributed
|
|
203
226
|
octree with leaf halos and weighted-ORB rebalancing, the collocated-projection cut-cell
|
|
204
227
|
Navier–Stokes solver, its tests, studies, docs and campaign logs) is the **`peclet-amr`** package,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: peclet-core
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.5.0
|
|
4
4
|
Summary: peclet.core — compatibility shell: peclet.core.geom is now peclet.geom, peclet.core.mpi is now peclet.halo
|
|
5
5
|
Project-URL: Homepage, https://github.com/computational-chemical-engineering/peclet
|
|
6
6
|
Project-URL: Documentation, https://computational-chemical-engineering.github.io/peclet/
|
|
@@ -106,13 +106,18 @@ after `cmake --install`, or as a sibling checkout in the suite.
|
|
|
106
106
|
`KOKKOS_INLINE_FUNCTION` kernels (PLIC plane↔volume and normals, the height-function curvature
|
|
107
107
|
cascade, the cut-cell colour-transport rules, wetting). No `Kokkos::View` and no grid indexing in
|
|
108
108
|
any signature, so one copy serves every VoF container; the drivers live in `flow`.
|
|
109
|
+
Since 1.5.0 the tier-3 paraboloid fit also has its cost kernels (per-cell polygon and moment
|
|
110
|
+
caches, a support prefilter and per-entry accumulation; flow design G), bitwise to the old fit.
|
|
109
111
|
- `peclet::core::solver` (`include/peclet/core/solver/`) — mesh-agnostic linear algebra: the
|
|
110
112
|
smoothed-aggregation graph AMG (`graph_amg.hpp`, host setup; `graph_amg_device.hpp`, device apply)
|
|
111
113
|
and the **assembled face-CSR operator layer** lifted out of the AMR tree on 2026-09-10 —
|
|
112
114
|
`face_csr.hpp` (host+device row kernels), `coloring.hpp` (greedy symmetrised graph colouring),
|
|
113
115
|
`csr_operator.hpp` (the device operator, Jacobi and multicolour Gauss–Seidel sweeps),
|
|
114
116
|
`csr_bicgstab.hpp` (preconditioned BiCGStab / defect correction) and `vector_ops.hpp`. Consumed by
|
|
115
|
-
voro's mesh optimiser and by peclet-amr.
|
|
117
|
+
voro's mesh optimiser and by peclet-amr. Since 1.4.0 also `anderson.hpp`: **Anderson acceleration
|
|
118
|
+
of a steady march** (`AndersonCore`, type-II, grid-agnostic, on device; the caller owns the
|
|
119
|
+
fixed-point map, one time step), MPI-free with its collectives built by `anderson_mpi.hpp`.
|
|
120
|
+
Built for flow's `march_to_steady`.
|
|
116
121
|
- **Python bindings** (`python/halo_bindings.cpp`) — a host-only **nanobind** module (no Kokkos):
|
|
117
122
|
**`peclet.halo`** exposes the Lagrangian halo (`ParticleMigrator`, `ParticleHalo`: migration /
|
|
118
123
|
ghosts / count-weighted rebalance) to an mpi4py driver. The shared zero-copy Kokkos
|
|
@@ -133,7 +138,7 @@ after `cmake --install`, or as a sibling checkout in the suite.
|
|
|
133
138
|
|
|
134
139
|
Validated end-to-end by distributed explicit heat-diffusion solvers (plain, and **around an SDF solid
|
|
135
140
|
obstacle**) matching a serial reference cell-for-cell across ranks, and consumed by the validated
|
|
136
|
-
`flow` and `dem` distributed solvers.
|
|
141
|
+
`flow` and `dem` distributed solvers. 76 ctests in the plain host+MPI build, 96 with Kokkos (`np` 1–8),
|
|
137
142
|
plus 6 Python ctests in the `python/` build.
|
|
138
143
|
|
|
139
144
|
## Build / test / benchmark
|
|
@@ -86,13 +86,18 @@ after `cmake --install`, or as a sibling checkout in the suite.
|
|
|
86
86
|
`KOKKOS_INLINE_FUNCTION` kernels (PLIC plane↔volume and normals, the height-function curvature
|
|
87
87
|
cascade, the cut-cell colour-transport rules, wetting). No `Kokkos::View` and no grid indexing in
|
|
88
88
|
any signature, so one copy serves every VoF container; the drivers live in `flow`.
|
|
89
|
+
Since 1.5.0 the tier-3 paraboloid fit also has its cost kernels (per-cell polygon and moment
|
|
90
|
+
caches, a support prefilter and per-entry accumulation; flow design G), bitwise to the old fit.
|
|
89
91
|
- `peclet::core::solver` (`include/peclet/core/solver/`) — mesh-agnostic linear algebra: the
|
|
90
92
|
smoothed-aggregation graph AMG (`graph_amg.hpp`, host setup; `graph_amg_device.hpp`, device apply)
|
|
91
93
|
and the **assembled face-CSR operator layer** lifted out of the AMR tree on 2026-09-10 —
|
|
92
94
|
`face_csr.hpp` (host+device row kernels), `coloring.hpp` (greedy symmetrised graph colouring),
|
|
93
95
|
`csr_operator.hpp` (the device operator, Jacobi and multicolour Gauss–Seidel sweeps),
|
|
94
96
|
`csr_bicgstab.hpp` (preconditioned BiCGStab / defect correction) and `vector_ops.hpp`. Consumed by
|
|
95
|
-
voro's mesh optimiser and by peclet-amr.
|
|
97
|
+
voro's mesh optimiser and by peclet-amr. Since 1.4.0 also `anderson.hpp`: **Anderson acceleration
|
|
98
|
+
of a steady march** (`AndersonCore`, type-II, grid-agnostic, on device; the caller owns the
|
|
99
|
+
fixed-point map, one time step), MPI-free with its collectives built by `anderson_mpi.hpp`.
|
|
100
|
+
Built for flow's `march_to_steady`.
|
|
96
101
|
- **Python bindings** (`python/halo_bindings.cpp`) — a host-only **nanobind** module (no Kokkos):
|
|
97
102
|
**`peclet.halo`** exposes the Lagrangian halo (`ParticleMigrator`, `ParticleHalo`: migration /
|
|
98
103
|
ghosts / count-weighted rebalance) to an mpi4py driver. The shared zero-copy Kokkos
|
|
@@ -113,7 +118,7 @@ after `cmake --install`, or as a sibling checkout in the suite.
|
|
|
113
118
|
|
|
114
119
|
Validated end-to-end by distributed explicit heat-diffusion solvers (plain, and **around an SDF solid
|
|
115
120
|
obstacle**) matching a serial reference cell-for-cell across ranks, and consumed by the validated
|
|
116
|
-
`flow` and `dem` distributed solvers.
|
|
121
|
+
`flow` and `dem` distributed solvers. 76 ctests in the plain host+MPI build, 96 with Kokkos (`np` 1–8),
|
|
117
122
|
plus 6 Python ctests in the `python/` build.
|
|
118
123
|
|
|
119
124
|
## Build / test / benchmark
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
DOXYFILE_ENCODING = UTF-8
|
|
7
7
|
PROJECT_NAME = "core"
|
|
8
|
-
PROJECT_NUMBER = 1.
|
|
8
|
+
PROJECT_NUMBER = 1.5.0
|
|
9
9
|
PROJECT_BRIEF = "Shared MPI block decomposition, asynchronous ghost-layer exchange, SDF geometry, load balancing (header-only C++20)"
|
|
10
10
|
OUTPUT_DIRECTORY = docs
|
|
11
11
|
HTML_OUTPUT = html
|
|
@@ -0,0 +1,497 @@
|
|
|
1
|
+
/// @file
|
|
2
|
+
/// @brief core — the cut-cell geometric record of one cell from a piecewise-linear (PL) model of
|
|
3
|
+
/// its signed distance field: fluid fraction, face apertures, facet area vectors and centroids.
|
|
4
|
+
///
|
|
5
|
+
/// Design: flow `doc/scalar_ibm_design.md` §2 (decision D4, register entry "Scalar cut-cell
|
|
6
|
+
/// geometry is the fan-tetrahedron PL model"). The record is container-free — scalars and small
|
|
7
|
+
/// local arrays, no `Kokkos::View`, no grid indexing — so ONE copy serves flow's structured grid
|
|
8
|
+
/// (WO-2) and amr's leaves (§7.3).
|
|
9
|
+
///
|
|
10
|
+
/// **The PL model.** A cell carries 15 samples of the SDF φ (internal length units): its 8 corners,
|
|
11
|
+
/// its 6 face centres and its centre. Each face is split into 4 triangles (corner, next corner,
|
|
12
|
+
/// face centre) — the triangle fan of flow's `ccFaceOpenMS` — and each triangle is coned to the
|
|
13
|
+
/// cell centre, giving 24 tetrahedra of volume V/24. φ is linear on each. Shared faces carry
|
|
14
|
+
/// identical fans, so the model is conforming across cells.
|
|
15
|
+
///
|
|
16
|
+
/// **"Fluid" means φ > 0 strictly**: a vertex with φ = 0 is solid, so a wall lying exactly on a
|
|
17
|
+
/// face closes that face and κ = 0 never coexists with an open face.
|
|
18
|
+
///
|
|
19
|
+
/// κ, the six apertures and the facet pieces all come from that one polyhedron, so the PL
|
|
20
|
+
/// divergence theorem holds to round-off:
|
|
21
|
+
///
|
|
22
|
+
/// Σ_a A_a (aperture_{a+} − aperture_{a−}) e_a = areaPL (A_a = face area)
|
|
23
|
+
///
|
|
24
|
+
/// **Conventions.** Frame = the cell centre at the origin, internal lengths, cell size h[3].
|
|
25
|
+
/// Corner index c = bx + 2·by + 4·bz (x fastest, the suite's axis order; bit set = high side),
|
|
26
|
+
/// i.e. corner c sits at ((bx − ½)h_x, (by − ½)h_y, (bz − ½)h_z). Face order −x, +x, −y, +y, −z,
|
|
27
|
+
/// +z. Area vectors point INTO the fluid. Everything is double (D7).
|
|
28
|
+
///
|
|
29
|
+
/// Host/device: `PECLET_CORE_CC_HD` (from `scheme/cut_cell_closure.hpp`) is
|
|
30
|
+
/// `KOKKOS_INLINE_FUNCTION` when Kokkos_Core.hpp was included BEFORE this header, plain `inline`
|
|
31
|
+
/// otherwise (host-only oracle builds).
|
|
32
|
+
///
|
|
33
|
+
/// Reserved, NOT implemented (design §7.1, §7.4): the plane source
|
|
34
|
+
/// `cutCellGeometryFromPlane(const double m[3], double alpha, const double h[3])` for PLIC cells.
|
|
35
|
+
#ifndef PECLET_CORE_SCHEME_CUT_CELL_GEOMETRY_HPP
|
|
36
|
+
#define PECLET_CORE_SCHEME_CUT_CELL_GEOMETRY_HPP
|
|
37
|
+
|
|
38
|
+
#include <cmath>
|
|
39
|
+
|
|
40
|
+
#include "peclet/core/scheme/cut_cell_closure.hpp" // PECLET_CORE_CC_HD
|
|
41
|
+
|
|
42
|
+
namespace peclet::core::scheme {
|
|
43
|
+
|
|
44
|
+
/// Aperture snap threshold at BOTH ends (§2.3): a < 1e-3 → 0, a > 1 − 1e-3 → 1. The 1e-3 floor is
|
|
45
|
+
/// flow's pressure constant; snapping both ends keeps a_s = 1 − a^snap exact (linear exactness).
|
|
46
|
+
inline constexpr double kApertureSnap = 1e-3;
|
|
47
|
+
/// A facet piece with area < kPieceDropRel · min_a A_a is dropped (§2.2).
|
|
48
|
+
inline constexpr double kPieceDropRel = 1e-14;
|
|
49
|
+
/// ρ = |areaPL| / areaSum at or above which the cell carries ONE facet (§2.2).
|
|
50
|
+
inline constexpr double kSingleFacetRho = 0.5;
|
|
51
|
+
|
|
52
|
+
/// Facet classification of a cut cell (§2.2).
|
|
53
|
+
enum class CutCellKind : int {
|
|
54
|
+
none = 0, ///< no facet (uncut, or every piece below the drop threshold)
|
|
55
|
+
single = 1, ///< one facet (ρ ≥ 0.5, or the two-group split left a group empty)
|
|
56
|
+
gap = 2, ///< two facets, fluid between two walls
|
|
57
|
+
thinSolid = 3, ///< two facets, solid between two fluids (a counted resolution error)
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
/// The geometric record of one cell (§2.1). Double, cell-centred frame, internal lengths.
|
|
61
|
+
struct CutCellGeometry {
|
|
62
|
+
double kappa; ///< fluid volume fraction ∈ [0, 1]
|
|
63
|
+
double aperture[6]; ///< open fraction of each face, −x,+x,−y,+y,−z,+z, UNSNAPPED
|
|
64
|
+
double areaPL[3]; ///< net PL facet area vector (into the fluid)
|
|
65
|
+
double areaSum; ///< Σ |piece|
|
|
66
|
+
int nFacet; ///< 0, 1 or 2
|
|
67
|
+
double facetArea[2][3]; ///< per facet: area vector (into the fluid); unused slots 0
|
|
68
|
+
double facetCentroid[2][3]; ///< per facet: centroid relative to the cell centre; unused 0
|
|
69
|
+
CutCellKind kind;
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
namespace detail {
|
|
73
|
+
|
|
74
|
+
PECLET_CORE_CC_HD double ccgSqrt(double x) {
|
|
75
|
+
#ifdef KOKKOS_INLINE_FUNCTION
|
|
76
|
+
return Kokkos::sqrt(x);
|
|
77
|
+
#else
|
|
78
|
+
return std::sqrt(x);
|
|
79
|
+
#endif
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
PECLET_CORE_CC_HD double ccgAbs(double x) {
|
|
83
|
+
return x < 0.0 ? -x : x;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
PECLET_CORE_CC_HD double ccgMaxAbs3(double a, double b, double c) {
|
|
87
|
+
double m = ccgAbs(a);
|
|
88
|
+
m = ccgAbs(b) > m ? ccgAbs(b) : m;
|
|
89
|
+
return ccgAbs(c) > m ? ccgAbs(c) : m;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
PECLET_CORE_CC_HD double ccgMaxAbs4(double a, double b, double c, double d) {
|
|
93
|
+
const double m = ccgMaxAbs3(a, b, c);
|
|
94
|
+
return ccgAbs(d) > m ? ccgAbs(d) : m;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// Triangle, one positive vertex x > 0 >= y, z: F = x^2 / ((x - y)(x - z)).
|
|
98
|
+
PECLET_CORE_CC_HD double triOnePositive(double x, double y, double z) {
|
|
99
|
+
const double den = (x - y) * (x - z);
|
|
100
|
+
if (den > 0.0)
|
|
101
|
+
return (x * x) / den;
|
|
102
|
+
// Underflow only (every |value| below ~1e-154): F is scale-invariant, so rescale once.
|
|
103
|
+
const double s = 1.0 / ccgMaxAbs3(x, y, z);
|
|
104
|
+
x *= s;
|
|
105
|
+
y *= s;
|
|
106
|
+
z *= s;
|
|
107
|
+
return (x * x) / ((x - y) * (x - z));
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// Tetrahedron, one positive vertex a > 0 >= b1, b2, b3: F = a^3 / ((a-b1)(a-b2)(a-b3)).
|
|
111
|
+
PECLET_CORE_CC_HD double tetOnePositive(double a, double b1, double b2, double b3) {
|
|
112
|
+
const double den = ((a - b1) * (a - b2)) * (a - b3);
|
|
113
|
+
if (den > 0.0)
|
|
114
|
+
return (a * a * a) / den;
|
|
115
|
+
const double s = 1.0 / ccgMaxAbs4(a, b1, b2, b3); // underflow only; F is scale-invariant
|
|
116
|
+
a *= s;
|
|
117
|
+
b1 *= s;
|
|
118
|
+
b2 *= s;
|
|
119
|
+
b3 *= s;
|
|
120
|
+
return (a * a * a) / (((a - b1) * (a - b2)) * (a - b3));
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// Tetrahedron, two positive vertices a1, a2 > 0 >= b1, b2 (§2.2; every term non-negative):
|
|
124
|
+
// F = [a1²a2² − (a1+a2)(b1+b2)a1a2 + b1b2(a1²+a1a2+a2²)] / [(a1−b1)(a1−b2)(a2−b1)(a2−b2)].
|
|
125
|
+
PECLET_CORE_CC_HD double tetTwoPositive(double a1, double a2, double b1, double b2) {
|
|
126
|
+
double den = ((a1 - b1) * (a1 - b2)) * ((a2 - b1) * (a2 - b2));
|
|
127
|
+
if (!(den > 0.0)) {
|
|
128
|
+
const double s = 1.0 / ccgMaxAbs4(a1, a2, b1, b2); // underflow only; F is scale-invariant
|
|
129
|
+
a1 *= s;
|
|
130
|
+
a2 *= s;
|
|
131
|
+
b1 *= s;
|
|
132
|
+
b2 *= s;
|
|
133
|
+
den = ((a1 - b1) * (a1 - b2)) * ((a2 - b1) * (a2 - b2));
|
|
134
|
+
}
|
|
135
|
+
const double p = a1 * a2;
|
|
136
|
+
const double num = p * p - (a1 + a2) * (b1 + b2) * p + b1 * b2 * (a1 * a1 + p + a2 * a2);
|
|
137
|
+
return num / den;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
} // namespace detail
|
|
141
|
+
|
|
142
|
+
/// Fraction of a triangle on which the linear interpolant of its vertex values (a, b, c) is
|
|
143
|
+
/// strictly positive. Robust case formulas (§2.2), no subtraction of close numbers; the vertex
|
|
144
|
+
/// rotation mirrors flow's `ccTriFrac`.
|
|
145
|
+
PECLET_CORE_CC_HD double triPositiveFraction(double a, double b, double c) {
|
|
146
|
+
const bool pa = a > 0.0, pb = b > 0.0, pc = c > 0.0;
|
|
147
|
+
const int np = (pa ? 1 : 0) + (pb ? 1 : 0) + (pc ? 1 : 0);
|
|
148
|
+
if (np == 3)
|
|
149
|
+
return 1.0;
|
|
150
|
+
if (np == 0)
|
|
151
|
+
return 0.0;
|
|
152
|
+
if (np == 1) { // rotate the positive vertex to the front
|
|
153
|
+
if (pa)
|
|
154
|
+
return detail::triOnePositive(a, b, c);
|
|
155
|
+
if (pb)
|
|
156
|
+
return detail::triOnePositive(b, c, a);
|
|
157
|
+
return detail::triOnePositive(c, a, b);
|
|
158
|
+
}
|
|
159
|
+
// np == 2: the fraction of the single non-positive vertex's mirror, F = 1 − b²/((b−a1)(b−a2))
|
|
160
|
+
// = 1 − triOnePositive(−b, −a1, −a2) (the negative part as a one-positive triangle of −φ).
|
|
161
|
+
if (!pa)
|
|
162
|
+
return 1.0 - detail::triOnePositive(-a, -b, -c);
|
|
163
|
+
if (!pb)
|
|
164
|
+
return 1.0 - detail::triOnePositive(-b, -c, -a);
|
|
165
|
+
return 1.0 - detail::triOnePositive(-c, -a, -b);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/// Fraction of a tetrahedron on which the linear interpolant of its vertex values is strictly
|
|
169
|
+
/// positive (§2.2). Vertices with value exactly 0 count as non-positive (solid).
|
|
170
|
+
PECLET_CORE_CC_HD double tetPositiveFraction(double v0, double v1, double v2, double v3) {
|
|
171
|
+
const double v[4] = {v0, v1, v2, v3};
|
|
172
|
+
double pos[4], neg[4];
|
|
173
|
+
int np = 0, nn = 0;
|
|
174
|
+
for (int k = 0; k < 4; ++k) {
|
|
175
|
+
if (v[k] > 0.0)
|
|
176
|
+
pos[np++] = v[k];
|
|
177
|
+
else
|
|
178
|
+
neg[nn++] = v[k];
|
|
179
|
+
}
|
|
180
|
+
if (np == 0)
|
|
181
|
+
return 0.0;
|
|
182
|
+
if (np == 4)
|
|
183
|
+
return 1.0;
|
|
184
|
+
if (np == 1)
|
|
185
|
+
return detail::tetOnePositive(pos[0], neg[0], neg[1], neg[2]);
|
|
186
|
+
if (np == 3) // 1 − b³/((b−a1)(b−a2)(b−a3)) = 1 − tetOnePositive(−b, −a1, −a2, −a3)
|
|
187
|
+
return 1.0 - detail::tetOnePositive(-neg[0], -pos[0], -pos[1], -pos[2]);
|
|
188
|
+
return detail::tetTwoPositive(pos[0], pos[1], neg[0], neg[1]);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/// PL aperture of one face from its fan (§2.2): the corner values in loop order c00, c10, c11, c01
|
|
192
|
+
/// over the face's tangent axes (t1 < t2) and the face-centre value cc,
|
|
193
|
+
/// ¼ (F(c00,c10,cc) + F(c10,c11,cc) + F(c11,c01,cc) + F(c01,c00,cc)), summed in that order. The
|
|
194
|
+
/// face kernel of a container and `cutCellGeometryFanTet` both call this, so a face's aperture is
|
|
195
|
+
/// the same bits from either cell and from the face kernel.
|
|
196
|
+
PECLET_CORE_CC_HD double fanFaceAperture(double v00, double v10, double v11, double v01,
|
|
197
|
+
double cc) {
|
|
198
|
+
return 0.25 * (triPositiveFraction(v00, v10, cc) + triPositiveFraction(v10, v11, cc) +
|
|
199
|
+
triPositiveFraction(v11, v01, cc) + triPositiveFraction(v01, v00, cc));
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/// Snap a face aperture at both ends (§2.3): a < 1e-3 → 0, a > 1 − 1e-3 → 1, else a.
|
|
203
|
+
PECLET_CORE_CC_HD double snapAperture(double a) {
|
|
204
|
+
if (a < kApertureSnap)
|
|
205
|
+
return 0.0;
|
|
206
|
+
if (a > 1.0 - kApertureSnap)
|
|
207
|
+
return 1.0;
|
|
208
|
+
return a;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
/// Face area of axis a for cell size h: the product of the two other spacings.
|
|
212
|
+
PECLET_CORE_CC_HD double cutCellFaceArea(int a, const double h[3]) {
|
|
213
|
+
return a == 0 ? h[1] * h[2] : (a == 1 ? h[0] * h[2] : h[0] * h[1]);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/// The area vector the apertures imply through the divergence theorem (§2.3):
|
|
217
|
+
/// out_a = A_a (ap[2a+1] − ap[2a]), A_a the a-face area. Applied to the UNSNAPPED apertures it is
|
|
218
|
+
/// `areaPL` (the PL identity); applied to the snapped ones it is the operator's A⃗^snap.
|
|
219
|
+
PECLET_CORE_CC_HD void facetAreaVector(const double ap[6], const double h[3], double out[3]) {
|
|
220
|
+
for (int a = 0; a < 3; ++a)
|
|
221
|
+
out[a] = cutCellFaceArea(a, h) * (ap[2 * a + 1] - ap[2 * a]);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
namespace detail {
|
|
225
|
+
|
|
226
|
+
// Position of corner c (bits x, y, z = bit 0, 1, 2) relative to the cell centre.
|
|
227
|
+
PECLET_CORE_CC_HD void ccgCornerPos(int c, const double h[3], double x[3]) {
|
|
228
|
+
for (int a = 0; a < 3; ++a)
|
|
229
|
+
x[a] = (((c >> a) & 1) ? 0.5 : -0.5) * h[a];
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
// The two tangent axes of a face of axis a, ascending (the ccFaceOpenMS t1, t2).
|
|
233
|
+
PECLET_CORE_CC_HD void ccgTangents(int a, int& t1, int& t2) {
|
|
234
|
+
t1 = (a == 0) ? 1 : 0;
|
|
235
|
+
t2 = (a == 2) ? 1 : 2;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
// Corner k (0..3) of face f's fan loop: c00, c10, c11, c01 in the (t1, t2) bits.
|
|
239
|
+
PECLET_CORE_CC_HD int ccgFanCorner(int f, int k) {
|
|
240
|
+
const int a = f >> 1, side = f & 1;
|
|
241
|
+
int t1, t2;
|
|
242
|
+
ccgTangents(a, t1, t2);
|
|
243
|
+
const int u = (k == 1 || k == 2) ? 1 : 0;
|
|
244
|
+
const int w = (k >= 2) ? 1 : 0;
|
|
245
|
+
return (side << a) | (u << t1) | (w << t2);
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
// Tetrahedron (f, k): face f's fan triangle k = (corner k, corner k+1, face centre) coned to the
|
|
249
|
+
// cell centre. Vertex values and positions in that order.
|
|
250
|
+
PECLET_CORE_CC_HD void ccgFanTet(int f, int k, const double corner[8], const double face[6],
|
|
251
|
+
double centre, const double h[3], double val[4],
|
|
252
|
+
double pos[4][3]) {
|
|
253
|
+
const int c0 = ccgFanCorner(f, k), c1 = ccgFanCorner(f, (k + 1) & 3);
|
|
254
|
+
val[0] = corner[c0];
|
|
255
|
+
val[1] = corner[c1];
|
|
256
|
+
val[2] = face[f];
|
|
257
|
+
val[3] = centre;
|
|
258
|
+
ccgCornerPos(c0, h, pos[0]);
|
|
259
|
+
ccgCornerPos(c1, h, pos[1]);
|
|
260
|
+
const int a = f >> 1;
|
|
261
|
+
for (int d = 0; d < 3; ++d) {
|
|
262
|
+
pos[2][d] = 0.0;
|
|
263
|
+
pos[3][d] = 0.0;
|
|
264
|
+
}
|
|
265
|
+
pos[2][a] = ((f & 1) ? 0.5 : -0.5) * h[a];
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
// Edge crossing x = x_p + t (x_n − x_p), t = φ_p / (φ_p − φ_n) ∈ (0, 1].
|
|
269
|
+
PECLET_CORE_CC_HD void ccgCross(double vp, double vn, const double xp[3], const double xn[3],
|
|
270
|
+
double x[3]) {
|
|
271
|
+
const double t = vp / (vp - vn);
|
|
272
|
+
for (int d = 0; d < 3; ++d)
|
|
273
|
+
x[d] = xp[d] + t * (xn[d] - xp[d]);
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
PECLET_CORE_CC_HD void ccgCrossProd(const double u[3], const double v[3], double w[3]) {
|
|
277
|
+
w[0] = u[1] * v[2] - u[2] * v[1];
|
|
278
|
+
w[1] = u[2] * v[0] - u[0] * v[2];
|
|
279
|
+
w[2] = u[0] * v[1] - u[1] * v[0];
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
PECLET_CORE_CC_HD double ccgNorm(const double v[3]) {
|
|
283
|
+
return ccgSqrt(v[0] * v[0] + v[1] * v[1] + v[2] * v[2]);
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
// The zero-set piece of one tetrahedron with 0 < n+ < 4 (§2.2): area vector `vec` oriented toward
|
|
287
|
+
// a positive vertex, its magnitude `area`, and centroid `cen`. Returns false when the tet is not
|
|
288
|
+
// cut (n+ = 0 or 4).
|
|
289
|
+
PECLET_CORE_CC_HD bool ccgTetPiece(const double val[4], const double pos[4][3], double vec[3],
|
|
290
|
+
double& area, double cen[3]) {
|
|
291
|
+
int ip[4], in[4];
|
|
292
|
+
int np = 0, nn = 0;
|
|
293
|
+
for (int k = 0; k < 4; ++k) {
|
|
294
|
+
if (val[k] > 0.0)
|
|
295
|
+
ip[np++] = k;
|
|
296
|
+
else
|
|
297
|
+
in[nn++] = k;
|
|
298
|
+
}
|
|
299
|
+
if (np == 0 || np == 4)
|
|
300
|
+
return false;
|
|
301
|
+
const int pRef = ip[0]; // the positive vertex the area vector is oriented toward
|
|
302
|
+
double X[4][3];
|
|
303
|
+
if (np == 2) {
|
|
304
|
+
// Quad X11, X12, X22, X21 (X_ij on edge p_i – n_j); area ½ (X2 − X0) × (X3 − X1).
|
|
305
|
+
ccgCross(val[ip[0]], val[in[0]], pos[ip[0]], pos[in[0]], X[0]);
|
|
306
|
+
ccgCross(val[ip[0]], val[in[1]], pos[ip[0]], pos[in[1]], X[1]);
|
|
307
|
+
ccgCross(val[ip[1]], val[in[1]], pos[ip[1]], pos[in[1]], X[2]);
|
|
308
|
+
ccgCross(val[ip[1]], val[in[0]], pos[ip[1]], pos[in[0]], X[3]);
|
|
309
|
+
double d02[3], d13[3];
|
|
310
|
+
for (int d = 0; d < 3; ++d) {
|
|
311
|
+
d02[d] = X[2][d] - X[0][d];
|
|
312
|
+
d13[d] = X[3][d] - X[1][d];
|
|
313
|
+
}
|
|
314
|
+
ccgCrossProd(d02, d13, vec);
|
|
315
|
+
for (int d = 0; d < 3; ++d)
|
|
316
|
+
vec[d] *= 0.5;
|
|
317
|
+
// Centroid: area-weighted mean of the triangles (X0, X1, X2) and (X0, X2, X3).
|
|
318
|
+
double d01[3], d03[3], tA[3], tB[3];
|
|
319
|
+
for (int d = 0; d < 3; ++d) {
|
|
320
|
+
d01[d] = X[1][d] - X[0][d];
|
|
321
|
+
d03[d] = X[3][d] - X[0][d];
|
|
322
|
+
}
|
|
323
|
+
ccgCrossProd(d01, d02, tA);
|
|
324
|
+
ccgCrossProd(d02, d03, tB);
|
|
325
|
+
const double wA = 0.5 * ccgNorm(tA), wB = 0.5 * ccgNorm(tB);
|
|
326
|
+
const double wS = wA + wB;
|
|
327
|
+
for (int d = 0; d < 3; ++d) {
|
|
328
|
+
const double cA = (X[0][d] + X[1][d] + X[2][d]) / 3.0;
|
|
329
|
+
const double cB = (X[0][d] + X[2][d] + X[3][d]) / 3.0;
|
|
330
|
+
cen[d] = wS > 0.0 ? (wA * cA + wB * cB) / wS : 0.25 * (X[0][d] + X[1][d] + X[2][d] + X[3][d]);
|
|
331
|
+
}
|
|
332
|
+
} else {
|
|
333
|
+
// Triangle: n+ = 1 → crossings on (p, n1), (p, n2), (p, n3); n+ = 3 → on (p1, n), (p2, n),
|
|
334
|
+
// (p3, n). Area ½ (X1 − X0) × (X2 − X0).
|
|
335
|
+
for (int k = 0; k < 3; ++k) {
|
|
336
|
+
const int p = (np == 1) ? ip[0] : ip[k];
|
|
337
|
+
const int n = (np == 1) ? in[k] : in[0];
|
|
338
|
+
ccgCross(val[p], val[n], pos[p], pos[n], X[k]);
|
|
339
|
+
}
|
|
340
|
+
double d01[3], d02[3];
|
|
341
|
+
for (int d = 0; d < 3; ++d) {
|
|
342
|
+
d01[d] = X[1][d] - X[0][d];
|
|
343
|
+
d02[d] = X[2][d] - X[0][d];
|
|
344
|
+
}
|
|
345
|
+
ccgCrossProd(d01, d02, vec);
|
|
346
|
+
for (int d = 0; d < 3; ++d) {
|
|
347
|
+
vec[d] *= 0.5;
|
|
348
|
+
cen[d] = (X[0][d] + X[1][d] + X[2][d]) / 3.0;
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
// Orient toward the positive vertex.
|
|
352
|
+
const double dot = vec[0] * (pos[pRef][0] - X[0][0]) + vec[1] * (pos[pRef][1] - X[0][1]) +
|
|
353
|
+
vec[2] * (pos[pRef][2] - X[0][2]);
|
|
354
|
+
if (dot < 0.0)
|
|
355
|
+
for (int d = 0; d < 3; ++d)
|
|
356
|
+
vec[d] = -vec[d];
|
|
357
|
+
area = ccgNorm(vec);
|
|
358
|
+
return true;
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
} // namespace detail
|
|
362
|
+
|
|
363
|
+
/// The cut-cell record of one cell from its 15 PL samples (§2.2): corner[8] (index bx+2by+4bz),
|
|
364
|
+
/// face[6] (−x,+x,−y,+y,−z,+z), the centre value, and the cell size h[3] (internal lengths).
|
|
365
|
+
///
|
|
366
|
+
/// - κ = (1/24) Σ_tets F_tet; aperture_f = ¼ Σ_{4 fan triangles of f} F_tri (unsnapped).
|
|
367
|
+
/// - Pieces: the zero set of each cut tetrahedron; pieces with area < 1e-14 · min_a A_a dropped.
|
|
368
|
+
/// areaPL = Σ piece vectors, areaSum = Σ |piece|, ρ = |areaPL| / areaSum.
|
|
369
|
+
/// - ρ ≥ 0.5 → `single` (facet 0 = areaPL at the areaSum-weighted piece centroid). Otherwise the
|
|
370
|
+
/// pieces split into two groups by the sign of n_piece · n_ref (n_ref = the largest piece; a
|
|
371
|
+
/// piece with n_piece · n_ref ≥ 0 joins the reference group A, which is facet 0) — `gap` if
|
|
372
|
+
/// (x̄_B − x̄_A) · n_A > 0, else `thinSolid`; an empty group falls back to `single`.
|
|
373
|
+
PECLET_CORE_CC_HD CutCellGeometry cutCellGeometryFanTet(const double corner[8],
|
|
374
|
+
const double face[6], double centre,
|
|
375
|
+
const double h[3]) {
|
|
376
|
+
CutCellGeometry g;
|
|
377
|
+
g.kappa = 0.0;
|
|
378
|
+
g.areaSum = 0.0;
|
|
379
|
+
g.nFacet = 0;
|
|
380
|
+
g.kind = CutCellKind::none;
|
|
381
|
+
for (int d = 0; d < 3; ++d) {
|
|
382
|
+
g.areaPL[d] = 0.0;
|
|
383
|
+
g.facetArea[0][d] = g.facetArea[1][d] = 0.0;
|
|
384
|
+
g.facetCentroid[0][d] = g.facetCentroid[1][d] = 0.0;
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
// Apertures: face f's fan (c00, c10, cc), (c10, c11, cc), (c11, c01, cc), (c01, c00, cc),
|
|
388
|
+
// summed in that order — the same triangles and order from both cells sharing the face.
|
|
389
|
+
for (int f = 0; f < 6; ++f) {
|
|
390
|
+
const double cc = face[f];
|
|
391
|
+
const double v00 = corner[detail::ccgFanCorner(f, 0)];
|
|
392
|
+
const double v10 = corner[detail::ccgFanCorner(f, 1)];
|
|
393
|
+
const double v11 = corner[detail::ccgFanCorner(f, 2)];
|
|
394
|
+
const double v01 = corner[detail::ccgFanCorner(f, 3)];
|
|
395
|
+
g.aperture[f] = fanFaceAperture(v00, v10, v11, v01, cc);
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
// Uniform sign over all 15 samples: κ = 1 or 0, no facet (the apertures above are then exactly
|
|
399
|
+
// 1 or 0 as well).
|
|
400
|
+
bool anyPos = centre > 0.0, anyNonPos = !(centre > 0.0);
|
|
401
|
+
for (int c = 0; c < 8; ++c) {
|
|
402
|
+
anyPos = anyPos || corner[c] > 0.0;
|
|
403
|
+
anyNonPos = anyNonPos || !(corner[c] > 0.0);
|
|
404
|
+
}
|
|
405
|
+
for (int f = 0; f < 6; ++f) {
|
|
406
|
+
anyPos = anyPos || face[f] > 0.0;
|
|
407
|
+
anyNonPos = anyNonPos || !(face[f] > 0.0);
|
|
408
|
+
}
|
|
409
|
+
if (!anyPos || !anyNonPos) {
|
|
410
|
+
g.kappa = anyPos ? 1.0 : 0.0;
|
|
411
|
+
return g;
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
double minA = cutCellFaceArea(0, h);
|
|
415
|
+
minA = cutCellFaceArea(1, h) < minA ? cutCellFaceArea(1, h) : minA;
|
|
416
|
+
minA = cutCellFaceArea(2, h) < minA ? cutCellFaceArea(2, h) : minA;
|
|
417
|
+
const double dropArea = kPieceDropRel * minA;
|
|
418
|
+
|
|
419
|
+
// Pass 1: κ, the net area vector, Σ|piece|, the weighted centroid and the largest piece.
|
|
420
|
+
double ksum = 0.0;
|
|
421
|
+
double wc[3] = {0.0, 0.0, 0.0};
|
|
422
|
+
double refVec[3] = {0.0, 0.0, 0.0};
|
|
423
|
+
double refArea = -1.0;
|
|
424
|
+
for (int f = 0; f < 6; ++f) {
|
|
425
|
+
for (int k = 0; k < 4; ++k) {
|
|
426
|
+
double val[4], pos[4][3];
|
|
427
|
+
detail::ccgFanTet(f, k, corner, face, centre, h, val, pos);
|
|
428
|
+
ksum += tetPositiveFraction(val[0], val[1], val[2], val[3]);
|
|
429
|
+
double vec[3], cen[3], area;
|
|
430
|
+
if (!detail::ccgTetPiece(val, pos, vec, area, cen) || area < dropArea)
|
|
431
|
+
continue;
|
|
432
|
+
for (int d = 0; d < 3; ++d) {
|
|
433
|
+
g.areaPL[d] += vec[d];
|
|
434
|
+
wc[d] += area * cen[d];
|
|
435
|
+
}
|
|
436
|
+
g.areaSum += area;
|
|
437
|
+
if (area > refArea) {
|
|
438
|
+
refArea = area;
|
|
439
|
+
for (int d = 0; d < 3; ++d)
|
|
440
|
+
refVec[d] = vec[d];
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
g.kappa = ksum / 24.0;
|
|
445
|
+
if (!(g.areaSum > 0.0))
|
|
446
|
+
return g; // every piece below the drop threshold: no facet
|
|
447
|
+
|
|
448
|
+
const double rho = detail::ccgNorm(g.areaPL) / g.areaSum;
|
|
449
|
+
if (rho < kSingleFacetRho) {
|
|
450
|
+
// Pass 2: split the pieces into the reference group A (n·n_ref >= 0) and B.
|
|
451
|
+
double vA[3] = {0.0, 0.0, 0.0}, vB[3] = {0.0, 0.0, 0.0};
|
|
452
|
+
double cA[3] = {0.0, 0.0, 0.0}, cB[3] = {0.0, 0.0, 0.0};
|
|
453
|
+
double sA = 0.0, sB = 0.0;
|
|
454
|
+
for (int f = 0; f < 6; ++f) {
|
|
455
|
+
for (int k = 0; k < 4; ++k) {
|
|
456
|
+
double val[4], pos[4][3];
|
|
457
|
+
detail::ccgFanTet(f, k, corner, face, centre, h, val, pos);
|
|
458
|
+
double vec[3], cen[3], area;
|
|
459
|
+
if (!detail::ccgTetPiece(val, pos, vec, area, cen) || area < dropArea)
|
|
460
|
+
continue;
|
|
461
|
+
const double dot = vec[0] * refVec[0] + vec[1] * refVec[1] + vec[2] * refVec[2];
|
|
462
|
+
double* v = dot >= 0.0 ? vA : vB;
|
|
463
|
+
double* c = dot >= 0.0 ? cA : cB;
|
|
464
|
+
for (int d = 0; d < 3; ++d) {
|
|
465
|
+
v[d] += vec[d];
|
|
466
|
+
c[d] += area * cen[d];
|
|
467
|
+
}
|
|
468
|
+
(dot >= 0.0 ? sA : sB) += area;
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
if (sA > 0.0 && sB > 0.0) {
|
|
472
|
+
for (int d = 0; d < 3; ++d) {
|
|
473
|
+
g.facetArea[0][d] = vA[d];
|
|
474
|
+
g.facetArea[1][d] = vB[d];
|
|
475
|
+
g.facetCentroid[0][d] = cA[d] / sA;
|
|
476
|
+
g.facetCentroid[1][d] = cB[d] / sB;
|
|
477
|
+
}
|
|
478
|
+
const double sep = (g.facetCentroid[1][0] - g.facetCentroid[0][0]) * vA[0] +
|
|
479
|
+
(g.facetCentroid[1][1] - g.facetCentroid[0][1]) * vA[1] +
|
|
480
|
+
(g.facetCentroid[1][2] - g.facetCentroid[0][2]) * vA[2];
|
|
481
|
+
g.nFacet = 2;
|
|
482
|
+
g.kind = sep > 0.0 ? CutCellKind::gap : CutCellKind::thinSolid;
|
|
483
|
+
return g;
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
g.nFacet = 1;
|
|
487
|
+
g.kind = CutCellKind::single;
|
|
488
|
+
for (int d = 0; d < 3; ++d) {
|
|
489
|
+
g.facetArea[0][d] = g.areaPL[d];
|
|
490
|
+
g.facetCentroid[0][d] = wc[d] / g.areaSum;
|
|
491
|
+
}
|
|
492
|
+
return g;
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
} // namespace peclet::core::scheme
|
|
496
|
+
|
|
497
|
+
#endif // PECLET_CORE_SCHEME_CUT_CELL_GEOMETRY_HPP
|