Exemple #1
0
void
setToExactFlux(EBFluxFAB&             a_flux,
               const EBISBox&         a_ebisBox,
               const Box&             a_region,
               const Real&            a_dx)
{
    IntVectSet ivsregion(a_region);
    for (int faceDir = 0; faceDir < SpaceDim; faceDir++)
    {
        for (FaceIterator faceit(ivsregion, a_ebisBox.getEBGraph(), faceDir, FaceStop::SurroundingWithBoundary); faceit.ok(); ++faceit)
        {
            RealVect xval;
            IntVect iv = faceit().gridIndex(Side::Hi);
            RealVect centroid = a_ebisBox.centroid(faceit());
            for (int idir = 0; idir < SpaceDim; idir++)
            {
                if (idir == faceDir)
                {
                    xval[idir] = (Real(iv[idir]))*a_dx;
                }
                else
                {
                    xval[idir] = (Real(iv[idir]) + 0.5 + centroid[idir])*a_dx;
                }
            }
            Real fluxDir = exactFlux(xval, faceDir);
            a_flux[faceDir](faceit(), 0) = fluxDir;
        }
    } //end loop over face directions

}
Exemple #2
0
void EBPoissonOp::
getOpFaceStencil(VoFStencil&             a_stencil,
                 const Vector<VolIndex>& a_allMonotoneVoFs,
                 const EBISBox&          a_ebisbox,
                 const VolIndex&         a_VoF,
                 int                     a_dir,
                 const Side::LoHiSide&   a_side,
                 const FaceIndex&        a_face,
                 const bool&             a_lowOrder)
{
  a_stencil.clear();

  const RealVect& faceCentroid = a_ebisbox.centroid(a_face);
  const IntVect& origin = a_VoF.gridIndex();

  IntVect dirs = IntVect::Zero;

  for (int idir = 0; idir < SpaceDim; idir++)
    {
      if (idir != a_dir)
        {
          IntVect ivPlus = origin;
          ivPlus[idir] += 1;
          if (faceCentroid[idir] < 0.0)
            {
              dirs[idir] = -1;
            }
          else if (faceCentroid[idir] > 0.0)
            {
              dirs[idir] = 1;
            }
          else if (m_eblg.getDomain().contains(ivPlus))
            {
              dirs[idir] = 1;
            }
          else
            {
              dirs[idir] = -1;
            }
        }
    }

  bool orderOne = true;

  if (m_orderEB == 0 || a_lowOrder)
    {
      orderOne = false;
    }
  else
    {
      IntVect loVect = dirs;
      loVect.min(IntVect::Zero);

      IntVect hiVect = dirs;
      hiVect.max(IntVect::Zero);

      Box fluxBox(loVect,hiVect);
      IntVectSet fluxIVS(fluxBox);

      IVSIterator ivsit(fluxIVS);
      for (ivsit.begin(); ivsit.ok(); ++ivsit)
        {
          bool curOkay;

          IntVect ivDelta = ivsit();

          IntVect iv1 = ivDelta;
          iv1 += origin;

          VolIndex VoF1;

          curOkay = EBArith::isVoFHere(VoF1,a_allMonotoneVoFs,iv1);

          IntVect iv2 = iv1;
          iv2[a_dir] += sign(a_side);

          VolIndex VoF2;

          curOkay = curOkay && EBArith::isVoFHere(VoF2,a_allMonotoneVoFs,iv2);

          orderOne = orderOne && curOkay;

          if (curOkay)
            {
              VoFStencil curPair;
              curPair.add(VoF1,-m_invDx2[a_dir]);
              curPair.add(VoF2, m_invDx2[a_dir]);

              for (int idir = 0; idir < SpaceDim; idir++)
                {
                  if (idir != a_dir)
                    {
                      if (ivDelta[idir] == 0)
                        {
                          curPair *= 1 - abs(faceCentroid[idir]);
                        }
                      else
                        {
                          curPair *= abs(faceCentroid[idir]);
                        }
                    }
                }
              a_stencil += curPair;
            }
        }
    }

  if (!orderOne)
    {
      VolIndex VoF1 = a_VoF;
      VolIndex VoF2 = a_face.getVoF(a_side);

      if (a_ebisbox.getRegion().contains(VoF2.gridIndex()))
        {
          a_stencil.clear();

          a_stencil.add(VoF1,-m_invDx2[a_dir]);
          a_stencil.add(VoF2, m_invDx2[a_dir]);
        }
    }
  if (!a_lowOrder)
    {
      a_stencil *= a_ebisbox.areaFrac(a_face);
    }
}