releasedExamples/MultiDimPhase/advectSrc/OldPatchGodunov.cpp
// Compute a face centered divergence of the velocity
Compute a face centered divergence of the velocity
Compute a face centered divergence of the velocity
void OldPatchGodunov::divVel(FArrayBox&       a_divVel,
                             const FArrayBox& a_W,
                             const int        a_dir,
                             const Box&       a_box)
{
  Box dveltanBox = a_divVel.box();
  dveltanBox.enclosedCells(a_dir);
  dveltanBox.grow(1);
  dveltanBox &= m_domain;
  FArrayBox dveltan(dveltanBox,SpaceDim-1);
  Interval velInterval= velocityInterval();
  int v0index = velInterval.begin();
  for (int i = 0, dir = 0; dir < SpaceDim; ++dir)
  {
    if (dir != a_dir)
    {
      Box primBox = a_divVel.box();
      primBox.enclosedCells(a_dir);
      primBox.grow(dir,1).grow(a_dir,1);
      Box gradBox,hiBox,loBox,centerBox;
      int hasLo,hasHi;
      oldLoHiCenter(loBox,hasLo,hiBox,hasHi,centerBox,gradBox,
                    primBox,m_domain,dir);
      FORT_OLDGETGRADF(CHF_FRA1(dveltan,i),
                       CHF_CONST_FRA1(a_W,v0index+dir),
                       CHF_CONST_INT(dir),
                       CHF_BOX(loBox),
                       CHF_CONST_INT(hasLo),
                       CHF_BOX(hiBox),
                       CHF_CONST_INT(hasHi),
                       CHF_BOX(centerBox));
      ++i;
    }
  }
  Box divBox = a_divVel.box();
  divBox.enclosedCells(a_dir);
  divBox.grow(a_dir,1);
  Box loBox,hiBox,centerBox,entireBox;
  int hasLo,hasHi;
  oldLoHiCenterFace(loBox,hasLo,hiBox,hasHi,centerBox,entireBox,
                    divBox,m_domain,a_dir);
  loBox.shiftHalf(a_dir,1);
  centerBox.shiftHalf(a_dir,1);
  hiBox.shiftHalf(a_dir,1);
  a_divVel.shiftHalf(a_dir,1);
  FORT_OLDDIVUEDGEF(CHF_FRA1(a_divVel,0),
                    CHF_CONST_FRA1(a_W,v0index+a_dir),
                    CHF_CONST_FRA(dveltan),
                    CHF_CONST_INT(a_dir),
                    CHF_BOX(loBox),
                    CHF_CONST_INT(hasLo),
                    CHF_BOX(hiBox),
                    CHF_CONST_INT(hasHi),
                    CHF_BOX(centerBox));
  a_divVel.shiftHalf(a_dir,-1);
}
void OldPatchGodunov :: divVel ( FArrayBox & a_divVel , const FArrayBox & a_W , const int a_dir , const Box & a_box ) { Box dveltanBox = a_divVel . box ( ) ; dveltanBox . enclosedCells ( a_dir ) ; dveltanBox . grow ( 1 ) ; dveltanBox &= m_domain ; FArrayBox dveltan ( dveltanBox , SpaceDim - 1 ) ; Interval velInterval = velocityInterval ( ) ; int v0index = velInterval . begin ( ) ; for ( int i = 0 , dir = 0 ; dir < SpaceDim ; ++ dir ) { if ( dir != a_dir ) { Box primBox = a_divVel . box ( ) ; primBox . enclosedCells ( a_dir ) ; primBox . grow ( dir , 1 ) . grow ( a_dir , 1 ) ; Box gradBox , hiBox , loBox , centerBox ; int hasLo , hasHi ; oldLoHiCenter ( loBox , hasLo , hiBox , hasHi , centerBox , gradBox , primBox , m_domain , dir ) ; FORT_OLDGETGRADF ( CHF_FRA1 ( dveltan , i ) , CHF_CONST_FRA1 ( a_W , v0index + dir ) , CHF_CONST_INT ( dir ) , CHF_BOX ( loBox ) , CHF_CONST_INT ( hasLo ) , CHF_BOX ( hiBox ) , CHF_CONST_INT ( hasHi ) , CHF_BOX ( centerBox ) ) ; ++ i ; } } Box divBox = a_divVel . box ( ) ; divBox . enclosedCells ( a_dir ) ; divBox . grow ( a_dir , 1 ) ; Box loBox , hiBox , centerBox , entireBox ; int hasLo , hasHi ; oldLoHiCenterFace ( loBox , hasLo , hiBox , hasHi , centerBox , entireBox , divBox , m_domain , a_dir ) ; loBox . shiftHalf ( a_dir , 1 ) ; centerBox . shiftHalf ( a_dir , 1 ) ; hiBox . shiftHalf ( a_dir , 1 ) ; a_divVel . shiftHalf ( a_dir , 1 ) ; FORT_OLDDIVUEDGEF ( CHF_FRA1 ( a_divVel , 0 ) , CHF_CONST_FRA1 ( a_W , v0index + a_dir ) , CHF_CONST_FRA ( dveltan ) , CHF_CONST_INT ( a_dir ) , CHF_BOX ( loBox ) , CHF_CONST_INT ( hasLo ) , CHF_BOX ( hiBox ) , CHF_CONST_INT ( hasHi ) , CHF_BOX ( centerBox ) ) ; a_divVel . shiftHalf ( a_dir , -1 ) ; }
Compute a face centered divergence of the velocity
Compute a face centered divergence of the velocity
// First, we need to calculate the directional derivatives of // the tangential components of velocity at the cell-centers. // Get the interval of the primitive variables corresponding to the velocity // Go through the tangential directions // This velocity component is tangential.  Build the box in which // d(v[dir])/d(x[dir]) is to be computed. // Compute where centered differences can be used and where one sided // differences need to be used.  The data used for the differences is // defined on "dveltanBox" // Compute d(v[dir])/d(x[dir]). // Now, we can calculate the divergence of the normal velocity // at the center normal-direction edges. To do this, we determine // which edges at which we have sufficient data to compute centered // estimates of h*(div(u)). At the remaining edges. i.e. those // corresponding to the physical boundaries, we use zeroth-order // extrapolation. // All of the boxes computed above are shifted so as to be cell-centered, // with the index of the cell center being identified with the low edge. // We then shift a_divVel to be compatible with that convention on input, // and undo the shift on output.  Basically, everything is made compatible // a_W (which is cell-centered).