From dc31cd0549b31fa7a6bc57e5dc3286038741b894 Mon Sep 17 00:00:00 2001 From: Rob Kirby Date: Mon, 31 Aug 2020 13:27:54 -0500 Subject: [PATCH 1/2] Allow reference edge normal/tangents to be normalized or scaled in CoordinateMapping --- tsfc/fem.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/tsfc/fem.py b/tsfc/fem.py index 2411a1dd..06b8c075 100644 --- a/tsfc/fem.py +++ b/tsfc/fem.py @@ -166,14 +166,19 @@ def detJ_at(self, point): context = PointSetContext(**config) return map_expr_dag(context.translator, expr) - def reference_normals(self): + def reference_normals(self, normalized=True): if not (isinstance(self.interface.fiat_cell, UFCSimplex) and self.interface.fiat_cell.get_spatial_dimension() == 2): raise NotImplementedError("Only works for triangles for now") - return gem.Literal(numpy.asarray([self.interface.fiat_cell.compute_normal(i) for i in range(3)])) + cn = (self.interface.fiat_cell.compute_normal if normalized + else self.interface.fiat_cell.compute_scaled_normal) + return gem.Literal(numpy.asarray([cn for i in range(3)])) - def reference_edge_tangents(self): - return gem.Literal(numpy.asarray([self.interface.fiat_cell.compute_edge_tangent(i) for i in range(3)])) + def reference_edge_tangents(self, normalized=False): + ct = (self.interface.fiat_cell.compute_normalized_edge_tangent + if normalized else self.interface.fiat_cell.compute_edge_tangent) + + return gem.Literal(numpy.asarray([ct(i) for i in range(3)])) def physical_tangents(self): if not (isinstance(self.interface.fiat_cell, UFCSimplex) and From babe6877ac51d19f060e1e5490bd4b32d582f31b Mon Sep 17 00:00:00 2001 From: Rob Kirby Date: Mon, 31 Aug 2020 14:01:43 -0500 Subject: [PATCH 2/2] fix stupid bug --- tsfc/fem.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tsfc/fem.py b/tsfc/fem.py index 06b8c075..57ddac4d 100644 --- a/tsfc/fem.py +++ b/tsfc/fem.py @@ -172,7 +172,7 @@ def reference_normals(self, normalized=True): raise NotImplementedError("Only works for triangles for now") cn = (self.interface.fiat_cell.compute_normal if normalized else self.interface.fiat_cell.compute_scaled_normal) - return gem.Literal(numpy.asarray([cn for i in range(3)])) + return gem.Literal(numpy.asarray([cn(i) for i in range(3)])) def reference_edge_tangents(self, normalized=False): ct = (self.interface.fiat_cell.compute_normalized_edge_tangent