@@ -423,7 +423,7 @@ Level::buildCellFlag ()
423423}
424424
425425void
426- Level::fillEBCellFlag (FabArray<EBCellFlagFab>& cellflag, const Geometry& geom) const
426+ Level::fillEBCellFlag (FabArray<EBCellFlagFab>& cellflag, const Geometry& /* geom*/ ) const
427427{
428428 if (isAllRegular ()) {
429429 cellflag.setVal (EBCellFlag::TheDefaultCell ());
@@ -436,10 +436,13 @@ Level::fillEBCellFlag (FabArray<EBCellFlagFab>& cellflag, const Geometry& geom)
436436 }
437437
438438 const int ng = cellflag.nGrow ();
439+ cellflag.ParallelCopy (m_cellflag,0 ,0 ,1 ,IntVect (0 ),IntVect (ng),-m_shift,
440+ m_geom.periodicity ());
439441
440- cellflag.ParallelCopy (m_cellflag,0 ,0 ,1 ,0 ,ng,geom.periodicity ());
441-
442- const std::vector<IntVect>& pshifts = geom.periodicity ().shiftIntVect ();
442+ std::vector<IntVect> pshifts = m_geom.periodicity ().shiftIntVect ();
443+ if (m_shift != 0 ) {
444+ for (auto & pit : pshifts) { pit += m_shift; }
445+ }
443446
444447 auto cov_val = EBCellFlag::TheCoveredCell ();
445448#ifdef AMREX_USE_OMP
@@ -474,14 +477,18 @@ Level::fillEBCellFlag (FabArray<EBCellFlagFab>& cellflag, const Geometry& geom)
474477}
475478
476479void
477- Level::fillVolFrac (MultiFab& vfrac, const Geometry& geom) const
480+ Level::fillVolFrac (MultiFab& vfrac, const Geometry& /* geom*/ ) const
478481{
479482 vfrac.setVal (1.0 );
480483 if (isAllRegular ()) { return ; }
481484
482- vfrac.ParallelCopy (m_volfrac,0 ,0 ,1 ,0 ,vfrac.nGrow (),geom.periodicity ());
485+ vfrac.ParallelCopy (m_volfrac,0 ,0 ,1 ,IntVect (0 ),vfrac.nGrowVect (),-m_shift,
486+ m_geom.periodicity ());
483487
484- const std::vector<IntVect>& pshifts = geom.periodicity ().shiftIntVect ();
488+ std::vector<IntVect> pshifts = m_geom.periodicity ().shiftIntVect ();
489+ if (m_shift != 0 ) {
490+ for (auto & pit : pshifts) { pit += m_shift; }
491+ }
485492
486493#ifdef AMREX_USE_OMP
487494#pragma omp parallel if (Gpu::notInLaunchRegion())
@@ -545,12 +552,12 @@ Level::fillCentroid (MultiCutFab& centroid, const Geometry& geom) const
545552}
546553
547554void
548- Level::fillCentroid (MultiFab& centroid, const Geometry& geom) const
555+ Level::fillCentroid (MultiFab& centroid, const Geometry& /* geom*/ ) const
549556{
550557 centroid.setVal (0.0 );
551558 if (!isAllRegular ()) {
552- centroid.ParallelCopy (m_centroid,0 ,0 ,AMREX_SPACEDIM,0 ,centroid.nGrow (),
553- geom .periodicity ());
559+ centroid.ParallelCopy (m_centroid,0 ,0 ,AMREX_SPACEDIM,IntVect ( 0 ) ,centroid.nGrowVect (),
560+ -m_shift, m_geom .periodicity ());
554561 }
555562}
556563
@@ -569,11 +576,12 @@ Level::fillBndryArea (MultiCutFab& bndryarea, const Geometry& geom) const
569576}
570577
571578void
572- Level::fillBndryArea ( MultiFab& bndryarea, const Geometry& geom) const
579+ Level::fillBndryArea ( MultiFab& bndryarea, const Geometry& /* geom*/ ) const
573580{
574581 bndryarea.setVal (0.0 );
575582 if (!isAllRegular ()) {
576- bndryarea.ParallelCopy (m_bndryarea,0 ,0 ,1 ,0 ,bndryarea.nGrow (),geom.periodicity ());
583+ bndryarea.ParallelCopy (m_bndryarea,0 ,0 ,1 ,IntVect (0 ),bndryarea.nGrowVect (),
584+ -m_shift, m_geom.periodicity ());
577585 }
578586}
579587
@@ -592,12 +600,12 @@ Level::fillBndryCent (MultiCutFab& bndrycent, const Geometry& geom) const
592600}
593601
594602void
595- Level::fillBndryCent (MultiFab& bndrycent, const Geometry& geom) const
603+ Level::fillBndryCent (MultiFab& bndrycent, const Geometry& /* geom*/ ) const
596604{
597605 bndrycent.setVal (-1.0 );
598606 if (!isAllRegular ()) {
599- bndrycent.ParallelCopy (m_bndrycent,0 ,0 ,bndrycent.nComp (),0 ,bndrycent. nGrow ( ),
600- geom .periodicity ());
607+ bndrycent.ParallelCopy (m_bndrycent,0 ,0 ,bndrycent.nComp (),IntVect ( 0 ),
608+ bndrycent. nGrowVect (), -m_shift, m_geom .periodicity ());
601609 }
602610}
603611
@@ -616,17 +624,18 @@ Level::fillBndryNorm (MultiCutFab& bndrynorm, const Geometry& geom) const
616624}
617625
618626void
619- Level::fillBndryNorm ( MultiFab& bndrynorm, const Geometry& geom) const
627+ Level::fillBndryNorm ( MultiFab& bndrynorm, const Geometry& /* geom*/ ) const
620628{
621629 bndrynorm.setVal (0.0 );
622630 if (!isAllRegular ()) {
623- bndrynorm.ParallelCopy (m_bndrynorm,0 ,0 ,bndrynorm.nComp (),0 ,bndrynorm. nGrow ( ),
624- geom .periodicity ());
631+ bndrynorm.ParallelCopy (m_bndrynorm,0 ,0 ,bndrynorm.nComp (),IntVect ( 0 ),
632+ bndrynorm. nGrowVect (), -m_shift, m_geom .periodicity ());
625633 }
626634}
627635
628636void
629- Level::fillAreaFrac (Array<MultiCutFab*,AMREX_SPACEDIM> const & a_areafrac, const Geometry& geom) const
637+ Level::fillAreaFrac (Array<MultiCutFab*,AMREX_SPACEDIM> const & a_areafrac,
638+ const Geometry& /* geom*/ ) const
630639{
631640 if (isAllRegular ()) {
632641 for (int idim = 0 ; idim < AMREX_SPACEDIM; ++idim) {
@@ -642,11 +651,14 @@ Level::fillAreaFrac (Array<MultiCutFab*,AMREX_SPACEDIM> const& a_areafrac, const
642651 areafrac.nComp (), areafrac.nGrow ());
643652 tmp.setVal (1.0 );
644653 tmp.ParallelCopy (m_areafrac[idim],0 ,0 ,areafrac.nComp (),
645- 0 ,areafrac. nGrow (),geom .periodicity ());
654+ IntVect ( 0 ),tmp. nGrowVect (), -m_shift, m_geom .periodicity ());
646655 copyMultiFabToMultiCutFab (areafrac, tmp);
647656 }
648657
649- const std::vector<IntVect>& pshifts = geom.periodicity ().shiftIntVect ();
658+ std::vector<IntVect> pshifts = m_geom.periodicity ().shiftIntVect ();
659+ if (m_shift != 0 ) {
660+ for (auto & pit : pshifts) { pit += m_shift; }
661+ }
650662
651663#ifdef AMREX_USE_OMP
652664#pragma omp parallel if (Gpu::notInLaunchRegion())
@@ -703,7 +715,8 @@ Level::fillAreaFrac (Array<MultiCutFab*,AMREX_SPACEDIM> const& a_areafrac, const
703715}
704716
705717void
706- Level::fillAreaFrac (Array<MultiFab*,AMREX_SPACEDIM> const & a_areafrac, const Geometry& geom) const
718+ Level::fillAreaFrac (Array<MultiFab*,AMREX_SPACEDIM> const & a_areafrac,
719+ const Geometry& /* geom*/ ) const
707720{
708721 for (int idim = 0 ; idim < AMREX_SPACEDIM; ++idim) {
709722 a_areafrac[idim]->setVal (1.0 );
@@ -715,10 +728,13 @@ Level::fillAreaFrac (Array<MultiFab*,AMREX_SPACEDIM> const& a_areafrac, const Ge
715728 {
716729 auto & areafrac = *a_areafrac[idim];
717730 areafrac.ParallelCopy (m_areafrac[idim],0 ,0 ,areafrac.nComp (),
718- 0 ,areafrac.nGrow (),geom .periodicity ());
731+ IntVect ( 0 ) ,areafrac.nGrowVect (),-m_shift,m_geom .periodicity ());
719732 }
720733
721- const std::vector<IntVect>& pshifts = geom.periodicity ().shiftIntVect ();
734+ std::vector<IntVect> pshifts = m_geom.periodicity ().shiftIntVect ();
735+ if (m_shift != 0 ) {
736+ for (auto & pit : pshifts) { pit += m_shift; }
737+ }
722738
723739#ifdef AMREX_USE_OMP
724740#pragma omp parallel if (Gpu::notInLaunchRegion())
@@ -772,7 +788,8 @@ Level::fillAreaFrac (Array<MultiFab*,AMREX_SPACEDIM> const& a_areafrac, const Ge
772788}
773789
774790void
775- Level::fillFaceCent (Array<MultiCutFab*,AMREX_SPACEDIM> const & a_facecent, const Geometry& geom) const
791+ Level::fillFaceCent (Array<MultiCutFab*,AMREX_SPACEDIM> const & a_facecent,
792+ const Geometry& /* geom*/ ) const
776793{
777794 if (isAllRegular ()) {
778795 for (int idim = 0 ; idim < AMREX_SPACEDIM; ++idim) {
@@ -788,13 +805,14 @@ Level::fillFaceCent (Array<MultiCutFab*,AMREX_SPACEDIM> const& a_facecent, const
788805 facecent.nComp (), facecent.nGrow ());
789806 tmp.setVal (0.0 );
790807 tmp.ParallelCopy (m_facecent[idim],0 ,0 ,facecent.nComp (),
791- 0 ,facecent. nGrow (),geom .periodicity ());
808+ IntVect ( 0 ),tmp. nGrowVect (),-m_shift,m_geom .periodicity ());
792809 copyMultiFabToMultiCutFab (facecent,tmp);
793810 }
794811}
795812
796813void
797- Level::fillFaceCent (Array<MultiFab*,AMREX_SPACEDIM> const & a_facecent, const Geometry& geom) const
814+ Level::fillFaceCent (Array<MultiFab*,AMREX_SPACEDIM> const & a_facecent,
815+ const Geometry& /* geom*/ ) const
798816{
799817 for (int idim = 0 ; idim < AMREX_SPACEDIM; ++idim) {
800818 a_facecent[idim]->setVal (0.0 );
@@ -804,7 +822,8 @@ Level::fillFaceCent (Array<MultiFab*,AMREX_SPACEDIM> const& a_facecent, const Ge
804822 {
805823 auto & facecent = *a_facecent[idim];
806824 a_facecent[idim]->ParallelCopy (m_facecent[idim],0 ,0 ,facecent.nComp (),
807- 0 ,facecent.nGrow (),geom.periodicity ());
825+ IntVect (0 ),facecent.nGrowVect (),
826+ -m_shift, m_geom.periodicity ());
808827 }
809828 }
810829}
@@ -834,7 +853,8 @@ Level::fillEdgeCent (Array<MultiCutFab*,AMREX_SPACEDIM> const& a_edgecent, const
834853}
835854
836855void
837- Level::fillEdgeCent (Array<MultiFab*,AMREX_SPACEDIM> const & a_edgecent, const Geometry& geom) const
856+ Level::fillEdgeCent (Array<MultiFab*,AMREX_SPACEDIM> const & a_edgecent,
857+ const Geometry& /* geom*/ ) const
838858{
839859 for (int idim = 0 ; idim < AMREX_SPACEDIM; ++idim) {
840860 a_edgecent[idim]->setVal (1.0 );
@@ -844,14 +864,18 @@ Level::fillEdgeCent (Array<MultiFab*,AMREX_SPACEDIM> const& a_edgecent, const Ge
844864 {
845865 auto & edgecent = *a_edgecent[idim];
846866 a_edgecent[idim]->ParallelCopy (m_edgecent[idim],0 ,0 ,edgecent.nComp (),
847- 0 ,edgecent.nGrow (),geom.periodicity ());
867+ IntVect (0 ),edgecent.nGrowVect (),
868+ -m_shift,m_geom.periodicity ());
848869
849870#ifdef AMREX_USE_OMP
850871#pragma omp parallel if (Gpu::notInLaunchRegion())
851872#endif
852873 if (!m_covered_grids.empty ())
853874 {
854- const std::vector<IntVect>& pshifts = geom.periodicity ().shiftIntVect ();
875+ std::vector<IntVect> pshifts = m_geom.periodicity ().shiftIntVect ();
876+ if (m_shift != 0 ) {
877+ for (auto & pit : pshifts) { pit += m_shift; }
878+ }
855879 BoxArray const & covered_edge_grids = amrex::convert (m_covered_grids,
856880 edgecent.ixType ());
857881 std::vector<std::pair<int ,Box> > isects;
@@ -877,12 +901,16 @@ Level::fillEdgeCent (Array<MultiFab*,AMREX_SPACEDIM> const& a_edgecent, const Ge
877901}
878902
879903void
880- Level::fillLevelSet (MultiFab& levelset, const Geometry& geom) const
904+ Level::fillLevelSet (MultiFab& levelset, const Geometry& /* geom*/ ) const
881905{
882906 levelset.setVal (-1.0 );
883- levelset.ParallelCopy (m_levelset,0 ,0 ,1 ,IntVect (0 ),levelset.nGrowVect (),geom.periodicity ());
907+ levelset.ParallelCopy (m_levelset,0 ,0 ,1 ,IntVect (0 ),levelset.nGrowVect (),
908+ -m_shift, m_geom.periodicity ());
884909
885- const std::vector<IntVect>& pshifts = geom.periodicity ().shiftIntVect ();
910+ std::vector<IntVect> pshifts = m_geom.periodicity ().shiftIntVect ();
911+ if (m_shift != 0 ) {
912+ for (auto & pit : pshifts) { pit += m_shift; }
913+ }
886914
887915 Real cov_val = 1.0 ; // for covered cells
888916
@@ -916,7 +944,8 @@ Level::fillCutCellMask (iMultiFab& cutcellmask, const Geometry&) const
916944{
917945 if (!m_has_eb_info) {
918946 cutcellmask.setVal (0 );
919- cutcellmask.ParallelCopy (m_cutcellmask);
947+ cutcellmask.ParallelCopy (m_cutcellmask,0 ,0 ,1 ,IntVect (0 ),IntVect (0 ),-m_shift,
948+ m_geom.periodicity ());
920949 }
921950}
922951
@@ -1011,4 +1040,19 @@ Level::buildCutCellMask (Level const& fine_level)
10111040 }
10121041}
10131042
1043+ void
1044+ Level::setShift (int direction, int ncells)
1045+ {
1046+ if (direction < 0 || direction >= AMREX_SPACEDIM) { return ; }
1047+
1048+ if (m_geom.isPeriodic (direction)) {
1049+ auto len = m_geom.Domain ().length (direction);
1050+ ncells = ncells % len;
1051+ if (ncells < 0 ) { ncells += len; }
1052+ if (2 *ncells > len) { ncells -= len; }
1053+ }
1054+
1055+ m_shift[direction] = ncells;
1056+ }
1057+
10141058}
0 commit comments