Geometry classes

TMREntity

Almost all classes in TMR inherit from Entity. Those that do not are low-level data structures that are used within high-level operations. Entity defines a reference counting scheme for all objects allocated on the heap. This is handled automatically through the Python interface.

Loading a model

The primary geometry-level classes used within TMR consist of entity-level classes (Vertex, Edge, and Face) and container-level classes (EdgeLoop, Volume, and Model). The member functions for these classes are described below.

The geometry of a model is contained within the class Model and is often created by a call to the function LoadModel(). This function loads the model data from a STEP, IGES or EGADS file and creates the TMR versions of the geometric entities and containers that define the model. This call attempts to remove any extraneous geometry defined in the file but not contained within the model. This function creates and initializes the internal topology of the model, which can then be used in subsequent meshing operations:

  • tmr.TMR.LoadModel(fname, print_lev=0)

    Load and initialize a Model class based on information within a STEP, IGES or EGADS file. The file type is determined based on the extension.

    Parameters
    • fname (str) – Name of the geometry file

    • print_lev (int) – Print level for operation

    Returns

    An instance of a Model class

    Return type

    Model

Alternatively, a Model instance can be created by direct in-memory wrapping of EGADS objects through egads4py:

  • tmr.TMR.ConvertEGADSModel()

    LoadModel(egads_model, print_lev=0)

    This function wraps the egads4py object with the TMR interface layer and creates a Model class.

    Parameters
    • egads_model (pyego) – Model created from egads4py

    • print_lev (int) – Print level for operation

    Returns

    An instance of a Model class

    Return type

    Model

A direct connection between the geometry and octree or quadtree levels is provided through Topology that defines the topology for mapped-quadrilateral and hexahedral geometries. This class can be created directly, but it is most common to create this using the mesh-level classes.

Geometry interface

The interface classes to the underlying geometry consist of:

  • class tmr.TMR.Vertex

    The vertex class is used to store both the point and to represent the underlying geometry

    checkMatching(self, v, tol=1e-6)

    Check if two verticies are coincident, within a given tolerance

    Parameters
    • v (Vertex) – Vertex to check

    • tol (float) – Tolerance for

    evalPoint(self)

    Evaluate the point on the parametric surface and returns the node location

    Returns

    the vertex location

    Return type

    np.ndarray

    getCopySource(self)

    Get the copy source object.

    Returns

    Vertex object, None if no source is set

    Return type

    Vertex

    getEntityId(self)

    Get the entity id associated with the Vertex

    Returns

    Id number of the object, -1 for NULL object

    Return type

    int

    getName(self)

    Get the name associated with the Vertex

    Returns

    Name associated with the entity

    Return type

    str

    isSame(self, v)

    Check if the two objects are geometrically equivalent using the underlying CAD kernel.

    Parameters

    v (Vertex) – Vertex to check

    Returns

    True if the same, False otherwise

    Return type

    bool

    isSameObject(self, v)

    Check if the two objects have the same pointer

    Parameters

    v (Vertex) – Vertex to check

    Returns

    True if the same object, False otherwise

    Return type

    bool

    setCopySource(self, v)

    Set the copy source object. The node number for this vertex is copied from the copy source during meshing, effectively merging this Vertex and the copy source Vertex in the final mesh.

    Parameters

    v (Vertex) – New vertex source

    setName(self, aname)

    Set the name associated with the Vertex

    Parameters

    aname (str) – Name associated with the Vertex

    setNodeNum(self, num)

    Set the node number associated with the Vertex

    Parameters

    num (int) – Node number associated with the Vertex

  • class tmr.TMR.Edge

    The edge class is used to store both the points on an edge and to represent the underlying geometry

    checkMatching(self, e, tol=1e6)

    Check if two edges are coincident, within a given tolerance.

    Parameters
    • e (Edge) – The Edge object to check

    • tol (float) – The tolerance to use in the check

    Returns

    True if the Edges match, False otherwise

    Return type

    bool

    evalDeriv(self, t)

    Evaluate a position on an edge and the derivative of the position from a single parametric argument t.

    Returns

    The (x,y,z) position np.ndarray: The derivative of position with respect to t

    Return type

    np.ndarray

    evalPoint(self, t)

    Evaluate a position on an edge from a single parametric argument t. Provides access to the first and second vertices that begin/end the edge.

    Parameters

    t (float) – Parameteric location

    Returns

    the (x,y,z) location

    Return type

    np.ndarray

    getCopySource(self)

    Get the source Edge object for the node numbers

    Returns

    Edge object, None if no source is set

    Return type

    Edge

    getEntityId(self)

    Get the entity id associated with the edge

    Returns

    Id number of the model, -1 for NULL object

    Return type

    int

    getName(self)

    Get the name associated with the edge

    Returns

    Name associated with the entity

    Return type

    str

    getRange(self)

    Get the range of parameter values for this edge.

    Returns

    The parametric end points for the edge.

    Return type

    tmin, tmax

    getSource(self)

    Get the source Edge object

    Returns

    Edge object, None if no source is set

    Return type

    Edge

    getVertices()

    getVertices(self):

    Get the start and edge vertices associated with the edge

    Returns

    First vertex at the starting point of the edge v2 (Vertex): Second vertex at the end point of the edge

    Return type

    v1 (Vertex)

    invEvalPoint(self, pt)

    Returns the result of an inverse evaluation on the edge.

    Parameters

    pt (list) – The position for the inverse evaluation

    Returns

    Fail flag to indicate success/failure t (float): The parametric point

    Return type

    fail (bool)

    isDegenerate(self)

    Is this edge degenerate (edge length = 0)

    Returns

    True if degenerate, false otherwise

    Return type

    bool

    isSame(self, e)

    Check if the two objects are geometrically equivalent using the underlying CAD kernel.

    Parameters

    e (Edge) – Edge to check

    Returns

    True if the same, False otherwise

    Return type

    bool

    isSameObject(self, e)

    Check if the two objects have the same pointer

    Parameters

    e (Edge) – Edge to check

    Returns

    True if the same object, False otherwise

    Return type

    bool

    setCopySource(self, e)

    Set the source Edge object for the node numbers

    Parameters

    e (Edge) – New edge source

    setMesh(self, mesh)

    Set the EdgeMesh object associated with the edge

    Parameters

    mesh (EdgeMesh) – The EdgeMesh object set for this edge

    setName(self, aname)

    Set the name associated with the edge

    Parameters

    aname (str) – Name associated with the edge

    setSource(self, e)

    Set the source Edge object. When this edge is meshed, the number of nodes along the edge will be equal to the number of nodes along the source Edge. The source Edge will be meshed first. Note that this is different than the setCopySource() which also copies the node numbers from the copy source edge.

    Parameters

    e (Edge) – New edge source

    setVertices(self, v1, v2)

    Set the start and end vertices of the edge

    Parameters
    • v1 (Vertex) – First vertex at the starting point of the edge

    • v2 (Vertex) – Second vertex at the end point of the edge

    writeToVTK(self, fname)

    Write the Edge to a VTK file for visualization.

    Parameters

    fname (str) – File name

  • class tmr.TMR.Face

    The face class is used to store both the points and edges and to represent the underlying geometry

    addEdgeLoop(self, _dir, loop)

    Add an EdgeLoop object to the Face.

    Parameters
    • _dir – The direction of the EdgeLoop

    • loop – The EdgeLoop object to add

    checkMatching(self, f, tol=1e6)

    Check if the two Faces are coincident, within a given tolerance.

    Parameters
    • f (Face) – The Face object to check

    • tol (float) – The tolerance to use in the check

    Returns

    True if the Faces match, False otherwise

    Return type

    bool

    evalPoint(self, u, v)

    Evaluate a node location given a parametric location (u,v). Access the edge loops that bound the face.

    Parameters
    • u (float) – Parametric location in u

    • v (float) – Parametric location in v

    getCopySource(self)

    Get the copy source Face object and its orientation

    Returns

    The relative orientation and Face (None if not set)

    getEdgeLoop()

    getNumEdgeLoops(self)

    Get the number of edge loops stored by this object

    Returns

    The number of edge loops

    Return type

    int

    getEntityId(self)

    Get the entity id associated with the Face

    Returns

    Id number of the object, -1 for NULL object

    Return type

    int

    getMesh(self)

    Set the FaceMesh object associated with the Face

    Parameters

    mesh (FaceMesh) – The FaceMesh object set for this Face

    getName(self)

    Get the name associated with the Face

    Returns

    Name associated with the entity

    Return type

    str

    getNumEdgeLoops(self)

    Get the number of edge loops stored by this object

    Returns

    The number of edge loops

    Return type

    int

    getRange(self)

    Get the range of parameter values for this Face.

    Returns

    umin, vmin, umax, vmax The parametric limits for the Face

    getSource(self)

    Get the source Volume and Face object

    Returns

    the Volume and Face objects, None if no source is set

    isSame(self, f)

    Check if the two objects are geometrically equivalent using the underlying CAD kernel.

    Parameters

    f (Face) – Face to check

    Returns

    True if the same, False otherwise

    Return type

    bool

    isSameObject(self, f)

    Check if the two objects have the same pointer

    Parameters

    f (Face) – Face to check

    Returns

    True if the same object, False otherwise

    Return type

    bool

    setCopySource(self, face, orient=-1)

    Set the copy source Face object. The mesh for this Face will be copied from the copy source Face, including node numbering. This essentially merges this mesh and the copy source meshes together in the final global mesh.

    Parameters
    • face (Fdge) – New face source

    • orient (int) – Relative orientation of the two Faces

    setMesh(self, mesh)

    Set the FaceMesh object associated with the Face

    Parameters

    mesh (FaceMesh) – The FaceMesh object set for this Face

    setName(self, aname)

    Set the name associated with the Face

    Parameters

    aname (str) – Name associated with the Face

    setSource(self, v, f, set_edges=False)

    Set the source Face to copy the connectivity from within the specified Volume. This code copies the connectivity of the mesh on the source Face to this Face, as long as they share the same Volume. The Volume is needed to ensure the orientation of the Faces are taken into account.

    Parameters
    • v (Volume) – Volume which contains both this Face and the Face f

    • f (Face) – Source Face to set

    • set_edges (bool) – Set source edges for all edges connecting the source

    • destination Face. This is useful for mesh sweeping. (and) –

    writeToVTK(self, fname)

    Write the Face to a VTK file for visualization.

    Parameters

    fname (str) – File name

