lib/src/AMRTools/TensorCFInterp.cpp
/***********************/
//  apply coarse-fine boundary conditions -- assume that phi grids
//  are grown by one
/***********************/
apply coarse-fine boundary conditions -- assume that phi grids
are grown by one
apply coarse - fine boundary conditions -- assume that phi grids are grown by one
void
TensorCFInterp::coarseFineInterp(LevelData<FArrayBox>& a_phif,
                                 LevelData<FArrayBox>& a_gradf,
                                 const LevelData<FArrayBox>& a_phic)
{
  CH_assert(isDefined());
  CH_assert(a_phif.nComp() == m_nComp);
  CH_assert(a_phic.nComp() == m_nComp);
  CH_assert(a_phif.ghostVect() >= IntVect::Unit);
  CH_assert(a_phic.boxLayout() == m_inputCoarLayout);
  CH_assert(a_phif.boxLayout() == m_inputFineLayout);
  Interval variables = a_phic.interval();
  if (m_level > 0)
    {
      LevelData<FArrayBox>& phif = (LevelData<FArrayBox>&)(a_phif);
      LevelData<FArrayBox>& phic = (LevelData<FArrayBox>&)(a_phic);
      phif.exchange();
      phic.exchange();
      Interval interv(0, m_nComp-1);
      a_phic.copyTo(interv, m_coarsenedFineBuffer, interv);
      DataIterator ditFine = a_phif.dataIterator();
      for (ditFine.begin(); ditFine.ok(); ++ditFine)
        {
          DataIndex datIndGlo =ditFine();
          BaseFab<Real> & phif = a_phif[datIndGlo];
          BaseFab<Real> & gradf = a_gradf[datIndGlo];
          BaseFab<Real> gradStar[SpaceDim][2];
          for (int idir=0; idir<SpaceDim; idir++)
            {
              {
                const BaseFab<Real> & loPhiC = m_coarsenedFineBuffer[datIndGlo];
                const QuadCFStencil& loQCFS = m_loQCFS[idir][datIndGlo];
                BaseFab<Real>& thisGradStar = gradStar[idir][0];
                coarseFineInterp(phif, gradf, thisGradStar, loPhiC,loQCFS,
                                 Side::Lo, idir, variables);
              }
              {
                const BaseFab<Real> & hiPhiC = m_coarsenedFineBuffer[datIndGlo];
                const QuadCFStencil& hiQCFS = m_hiQCFS[idir][datIndGlo];
                BaseFab<Real>& thisGradStar = gradStar[idir][1];
                coarseFineInterp(phif, gradf, thisGradStar, hiPhiC, hiQCFS,
                                 Side::Hi, idir, variables);
              }
            } 
          BaseFab<Real> & tanGrad = a_gradf[ditFine()];
          for (int idir=0; idir<SpaceDim; idir++)
            {
              BaseFab<Real>& thisGradStarLo = gradStar[idir][0];
              const QuadCFStencil& loQCFS = m_loQCFS[idir][datIndGlo];
              const TensorFineStencilSet& loTFSS
                = m_loFineStencilSets[idir][datIndGlo];
              computeTanGrad(tanGrad, phif, thisGradStarLo,
                             loTFSS, loQCFS, Side::Lo, idir, variables);
              BaseFab<Real>& thisGradStarHi = gradStar[idir][1];
              const QuadCFStencil& hiQCFS = m_hiQCFS[idir][datIndGlo];
              const TensorFineStencilSet& hiTFSS
                = m_hiFineStencilSets[idir][datIndGlo];
              computeTanGrad(tanGrad, phif, thisGradStarHi,
                             hiTFSS, hiQCFS,Side::Hi, idir, variables);
            }
        }
    }
}
void TensorCFInterp :: coarseFineInterp ( LevelData < FArrayBox > & a_phif , LevelData < FArrayBox > & a_gradf , const LevelData < FArrayBox > & a_phic ) { CH_assert ( isDefined ( ) ) ; CH_assert ( a_phif . nComp ( ) == m_nComp ) ; CH_assert ( a_phic . nComp ( ) == m_nComp ) ; CH_assert ( a_phif . ghostVect ( ) >= IntVect :: Unit ) ; CH_assert ( a_phic . boxLayout ( ) == m_inputCoarLayout ) ; CH_assert ( a_phif . boxLayout ( ) == m_inputFineLayout ) ; Interval variables = a_phic . interval ( ) ; if ( m_level > 0 ) { LevelData < FArrayBox > & phif = ( LevelData < FArrayBox > & ) ( a_phif ) ; LevelData < FArrayBox > & phic = ( LevelData < FArrayBox > & ) ( a_phic ) ; phif . exchange ( ) ; phic . exchange ( ) ; Interval interv ( 0 , m_nComp - 1 ) ; a_phic . copyTo ( interv , m_coarsenedFineBuffer , interv ) ; DataIterator ditFine = a_phif . dataIterator ( ) ; for ( ditFine . begin ( ) ; ditFine . ok ( ) ; ++ ditFine ) { DataIndex datIndGlo = ditFine ( ) ; BaseFab < Real > & phif = a_phif [ datIndGlo ] ; BaseFab < Real > & gradf = a_gradf [ datIndGlo ] ; BaseFab < Real > gradStar [ SpaceDim ] [ 2 ] ; for ( int idir = 0 ; idir < SpaceDim ; idir ++ ) { { const BaseFab < Real > & loPhiC = m_coarsenedFineBuffer [ datIndGlo ] ; const QuadCFStencil & loQCFS = m_loQCFS [ idir ] [ datIndGlo ] ; BaseFab < Real > & thisGradStar = gradStar [ idir ] [ 0 ] ; coarseFineInterp ( phif , gradf , thisGradStar , loPhiC , loQCFS , Side :: Lo , idir , variables ) ; } { const BaseFab < Real > & hiPhiC = m_coarsenedFineBuffer [ datIndGlo ] ; const QuadCFStencil & hiQCFS = m_hiQCFS [ idir ] [ datIndGlo ] ; BaseFab < Real > & thisGradStar = gradStar [ idir ] [ 1 ] ; coarseFineInterp ( phif , gradf , thisGradStar , hiPhiC , hiQCFS , Side :: Hi , idir , variables ) ; } } BaseFab < Real > & tanGrad = a_gradf [ ditFine ( ) ] ; for ( int idir = 0 ; idir < SpaceDim ; idir ++ ) { BaseFab < Real > & thisGradStarLo = gradStar [ idir ] [ 0 ] ; const QuadCFStencil & loQCFS = m_loQCFS [ idir ] [ datIndGlo ] ; const TensorFineStencilSet & loTFSS = m_loFineStencilSets [ idir ] [ datIndGlo ] ; computeTanGrad ( tanGrad , phif , thisGradStarLo , loTFSS , loQCFS , Side :: Lo , idir , variables ) ; BaseFab < Real > & thisGradStarHi = gradStar [ idir ] [ 1 ] ; const QuadCFStencil & hiQCFS = m_hiQCFS [ idir ] [ datIndGlo ] ; const TensorFineStencilSet & hiTFSS = m_hiFineStencilSets [ idir ] [ datIndGlo ] ; computeTanGrad ( tanGrad , phif , thisGradStarHi , hiTFSS , hiQCFS , Side :: Hi , idir , variables ) ; } } } }
apply coarse-fine boundary conditions -- assume that phi grids
are grown by one
apply coarse - fine boundary conditions -- assume that phi grids are grown by one
// this will contain the coarse-grid gradients, // centered in the same locations as phiStar. // this is necessary because cannot compute interpolated // grad(phi) until ghost cell values are computed. // these will be allocated at the same time as phiStar // loop over directions //lo side cfinterp //recall that buffers have fine processor mapping //hi side cfinterp //end iteration over directions // now can compute tangential gradients // lo side // hi side //end iteration over boxes in fine grid