Beispiel #1
0
  static void setVal1(const Box& box, int comps, BaseFab<int>& fab)
    {
      int center = (box.smallEnd()[0] + box.bigEnd()[0])/2;
      fab.setVal(center, 0);
      fab.setVal(2*center, 1);
      fab.setVal(3*center, 2);

    }
Beispiel #2
0
 static void setVal2(const Box& box, int comps, BaseFab<int>& fab)
   {
     if ( SpaceDim == 1 )
       {
         fab.setVal(173);
       }
     else
       {
         int center = (box.smallEnd()[1] + box.bigEnd()[1])/2;
         fab.setVal(center);
       }
   }
Beispiel #3
0
// -------------------------------------------------------------
void
Mask::buildMask(BaseFab<int>& a_mask, const ProblemDomain& a_dProblem,
                const BoxLayout& a_grids, const BoxLayout* a_fineGridsPtr,
                int a_nRefFine)
{
  // first set entire box to Physical BC
  a_mask.setVal(maskPhysical);

  // now set all of domain interior to coarse
  Box domainInterior(a_mask.box());
  domainInterior &= a_dProblem;
  a_mask.setVal(maskCoarse,domainInterior,0);

  // now loop over this level's boxes and set them to "copy"
  LayoutIterator lit = a_grids.layoutIterator();

  for (lit.reset(); lit.ok(); ++lit)
    {
      Box intersectBox = a_grids.get(lit());
      intersectBox &= a_mask.box();
      if (!intersectBox.isEmpty())
        {
          a_mask.setVal(maskCopy,intersectBox,0);
        }
    }

  // if finer grids exist, set them to "covered"
  if (a_fineGridsPtr != NULL)
    {
      CH_assert (a_nRefFine > 1);

      LayoutIterator litFine = a_fineGridsPtr->layoutIterator();
      for (litFine.reset(); litFine.ok(); ++litFine)
        {
          Box coarsenedBox(a_fineGridsPtr->get(litFine()));
          coarsenedBox.coarsen(a_nRefFine);
          coarsenedBox &= a_mask.box();
          if (!coarsenedBox.isEmpty())
            {
              a_mask.setVal(maskCovered,coarsenedBox,0);
            }
        }
    }
}
Beispiel #4
0
void
AllRegularService::fillGraph(BaseFab<int>&        a_regIrregCovered,
                             Vector<IrregNode>&   a_nodes,
                             const Box&           a_validRegion,
                             const Box&           a_ghostRegion,
                             const ProblemDomain& a_domain,
                             const RealVect&      a_origin,
                             const Real&          a_dx) const
{
    PolyGeom::setVectDx(RealVect::Unit);
    //set all cells to regular
    a_regIrregCovered.setVal(1);
}
Beispiel #5
0
template < > int BaseFab<int>::test()
{
  int retbox = testBoxAndComp();
  if (retbox != 0)
    {
      pout() << "testboxandcomp failed" << endl;
      return retbox;
    }

  Box b(IntVect::Zero, IntVect::Unit);
  BaseFab<int> blerg;
  blerg.define(b, 1);
  int val = 4;
  blerg.setVal(val);
  for (BoxIterator bit(b); bit.ok();++bit)
    {
      if (blerg(bit(), 0) != val)
        {
          pout() << "setval or index busted" << endl;
          return -1;
        }
    }

  Box bcop(IntVect::Unit, 2*IntVect::Unit);
  BaseFab<int> bfcopy(bcop, 1);
  bfcopy.setVal(2*val);
  bfcopy.copy(blerg, 0, 0, 1);
  Box binter =bcop;
  binter &= b;
  for (BoxIterator bit(binter); bit.ok();++bit)
    {
      if (bfcopy(bit(), 0) != val)
        {
          pout() << "copy busted" << endl;
          return -2;
        }
    }

  return 0;
}
Beispiel #6
0
void
SlabService::fillGraph(BaseFab<int>&      a_regIrregCovered,
                       Vector<IrregNode>& a_nodes,
                       const Box&         a_validRegion,
                       const Box&         a_ghostRegion,
                       const ProblemDomain&         a_domain,
                       const RealVect&    a_origin,
                       const Real&        a_dx) const
{
  Box grownCovBox = grow(m_coveredRegion, 1);
  grownCovBox &= a_ghostRegion;
  IntVectSet ivsIrreg(grownCovBox);
  ivsIrreg -= m_coveredRegion;
  ivsIrreg &= a_domain;

  //set regirregcoverred flags
  CH_assert(a_regIrregCovered.box().contains(a_ghostRegion));

  //set every cell to regular
  a_regIrregCovered.setVal(1);
  for (BoxIterator bit(a_ghostRegion); bit.ok(); ++bit)
    {
      if (m_coveredRegion.contains(bit()))
        {
          //set covered cells to -1
          a_regIrregCovered(bit(), 0) = -1;
        }
      else if (ivsIrreg.contains(bit()))
        {
          //set irreg cells to 0
          a_regIrregCovered(bit(), 0) = 0;
        }
    }

  //now loop through irreg cells and make Nodes for them
  a_nodes.resize(0);
  for (IVSIterator ivsit(ivsIrreg); ivsit.ok(); ++ivsit)
    {
      const IntVect& iv = ivsit();
      if (a_validRegion.contains(iv))
        {
          IrregNode node;
          //first the obvious
          node.m_cell = iv;
          node.m_volFrac = 1.0;
          node.m_cellIndex = 0;
          node.m_volCentroid    = RealVect::Zero;
          //any time the next cell over is in the covered
          //region, there is no face.  If there is a cell
          //but it is outside the domain, the arc=-1 to signify
          //a boundary face.  Otherwise, the arc is -2 if it
          //is to a regular cell and 0 if it is to an irregular cell
          for (int idir = 0; idir < SpaceDim; idir++)
            {
              for (SideIterator sit; sit.ok(); ++sit)
                {
                  int arcIndex = node.index(idir, sit());
                  Vector<int>&      arcs     = node.m_arc[arcIndex];
                  Vector<Real>&     areaFracs= node.m_areaFrac[arcIndex];
                  Vector<RealVect>& faceCents= node.m_faceCentroid[arcIndex];
                  IntVect otherIV = iv + sign(sit())*BASISV(idir);
                  if (m_coveredRegion.contains(otherIV))
                    {
                      //do nothing, covered face. leave the vector empty
                    }
                  else
                    {
                      int otherCellIndex;
                      if (ivsIrreg.contains(otherIV))
                        {
                          //arc irregular cell inside the domain
                          otherCellIndex = 0;
                        }
                      else if (!a_domain.contains(otherIV))
                        {
                          //boundary face
                          otherCellIndex = -1;
                        }
                      else
                        {
                          //arc to regular cell
                          otherCellIndex = -2;
                        }
                      arcs.push_back(otherCellIndex);
                      Real     areaFrac = 1.0;
                      RealVect faceCent = RealVect::Zero;

                      areaFracs.push_back(areaFrac);
                      faceCents.push_back(faceCent);
                    } //end otherIV not covered
                }
            }
          //the boundary centroid and normal
          //depend on which side is covered

          for (int idir = 0; idir < SpaceDim; idir++)
            {
              for (SideIterator sit; sit.ok(); ++sit)
                {
                  int arcIndex = node.index(idir, sit());
                  Vector<int>& arcs = node.m_arc[arcIndex];
                  if (arcs.size() == 0)
                    {
                      int isign = sign(sit());
                      node.m_bndryCentroid[idir] = Real(isign)*0.5;
                    }
                }
            }
          a_nodes.push_back(node);
        }
    }
}
Beispiel #7
0
void
BaseFab<T>::maskLT (BaseFab<int>& mask) const
   {
     mask.setVal(0);
   }
