Skip to content
This repository has been archived by the owner on Dec 6, 2024. It is now read-only.

Commit

Permalink
Merge pull request #304 from firedrakeproject/pbrubeck/expunge-ufl-do…
Browse files Browse the repository at this point in the history
…main

Expunge Expr.ufl_domain()
  • Loading branch information
dham authored Nov 29, 2023
2 parents 5515b2a + 3be63a4 commit 799191d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
3 changes: 2 additions & 1 deletion tsfc/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from ufl.algorithms import extract_arguments, extract_coefficients
from ufl.algorithms.analysis import has_type
from ufl.classes import Form, GeometricQuantity
from ufl.domain import extract_unique_domain

import gem
import gem.impero_utils as impero_utils
Expand Down Expand Up @@ -219,7 +220,7 @@ def compile_expression_dual_evaluation(expression, to_element, ufl_element, *,

# Replace coordinates (if any) unless otherwise specified by kwarg
if domain is None:
domain = expression.ufl_domain()
domain = extract_unique_domain(expression)
assert domain is not None

# Collect required coefficients and determine numbering
Expand Down
20 changes: 10 additions & 10 deletions tsfc/fem.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ def cell_size(self):

def jacobian_at(self, point):
ps = PointSingleton(point)
expr = Jacobian(self.mt.terminal.ufl_domain())
expr = Jacobian(extract_unique_domain(self.mt.terminal))
assert ps.expression.shape == (extract_unique_domain(expr).topological_dimension(), )
if self.mt.restriction == '+':
expr = PositiveRestricted(expr)
Expand All @@ -163,7 +163,7 @@ def jacobian_at(self, point):
return map_expr_dag(context.translator, expr)

def detJ_at(self, point):
expr = JacobianDeterminant(self.mt.terminal.ufl_domain())
expr = JacobianDeterminant(extract_unique_domain(self.mt.terminal))
if self.mt.restriction == '+':
expr = PositiveRestricted(expr)
elif self.mt.restriction == '-':
Expand Down Expand Up @@ -202,7 +202,7 @@ def physical_normals(self):
return gem.ListTensor([[pts[i, 1], -1*pts[i, 0]] for i in range(3)])

def physical_edge_lengths(self):
expr = ufl.classes.CellEdgeVectors(self.mt.terminal.ufl_domain())
expr = ufl.classes.CellEdgeVectors(extract_unique_domain(self.mt.terminal))
if self.mt.restriction == '+':
expr = PositiveRestricted(expr)
elif self.mt.restriction == '-':
Expand All @@ -217,13 +217,13 @@ def physical_edge_lengths(self):

def physical_points(self, point_set, entity=None):
"""Converts point_set from reference to physical space"""
expr = SpatialCoordinate(self.mt.terminal.ufl_domain())
expr = SpatialCoordinate(extract_unique_domain(self.mt.terminal))
point_shape, = point_set.expression.shape
if entity is not None:
e, _ = entity
assert point_shape == e
else:
assert point_shape == expr.ufl_domain().topological_dimension()
assert point_shape == extract_unique_domain(expr).topological_dimension()
if self.mt.restriction == '+':
expr = PositiveRestricted(expr)
elif self.mt.restriction == '-':
Expand Down Expand Up @@ -330,7 +330,7 @@ def cell_avg(self, o):
# below).
raise NotImplementedError("CellAvg on non-cell integrals not yet implemented")
integrand, = o.ufl_operands
domain = o.ufl_domain()
domain = extract_unique_domain(o)
measure = ufl.Measure(self.context.integral_type, domain=domain)
integrand, degree, argument_multiindices = entity_avg(integrand / CellVolume(domain), measure, self.context.argument_multiindices)

Expand All @@ -345,7 +345,7 @@ def facet_avg(self, o):
if self.context.integral_type == "cell":
raise ValueError("Can't take FacetAvg in cell integral")
integrand, = o.ufl_operands
domain = o.ufl_domain()
domain = extract_unique_domain(o)
measure = ufl.Measure(self.context.integral_type, domain=domain)
integrand, degree, argument_multiindices = entity_avg(integrand / FacetArea(domain), measure, self.context.argument_multiindices)

Expand Down Expand Up @@ -509,7 +509,7 @@ def coefficient(self, ufl_coefficient, r):

@translate.register(CellVolume)
def translate_cellvolume(terminal, mt, ctx):
integrand, degree = one_times(ufl.dx(domain=terminal.ufl_domain()))
integrand, degree = one_times(ufl.dx(domain=extract_unique_domain(terminal)))
interface = CellVolumeKernelInterface(ctx, mt.restriction)

config = {name: getattr(ctx, name)
Expand All @@ -522,7 +522,7 @@ def translate_cellvolume(terminal, mt, ctx):
@translate.register(FacetArea)
def translate_facetarea(terminal, mt, ctx):
assert ctx.integral_type != 'cell'
domain = terminal.ufl_domain()
domain = extract_unique_domain(terminal)
integrand, degree = one_times(ufl.Measure(ctx.integral_type, domain=domain))

config = {name: getattr(ctx, name)
Expand All @@ -535,7 +535,7 @@ def translate_facetarea(terminal, mt, ctx):

@translate.register(CellOrigin)
def translate_cellorigin(terminal, mt, ctx):
domain = terminal.ufl_domain()
domain = extract_unique_domain(terminal)
coords = SpatialCoordinate(domain)
expression = construct_modified_terminal(mt, coords)
point_set = PointSingleton((0.0,) * domain.topological_dimension())
Expand Down
3 changes: 2 additions & 1 deletion tsfc/kernel_interface/firedrake_loopy.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from functools import partial

from ufl import Coefficient, FunctionSpace
from ufl.domain import extract_unique_domain
from finat.ufl import MixedElement as ufl_MixedElement, FiniteElement

import gem
Expand Down Expand Up @@ -323,7 +324,7 @@ def set_coefficients(self, integral_data, form_data):
else:
self.coefficient_split[coefficient] = []
for j, element in enumerate(coefficient.ufl_element().sub_elements):
c = Coefficient(FunctionSpace(coefficient.ufl_domain(), element))
c = Coefficient(FunctionSpace(extract_unique_domain(coefficient), element))
self.coefficient_split[coefficient].append(c)
self._coefficient(c, f"w_{k}")
self.coefficient_number_index_map[c] = (n, j)
Expand Down

0 comments on commit 799191d

Please sign in to comment.