@@ -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,11 @@ def set_cell_sizes(self, domains):
157158 """
158159 self ._cell_sizes = {}
159160 for i , domain in enumerate (domains ):
161+ try :
162+ integral_type = self ._domain_integral_type_map [domain ]
163+ except KeyError :
164+ # skip unused domain
165+ continue
160166 if domain .ufl_cell ().topological_dimension > 0 :
161167 # Can't create P1 since only P0 is a valid finite element if
162168 # topological_dimension is 0 and the concept of "cell size"
@@ -326,13 +332,13 @@ def set_entity_numbers(self, domains):
326332 self ._entity_numbers = {}
327333 self ._entity_ids = {}
328334 for i , domain in enumerate (domains ):
335+ try :
336+ integral_type = self .integral_data_info .domain_integral_type_map [domain ]
337+ except KeyError :
338+ # skip unused domain
339+ continue
329340 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 )
341+ _ , entity_ids = lower_integral_type (fiat_cell , integral_type )
336342 self ._entity_ids [domain ] = entity_ids
337343 if integral_type in ['exterior_facet' , 'exterior_facet_vert' ]:
338344 facet = gem .Variable (f'facet_{ i } ' , (1 ,), dtype = gem .uint_type )
@@ -359,7 +365,11 @@ def set_entity_orientations(self, domains):
359365 """
360366 self ._entity_orientations = {}
361367 for i , domain in enumerate (domains ):
362- integral_type = self .integral_data_info .domain_integral_type_map [domain ]
368+ try :
369+ integral_type = self .integral_data_info .domain_integral_type_map [domain ]
370+ except KeyError :
371+ # skip unused domain
372+ continue
363373 variable_name = f"entity_orientations_{ i } "
364374 if integral_type in ['exterior_facet' , 'exterior_facet_vert' ]:
365375 o = gem .Variable (variable_name , (1 ,), dtype = gem .uint_type )
0 commit comments