Example #1
0
//-----------------------------------------------------------------------
//  AMR Factory define function
void VCAMRPoissonOp2Factory::define(const ProblemDomain&                           a_coarseDomain,
                                   const Vector<DisjointBoxLayout>&               a_grids,
                                   const Vector<int>&                             a_refRatios,
                                   const Real&                                    a_coarsedx,
                                   BCHolder                                       a_bc,
                                   const Real&                                    a_alpha,
                                   Vector<RefCountedPtr<LevelData<FArrayBox> > >& a_aCoef,
                                   const Real&                                    a_beta,
                                   Vector<RefCountedPtr<LevelData<FluxBox> > >&   a_bCoef)
{
  CH_TIME("VCAMRPoissonOp2Factory::define");

  setDefaultValues();

  m_boxes = a_grids;

  m_refRatios = a_refRatios;

  m_bc = a_bc;

  m_dx.resize(a_grids.size());
  m_dx[0] = a_coarsedx;

  m_domains.resize(a_grids.size());
  m_domains[0] = a_coarseDomain;

  m_exchangeCopiers.resize(a_grids.size());
  m_exchangeCopiers[0].exchangeDefine(a_grids[0], IntVect::Unit);
  m_exchangeCopiers[0].trimEdges(a_grids[0], IntVect::Unit);

  m_cfregion.resize(a_grids.size());
  m_cfregion[0].define(a_grids[0], m_domains[0]);

  for (int i = 1; i < a_grids.size(); i++)
    {
      m_dx[i] = m_dx[i-1] / m_refRatios[i-1];

      m_domains[i] = m_domains[i-1];
      m_domains[i].refine(m_refRatios[i-1]);

      m_exchangeCopiers[i].exchangeDefine(a_grids[i], IntVect::Unit);
      m_exchangeCopiers[i].trimEdges(a_grids[i], IntVect::Unit);

      m_cfregion[i].define(a_grids[i], m_domains[i]);
    }

  m_alpha = a_alpha;
  m_aCoef = a_aCoef;

  m_beta  = a_beta;
  m_bCoef = a_bCoef;
}
void
EBCompositeCCProjector::
setSolverParams(int  a_numSmooths,
                int  a_iterMax,
                int  a_mgcycle,
                Real a_hang,
                Real a_tolerance,
                int  a_verbosity,
                Real a_normThresh)
{
  CH_TIME("EBCompositeCCProjector::setSolverParams");
  m_macProjector->setSolverParams(a_numSmooths, a_iterMax, a_mgcycle, a_hang, a_tolerance,a_verbosity,a_normThresh);
}
void
EBCompositeCCProjector::
averageStressToFaces(Vector<LevelData<EBFluxFAB>* >&  a_macVeloc,
                     Vector<LevelData<EBCellFAB>* >&  a_velocity)
{
  CH_TIME("EBCompositeCCProjector::averageVelocityToFaces");
  //interpolate and then send stuff on through to level function
  int ncomp = a_velocity[0]->nComp();
  Interval interv(0, ncomp-1);
  Vector<LevelData<EBCellFAB> *> amrPhi = m_macProjector->getPhi();
  for (int ilev = 0; ilev < m_numLevels; ilev++)
    {
      if (ilev > 0)
        {
          //so it can be reused quadcfi is a one-variable animal
          //when we have ebalias, we can accomplish this without copies.
          //for now, tough luck
          //use phi for scratch space
          LevelData<EBCellFAB>& phiCoar = *amrPhi[ilev-1];
          LevelData<EBCellFAB>& phiFine = *amrPhi[ilev  ];
          for (int idir = 0; idir < ncomp; idir++)
            {
              Interval phiInterv(0, 0);
              Interval velInterv(idir, idir);
              a_velocity[ilev-1]->copyTo(velInterv, phiCoar, phiInterv);
              a_velocity[ilev  ]->copyTo(velInterv, phiFine, phiInterv);
              m_quadCFI[ilev]->interpolate(phiFine,
                                           phiCoar,
                                           phiInterv);

              //on copy back, we need ghost cells, so do the data iterator loop
              for (DataIterator dit = phiFine.dataIterator(); dit.ok(); ++dit)
                {
                  Box region = phiFine[dit()].getRegion(); //includes ghost cells
                  (*a_velocity[ilev])[dit()].copy(region, velInterv, region, phiFine[dit()], phiInterv);
                }

              EBLevelDataOps::setVal(phiFine, 0.0);
              EBLevelDataOps::setVal(phiCoar, 0.0);
            }
        }
      a_velocity[ilev]->exchange(interv);
      ccpAverageStressToFaces(*a_macVeloc[ilev],
                              *a_velocity[ilev],
                              m_eblg[ilev].getDBL(),
                              m_eblg[ilev].getEBISL(),
                              m_eblg[ilev].getDomain(),
                              m_dx[ilev],
                              *m_eblg[ilev].getCFIVS());
    }
}
void NonAggregatedEBStencil::applyInhomDomBC(EBCellFAB&             a_lofphi,
                                             const EBCellFAB&       a_phi,
                                             const Real             a_factor) const

