@@ -267,7 +267,7 @@ def name_multiindex(multiindex, name):
267267 return builder .construct_kernel (kernel_name , impero_c , index_names , quad_rule )
268268
269269
270- def compile_expression_dual_evaluation (expression , to_element , coordinates , * ,
270+ def compile_expression_dual_evaluation (expression , to_element , * ,
271271 domain = None , interface = None ,
272272 parameters = None , coffee = False ):
273273 """Compile a UFL expression to be evaluated against a compile-time known reference element's dual basis.
@@ -276,8 +276,7 @@ def compile_expression_dual_evaluation(expression, to_element, coordinates, *,
276276
277277 :arg expression: UFL expression
278278 :arg to_element: A FInAT element for the target space
279- :arg coordinates: the coordinate function
280- :arg domain: optional UFL domain the expression is defined on (useful when expression contains no domain).
279+ :arg domain: optional UFL domain the expression is defined on (required when expression contains no domain).
281280 :arg interface: backend module for the kernel interface
282281 :arg parameters: parameters object
283282 :arg coffee: compile coffee kernel instead of loopy kernel
@@ -328,25 +327,28 @@ def compile_expression_dual_evaluation(expression, to_element, coordinates, *,
328327 argument_multiindices = tuple (builder .create_element (arg .ufl_element ()).get_indices ()
329328 for arg in arguments )
330329
331- # Replace coordinates (if any)
332- domain = expression .ufl_domain ()
333- if domain :
334- assert coordinates .ufl_domain () == domain
335- builder .domain_coordinate [domain ] = coordinates
336- builder .set_cell_sizes (domain )
330+ # Replace coordinates (if any) unless otherwise specified by kwarg
331+ if domain is None :
332+ domain = expression .ufl_domain ()
333+ assert domain is not None
334+
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 )
337339
338340 # Collect required coefficients
339341 coefficients = extract_coefficients (expression )
340342 if has_type (expression , GeometricQuantity ) or any (fem .needs_coordinate_mapping (c .ufl_element ()) for c in coefficients ):
341- coefficients = [coordinates ] + coefficients
343+ coefficients = [coords_coefficient ] + coefficients
342344 builder .set_coefficients (coefficients )
343345
344346 # Split mixed coefficients
345347 expression = ufl_utils .split_coefficients (expression , builder .coefficient_split )
346348
347349 # Translate to GEM
348350 kernel_cfg = dict (interface = builder ,
349- ufl_cell = coordinates . ufl_domain () .ufl_cell (),
351+ ufl_cell = domain .ufl_cell (),
350352 argument_multiindices = argument_multiindices ,
351353 index_cache = {},
352354 scalar_type = parameters ["scalar_type" ])
0 commit comments