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(
"Cabana::Grid::LocalGrid::getBound::"
306 "Impl: Only 1 or -1 allowed" );
309 else if ( 1 == off_ijk[d] )
311 minmax[d] = owned_space.max( d ) + upper_shift;
315 throw std::runtime_error(
"Cabana::Grid::LocalGrid::getBound: "
316 "Neighbor offset must be 1, 0, or -1" );
324template <
class MeshType>
325template <
int Dir,
class OwnedIndexSpace>
326auto LocalGrid<MeshType>::getBound(
327 OwnedIndexSpace owned_space,
const int upper_lower,
328 const std::array<int, num_space_dim>& off_ijk,
const int lower_shift_dir,
329 const int lower_shift,
const int upper_shift_dir,
330 const int upper_shift )
const
333 std::array<long, num_space_dim> minmax;
334 for ( std::size_t d = 0; d < num_space_dim; ++d )
337 if ( -1 == off_ijk[d] )
339 minmax[d] = ( Dir == d ) ? owned_space.min( d ) + lower_shift_dir
340 : owned_space.min( d ) + lower_shift;
343 else if ( 0 == off_ijk[d] )
345 if ( upper_lower < 0 )
346 minmax[d] = owned_space.min( d );
347 else if ( upper_lower > 0 )
348 minmax[d] = owned_space.max( d );
350 throw std::runtime_error(
"Cabana::Grid::LocalGrid::getBound::"
351 "Impl: Only 1 or -1 allowed" );
354 else if ( 1 == off_ijk[d] )
356 minmax[d] = ( Dir == d ) ? owned_space.max( d ) + upper_shift_dir
357 : owned_space.max( d ) + upper_shift;
361 throw std::runtime_error(
"Cabana::Grid::LocalGrid::getBound: "
362 "Neighbor offset must be 1, 0, or -1" );
371template <
class MeshType>
372auto LocalGrid<MeshType>::sharedIndexSpaceImpl(
373 Own,
Cell,
const std::array<int, num_space_dim>& off_ijk,
377 auto owned_space = indexSpaceImpl(
Own(),
Cell(),
Local() );
379 auto min = getBound( owned_space, -1, off_ijk, 0, -halo_width );
380 auto max = getBound( owned_space, 1, off_ijk, halo_width, 0 );
389template <
class MeshType>
390auto LocalGrid<MeshType>::sharedIndexSpaceImpl(
391 Ghost,
Cell,
const std::array<int, num_space_dim>& off_ijk,
395 auto owned_space = indexSpaceImpl(
Own(),
Cell(),
Local() );
397 auto min = getBound( owned_space, -1, off_ijk, -halo_width, 0 );
398 auto max = getBound( owned_space, 1, off_ijk, 0, halo_width );
407template <
class MeshType>
408auto LocalGrid<MeshType>::boundaryIndexSpaceImpl(
409 Own,
Cell,
const std::array<int, num_space_dim>& off_ijk,
412 return sharedIndexSpaceImpl(
Own(),
Cell(), off_ijk, halo_width );
419template <
class MeshType>
420auto LocalGrid<MeshType>::boundaryIndexSpaceImpl(
421 Ghost,
Cell,
const std::array<int, num_space_dim>& off_ijk,
424 return sharedIndexSpaceImpl(
Ghost(),
Cell(), off_ijk, halo_width );
429template <
class MeshType>
430auto LocalGrid<MeshType>::indexSpaceImpl(
Own,
Node,
Local )
const
434 std::array<long, num_space_dim> min;
435 for ( std::size_t d = 0; d < num_space_dim; ++d )
436 min[d] = _halo_cell_width;
440 std::array<long, num_space_dim> max;
441 for ( std::size_t d = 0; d < num_space_dim; ++d )
442 max[d] = ( _global_grid->isPeriodic( d ) ||
443 _global_grid->dimBlockId( d ) <
444 _global_grid->dimNumBlock( d ) - 1 )
445 ? min[d] + _global_grid->ownedNumCell( d )
446 : min[d] + _global_grid->ownedNumCell( d ) + 1;
453template <
class MeshType>
454auto LocalGrid<MeshType>::indexSpaceImpl(
Ghost,
Node,
Local )
const
458 std::array<long, num_space_dim>
size;
459 for ( std::size_t d = 0; d < num_space_dim; ++d )
461 size[d] = totalNumCell( d ) + 1;
469template <
class MeshType>
470auto LocalGrid<MeshType>::indexSpaceImpl(
Own t1,
Node t2,
Global )
const
473 return globalIndexSpace( t1, t2 );
479template <
class MeshType>
480auto LocalGrid<MeshType>::sharedIndexSpaceImpl(
481 Own,
Node,
const std::array<int, num_space_dim>& off_ijk,
485 auto owned_space = indexSpaceImpl(
Own(),
Node(),
Local() );
487 auto min = getBound( owned_space, -1, off_ijk, 0, -halo_width );
488 auto max = getBound( owned_space, 1, off_ijk, halo_width + 1, 0 );
497template <
class MeshType>
498auto LocalGrid<MeshType>::sharedIndexSpaceImpl(
499 Ghost,
Node,
const std::array<int, num_space_dim>& off_ijk,
503 auto owned_space = indexSpaceImpl(
Own(),
Node(),
Local() );
505 auto min = getBound( owned_space, -1, off_ijk, -halo_width, 0 );
506 auto max = getBound( owned_space, 1, off_ijk, 0, halo_width + 1 );
515template <
class MeshType>
516auto LocalGrid<MeshType>::boundaryIndexSpaceImpl(
517 Own,
Node,
const std::array<int, num_space_dim>& off_ijk,
521 auto owned_space = indexSpaceImpl(
Own(),
Node(),
Local() );
523 auto min = getBound( owned_space, -1, off_ijk, 0, -halo_width - 1 );
524 auto max = getBound( owned_space, 1, off_ijk, halo_width + 1, 0 );
533template <
class MeshType>
534auto LocalGrid<MeshType>::boundaryIndexSpaceImpl(
535 Ghost,
Node,
const std::array<int, num_space_dim>& off_ijk,
539 auto owned_space = indexSpaceImpl(
Own(),
Node(),
Local() );
541 auto min = getBound( owned_space, -1, off_ijk, -halo_width, 0 );
542 auto max = getBound( owned_space, 1, off_ijk, 0, halo_width );
548template <
class MeshType>
553 return faceIndexSpace( t1, t2, t3 );
557template <
class MeshType>
562 return faceIndexSpace( t1, t2, t3 );
566template <
class MeshType>
571 return faceIndexSpace( t1, t2, t3 );
575template <
class MeshType>
576auto LocalGrid<MeshType>::sharedIndexSpaceImpl(
577 Own t1,
Face<Dim::I> t2,
const std::array<int, num_space_dim>& off_ijk,
580 return faceSharedIndexSpace( t1, t2, off_ijk, halo_width );
584template <
class MeshType>
585auto LocalGrid<MeshType>::sharedIndexSpaceImpl(
589 return faceSharedIndexSpace( t1, t2, off_ijk, halo_width );
593template <
class MeshType>
594auto LocalGrid<MeshType>::boundaryIndexSpaceImpl(
595 Own t1,
Face<Dim::I> t2,
const std::array<int, num_space_dim>& off_ijk,
598 return faceBoundaryIndexSpace( t1, t2, off_ijk, halo_width );
602template <
class MeshType>
603auto LocalGrid<MeshType>::boundaryIndexSpaceImpl(
607 return faceBoundaryIndexSpace( t1, t2, off_ijk, halo_width );
611template <
class MeshType>
616 return faceIndexSpace( t1, t2, t3 );
620template <
class MeshType>
625 return faceIndexSpace( t1, t2, t3 );
629template <
class MeshType>
634 return faceIndexSpace( t1, t2, t3 );
638template <
class MeshType>
639auto LocalGrid<MeshType>::sharedIndexSpaceImpl(
640 Own t1,
Face<Dim::J> t2,
const std::array<int, num_space_dim>& off_ijk,
643 return faceSharedIndexSpace( t1, t2, off_ijk, halo_width );
647template <
class MeshType>
648auto LocalGrid<MeshType>::sharedIndexSpaceImpl(
652 return faceSharedIndexSpace( t1, t2, off_ijk, halo_width );
656template <
class MeshType>
657auto LocalGrid<MeshType>::boundaryIndexSpaceImpl(
658 Own t1,
Face<Dim::J> t2,
const std::array<int, num_space_dim>& off_ijk,
661 return faceBoundaryIndexSpace( t1, t2, off_ijk, halo_width );
665template <
class MeshType>
666auto LocalGrid<MeshType>::boundaryIndexSpaceImpl(
670 return faceBoundaryIndexSpace( t1, t2, off_ijk, halo_width );
674template <
class MeshType>
675template <std::
size_t NSD>
676std::enable_if_t<3 == NSD, IndexSpace<3>>
679 return faceIndexSpace( t1, t2, t3 );
683template <
class MeshType>
684template <std::
size_t NSD>
685std::enable_if_t<3 == NSD, IndexSpace<3>>
688 return faceIndexSpace( t1, t2, t3 );
692template <
class MeshType>
693template <std::
size_t NSD>
694std::enable_if_t<3 == NSD, IndexSpace<3>>
697 return faceIndexSpace( t1, t2, t3 );
701template <
class MeshType>
702template <std::
size_t NSD>
703std::enable_if_t<3 == NSD, IndexSpace<3>>
705 const std::array<int, 3>& off_ijk,
706 const int halo_width )
const
708 return faceSharedIndexSpace( t1, t2, off_ijk, halo_width );
712template <
class MeshType>
713template <std::
size_t NSD>
714std::enable_if_t<3 == NSD, IndexSpace<3>>
716 const std::array<int, 3>& off_ijk,
717 const int halo_width )
const
719 return faceSharedIndexSpace( t1, t2, off_ijk, halo_width );
723template <
class MeshType>
724template <std::
size_t NSD>
725std::enable_if_t<3 == NSD, IndexSpace<3>>
727 const std::array<int, 3>& off_ijk,
728 const int halo_width )
const
730 return faceBoundaryIndexSpace( t1, t2, off_ijk, halo_width );
734template <
class MeshType>
735template <std::
size_t NSD>
736std::enable_if_t<3 == NSD, IndexSpace<3>>
738 const std::array<int, 3>& off_ijk,
739 const int halo_width )
const
741 return faceBoundaryIndexSpace( t1, t2, off_ijk, halo_width );
745template <
class MeshType>
746template <std::
size_t NSD>
747std::enable_if_t<3 == NSD, IndexSpace<3>>
750 return edgeIndexSpace( t1, t2, t3 );
754template <
class MeshType>
755template <std::
size_t NSD>
756std::enable_if_t<3 == NSD, IndexSpace<3>>
759 return edgeIndexSpace( t1, t2, t3 );
763template <
class MeshType>
764template <std::
size_t NSD>
765std::enable_if_t<3 == NSD, IndexSpace<3>>
768 return edgeIndexSpace( t1, t2, t3 );
772template <
class MeshType>
773template <std::
size_t NSD>
774std::enable_if_t<3 == NSD, IndexSpace<3>>
776 const std::array<int, 3>& off_ijk,
777 const int halo_width )
const
779 return edgeSharedIndexSpace( t1, t2, off_ijk, halo_width );
783template <
class MeshType>
784template <std::
size_t NSD>
785std::enable_if_t<3 == NSD, IndexSpace<3>>
787 const std::array<int, 3>& off_ijk,
788 const int halo_width )
const
790 return edgeSharedIndexSpace( t1, t2, off_ijk, halo_width );
794template <
class MeshType>
795template <std::
size_t NSD>
796std::enable_if_t<3 == NSD, IndexSpace<3>>
798 const std::array<int, 3>& off_ijk,
799 const int halo_width )
const
801 return edgeBoundaryIndexSpace( t1, t2, off_ijk, halo_width );
805template <
class MeshType>
806template <std::
size_t NSD>
807std::enable_if_t<3 == NSD, IndexSpace<3>>
809 const std::array<int, 3>& off_ijk,
810 const int halo_width )
const
812 return edgeBoundaryIndexSpace( t1, t2, off_ijk, halo_width );
816template <
class MeshType>
817template <std::
size_t NSD>
818std::enable_if_t<3 == NSD, IndexSpace<3>>
821 return edgeIndexSpace( t1, t2, t3 );
825template <
class MeshType>
826template <std::
size_t NSD>
827std::enable_if_t<3 == NSD, IndexSpace<3>>
830 return edgeIndexSpace( t1, t2, t3 );
834template <
class MeshType>
835template <std::
size_t NSD>
836std::enable_if_t<3 == NSD, IndexSpace<3>>
839 return edgeIndexSpace( t1, t2, t3 );
843template <
class MeshType>
844template <std::
size_t NSD>
845std::enable_if_t<3 == NSD, IndexSpace<3>>
847 const std::array<int, 3>& off_ijk,
848 const int halo_width )
const
850 return edgeSharedIndexSpace( t1, t2, off_ijk, halo_width );
854template <
class MeshType>
855template <std::
size_t NSD>
856std::enable_if_t<3 == NSD, IndexSpace<3>>
858 const std::array<int, 3>& off_ijk,
859 const int halo_width )
const
861 return edgeSharedIndexSpace( t1, t2, off_ijk, halo_width );
865template <
class MeshType>
866template <std::
size_t NSD>
867std::enable_if_t<3 == NSD, IndexSpace<3>>
869 const std::array<int, 3>& off_ijk,
870 const int halo_width )
const
872 return edgeBoundaryIndexSpace( t1, t2, off_ijk, halo_width );
876template <
class MeshType>
877template <std::
size_t NSD>
878std::enable_if_t<3 == NSD, IndexSpace<3>>
880 const std::array<int, 3>& off_ijk,
881 const int halo_width )
const
883 return edgeBoundaryIndexSpace( t1, t2, off_ijk, halo_width );
886template <
class MeshType>
887template <std::
size_t NSD>
888std::enable_if_t<3 == NSD, IndexSpace<3>>
891 return edgeIndexSpace( t1, t2, t3 );
895template <
class MeshType>
896template <std::
size_t NSD>
897std::enable_if_t<3 == NSD, IndexSpace<3>>
900 return edgeIndexSpace( t1, t2, t3 );
904template <
class MeshType>
905template <std::
size_t NSD>
906std::enable_if_t<3 == NSD, IndexSpace<3>>
909 return edgeIndexSpace( t1, t2, t3 );
913template <
class MeshType>
914template <std::
size_t NSD>
915std::enable_if_t<3 == NSD, IndexSpace<3>>
917 const std::array<int, 3>& off_ijk,
918 const int halo_width )
const
920 return edgeSharedIndexSpace( t1, t2, off_ijk, halo_width );
924template <
class MeshType>
925template <std::
size_t NSD>
926std::enable_if_t<3 == NSD, IndexSpace<3>>
928 const std::array<int, 3>& off_ijk,
929 const int halo_width )
const
931 return edgeSharedIndexSpace( t1, t2, off_ijk, halo_width );
935template <
class MeshType>
936template <std::
size_t NSD>
937std::enable_if_t<3 == NSD, IndexSpace<3>>
939 const std::array<int, 3>& off_ijk,
940 const int halo_width )
const
942 return edgeBoundaryIndexSpace( t1, t2, off_ijk, halo_width );
946template <
class MeshType>
947template <std::
size_t NSD>
948std::enable_if_t<3 == NSD, IndexSpace<3>>
950 const std::array<int, 3>& off_ijk,
951 const int halo_width )
const
953 return edgeBoundaryIndexSpace( t1, t2, off_ijk, halo_width );
958template <
class MeshType>
959template <
class EntityType>
960auto LocalGrid<MeshType>::globalIndexSpace(
Own, EntityType )
const
963 auto local_space = indexSpaceImpl(
Own(), EntityType(),
Local() );
964 std::array<long, num_space_dim> min;
965 std::array<long, num_space_dim> max;
966 for ( std::size_t d = 0; d < num_space_dim; ++d )
968 min[d] = _global_grid->globalOffset( d );
969 max[d] = min[d] + local_space.extent( d );
977template <
class MeshType>
982 static_assert( Dir < num_space_dim,
"Spatial dimension out of bounds" );
985 std::array<long, num_space_dim> min;
986 for ( std::size_t d = 0; d < num_space_dim; ++d )
987 min[d] = _halo_cell_width;
990 std::array<long, num_space_dim> max;
991 for ( std::size_t d = 0; d < num_space_dim; ++d )
995 max[d] = ( _global_grid->isPeriodic( d ) ||
996 _global_grid->dimBlockId( d ) <
997 _global_grid->dimNumBlock( d ) - 1 )
998 ? min[d] + _global_grid->ownedNumCell( d )
999 : min[d] + _global_grid->ownedNumCell( d ) + 1;
1003 max[d] = min[d] + _global_grid->ownedNumCell( d );
1012template <
class MeshType>
1017 static_assert( Dir < num_space_dim,
"Spatial dimension out of bounds" );
1020 std::array<long, num_space_dim>
size;
1021 for ( std::size_t d = 0; d < num_space_dim; ++d )
1025 size[d] = totalNumCell( d ) + 1;
1029 size[d] = totalNumCell( d );
1038template <
class MeshType>
1043 static_assert( Dir < num_space_dim,
"Spatial dimension out of bounds" );
1044 return globalIndexSpace( t1, t2 );
1051template <
class MeshType>
1053auto LocalGrid<MeshType>::faceSharedIndexSpace(
1054 Own,
Face<Dir>,
const std::array<int, num_space_dim>& off_ijk,
1057 static_assert( Dir < num_space_dim,
"Spatial dimension out of bounds" );
1062 auto min = getBound( owned_space, -1, off_ijk, 0, -halo_width );
1063 auto max = getBound<Dir>( owned_space, 1, off_ijk, halo_width + 1,
1073template <
class MeshType>
1075auto LocalGrid<MeshType>::faceSharedIndexSpace(
1079 static_assert( Dir < num_space_dim,
"Spatial dimension out of bounds" );
1084 auto min = getBound( owned_space, -1, off_ijk, -halo_width, 0 );
1085 auto max = getBound<Dir>( owned_space, 1, off_ijk, 0, 0, halo_width + 1,
1095template <
class MeshType>
1097auto LocalGrid<MeshType>::faceBoundaryIndexSpace(
1098 Own,
Face<Dir>,
const std::array<int, num_space_dim>& off_ijk,
1101 static_assert( Dir < num_space_dim,
"Spatial dimension out of bounds" );
1106 auto min = getBound<Dir>( owned_space, -1, off_ijk, 0, 0, -halo_width - 1,
1108 auto max = getBound<Dir>( owned_space, 1, off_ijk, halo_width + 1,
1118template <
class MeshType>
1120auto LocalGrid<MeshType>::faceBoundaryIndexSpace(
1124 static_assert( Dir < num_space_dim,
"Spatial dimension out of bounds" );
1129 auto min = getBound( owned_space, -1, off_ijk, -halo_width, 0 );
1130 auto max = getBound( owned_space, 1, off_ijk, 0, halo_width );
1136template <
class MeshType>
1137template <
int Dir, std::
size_t NSD>
1138std::enable_if_t<3 == NSD, IndexSpace<3>>
1142 std::array<long, 3> min;
1143 for ( std::size_t d = 0; d < 3; ++d )
1144 min[d] = _halo_cell_width;
1147 std::array<long, 3> max;
1148 for ( std::size_t d = 0; d < 3; ++d )
1152 max[d] = min[d] + _global_grid->ownedNumCell( d );
1156 max[d] = ( _global_grid->isPeriodic( d ) ||
1157 _global_grid->dimBlockId( d ) <
1158 _global_grid->dimNumBlock( d ) - 1 )
1159 ? min[d] + _global_grid->ownedNumCell( d )
1160 : min[d] + _global_grid->ownedNumCell( d ) + 1;
1169template <
class MeshType>
1170template <
int Dir, std::
size_t NSD>
1171std::enable_if_t<3 == NSD, IndexSpace<3>>
1175 std::array<long, 3>
size;
1176 for ( std::size_t d = 0; d < 3; ++d )
1180 size[d] = totalNumCell( d );
1184 size[d] = totalNumCell( d ) + 1;
1193template <
class MeshType>
1194template <
int Dir, std::
size_t NSD>
1195std::enable_if_t<3 == NSD, IndexSpace<3>>
1198 return globalIndexSpace( t1, t2 );
1205template <
class MeshType>
1206template <
int Dir, std::
size_t NSD>
1207std::enable_if_t<3 == NSD, IndexSpace<3>>
1208LocalGrid<MeshType>::edgeSharedIndexSpace(
Own,
Edge<Dir>,
1209 const std::array<int, 3>& off_ijk,
1210 const int halo_width )
const
1215 auto min = getBound( owned_space, -1, off_ijk, 0, -halo_width );
1216 auto max = getBound<Dir>( owned_space, 1, off_ijk, halo_width,
1217 halo_width + 1, 0, 0 );
1226template <
class MeshType>
1227template <
int Dir, std::
size_t NSD>
1228std::enable_if_t<3 == NSD, IndexSpace<3>>
1230 const std::array<int, 3>& off_ijk,
1231 const int halo_width )
const
1236 auto min = getBound( owned_space, -1, off_ijk, -halo_width, 0 );
1237 auto max = getBound<Dir>( owned_space, 1, off_ijk, 0, 0, halo_width,
1247template <
class MeshType>
1248template <
int Dir, std::
size_t NSD>
1249std::enable_if_t<3 == NSD, IndexSpace<3>>
1250LocalGrid<MeshType>::edgeBoundaryIndexSpace(
Own,
Edge<Dir>,
1251 const std::array<int, 3>& off_ijk,
1252 const int halo_width )
const
1257 auto min = getBound<Dir>( owned_space, -1, off_ijk, 0, 0, -halo_width,
1259 auto max = getBound<Dir>( owned_space, 1, off_ijk, halo_width,
1260 halo_width + 1, 0, 0 );
1269template <
class MeshType>
1270template <
int Dir, std::
size_t NSD>
1271std::enable_if_t<3 == NSD, IndexSpace<3>>
1273 const std::array<int, 3>& off_ijk,
1274 const int halo_width )
const
1279 auto min = getBound( owned_space, -1, off_ijk, -halo_width, 0 );
1280 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