esys.pycad provides a simple way to build a mesh for your finite element simulation. You begin by building what we call a Design using primitive geometric objects, and then to go on to build a mesh from the Design. The final step of generating the mesh from a Design uses freely available mesh generation software, such as Gmsh[10] .
A Design is built by defining points, which are used to specify the corners of geometric objects and the vertices of curves. Using points you construct more interesting objects such as lines, rectangles, and arcs. By adding many of these objects into what we call a Design, you can build meshes for arbitrarily complex 2-D and 3-D structures.
The example included below shows how to use pycad to create a 2-D mesh in the shape of a trapezoid with a cutout area.
This example is included with the software in pycad/examples/trapezoid.py. If you have gmsh installed you can run the example and view the geometry and mesh with:
A CurveLoop is used to connect several lines into a single curve. It is used in the example above to create the trapezoidal outline for the grid and also for the triangular cutout area. You can use any number of lines when creating a CurveLoop, but the end of one line must be identical to the start of the next.
Sometimes you might see us write -c where c is a CurveLoop. This is the reverse curve of the curve c. It is identical to the original except that its points are traversed in the opposite order. This may make it easier to connect two curves in a CurveLoop.
The example python script above calls both d.setScriptFileName() and d.setMeshFileName(). You need only call these if you wish to save the gmsh geometry and mesh files.
Note that the underlying mesh generation software will not accept all the geometries you can create with pycad. For example, pycad will happily allow you to create a 2-D Design that is a closed loop with some additional points or lines lying outside of the enclosed area, but gmsh will fail to create a mesh for it.
esys@esscc.uq.edu.au