pyAMG
A fast, robust mesh adaptation software for 2D and 3D complex geometries, all wrapped in Python. pyAMG is developed at Inria and released for free for non-commercial use.
pyAMG is a mesh adaptation software library developed by the GAMMA team at Inria. Its main capabilities include:
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.
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 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.
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.
pyAMG is interfaced with the open-source Computational Fluid Dynamics (CFD) solver SU2. The installation steps are the following:
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.
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.
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'.
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.