Metadata-Version: 2.4
Name: simgeometry
Version: 0.1.1
Summary: Shapes, grids, and simulation domains for numerical simulations
Author: Max
License-Expression: MIT
Project-URL: Source, https://github.com/max-models/simgeometry
Keywords: geometry,grids,simulation,mpi
Classifier: Development Status :: 3 - Alpha
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE.txt
Requires-Dist: cunumpy>=0.6.2
Requires-Dist: maybempi>=0.1
Requires-Dist: mpiarray>=0.1.0
Requires-Dist: numpy
Provides-Extra: dev
Requires-Dist: jupyterlab; extra == "dev"
Requires-Dist: pre-commit; extra == "dev"
Requires-Dist: pyproject-fmt; extra == "dev"
Requires-Dist: pyright; extra == "dev"
Requires-Dist: ruff; extra == "dev"
Requires-Dist: simgeometry[docs,test]; extra == "dev"
Provides-Extra: docs
Requires-Dist: griffe; extra == "docs"
Requires-Dist: simgeometry[clip,plot]; extra == "docs"
Requires-Dist: ipykernel; extra == "docs"
Requires-Dist: matplotlib>=3.10.9; extra == "docs"
Requires-Dist: nbclient>=0.11; extra == "docs"
Requires-Dist: nbformat>=5.11.1; extra == "docs"
Provides-Extra: clip
Requires-Dist: shapely>=2; extra == "clip"
Provides-Extra: evaluate
Requires-Dist: xarray; extra == "evaluate"
Provides-Extra: mesh
Requires-Dist: scikit-image>=0.22; extra == "mesh"
Provides-Extra: plot
Requires-Dist: matplotlib>=3.10; extra == "plot"
Requires-Dist: simgeometry[evaluate,mesh]; extra == "plot"
Provides-Extra: interactive
Requires-Dist: pyvista>=0.44; extra == "interactive"
Requires-Dist: simgeometry[plot]; extra == "interactive"
Provides-Extra: mpi
Requires-Dist: mpi4py; extra == "mpi"
Provides-Extra: pyccel
Requires-Dist: pyccel>2.0; extra == "pyccel"
Provides-Extra: gpu
Requires-Dist: cupy-cuda12x; extra == "gpu"
Provides-Extra: metal
Requires-Dist: mlx; (sys_platform == "darwin" and platform_machine == "arm64") and extra == "metal"
Provides-Extra: test
Requires-Dist: mpi4py; extra == "test"
Requires-Dist: pytest; extra == "test"
Requires-Dist: pytest-cov; extra == "test"
Requires-Dist: simgeometry[clip]; extra == "test"
Dynamic: license-file

# simgeometry


Geometry primitives for numerical simulations: bounded domains,
structured grids, MPI domain decomposition, and 1D, 2D, and 3D shapes.
Box, ball, and polygon containment have NumPy, Pyccel, CUDA, and Metal
implementations. Originally developed for
[Picnic](https://github.com/max-models/picnic).

## Install

``` bash
pip install simgeometry
```

For development, install this checkout with `pip install -e '.[test]'`.
NumPy, cunumpy, maybempi, and mpiarray are runtime dependencies.
Matplotlib is optional. Install `simgeometry[plot]` for plotting,
labelled evaluation and surface meshing, or `simgeometry[interactive]`
for interactive 3D clipping with PyVista. Install `simgeometry[mpi]` for
MPI, `simgeometry[pyccel]` for compiled CPU containment kernels, or
`simgeometry[gpu]` for CUDA.

## Example

``` python
from simgeometry.grid import Grid
from simgeometry.objects import Circle

boundary = Circle(midpoint=(0.5, 0.5), radius=0.25)
grid = Grid(ndim=2, lower_bound=(0, 0), upper_bound=(1, 1), num_gridpoints=(32, 32))
mask = boundary.node_mask(grid)
```

`SimulationDomain` accepts field and particle boundary objects through
their `get_bc(dir=..., side=...).bc_type` interface. Applications may
supply a seeded random function with `BoundingBox.random` and an
accelerated particle boundary implementation with
`SimulationDomain.boundary_kernel`.

## Inspect, slice, and compose

``` python
from simgeometry import Sphere

shell = Sphere((0, 0, 0), 1) - Sphere((0, 0, 0), 0.4)
shell.show_3d(opacity=0.6)
shell.slice(z=0.2).show()
inside = shell.evaluate(x=[0, 0.8], y=0, z=0)
```

Shapes support named collections, Boolean operations, affine transforms,
surface queries, point sampling, mesh export, cut-edge geometry and
approximate cell/face fractions. See the [executed
tutorials](https://max-models.github.io/simgeometry/tutorials/) and [API
guide](https://max-models.github.io/simgeometry/getting-started/geometry-api/)
for examples and the accuracy limits of sampled operations.

## Development

``` bash
pytest src/simgeometry/tests
```

Documentation: <https://max-models.github.io/simgeometry/>
