Getting Started#
MyMesh is a Python package that can be used to write python scripts are be used interactively, for example in Jupyter Notebooks or other IPython environments. It can also be used in Matlab through Matlab’s Python interface (see Using MyMesh in MATLAB).
What do you want to do?#
There are a lot of different things you can do with MyMesh, depending on what you’re trying to do, there are different places to start.
What do you want to create a mesh from?
See also Mesh Generation Examples.
Functions, specifically implicit functions, can be turned into meshes using the
implicit module.
A few pre-defined implicit functions are available in
implicit, such as sphere(), torus(), and triply periodic
minimal surfaces like gyroid().
See the user guide on Implicit Meshing for further
explanation of what implicit functions are and how to pre-defined them, and the implicit mesh generation tools
available in the implicit module:
VoxelMesh(), SurfaceMesh(), TetMesh().
Both 2D and 3D images can be converted
into meshes using the image module.
Point clouds can be triangulated/tetrahedralized with the
delaunay module. The convex hull and alpha shapes
(concave hulls) can be by identified with
mymesh.delaunay.ConvexHull()/mymesh.delaunay.AlphaShape().
Oriented points (those with normal vectors associated with them)
can be reconstructed into an implicit function using
mymesh.implicit.SurfaceReconstruction().
If you’re starting from scratch, a number of options are
available. You can start with predefined shapes in the
primitives module, including spheres, boxes, cylinders, or use demo models from mymesh.demo_mesh().
From there, you can use
explicit mesh boolean operations to make
more complex shapes from simple shapes.
You can also use sweep construction methods like
mymesh.primitives.Revolve() and
mymesh.primitives.Extrude() to build up meshes from
1D to 2D and 2D to 3D.
If you have a model designed in a computer aided design (CAD) software, most softwares have features to export models as STL files (which store the geometry as a triangular surface mesh).
You can then read() the STL file to
work with it in MyMesh.
MyMesh doesn’t currently have any capabilities to work with other CAD files like .step or .iges files.
See also Mesh Analysis Examples.
There are many geometric properties that can be calculated from
meshes.
The mesh object can calculate many of these
on-demand, for example surface normal vectors (ElemNormals, NodeNormals), bounding boxes (aabb, mvbb). Additionally, the curvature module can be used to calculate surface curvatures in several different ways (see also the Curvature Analysis examples and the Curvature theory guide).
Maintaining high element quality is essential in many mesh-based simulations in order to obtain accurate results.
The quality module contains functions to calculate a variety of different mesh quality metrics.
In addition to the fundamental connectivity of nodes into elements, there is other connectivity information that can be useful in various situations, such as the nodes neighboring each node (NodeNeighbors), the elements connected to each node (ElemConn), etc.
In meshes that may contain multiple, disconnected regions, it can also be useful to identify the connected nodes (mymesh.utils.getConnectedNodes()) or connected elements (mymesh.utils.getConnectedElements()).
See also Mesh Modification Examples.
The improvement module has various tools that can be to improve mesh quality, such as smoothing (e.g. LocalLaplacianSmoothing(), TaubinSmoothing()) and edge contraction/coarsening (Contract())
Sometimes it can be useful to convert meshes from one form to another, such as extracting the surface from a volumetric mesh, converting a hexahedral mesh to a tetrahedral mesh, or converting first-order (linear) elements to second-order (quadratic) elements (or vice versa).
The converter module has a variety of functions for performing such conversions.
the mesh class also has attributes to access the Surface or Boundary representations of meshes.
If you have an existing mesh with values associated with the nodes and/or elements of the mesh, you can Threshold() or Contour() the mesh based on those values.
You can also Crop() the a mesh by specifying bounds or Clip() the mesh by a plane.
If you have two representations of an object, or two similar objects, you can perform registration to align them with the register module.