@@ -610,82 +610,79 @@ Packing<Elem *>::unpack (std::vector<largest_id_type>::const_iterator in,
610610 // to update a remote_elem link, and we can check for possible
611611 // inconsistencies along the way.
612612 //
613- // For subactive elements, we don't bother keeping neighbor
614- // links in good shape, so there's nothing we need to set or can
615- // safely assert here.
616- if (!elem -> subactive ())
617- for (auto n : elem -> side_index_range ())
618- {
619- const dof_id_type neighbor_id =
620- cast_int < dof_id_type > (* in ++ );
613+ // Even for subactive elements, we'll try to keep neighbor links
614+ // in good shape now, if only so any future find_neighbors() is
615+ // idempotent.
616+ for (auto n : elem -> side_index_range ())
617+ {
618+ const dof_id_type neighbor_id =
619+ cast_int < dof_id_type > (* in ++ );
621620
622- const dof_id_type neighbor_side =
623- cast_int < dof_id_type > (* in ++ );
621+ const dof_id_type neighbor_side =
622+ cast_int < dof_id_type > (* in ++ );
624623
625- // If the sending processor sees a domain boundary here,
626- // we'd better agree ... unless all we see is a
627- // remote_elem? In that case maybe we just couldn't keep
628- // up with a user's delete_elem. Let's trust them.
629- if (neighbor_id == DofObject ::invalid_id )
630- {
631- const Elem * my_neigh = elem -> neighbor_ptr (n );
632- if (my_neigh == remote_elem )
633- elem -> set_neighbor (n , nullptr );
634- else
635- libmesh_assert (!my_neigh );
636- continue ;
637- }
624+ // If the sending processor sees a domain boundary here,
625+ // we'd better agree ... unless all we see is a remote_elem?
626+ // In that case maybe we just couldn't keep up with a user's
627+ // delete_elem. Let's trust them.
628+ if (neighbor_id == DofObject ::invalid_id )
629+ {
630+ const Elem * my_neigh = elem -> neighbor_ptr (n );
631+ if (my_neigh == remote_elem )
632+ elem -> set_neighbor (n , nullptr );
633+ else
634+ libmesh_assert (!my_neigh );
635+ continue ;
636+ }
638637
639- // If the sending processor has a remote_elem neighbor here,
640- // then all we know is that we'd better *not* have a domain
641- // boundary ... except that maybe it's the *sending*
642- // processor who missed a delete_elem we saw.
643- if (neighbor_id == remote_elem -> id ())
644- {
645- // At this level of the code we can't even assert in
646- // cases where the neighbor should know what they're
647- // talking about, so skip it.
638+ // If the sending processor has a remote_elem neighbor here,
639+ // then all we know is that we'd better *not* have a domain
640+ // boundary ... except that maybe it's the *sending*
641+ // processor who missed a delete_elem we saw.
642+ if (neighbor_id == remote_elem -> id ())
643+ {
644+ // At this level of the code we can't even assert in
645+ // cases where the neighbor should know what they're
646+ // talking about, so skip it.
648647
649- // libmesh_assert(elem->neighbor_ptr(n));
650- continue ;
651- }
648+ // libmesh_assert(elem->neighbor_ptr(n));
649+ continue ;
650+ }
652651
653- Elem * neigh = mesh -> query_elem_ptr (neighbor_id );
652+ Elem * neigh = mesh -> query_elem_ptr (neighbor_id );
654653
655- // The sending processor sees a neighbor here, so if we
656- // don't have that neighboring element, then we'd better
657- // have a remote_elem signifying that fact.
658- if (!neigh )
659- {
660- libmesh_assert_equal_to (elem -> neighbor_ptr (n ), remote_elem );
661- continue ;
662- }
654+ // The sending processor sees a neighbor here, so if we
655+ // don't have that neighboring element, then we'd better
656+ // have a remote_elem signifying that fact.
657+ if (!neigh )
658+ {
659+ libmesh_assert_equal_to (elem -> neighbor_ptr (n ), remote_elem );
660+ continue ;
661+ }
663662
664- // The sending processor has a neighbor here, and we have
665- // that element, but that does *NOT* mean we're already
666- // linking to it. Perhaps we initially received both elem
667- // and neigh from processors on which their mutual link was
668- // remote?
669- libmesh_assert (elem -> neighbor_ptr (n ) == neigh ||
670- elem -> neighbor_ptr (n ) == remote_elem );
671-
672- // If the link was originally remote, we should update it,
673- // and make sure the appropriate parts of its family link
674- // back to us.
675- if (elem -> neighbor_ptr (n ) == remote_elem )
676- {
677- elem -> set_neighbor (n , neigh );
663+ // The sending processor has a neighbor here, and we have
664+ // that element, but that does *NOT* mean we're already
665+ // linking to it. Perhaps we initially received both elem
666+ // and neigh from processors on which their mutual link was
667+ // remote?
668+ libmesh_assert (elem -> neighbor_ptr (n ) == neigh ||
669+ elem -> neighbor_ptr (n ) == remote_elem );
670+
671+ // If the link was originally remote, we should update it,
672+ // and make sure the appropriate parts of its family link
673+ // back to us.
674+ if (elem -> neighbor_ptr (n ) == remote_elem )
675+ {
676+ elem -> set_neighbor (n , neigh );
678677
678+ if (neighbor_side != libMesh ::invalid_uint )
679679 elem -> make_links_to_me_local (n , neighbor_side );
680- }
681- else
682- libmesh_assert (neigh -> level () < elem -> level () ||
683- neigh -> neighbor_ptr (neighbor_side ) == elem );
684- }
685- else
686- // We skip these to go to the boundary information if the element is
687- // actually subactive
688- in += 2 * elem -> n_sides ();
680+ }
681+ else
682+ libmesh_assert (elem -> subactive () ||
683+ neigh -> level () < elem -> level () ||
684+ neigh -> neighbor_ptr (neighbor_side ) == elem );
685+ }
689686
690687 // Our p level and refinement flags should be "close to" correct
691688 // if we're not an active element - we might have a p level
@@ -841,7 +838,8 @@ Packing<Elem *>::unpack (std::vector<largest_id_type>::const_iterator in,
841838 // to us.
842839 elem -> set_neighbor (n , neigh );
843840
844- elem -> make_links_to_me_local (n , neighbor_side );
841+ if (neighbor_side != libMesh ::invalid_uint )
842+ elem -> make_links_to_me_local (n , neighbor_side );
845843 }
846844
847845 elem -> unpack_indexing (in );
0 commit comments