diff --git a/meshmode/interop/firedrake/connection.py b/meshmode/interop/firedrake/connection.py index 6786bd16276b294a40b7b3a1091599ac985a27e8..84e3739ad7ba00a92c05624c0ff872692bae79af 100644 --- a/meshmode/interop/firedrake/connection.py +++ b/meshmode/interop/firedrake/connection.py @@ -129,6 +129,8 @@ class FiredrakeConnection: obtain firedrake unit dofs on the meshmode reference cell) .. automethod:: __init__ + .. automethod:: from_meshmode + .. automethod:: from_firedrake """ def __init__(self, discr, fdrake_fspace, mm2fd_node_mapping, group_nr=None): """ @@ -288,7 +290,7 @@ class FiredrakeConnection: if ufl_elt.family() != self._ufl_element.family(): raise ValueError(f"'{function_name}.function_space().ufl_element()" f".family()' must be {self._ufl_element.family()}" - f", not '{type(ufl_elt.family())}'") + f", not '{ufl_elt.family()}'") if ufl_elt.degree() != self._ufl_element.degree(): raise ValueError(f"'{function_name}.function_space().ufl_element()" f".degree()' must be {self._ufl_element.degree()}" @@ -480,7 +482,7 @@ class FiredrakeConnection: representing a field of shape *mm_field.shape* on :attr:`discr` - See :class:`~meshmode.dof.DOFArray` for further requirements. + See :class:`~meshmode.dof_array.DOFArray` for further requirements. The :attr:`group_nr` entry of each :class:`~meshmode.dof_array.DOFArray` must be of shape *(nelements, nunit_dofs)* and diff --git a/meshmode/interop/firedrake/mesh.py b/meshmode/interop/firedrake/mesh.py index f5d5f97fb79f14ca78c24c7443da768d66529a7f..bbc9e762fd89bdf77f50cc950ccd61438b86bc0e 100644 --- a/meshmode/interop/firedrake/mesh.py +++ b/meshmode/interop/firedrake/mesh.py @@ -251,10 +251,16 @@ def _get_firedrake_facial_adjacency_groups(fdrake_mesh_topology, boundary_tag_to_index = {bdy_tag: i for i, bdy_tag in enumerate(bdy_tags)} marker_to_neighbor_value = {} from meshmode.mesh import _boundary_tag_bit - # None for no marker + # for convenience, + # None maps to the boundary tag for a boundary facet with no marker marker_to_neighbor_value[None] = \ -(_boundary_tag_bit(bdy_tags, boundary_tag_to_index, BTAG_REALLY_ALL) | _boundary_tag_bit(bdy_tags, boundary_tag_to_index, BTAG_ALL)) + # firedrake exterior facets with no marker are assigned the + # a dummy marker + from firedrake.mesh import unmarked as fd_unmarked + marker_to_neighbor_value[fd_unmarked] = marker_to_neighbor_value[None] + # Now figure out the appropriate tags for each firedrake markers for marker in top.exterior_facets.unique_markers: marker_to_neighbor_value[marker] = \ -(_boundary_tag_bit(bdy_tags, boundary_tag_to_index, marker) @@ -348,18 +354,21 @@ def _get_firedrake_facial_adjacency_groups(fdrake_mesh_topology, dtype=Mesh.face_id_dtype) # If only using some of the cells, throw away unused cells and # move to new cell index + exterior_facet_markers = top.exterior_facets.markers if cells_to_use is not None: to_keep = np.isin(ext_elements, cells_to_use) ext_elements = np.vectorize(cells_to_use_inv.__getitem__)( ext_elements[to_keep]) ext_element_faces = ext_element_faces[to_keep] ext_neighbor_faces = ext_neighbor_faces[to_keep] + if exterior_facet_markers is not None: + exterior_facet_markers = exterior_facet_markers[to_keep] # tag the boundary, making sure to record custom tags # (firedrake "markers") if present if top.exterior_facets.markers is not None: ext_neighbors = np.zeros(ext_elements.shape, dtype=IntType) - for ifac, marker in enumerate(top.exterior_facets.markers): + for ifac, marker in enumerate(exterior_facet_markers): ext_neighbors[ifac] = marker_to_neighbor_value[marker] else: ext_neighbors = np.full(ext_elements.shape,