Skip to content

Commit 44f19bc

Browse files
committed
Make clear if using manufactured coordinates coefficient
So that caller can replace if necessary
1 parent 649a451 commit 44f19bc

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

Diff for: tsfc/driver.py

+7-6
Original file line numberDiff line numberDiff line change
@@ -332,15 +332,16 @@ def compile_expression_dual_evaluation(expression, to_element, *,
332332
domain = expression.ufl_domain()
333333
assert domain is not None
334334

335-
# Create a fake coordinate coefficient for a domain.
336-
coords_coefficient = ufl.Coefficient(ufl.FunctionSpace(domain, domain.ufl_coordinate_element()))
337-
builder.domain_coordinate[domain] = coords_coefficient
338-
builder.set_cell_sizes(domain)
339-
340335
# Collect required coefficients
336+
first_coefficient_fake_coords = False
341337
coefficients = extract_coefficients(expression)
342338
if has_type(expression, GeometricQuantity) or any(fem.needs_coordinate_mapping(c.ufl_element()) for c in coefficients):
339+
# Create a fake coordinate coefficient for a domain.
340+
coords_coefficient = ufl.Coefficient(ufl.FunctionSpace(domain, domain.ufl_coordinate_element()))
341+
builder.domain_coordinate[domain] = coords_coefficient
342+
builder.set_cell_sizes(domain)
343343
coefficients = [coords_coefficient] + coefficients
344+
first_coefficient_fake_coords = True
344345
builder.set_coefficients(coefficients)
345346

346347
# Split mixed coefficients
@@ -433,7 +434,7 @@ def compile_expression_dual_evaluation(expression, to_element, *,
433434
# Handle kernel interface requirements
434435
builder.register_requirements([ir])
435436
# Build kernel tuple
436-
return builder.construct_kernel(return_arg, impero_c, index_names)
437+
return builder.construct_kernel(return_arg, impero_c, index_names, first_coefficient_fake_coords)
437438

438439

439440
def lower_integral_type(fiat_cell, integral_type):

Diff for: tsfc/kernel_interface/firedrake_loopy.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818

1919
# Expression kernel description type
20-
ExpressionKernel = namedtuple('ExpressionKernel', ['ast', 'oriented', 'needs_cell_sizes', 'coefficients', 'tabulations'])
20+
ExpressionKernel = namedtuple('ExpressionKernel', ['ast', 'oriented', 'needs_cell_sizes', 'coefficients', 'first_coefficient_fake_coords', 'tabulations'])
2121

2222

2323
def make_builder(*args, **kwargs):
@@ -153,12 +153,14 @@ def register_requirements(self, ir):
153153
provided by the kernel interface."""
154154
self.oriented, self.cell_sizes, self.tabulations = check_requirements(ir)
155155

156-
def construct_kernel(self, return_arg, impero_c, index_names):
156+
def construct_kernel(self, return_arg, impero_c, index_names, first_coefficient_fake_coords):
157157
"""Constructs an :class:`ExpressionKernel`.
158158
159159
:arg return_arg: loopy.GlobalArg for the return value
160160
:arg impero_c: gem.ImperoC object that represents the kernel
161161
:arg index_names: pre-assigned index names
162+
:arg first_coefficient_fake_coords: If true, the kernel's first
163+
coefficient is a constructed UFL coordinate field
162164
:returns: :class:`ExpressionKernel` object
163165
"""
164166
args = [return_arg]
@@ -173,7 +175,8 @@ def construct_kernel(self, return_arg, impero_c, index_names):
173175
loopy_kernel = generate_loopy(impero_c, args, self.scalar_type,
174176
"expression_kernel", index_names)
175177
return ExpressionKernel(loopy_kernel, self.oriented, self.cell_sizes,
176-
self.coefficients, self.tabulations)
178+
self.coefficients, first_coefficient_fake_coords,
179+
self.tabulations)
177180

178181

179182
class KernelBuilder(KernelBuilderBase):

0 commit comments

Comments
 (0)