void
NeumannConductivityDomainBC::
getFaceFlux(BaseFab<Real>&        a_faceFlux,
            const BaseFab<Real>&  a_phi,
            const RealVect&       a_probLo,
            const RealVect&       a_dx,
            const int&            a_idir,
            const Side::LoHiSide& a_side,
            const DataIndex&      a_dit,
            const Real&           a_time,
            const bool&           a_useHomogeneous)
{
  CH_TIME("NeumannPoissonDomainBC::getFaceFlux");
  CH_assert(a_phi.nComp() == 1);
  for (int comp=0; comp<a_phi.nComp(); comp++)
    {

      const Box& box = a_faceFlux.box();

      int iside;

      if (a_side == Side::Lo)
        {
          iside = 1;
        }
      else
        {
          iside = -1;
        }

      if (a_useHomogeneous)
        {
          Real value = 0.0;

          a_faceFlux.setVal(iside * value);
        }
      else
        {
          if (m_isFunction)
            {
              BoxIterator bit(box);

              for (bit.begin(); bit.ok(); ++bit)
                {
                  const IntVect& iv = bit();

                  RealVect point = EBArith::getIVLocation(iv,a_dx,a_probLo);
                  point[a_idir] -= iside * 0.5 * a_dx[a_idir];//point is now at the face center

                  RealVect normal = RealVect::Zero;
                  normal[a_idir] = iside;

                  a_faceFlux(iv,comp) = iside * m_flux->value(iv,a_dit,point,normal,a_time,comp);
                }
            }
          else
            {
              if (m_onlyHomogeneous)
                {
                  MayDay::Error("NeumannPoissonDomainBC::getFaceFlux called with undefined inhomogeneous BC");
                }

              Real value = m_value;

              a_faceFlux.setVal(iside * value);
            }
        }
    }

  //again, following the odd convention of EBAMRPoissonOp
  //(because I am reusing its BC classes),
  //the input flux here is CELL centered and the input box
  //is the box adjacent to the domain boundary on the valid side.
  //because I am not insane (yet) I will just shift the flux's box
  //over and multiply by the appropriate coefficient
  a_faceFlux.shiftHalf(a_idir, -sign(a_side));
  const Box& faceBox = a_faceFlux.box();
  const BaseFab<Real>&   regCoef = (*m_bcoef)[a_dit][a_idir].getSingleValuedFAB();
  int  isrc = 0;
  int  idst = 0;
  int  inum = 1;
  FORT_MULTIPLYTWOFAB(CHF_FRA(a_faceFlux),
                      CHF_CONST_FRA(regCoef),
                      CHF_BOX(faceBox),
                      CHF_INT(isrc),CHF_INT(idst),CHF_INT(inum));

  //shift flux back to cell centered land
  a_faceFlux.shiftHalf(a_idir,  sign(a_side));
}