@@ -1101,6 +1101,45 @@ const Elem * Elem::topological_neighbor (const unsigned int i,
11011101}
11021102
11031103
1104+ const Elem *
1105+ Elem ::topological_neighbor_side (const unsigned int i ,
1106+ const MeshBase & mesh ,
1107+ const PointLocatorBase & point_locator ,
1108+ const PeriodicBoundaries * pb ,
1109+ unsigned int * neigh_side ) const
1110+ {
1111+ libmesh_assert_less (i , this -> n_neighbors ());
1112+
1113+ const Elem * neighbor_i = this -> neighbor_ptr (i );
1114+ if (neighbor_i != nullptr )
1115+ return neighbor_i ;
1116+
1117+ if (pb )
1118+ {
1119+ // Since the neighbor is nullptr it must be on a boundary. We need
1120+ // see if this is a periodic boundary in which case it will have a
1121+ // topological neighbor
1122+ std ::vector < boundary_id_type > bc_ids ;
1123+ mesh .get_boundary_info ().boundary_ids (this , cast_int < unsigned short > (i ), bc_ids );
1124+ for (const auto & id : bc_ids )
1125+ if (pb -> boundary (id ))
1126+ {
1127+ neighbor_i = pb -> neighbor (id , point_locator , this , i , neigh_side );
1128+
1129+ // Since coarse elements do not have more refined
1130+ // neighbors we need to make sure that we don't return one
1131+ // of these types of neighbors.
1132+ if (neighbor_i )
1133+ while (level () < neighbor_i -> level ())
1134+ neighbor_i = neighbor_i -> parent ();
1135+ return neighbor_i ;
1136+ }
1137+ }
1138+
1139+ return nullptr ;
1140+ }
1141+
1142+
11041143bool Elem ::has_topological_neighbor (const Elem * elem ,
11051144 const MeshBase & mesh ,
11061145 const PointLocatorBase & point_locator ,
0 commit comments