diff --git a/tests/firedrake/submesh/test_submesh_solve.py b/tests/firedrake/submesh/test_submesh_solve.py index aa5e6725de..2f3ba98c68 100644 --- a/tests/firedrake/submesh/test_submesh_solve.py +++ b/tests/firedrake/submesh/test_submesh_solve.py @@ -592,7 +592,7 @@ def _test_submesh_solve_3d_2d_poisson(simplex, direction, nref, degree): mesh12 = Submesh(mesh2, dim - 1, label_interf) dx1 = Measure("dx", mesh1) dx2 = Measure("dx", mesh2) - ds1_ds2 = Measure("ds", mesh1, intersect_measures=(Measure("ds", mesh2),)) + ds1_ds2 = Measure("ds", mesh1, intersect_measures=(Measure("ds", mesh2), Measure("dx", mesh12))) dx12_ds1_ds2 = Measure( "dx", mesh12, intersect_measures=( diff --git a/tsfc/kernel_interface/common.py b/tsfc/kernel_interface/common.py index 4b48b0ca3f..c776db4fd6 100644 --- a/tsfc/kernel_interface/common.py +++ b/tsfc/kernel_interface/common.py @@ -505,12 +505,13 @@ def prepare_coefficient(coefficient, name, domain_integral_type_map): shape = finat_element.index_shape size = numpy.prod(shape, dtype=int) domain = extract_unique_domain(coefficient) - integral_type = domain_integral_type_map[domain] - if integral_type is None: + try: + integral_type = domain_integral_type_map[domain] + except KeyError: # This means that this coefficient does not exist in the DAG, # so corresponding gem expression will never be needed. - expression = None - elif integral_type.startswith("interior_facet"): + return None + if integral_type.startswith("interior_facet"): varexp = gem.Variable(name, (2 * size,)) plus = gem.view(varexp, slice(size)) minus = gem.view(varexp, slice(size, 2 * size)) diff --git a/tsfc/kernel_interface/firedrake_loopy.py b/tsfc/kernel_interface/firedrake_loopy.py index bb282e1d25..e949a472fa 100644 --- a/tsfc/kernel_interface/firedrake_loopy.py +++ b/tsfc/kernel_interface/firedrake_loopy.py @@ -127,11 +127,12 @@ def set_cell_orientations(self, domains): # Cell orientation self._cell_orientations = {} for i, domain in enumerate(domains): - integral_type = self._domain_integral_type_map[domain] - if integral_type is None: - # See comment in prepare_coefficient. - self._cell_orientations[domain] = None - elif integral_type.startswith("interior_facet"): + try: + integral_type = self._domain_integral_type_map[domain] + except KeyError: + # skip unused domain + continue + if integral_type.startswith("interior_facet"): cell_orientations = gem.Variable(f"cell_orientations_{i}", (2,), dtype=gem.uint_type) self._cell_orientations[domain] = (gem.Indexed(cell_orientations, (0,)), gem.Indexed(cell_orientations, (1,))) @@ -157,6 +158,9 @@ def set_cell_sizes(self, domains): """ self._cell_sizes = {} for i, domain in enumerate(domains): + if domain not in self._domain_integral_type_map: + # skip unused domain + continue if domain.ufl_cell().topological_dimension > 0: # Can't create P1 since only P0 is a valid finite element if # topological_dimension is 0 and the concept of "cell size" @@ -326,13 +330,13 @@ def set_entity_numbers(self, domains): self._entity_numbers = {} self._entity_ids = {} for i, domain in enumerate(domains): + try: + integral_type = self.integral_data_info.domain_integral_type_map[domain] + except KeyError: + # skip unused domain + continue fiat_cell = as_fiat_cell(domain.ufl_cell()) - integral_type = self.integral_data_info.domain_integral_type_map[domain] - if integral_type is None: - # Set placeholder for unused domain. - entity_ids = None - else: - _, entity_ids = lower_integral_type(fiat_cell, integral_type) + _, entity_ids = lower_integral_type(fiat_cell, integral_type) self._entity_ids[domain] = entity_ids if integral_type in ['exterior_facet', 'exterior_facet_vert']: facet = gem.Variable(f'facet_{i}', (1,), dtype=gem.uint_type) @@ -359,7 +363,11 @@ def set_entity_orientations(self, domains): """ self._entity_orientations = {} for i, domain in enumerate(domains): - integral_type = self.integral_data_info.domain_integral_type_map[domain] + try: + integral_type = self.integral_data_info.domain_integral_type_map[domain] + except KeyError: + # skip unused domain + continue variable_name = f"entity_orientations_{i}" if integral_type in ['exterior_facet', 'exterior_facet_vert']: o = gem.Variable(variable_name, (1,), dtype=gem.uint_type)