A Fast Iterative Method Python package
A Fast Iterative Method Python package - Published in JOSS (2021)
Science Score: 93.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
✓DOI references
Found 11 DOI reference(s) in README and JOSS metadata -
✓Academic publication links
Links to: joss.theoj.org -
○Committers with academic emails
-
○Institutional organization owner
-
✓JOSS paper metadata
Published in Journal of Open Source Software
Repository
This repository implements the Fast Iterative Method (FIM) for use in python
Basic Info
- Host: GitHub
- Owner: thomgrand
- License: agpl-3.0
- Language: Python
- Default Branch: master
- Size: 1.22 MB
Statistics
- Stars: 10
- Watchers: 2
- Forks: 3
- Open Issues: 1
- Releases: 5
Metadata Files
README.md
Fast Iterative Method - Numpy/Cupy
This repository implements the Fast Iterative Method on tetrahedral domains and triangulated surfaces purely in python both for CPU (numpy) and GPU (cupy). The main focus is however on the GPU implementation, since it can be better exploited for very large domains.
Details
The anisotropic eikonal equation is given by
for given boundary conditions
For a given anisotropic velocity, this can calculate the geodesic distance between a set of and all points on the domain like shown in the figure.

Note that when using multiple , they are not guaranteed to be in the final solution if they are not a valid viscosity solution. A recommended read for more details on the subject is:
Evans, Lawrence C. "Partial differential equations." Graduate studies in mathematics 19.2 (1998).
Installation
The easiest way to install the library is using pip
bash
pip install fim-python[gpu] #GPU version
If you don't have a compatible CUDA GPU, you can install the CPU only version to test the library, but the performance won't be comparable to the GPU version (see Benchmark).
bash
pip install fim-python #CPU version
Usage
The main interface to create a solver object to use is create_fim_solver
```python from fimpy.solver import createfimsolver
Create a FIM solver, by default the GPU solver will be called with the active list
Set device='cpu' to run on cpu and useactivelist=False to use Jacobi method
fim = createfimsolver(points, elems, D) ```
Example
The following code reproduces the above example
```python import numpy as np import cupy as cp from fimpy.solver import createfimsolver from scipy.spatial import Delaunay import matplotlib.pyplot as plt
Create triangulated points in 2D
x = np.linspace(-1, 1, num=50) X, Y = np.meshgrid(x, x) points = np.stack([X, Y], axis=-1).reshape([-1, 2]).astype(np.float32) elems = Delaunay(points).simplices elem_centers = np.mean(points[elems], axis=1)
The domain will have a small spot where movement will be slow
velocityf = lambda x: (1 / (1 + np.exp(3.5 - 25np.linalg.norm(x - np.array([[0.33, 0.33]]), axis=-1)*2))) velocityp = velocityf(points) #For plotting velocitye = velocityf(elemcenters) #For computing D = np.eye(2, dtype=np.float32)[np.newaxis] * velocity_e[..., np.newaxis, np.newaxis] #Isotropic propagation
x0 = np.array([np.argmin(np.linalg.norm(points, axis=-1), axis=0)]) x0_vals = np.array([0.])
Create a FIM solver, by default the GPU solver will be called with the active list
fim = createfimsolver(points, elems, D) phi = fim.compfim(x0, x0vals)
Plot the data of all points to the given x0 at the center of the domain
fig, axes = plt.subplots(nrows=1, ncols=2, sharey=True) contf1 = axes[0].contourf(X, Y, phi.get().reshape(X.shape)) axes[0].settitle("Distance from center")
contf2 = axes[1].contourf(X, Y, velocityp.reshape(X.shape)) axes[1].set_title("Assumed isotropic velocity") plt.show() ```
A general rule of thumb: If you only need to evaluate the eikonal equation once for a mesh, the Jacobi version (use_active_list=False) will probably be quicker since its initial overhead is low.
Repeated evaluations with different or
favor the active list method for larger meshes.
On the CPU, use_active_list=True outperforms the Jacobi approach for almost all cases.
Documentation
https://fim-python.readthedocs.io/en/latest
Citation
If you find this work useful in your research, please consider citing the paper in the Journal of Open Source Software
bibtex
@article{grandits_fast_2021,
doi = {10.21105/joss.03641},
url = {https://doi.org/10.21105/joss.03641},
year = {2021},
publisher = {The Open Journal},
volume = {6},
number = {66},
pages = {3641},
author = {Thomas Grandits},
title = {A Fast Iterative Method Python package},
journal = {Journal of Open Source Software}
}
Benchmark
Below you can see a performance benchmark of the library for tetrahedral domains (cube in ND), triangular surfaces (plane in ND), and line networks (randomly sampled point cloud in the ND cube with successive minimum spanning tree) from left to right.
In all cases, was placed in the middle of the domain.
The dashed lines show the performance of the implementation using active lists, the solid lines use the Jacobi method (computing all updates in each iteration).


The library works for an arbitrary number of dimensions (manifolds in N-D), but the versions for 2 and 3D received a few optimized kernels that speed up the computations.
The steps to reproduce the benchmarks can be found in the documentation at https://fim-python.readthedocs.io/en/latest/benchmark.html
Contributing
See Contributing for more information on how to contribute.
License
This library is licensed under the GNU Affero General Public License. If you need the library issued under another license for commercial use, you can contact me via e-mail tomdev (at) gmx.net.
Owner
- Name: Thomas G.
- Login: thomgrand
- Kind: user
- Repositories: 3
- Profile: https://github.com/thomgrand
JOSS Publication
A Fast Iterative Method Python package
Authors
Institute of Computer Graphics and Vision, TU Graz
Tags
eikonal partial differential equations cudaGitHub Events
Total
- Issues event: 1
- Watch event: 4
- Fork event: 1
Last Year
- Issues event: 1
- Watch event: 4
- Fork event: 1
Committers
Last synced: 7 months ago
Top Committers
| Name | Commits | |
|---|---|---|
| Thomas Grandits | t****v@g****t | 25 |
| Simone Pezzuto | s****e@p****t | 1 |
Issues and Pull Requests
Last synced: 6 months ago
All Time
- Total issues: 1
- Total pull requests: 4
- Average time to close issues: N/A
- Average time to close pull requests: about 5 hours
- Total issue authors: 1
- Total pull request authors: 2
- Average comments per issue: 0.0
- Average comments per pull request: 1.25
- Merged pull requests: 4
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 1
- Pull requests: 0
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Issue authors: 1
- Pull request authors: 0
- Average comments per issue: 0.0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- marie-cloet2000 (1)
Pull Request Authors
- thomgrand (4)
- pezzus (1)
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 1
-
Total downloads:
- pypi 223 last-month
- Total dependent packages: 0
- Total dependent repositories: 1
- Total versions: 6
- Total maintainers: 1
pypi.org: fim-python
This repository implements the Fast Iterative Method on tetrahedral domains and triangulated surfaces purely in python both for CPU (numpy) and GPU (cupy).
- Homepage: https://github.com/thomgrand/fim-python
- Documentation: https://fim-python.readthedocs.io/
- License: AGPL
-
Latest release: 1.2.2
published almost 2 years ago
Rankings
Maintainers (1)
Dependencies
- cython *
- numba *
- numpy *
- pydata_sphinx_theme *
- sphinx *
- actions/checkout v2 composite
- actions/upload-artifact v1 composite
- openjournals/openjournals-draft-action master composite
- actions/checkout v2 composite
- actions/setup-python v2 composite
- actions/checkout v2 composite
- actions/setup-python v2 composite
- pypa/gh-action-pypi-publish 27b31702a0e7fc50959f5ad993c78deac1bdfc29 composite
