Skip to main content

SSplines

Simplex Splines on the Powell-Sabin 12-split

Build Status Coverage Status Downloads DOI

SSplines is a Python library for the evaluation of simplex splines over the Powell-Sabin 12-split of a triangle. The library provides efficient evaluation using the matrix recurrence relation for S-spline basis functions for constant, linear, and quadratic simplex splines as developed by Cohen, Lyche and Riesenfeld. The SSplines library was developed as part of the thesis: Simplex Splines on the Powell-Sabin 12-Split.

Features

  • SplineFunction objects: Callable spline functions over a single triangle
  • SplineSpace objects: Facilitate instantiation of multiple functions in the same spline space
  • Evaluation and differentiation: Support for constant, linear, and quadratic simplex splines with convenient shortcuts for gradient, divergence, and Laplacian operators
  • Hermite basis conversion: Conversion between quadratic S-spline basis and quadratic Hermite nodal basis for finite element methods
  • Triangle sampling: Methods for sampling triangles for evaluation and visualization
  • Numerical integration: Basic subdomain integration methods over the Powell-Sabin 12-split for finite element computations
  • Polynomial pieces: Methods for returning polynomial restrictions of splines to each of the twelve sub-triangles
  • Symbolic computation: Integration with SymPy for exact symbolic calculations

Installation

Using pip

pip install SSplines

Using uv (recommended for development)

# Install uv first (if not already installed)
curl -LsSf https://astral.sh/uv/install.sh | sh

# Install SSplines
uv pip install SSplines

# For development with testing and visualization
uv pip install "SSplines[dev]"

Local installation

git clone https://github.com/qTipTip/SSplines
cd SSplines
uv pip install -e ".[dev]"

Quick Start

Basic Usage

import numpy as np
from SSplines import SplineSpace, SplineFunction

# Define a triangle
triangle = np.array([
    [0, 0],
    [1, 0], 
    [0, 1]
])

# Create a quadratic spline space
space = SplineSpace(triangle, degree=2)

# Get the dimension of the space
print(f"Spline space dimension: {space.dimension}")  # 12 for quadratic

# Create a spline function with random coefficients
coefficients = np.random.rand(space.dimension)
spline_func = space.function(coefficients)

# Evaluate the spline at points
points = np.array([
    [0.3, 0.3],
    [0.1, 0.2],
    [0.5, 0.1]
])
values = spline_func(points)
print(f"Spline values: {values}")

Working with Basis Functions

# Get all basis functions
basis_functions = space.basis()

# Evaluate the first basis function
first_basis = basis_functions[0]
value_at_point = first_basis([0.3, 0.3])

# Compute derivatives
gradient = first_basis.grad([0.3, 0.3])
laplacian = first_basis.lapl([0.3, 0.3])

Hermite Basis

# For quadratic splines, you can use Hermite basis
hermite_basis = space.hermite_basis()

# Each Hermite basis function corresponds to nodal values or derivatives
h0 = hermite_basis[0]  # Value at first vertex
h1 = hermite_basis[1]  # x-derivative at first vertex
h2 = hermite_basis[2]  # y-derivative at first vertex

Symbolic Computation

from SSplines.symbolic import polynomial_basis_quadratic

# Get symbolic polynomial representations
symbolic_basis = polynomial_basis_quadratic(triangle)

# Each entry contains the polynomial pieces over the 12 sub-triangles
print(f"Number of polynomial pieces: {len(symbolic_basis[0])}")  # 12

Dependencies

  • Core dependencies:

    • numpy ≥ 1.24.0: Numerical computations
    • sympy ≥ 1.10: Symbolic mathematics
  • Development dependencies:

    • pytest ≥ 7.0.1: Testing framework
    • pytest-cov: Test coverage
    • matplotlib ≥ 3.5.1: Plotting and visualization

Development

Setting up a development environment

# Clone the repository
git clone https://github.com/qTipTip/SSplines
cd SSplines

# Install in development mode with all dependencies
uv pip install -e ".[dev]"

Running tests

# Run all tests
uv run pytest

# Run with coverage
uv run pytest --cov SSplines/

# Run specific test file
uv run pytest tests/test_spline_function.py -v

Code structure

SSplines/
├── __init__.py              # Main module exports
├── constants.py             # Mathematical constants and lookup tables
├── helper_functions.py      # Core computational functions
├── simplex_spline.py        # SimplexSpline class
├── spline_function.py       # SplineFunction class  
├── spline_space.py          # SplineSpace class
├── symbolic.py              # Symbolic computation utilities
└── dicts.py                 # Lookup dictionaries for sub-triangles

Mathematical Background

The library implements S-splines on the Powell-Sabin 12-split, which divides a triangle into 12 sub-triangles by:

  1. Adding a point at the centroid
  2. Adding midpoints on each edge
  3. Connecting these points to create 12 sub-triangles

The S-splines are defined using a matrix recurrence relation that allows efficient evaluation without explicit polynomial representation. This approach is particularly useful for:

  • Finite element methods
  • Computer-aided geometric design
  • Approximation theory
  • Scientific computing applications requiring smooth basis functions

Contributing

Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Citation

If you use SSplines in your research, please cite the original theoretical work and the software implementation:

Original S-splines theory:

@article{cohen2013splines,
  title={S-splines},
  author={Cohen, Elaine and Lyche, Tom and Riesenfeld, Richard},
  journal={Mathematics of Computation},
  volume={82},
  number={283},
  pages={1577--1596},
  year={2013},
  doi={10.1090/S0025-5718-2013-02664-6}
}

SSplines software and implementation:

@mastersthesis{stangeby2018ssplines,
  title={Simplex Splines on the Powell-Sabin 12-Split},
  author={Stangeby, Ivar Haugal{\o}kken},
  school={University of Oslo},
  year={2018},
  url={http://hdl.handle.net/10852/64070},
  urn={URN:NBN:no-66606}
}

Software repository:

@software{stangeby2024ssplines,
  title={SSplines: Simplex Splines on the Powell-Sabin 12-split},
  author={Stangeby, Ivar},
  year={2024},
  doi={10.5281/zenodo.15742326},
  url={https://github.com/qTipTip/SSplines}
}

Author

Ivar Stangeby - istangeby@gmail.com

Links

Metadata

Release files for SSplines 3.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for SSplines 3.0.0
File Size Uploaded
ssplines-3.0.0.tar.gz 23.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for SSplines 3.0.0
File Interpreter ABI Platform
ssplines-3.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 44.9 kB

Release files / ssplines-3.0.0.tar.gz

Download URL ssplines-3.0.0.tar.gz
Size 23.6 kB
Tags Source
SHA-256 checksum
How to use checksums
9126ae17f50e489fb20e312d7e10fcd3ed29d2cd61db5400b80dd0e4f8e51126
BLAKE2b-256 checksum
How to use checksums
7712d88ccf79e14b7a55c10694f547aa83622327cdfb78e5babeb64c86e1670c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 25, 2025.

Transparency log

Release files / ssplines-3.0.0-py3-none-any.whl

Download URL ssplines-3.0.0-py3-none-any.whl
Size 21.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7da2627ca3f7815c8bea338672b7e295c849b9dfd2e8d1ee20cf382ba3d69f4e
BLAKE2b-256 checksum
How to use checksums
fa2d4cceae9caf84e8ce180764526db2ca5291b3d79a1390f2efb0a9d584460c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 25, 2025.

Transparency log

Release history Release notifications | RSS feed

This release

3.0.0 This release

2 release files

2.0.1

2 release files

2.0.0

2 release files

1.1.1

1 release file

1.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page