What is pyAMG?

pyAMG is a mesh adaptation software library developed by the GAMMA team at Inria. Its main capabilities include:

  • Volume and surface remeshing through local modifications
  • Metric computation from a solution field using a multiscale metric
  • Metric field correction using anisotropic gradation
  • Solution field interpolation from one mesh onto another

Interface with SU2

pyAMG is interfaced with SU2, an open-source collection of software for multi-physics simulation and design on unstructured meshes (i.e., CFD and beyond) developed in the Aerospace Design Lab (ADL) at Stanford University.

Mesh adaptation algorithm.

Mesh adaptation algorithm: successive calls to SU2 and pyAMG.

The pyAMG/SU2 interface is presented in the examples below.

SU2: An Open-Source Suite for Multiphysics Simulation and Design, T.D. Economon et al. (2016). AIAA Journal , Vol. 54, No. 3 (2016), pp. 828-846.

pyAMG References

  1. Mesh generation and adaptation, A. Loseille (2017). Handbook on Numerical Methods for Hyperbolic Problems: Applied and Modern Issues , Chapter 12, Elsevier, 2017.
  2. Metric-orthogonal Anisotropic Mesh Generation, A. Loseille (2014). Procedia Engineering , Vol 163, pp. 403-415, 2014.
  3. A decade of progress on anisotropic mesh adaptation for computational fluid dynamics, F. Alauzet and A. Loseille (2016). Computer-Aided Design , Vol 72, pp. 13-39, 2016.

Contact

Downloading pyAMG

pyAMG is the property of Inria and is free for evaluation purposes and non-commercial uses. It cannot be included in any third package without prior agreement. Python distributions are available for Linux and MacOS. See installation for instructions regarding the setup.

Installation

After downloading the python wheel corresponding to your architecture, open a terminal and follow these steps to install pyAMG using pip, the python installer. Note that Python 2.7 (or newer) is required.

tar -zxvf pyamg-inria.macos64bits.tgz
pip install pyamg-inria.macos64bits.whl
In case you don't have root access, you can specify an installation location using --prefix, and set your PYTHONPATH environment variable accordingly.
pip install pyamg-inria.macos64bits.whl --prefix=/path/to/install
EXPORT PYTHONPATH=/path/to/install/lib/python2.7/site-packages:$PYTHONPATH

Now that pyAMG is setup, you can check how to use it together with SU2, or jump straight to the quick start.

SU2/pyAMG interface installation

pyAMG is interfaced with the open-source Computational Fluid Dynamics (CFD) solver SU2. The installation steps are the following:

  1. Install a custom version of SU2
  2. Run an example

Install a custom version of SU2

This custom version of SU2 includes the python script mesh_adaptation_amg.py that drives the mesh adaptation process by calling SU2 and pyAMG according to parameters provided by the user in the SU2 configuration file (e.g. number of iterative loops, mesh sizes etc.).

To install SU2, start by cloning the following github repository.

git clone https://github.com/vmenier/SU2.git
cd SU2
git checkout develop
Then, build SU2 from source and do not forget to set your environment variables.

Run an example

Running an adaptive case using pyAMG and SU2 is done only by adding a few lines to the SU2 configuration file and calling the mesh_adaptation_amg.py python script. Examples are provided in the examples page.

Quick start

Python data structures

In pyAMG, a mesh is stored as a dictionary. Each key points to an array representating the cordinates, geometry, connectivity, ... The keys are 'xy' for the coordinates of a 2D mesh and 'xyz' for a 3D mesh. The connectivity is provided by 'triangles', 'tetrahedra', 'edges'.

A very simple 2D example

This is the simplest example there is. We start by defining the mesh of a unit square that contains only two triangles, by filling mesh['Triangles']. Then, the pyamg mesh adaptation function is called with a maximal edge size set to 0.5, generating a final mesh containing 6 triangles.

The output mesh in the Gamma mesh format (*.mesh[b]). Information about this format is available on the repository of the libmesh7 library, a light open-source I/O library.

import pyamg
mesh = {}
mesh['xy']        = [ [0,0], [1,0], [1,1], [0,1] ]
mesh['Triangles'] = [ [1,2,3,0],[3,4,1,0]]
print "Writing initial_mesh.mesh"
pyamg.write_mesh(mesh, "initial_mesh.mesh")
remesh_options = {'hmax':0.5}
print "Refining mesh and writing refined_mesh.mesh"
adapted_mesh = pyamg.adapt_mesh(mesh,remesh_options)
pyamg.write_mesh(adapted_mesh, "refined_mesh.mesh")

A series of examples of increasing complexity is available below.

Examples

Some adaptive simulations powered by pyAMG.