lib/src/AMRTools/QuadCFStencil.cpp
/**
   compute second derivative in devdir direction
   at coarse point ivin
   Uses centered finite diff approximation if
   m_ivsStandard.contains(ivin ).
   Otherwise, it uses the stencil from m_second
   Asserts that derivdir != direction of face
*/
compute second derivative in devdir direction
at coarse point ivin
Uses centered finite diff approximation if
m_ivsStandard.contains(ivin ).
Otherwise, it uses the stencil from m_second
Asserts that derivdir != direction of face
compute second derivative in devdir direction at coarse point ivin Uses centered finite diff approximation if m_ivsStandard . contains ( ivin ) . Otherwise it uses the stencil from m_second Asserts that derivdir ! = direction of face
Real
QuadCFStencil::computeSecondDerivative(
                                       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 != m_direction);
  CH_assert(a_derivdir < SpaceDim);
  CH_assert(a_dx > 0);
  Real secondd;
  if (m_ivsStandard.contains(a_ivin))
    {
      IntVect basisv = BASISV(a_derivdir);
      IntVect ivcc = a_ivin;
      IntVect ivlo = a_ivin - basisv;
      IntVect ivhi = a_ivin + basisv;
      CH_assert(a_phic.box().contains(ivcc));
      CH_assert(a_phic.box().contains(ivlo));
      CH_assert(a_phic.box().contains(ivhi));
      Real phicc = a_phic(ivcc, a_ivar);
      Real philo = a_phic(ivlo, a_ivar);
      Real phihi = a_phic(ivhi, a_ivar);
      secondd = (phihi + philo - 2.0*phicc)/(a_dx*a_dx);
    }
  else
    {
      CH_assert(m_ivsQuadd.contains(a_ivin));
      CH_assert(m_dropOrd.box().contains(a_ivin));
      if (m_dropOrd(a_ivin))
        {
          secondd = 0.0;
        }
      else
        {
          const BaseFab<DerivStencil>& stenfab
            = m_second[a_derivdir];
          CH_assert(stenfab.box().contains(a_ivin));
          const DerivStencil& dersten = stenfab(a_ivin);
          secondd = 0.0;
          bool keepzer = false;
          for (int isten = 0; isten < dersten.size(); isten++)
            {
              Real wgt = dersten.getWeight(isten);
              IntVect ivphi = dersten.getIndex(isten);
              if (a_phic.box().contains(ivphi))
                secondd += wgt*a_phic(ivphi, a_ivar);
              else
                keepzer = true;
            }
          if (keepzer) secondd = 0.0;
          secondd /= (a_dx*a_dx);
        }
    }
  return secondd;
}
Real QuadCFStencil :: computeSecondDerivative ( 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 != m_direction ) ; CH_assert ( a_derivdir < SpaceDim ) ; CH_assert ( a_dx > 0 ) ; Real secondd ; if ( m_ivsStandard . contains ( a_ivin ) ) { IntVect basisv = BASISV ( a_derivdir ) ; IntVect ivcc = a_ivin ; IntVect ivlo = a_ivin - basisv ; IntVect ivhi = a_ivin + basisv ; CH_assert ( a_phic . box ( ) . contains ( ivcc ) ) ; CH_assert ( a_phic . box ( ) . contains ( ivlo ) ) ; CH_assert ( a_phic . box ( ) . contains ( ivhi ) ) ; Real phicc = a_phic ( ivcc , a_ivar ) ; Real philo = a_phic ( ivlo , a_ivar ) ; Real phihi = a_phic ( ivhi , a_ivar ) ; secondd = ( phihi + philo - 2.0 * phicc ) / ( a_dx * a_dx ) ; } else { CH_assert ( m_ivsQuadd . contains ( a_ivin ) ) ; CH_assert ( m_dropOrd . box ( ) . contains ( a_ivin ) ) ; if ( m_dropOrd ( a_ivin ) ) { secondd = 0.0 ; } else { const BaseFab < DerivStencil > & stenfab = m_second [ a_derivdir ] ; CH_assert ( stenfab . box ( ) . contains ( a_ivin ) ) ; const DerivStencil & dersten = stenfab ( a_ivin ) ; secondd = 0.0 ; bool keepzer = false ; for ( int isten = 0 ; isten < dersten . size ( ) ; isten ++ ) { Real wgt = dersten . getWeight ( isten ) ; IntVect ivphi = dersten . getIndex ( isten ) ; if ( a_phic . box ( ) . contains ( ivphi ) ) secondd += wgt * a_phic ( ivphi , a_ivar ) ; else keepzer = true ; } if ( keepzer ) secondd = 0.0 ; secondd /= ( a_dx * a_dx ) ; } } return secondd ; }
compute second derivative in devdir direction
at coarse point ivin
Uses centered finite diff approximation if
m_ivsStandard.contains(ivin ).
compute second derivative in devdir direction at coarse point ivin Uses centered finite diff approximation if m_ivsStandard . contains ( 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));