GPU-focused linear quadtree/octree utilities for mesh-based AMR workflows using Morton codes. Core operations include tree completion (add ancestors), linearization/coarsening, 2:1 balancing, neighbor lookup, domain masking, and mesh-to-VTU conversion. Dimension is selected at configure time via -DMORTON_DIM=2 or 3.
- Morton helpers:
morton2D.cuh,mortonND.cuh. - Host tree ops:
treeND.hpp,tree2D.hpp,tree3D.hpp(generate leaves, complete, coarsen siblings, 2:1 balance, VTU dump). - GPU tree ops:
gpuTreeCompleteND.cuh,gpuTreeComplete2D.cuh: GPU tree completion (block-local buffering).gpuTreeLinearize2D/ND.cuh: Coarsen full sibling sets (leaf-only).gpuTreeBalanceND.cuh: GPU 2:1 balance (face neighbor refinement).gpuTreeNeighbors2D/ND.cuh: Same-level neighbor lookup.gpuDomainMask2D.cuh,gpuDomainMask3D.cuh: Domain filtering/masking (analytic predicates, polygons/meshes with ray tests).
- AMR scaffolding (experimental):
fvAMR.hpp(AMR state container) andfvAdvection2D.cuh(scalar advection kernel on 2:1 trees; disabled for nvcc 10.1).
- CPU:
test_tree2D,test_tree3D,test_treeSteps2D_cpu(random leaves → complete → balance, writes CSVs tosteps_out_cpu/). - GPU (buildable on newer nvcc; some disabled for nvcc 10.1):
test_gpuTreeComplete2D,test_gpuTreeLinearize2D,test_gpuTreeNeighbors2D.test_gpuAdaptiveCircle2D: Moving refinement region; writes VTUs toadaptive_path/+.pvd.- Disabled in
build2for nvcc 10.1 compatibility:test_gpuTreeBalance2D,test_gpuDomainMask2D,test_gpuTreeSteps2D,test_gpuTreePipeline2D,advection2D.
scripts/pngs_to_gif.py: Convertamr.*.pngsequences to GIF. Usage:python3 scripts/pngs_to_gif.py <folder> <output.gif>; deps:imageio.scripts/plot_tree_steps_cpu.py: Render quadtree CSVs (steps_out_cpu/step*.csv) to PNGs insteps_out_cpu/plots/; deps:matplotlib,pandas.scripts/plot_pipeline_steps.py: Plot pipeline VTUs if generated; deps:meshio,matplotlib.
cd build
cmake -DMORTON_DIM=2 .. # or 3
cmake --build . -- -j4
Examples:
- CPU steps:
./test_treeSteps2D_cpu→ CSVs insteps_out_cpu/. - Adaptive circle (GPU):
./test_gpuAdaptiveCircle2D [steps]→ VTUs inadaptive_path/+.pvd.
- nvcc 10.1 is strict; some CUDA tests are disabled in
build2to keep builds clean. Use a newer CUDA toolkit (e.g., 12.x) to build all GPU tests (balance, domain mask, advection). - AMR advection demo is disabled under nvcc 10.1 for the same reason.
- CSVs: Use
scripts/plot_tree_steps_cpu.pyto render quadtree tiles; PNGs saved tosteps_out_cpu/plots/. - PNG sequences:
scripts/pngs_to_gif.pyto build GIFs (e.g.,build2/Animation/amr.*.png→amr.gif). - VTUs: Load in ParaView; use
.pvdcollections for time series (e.g.,adaptive_circle.pvd).
-
scripts/pngs_to_gif.py: Convert a sequence of PNGs (amr.*.png) into an animated GIF.- Usage:
python3 scripts/pngs_to_gif.py <folder> <output.gif> - Dependencies:
pip install imageio - Example:
python3 scripts/pngs_to_gif.py build2/Animation amr.gif
- Usage:
-
scripts/plot_tree_steps_cpu.py: Plot quadtree CSV outputs (ix, iy, level) from the CPU pipeline.- Inputs:
steps_out_cpu/step*.csvgenerated bytest_treeSteps2D_cpu - Outputs: PNGs in
steps_out_cpu/plots/ - Dependencies:
pip install matplotlib pandas
- Inputs: