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.
-
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.
-
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
-
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
-
getEntityId
(self)¶ Get the entity id associated with the Vertex
- Returns
Id number of the object, -1 for NULL object
- Return type
-
getName
(self)¶ Get the name associated with the Vertex
- Returns
Name associated with the entity
- Return type
-
isSame
(self, v)¶ Check if the two objects are geometrically equivalent using the underlying CAD kernel.
-
isSameObject
(self, v)¶ Check if the two objects have the same pointer
-
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
-
-
class
-
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.
-
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
-
getEntityId
(self)¶ Get the entity id associated with the edge
- Returns
Id number of the model, -1 for NULL object
- Return type
-
getName
(self)¶ Get the name associated with the edge
- Returns
Name associated with the entity
- Return type
-
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
-
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.
-
isDegenerate
(self)¶ Is this edge degenerate (edge length = 0)
- Returns
True if degenerate, false otherwise
- Return type
-
isSame
(self, e)¶ Check if the two objects are geometrically equivalent using the underlying CAD kernel.
-
isSameObject
(self, e)¶ Check if the two objects have the same pointer
-
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
-
-
class
-
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.
-
evalPoint
(self, u, v)¶ Evaluate a node location given a parametric location (u,v). Access the edge loops that bound the face.
-
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
-
getEntityId
(self)¶ Get the entity id associated with the Face
- Returns
Id number of the object, -1 for NULL object
- Return type
-
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
-
getNumEdgeLoops
(self)¶ Get the number of edge loops stored by this object
- Returns
The number of edge loops
- Return type
-
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.
-
isSameObject
(self, f)¶ Check if the two objects have the same pointer
-
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.
-
-
class
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.
-
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
-
-
class
-
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
-
getFaces
(self)¶ Get the Face objects referenced by this Volume
- Returns
List of Face objects
- Return type
-
getName
(self)¶ Get the name associated with the volume
- Returns
Name associated with the entity
- Return type
-
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
-
-
class
-
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
-
getFaces
(self)¶ Get the list of Face objects from the Model
- Returns
A list of the Face objects
- Return type
-
getVertices
(self)¶ Get the list of Vertex objects from the Model
- Returns
A list of the Vertex objects
- Return type
-
getVolumes
(self)¶ Get the list of Volume objects from the Model
- Returns
A list of the Volume objects
- Return type
-
writeModelToTecplot
()¶ - writeModelToTecplot(self, fname,
vlabels=True, elabels=True, flabels=True)
Write a representation of the model to a tecplot file with labels.
-
-
class