Volume meshes
VolumeMesh
Bases: Mesh
boundary_mesh
property
The boundary of the VolumeMesh as a SurfaceMesh. Shortcut for `self.boundary_connectivity.mesh
Returns:
Name | Type | Description |
---|---|---|
None |
if the boundary connectivity is not enabled (mesh was not built). See |
|
SurfaceMesh |
the boundary mesh otherwise |
id_cells
property
Shortcut for range(len(self.cells))
id_corners
property
Shortcut for range(len(self.face_corners))
id_edges
property
Shortcut for range(len(self.edges))
id_faces
property
Shortcut for range(len(self.faces))
id_vertices
property
Shortcut for range(len(self.vertices))
_BoundaryConnectivity(master)
Bases: _Connectivity
Attributes:
Name | Type | Description |
---|---|---|
m2b_vertex |
dict
|
volume mesh -> boundary indirection for vertices |
m2b_edge |
dict
|
volume mesh -> boundary indirection for edges |
m2b_face |
dict
|
volume mesh -> boundary indirection for faces |
b2m_vertex |
dict
|
boundary -> volume mesh indirection for vertices |
b2m_edge |
dict
|
boundary -> volume mesh indirection for edges |
b2m_face |
dict
|
boundary -> volume mesh indirection for faces |
_extract_surface_boundary()
Builds indirection maps. This is performed automatically upon first connectivity request.
clear()
Resets connectivity. The next query in the code will regenerate internal arrays.
common_edge(iF1, iF2)
Returns the two vertices (u,v) of the edge that separates faces iF1 and iF2 if it exists, and (None,None) otherwise.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
iF1
|
int
|
first face index |
required |
iF2
|
int
|
second face index |
required |
Returns:
Type | Description |
---|---|
(int, int)
|
(u,v) pair of vertex indices, or (None,None) |
corner_to_face(C)
The face inside which corner C
belongs.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
C
|
int
|
corner id |
required |
Returns:
Name | Type | Description |
---|---|---|
int |
int
|
face id |
direct_face(u, v, return_inds=False)
Pair (u,v) of vertex -> triangle to the left of edge (u,v) if edge (u,v) exists, None otherwise Also returns local indexes of u and v in the triangle (and None if (u,v) does not exists)
Calling this function with edge (v,u) yield the triangle of the other side of the edge
Parameters:
Name | Type | Description | Default |
---|---|---|---|
u
|
int
|
first vertex index |
required |
v
|
int
|
second vertex index |
required |
return_inds
|
bool
|
Whether to return local indices of u and v in the face. Defaults to False. |
False
|
Returns:
Type | Description |
---|---|
Index of a face or None. If return_inds is True, tuple made of index of face and local indices of u and v in face or (None,None,None). |
edge_id(V1, V2)
Identifier of an edge. If self.edges[i]
contains edges (A,B)
, then edge_id(A,B)=edge_id(B,A)=i
If (A,B) is not a valid edge of the mesh, returns None
Parameters:
Name | Type | Description | Default |
---|---|---|---|
V1
|
int
|
first vertex of the edge |
required |
V2
|
int
|
second vertex of the edge |
required |
Returns:
Name | Type | Description |
---|---|---|
int |
int
|
the id of edge (V1,V2), or |
edge_to_faces(u, v)
For an edge (u,v)
, returns the indices of faces that are direct and indirect from (u,v)
(see direct_face
method). If one of the faces does not exist, returns a None
instead of its index.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
u
|
int
|
index of first vertex |
required |
v
|
int
|
index of second vertex |
required |
edge_to_vertices(E)
Returns the two vertex indices that are adjacent to edge `E
Parameters:
Name | Type | Description | Default |
---|---|---|---|
E
|
int
|
edge index |
required |
Note
Equivalent to mesh.edges[E]
Returns:
Name | Type | Description |
---|---|---|
list |
list
|
two vertex indices |
face_id(*args)
The identifier of a face.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
int*
|
integers representing indices of vertices of the face (not necessarily in the correct order) |
required |
Returns:
Name | Type | Description |
---|---|---|
int |
int
|
A face index or None if the given tuple is invalid |
face_to_corners(F)
list of corners of face F
Parameters:
Name | Type | Description | Default |
---|---|---|---|
F
|
int
|
face id |
required |
Returns:
Name | Type | Description |
---|---|---|
list |
list
|
list of corners of face |
face_to_first_corner(F)
One corner C
of the face F
(the first in order of appearance in the face_corners
container)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
F
|
int
|
face id |
required |
Returns:
Name | Type | Description |
---|---|---|
int |
int
|
corner id |
in_face_index(F, V)
Index of vertex V in face F. None if V is not in face F
Parameters:
Name | Type | Description | Default |
---|---|---|---|
F
|
int
|
face index |
required |
V
|
int
|
vertex index |
required |
Returns:
Type | Description |
---|---|
int |
next_corner(C)
Next corner of C
around its associated face
Parameters:
Name | Type | Description | Default |
---|---|---|---|
C
|
int
|
corner index |
required |
Returns:
Name | Type | Description |
---|---|---|
int |
int
|
index of the next corner |
opposite_corner(C)
Opposite corner of C
in terms of half edges.
If C.vertex = A
and C.next.vertex = B
, then returns the corner D such that D.vertex = B
and D.vertex.next = A
Parameters:
Name | Type | Description | Default |
---|---|---|---|
C
|
int
|
corner index |
required |
Returns:
Name | Type | Description |
---|---|---|
int |
int
|
index of the opposite corner |
opposite_face(u, v, F, return_inds=False)
Returns the index of the face adjacent to edge (u,v)
that is at the opposite of face F
. Returns None
if such a face does not exist, or if F
is not adjacent to edge (u,v)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
u
|
int
|
index of edge's first vertex |
required |
v
|
int
|
index of edge's second vertex |
required |
F
|
int
|
index of face |
required |
return_inds
|
bool
|
If True, also returns local indices of |
False
|
Returns:
Name | Type | Description |
---|---|---|
int |
index of a face |
other_edge_end(E, V)
Vertex at the opposite end of edge E
from vertex V
.
Returns None
if V
is not adjacent to edge E
Parameters:
Name | Type | Description | Default |
---|---|---|---|
E
|
int
|
edge id |
required |
V
|
int
|
vertex id |
required |
Returns:
Name | Type | Description |
---|---|---|
int |
int
|
the vertex |
previous_corner(C)
Previous corner of C
around its associated face
Parameters:
Name | Type | Description | Default |
---|---|---|---|
C
|
int
|
corner index |
required |
Returns:
Name | Type | Description |
---|---|---|
int |
int
|
index of the previous corner |
vertex_to_corner_in_face(V, F)
The corner C
corresponding to vertex V
in face F
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
V
|
int
|
vertex id |
required |
F
|
int
|
face id |
required |
Returns:
Name | Type | Description |
---|---|---|
int |
int
|
corner id, or |
vertex_to_corners(V)
List of face corners that correspond to vertex V
Parameters:
Name | Type | Description | Default |
---|---|---|---|
V
|
int
|
vertex id |
required |
Returns:
Name | Type | Description |
---|---|---|
list |
list
|
the list of corners |
_Connectivity(master)
Bases: _Connectivity
_sort_edge_neighborhoods()
Sorts cells adjacent to an edge so that they are in direct order
common_edge(iF1, iF2)
Returns the two vertices (u,v) of the edge that separates faces iF1 and iF2 if it exists, and (None,None) otherwise.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
iF1
|
int
|
first face index |
required |
iF2
|
int
|
second face index |
required |
Returns:
Type | Description |
---|---|
(int, int)
|
(u,v) pair of vertex indices, or (None,None) |
corner_to_face(C)
The face inside which corner C
belongs.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
C
|
int
|
corner id |
required |
Returns:
Name | Type | Description |
---|---|---|
int |
int
|
face id |
direct_face(u, v, return_inds=False)
Pair (u,v) of vertex -> triangle to the left of edge (u,v) if edge (u,v) exists, None otherwise Also returns local indexes of u and v in the triangle (and None if (u,v) does not exists)
Calling this function with edge (v,u) yield the triangle of the other side of the edge
Parameters:
Name | Type | Description | Default |
---|---|---|---|
u
|
int
|
first vertex index |
required |
v
|
int
|
second vertex index |
required |
return_inds
|
bool
|
Whether to return local indices of u and v in the face. Defaults to False. |
False
|
Returns:
Type | Description |
---|---|
Index of a face or None. If return_inds is True, tuple made of index of face and local indices of u and v in face or (None,None,None). |
edge_id(V1, V2)
Identifier of an edge. If self.edges[i]
contains edges (A,B)
, then edge_id(A,B)=edge_id(B,A)=i
If (A,B) is not a valid edge of the mesh, returns None
Parameters:
Name | Type | Description | Default |
---|---|---|---|
V1
|
int
|
first vertex of the edge |
required |
V2
|
int
|
second vertex of the edge |
required |
Returns:
Name | Type | Description |
---|---|---|
int |
int
|
the id of edge (V1,V2), or |
edge_to_faces(u, v)
For an edge (u,v)
, returns the indices of faces that are direct and indirect from (u,v)
(see direct_face
method). If one of the faces does not exist, returns a None
instead of its index.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
u
|
int
|
index of first vertex |
required |
v
|
int
|
index of second vertex |
required |
edge_to_vertices(E)
Returns the two vertex indices that are adjacent to edge `E
Parameters:
Name | Type | Description | Default |
---|---|---|---|
E
|
int
|
edge index |
required |
Note
Equivalent to mesh.edges[E]
Returns:
Name | Type | Description |
---|---|---|
list |
list
|
two vertex indices |
face_id(*args)
The identifier of a face.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
int*
|
integers representing indices of vertices of the face (not necessarily in the correct order) |
required |
Returns:
Name | Type | Description |
---|---|---|
int |
int
|
A face index or None if the given tuple is invalid |
face_to_corners(F)
list of corners of face F
Parameters:
Name | Type | Description | Default |
---|---|---|---|
F
|
int
|
face id |
required |
Returns:
Name | Type | Description |
---|---|---|
list |
list
|
list of corners of face |
face_to_edges(F)
List of edges that bound face F
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
F
|
int
|
face id |
required |
Returns:
Name | Type | Description |
---|---|---|
list |
list
|
list of edges |
face_to_faces(F)
List of faces that are adjacent to face F
Parameters:
Name | Type | Description | Default |
---|---|---|---|
F
|
int
|
face id |
required |
Returns:
Name | Type | Description |
---|---|---|
list |
list
|
list of faces |
face_to_first_corner(F)
One corner C
of the face F
(the first in order of appearance in the face_corners
container)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
F
|
int
|
face id |
required |
Returns:
Name | Type | Description |
---|---|---|
int |
int
|
corner id |
face_to_vertices(F)
Neighborhood of face F
in terms of vertices.
Note
Equivalent to mesh.faces[F]
Parameters:
Name | Type | Description | Default |
---|---|---|---|
F
|
int
|
face id |
required |
Returns:
Name | Type | Description |
---|---|---|
list |
list
|
list of vertices |
in_cell_index(C, V)
Index of vertex V in cell C. None if V is not in cell C
Parameters:
Name | Type | Description | Default |
---|---|---|---|
C
|
int
|
cell index |
required |
V
|
int
|
vertex index |
required |
Returns:
Type | Description |
---|---|
int |
in_face_index(F, V)
Index of vertex V in face F. None if V is not in face F
Parameters:
Name | Type | Description | Default |
---|---|---|---|
F
|
int
|
face index |
required |
V
|
int
|
vertex index |
required |
Returns:
Type | Description |
---|---|
int |
next_corner(C)
Next corner of C
around its associated face
Parameters:
Name | Type | Description | Default |
---|---|---|---|
C
|
int
|
corner index |
required |
Returns:
Name | Type | Description |
---|---|---|
int |
int
|
index of the next corner |
opposite_corner(C)
Opposite corner of C
in terms of half edges.
If C.vertex = A
and C.next.vertex = B
, then returns the corner D such that D.vertex = B
and D.vertex.next = A
Parameters:
Name | Type | Description | Default |
---|---|---|---|
C
|
int
|
corner index |
required |
Returns:
Name | Type | Description |
---|---|---|
int |
int
|
index of the opposite corner |
opposite_face(u, v, F, return_inds=False)
Returns the index of the face adjacent to edge (u,v)
that is at the opposite of face F
. Returns None
if such a face does not exist, or if F
is not adjacent to edge (u,v)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
u
|
int
|
index of edge's first vertex |
required |
v
|
int
|
index of edge's second vertex |
required |
F
|
int
|
index of face |
required |
return_inds
|
bool
|
If True, also returns local indices of |
False
|
Returns:
Name | Type | Description |
---|---|---|
int |
index of a face |
other_edge_end(E, V)
Vertex at the opposite end of edge E
from vertex V
.
Returns None
if V
is not adjacent to edge E
Parameters:
Name | Type | Description | Default |
---|---|---|---|
E
|
int
|
edge id |
required |
V
|
int
|
vertex id |
required |
Returns:
Name | Type | Description |
---|---|---|
int |
int
|
the vertex |
previous_corner(C)
Previous corner of C
around its associated face
Parameters:
Name | Type | Description | Default |
---|---|---|---|
C
|
int
|
corner index |
required |
Returns:
Name | Type | Description |
---|---|---|
int |
int
|
index of the previous corner |
vertex_to_corner_in_face(V, F)
The corner C
corresponding to vertex V
in face F
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
V
|
int
|
vertex id |
required |
F
|
int
|
face id |
required |
Returns:
Name | Type | Description |
---|---|---|
int |
int
|
corner id, or |
vertex_to_corners(V)
List of face corners that correspond to vertex V
Parameters:
Name | Type | Description | Default |
---|---|---|---|
V
|
int
|
vertex id |
required |
Returns:
Name | Type | Description |
---|---|---|
list |
list
|
the list of corners |
vertex_to_edges(V)
Neighborhood of vertex V
in terms of edges.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
V
|
int
|
vertex id |
required |
Returns:
Name | Type | Description |
---|---|---|
list |
list
|
list of edges E such that V belongs to E. |
vertex_to_faces(V)
Neighborhood of vertex V
in terms of faces.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
V
|
int
|
vertex id |
required |
Returns:
Name | Type | Description |
---|---|---|
list |
list
|
list of faces |
vertex_to_vertices(V)
Neighborhood of vertex V
in terms of vertices.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
V
|
int
|
vertex id |
required |
Returns:
Name | Type | Description |
---|---|---|
list |
list
|
list of vertices |
enable_boundary_connectivity()
Builds the indirection maps to the boundary surface mesh, which then can be accessed via the self.boundary_connectivity
attribute.
See documentation for VolumeMesh._BoundaryConnectivity for more details.
is_cell_tet(ic)
Returns True if the cell given by id
ic` is a tetrahedron (i.e. has 4 vertices)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ic
|
int
|
cell index |
required |
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
len(self.cells[ic])==4 |
is_edge_on_border(*args)
Simple test to determine if a given edge is on the boundary of the mesh.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
*args
|
Either an integer index representing an edge, or two integer indices representing two (adjacent) vertices |
()
|
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
Returns True if the given edge is on the boundary of the mesh. |
is_face_on_border(*args)
Simple test to determine if a given face is on the boundary of the mesh.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
*args
|
Either an integer index representing a face, or n integer indices representing the vertices |
()
|
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
Returns True is the given face exists and is on the boundary of the mesh |
is_tetrahedral()
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
True if the mesh is tetrahedral (all cells are tetrahedra) |
Volume Connectivity
Warning
Volume connectivity is a work in progress and will be available soon.
BoundaryConnectivity
In some applications, you may need to access the boundary surface mesh of a volume mesh in a self-contained way while keeping links to the original volume. It allows requests like "return the list of all vertices adjacent to boundary vertex i that are on the boundary"
It implements the same methods as the Connectivity class of surface meshes for the boundary mesh, as well as indirection arrays to move from volume indices to surface indices. Returned indices of connectivity queries are indices with relation to the volume mesh.
To save time and memory, the boundary indirections are not computed by default. Use the enable_boundary_connectivity()
method of the VolumeMesh
to explicitly generate a BoundaryConnectivity
object, stored in the .boundary_connectivity
attribute.
Example
import mouette as M
m = M.mesh.load("my_volume_mesh.tet")
# if enable_boundary_connectivity is not called, `m.boundary_connectivity` is None
m.enable_boundary_connectivity() # builds the indirection
bnd_m = m.boundary_mesh # access the boundary mesh as an independent surface mesh
boundary_neighbors = m.boundary_connectivity.vertex_to_vertices(4) # query connectivity
Bases: _Connectivity
Attributes:
Name | Type | Description |
---|---|---|
m2b_vertex |
dict
|
volume mesh -> boundary indirection for vertices |
m2b_edge |
dict
|
volume mesh -> boundary indirection for edges |
m2b_face |
dict
|
volume mesh -> boundary indirection for faces |
b2m_vertex |
dict
|
boundary -> volume mesh indirection for vertices |
b2m_edge |
dict
|
boundary -> volume mesh indirection for edges |
b2m_face |
dict
|
boundary -> volume mesh indirection for faces |
clear()
Resets connectivity. The next query in the code will regenerate internal arrays.