12#ifndef CABANA_GRID_LOCALGRID_IMPL_HPP
13#define CABANA_GRID_LOCALGRID_IMPL_HPP
21template <
class MeshType>
24 const int halo_cell_width )
25 : _global_grid( global_grid )
26 , _halo_cell_width( halo_cell_width )
32template <
class MeshType>
40template <
class MeshType>
48template <
class MeshType>
51 return _halo_cell_width;
56template <
class MeshType>
59 return _global_grid->
ownedNumCell( d ) + 2 * _halo_cell_width;
65template <
class MeshType>
67 const std::array<int, num_space_dim>& off_ijk )
const
69 std::array<int, num_space_dim> nijk;
71 nijk[d] = _global_grid->dimBlockId( d ) + off_ijk[d];
72 return _global_grid->blockRank( nijk );
75template <
class MeshType>
76template <std::
size_t NSD>
77std::enable_if_t<3 == NSD, int>
79 const int off_k )
const
81 std::array<int, num_space_dim> off_ijk = { off_i, off_j, off_k };
85template <
class MeshType>
86template <std::
size_t NSD>
87std::enable_if_t<2 == NSD, int>
90 std::array<int, num_space_dim> off_ijk = { off_i, off_j };
98template <
class MeshType>
99template <
class DecompositionTag,
class EntityType,
class IndexType>
104 return indexSpaceImpl( t1, t2, t3 );
114template <
class MeshType>
115template <
class DecompositionTag,
class EntityType>
117 DecompositionTag t1, EntityType t2,
118 const std::array<int, num_space_dim>& off_ijk,
const int halo_width )
const
119 -> IndexSpace<num_space_dim>
123 int hw = ( -1 == halo_width ) ? _halo_cell_width : halo_width;
126 for ( std::size_t d = 0; d < num_space_dim; ++d )
127 if ( off_ijk[d] < -1 || 1 < off_ijk[d] )
128 throw std::logic_error(
"Neighbor indices out of bounds" );
131 if ( hw > _halo_cell_width )
132 throw std::logic_error(
133 "Requested halo width larger than local grid halo" );
137 if ( neighborRank( off_ijk ) < 0 )
139 std::array<long, num_space_dim> zero_size;
140 for ( std::size_t d = 0; d < num_space_dim; ++d )
142 return IndexSpace<num_space_dim>( zero_size, zero_size );
146 return sharedIndexSpaceImpl( t1, t2, off_ijk, hw );
149template <
class MeshType>
150template <
class DecompositionTag,
class EntityType, std::
size_t NSD>
152 DecompositionTag t1, EntityType t2,
const int off_i,
const int off_j,
153 const int off_k,
const int halo_width )
const
155 std::array<int, 3> off_ijk = { off_i, off_j, off_k };
156 return sharedIndexSpace( t1, t2, off_ijk, halo_width );
159template <
class MeshType>
160template <
class DecompositionTag,
class EntityType, std::
size_t NSD>
161std::enable_if_t<2 == NSD, IndexSpace<2>>
163 const int off_i,
const int off_j,
164 const int halo_width )
const
166 std::array<int, 2> off_ijk = { off_i, off_j };
167 return sharedIndexSpace( t1, t2, off_ijk, halo_width );
179template <
class MeshType>
180template <
class DecompositionTag,
class EntityType>
182 DecompositionTag t1, EntityType t2,
183 const std::array<int, num_space_dim>& off_ijk,
const int halo_width )
const
188 int hw = ( -1 == halo_width ) ? _halo_cell_width : halo_width;
191 for ( std::size_t d = 0; d < num_space_dim; ++d )
192 if ( off_ijk[d] < -1 || 1 < off_ijk[d] )
193 throw std::logic_error(
"Boundary indices out of bounds" );
196 if ( hw > _halo_cell_width )
197 throw std::logic_error(
198 "Requested halo width larger than local grid halo" );
202 if ( neighborRank( off_ijk ) >= 0 )
204 std::array<long, num_space_dim> zero_size;
205 for ( std::size_t d = 0; d < num_space_dim; ++d )
210 return boundaryIndexSpaceImpl( t1, t2, off_ijk, hw );
213template <
class MeshType>
214template <
class DecompositionTag,
class EntityType, std::
size_t NSD>
215std::enable_if_t<3 == NSD, IndexSpace<3>>
217 const int off_i,
const int off_j,
219 const int halo_width )
const
221 std::array<int, 3> off_ijk = { off_i, off_j, off_k };
222 return boundaryIndexSpace( t1, t2, off_ijk, halo_width );
225template <
class MeshType>
226template <
class DecompositionTag,
class EntityType, std::
size_t NSD>
227std::enable_if_t<2 == NSD, IndexSpace<2>>
229 const int off_i,
const int off_j,
230 const int halo_width )
const
232 std::array<int, 2> off_ijk = { off_i, off_j };
233 return boundaryIndexSpace( t1, t2, off_ijk, halo_width );
238template <
class MeshType>
239auto LocalGrid<MeshType>::indexSpaceImpl(
Own,
Cell,
Local )
const
243 std::array<long, num_space_dim> min;
244 for ( std::size_t d = 0; d < num_space_dim; ++d )
245 min[d] = _halo_cell_width;
248 std::array<long, num_space_dim> max;
249 for ( std::size_t d = 0; d < num_space_dim; ++d )
250 max[d] = min[d] + _global_grid->ownedNumCell( d );
257template <
class MeshType>
258auto LocalGrid<MeshType>::indexSpaceImpl(
Ghost,
Cell,
Local )
const
262 std::array<long, num_space_dim>
size;
263 for ( std::size_t d = 0; d < num_space_dim; ++d )
265 size[d] = totalNumCell( d );
273template <
class MeshType>
274auto LocalGrid<MeshType>::indexSpaceImpl(
Own t1,
Cell t2,
Global )
const
277 return globalIndexSpace( t1, t2 );
281template <
class MeshType>
282template <
class OwnedIndexSpace>
283auto LocalGrid<MeshType>::getBound(
284 OwnedIndexSpace owned_space,
const int upper_lower,
285 const std::array<int, num_space_dim>& off_ijk,
const int lower_shift,
286 const int upper_shift )
const
289 std::array<long, num_space_dim> minmax;
290 for ( std::size_t d = 0; d < num_space_dim; ++d )
293 if ( -1 == off_ijk[d] )
295 minmax[d] = owned_space.min( d ) + lower_shift;
298 else if ( 0 == off_ijk[d] )
300 if ( upper_lower < 0 )
301 minmax[d] = owned_space.min( d );
302 else if ( upper_lower > 0 )
303 minmax[d] = owned_space.max( d );
305 throw std::runtime_error(
"Impl: Only 1 or -1 allowed" );
308 else if ( 1 == off_ijk[d] )
310 minmax[d] = owned_space.max( d ) + upper_shift;
314 throw std::runtime_error(
"Neighbor offset must be 1, 0, or -1" );
322template <
class MeshType>
323template <
int Dir,
class OwnedIndexSpace>
324auto LocalGrid<MeshType>::getBound(
325 OwnedIndexSpace owned_space,
const int upper_lower,
326 const std::array<int, num_space_dim>& off_ijk,
const int lower_shift_dir,
327 const int lower_shift,
const int upper_shift_dir,
328 const int upper_shift )
const
331 std::array<long, num_space_dim> minmax;
332 for ( std::size_t d = 0; d < num_space_dim; ++d )
335 if ( -1 == off_ijk[d] )
337 minmax[d] = ( Dir == d ) ? owned_space.min( d ) + lower_shift_dir
338 : owned_space.min( d ) + lower_shift;
341 else if ( 0 == off_ijk[d] )
343 if ( upper_lower < 0 )
344 minmax[d] = owned_space.min( d );
345 else if ( upper_lower > 0 )
346 minmax[d] = owned_space.max( d );
348 throw std::runtime_error(
"Impl: Only 1 or -1 allowed" );
351 else if ( 1 == off_ijk[d] )
353 minmax[d] = ( Dir == d ) ? owned_space.max( d ) + upper_shift_dir
354 : owned_space.max( d ) + upper_shift;
358 throw std::runtime_error(
"Neighbor offset must be 1, 0, or -1" );
367template <
class MeshType>
368auto LocalGrid<MeshType>::sharedIndexSpaceImpl(
369 Own,
Cell,
const std::array<int, num_space_dim>& off_ijk,
373 auto owned_space = indexSpaceImpl(
Own(),
Cell(),
Local() );
375 auto min = getBound( owned_space, -1, off_ijk, 0, -halo_width );
376 auto max = getBound( owned_space, 1, off_ijk, halo_width, 0 );
385template <
class MeshType>
386auto LocalGrid<MeshType>::sharedIndexSpaceImpl(
387 Ghost,
Cell,
const std::array<int, num_space_dim>& off_ijk,
391 auto owned_space = indexSpaceImpl(
Own(),
Cell(),
Local() );
393 auto min = getBound( owned_space, -1, off_ijk, -halo_width, 0 );
394 auto max = getBound( owned_space, 1, off_ijk, 0, halo_width );
403template <
class MeshType>
404auto LocalGrid<MeshType>::boundaryIndexSpaceImpl(
405 Own,
Cell,
const std::array<int, num_space_dim>& off_ijk,
408 return sharedIndexSpaceImpl(
Own(),
Cell(), off_ijk, halo_width );
415template <
class MeshType>
416auto LocalGrid<MeshType>::boundaryIndexSpaceImpl(
417 Ghost,
Cell,
const std::array<int, num_space_dim>& off_ijk,
420 return sharedIndexSpaceImpl(
Ghost(),
Cell(), off_ijk, halo_width );
425template <
class MeshType>
426auto LocalGrid<MeshType>::indexSpaceImpl(
Own,
Node,
Local )
const
430 std::array<long, num_space_dim> min;
431 for ( std::size_t d = 0; d < num_space_dim; ++d )
432 min[d] = _halo_cell_width;
436 std::array<long, num_space_dim> max;
437 for ( std::size_t d = 0; d < num_space_dim; ++d )
438 max[d] = ( _global_grid->isPeriodic( d ) ||
439 _global_grid->dimBlockId( d ) <
440 _global_grid->dimNumBlock( d ) - 1 )
441 ? min[d] + _global_grid->ownedNumCell( d )
442 : min[d] + _global_grid->ownedNumCell( d ) + 1;
449template <
class MeshType>
450auto LocalGrid<MeshType>::indexSpaceImpl(
Ghost,
Node,
Local )
const
454 std::array<long, num_space_dim>
size;
455 for ( std::size_t d = 0; d < num_space_dim; ++d )
457 size[d] = totalNumCell( d ) + 1;
465template <
class MeshType>
466auto LocalGrid<MeshType>::indexSpaceImpl(
Own t1,
Node t2,
Global )
const
469 return globalIndexSpace( t1, t2 );
475template <
class MeshType>
476auto LocalGrid<MeshType>::sharedIndexSpaceImpl(
477 Own,
Node,
const std::array<int, num_space_dim>& off_ijk,
481 auto owned_space = indexSpaceImpl(
Own(),
Node(),
Local() );
483 auto min = getBound( owned_space, -1, off_ijk, 0, -halo_width );
484 auto max = getBound( owned_space, 1, off_ijk, halo_width + 1, 0 );
493template <
class MeshType>
494auto LocalGrid<MeshType>::sharedIndexSpaceImpl(
495 Ghost,
Node,
const std::array<int, num_space_dim>& off_ijk,
499 auto owned_space = indexSpaceImpl(
Own(),
Node(),
Local() );
501 auto min = getBound( owned_space, -1, off_ijk, -halo_width, 0 );
502 auto max = getBound( owned_space, 1, off_ijk, 0, halo_width + 1 );
511template <
class MeshType>
512auto LocalGrid<MeshType>::boundaryIndexSpaceImpl(
513 Own,
Node,
const std::array<int, num_space_dim>& off_ijk,
517 auto owned_space = indexSpaceImpl(
Own(),
Node(),
Local() );
519 auto min = getBound( owned_space, -1, off_ijk, 0, -halo_width - 1 );
520 auto max = getBound( owned_space, 1, off_ijk, halo_width + 1, 0 );
529template <
class MeshType>
530auto LocalGrid<MeshType>::boundaryIndexSpaceImpl(
531 Ghost,
Node,
const std::array<int, num_space_dim>& off_ijk,
535 auto owned_space = indexSpaceImpl(
Own(),
Node(),
Local() );
537 auto min = getBound( owned_space, -1, off_ijk, -halo_width, 0 );
538 auto max = getBound( owned_space, 1, off_ijk, 0, halo_width );
544template <
class MeshType>
549 return faceIndexSpace( t1, t2, t3 );
553template <
class MeshType>
558 return faceIndexSpace( t1, t2, t3 );
562template <
class MeshType>
567 return faceIndexSpace( t1, t2, t3 );
571template <
class MeshType>
572auto LocalGrid<MeshType>::sharedIndexSpaceImpl(
573 Own t1,
Face<Dim::I> t2,
const std::array<int, num_space_dim>& off_ijk,
576 return faceSharedIndexSpace( t1, t2, off_ijk, halo_width );
580template <
class MeshType>
581auto LocalGrid<MeshType>::sharedIndexSpaceImpl(
585 return faceSharedIndexSpace( t1, t2, off_ijk, halo_width );
589template <
class MeshType>
590auto LocalGrid<MeshType>::boundaryIndexSpaceImpl(
591 Own t1,
Face<Dim::I> t2,
const std::array<int, num_space_dim>& off_ijk,
594 return faceBoundaryIndexSpace( t1, t2, off_ijk, halo_width );
598template <
class MeshType>
599auto LocalGrid<MeshType>::boundaryIndexSpaceImpl(
603 return faceBoundaryIndexSpace( t1, t2, off_ijk, halo_width );
607template <
class MeshType>
612 return faceIndexSpace( t1, t2, t3 );
616template <
class MeshType>
621 return faceIndexSpace( t1, t2, t3 );
625template <
class MeshType>
630 return faceIndexSpace( t1, t2, t3 );
634template <
class MeshType>
635auto LocalGrid<MeshType>::sharedIndexSpaceImpl(
636 Own t1,
Face<Dim::J> t2,
const std::array<int, num_space_dim>& off_ijk,
639 return faceSharedIndexSpace( t1, t2, off_ijk, halo_width );
643template <
class MeshType>
644auto LocalGrid<MeshType>::sharedIndexSpaceImpl(
648 return faceSharedIndexSpace( t1, t2, off_ijk, halo_width );
652template <
class MeshType>
653auto LocalGrid<MeshType>::boundaryIndexSpaceImpl(
654 Own t1,
Face<Dim::J> t2,
const std::array<int, num_space_dim>& off_ijk,
657 return faceBoundaryIndexSpace( t1, t2, off_ijk, halo_width );
661template <
class MeshType>
662auto LocalGrid<MeshType>::boundaryIndexSpaceImpl(
666 return faceBoundaryIndexSpace( t1, t2, off_ijk, halo_width );
670template <
class MeshType>
671template <std::
size_t NSD>
672std::enable_if_t<3 == NSD, IndexSpace<3>>
675 return faceIndexSpace( t1, t2, t3 );
679template <
class MeshType>
680template <std::
size_t NSD>
681std::enable_if_t<3 == NSD, IndexSpace<3>>
684 return faceIndexSpace( t1, t2, t3 );
688template <
class MeshType>
689template <std::
size_t NSD>
690std::enable_if_t<3 == NSD, IndexSpace<3>>
693 return faceIndexSpace( t1, t2, t3 );
697template <
class MeshType>
698template <std::
size_t NSD>
699std::enable_if_t<3 == NSD, IndexSpace<3>>
701 const std::array<int, 3>& off_ijk,
702 const int halo_width )
const
704 return faceSharedIndexSpace( t1, t2, off_ijk, halo_width );
708template <
class MeshType>
709template <std::
size_t NSD>
710std::enable_if_t<3 == NSD, IndexSpace<3>>
712 const std::array<int, 3>& off_ijk,
713 const int halo_width )
const
715 return faceSharedIndexSpace( t1, t2, off_ijk, halo_width );
719template <
class MeshType>
720template <std::
size_t NSD>
721std::enable_if_t<3 == NSD, IndexSpace<3>>
723 const std::array<int, 3>& off_ijk,
724 const int halo_width )
const
726 return faceBoundaryIndexSpace( t1, t2, off_ijk, halo_width );
730template <
class MeshType>
731template <std::
size_t NSD>
732std::enable_if_t<3 == NSD, IndexSpace<3>>
734 const std::array<int, 3>& off_ijk,
735 const int halo_width )
const
737 return faceBoundaryIndexSpace( t1, t2, off_ijk, halo_width );
741template <
class MeshType>
742template <std::
size_t NSD>
743std::enable_if_t<3 == NSD, IndexSpace<3>>
746 return edgeIndexSpace( t1, t2, t3 );
750template <
class MeshType>
751template <std::
size_t NSD>
752std::enable_if_t<3 == NSD, IndexSpace<3>>
755 return edgeIndexSpace( t1, t2, t3 );
759template <
class MeshType>
760template <std::
size_t NSD>
761std::enable_if_t<3 == NSD, IndexSpace<3>>
764 return edgeIndexSpace( t1, t2, t3 );
768template <
class MeshType>
769template <std::
size_t NSD>
770std::enable_if_t<3 == NSD, IndexSpace<3>>
772 const std::array<int, 3>& off_ijk,
773 const int halo_width )
const
775 return edgeSharedIndexSpace( t1, t2, off_ijk, halo_width );
779template <
class MeshType>
780template <std::
size_t NSD>
781std::enable_if_t<3 == NSD, IndexSpace<3>>
783 const std::array<int, 3>& off_ijk,
784 const int halo_width )
const
786 return edgeSharedIndexSpace( t1, t2, off_ijk, halo_width );
790template <
class MeshType>
791template <std::
size_t NSD>
792std::enable_if_t<3 == NSD, IndexSpace<3>>
794 const std::array<int, 3>& off_ijk,
795 const int halo_width )
const
797 return edgeBoundaryIndexSpace( t1, t2, off_ijk, halo_width );
801template <
class MeshType>
802template <std::
size_t NSD>
803std::enable_if_t<3 == NSD, IndexSpace<3>>
805 const std::array<int, 3>& off_ijk,
806 const int halo_width )
const
808 return edgeBoundaryIndexSpace( t1, t2, off_ijk, halo_width );
812template <
class MeshType>
813template <std::
size_t NSD>
814std::enable_if_t<3 == NSD, IndexSpace<3>>
817 return edgeIndexSpace( t1, t2, t3 );
821template <
class MeshType>
822template <std::
size_t NSD>
823std::enable_if_t<3 == NSD, IndexSpace<3>>
826 return edgeIndexSpace( t1, t2, t3 );
830template <
class MeshType>
831template <std::
size_t NSD>
832std::enable_if_t<3 == NSD, IndexSpace<3>>
835 return edgeIndexSpace( t1, t2, t3 );
839template <
class MeshType>
840template <std::
size_t NSD>
841std::enable_if_t<3 == NSD, IndexSpace<3>>
843 const std::array<int, 3>& off_ijk,
844 const int halo_width )
const
846 return edgeSharedIndexSpace( t1, t2, off_ijk, halo_width );
850template <
class MeshType>
851template <std::
size_t NSD>
852std::enable_if_t<3 == NSD, IndexSpace<3>>
854 const std::array<int, 3>& off_ijk,
855 const int halo_width )
const
857 return edgeSharedIndexSpace( t1, t2, off_ijk, halo_width );
861template <
class MeshType>
862template <std::
size_t NSD>
863std::enable_if_t<3 == NSD, IndexSpace<3>>
865 const std::array<int, 3>& off_ijk,
866 const int halo_width )
const
868 return edgeBoundaryIndexSpace( t1, t2, off_ijk, halo_width );
872template <
class MeshType>
873template <std::
size_t NSD>
874std::enable_if_t<3 == NSD, IndexSpace<3>>
876 const std::array<int, 3>& off_ijk,
877 const int halo_width )
const
879 return edgeBoundaryIndexSpace( t1, t2, off_ijk, halo_width );
882template <
class MeshType>
883template <std::
size_t NSD>
884std::enable_if_t<3 == NSD, IndexSpace<3>>
887 return edgeIndexSpace( t1, t2, t3 );
891template <
class MeshType>
892template <std::
size_t NSD>
893std::enable_if_t<3 == NSD, IndexSpace<3>>
896 return edgeIndexSpace( t1, t2, t3 );
900template <
class MeshType>
901template <std::
size_t NSD>
902std::enable_if_t<3 == NSD, IndexSpace<3>>
905 return edgeIndexSpace( t1, t2, t3 );
909template <
class MeshType>
910template <std::
size_t NSD>
911std::enable_if_t<3 == NSD, IndexSpace<3>>
913 const std::array<int, 3>& off_ijk,
914 const int halo_width )
const
916 return edgeSharedIndexSpace( t1, t2, off_ijk, halo_width );
920template <
class MeshType>
921template <std::
size_t NSD>
922std::enable_if_t<3 == NSD, IndexSpace<3>>
924 const std::array<int, 3>& off_ijk,
925 const int halo_width )
const
927 return edgeSharedIndexSpace( t1, t2, off_ijk, halo_width );
931template <
class MeshType>
932template <std::
size_t NSD>
933std::enable_if_t<3 == NSD, IndexSpace<3>>
935 const std::array<int, 3>& off_ijk,
936 const int halo_width )
const
938 return edgeBoundaryIndexSpace( t1, t2, off_ijk, halo_width );
942template <
class MeshType>
943template <std::
size_t NSD>
944std::enable_if_t<3 == NSD, IndexSpace<3>>
946 const std::array<int, 3>& off_ijk,
947 const int halo_width )
const
949 return edgeBoundaryIndexSpace( t1, t2, off_ijk, halo_width );
954template <
class MeshType>
955template <
class EntityType>
956auto LocalGrid<MeshType>::globalIndexSpace(
Own, EntityType )
const
959 auto local_space = indexSpaceImpl(
Own(), EntityType(),
Local() );
960 std::array<long, num_space_dim> min;
961 std::array<long, num_space_dim> max;
962 for ( std::size_t d = 0; d < num_space_dim; ++d )
964 min[d] = _global_grid->globalOffset( d );
965 max[d] = min[d] + local_space.extent( d );
973template <
class MeshType>
978 static_assert( Dir < num_space_dim,
"Spatial dimension out of bounds" );
981 std::array<long, num_space_dim> min;
982 for ( std::size_t d = 0; d < num_space_dim; ++d )
983 min[d] = _halo_cell_width;
986 std::array<long, num_space_dim> max;
987 for ( std::size_t d = 0; d < num_space_dim; ++d )
991 max[d] = ( _global_grid->isPeriodic( d ) ||
992 _global_grid->dimBlockId( d ) <
993 _global_grid->dimNumBlock( d ) - 1 )
994 ? min[d] + _global_grid->ownedNumCell( d )
995 : min[d] + _global_grid->ownedNumCell( d ) + 1;
999 max[d] = min[d] + _global_grid->ownedNumCell( d );
1008template <
class MeshType>
1013 static_assert( Dir < num_space_dim,
"Spatial dimension out of bounds" );
1016 std::array<long, num_space_dim>
size;
1017 for ( std::size_t d = 0; d < num_space_dim; ++d )
1021 size[d] = totalNumCell( d ) + 1;
1025 size[d] = totalNumCell( d );
1034template <
class MeshType>
1039 static_assert( Dir < num_space_dim,
"Spatial dimension out of bounds" );
1040 return globalIndexSpace( t1, t2 );
1047template <
class MeshType>
1049auto LocalGrid<MeshType>::faceSharedIndexSpace(
1050 Own,
Face<Dir>,
const std::array<int, num_space_dim>& off_ijk,
1053 static_assert( Dir < num_space_dim,
"Spatial dimension out of bounds" );
1058 auto min = getBound( owned_space, -1, off_ijk, 0, -halo_width );
1059 auto max = getBound<Dir>( owned_space, 1, off_ijk, halo_width + 1,
1069template <
class MeshType>
1071auto LocalGrid<MeshType>::faceSharedIndexSpace(
1075 static_assert( Dir < num_space_dim,
"Spatial dimension out of bounds" );
1080 auto min = getBound( owned_space, -1, off_ijk, -halo_width, 0 );
1081 auto max = getBound<Dir>( owned_space, 1, off_ijk, 0, 0, halo_width + 1,
1091template <
class MeshType>
1093auto LocalGrid<MeshType>::faceBoundaryIndexSpace(
1094 Own,
Face<Dir>,
const std::array<int, num_space_dim>& off_ijk,
1097 static_assert( Dir < num_space_dim,
"Spatial dimension out of bounds" );
1102 auto min = getBound<Dir>( owned_space, -1, off_ijk, 0, 0, -halo_width - 1,
1104 auto max = getBound<Dir>( owned_space, 1, off_ijk, halo_width + 1,
1114template <
class MeshType>
1116auto LocalGrid<MeshType>::faceBoundaryIndexSpace(
1120 static_assert( Dir < num_space_dim,
"Spatial dimension out of bounds" );
1125 auto min = getBound( owned_space, -1, off_ijk, -halo_width, 0 );
1126 auto max = getBound( owned_space, 1, off_ijk, 0, halo_width );
1132template <
class MeshType>
1133template <
int Dir, std::
size_t NSD>
1134std::enable_if_t<3 == NSD, IndexSpace<3>>
1138 std::array<long, 3> min;
1139 for ( std::size_t d = 0; d < 3; ++d )
1140 min[d] = _halo_cell_width;
1143 std::array<long, 3> max;
1144 for ( std::size_t d = 0; d < 3; ++d )
1148 max[d] = min[d] + _global_grid->ownedNumCell( d );
1152 max[d] = ( _global_grid->isPeriodic( d ) ||
1153 _global_grid->dimBlockId( d ) <
1154 _global_grid->dimNumBlock( d ) - 1 )
1155 ? min[d] + _global_grid->ownedNumCell( d )
1156 : min[d] + _global_grid->ownedNumCell( d ) + 1;
1165template <
class MeshType>
1166template <
int Dir, std::
size_t NSD>
1167std::enable_if_t<3 == NSD, IndexSpace<3>>
1171 std::array<long, 3>
size;
1172 for ( std::size_t d = 0; d < 3; ++d )
1176 size[d] = totalNumCell( d );
1180 size[d] = totalNumCell( d ) + 1;
1189template <
class MeshType>
1190template <
int Dir, std::
size_t NSD>
1191std::enable_if_t<3 == NSD, IndexSpace<3>>
1194 return globalIndexSpace( t1, t2 );
1201template <
class MeshType>
1202template <
int Dir, std::
size_t NSD>
1203std::enable_if_t<3 == NSD, IndexSpace<3>>
1204LocalGrid<MeshType>::edgeSharedIndexSpace(
Own,
Edge<Dir>,
1205 const std::array<int, 3>& off_ijk,
1206 const int halo_width )
const
1211 auto min = getBound( owned_space, -1, off_ijk, 0, -halo_width );
1212 auto max = getBound<Dir>( owned_space, 1, off_ijk, halo_width,
1213 halo_width + 1, 0, 0 );
1222template <
class MeshType>
1223template <
int Dir, std::
size_t NSD>
1224std::enable_if_t<3 == NSD, IndexSpace<3>>
1226 const std::array<int, 3>& off_ijk,
1227 const int halo_width )
const
1232 auto min = getBound( owned_space, -1, off_ijk, -halo_width, 0 );
1233 auto max = getBound<Dir>( owned_space, 1, off_ijk, 0, 0, halo_width,
1243template <
class MeshType>
1244template <
int Dir, std::
size_t NSD>
1245std::enable_if_t<3 == NSD, IndexSpace<3>>
1246LocalGrid<MeshType>::edgeBoundaryIndexSpace(
Own,
Edge<Dir>,
1247 const std::array<int, 3>& off_ijk,
1248 const int halo_width )
const
1253 auto min = getBound<Dir>( owned_space, -1, off_ijk, 0, 0, -halo_width,
1255 auto max = getBound<Dir>( owned_space, 1, off_ijk, halo_width,
1256 halo_width + 1, 0, 0 );
1265template <
class MeshType>
1266template <
int Dir, std::
size_t NSD>
1267std::enable_if_t<3 == NSD, IndexSpace<3>>
1269 const std::array<int, 3>& off_ijk,
1270 const int halo_width )
const
1275 auto min = getBound( owned_space, -1, off_ijk, -halo_width, 0 );
1276 auto max = getBound( owned_space, 1, off_ijk, 0, halo_width );
Global logical grid.
Definition Cabana_Grid_GlobalGrid.hpp:39
int ownedNumCell(const int dim) const
Get the owned number of cells in a given dimension of this block.
Definition Cabana_Grid_GlobalGrid_impl.hpp:302
Structured index space.
Definition Cabana_Grid_IndexSpace.hpp:37
IndexSpace< num_space_dim > sharedIndexSpace(DecompositionTag t1, EntityType t2, const std::array< int, num_space_dim > &off_ijk, const int halo_width=-1) const
Given the relative offsets of a neighbor rank relative to this local grid's indices get the set of lo...
IndexSpace< num_space_dim > indexSpace(DecompositionTag t1, EntityType t2, IndexType t3) const
Given a decomposition type, entity type, and index type, get the contiguous set of indices that span ...
int haloCellWidth() const
Get the number of cells in the halo.
Definition Cabana_Grid_LocalGrid_impl.hpp:49
LocalGrid(const std::shared_ptr< GlobalGrid< MeshType > > &global_grid, const int halo_cell_width)
Constructor.
Definition Cabana_Grid_LocalGrid_impl.hpp:22
const GlobalGrid< MeshType > & globalGrid() const
Get the global grid that owns the local grid.
Definition Cabana_Grid_LocalGrid_impl.hpp:33
static constexpr std::size_t num_space_dim
Spatial dimension.
Definition Cabana_Grid_LocalGrid.hpp:45
int neighborRank(const std::array< int, num_space_dim > &off_ijk) const
Get the global index of a neighbor given neighbor rank offsets relative to this local grid.
Definition Cabana_Grid_LocalGrid_impl.hpp:66
int totalNumCell(const int d) const
Get the total number of local cells per dimension (owned + halo).
Definition Cabana_Grid_LocalGrid_impl.hpp:57
IndexSpace< num_space_dim > boundaryIndexSpace(DecompositionTag t1, EntityType t2, const std::array< int, num_space_dim > &off_ijk, const int halo_width=-1) const
Given the relative offsets of a boundary relative to this local grid's indices get the set of local e...
Core: particle data structures and algorithms.
Definition Cabana_AoSoA.hpp:36
auto size(SliceType slice, typename std::enable_if< is_slice< SliceType >::value, int >::type *=0)
Check slice size (differs from Kokkos View).
Definition Cabana_Slice.hpp:1012
Mesh cell tag.
Definition Cabana_Grid_Types.hpp:49
Mesh edge tag.
Definition Cabana_Grid_Types.hpp:95
Mesh face tag.
Definition Cabana_Grid_Types.hpp:64
Ghosted decomposition tag.
Definition Cabana_Grid_Types.hpp:197
Global index tag.
Definition Cabana_Grid_Types.hpp:215
Local index tag.
Definition Cabana_Grid_Types.hpp:208
Mesh node tag.
Definition Cabana_Grid_Types.hpp:56
Owned decomposition tag.
Definition Cabana_Grid_Types.hpp:190