lib/src/BoxTools/LoHiCenter.cpp
///
/**
   This function is used when in direction a_dir a 2-point stencil of
   cell-centered data is being used to compute something at the
   face between cells of the stencil.

   Inputs:
   * a_dir is the direction of the 2-point stencil;
   * a_inBox is the cell-centered box on which we have data;
   * a_domain is the problem domain.

   Output boxes are all face-centered subboxes of the faces of a_inBox
   in direction a_dir, and are also contained in the faces of a_domain:
   * a_loBox is where a 1-point stencil must be used on the low side;
   * a_centerBox is where the full 2-point stencil can be used;
   * a_hiBox is where a 1-point stencil must be used on the high side;
   * a_entireBox is the union of a_loBox and a_centerBox and a_hiBox.

   The boxes a_loBox and a_hiBox will be at most 1 face wide;
   here the 1-point stencil consists of only 1 of the adjacent cells
   in direction a_dir.

   Output flags:
   * a_hasLo:  1 or 0, according to whether a_loBox is defined or not;
   * a_hasHi:  1 or 0, according to whether a_hiBox is defined or not.
 */
This function is used when in direction a_dir a 2-point stencil of
cell-centered data is being used to compute something at the
face between cells of the stencil.

a_dir is the direction of the 2-point stencil;
a_inBox is the cell-centered box on which we have data;
a_domain is the problem domain.

Output boxes are all face-centered subboxes of the faces of a_inBox
in direction a_dir, and are also contained in the faces of a_domain:
a_loBox is where a 1-point stencil must be used on the low side;
a_centerBox is where the full 2-point stencil can be used;
a_hiBox is where a 1-point stencil must be used on the high side;
a_entireBox is the union of a_loBox and a_centerBox and a_hiBox.

The boxes a_loBox and a_hiBox will be at most 1 face wide;
here the 1-point stencil consists of only 1 of the adjacent cells
in direction a_dir.