{
  CH_TIME("NonAggregatedEBStencil::applyInhomDomBC");
  for (int isrc = 0; isrc < m_srcVofs.size(); isrc++)
    {
      const VolIndex& vof = m_srcVofs[isrc];
      Real& lphi       = a_lofphi(vof, m_destVar);
      const Real& sour = a_phi(vof,0);
      lphi += a_factor*sour;
    }
}
Example #5
0
void
EBLevelAdvect::
advectToFacesBCG(EBFluxFAB&                         a_extrapState,
                 BaseIVFAB<Real>&                   a_boundaryPrim,
                 const EBCellFAB &                  a_consState,
                 const EBCellFAB &                  a_normalVel,
                 const EBFluxFAB &                  a_advectionVel,
                 const Box&                         a_cellBox,
                 const EBISBox&                     a_ebisBox,
                 const Real&                        a_dt,
                 const Real&                        a_time,
                 const EBCellFAB &                  a_source,
                 const DataIndex&                   a_dit,
                 bool   a_doBoundaryPrim)
{
  CH_TIME("EBLevelAdvect::advectToFacesBCG (fluxfab)");
  IntVectSet cfivs; //not used here.  only used in flux interpolation
  m_ebPatchAdvect[a_dit]->setTimeAndDt(a_time, a_dt);
  // EBCellFAB& primState = m_ebPatchAdvect[a_dit]->getPrimState();
  m_ebPatchAdvect[a_dit]->setVelocities(a_normalVel, a_advectionVel);

  //placeholder (no flattening used here)
  EBCellFAB flattening;
  //not reused
  EBCellFAB  slopesPrim[SpaceDim];
  EBCellFAB  slopesSeco[SpaceDim];
  bool verbose = false;

  m_ebPatchAdvect[a_dit]->extrapolateBCG(a_extrapState,
                                         // primState,
                                         slopesPrim,
                                         slopesSeco,
                                         flattening,
                                         a_consState,
                                         a_source,
                                         a_cellBox,
                                         a_dit,
                                         verbose);

  if (a_doBoundaryPrim)
    {
      IntVectSet irregIVS = a_ebisBox.getIrregIVS(a_cellBox);
      m_ebPatchAdvect[a_dit]->computeEBIrregFlux(a_boundaryPrim,
                                                 // primState,
                                                 a_consState,
                                                 slopesPrim,
                                                 irregIVS,
                                                 a_source);
    }
}
Example #6
0
void VCAMRPoissonOp2::getFlux(FArrayBox&       a_flux,
                             const FArrayBox& a_data,
                             const FluxBox&   a_bCoef,
                             const Box&       a_facebox,
                             int              a_dir,
                             int              a_ref) const
{
  CH_TIME("VCAMRPoissonOp2::getFlux");

  CH_assert(a_dir >= 0);
  CH_assert(a_dir <  SpaceDim);
  CH_assert(!a_data.box().isEmpty());
  CH_assert(!a_facebox.isEmpty());

  // probably the simplest way to test centering
  // a_box needs to be face-centered in the a_dir
  Box faceTestBox(IntVect::Zero, IntVect::Unit);
  faceTestBox.surroundingNodes(a_dir);
  CH_assert(a_facebox.type() == faceTestBox.type());

  const FArrayBox& bCoefDir = a_bCoef[a_dir];

  // reality check for bCoef
  CH_assert(bCoefDir.box().contains(a_facebox));

  a_flux.resize(a_facebox, a_data.nComp());
  BoxIterator bit(a_facebox);

  Real scale = m_beta * a_ref / m_dx;

  for ( bit.begin(); bit.ok(); bit.next())
    {
      IntVect iv = bit();
      IntVect shiftiv = BASISV(a_dir);
      IntVect ivlo = iv - shiftiv;
      IntVect ivhi = iv;

      CH_assert(a_data.box().contains(ivlo));
      CH_assert(a_data.box().contains(ivhi));

      for (int ivar = 0; ivar < a_data.nComp(); ivar++)
        {
          Real phihi = a_data(ivhi,ivar);
          Real philo = a_data(ivlo,ivar);
          Real gradphi = (phihi - philo ) * scale;

          a_flux(iv,ivar) = -bCoefDir(iv, ivar) * gradphi;
        }
    }
}
void
MappedLevelFluxRegister::setToZero()
{
    CH_TIME("MappedLevelFluxRegister::setToZero");
    if (m_isDefined & FluxRegCoarseDefined) {
        for (DataIterator d = m_coarFlux.dataIterator(); d.ok(); ++d) {
            m_coarFlux[d].setVal(0.0);
        }
    }
    if (m_isDefined & FluxRegFineDefined) {
        for (DataIterator d = m_fineFlux.dataIterator(); d.ok(); ++d) {
            m_fineFlux[d].setVal(0.0);
        }
    }
}
Example #8
0
EBStenVarCoef::
EBStenVarCoef(const Vector<VolIndex>& a_srcVofs,
              const BaseIVFAB<VoFStencil>& a_vofStencil,
              const Box& a_box,
              const EBISBox& a_ebisBox,
              const IntVect& a_ghostVect,
              int a_varDest)
  : m_box(       a_box       ),
    m_ebisBox(   a_ebisBox   ),
    m_ghostVect( a_ghostVect ),
    m_destVar(   a_varDest   )
{
  CH_TIME("EBStenVarCoef::EBStenVarCoef");
  computeOffsets(a_srcVofs, a_vofStencil);
}
Example #9
0
void EBPoissonOp::
residual(LevelData<EBCellFAB>&       a_residual,
         const LevelData<EBCellFAB>& a_phi,
         const LevelData<EBCellFAB>& a_rhs,
         bool                        a_homogeneousPhysBC)
{
  CH_TIME("EBPoissonOp::residual");
  //this is a multigrid operator so only homogeneous CF BC
  //and null coar level
  CH_assert(a_residual.ghostVect() == m_ghostCellsRHS);
  CH_assert(a_phi.ghostVect() == m_ghostCellsPhi);
  DataIterator dit = a_residual.dataIterator();
  applyOp(a_residual,a_phi, a_homogeneousPhysBC, dit );
  axby(a_residual,a_residual,a_rhs,-1.0, 1.0);
}
void
EBCompositeMACProjector::
enforceGradientBC(Vector<LevelData<EBFluxFAB>* >&       a_grad,
                  const Vector<LevelData<EBCellFAB>* >& a_phi)
{
  CH_TIME("EBCompositeMACProjector::enforceGradientBC");
  for (int ilev = 0; ilev < m_numLevels; ilev++)
    {
      EBLevelMACProjector::setCurLevel(ilev);
      macEnforceGradientBC(*a_grad[ilev],  *a_phi[ilev],
                           m_eblg[ilev].getDBL(), m_eblg[ilev].getEBISL(),
                           m_eblg[ilev].getDomain(),   m_dx[ilev],
                           m_origin,m_time,m_baseDomainBCFactPhi);
    }
}
void
EBCompositeMACProjector::
correctVelocityComponent(Vector<LayoutData< Vector< BaseIVFAB<Real> * > >* >      &  a_coveredVelLo,
                         Vector<LayoutData< Vector< BaseIVFAB<Real> * > >* >      &  a_coveredVelHi,
                         const Vector< LayoutData< Vector< Vector<VolIndex> > >* >&  a_coveredFaceLo,
                         const Vector< LayoutData< Vector< Vector<VolIndex> > >* >&  a_coveredFaceHi,
                         const Vector< LayoutData< Vector< IntVectSet > >* >      &  a_coveredSetsLo,
                         const Vector< LayoutData< Vector< IntVectSet > >* >      &  a_coveredSetsHi,
                         const Vector<LevelData<EBFluxFAB>* >                     &  a_macGradient,
                         int                                                         a_coveredFaceDir,
                         int                                                         a_velComp)
{
  CH_TIME("EBCompositeMACProjector::correctVelocityComponent");
  for (int ilev = 0; ilev < m_numLevels; ilev++)
    {
      for (SideIterator sit; sit.ok(); ++sit)
        {
          LayoutData<Vector<BaseIVFAB<Real>* > >*        velPtr = NULL;
          const LayoutData<Vector<Vector<VolIndex> > >* facePtr = NULL;
          const LayoutData<Vector<IntVectSet>  >*       setsPtr = NULL;
          if (sit() == Side::Lo)
            {
              velPtr  =  a_coveredVelLo[ilev];
              facePtr = a_coveredFaceLo[ilev];
              setsPtr = a_coveredSetsLo[ilev];
            }
          else
            {
              velPtr  =  a_coveredVelHi[ilev];
              facePtr = a_coveredFaceHi[ilev];
              setsPtr = a_coveredSetsHi[ilev];
            }

          const LevelData<EBFluxFAB>& macGradient = *a_macGradient[ilev];
          for (DataIterator dit = m_eblg[ilev].getDBL().dataIterator(); dit.ok(); ++dit)
            {
              const EBFluxFAB       & macGradFAB  = macGradient[dit()];
              const Vector<VolIndex>& coveredFace =  (*facePtr)[dit()][a_coveredFaceDir];
              const IntVectSet      & coveredSets =  (*setsPtr)[dit()][a_coveredFaceDir];
              BaseIVFAB<Real>       & coveredVel  = *((*velPtr)[dit()][a_coveredFaceDir]);
              const EBISBox& ebisBox = m_eblg[ilev].getEBISL()[dit()];

              correctVelocityComponent(coveredVel, coveredFace, coveredSets, macGradFAB, ebisBox,
                                       a_coveredFaceDir, sit(), a_velComp);
            }
        }
    }
}
void
EBGradDivFilter::
fillLambda()
{
  CH_TIME("EBGradDivFilter::fillLambda");
  Real lambdaVal = 1.0e10;
  for (int idir = 0; idir < SpaceDim; idir++)
    {
      Real lambdaDir  = m_lambdaScale*m_dxFine[idir]*m_dxFine[idir];
      lambdaVal = Min(lambdaVal, lambdaDir);
    }
  for (DataIterator dit = m_gridsFine.dataIterator(); dit.ok(); ++dit)
    {
      m_lambda[dit()].setVal(lambdaVal);
    }
}
Example #13
0
void VCAMRPoissonOp2::applyOpNoBoundary(LevelData<FArrayBox>&      a_lhs,
                                        const LevelData<FArrayBox>& a_phi)
{
  CH_TIME("VCAMRPoissonOp2::applyOpNoBoundary");

  LevelData<FArrayBox>& phi = (LevelData<FArrayBox>&)a_phi;

  const DisjointBoxLayout& dbl = a_lhs.disjointBoxLayout();
  DataIterator dit = phi.dataIterator();

  phi.exchange(phi.interval(), m_exchangeCopier);

  for (dit.begin(); dit.ok(); ++dit)
    {
      const Box& region = dbl[dit()];
      const FluxBox& thisBCoef = (*m_bCoef)[dit];

#if CH_SPACEDIM == 1
      FORT_VCCOMPUTEOP1D
#elif CH_SPACEDIM == 2
      FORT_VCCOMPUTEOP2D
#elif CH_SPACEDIM == 3
      FORT_VCCOMPUTEOP3D
#else
      This_will_not_compile!
#endif
                        (CHF_FRA(a_lhs[dit]),
                         CHF_CONST_FRA(phi[dit]),
                         CHF_CONST_REAL(m_alpha),
                         CHF_CONST_FRA((*m_aCoef)[dit]),
                         CHF_CONST_REAL(m_beta),
#if CH_SPACEDIM >= 1
                         CHF_CONST_FRA(thisBCoef[0]),
#endif
#if CH_SPACEDIM >= 2
                         CHF_CONST_FRA(thisBCoef[1]),
#endif
#if CH_SPACEDIM >= 3
                         CHF_CONST_FRA(thisBCoef[2]),
#endif
#if CH_SPACEDIM >= 4
                         This_will_not_compile!
#endif
                         CHF_BOX(region),
                         CHF_CONST_REAL(m_dx));
    } // end loop over boxes
}
Example #14
0
void
EBCoarToFineRedist::
redistribute(LevelData<EBCellFAB>& a_fineSolution,
             const Interval& a_variables)
{
  CH_TIME("EBCoarToFineRedist::redistribute");
  //copy the buffer to the fine layout
  m_regsCoar.copyTo(a_variables, m_regsCedFine, a_variables);
  //redistribute the coarsened fine registers to the fine solution
  for (DataIterator dit = m_gridsFine.dataIterator(); dit.ok(); ++dit)
    {
      const BaseIVFAB<Real>& regCoar = m_regsCedFine[dit()];
      const IntVectSet& ivsCoar = m_setsCedFine[dit()];
      const EBISBox& ebisBoxCoar = m_ebislCedFine[dit()];
      const BaseIVFAB<VoFStencil>& stenFAB = m_stenCedFine[dit()];

      EBCellFAB& solFAB = a_fineSolution[dit()];

      for (VoFIterator vofitCoar(ivsCoar, ebisBoxCoar.getEBGraph());
          vofitCoar.ok(); ++vofitCoar)
        {
          const VolIndex& srcVoFCoar = vofitCoar();
          const VoFStencil& vofsten = stenFAB(srcVoFCoar, 0);
          for (int isten = 0; isten < vofsten.size(); isten++)
            {
              const Real& weight = vofsten.weight(isten);
              const VolIndex& dstVoFCoar = vofsten.vof(isten);
              Vector<VolIndex> vofsFine =
                m_ebislCedFine.refine(dstVoFCoar,m_refRat, dit());

              for (int ivar = a_variables.begin();
                  ivar <= a_variables.end();  ivar++)
                {
                  Real dmCoar = regCoar(srcVoFCoar, ivar);
                  for (int ifine = 0; ifine < vofsFine.size(); ifine++)
                    {

                      const VolIndex& dstVoFFine = vofsFine[ifine];
                      //ufine += (wcoar*dmCoar) (piecewise constant density diff)
                      Real dUFine = dmCoar*weight;
                      solFAB(dstVoFFine, ivar) += dUFine;
                    }
                }
            }
        }
    }
}
Example #15
0
void
EBCoarToFineRedist::
setToZero()
{
  CH_TIME("EBCoarToFineRedist::setToZero");
  for (DataIterator dit = m_gridsCedFine.dataIterator();
      dit.ok(); ++dit)
    {
      m_regsCedFine[dit()].setVal(0.0);
    }

  for (DataIterator dit = m_gridsCoar.dataIterator();
      dit.ok(); ++dit)
    {
      m_regsCoar[dit()].setVal(0.0);
    }
}
Example #16
0
void VCAMRPoissonOp2::applyOpI(LevelData<FArrayBox>&      a_lhs,
                             const LevelData<FArrayBox>& a_phi,
                             bool                        a_homogeneous )
{
  CH_TIME("VCAMRPoissonOp2::applyOpI");
  LevelData<FArrayBox>& phi = (LevelData<FArrayBox>&)a_phi;
  Real dx = m_dx;
  const DisjointBoxLayout& dbl = a_lhs.disjointBoxLayout();
  DataIterator dit = phi.dataIterator();

  for (dit.begin(); dit.ok(); ++dit)
    {
      m_bc(phi[dit], dbl[dit()],m_domain, dx, a_homogeneous);
    }

  applyOpNoBoundary(a_lhs, a_phi);
}
Example #17
0
void
EBFineToCoarRedist::
setToZero()
{
  CH_TIME("EBFineToCoarRedist::setToZero");
  for (DataIterator dit = m_gridsRefCoar.dataIterator();
      dit.ok(); ++dit)
    {
      m_regsRefCoar[dit()].setVal(0.0);
    }

  for (DataIterator dit = m_gridsFine.dataIterator();
      dit.ok(); ++dit)
    {
      m_regsFine[dit()].setVal(0.0);
    }
}
void NonAggregatedEBStencil::apply(EBCellFAB& a_lofphi, const EBCellFAB& a_phi, bool a_incrementOnly, int  a_ivar) const
{

  CH_TIME("NonAggregatedEBStencil::apply");
  for (int isrc = 0; isrc < m_srcVofs.size(); isrc++)
    {
      const VolIndex& vof = m_srcVofs[isrc];
      Real& lphi = a_lofphi(vof, m_destVar);

      if (!a_incrementOnly)
        {
          lphi =  0.;
        }
      Real stenval = applyVoFStencil(m_vofStencil[isrc], a_phi, 0);
      lphi += stenval;
    }
}
Example #19
0
void
EBMGInterp::pwcInterpMG(LevelData<EBCellFAB>&       a_fineData,
                        const LevelData<EBCellFAB>& a_coarData,
                        const Interval&             a_variables)
{
  CH_TIME("EBMGInterp::pwcInterpMG");
  CH_assert(a_fineData.ghostVect() == m_ghost);
  CH_assert(a_coarData.ghostVect() == m_ghost);

  for (DataIterator dit = m_coarGrids.dataIterator(); dit.ok(); ++dit)
    {
      pwcInterpFAB(a_fineData[dit()],
                   m_coarGrids[dit()],
                   a_coarData[dit()],
                   dit(),
                   a_variables);
    }
}
Example #20
0
void
EBMGInterp::pwlInterpMG(LevelData<EBCellFAB>&       a_fineData,
                        const LevelData<EBCellFAB>& a_coarData,
                        const Interval&             a_variables)
{
  CH_TIME("EBMGInterp::pwlInterpMG");
  CH_assert(a_fineData.ghostVect() == m_ghost);
  CH_assert(a_coarData.ghostVect() == m_ghost);
  CH_assert(m_doLinear); //otherwise stencils have not been defined


  for (DataIterator dit = m_coarGrids.dataIterator(); dit.ok(); ++dit)
    {
      pwlInterpFAB(a_fineData[dit()],
                   m_coarGrids[dit()],
                   a_coarData[dit()],
                   dit(),
                   a_variables);
    }
}
void
EBCompositeMACProjector::
enforceVelocityBC(Vector<LevelData<EBFluxFAB>* >&  a_velocity,
                  const bool&                      a_doDivFreeOutflow)
{
  CH_TIME("EBCompositeMACProjector::enforceVelocityBC");
  for (int ilev = 0; ilev < m_numLevels; ilev++)
    {
      macEnforceVelocityBC(*a_velocity[ilev],
                           m_eblg[ilev].getDBL(),
                           m_eblg[ilev].getEBISL(),
                           m_eblg[ilev].getDomain(),
                           m_dx[ilev],
                           m_origin,
                           m_baseDomainBCFactVel,
                           m_time,
                           a_doDivFreeOutflow,
                           NULL);
    }
}
Example #22
0
void EBPoissonOp::
preCond(LevelData<EBCellFAB>&       a_lhs,
        const LevelData<EBCellFAB>& a_rhs)
{
  CH_TIME("EBPoissonOp::preCond");

  // Recall that the operator is: alpha*phi + beta*lap(phi)
  // For isotropic-dx Poisson: alpha=0,beta=1 and the
  //    diagonal term of this operator is: 4/h/h in 2D, 6/h/h in 3D,
  // For anisotropic-dx Helmholtz: alpha*phi + beta*lap(phi) and the
  //    diagonal term of this operator is: alpha - beta*(2/dx/dx + 2/dy/dy [+ 2/dz/dz])
  // Inverse of the diagonal term is our initial multiplier.

  getInvDiagRHS(a_lhs,a_rhs);
  //relax(a_lhs, a_rhs, m_numPreCondIters);
  for (int iter = 0; iter < m_numPreCondIters; iter++)
    {
      levelJacobi(a_lhs, a_rhs);
    }

}
Example #23
0
void
EBCoarsen::define(const EBLevelGrid&             a_eblgFine,
                  const EBLevelGrid&             a_eblgCoar,
                  const int&                     a_nref,
                  const int&                     a_nvar)
{
  CH_TIME("EBCoarsen:define");
  CH_assert(a_nref > 0);
  CH_assert(a_nvar > 0);
  CH_assert(a_eblgFine.getDBL().coarsenable(a_nref));
  CH_assert(a_eblgFine.getEBIS()->isDefined());
  CH_assert(a_eblgCoar.getEBIS()->isDefined());
  m_cfivsPtr = a_eblgFine.getCFIVS();
  m_isDefined  = true;
  m_refRat     = a_nref;
  m_nComp      = a_nvar;
  m_gridsCoar  = a_eblgCoar.getDBL();
  m_gridsFine  = a_eblgFine.getDBL();
  m_ebislCoar  = a_eblgCoar.getEBISL();
  m_ebislFine  = a_eblgFine.getEBISL();
  m_domainCoar = a_eblgCoar.getDomain();
  m_domainFine = a_eblgFine.getDomain();

  IntVect ghost = 4*IntVect::Unit;
  int nghost = 4;

  m_coarsenedFineGrids = DisjointBoxLayout();
  coarsen(m_coarsenedFineGrids, m_gridsFine, m_refRat);
  a_eblgFine.getEBIS()->fillEBISLayout(m_coarsenedFineEBISL,
                                       m_coarsenedFineGrids,
                                       m_domainCoar, nghost);
  m_coarsenedFineEBISL.setMaxRefinementRatio(m_refRat, a_eblgFine.getEBIS());
  EBCellFactory ebcellfact(m_coarsenedFineEBISL);
  m_coarsenedFineData.define(m_coarsenedFineGrids, m_nComp,
                             ghost, ebcellfact);

  //define the coarsening stencil for irreg vofs and
  //  for coarse vofs next to the cf interface if refRat<4
  defineStencil(*a_eblgFine.getCFIVS());
}
void
EBCompositeMACProjector::
setSolverParams(int  a_numSmooths,
                int  a_iterMax,
                int  a_mgcycle,
                Real a_hang,
                Real a_tolerance,
                int  a_verbosity,
                Real a_normThresh)
{
  CH_TIME("EBCompositeMACProjector::setSolverParams");
  m_solver.setSolverParameters(a_numSmooths,
                               a_numSmooths,
                               a_numSmooths,
                               a_mgcycle,
                               a_iterMax,
                               a_tolerance,
                               a_hang,
                               a_normThresh);

  m_solver.m_verbosity = a_verbosity;

  if (m_bottomSolverType==0)
    {
      m_bottomSolverBiCG.m_verbosity = a_verbosity - 2;
      m_bottomSolverBiCG.m_hang = -0.1;//because BiCGStab can be a bouncy ride
    }
  else if (m_bottomSolverType==1)
    {
      m_bottomSolverSimp.setNumSmooths(128*a_numSmooths);
    }
  else if (m_bottomSolverType==2)
    {
      //GMRES
    }
  else
    {
      MayDay::Error("EBCompositeMACProjector::setSolverParams bad bottomSolverType");
    }
}
Example #25
0
void EBPoissonOp::
colorGS(LevelData<EBCellFAB>&       a_phi,
        const LevelData<EBCellFAB>& a_rhs,
        const IntVect& a_color,
        int icolor)
{
  CH_TIME("EBPoissonOp::colorGS");

  //this is a multigrid operator so only homogeneous CF BC and null coar level
  CH_assert(a_rhs.ghostVect()    == m_ghostCellsRHS);
  CH_assert(a_phi.ghostVect()    == m_ghostCellsPhi);

  a_phi.exchange();


  Real weight = m_alpha;
  for (int idir = 0; idir < SpaceDim; idir++)
    {
      weight += -2.0 * m_beta * m_invDx2[idir];
    }
  weight = 1.0 / weight;


  for (DataIterator dit = a_phi.dataIterator(); dit.ok(); ++dit)
    {
      EBCellFAB& phifab = a_phi[dit()];
      m_colorEBStencil[icolor][dit()]->cache(phifab);
    }

  GSColorAllRegular(  a_phi, a_rhs, a_color, weight, true);

  for (DataIterator dit = a_phi.dataIterator(); dit.ok(); ++dit)
    {
      EBCellFAB& phifab = a_phi[dit()];
      m_colorEBStencil[icolor][dit()]->uncache(phifab);
    }

  GSColorAllIrregular(a_phi, a_rhs, a_color, true, icolor);
}
void
EBCompositeMACProjector::
gradient(Vector<LevelData<EBFluxFAB>* >&       a_grad,
         const Vector<LevelData<EBCellFAB>* >& a_phi)
{
  CH_TIME("EBCompositeMACProjector::gradient");
  for (int ilev = 0; ilev < m_numLevels; ilev++)
    {
      if (ilev>0)
        {
          m_quadCFI[ilev]->interpolate(*a_phi[ilev],
                                       *a_phi[ilev-1],
                                       Interval(0,0));
        }
      a_phi[ilev]->exchange();
      EBLevelMACProjector::setCurLevel(ilev);
      //compute the gradient ignoring other levels
      macGradient(*a_grad[ilev],  *a_phi[ilev],
                  m_eblg[ilev].getDBL(), m_eblg[ilev].getEBISL(),
                  m_eblg[ilev].getDomain(),   m_dx[ilev]);
    }
}
void
EBCompositeMACProjector::
correctVelocityComponent(Vector<LevelData<EBFluxFAB>* >&       a_velocity,
                         Vector<LevelData<EBFluxFAB>* >&       a_gradient,
                         int                                   a_icomp)
{
  CH_TIME("EBCompositeMACProjector::correctVelocityComponent");
  for (int ilev = 0; ilev < m_numLevels; ilev++)
    {
      //this routine makes no sense otherwise
      CH_assert(a_gradient[ilev]->nComp() == 1);
      CH_assert(a_velocity[ilev]->nComp() == 1);

      a_gradient[ilev]->exchange(Interval(0,0));
      for (DataIterator dit = m_eblg[ilev].getDBL().dataIterator(); dit.ok(); ++dit)
        {
          //same comp (a_icomp) of velocity on every face.
          //gradient of phi is ordinary mac gradient
          //so it lives on a_icomp faces
          const EBFaceFAB& gradFAB = (*a_gradient[ilev])[dit()][a_icomp];
          for (int idir = 0; idir < SpaceDim; idir++)
            {
              EBFaceFAB& velFAB = (*a_velocity[ilev])[dit()][idir];
              if (idir == a_icomp)
                {
                  velFAB -= gradFAB;
                }
              else
                {
                  correctTangentialVelocity(velFAB, gradFAB,
                                            m_eblg[ilev].getDBL().get(dit()),
                                            m_eblg[ilev].getEBISL()[dit()],
                                            (*m_eblg[ilev].getCFIVS())[dit()]);
                }
            }
        }
      a_velocity[ilev]->exchange();
    }
}
Example #28
0
void
EBCoarseAverage::define(const EBLevelGrid& a_eblgFine,
                        const EBLevelGrid& a_eblgCoar,
                        const EBLevelGrid& a_eblgCoFi,
                        const int& a_nref,
                        const int& a_nvar)
{
  CH_TIME("EBCoarseAverage::define(EBLG)");
  CH_assert(a_nref > 0);
  CH_assert(a_nvar > 0);
  CH_assert(a_eblgFine.getEBISL().getGhost() >= 2);
  CH_assert(a_eblgCoar.getEBISL().getGhost() >= 2);


  m_isDefined = true;
  m_refRat    = a_nref;
  m_nComp     = a_nvar;
  m_eblgCoar  = a_eblgCoar;

  m_eblgFine  = a_eblgFine;
  m_eblgCoFi  = a_eblgCoFi;
  m_eblgCoFi.getEBISL().setMaxRefinementRatio(a_nref, m_eblgCoar.getEBIS());

  m_irregSetsCoFi.define(m_eblgCoFi.getDBL());
  for (DataIterator dit = m_eblgCoFi.getDBL().dataIterator(); dit.ok(); ++dit)
    {
      m_irregSetsCoFi[dit()] = m_eblgCoFi.getEBISL()[dit()].getIrregIVS(m_eblgCoFi.getDBL().get(dit()));
    }

  if (m_useFineBuffer)
    {
      m_irregSetsFine.define(m_eblgFine.getDBL());
      for (DataIterator dit = m_eblgFine.getDBL().dataIterator(); dit.ok(); ++dit)
        {
          m_irregSetsFine[dit()] = m_eblgFine.getEBISL()[dit()].getIrregIVS(m_eblgFine.getDBL().get(dit()));
        }
    }
}
void NonAggregatedEBStencil::apply(EBCellFAB&             a_lofphi,
                                   const EBCellFAB&       a_phi,
                                   const BaseIVFAB<Real>& a_alphaWeight,
                                   Real                   a_alpha,
                                   Real                   a_beta,
                                   bool                   a_incrementOnly) const

