@@ -116,7 +116,7 @@ auto LocalGrid<MeshType>::setupHaloWidth( const int halo_width )
116116 return hw;
117117}
118118
119- auto LocalGrid<MeshType>::checkOffsets(
119+ void LocalGrid<MeshType>::checkOffsets(
120120 const std::array<int , num_space_dim>& off_ijk )
121121{
122122 // Check that the offsets are valid.
@@ -238,6 +238,42 @@ LocalGrid<MeshType>::boundaryIndexSpace( DecompositionTag t1, EntityType t2,
238238 return boundaryIndexSpace ( t1, t2, off_ijk, halo_width );
239239}
240240
241+ // ---------------------------------------------------------------------------//
242+ // Given the relative offsets of a boundary relative to this local grid's
243+ // indices get the set of local entity indices associated with that periodic
244+ // boundary in the given decomposition. Optionally provide a halo width for the
245+ // shared space. This halo width must be less than or equal to the halo width of
246+ // the local grid. The default behavior is to use the halo width of the local
247+ // grid. For example, if the Own decomposition is used, the interior entities
248+ // that would be affected by a periodic boundary operation are provided whereas
249+ // if the Ghost decomposition is used the halo entities on the boundary are
250+ // provided.
251+ template <class MeshType >
252+ template <class DecompositionTag , class EntityType >
253+ auto LocalGrid<MeshType>::periodicIndexSpace(
254+ DecompositionTag t1, EntityType t2,
255+ const std::array<int , num_space_dim>& off_ijk, const int halo_width ) const
256+ -> IndexSpace<num_space_dim>
257+ {
258+ auto hw = setupHaloWidth ( halo_width );
259+ checkOffsets ( off_ijk );
260+
261+ // Check to see if this is a periodic neighbor. If not, return a boundary
262+ // space of size 0 because there is no periodic boundary.
263+ bool periodic_ijk = true ;
264+ for ( std::size_t d = 0 ; d < num_space_dim; ++d )
265+ if ( off_ijk[d] == 0 || !_global_grid->isPeriodic ( d ) )
266+ periodic_ijk = false ;
267+ if ( !periodic_ijk )
268+ {
269+ return zeroIndexSpace ();
270+ }
271+
272+ // Periodic spaces equivalent to boundary except determining whether this
273+ // offset is valid (see above).
274+ return boundaryIndexSpaceImpl ( t1, t2, off_ijk, hw );
275+ }
276+
241277// ---------------------------------------------------------------------------//
242278// Get the local index space of the owned cells.
243279template <class MeshType >
0 commit comments