GMAC
A fast geometry manipulation and creation library made in rust, with a convenient python interface, and very few dependencies. Primary features include:
- Create primitives
- Transform geometries (or selection just a selection of nodes)
- Large range of selection and transformation tools
- Deform geometries using RBF and FFD
- Convenient python interface (gmac_py)
- Fast and memory efficient
Here's a demonstration of a plane tail deformed using the Free Form deformer (FFD):
| Variation 1 | Variation 2 |
|---|---|
![]() |
![]() |
Both plane tail variations were created using the Gmac Free Form deformer (FFD).
Setup
Python
Make sure that Python3 is installed on your system.
Rust
Ensure Cargo is installed on your system.
Contributing
Build python from source
These instructions assume that Python3 and Cargo are installed on your system. To set up this project, follow these steps:
- Clone the repository:
- Create a virtual environment and install build system:
- Build the release binary:
- Build the python wheel:
Examples in Python
Using GMAC to deform a box
Heres a simple demonstration where we deform a box mesh using RbfDeformer from the gmac_morph library.
Firstly lets import the required modules and create a box mesh that we intend to deform using the generate_box function:
=
Now lets define some control points to use in the training of our RBF deformer. We use generate_block_cluster to create a grid of 3D points:
=
Now before we define the deformed control points we want to use as the output training data for our RBF deformer, lets select nodes that we want to change from the original control points. GMAC has various selection tools to allow you to select nodes of the mesh, in this case we utilise select_nodes_in_plane_direction to select the nodes in the direction of a plane:
=
We will define our deformed control points by transforming the target points of the original control points. To do this we will utilise one of GMACs various transformation tools, in this case transform_points. We define our transformation using a transformation matrix, in this case we will translate, rotate and scale the target points:
=
=
Now we can set up the RbfDeformer using these original and deformed control points as well as some other parameters specific to the the RBF interpolator. Using this deformer we can deform the original box:
=
=
Here you can see the original control points and mesh, as well as the deformed control points and mesh:
| Original box | Deformed box |
|---|---|
![]() |
![]() |
Similarly the Free Form Deformer can be used. This gives more control over the deformation process and can be used for deforming specific parts of the mesh without affecting the rest of the mesh. Starting from the same geometry as before, we can define a design block (the specific region we want to deform) and deform the geometry as follows:
=
=
=
=
=
=
=
| Original box | Deformed box |
|---|---|
![]() |
![]() |
Examples in Rust
Using GMAC to deform a box
Using the gmac_morph library a box can be deformed using both RBF and FFD tools. In this case we will demonstrate the FFD process. Firstly lets import the modules required and create a box:
use generate_box;
use ;
use ;
use ;
Now lets specify the design block that we want to use to map our deformation:
...
let design_block =
new;
We will now deform the design block nodes so that the deformation can be mapped to the box. First we will clone the nodes. Then select the last layer of the nodes and transform it:
...
let free_design_ids = design_block.select_free_design_nodes.unwrap;
let mut deformed_design_nodes = design_block.nodes.clone;
let transformation_matrix =
build_transformation_matrix;
free_design_ids.iter.for_each;
...
Lets create the free form deformer and deform the target nodes:
...
let ffd = new;
geometry.nodes = ffd.deform.unwrap;
write_vtu.unwrap;
write_stl.unwrap;
...
References
The gmac_morph is heavily influenced by PyGEM (https://github.com/mathLab/PyGeM), and the following
Sieger, Menzel, Botsch. On Shape Deformation Techniques for Simulation-based Design Optimization. SEMA SIMAI Springer Series, 2015.
Lombardi, Parolini, Quarteroni, Rozza. Numerical Simulation of Sailing Boats: Dynamics, FSI, and Shape Optimization. Springer Optimization and Its Applications, 2012.





