Skip to main content

Polynomial And NURBS Toolkit

Project description

PaNTr

PyPI version Python versions License: MIT Documentation Status

Polynomial and NURBS Toolkit (PaNTr) is a pure Python 3.11–3.14 library for geometric modeling and numerical analysis using NumPy, SciPy, and Numba.

Documentation: pantr.readthedocs.io

Features

  • B-spline & NURBS spaces — univariate and tensor-product BsplineSpace, exact rational (NURBS) geometry, evaluation and derivatives, knot insertion/removal, degree elevation, and splitting.
  • Bézier toolkit — Bernstein/Bézier curves and patches, composition, products, degree reduction, and Bernstein-polynomial root finding.
  • Truncated hierarchical B-splinesTHBSplineSpace with local refinement, mirroring the tensor-product API.
  • Constructive geometry (pantr.cad) — lines, circles and arcs, disks, cylinders, extrusion, revolution, sweep, ruled and Coons surfaces/volumes.
  • Structured grids (pantr.grid) — tensor-product and hierarchical grids, BVH spatial queries, dolfinx-style cell/facet tags, and cell quadrature.
  • Quadrature and change of basis — Gauss–Legendre and tensor-product rules, plus exact change of basis operators between Bernstein, Lagrange, monomial, and cardinal B-spline bases.
  • Fast and typed — Numba-JIT kernels parallelized over CPU cores, with strict type hints across the public API.
  • Dependency-gated MPI and visualizationpantr.mpi distributes spaces across ranks once mpi4py is installed, and pantr.viz renders exact higher-order geometry through PyVista / VTK once PyVista is installed. Both modules ship with PaNTr; only their backends are optional.

Installation

pip install pantr

Requires Python 3.11–3.14. The serial core depends only on NumPy, SciPy, Numba, and threadpoolctl.

To install the latest development version from source:

git clone https://github.com/FELIGN/pantr.git
cd pantr
pip install .

Quick start

A geometry is a function space plus control points; build one and evaluate it:

import numpy as np
from pantr.bspline import Bspline, BsplineSpace, BsplineSpace1D

# Quadratic 1-D space on the knot vector [0, 0, 0, 1, 2, 3, 3, 3]
space = BsplineSpace([BsplineSpace1D([0, 0, 0, 1, 2, 3, 3, 3], 2)])

# Five 2-D control points -> a planar curve
control_points = np.array(
    [[0.0, 0.0], [1.0, 2.0], [2.0, -1.0], [3.0, 1.0], [4.0, 0.0]]
)
curve = Bspline(space, control_points)

# Evaluate at 50 parameters spanning the domain [0, 3]
points = curve.evaluate(np.linspace(0.0, 3.0, 50))  # shape (50, 2)

See the getting-started guide for a full walkthrough from this first curve to NURBS, CAD modeling, and refinement.

Optional features

Every install of PaNTr includes all of its modules — pantr.viz and pantr.mpi among them. Those two stay dormant until their third-party backend is importable, and activate automatically once it is; until then, calling into them raises a clear, actionable error (nothing else is affected). The "extras" below add no PaNTr code — they are just a convenience that installs the backend for you, so pip install "pantr[viz]" and pip install pyvista are equivalent.

Capability Module Backend it needs Install (extra or direct)
Visualization & VTK export pantr.viz pyvista (+ VTK) pip install "pantr[viz]" · or pip install pyvista
Distributed (MPI) spaces pantr.mpi mpi4py (+ an MPI library) pip install "pantr[mpi]"
METIS partitioning backend pantr.bspline.partition_graph pymetis pip install "pantr[metis]"

The serial core (pantr.grid, pantr.bspline, …) never imports pantr.mpi, so a plain pip install pantr behaves identically with or without these backends. Contributors can grab everything — including the docs toolchain (Sphinx) — with pip install -e ".[dev]".

Development

pip install -e ".[dev]"   # includes all optional feature extras

License

PaNTr is licensed under the MIT License. See LICENSE for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pantr-0.6.0.tar.gz (707.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pantr-0.6.0-py3-none-any.whl (450.0 kB view details)

Uploaded Python 3

File details

Details for the file pantr-0.6.0.tar.gz.

File metadata

  • Download URL: pantr-0.6.0.tar.gz
  • Upload date:
  • Size: 707.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for pantr-0.6.0.tar.gz
Algorithm Hash digest
SHA256 e2a7813534a392f3c6e8a09dbf152dfd030de088f3b90c1c6449786c4d73431d
MD5 3fccc19458d4960936364abb2e4eb424
BLAKE2b-256 40d85dd887c573d55c465306136ad612a9196cd675de65bdbad41fa428c63384

See more details on using hashes here.

Provenance

The following attestation bundles were made for pantr-0.6.0.tar.gz:

Publisher: release.yaml on FELIGN/pantr

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pantr-0.6.0-py3-none-any.whl.

File metadata

  • Download URL: pantr-0.6.0-py3-none-any.whl
  • Upload date:
  • Size: 450.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for pantr-0.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b681b48440071246ed9b9529faf660dc379388b490478197ed9319bdf831aea7
MD5 fc94207d6f34e7822f2b123c7f58994f
BLAKE2b-256 c9a03697bfc8b7bea7cb3cc3d9f6418bbfc8583101ede04df163ed0593c61c3c

See more details on using hashes here.

Provenance

The following attestation bundles were made for pantr-0.6.0-py3-none-any.whl:

Publisher: release.yaml on FELIGN/pantr

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page