From 9d227a48b48e01982fd87c2527a9a202ab208cf3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20S=2E=20Dokken?= Date: Mon, 14 Oct 2024 12:19:20 +0000 Subject: [PATCH] Add many geometrical quantities to ffcx expression generator. Fix various errors in the definition of geometry tables --- ffcx/codegeneration/access.py | 7 +++---- ffcx/codegeneration/expression_generator.py | 8 +++++++- ffcx/codegeneration/geometry.py | 2 +- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/ffcx/codegeneration/access.py b/ffcx/codegeneration/access.py index 18bcf9c89..5cd361bea 100644 --- a/ffcx/codegeneration/access.py +++ b/ffcx/codegeneration/access.py @@ -263,9 +263,8 @@ def reference_facet_edge_vectors(self, mt, tabledata, num_points): """Access a reference facet edge vector.""" cellname = ufl.domain.extract_unique_domain(mt.terminal).ufl_cell().cellname() if cellname in ("tetrahedron", "hexahedron"): - table = L.Symbol(f"{cellname}_reference_edge_vectors", dtype=L.DataType.REAL) - facet = self.symbols.entity("facet", mt.restriction) - return table[facet][mt.component[0]][mt.component[1]] + table = L.Symbol(f"{cellname}_facet_reference_edge_vectors", dtype=L.DataType.REAL) + return table[mt.component[0]][mt.component[1]] elif cellname in ("interval", "triangle", "quadrilateral"): raise RuntimeError( "The reference cell facet edge vectors doesn't make sense for interval " @@ -280,7 +279,7 @@ def facet_orientation(self, mt, tabledata, num_points): if cellname not in ("interval", "triangle", "tetrahedron"): raise RuntimeError(f"Unhandled cell types {cellname}.") - table = L.Symbol(f"{cellname}_facet_orientations", dtype=L.DataType.INT) + table = L.Symbol(f"{cellname}_facet_orientation", dtype=L.DataType.INT) facet = self.symbols.entity("facet", mt.restriction) return table[facet] diff --git a/ffcx/codegeneration/expression_generator.py b/ffcx/codegeneration/expression_generator.py index a3c0c56f0..62f9ee45a 100644 --- a/ffcx/codegeneration/expression_generator.py +++ b/ffcx/codegeneration/expression_generator.py @@ -61,10 +61,16 @@ def generate(self): def generate_geometry_tables(self): """Generate static tables of geometry data.""" - # Currently we only support circumradius ufl_geometry = { + ufl.geometry.FacetEdgeVectors: "facet_edge_vertices", + ufl.geometry.CellFacetJacobian: "reference_facet_jacobian", ufl.geometry.ReferenceCellVolume: "reference_cell_volume", + ufl.geometry.ReferenceFacetVolume: "reference_facet_volume", + ufl.geometry.ReferenceCellEdgeVectors: "reference_edge_vectors", + ufl.geometry.ReferenceFacetEdgeVectors: "facet_reference_edge_vectors", + ufl.geometry.FacetJacobianDeterminant: "reference_facet_jacobian", ufl.geometry.ReferenceNormal: "reference_facet_normals", + ufl.geometry.FacetOrientation: "facet_orientation", } cells: dict[Any, set[Any]] = {t: set() for t in ufl_geometry.keys()} # type: ignore diff --git a/ffcx/codegeneration/geometry.py b/ffcx/codegeneration/geometry.py index 39a5f5901..dc0b280b6 100644 --- a/ffcx/codegeneration/geometry.py +++ b/ffcx/codegeneration/geometry.py @@ -134,4 +134,4 @@ def facet_orientation(tablename, cellname): celltype = getattr(basix.CellType, cellname) out = basix.cell.facet_orientations(celltype) symbol = L.Symbol(f"{cellname}_{tablename}", dtype=L.DataType.REAL) - return L.ArrayDecl(symbol, values=out, const=True) + return L.ArrayDecl(symbol, values=np.asarray(out), const=True)