@@ -127,11 +127,12 @@ def set_cell_orientations(self, domains):
127127 # Cell orientation
128128 self ._cell_orientations = {}
129129 for i , domain in enumerate (domains ):
130- integral_type = self ._domain_integral_type_map [domain ]
131- if integral_type is None :
132- # See comment in prepare_coefficient.
133- self ._cell_orientations [domain ] = None
134- elif integral_type .startswith ("interior_facet" ):
130+ try :
131+ integral_type = self ._domain_integral_type_map [domain ]
132+ except KeyError :
133+ # skip unused domain
134+ continue
135+ if integral_type .startswith ("interior_facet" ):
135136 cell_orientations = gem .Variable (f"cell_orientations_{ i } " , (2 ,), dtype = gem .uint_type )
136137 self ._cell_orientations [domain ] = (gem .Indexed (cell_orientations , (0 ,)),
137138 gem .Indexed (cell_orientations , (1 ,)))
@@ -157,6 +158,9 @@ def set_cell_sizes(self, domains):
157158 """
158159 self ._cell_sizes = {}
159160 for i , domain in enumerate (domains ):
161+ if domain not in self ._domain_integral_type_map :
162+ # skip unused domain
163+ continue
160164 if domain .ufl_cell ().topological_dimension > 0 :
161165 # Can't create P1 since only P0 is a valid finite element if
162166 # topological_dimension is 0 and the concept of "cell size"
@@ -326,13 +330,13 @@ def set_entity_numbers(self, domains):
326330 self ._entity_numbers = {}
327331 self ._entity_ids = {}
328332 for i , domain in enumerate (domains ):
333+ try :
334+ integral_type = self .integral_data_info .domain_integral_type_map [domain ]
335+ except KeyError :
336+ # skip unused domain
337+ continue
329338 fiat_cell = as_fiat_cell (domain .ufl_cell ())
330- integral_type = self .integral_data_info .domain_integral_type_map [domain ]
331- if integral_type is None :
332- # Set placeholder for unused domain.
333- entity_ids = None
334- else :
335- _ , entity_ids = lower_integral_type (fiat_cell , integral_type )
339+ _ , entity_ids = lower_integral_type (fiat_cell , integral_type )
336340 self ._entity_ids [domain ] = entity_ids
337341 if integral_type in ['exterior_facet' , 'exterior_facet_vert' ]:
338342 facet = gem .Variable (f'facet_{ i } ' , (1 ,), dtype = gem .uint_type )
@@ -359,7 +363,11 @@ def set_entity_orientations(self, domains):
359363 """
360364 self ._entity_orientations = {}
361365 for i , domain in enumerate (domains ):
362- integral_type = self .integral_data_info .domain_integral_type_map [domain ]
366+ try :
367+ integral_type = self .integral_data_info .domain_integral_type_map [domain ]
368+ except KeyError :
369+ # skip unused domain
370+ continue
363371 variable_name = f"entity_orientations_{ i } "
364372 if integral_type in ['exterior_facet' , 'exterior_facet_vert' ]:
365373 o = gem .Variable (variable_name , (1 ,), dtype = gem .uint_type )
0 commit comments