Ejemplo n.º 1
0
void
MappedLevelFluxRegister::incrementCoarse(const FArrayBox& a_coarseFlux,
                                   Real a_scale,
                                   const DataIndex& a_coarseDataIndex,
                                   const Interval& a_srcInterval,
                                   const Interval& a_dstInterval,
                                   int a_dir,
                                   Side::LoHiSide a_sd)
{
    CH_assert(isDefined());
    if (!(m_isDefined & FluxRegCoarseDefined)) return;
    CH_TIME("MappedLevelFluxRegister::incrementCoarse");

    const Vector<Box>& intersect =
        m_coarseLocations[a_dir + a_sd * CH_SPACEDIM][a_coarseDataIndex];

    FArrayBox& coarse = m_coarFlux[a_coarseDataIndex];

    // We cast away the constness in a_coarseFlux for the scope of this function. This
    // should be acceptable, since at the end of the day there is no change to it. -JNJ
    FArrayBox& coarseFlux = const_cast<FArrayBox&>(a_coarseFlux); // Muhahaha.
    coarseFlux.shiftHalf(a_dir, sign(a_sd));
    Real scale = -sign(a_sd) * a_scale;
    int s = a_srcInterval.begin();
    int d = a_dstInterval.begin();
    int size = a_srcInterval.size();

    for (int b = 0; b < intersect.size(); ++b) {
        const Box& box = intersect[b];
        Vector<Real> regbefore(coarse.nComp());
        Vector<Real> regafter(coarse.nComp());
        if (s_verbose && (a_dir == debugdir) && box.contains(ivdebnoeb)) {
            for (int ivar = 0; ivar < coarse.nComp(); ivar++) {
                regbefore[ivar] = coarse(ivdebnoeb, ivar);
            }
        }

        coarse.plus(coarseFlux, box, box, scale, s, d, size);

        if (s_verbose && (a_dir == debugdir) && box.contains(ivdebnoeb)) {
            for (int ivar = 0; ivar < coarse.nComp(); ivar++) {
                regafter[ivar] = coarse(ivdebnoeb, ivar);
            }

            pout() << "levelfluxreg::incrementCoar: scale = " << scale << ", ";
            for (int ivar = 0; ivar < coarse.nComp(); ivar++) {
                pout() << " input flux = " << coarseFlux(ivdebnoeb, ivar) << ", ";
                pout() << " reg before = " <<             regbefore[ivar] << ", ";
                pout() << " reg after  = " <<                regafter[ivar] << ", ";
            }
            pout() << endl;

        }
    }

    coarseFlux.shiftHalf(a_dir, - sign(a_sd));
}
void update_hash(string coordfile) {
  ifstream coordstream(coordfile);
  floatVector fine(3);
  intVector fineInt(3);
  intVector coarse(3);

  while(coordstream.good()) {
    coordstream >> fine[0]; coordstream >> fine[1]; coordstream >> fine[2];
    for (int z=0; z<2; z++)
      for (int y=0; y<2; y++)
	for (int x=0; x<2; x++) {
	  fineInt[0]=(int)fine[0]+x; fineInt[1]=(int)fine[1]+y; fineInt[2]=(int)fine[2]+z;
	  conn_profile()[fineInt]=vector<float>(); // just to store the key
	}

    fine2coarse(fine, coarse);
    if (!coarse_map().count(coarse))
      coarse_map()[coarse] = coarse_map().size();
  }
}
Ejemplo n.º 3
0
void
Elastic::V_Coarsen_Patch_Strategy::fix_boundary_elements_2D
(SAMRAI::pdat::SideData<double>& v,
 const SAMRAI::pdat::SideData<double>& v_fine,
 const boost::shared_ptr<SAMRAI::pdat::SideData<double> > dv_mixed,
 const std::vector<SAMRAI::hier::BoundaryBox> &boundaries) const
{
  /* FIXME: Why is this required?  Shouldn't the boundary points be
     ok?  They are partially interpolated from the coarse level, but
     that should not be a problem.  Unfortunately, it is a problem,
     because removing this routine generates nan's. */

  /* Fix up the boundary elements by iterating through the boundary
     boxes */

  /* We only care about edges, not corners, so we only iterate over
     edge boundary boxes. */

  SAMRAI::hier::Box gbox(v_fine.getGhostBox());
  SAMRAI::hier::Index ip(1,0), jp(0,1);
  for(size_t mm=0; mm<boundaries.size(); ++mm)
    {
      SAMRAI::hier::Box bbox=boundaries[mm].getBox();
      int location_index=boundaries[mm].getLocationIndex();

      SAMRAI::hier::Index
        lower=SAMRAI::hier::Index::coarsen(bbox.lower(),
                                           SAMRAI::hier::Index(2,2)),
        upper=SAMRAI::hier::Index::coarsen(bbox.upper(),
                                           SAMRAI::hier::Index(2,2));

      for(int j=lower(1); j<=upper(1); ++j)
        for(int i=lower(0); i<=upper(0); ++i)
          {
            /* Fix vx */
            if(location_index==0)
              {
                SAMRAI::pdat::SideIndex coarse(SAMRAI::hier::Index(i,j),0,
                                               SAMRAI::pdat::SideIndex::Upper);
                SAMRAI::pdat::SideIndex x(coarse*2);
                if(x[1]>=gbox.lower(1) && x[1]<gbox.upper(1))
                  {
                    v(coarse)=(v_fine(x) + v_fine(x+jp))/2;
                    if(have_faults() && !is_residual)
                      v(coarse)+=((*dv_mixed)(x,0) + (*dv_mixed)(x+jp,1))/2;
                  }
              }
            else if(location_index==1)
              {
                SAMRAI::pdat::SideIndex coarse(SAMRAI::hier::Index(i,j),0,
                                               SAMRAI::pdat::SideIndex::Lower);
                SAMRAI::pdat::SideIndex x(coarse*2);
                if(x[1]>=gbox.lower(1) && x[1]<gbox.upper(1))
                  {
                    v(coarse)=(v_fine(x) + v_fine(x+jp))/2;
                    if(have_faults() && !is_residual)
                      v(coarse)+=((*dv_mixed)(x,0) + (*dv_mixed)(x+jp,1))/2;
                  }
              }
            /* Fix vy */
            else if(location_index==2)
              {
                SAMRAI::pdat::SideIndex coarse(SAMRAI::hier::Index(i,j),1,
                                               SAMRAI::pdat::SideIndex::Upper);
                SAMRAI::pdat::SideIndex y(coarse*2);
                if(y[0]>=gbox.lower(0) && y[0]<gbox.upper(0))
                  {
                    v(coarse)=(v_fine(y) + v_fine(y+ip))/2;
                    if(have_faults() && !is_residual)
                      v(coarse)+=((*dv_mixed)(y,0) + (*dv_mixed)(y+ip,1))/2;
                  }
              }
            else if(location_index==3)
              {
                SAMRAI::pdat::SideIndex coarse(SAMRAI::hier::Index(i,j),1,
                                               SAMRAI::pdat::SideIndex::Lower);
                SAMRAI::pdat::SideIndex y(coarse*2);
                if(y[0]>=gbox.lower(0) && y[0]<gbox.upper(0))
                  {
                    v(coarse)=(v_fine(y) + v_fine(y+ip))/2;
                    if(have_faults() && !is_residual)
                      v(coarse)+=((*dv_mixed)(y,0) + (*dv_mixed)(y+ip,1))/2;
                  }
              }
            else
              {
                abort();
              }
          }
    }
}