The other objects define collections of geometric entities:

  • class tmr.TMR.EdgeLoop

    Contains an oriented set of edges that enclose a surface. Provides the edge list and their relative orientations in the loop

    checkMatching(self, eloop, tol=1e-6)

    Check if two edge loops are coincident, within a given tolerance.

    Parameters
    • eloop (EdgeLoop) – The EdgeLoop object to check

    • tol (float) – The tolerance of the check

    Returns

    True if the loops match, False otherwise

    Return type

    bool

    getEdgeLoop(self)

    Get the list of edges and directions from this EdgeLoop

    Returns

    The list of Edge objects list: The list of +/- integers indicating relative directions

    Return type

    list

    getEntityId(self)

    Get the entity id associated with the EdgeLoop

    Returns

    Id number of the object, -1 for NULL object

    Return type

    int

  • class tmr.TMR.Volume

    Contains an oriented collection of surfaces that enclose a volume. Provides a list of surfaces. All faces must be oriented with positive orientation outwards.

    getEntityId(self)

    Get the entity id associated with the volume

    Returns

    Id number of the model, -1 for NULL object

    Return type

    int

    getFaces(self)

    Get the Face objects referenced by this Volume

    Returns

    List of Face objects

    Return type

    list

    getName(self)

    Get the name associated with the volume

    Returns

    Name associated with the entity

    Return type

    str

    getSweptFacePairs(self)

    Find source and target faces to see if this is a sweepable volume

    Returns

    A list of two Face objects that can be swept

    Return type

    list

    setName(self, aname)

    Set the name associated with the volume

    Parameters

    aname (str) – Name associated with the volume

  • class tmr.TMR.Model

    Contains an ordered collection of vertices, edges, faces, and volumes that define a model geometry.

    getEdges(self)

    Get the list of Edge objects from the Model

    Returns

    A list of the Edge objects

    Return type

    list

    getFaces(self)

    Get the list of Face objects from the Model

    Returns

    A list of the Face objects

    Return type

    list

    getVertices(self)

    Get the list of Vertex objects from the Model

    Returns

    A list of the Vertex objects

    Return type

    list

    getVolumes(self)

    Get the list of Volume objects from the Model

    Returns

    A list of the Volume objects

    Return type

    list

    writeModelToTecplot()
    writeModelToTecplot(self, fname,

    vlabels=True, elabels=True, flabels=True)

    Write a representation of the model to a tecplot file with labels.

    Parameters
    • fname (str) – File name to write

    • vlabels (bool) – Write the vertex labels

    • elabels (bool) – Write the edge labels

    • flabels (bool) – Write the face labels