Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add many geometrical quantities to ffcx expression generator. #725

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions ffcx/codegeneration/access.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 "
Expand All @@ -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]

Expand Down
8 changes: 7 additions & 1 deletion ffcx/codegeneration/expression_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ugh, the naming (unrelated to the PR) is a bit inconsistent with UFL. Nvm, can you add a quick test so we're sure these are covered for the future?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, I'll try to add a test sometime this week.

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
Expand Down
2 changes: 1 addition & 1 deletion ffcx/codegeneration/geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Loading