Mesh generation level classes

Mesh provides the primary interface to the meshing functionality in TMR and is used to create quadrilateral and hexahedral meshes. The actual meshing operations are performed on the root processor with rank 0, but all connectivity and location information is broadcast to all processors.

Mesh attempts to mesh all tmr.TMR.Face and tmr.TMR.Volume objects contained in Model. If only a surface mesh is desired, create a new Model class without the volume objects.

TMR only supports swept volume mesh generation. This requires the specification of additional information to indicate what surfaces should be linked and what direction should be swept. This information is provided by indicating source and target geometry entities. When a source/target pair is set, the mesh connectivity is copied from the source to the target. A swept volume can only be created if:

  1. Volume contains a source/target Face object pair that share the same number of edge loops and each source/target edge pair has the same number of nodes.

  2. All other Face objects are structured with the same number of nodes along the swept direction.

To ensure these conditions apply, it is often necessary to set source/target pairs for faces and edges.

The primary mesh-level functions are as follows:

  • class tmr.TMR.Mesh

    Mesh the geometry model. This class handles the meshing for surface objects without any additional information. For hexahedral meshes, the model must have a source or target.

    createModelFromMesh(self)

    Create a geometry model based on the input mesh

    Returns

    The Model geometry representation of the underlying mesh

    Return type

    Model

    getHexConnectivity(self)

    Retrieve the global connectivity from the hexahedral mesh

    Returns

    Numpy array of the hexahedral connectivity

    Return type

    np.ndarray

    getMeshPoints(self)

    Retrieve a global array of the mesh locations

    Returns

    Numpy array of the node locations

    Return type

    np.ndarray

    getQuadConnectivity(self)

    Retrieve the global connectivity from the quadrilateral mesh

    Returns

    Numpy array of the quadrilateral connectivity

    Return type

    np.ndarray

    getTriConnectivity(self)

    Retrieve the global connectivity from the triangular mesh

    Returns

    Numpy array of the triangle connectivity

    Return type

    np.ndarray

    mesh(self, h=1.0, opts=None, fs=None)

    Mesh the model with the provided mesh spacing h, default meshing options MeshOptions opts if it is not provided or given ElementFeatureSize fs

    Parameters
    writeToBDF(self, fname, outtype=None)

    Write both the quadrilateral and hexahedral mesh to a BDF file

    Parameters
    • fname (str) – File name

    • outtype (str) – Type of mesh to output to BDF file i.e. quad or hex

    writeToVTK(self, fname, outtype=None)

    Write both the quadrilateral and hexahedral mesh to a VTK file

    Parameters
    • fname (str) – File name

    • outtype (str) – Type of mesh to output to VTK file i.e. quad or hex

MeshOptions class defines a number of options that modify the meshing algorithm. These include the following:

  • class tmr.TMR.MeshOptions

    Defines a number of options that modify the meshing algorithm.

    frontal_quality_factor

    Use the mesh quality indicator to determine when to accept new triangles in the frontal algorithm.

    Parameters

    value (float) – Quality factor

    mesh_type_default

    Default mesh type either structured or unstructured. In the case that it is set to structured, the algorithm firsts checks if it is possible to use a mapped mesh, and reverts to an unstructured algorithm otherwise.

    num_smoothing_steps

    Number of smoothing steps to apply during both the Laplacian and quad smoothing algorithms

    Parameters

    value (int) – Number of smoothing steps

    triangularize_print_level

    Print level to provide more verbosity during the triangularization algorithm

    Parameters

    value (int) – Print level for the operation

    write_mesh_quality_histogram

    Write out a histogram of the mesh quality in the final smoothed quadrilateral mesh.

    Parameters

    value (bool) – Whether or not to write the mesh quality histogram

ElementFeatureSize class is a base class that can be used to define the feature size of the elements in the mesh.

  • class tmr.TMR.ElementFeatureSize

    Base class for creating feature size

The mesh itself is created by meshing the vertices, edges, faces, and volumes within the mesh. These meshes are stored in the following classes:

The EdgeMesh object is created by first computing the number of nodes along its length, and then globally ordering the nodes. The number of nodes is determined based on the following criteria:

  1. If the first and second vertices are different, then at least 3 nodes are created along the edge.

  2. If the first and second vertices are the same and the edge is not degenerate, then it forms a loop back on itself and at least 5 nodes are created (double counting the first and last node number).

  3. If the edge is a target edge, the number of nodes is taken from the source edge.

  4. Otherwise, the number of nodes is selected as an odd number that most closely matches the spacing requested along the edge.

  • class tmr.TMR.EdgeMesh

    This is the class that stores the node numbers along an edge

  • class tmr.TMR.FaceMesh

    This is the class that stores the structured/unstructured surface mesh

  • class tmr.TMR.VolumeMesh

    This is the class that stores the hexahedral mesh