SOFIA: A Python Library for High-Quality 2D Triangular Mesh Adaptation

SOFIA: A Python Library for High-Quality 2D Triangular Mesh Adaptation - Published in JOSS (2026)

https://github.com/youssef-mesri/sofia-mesh

Science Score: 92.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
  • .zenodo.json file
  • DOI references
    Found 4 DOI reference(s) in README and JOSS metadata
  • Academic publication links
    Links to: zenodo.org
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
    Published in Journal of Open Source Software
Last synced: 17 days ago · JSON representation ·

Repository

Basic Info
  • Host: GitHub
  • Owner: youssef-mesri
  • License: mit
  • Language: Python
  • Default Branch: main
  • Size: 17.3 MB
Statistics
  • Stars: 1
  • Watchers: 0
  • Forks: 2
  • Open Issues: 0
  • Releases: 1
Created 6 months ago · Last pushed 24 days ago
Metadata Files
Readme Contributing License Code of conduct Citation

README.md

SOFIA - Scalable Operators for Field-driven Iso/Ani Adaptation

**A Modern 2D Triangular Mesh Modification Library** [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![Python 3.8+](https://img.shields.io/badge/python-3.8+-blue.svg)](https://www.python.org/downloads/) [![Tests](https://img.shields.io/badge/tests-passing-brightgreen.svg)](https://github.com/youssef-mesri/sofia-mesh/actions) [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.20053887.svg)](https://doi.org/10.5281/zenodo.20053887) [Features](#-features) • [Installation](#-installation) • [Quick Start](#-quick-start) • [API Documentation](docs/API.md) • [Examples](#-examples) • [Roadmap](#-roadmap)

What is SOFIA?

SOFIA is a pure Python library for 2D triangular mesh modification and remeshing. It provides robust, high-quality local operations to edit, refine, and optimize meshes while maintaining mesh conformity and quality.

Perfect for: - Computational scientists working with 2D simulations - Computer graphics professionals needing mesh processing - Numerical analysis requiring adaptive mesh refinement - Researchers in mesh generation and optimization


Features

Core Operations

  • Edge Split - Midpoint and Delaunay-based splitting
  • Edge Collapse - Quality-preserving mesh coarsening
  • Edge Flip - Improve triangle quality through flipping
  • Vertex Insertion/Removal - Add or remove mesh vertices
  • Pocket Filling - Fill holes in meshes intelligently
  • Boundary Operations - Safe manipulation of mesh boundaries

Quality & Robustness

  • Quality Metrics - Min angle, area, shape measures
  • Conformity Checks - Ensure valid mesh topology
  • Amortized Validation - Fast incremental checking
  • Strict Mode - Optional rigorous validation
  • Area Preservation - Maintain geometric properties

Workflows

  • Greedy Remeshing - Iterative quality improvement
  • Patch-based Processing - Batch operations on mesh regions
  • Visualization - Built-in plotting with Matplotlib
  • Extensive Testing - 50+ unit tests for reliability

Installation

Using pip (Recommended)

bash pip install sofia-mesh

From Source

bash git clone https://github.com/youssef-mesri/sofia-mesh.git cd sofia-mesh pip install -e .

Requirements

  • Python 3.8 or higher
  • NumPy ≥ 1.20
  • SciPy ≥ 1.7
  • Matplotlib ≥ 3.3

Quick Start

Basic Example - Improve Mesh Quality

```python import numpy as np from sofia import PatchBasedMeshEditor

Create a simple mesh

points = np.array([ [0.0, 0.0], [1.0, 0.0], [0.5, 0.8], [0.0, 1.0], [1.0, 1.0] ]) triangles = np.array([ [0, 1, 2], [0, 2, 3], [1, 4, 2], [3, 2, 4] ])

Initialize editor

editor = PatchBasedMeshEditor(points, triangles)

Split an edge to refine the mesh

success = editor.splitedge(edgeid=0, method='midpoint') print(f"Edge split: {success}")

Get the updated mesh

newpoints = editor.pts newtriangles = editor.tris

Check mesh quality

minangle = editor.meshminangle() print(f"Minimum angle: {minangle:.2f}°") ```

Remeshing Example

```python from sofia.core.remeshdriver import greedyremesh

Iteratively improve mesh quality

improvededitor = greedyremesh( editor, targetminangle=25.0, # Target minimum angle in degrees max_iterations=100 )

print(f"Final quality: {improvededitor.meshmin_angle():.2f}°") ```


Documentation


Examples

Check out the examples/ directory for more:

  • basic_remeshing.py - Simple mesh refinement
  • quality_improvement.py - Iterative quality optimization
  • boundary_operations.py - Boundary manipulation

Roadmap

Current (v1.0.0) - Python Implementation

  • Pure Python implementation
  • All core features working
  • Suitable for meshes up to ~10K triangles
  • Easy installation, no compilation needed

Next (v2.0) - High-Performance C++ Backend

  • 20-50x performance improvement
  • Transparent integration (same API)
  • Suitable for meshes up to 1M+ triangles
  • Optional: falls back to Python if C++ unavailable
  • Status: In development (private branch)

Future (v3.0+)

  • GPU acceleration
  • 3D tetrahedral mesh support
  • Parallel batch processing
  • Advanced anisotropic remeshing

Citation

If you use SOFIA in your research, please cite:

bibtex @software{sofia2025, author = {Mesri, Youssef}, title = {SOFIA: Scalable Operators for Field-driven Iso/Ani Adaptation}, year = {2025}, url = {https://github.com/youssef-mesri/sofia-mesh}, version = {1.0.0} }


Contributing

Contributions are welcome! Please see CONTRIBUTING.md for guidelines.


License

SOFIA is released under the MIT License.


Acknowledgments

  • Inspired by classical mesh modification algorithms
  • Built with modern Python best practices
  • Developed for research in computational geometry

Contact

Author: Youssef Mesri


**Made with love for the computational geometry community** Star us on GitHub if you find SOFIA useful!

Owner

  • Login: youssef-mesri
  • Kind: user

JOSS Publication

SOFIA: A Python Library for High-Quality 2D Triangular Mesh Adaptation
Published
May 11, 2026
Volume 11, Issue 121, Page 9729
Authors
Youssef Mesri ORCID
MINES Paris - PSL, France
Editor
Hugo Ledoux ORCID
Tags
mesh generation triangular mesh computational geometry mesh adaptation finite element method

Citation (CITATION.cff)

# Citation File Format (CFF)
# https://citation-file-format.github.io/

cff-version: 1.2.0
message: "If you use this software, please cite it as below."
type: software
title: "SOFIA: Scalable Operators for Field-driven Iso/Ani Adaptation"
version: 1.0.0
date-released: 2026-05-04
url: "https://github.com/youssef-mesri/sofia-mesh"
repository-code: "https://github.com/youssef-mesri/sofia-mesh"
license: MIT
authors:
  - family-names: "Mesri"
    given-names: "Youssef"
    email: "youssef.mesri@minesparis.psl.eu"
    affiliation: "Mines Paris - PSL"
    orcid: "https://orcid.org/0000-0002-5136-5435"
keywords:
  - mesh generation
  - triangular mesh
  - remeshing
  - computational geometry
  - mesh modification
  - mesh quality
abstract: "SOFIA is a pure Python library for 2D triangular mesh modification and remeshing. It provides robust, high-quality local operations to edit, refine, and optimize meshes while maintaining mesh conformity and quality."

GitHub Events

Total
  • Issues event: 3
  • Issue comment event: 2
  • Push event: 16
  • Create event: 1
Last Year
  • Issues event: 3
  • Issue comment event: 2
  • Push event: 16
  • Create event: 1