{
  CH_TIME("NonAggregatedEBStencil::apply1");
  for (int isrc = 0; isrc < m_srcVofs.size(); isrc++)
    {
      const VolIndex& vof = m_srcVofs[isrc];
      Real& lphi = a_lofphi(vof, m_destVar);

      if (!a_incrementOnly)
        {
          lphi =  0.;
        }
      Real stenval   = applyVoFStencil(m_vofStencil[isrc], a_phi, 0);
      Real totalval  = a_alpha*a_alphaWeight(vof, 0)*a_phi(vof,0) + a_beta*stenval;
      lphi += totalval;
    }
}
void
EBCompositeCCProjector::
gradient(Vector<LevelData<EBCellFAB>* >&  a_gradient,
         Vector<LevelData<EBCellFAB>* >&  a_phi)
{
  CH_TIME("EBCompositeCCProjector::gradient");
  m_macProjector->gradient(m_macGrad, a_phi);

  //extrapolate to domain boundaries so that
  //we can have a sufficiently accurate representation
  //of the gradient at domain boundariers
  for (int ilev = 0; ilev < m_numLevels; ilev++)
    {
      m_macGrad[ilev]->exchange();
      ccpExtrapolateToDomainBoundaries(*m_macGrad[ilev],
                                       m_eblg[ilev].getDBL(),
                                       m_eblg[ilev].getEBISL(),
                                       m_eblg[ilev].getDomain(),
                                       m_dx[ilev]);
    }

  averageFaceToCells(a_gradient, m_macGrad);
}