lib/src/AMRTimeDependent/FourthOrderFillPatch.cpp
//////////////////////////////////////////////////////////////////////////////
// Define the object so that time stepping can begin
Define the object so that time stepping can begin
Define the object so that time stepping can begin
void FourthOrderFillPatch::define(
                                  const DisjointBoxLayout&  a_thisDisjointBoxLayout,
                                  const DisjointBoxLayout&  a_coarserDisjointBoxLayout,
                                  const int&                a_numStates,
                                  const ProblemDomain&      a_coarseDomain,
                                  const int&                a_refineCoarse,
                                  const int&                a_interpRadius,
                                  bool                      a_fixedTime,
                                  Interval                  a_fixedDims)
{
  m_numStates = a_numStates;
  m_coarseDomain = a_coarseDomain;
  m_refineCoarse = a_refineCoarse;
  m_interpRadius = a_interpRadius;
  m_fixedDims = a_fixedDims;
  m_layout = a_thisDisjointBoxLayout;
  m_coarseLayout = a_coarserDisjointBoxLayout;
  m_refineVect = m_refineCoarse * IntVect::Unit;
  for (int dirf = m_fixedDims.begin(); dirf <= m_fixedDims.end(); dirf++)
    {
      m_refineVect[dirf] = 1;
    }
  ProblemDomain fineDomain = refine(m_coarseDomain, m_refineVect);
  int ghostsCoarsened = m_interpRadius / m_refineCoarse;
  if (ghostsCoarsened * m_refineCoarse < m_interpRadius) ghostsCoarsened++;
  m_spaceInterpolator.define(m_layout, m_numStates,
                             m_refineCoarse, fineDomain, ghostsCoarsened,
                             m_fixedDims);
  if (!a_fixedTime)
    {
      const IntVect& ghostVect =
        m_spaceInterpolator.coarsenedFineData().ghostVect();
      int ghosts = ghostVect[0];
      CH_assert(ghostVect == ghosts * IntVect::Unit);
      m_timeInterpolator.define(m_layout, m_coarseLayout, fineDomain,
                                m_refineCoarse, m_numStates, ghosts);
      m_timeInterpDefined = true;
    }
  DisjointBoxLayout m_layoutCoarsened;
  coarsen(m_layoutCoarsened, m_layout, m_refineVect);
  m_coarsenedGhosts.define(m_layoutCoarsened);
  Box periodicTestBox(m_coarseDomain.domainBox());
  if (m_coarseDomain.isPeriodic())
    {
      for (int idir = 0; idir < SpaceDim; idir++)
        {
          if (m_coarseDomain.isPeriodic(idir))
            periodicTestBox.grow(idir,-1);
        }
    }
  DataIterator dit = m_layoutCoarsened.dataIterator();
  for (dit.begin(); dit.ok(); ++dit)
    {
      const Box& coarseBox = m_layoutCoarsened[dit];
      Box coarseBoxWithGhosts =
        grow(coarseBox, ghostsCoarsened) & m_coarseDomain;
      IntVectSet& coarsenedGhostsHere = m_coarsenedGhosts[dit];
      coarsenedGhostsHere = IntVectSet(coarseBoxWithGhosts);
      LayoutIterator litOther = m_layoutCoarsened.layoutIterator();
      for (litOther.begin(); litOther.ok(); ++litOther)
        {
          const Box& coarseOtherBox = m_layoutCoarsened[litOther];
          coarsenedGhostsHere -= coarseOtherBox;
          if (m_coarseDomain.isPeriodic()
              && !periodicTestBox.contains(coarseOtherBox)
              && !periodicTestBox.contains(coarseBox))
            {
              ShiftIterator shiftIt = m_coarseDomain.shiftIterator();
              IntVect shiftMult(m_coarseDomain.domainBox().size());
              Box shiftedBox(coarseOtherBox);
              for (shiftIt.begin(); shiftIt.ok(); ++shiftIt)
                {
                  IntVect shiftVect = shiftMult*shiftIt();
                  shiftedBox.shift(shiftVect);
                  coarsenedGhostsHere -= shiftedBox;
                  shiftedBox.shift(-shiftVect);
                }
            }
        }
    }
  m_defined = true;
}
void FourthOrderFillPatch :: define ( const DisjointBoxLayout & a_thisDisjointBoxLayout , const DisjointBoxLayout & a_coarserDisjointBoxLayout , const int & a_numStates , const ProblemDomain & a_coarseDomain , const int & a_refineCoarse , const int & a_interpRadius , bool a_fixedTime , Interval a_fixedDims ) { m_numStates = a_numStates ; m_coarseDomain = a_coarseDomain ; m_refineCoarse = a_refineCoarse ; m_interpRadius = a_interpRadius ; m_fixedDims = a_fixedDims ; m_layout = a_thisDisjointBoxLayout ; m_coarseLayout = a_coarserDisjointBoxLayout ; m_refineVect = m_refineCoarse * IntVect :: Unit ; for ( int dirf = m_fixedDims . begin ( ) ; dirf <= m_fixedDims . end ( ) ; dirf ++ ) { m_refineVect [ dirf ] = 1 ; } ProblemDomain fineDomain = refine ( m_coarseDomain , m_refineVect ) ; int ghostsCoarsened = m_interpRadius / m_refineCoarse ; if ( ghostsCoarsened * m_refineCoarse < m_interpRadius ) ghostsCoarsened ++ ; m_spaceInterpolator . define ( m_layout , m_numStates , m_refineCoarse , fineDomain , ghostsCoarsened , m_fixedDims ) ; if ( ! a_fixedTime ) { const IntVect & ghostVect = m_spaceInterpolator . coarsenedFineData ( ) . ghostVect ( ) ; int ghosts = ghostVect [ 0 ] ; CH_assert ( ghostVect == ghosts * IntVect :: Unit ) ; m_timeInterpolator . define ( m_layout , m_coarseLayout , fineDomain , m_refineCoarse , m_numStates , ghosts ) ; m_timeInterpDefined = true ; } DisjointBoxLayout m_layoutCoarsened ; coarsen ( m_layoutCoarsened , m_layout , m_refineVect ) ; m_coarsenedGhosts . define ( m_layoutCoarsened ) ; Box periodicTestBox ( m_coarseDomain . domainBox ( ) ) ; if ( m_coarseDomain . isPeriodic ( ) ) { for ( int idir = 0 ; idir < SpaceDim ; idir ++ ) { if ( m_coarseDomain . isPeriodic ( idir ) ) periodicTestBox . grow ( idir , -1 ) ; } } DataIterator dit = m_layoutCoarsened . dataIterator ( ) ; for ( dit . begin ( ) ; dit . ok ( ) ; ++ dit ) { const Box & coarseBox = m_layoutCoarsened [ dit ] ; Box coarseBoxWithGhosts = grow ( coarseBox , ghostsCoarsened ) & m_coarseDomain ; IntVectSet & coarsenedGhostsHere = m_coarsenedGhosts [ dit ] ; coarsenedGhostsHere = IntVectSet ( coarseBoxWithGhosts ) ; LayoutIterator litOther = m_layoutCoarsened . layoutIterator ( ) ; for ( litOther . begin ( ) ; litOther . ok ( ) ; ++ litOther ) { const Box & coarseOtherBox = m_layoutCoarsened [ litOther ] ; coarsenedGhostsHere -= coarseOtherBox ; if ( m_coarseDomain . isPeriodic ( ) && ! periodicTestBox . contains ( coarseOtherBox ) && ! periodicTestBox . contains ( coarseBox ) ) { ShiftIterator shiftIt = m_coarseDomain . shiftIterator ( ) ; IntVect shiftMult ( m_coarseDomain . domainBox ( ) . size ( ) ) ; Box shiftedBox ( coarseOtherBox ) ; for ( shiftIt . begin ( ) ; shiftIt . ok ( ) ; ++ shiftIt ) { IntVect shiftVect = shiftMult * shiftIt ( ) ; shiftedBox . shift ( shiftVect ) ; coarsenedGhostsHere -= shiftedBox ; shiftedBox . shift ( - shiftVect ) ; } } } } m_defined = true ; }
Define the object so that time stepping can begin
Define the object so that time stepping can begin
/// layout at this level /// layout at coarser level /// number of variables /// problem domain on the coarser level /// refinement ratio between this level and the coarser level /// number of layers of ghost cells to fill by interpolation /// whether this object is for a fixed time /// dimensions that are fixed, not interpolated // Cache data // width of ghost layer of coarse cells with fine cells to fill in // int ghostCoarsened = ceil(m_interpRadius / m_refineCoarse); // FourthOrderFineInterp m_spaceInterpolator; // TimeInterpolatorRK4 m_timeInterpolator; // we'll need intermediate-time data on ghosted coarsened m_layout // (not only ghost cells), and that's exactly what this will give us. // FIXME, 4 Oct 2012: time interpolator still isotropic refinement. // Use m_spaceInterpolator.m_coarseData instead of this. // LevelData<FArrayBox> m_coarsenedFineData; //  m_coarsenedFineData.define(m_layoutCoarsened, //                             m_numStates, //                             m_interpRadius * IntVect::Unit); // LayoutData<IntVectSet> m_coarsenedGhosts; // I copied this code segment from PiecewiseLinearFillPatch::define(). // We find LayoutData<IntVectSet> m_coarsenedGhosts, using: // ProblemDomain m_coarseDomain; // DisjointBoxLayout m_layoutCoarsened; // int ghostsCoarsened; // a box which will determine whether a given box // adjoins a periodic boundary // Initially set coarsenedGhostsHere to the whole ghosted coarse box. // Iterate over boxes in coarsened fine layout, and subtract off // from the set of coarse cells from which the fine ghost cells // will be interpolated. // also need to remove periodic images from list of cells // to be filled, since they will be filled through exchange // as well // Everything is defined now.