Skip to content

Commit 169f5cc

Browse files
committed
Add mesh faces() method
1 parent ec24e8b commit 169f5cc

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

layermesh/mesh.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1220,6 +1220,25 @@ def type_columns(self, num_nodes):
12201220
nodes."""
12211221
return [col for col in self.column if col.num_nodes == num_nodes]
12221222

1223+
def faces(self, cells = None):
1224+
"""Returns a list of the faces between the specified cells. A
1225+
list of the cells may be optionally specified, otherwise all
1226+
cells will be included.
1227+
"""
1228+
if cells is None: cells = self.cell
1229+
cell_dict = {c.index: c for c in cells}
1230+
face_keys = set()
1231+
for c in cells:
1232+
for nbr in c.neighbour:
1233+
if nbr.index in cell_dict:
1234+
face_keys.add(frozenset([c.index, nbr.index]))
1235+
faces = []
1236+
for key in face_keys:
1237+
cells = [self.cell[c] for c in key]
1238+
f = face(cells)
1239+
faces.append(f)
1240+
return faces
1241+
12231242
def translate(self, shift):
12241243
"""Translates the mesh by the specified 3-D shift vector (tuple, list
12251244
or array of length 3)."""

0 commit comments

Comments
 (0)