How max-models/patchwork works
Patchwork is a block-structured adaptive-mesh library for cell- and node-centered fields, with optional MPI distribution. Users construct a hierarchy, allocate patch fields, and can exchange halos, regrid, and plot it. Marker workflows locate and migrate points, deposit charge, accumulate it onto composite nodes, and interpolate fields back. Composite spaces support Poisson, variable-coefficient cell, and curl-curl solves using configurable backends. README documents these capabilities; source excerpts and index references support only some implementation links, so unsampled relationships are omitted.
Main entry points: hierarchy.py AMR hierarchy · nodal_poisson.py Nodal Poisson · nodes.py Composite nodes · cell_operator.py Cell operator
Components 27
Mesh and fields
- AMR hierarchy
src/patchwork/mesh/hierarchy.py - Halo exchange
src/patchwork/mesh/halos.py - Tag and regrid
src/patchwork/mesh/regrid.py - Grading and tags
src/patchwork/mesh/grading.py - Halo accumulation
src/patchwork/mesh/accumulate.py - Flux register
src/patchwork/mesh/reflux.py - Patch plotting
src/patchwork/mesh/plotting.py
Composite spaces
- Boundary conditions
src/patchwork/spaces/boundaries.py - Composite cells
src/patchwork/spaces/cells.py - Composite nodes
src/patchwork/spaces/nodes.py - Composite edges
src/patchwork/spaces/edges.py - Composite faces
src/patchwork/spaces/faces.py - Mass matrices
src/patchwork/spaces/mass.py
Composite solvers
- Nodal Poisson
src/patchwork/solvers/nodal_poisson.py - Cell operator
src/patchwork/solvers/cell_operator.py - Cell Poisson
src/patchwork/solvers/poisson.py - Curl-curl solver
src/patchwork/solvers/curl_curl.py - Linear backends
src/patchwork/solvers/backends.py - Geometric multigrid
src/patchwork/solvers/multigrid.py - PETSc system
src/patchwork/solvers/distributed.py
Marker operations
- Point location
src/patchwork/kernels/locate_points - Node deposition
src/patchwork/kernels/deposit_nodes - Block scatter
src/patchwork/kernels/scatter_blocks - Block gather
src/patchwork/kernels/gather_blocks
Other components
- Application user
- Particle markers
- Profiling tags
src/patchwork/_profiling.py
Connections 31
- Application user → AMR hierarchy: constructs
README.md - AMR hierarchy → Halo exchange: exchanges halos
src/patchwork/mesh/hierarchy.py - Application user → Tag and regrid: requests refinement
README.md - Tag and regrid → AMR hierarchy: builds hierarchy
README.md - Application user → Patch plotting: plots patches
README.md - AMR hierarchy → Halo accumulation: accumulates halos
src/patchwork/mesh/hierarchy.py - AMR hierarchy → Point location: locates points
src/patchwork/mesh/hierarchy.py - AMR hierarchy → Block scatter: scatters blocks
src/patchwork/mesh/hierarchy.py - AMR hierarchy → Block gather: gathers blocks
src/patchwork/mesh/hierarchy.py - Particle markers → AMR hierarchy: locates and migrates
README.md - Particle markers → Node deposition: deposits charge
README.md - Node deposition → Composite nodes: weights onto nodes
src/patchwork/spaces/nodes.py - Halo accumulation → Composite nodes: combines copies
README.md - Composite nodes → Particle markers: interpolates field
README.md - Application user → Nodal Poisson: solves potential
README.md - Nodal Poisson → Composite nodes: assembles unknowns
src/patchwork/solvers/nodal_poisson.py - Nodal Poisson → Linear backends: sets up solver
src/patchwork/solvers/nodal_poisson.py - Linear backends → PETSc system: creates PETSc system
src/patchwork/solvers/backends.py - Linear backends → Geometric multigrid: builds hierarchy
src/patchwork/solvers/backends.py - Application user → Cell operator: solves cell system
README.md - Cell operator → Composite cells: uses leaf cells
src/patchwork/solvers/cell_operator.py - Application user → Cell Poisson: solves Poisson
README.md - Application user → Curl-curl solver: solves curl-curl
README.md - Cell operator → Boundary conditions: uses conditions
src/patchwork/solvers/cell_operator.py - Nodal Poisson → Boundary conditions: uses conditions
src/patchwork/solvers/nodal_poisson.py - Nodal Poisson → Composite edges: uses edge space
src/patchwork/solvers/nodal_poisson.py - Composite edges → Mass matrices: uses mass blocks
src/patchwork/spaces/edges.py - Composite nodes → Mass matrices: uses mass operators
src/patchwork/spaces/nodes.py - Application user → Grading and tags: tags cells
README.md - Application user → Flux register: registers flux
- Profiling tags → AMR hierarchy: marks operations
src/patchwork/mesh/hierarchy.py