From 71748d469dfa312a3e263adb6611b3e52ec3fc01 Mon Sep 17 00:00:00 2001 From: Tom Gustafsson Date: Fri, 12 Apr 2024 15:26:34 +0300 Subject: [PATCH] add p2e --- skfem/mesh/mesh.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/skfem/mesh/mesh.py b/skfem/mesh/mesh.py index 9df63d8b..97d891ec 100644 --- a/skfem/mesh/mesh.py +++ b/skfem/mesh/mesh.py @@ -160,7 +160,7 @@ def p2f(self): @property def p2t(self): - """Return incidence matrix between elements and vertices.""" + """Incidence matrix between elements and vertices.""" from scipy.sparse import coo_matrix t = self.t.flatten('C') return coo_matrix( @@ -171,6 +171,13 @@ def p2t(self): dtype=np.int32, ).tocsc() + @property + def p2e(self): + """Incidence matrix between edges and vertices.""" + p2t = self.p2t + edges = self.edges + return p2t[:, edges[0]].multiply(p2t[:, edges[1]]) + def dim(self): return self.elem.refdom.dim()