Output flags:
a_hasLo:  1 or 0, according to whether a_loBox is defined or not;
a_hasHi:  1 or 0, according to whether a_hiBox is defined or not.
This function is used when in direction a_dir a 2 - point stencil of cell - centered data is being used to compute something at the face between cells of the stencil . a_dir is the direction of the 2 - point stencil ; a_inBox is the cell - centered box on which we have data ; a_domain is the problem domain . Output boxes are all face - centered subboxes of the faces of a_inBox in direction a_dir and are also contained in the faces of a_domain : a_loBox is where a 1 - point stencil must be used on the low side ; a_centerBox is where the full 2 - point stencil can be used ; a_hiBox is where a 1 - point stencil must be used on the high side ; a_entireBox is the union of a_loBox and a_centerBox and a_hiBox . The boxes a_loBox and a_hiBox will be at most 1 face wide ; here the 1 - point stencil consists of only 1 of the adjacent cells in direction a_dir . Output flags : a_hasLo : 1 or 0 according to whether a_loBox is defined or not ; a_hasHi : 1 or 0 according to whether a_hiBox is defined or not .
void loHiCenterFace(Box&                 a_loBox,
                    int&                 a_hasLo,
                    Box&                 a_hiBox,
                    int&                 a_hasHi,
                    Box&                 a_centerBox,
                    Box&                 a_entireBox,
                    const Box&           a_inBox,
                    const ProblemDomain& a_domain,
                    const int&           a_dir)
{
  Box inBox = a_inBox;
  inBox &= a_domain;
  a_centerBox = inBox;
  a_centerBox.surroundingNodes(a_dir);
  a_centerBox.grow(a_dir,-1);
  a_entireBox = a_centerBox;
  Box tmp = a_inBox;
  tmp.shift(a_dir,-1);
  tmp &= a_domain;
  tmp.shift(a_dir,1);
  if (!a_domain.contains(tmp))
    {
      a_hasHi = 1;
      tmp.shift(a_dir,-2);
      a_hiBox = adjCellHi(tmp,a_dir);
      a_hiBox.shiftHalf(a_dir,1);
      a_entireBox.growHi(a_dir,1);
    }
  else
    {
      a_hasHi = 0;
      a_hiBox = Box().convert(BASISV(a_dir));
    }
  tmp = a_inBox;
  tmp.shift(a_dir,1);
  tmp &= a_domain;
  tmp.shift(a_dir,-1);
  if (!a_domain.contains(tmp))
    {
      a_hasLo = 1;
      tmp.shift(a_dir,2);
      a_loBox = adjCellLo(tmp,a_dir);
      a_loBox.shiftHalf(a_dir,-1);
      a_entireBox.growLo(a_dir,1);
    }
  else
    {
      a_hasLo = 0;
      a_loBox = Box().convert(BASISV(a_dir));
    }
  CH_assert(a_entireBox.contains(a_centerBox));
  if (a_hasLo == 1)
    {
      CH_assert(a_entireBox.contains(a_loBox));
    }
  if (a_hasHi == 1)
    {
      CH_assert(a_entireBox.contains(a_hiBox));
    }
}
void loHiCenterFace ( Box & a_loBox , int & a_hasLo , Box & a_hiBox , int & a_hasHi , Box & a_centerBox , Box & a_entireBox , const Box & a_inBox , const ProblemDomain & a_domain , const int & a_dir ) { Box inBox = a_inBox ; inBox &= a_domain ; a_centerBox = inBox ; a_centerBox . surroundingNodes ( a_dir ) ; a_centerBox . grow ( a_dir , -1 ) ; a_entireBox = a_centerBox ; Box tmp = a_inBox ; tmp . shift ( a_dir , -1 ) ; tmp &= a_domain ; tmp . shift ( a_dir , 1 ) ; if ( ! a_domain . contains ( tmp ) ) { a_hasHi = 1 ; tmp . shift ( a_dir , -2 ) ; a_hiBox = adjCellHi ( tmp , a_dir ) ; a_hiBox . shiftHalf ( a_dir , 1 ) ; a_entireBox . growHi ( a_dir , 1 ) ; } else { a_hasHi = 0 ; a_hiBox = Box ( ) . convert ( BASISV ( a_dir ) ) ; } tmp = a_inBox ; tmp . shift ( a_dir , 1 ) ; tmp &= a_domain ; tmp . shift ( a_dir , -1 ) ; if ( ! a_domain . contains ( tmp ) ) { a_hasLo = 1 ; tmp . shift ( a_dir , 2 ) ; a_loBox = adjCellLo ( tmp , a_dir ) ; a_loBox . shiftHalf ( a_dir , -1 ) ; a_entireBox . growLo ( a_dir , 1 ) ; } else { a_hasLo = 0 ; a_loBox = Box ( ) . convert ( BASISV ( a_dir ) ) ; } CH_assert ( a_entireBox . contains ( a_centerBox ) ) ; if ( a_hasLo == 1 ) { CH_assert ( a_entireBox . contains ( a_loBox ) ) ; } if ( a_hasHi == 1 ) { CH_assert ( a_entireBox . contains ( a_hiBox ) ) ; } }
This function is used when in direction a_dir a 2-point stencil of
cell-centered data is being used to compute something at the
face between cells of the stencil.
This function is used when in direction a_dir a 2 - point stencil of cell - centered data is being used to compute something at the face between cells of the stencil .
// Make a copy of the input box which can be modified // The centered difference box is always one smaller in a_dir // The union of all the output boxes start off equal to the center // difference portion on the input box (intersected with the domain) // See if this chops off the high side of the input box // If so, set up the high, one-sided difference box, a_hiBox, and expand // the entire box to include it // See if this chops off the low side of the input box // If so, set up the low, one-sided difference box, a_loBox, and expand // the entire box to include it // Make some simple sanity checks