In this tutorial we will show the typical workflow. In particular we are going to parse the parameters file for the FFD, read an iges file of a cylinder, perform the FFD and write the results on a new iges file. We also provide the example of the
show function which is not present in Tutorial 1.
First of all we just import the required PyGeM classes and we read a parameters file.
from pygem import FFDParameters, FFD, IgesHandler params = FFDParameters() params.read_parameters(filename='../tests/test_datasets/parameters_test_ffd_iges.prm')
Now we have to load the iges file on which we will perform the FFD. Since it is an iges we use the
IgesHandler class. The
parse method extracts the control points (or poles) coordinate of the NURBS surfaces that represent each face of the iges geometry without touching the topology.
iges_handler = IgesHandler() mesh_points = iges_handler.parse('../tests/test_datasets/test_pipe.iges')
We can now use the show method to visualize the iges geometry. It basically load the file and shows its geometry. It is different from the plot method since:
Here you can see the result of
For some "backend" issues we can show only one shape for session. Be careful when you try to show many geometries in the same script.
Finally we can actually perform the FFD and then we can write the modified iges file with the new control points (or poles).
free_form = FFD(params, mesh_points) free_form.perform() new_mesh_points = free_form.modified_mesh_points iges_handler.write(new_mesh_points, 'test_pipe_mod.iges')
Sometimes the write method can fail. In fact, in write function we perform some operations like
Often, a CAD file has its own tolerance and some entities that seems to be, for instance, linked actually are not. The linking and trimming operations can be hard for the software to be performed, especially when the starting CAD has not been made for analysis but for design purposes. Thus, for non trivial geometries it could be necessary to increase the tolerance. For the cylinder this is not the case, but we can increse the tolerance as well and write a, indeed almost equal, result.
iges_handler.write(new_mesh_points, 'test_pipe_mod.iges', 1e-3)
And here we show the final shape: