lib/src/AMRTools/QuadCFStencil.cpp
/**
   compute first derivative in devdir direction
   at coarse point a_ivin
   Uses centered finite diff approximation if
   m_ivsStandard.contains(a_ivin ).
   Otherwise, it uses the stencil from m_firstD
   Asserts that a_derivdir != direction of face
*/
compute first derivative in devdir direction
at coarse point a_ivin
Uses centered finite diff approximation if
m_ivsStandard.contains(a_ivin ).
Otherwise, it uses the stencil from m_firstD
Asserts that a_derivdir != direction of face
compute first derivative in devdir direction at coarse point a_ivin Uses centered finite diff approximation if m_ivsStandard . contains ( a_ivin ) . Otherwise it uses the stencil from m_firstD Asserts that a_derivdir ! = direction of face
Real
QuadCFStencil::computeFirstDerivative(
                                      const BaseFab<Real> & a_phic,
                                      int a_derivdir,
                                      int a_ivar,
                                      const IntVect& a_ivin,
                                      Real a_dx) const
{
  CH_assert(isDefined());
  CH_assert(a_ivar >= 0);
  CH_assert(a_ivar < a_phic.nComp());
  CH_assert(!a_phic.box().isEmpty());
  CH_assert(a_derivdir >= 0);
  CH_assert(a_derivdir < SpaceDim);
  CH_assert(a_derivdir != m_direction);
  CH_assert(a_dx > 0);
  Real firstd;
  if (m_ivsStandard.contains(a_ivin))
    {
      IntVect basisv = BASISV(a_derivdir);
      IntVect ivlo = a_ivin - basisv;
      IntVect ivhi = a_ivin + basisv;
      CH_assert(a_phic.box().contains(ivlo));
      CH_assert(a_phic.box().contains(ivhi));
      Real philo = a_phic(ivlo, a_ivar);
      Real phihi = a_phic(ivhi, a_ivar);
      firstd = (phihi - philo)/(2.0*a_dx);
    }
  else
    {
      const BaseFab<DerivStencil>& stenfab
        = m_firstD[a_derivdir];
      CH_assert(stenfab.box().contains(a_ivin));
      const DerivStencil& dersten = stenfab(a_ivin);
      firstd = 0.0;
      bool keepzer = false;
      for (int isten = 0; isten < dersten.size(); isten++)
        {
          Real wgt = dersten.getWeight(isten);
          const IntVect& ivphi= dersten.getIndex(isten);
          if (a_phic.box().contains(ivphi))
            firstd += wgt*a_phic(ivphi, a_ivar);
          else
            keepzer = true;
        }
      if (keepzer) firstd = 0.0;
      firstd /= (a_dx);
    }
  return firstd;
}
Real QuadCFStencil :: computeFirstDerivative ( const BaseFab < Real > & a_phic , int a_derivdir , int a_ivar , const IntVect & a_ivin , Real a_dx ) const { CH_assert ( isDefined ( ) ) ; CH_assert ( a_ivar >= 0 ) ; CH_assert ( a_ivar < a_phic . nComp ( ) ) ; CH_assert ( ! a_phic . box ( ) . isEmpty ( ) ) ; CH_assert ( a_derivdir >= 0 ) ; CH_assert ( a_derivdir < SpaceDim ) ; CH_assert ( a_derivdir != m_direction ) ; CH_assert ( a_dx > 0 ) ; Real firstd ; if ( m_ivsStandard . contains ( a_ivin ) ) { IntVect basisv = BASISV ( a_derivdir ) ; IntVect ivlo = a_ivin - basisv ; IntVect ivhi = a_ivin + basisv ; CH_assert ( a_phic . box ( ) . contains ( ivlo ) ) ; CH_assert ( a_phic . box ( ) . contains ( ivhi ) ) ; Real philo = a_phic ( ivlo , a_ivar ) ; Real phihi = a_phic ( ivhi , a_ivar ) ; firstd = ( phihi - philo ) / ( 2.0 * a_dx ) ; } else { const BaseFab < DerivStencil > & stenfab = m_firstD [ a_derivdir ] ; CH_assert ( stenfab . box ( ) . contains ( a_ivin ) ) ; const DerivStencil & dersten = stenfab ( a_ivin ) ; firstd = 0.0 ; bool keepzer = false ; for ( int isten = 0 ; isten < dersten . size ( ) ; isten ++ ) { Real wgt = dersten . getWeight ( isten ) ; const IntVect & ivphi = dersten . getIndex ( isten ) ; if ( a_phic . box ( ) . contains ( ivphi ) ) firstd += wgt * a_phic ( ivphi , a_ivar ) ; else keepzer = true ; } if ( keepzer ) firstd = 0.0 ; firstd /= ( a_dx ) ; } return firstd ; }
compute first derivative in devdir direction
at coarse point a_ivin
Uses centered finite diff approximation if
m_ivsStandard.contains(a_ivin ).
compute first derivative in devdir direction at coarse point a_ivin Uses centered finite diff approximation if m_ivsStandard . contains ( a_ivin ) .
//use standard centered diff approx if //a_ivin is contained in m_ivsStandard //can't really assert this because blocking factor //could screw it up (grid one cell wide and all that) // CH_assert(a_phic.box().contains(ivphi));