@@ -1153,6 +1153,45 @@ const Elem * Elem::topological_neighbor (const unsigned int i,
11531153}
11541154
11551155
1156+ const Elem *
1157+ Elem ::topological_neighbor_side (const unsigned int i ,
1158+ const MeshBase & mesh ,
1159+ const PointLocatorBase & point_locator ,
1160+ const PeriodicBoundaries * pb ,
1161+ unsigned int * neigh_side ) const
1162+ {
1163+ libmesh_assert_less (i , this -> n_neighbors ());
1164+
1165+ const Elem * neighbor_i = this -> neighbor_ptr (i );
1166+ if (neighbor_i != nullptr )
1167+ return neighbor_i ;
1168+
1169+ if (pb )
1170+ {
1171+ // Since the neighbor is nullptr it must be on a boundary. We need
1172+ // see if this is a periodic boundary in which case it will have a
1173+ // topological neighbor
1174+ std ::vector < boundary_id_type > bc_ids ;
1175+ mesh .get_boundary_info ().boundary_ids (this , cast_int < unsigned short > (i ), bc_ids );
1176+ for (const auto & id : bc_ids )
1177+ if (pb -> boundary (id ))
1178+ {
1179+ neighbor_i = pb -> neighbor (id , point_locator , this , i , neigh_side );
1180+
1181+ // Since coarse elements do not have more refined
1182+ // neighbors we need to make sure that we don't return one
1183+ // of these types of neighbors.
1184+ if (neighbor_i )
1185+ while (level () < neighbor_i -> level ())
1186+ neighbor_i = neighbor_i -> parent ();
1187+ return neighbor_i ;
1188+ }
1189+ }
1190+
1191+ return nullptr ;
1192+ }
1193+
1194+
11561195bool Elem ::has_topological_neighbor (const Elem * elem ,
11571196 const MeshBase & mesh ,
11581197 const PointLocatorBase & point_locator ,
0 commit comments