Example #1
0
// ----------------------------------------------------------
void
CoarseAverageEdge::averageGridData(FluxBox& a_coarsenedFine,
                                   const FluxBox& a_fine) const
{
  for (int dir=0; dir<SpaceDim; dir++)
    {
      FArrayBox& coarseFab = a_coarsenedFine[dir];
      const FArrayBox& fineFab = a_fine[dir];

      const Box& coarseBox = coarseFab.box();

      // set up refinement box
      int boxHi = m_nRef-1;
      IntVect hiVect(D_DECL(boxHi,boxHi,boxHi));
      // don't want to index at all in dir direction --
      // instead, want to just march along edge.
      hiVect.setVal(dir,0);
      IntVect loVect(D_DECL(0,0,0));
      Box refBox(loVect, hiVect);

      FORT_AVERAGEEDGE( CHF_FRA(coarseFab),
                        CHF_CONST_FRA(fineFab),
                        CHF_BOX(coarseBox),
                        CHF_CONST_INT(dir),
                        CHF_CONST_INT(m_nRef),
                        CHF_BOX(refBox));
    }
}
Example #2
0
BaseFab<Real>&
BaseFab<Real>::saxpy (Real a, const BaseFab<Real>& src,
                      const Box&        srcbox,
                      const Box&        destbox,
                      int               srccomp,
                      int               destcomp,
                      int               numcomp)
{
    const int* destboxlo  = destbox.loVect();
    const int* destboxhi  = destbox.hiVect();
    const int* _th_plo    = loVect();
    const int* _th_phi    = hiVect();
    const int* _x_lo      = srcbox.loVect();
    const int* _x_plo     = src.loVect();
    const int* _x_phi     = src.hiVect();
    Real*       _th_p     = dataPtr(destcomp);
    const Real* _x_p      = src.dataPtr(srccomp);

    FORT_FASTSAXPY(_th_p,
                   ARLIM(_th_plo),
                   ARLIM(_th_phi),
                   D_DECL(destboxlo[0],destboxlo[1],destboxlo[2]),
                   D_DECL(destboxhi[0],destboxhi[1],destboxhi[2]),
                   &a,
                   _x_p,
                   ARLIM(_x_plo),
                   ARLIM(_x_phi),
                   D_DECL(_x_lo[0],_x_lo[1],_x_lo[2]),
                   &numcomp);

    return *this;
}
Example #3
0
BaseIF* makeVanes(const int&      num,
                  const Real&     thick,
                  const RealVect& normal,
                  const Real&     innerRadius,
                  const Real&     outerRadius,
                  const Real&     offset,
                  const Real&     height)
{
  RealVect zero(D_DECL(0.0,0.0,0.0));
  RealVect xAxis(D_DECL(1.0,0.0,0.0));

  BaseIF* oneVane = makeVane(thick,normal,innerRadius,outerRadius,offset,height);

  Vector<BaseIF*> eachVane;

  for (int i = 0; i < num; i++)
  {
    Real angle = i * 2*M_PI / num;

    TransformIF* currentVane = new TransformIF(*oneVane);
    currentVane->rotate(angle,zero,xAxis);

    eachVane.push_back(currentVane);
  }

  UnionIF* allVanes = new UnionIF(eachVane);

  return allVanes;
}
Example #4
0
BaseIF* makeVanes(const int&      num,
                  const Real&     thick,
                  const RealVect& normal,
                  const Real&     innerRadius,
                  const Real&     outerRadius,
                  const Real&     offset,
                  const Real&     height)
{
  RealVect zeroVect(D_DECL(0.0,0.0,0.0));
  RealVect xAxis(D_DECL(1.0,0.0,0.0));

  Vector<BaseIF*> eachVane;

  for (int i = 0; i < num; i++)
  {
    Real angle = i*2.*M_PI/num;

    BaseIF* oneVane = makeVane(thick,normal,innerRadius,outerRadius,offset,height,angle);

    eachVane.push_back(oneVane);
  }

  UnionIF* allVanes = new UnionIF(eachVane);

  return allVanes;
}
Example #5
0
int
main (int argc, char** argv)
{
    BoxLib::Initialize(argc, argv);
    the_prog_name = argv[0];
    parse_args(argv);

    BoxArray ba(nBoxs);

    ba.set(0, Box(IntVect(D_DECL(0,0,0)), IntVect(D_DECL(2,2,2))));

    for (int i = 1; i < nBoxs; i++)
    {
        ba.set(i,BoxLib::grow(ba[i-1],2));
    }

    MultiFab mf(ba, 2, 1);

    for (MFIter mfi(mf); mfi.isValid(); ++mfi)
    {
        mf[mfi.index()].setVal(mfi.index()+1);
    }
    //
    // Set cells in ghost region to zero.
    //
    mf.setBndry(0);

    static const std::string mf_name = "Spam-n-Eggs";

    Write_N_Read (mf,
                  mf_name);

    BoxLib::Finalize();
}
Example #6
0
BaseIF* makeVane(const Real&     thick,
                 const RealVect& normal,
                 const Real&     innerRadius,
                 const Real&     outerRadius,
                 const Real&     offset,
                 const Real&     height)
{
  RealVect zero(D_DECL(0.0,0.0,0.0));
  RealVect xAxis(D_DECL(1.0,0.0,0.0));
  bool inside = true;

  Vector<BaseIF*> vaneParts;

  // Each side of the vane (infinite)
  RealVect normal1(normal);
  RealVect point1(D_DECL(offset+height/2.0,-thick/2.0,0.0));
  PlaneIF plane1(normal1,point1,inside);

  vaneParts.push_back(&plane1);

  RealVect normal2(-normal);
  RealVect point2(D_DECL(offset+height/2.0,thick/2.0,0.0));
  PlaneIF plane2(normal2,point2,inside);

  vaneParts.push_back(&plane2);

  // Make sure we only get something to the right of the origin
  RealVect normal3(D_DECL(0.0,0.0,1.0));
  RealVect point3(D_DECL(0.0,0.0,0.0));
  PlaneIF plane3(normal3,point3,inside);

  vaneParts.push_back(&plane3);

  // Cut off the top and bottom
  RealVect normal4(D_DECL(1.0,0.0,0.0));
  RealVect point4(D_DECL(offset,0.0,0.0));
  PlaneIF plane4(normal4,point4,inside);

  vaneParts.push_back(&plane4);

  RealVect normal5(D_DECL(-1.0,0.0,0.0));
  RealVect point5(D_DECL(offset+height,0.0,0.0));
  PlaneIF plane5(normal5,point5,inside);

  vaneParts.push_back(&plane5);

  // The outside of the inner cylinder
  TiltedCylinderIF inner(innerRadius,xAxis,zero,!inside);

  vaneParts.push_back(&inner);

  // The inside of the outer cylinder
  TiltedCylinderIF outer(outerRadius,xAxis,zero,inside);

  vaneParts.push_back(&outer);

  IntersectionIF* vane = new IntersectionIF(vaneParts);

  return vane;
}
Example #7
0
void
BaseFab<Real>::performCopy (const BaseFab<Real>& src,
                            const Box&           srcbox,
                            int                  srccomp,
                            const Box&           destbox,
                            int                  destcomp,
                            int                  numcomp)
{
    BL_ASSERT(destbox.ok());
    BL_ASSERT(src.box().contains(srcbox));
    BL_ASSERT(box().contains(destbox));
    BL_ASSERT(destbox.sameSize(srcbox));
    BL_ASSERT(srccomp >= 0 && srccomp+numcomp <= src.nComp());
    BL_ASSERT(destcomp >= 0 && destcomp+numcomp <= nComp());

    if (destbox == domain && srcbox == src.box())
    {
        Real*       data_dst = dataPtr(destcomp);
        const Real* data_src = src.dataPtr(srccomp);

        for (long i = 0, N = numcomp*numpts; i < N; i++)
        {
            *data_dst++ = *data_src++;
        }
    }
    else
    {
        const int* destboxlo  = destbox.loVect();
        const int* destboxhi  = destbox.hiVect();
        const int* _th_plo    = loVect();
        const int* _th_phi    = hiVect();
        const int* _x_lo      = srcbox.loVect();
        const int* _x_plo     = src.loVect();
        const int* _x_phi     = src.hiVect();
        Real*       _th_p     = dataPtr(destcomp);
        const Real* _x_p      = src.dataPtr(srccomp);

        FORT_FASTCOPY(_th_p,
                      ARLIM(_th_plo),
                      ARLIM(_th_phi),
                      D_DECL(destboxlo[0],destboxlo[1],destboxlo[2]),
                      D_DECL(destboxhi[0],destboxhi[1],destboxhi[2]),
                      _x_p,
                      ARLIM(_x_plo),
                      ARLIM(_x_phi),
                      D_DECL(_x_lo[0],_x_lo[1],_x_lo[2]),
                      &numcomp);
    }
}
Example #8
0
void do_geo(DisjointBoxLayout&              a_dbl,
            EBISLayout       &              a_ebisl,
            Box              &              a_domain,
            Real             &              a_dx )
{

  //define grids
  int len = 32;
  int mid = len/2;
  Real xdom = 1.0;
  a_dx = xdom/len;
  const IntVect hi = (len-1)*IntVect::Unit;
  a_domain=  Box(IntVect::Zero, hi);
  Vector<Box> boxes(4);
  Vector<int> procs(4);
  boxes[0] = Box(IntVect(D_DECL(0  ,  0,   0)), IntVect(D_DECL(mid-1, mid-1, len-1)));
  boxes[1] = Box(IntVect(D_DECL(0  ,mid,   0)), IntVect(D_DECL(mid-1, len-1, len-1)));
  boxes[2] = Box(IntVect(D_DECL(mid,  0,   0)), IntVect(D_DECL(len-1, mid-1, len-1)));
  boxes[3] = Box(IntVect(D_DECL(mid,mid,   0)), IntVect(D_DECL(len-1, len-1, len-1)));

  LoadBalance(procs, boxes);
  /**
  int loProc = 0;
  int hiProc = numProc() -1;
  procs[0] = loProc;
  procs[1] = hiProc;
  procs[2] = loProc;
  procs[3] = hiProc;
  **/

  a_dbl = DisjointBoxLayout(boxes, procs);

  //define geometry
  RealVect rampNormal = RealVect::Zero;
  rampNormal[0] = -0.5;
  rampNormal[1] = 0.866025404;

  Real rampAlpha = -0.0625;

  RealVect rampPoint = RealVect::Zero;
  rampPoint[0] = rampAlpha / rampNormal[0];

  bool inside = true;

  PlaneIF ramp(rampNormal,rampPoint,inside);

  RealVect vectDx = RealVect::Unit;
  vectDx *= a_dx;

  GeometryShop mygeom( ramp, 0, vectDx );
  RealVect origin = RealVect::Zero;

  EBIndexSpace *ebisPtr = Chombo_EBIS::instance();
  ebisPtr->define(a_domain, origin, a_dx, mygeom);

  //fill layout
  ebisPtr->fillEBISLayout(a_ebisl, a_dbl, a_domain, 4 );
}
Example #9
0
    void average_face_to_cellcenter (MultiFab& cc, int dcomp, const std::vector<MultiFab*>& fc)
    {
	BL_ASSERT(cc.nComp() >= dcomp + BL_SPACEDIM);
	BL_ASSERT(fc.size() == BL_SPACEDIM);
	BL_ASSERT(fc[0]->nComp() == 1);

	Real dx[3] = {1.0,1.0,1.0};
	Real problo[3] = {0.,0.,0.};
	int coord_type = 0;

#ifdef _OPENMP
#pragma omp parallel
#endif
	for (MFIter mfi(cc,true); mfi.isValid(); ++mfi) 
	{
	    const Box& bx = mfi.tilebox();

	    BL_FORT_PROC_CALL(BL_AVG_FC_TO_CC,bl_avg_fc_to_cc)
		(bx.loVect(), bx.hiVect(),
		 BL_TO_FORTRAN_N(cc[mfi],dcomp),
		 D_DECL(BL_TO_FORTRAN((*fc[0])[mfi]),
			BL_TO_FORTRAN((*fc[1])[mfi]),
			BL_TO_FORTRAN((*fc[2])[mfi])),
		 dx, problo, coord_type);
	}
    }
Example #10
0
    void average_face_to_cellcenter (MultiFab& cc, const PArray<MultiFab>& fc, const Geometry& geom)
    {
	BL_ASSERT(cc.nComp() >= BL_SPACEDIM);
	BL_ASSERT(fc.size() == BL_SPACEDIM);
	BL_ASSERT(fc[0].nComp() == 1); // We only expect fc to have the gradient perpendicular to the face

	const Real* dx     = geom.CellSize();
	const Real* problo = geom.ProbLo();
	int coord_type = Geometry::Coord();

#ifdef _OPENMP
#pragma omp parallel
#endif
	for (MFIter mfi(cc,true); mfi.isValid(); ++mfi) 
	{
	    const Box& bx = mfi.tilebox();

	    BL_FORT_PROC_CALL(BL_AVG_FC_TO_CC,bl_avg_fc_to_cc)
		(bx.loVect(), bx.hiVect(),
		 BL_TO_FORTRAN(cc[mfi]),
		 D_DECL(BL_TO_FORTRAN(fc[0][mfi]),
			BL_TO_FORTRAN(fc[1][mfi]),
			BL_TO_FORTRAN(fc[2][mfi])),
		 dx, problo, coord_type);
	}
    }
Example #11
0
void
ErrorRec::ErrorFunc2::operator () (int* tag, D_DECL(const int&tlo0,const int&tlo1,const int&tlo2), 
                                   D_DECL(const int&thi0,const int&thi1,const int&thi2), 
                                   const int* tagval, const int* clearval,
                                   Real* data, D_DECL(const int&dlo0,const int&dlo1,const int&dlo2), 
                                   D_DECL(const int&dhi0,const int&dhi1,const int&dhi2), 
                                   const int* lo, const int * hi, const int* nvar,
                                   const int* domain_lo, const int* domain_hi,
                                   const Real* dx, const int* level, const Real* avg) const
{
    BL_ASSERT(m_func != 0);

    m_func(tag,D_DECL(tlo0,tlo1,tlo2),D_DECL(thi0,thi1,thi2),
           tagval,clearval,data,D_DECL(dlo0,dlo1,dlo2),D_DECL(dhi0,dhi1,dhi2),lo,hi,nvar,
           domain_lo,domain_hi,dx,level,avg);
}
Example #12
0
void
ABec4::compFlux (D_DECL(MultiFab &xflux, MultiFab &yflux, MultiFab &zflux),
		 MultiFab& in, const BC_Mode& bc_mode,
		 int src_comp, int dst_comp, int num_comp, int bnd_comp)
{
  compFlux(D_DECL(xflux, yflux, zflux), in, true, bc_mode, src_comp, dst_comp, num_comp, bnd_comp);
}
Example #13
0
Box
BoxLib::refine (const Box& b,
                int        ref_ratio)
{
    Box result = b;
    result.refine(IntVect(D_DECL(ref_ratio,ref_ratio,ref_ratio)));
    return result;
}
Example #14
0
Box
BoxLib::coarsen (const Box& b,
                 int        ref_ratio)
{
    Box result = b;
    result.coarsen(IntVect(D_DECL(ref_ratio,ref_ratio,ref_ratio)));
    return result;
}
Example #15
0
const IntVect
BoxLib::coarsen (const IntVect& p,
		 int            s)
{
    BL_ASSERT(s > 0);
    IntVect v = p;
    return v.coarsen(IntVect(D_DECL(s,s,s)));
}
Example #16
0
Box::Box (const IntVect& small,
          const int*     vec_len)
    :
    smallend(small),
    bigend(D_DECL(small[0]+vec_len[0]-1,
                  small[1]+vec_len[1]-1,
                  small[2]+vec_len[2]-1))
{}
Example #17
0
BaseIF* makeChamber(const Real& radius,
                    const Real& thick,
                    const Real& offset,
                    const Real& height)
{
  RealVect zero(D_DECL(0.0,0.0,0.0));
  RealVect xAxis(D_DECL(1.0,0.0,0.0));
  bool inside = true;

  Vector<BaseIF*> pieces;

  // Create a chamber
  TiltedCylinderIF chamberOut(radius + thick/2.0,xAxis,zero, inside);
  TiltedCylinderIF chamberIn (radius - thick/2.0,xAxis,zero,!inside);

  IntersectionIF infiniteChamber(chamberIn,chamberOut);

  pieces.push_back(&infiniteChamber);

  RealVect normal1(D_DECL(1.0,0.0,0.0));
  RealVect point1(D_DECL(offset,0.0,0.0));
  PlaneIF plane1(normal1,point1,inside);

  pieces.push_back(&plane1);

  RealVect normal2(D_DECL(-1.0,0.0,0.0));
  RealVect point2(D_DECL(offset+height,0.0,0.0));
  PlaneIF plane2(normal2,point2,inside);

  pieces.push_back(&plane2);

  IntersectionIF* chamber = new IntersectionIF(pieces);

  return chamber;
}
Example #18
0
void
ParticleBase::CIC_Cells_Fracs_Basic (const ParticleBase& p,
                                     const Real*         plo,
                                     const Real*         dx,
                                     Real*               fracs,
                                     IntVect*            cells)
{
    //
    // "fracs" should be dimensioned: Real    fracs[D_TERM(2,+2,+4)]
    //
    // "cells" should be dimensioned: IntVect cells[D_TERM(2,+2,+4)]
    //
    const Real len[BL_SPACEDIM] = { D_DECL((p.m_pos[0]-plo[0])/dx[0] + Real(0.5),
                                           (p.m_pos[1]-plo[1])/dx[1] + Real(0.5),
                                           (p.m_pos[2]-plo[2])/dx[2] + Real(0.5)) };

    const IntVect cell(D_DECL(floor(len[0]), floor(len[1]), floor(len[2])));

    const Real frac[BL_SPACEDIM] = { D_DECL(len[0]-cell[0], len[1]-cell[1], len[2]-cell[2]) };

    ParticleBase::CIC_Fracs(frac, fracs);
    ParticleBase::CIC_Cells(cell, cells);
}
Example #19
0
void
CellBilinear::interp (const FArrayBox&  crse,
                      int               crse_comp,
                      FArrayBox&        fine,
                      int               fine_comp,
                      int               ncomp,
                      const Box&        fine_region,
                      const IntVect &   ratio,
                      const Geometry& /*crse_geom*/,
                      const Geometry& /*fine_geom*/,
                      Array<BCRec>&   /*bcr*/,
                      int               actual_comp,
                      int               actual_state)
{
    BL_PROFILE("CellBilinear::interp()");
#if (BL_SPACEDIM == 3)
    BoxLib::Error("interp: not implemented");
#endif
    //
    // Set up to call FORTRAN.
    //
    const int* clo = crse.box().loVect();
    const int* chi = crse.box().hiVect();
    const int* flo = fine.loVect();
    const int* fhi = fine.hiVect();
    const int* lo  = fine_region.loVect();
    const int* hi  = fine_region.hiVect();
    int num_slope  = D_TERM(2,*2,*2)-1;
    int len0       = crse.box().length(0);
    int slp_len    = num_slope*len0;

    Array<Real> slope(slp_len);

    int strp_len = len0*ratio[0];

    Array<Real> strip(strp_len);

    int strip_lo = ratio[0] * clo[0];
    int strip_hi = ratio[0] * chi[0];

    const Real* cdat  = crse.dataPtr(crse_comp);
    Real*       fdat  = fine.dataPtr(fine_comp);
    const int* ratioV = ratio.getVect();

    FORT_CBINTERP (cdat,ARLIM(clo),ARLIM(chi),ARLIM(clo),ARLIM(chi),
                   fdat,ARLIM(flo),ARLIM(fhi),ARLIM(lo),ARLIM(hi),
                   D_DECL(&ratioV[0],&ratioV[1],&ratioV[2]),&ncomp,
                   slope.dataPtr(),&num_slope,strip.dataPtr(),&strip_lo,&strip_hi,
                   &actual_comp,&actual_state);
}
Example #20
0
BaseFab<Real>&
BaseFab<Real>::protected_divide (const BaseFab<Real>& src,
                                 const Box&           srcbox,
                                 const Box&           destbox,
                                 int                  srccomp,
                                 int                  destcomp,
                                 int                  numcomp)
{
    BL_ASSERT(destbox.ok());
    BL_ASSERT(src.box().contains(srcbox));
    BL_ASSERT(box().contains(destbox));
    BL_ASSERT(destbox.sameSize(srcbox));
    BL_ASSERT(srccomp >= 0 && srccomp+numcomp <= src.nComp());
    BL_ASSERT(destcomp >= 0 && destcomp+numcomp <= nComp());

    const int* destboxlo  = destbox.loVect();
    const int* destboxhi  = destbox.hiVect();
    const int* _th_plo    = loVect();
    const int* _th_phi    = hiVect();
    const int* _x_lo      = srcbox.loVect();
    const int* _x_plo     = src.loVect();
    const int* _x_phi     = src.hiVect();
    Real*       _th_p     = dataPtr(destcomp);
    const Real* _x_p      = src.dataPtr(srccomp);

    FORT_FASTPROTDIVIDE(_th_p,
                        ARLIM(_th_plo),
                        ARLIM(_th_phi),
                        D_DECL(destboxlo[0],destboxlo[1],destboxlo[2]),
                        D_DECL(destboxhi[0],destboxhi[1],destboxhi[2]),
                        _x_p,
                        ARLIM(_x_plo),
                        ARLIM(_x_phi),
                        D_DECL(_x_lo[0],_x_lo[1],_x_lo[2]),
                        &numcomp);
    return *this;
}
Example #21
0
Real
Adv::estTimeStep (Real)
{
    // This is just a dummy value to start with 
    Real dt_est  = 1.0e+20;

    const Real* dx = geom.CellSize();
    const Real* prob_lo = geom.ProbLo();
    const Real cur_time = state[State_Type].curTime();
    const MultiFab& S_new = get_new_data(State_Type);

#ifdef _OPENMP
#pragma omp parallel reduction(min:dt_est)
#endif
    {
	FArrayBox uface[BL_SPACEDIM];

	for (MFIter mfi(S_new, true); mfi.isValid(); ++mfi)
	{
	    for (int i = 0; i < BL_SPACEDIM ; i++) {
		const Box& bx = mfi.nodaltilebox(i);
		uface[i].resize(bx,1);
	    }

	    BL_FORT_PROC_CALL(GET_FACE_VELOCITY,get_face_velocity)
		(level, cur_time,
		 D_DECL(BL_TO_FORTRAN(uface[0]),
			BL_TO_FORTRAN(uface[1]),
			BL_TO_FORTRAN(uface[2])),
		 dx, prob_lo);

	    for (int i = 0; i < BL_SPACEDIM; ++i) {
		Real umax = uface[i].norm(0);
		if (umax > 1.e-100) {
		    dt_est = std::min(dt_est, dx[i] / umax);
		}
	    }
	}
    }

    ParallelDescriptor::ReduceRealMin(dt_est);
    dt_est *= cfl;

    if (verbose && ParallelDescriptor::IOProcessor())
	std::cout << "Adv::estTimeStep at level " << level << ":  dt_est = " << dt_est << std::endl;
    
    return dt_est;
}
Example #22
0
    void average_edge_to_cellcenter (MultiFab& cc, int dcomp, const std::vector<MultiFab*>& edge)
    {
	BL_ASSERT(cc.nComp() >= dcomp + BL_SPACEDIM);
	BL_ASSERT(edge.size() == BL_SPACEDIM);
	BL_ASSERT(edge[0]->nComp() == 1);
#ifdef _OPENMP
#pragma omp parallel
#endif
	for (MFIter mfi(cc,true); mfi.isValid(); ++mfi) 
	{
	    const Box& bx = mfi.tilebox();

	    BL_FORT_PROC_CALL(BL_AVG_EG_TO_CC,bl_avg_eg_to_cc)
		(bx.loVect(), bx.hiVect(),
		 BL_TO_FORTRAN_N(cc[mfi],dcomp),
		 D_DECL(BL_TO_FORTRAN((*edge[0])[mfi]),
			BL_TO_FORTRAN((*edge[1])[mfi]),
			BL_TO_FORTRAN((*edge[2])[mfi])));
	}	
    }
Example #23
0
/** InputParams are the things in restart.inputs.
 *  This is the only place we use ParmParse.
*/
EBRestart::InputParams::InputParams(
    int argc, char** argv, const char* a_infilename )
  : n_cell(SpaceDim),
    prob_lo(SpaceDim, 1.0),
    ncomps(0),
    ghosts(0),
    first_step(0),
    test_mode(0),
    test_pass(1),
    verbose(0)
{
  ParmParse pp(argc-1, argv+1, 0, a_infilename);
  pp.getarr("n_cell",n_cell,0,SpaceDim);
  CH_assert(n_cell.size() == SpaceDim);
  pp.getarr("prob_lo",prob_lo,0,SpaceDim);
  pp.get("prob_hi",prob_hi);
  Vector<Real> vcenter;
  pp.getarr("center",vcenter,0,SpaceDim);
  center = RealVect( D_DECL(vcenter[0],vcenter[1],vcenter[2]) );

  pp.get("radius",radius);
  pp.get("nlevs",nlevs);
  pp.get("ncomps",ncomps);
  pp.query("ghosts",ghosts);
  pp.get("refratio",refratio);

  pp.get("nsteps",nsteps);
  pp.get("first_step",first_step);
  CH_assert( first_step < nsteps );

  pp.get("blocking_factor",blocking_factor);
  pp.get("buffer_size",buffer_size);
  pp.get("max_size",max_size);
  pp.get("test_mode",test_mode);

  pp.query("test_pass",test_pass);
  CH_assert( (test_pass == 1) || (test_pass == 2) );

  pp.query("verbose", verbose);
}
Example #24
0
void
NodeBilinear::interp (const FArrayBox&  crse,
                      int               crse_comp,
                      FArrayBox&        fine,
                      int               fine_comp,
                      int               ncomp,
                      const Box&        fine_region,
                      const IntVect&    ratio,
                      const Geometry& /*crse_geom */,
                      const Geometry& /*fine_geom */,
                      Array<BCRec>&   /*bcr*/,
                      int               actual_comp,
                      int               actual_state)
{
    BL_PROFILE("NodeBilinear::interp()");
    //
    // Set up to call FORTRAN.
    //
    const int* clo = crse.box().loVect();
    const int* chi = crse.box().hiVect();
    const int* flo = fine.loVect();
    const int* fhi = fine.hiVect();
    const int* lo  = fine_region.loVect();
    const int* hi  = fine_region.hiVect();
    int num_slope  = D_TERM(2,*2,*2)-1;
    int len0       = crse.box().length(0);
    int slp_len    = num_slope*len0;

    Array<Real> strip(slp_len);

    const Real* cdat  = crse.dataPtr(crse_comp);
    Real*       fdat  = fine.dataPtr(fine_comp);
    const int* ratioV = ratio.getVect();

    FORT_NBINTERP (cdat,ARLIM(clo),ARLIM(chi),ARLIM(clo),ARLIM(chi),
                   fdat,ARLIM(flo),ARLIM(fhi),ARLIM(lo),ARLIM(hi),
                   D_DECL(&ratioV[0],&ratioV[1],&ratioV[2]),&ncomp,
                   strip.dataPtr(),&num_slope,&actual_comp,&actual_state);
}
Example #25
0
    void average_cellcenter_to_face (PArray<MultiFab>& fc, const MultiFab& cc, const Geometry& geom)
    {
	BL_ASSERT(cc.nComp() == 1);
	BL_ASSERT(cc.nGrow() >= 1);
	BL_ASSERT(fc.size() == BL_SPACEDIM);
	BL_ASSERT(fc[0].nComp() == 1); // We only expect fc to have the gradient perpendicular to the face

	const Real* dx     = geom.CellSize();
	const Real* problo = geom.ProbLo();
	int coord_type = Geometry::Coord();

#ifdef _OPENMP
#pragma omp parallel
#endif
	for (MFIter mfi(cc,true); mfi.isValid(); ++mfi) 
	{
	    const Box& xbx = mfi.nodaltilebox(0);
#if (BL_SPACEDIM > 1)
	    const Box& ybx = mfi.nodaltilebox(1);
#endif
#if (BL_SPACEDIM == 3)
	    const Box& zbx = mfi.nodaltilebox(2);
#endif
	    
	    BL_FORT_PROC_CALL(BL_AVG_CC_TO_FC,bl_avg_cc_to_fc)
		(xbx.loVect(), xbx.hiVect(),
#if (BL_SPACEDIM > 1)
		 ybx.loVect(), ybx.hiVect(),
#endif
#if (BL_SPACEDIM == 3)
		 zbx.loVect(), zbx.hiVect(),
#endif
		 D_DECL(BL_TO_FORTRAN(fc[0][mfi]),
			BL_TO_FORTRAN(fc[1][mfi]),
			BL_TO_FORTRAN(fc[2][mfi])),
		 BL_TO_FORTRAN(cc[mfi]),
		 dx, problo, coord_type);
	}
    }
Example #26
0
std::vector<IntVect>
Periodicity::shiftIntVect () const
{
    std::vector<IntVect> r;

    int per[3] = {0,0,0};
    int jmp[3] = {1,1,1};

    for (int i = 0; i < BL_SPACEDIM; ++i) {
	if (isPeriodic(i)) {
	    per[i] = jmp[i] = period[i];
	}
    }

    for (int i = -per[0]; i <= per[0]; i += jmp[0]) {
    for (int j = -per[1]; j <= per[1]; j += jmp[1]) {
    for (int k = -per[2]; k <= per[2]; k += jmp[2]) {
	r.push_back(IntVect(D_DECL(i,j,k)));
    }
    }
    }

    return r;
}
Example #27
0
#include "BaseIVFactory.H"
#include "BaseIFFactory.H"
#include "BaseIFFAB.H"
#include "EBFluxFAB.H"
#include "FaceIterator.H"
#include "REAL.H"
#include "EBCellFactory.H"
#include "FaceIterator.H"
#include "EBPatchAdvectF_F.H"
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <string>
#include "EBAMRIO.H"
#include "NamespaceHeader.H"
const IntVect    f_ivLo(D_DECL(143,31,0));
const IntVect    f_ivHi(D_DECL(143,32,0));
const IntVect f_ivLoGho(D_DECL(144,31,0));
const IntVect f_ivHiGho(D_DECL(144,32,0));

void
EBLevelAdvect::
resetBCs(const RefCountedPtr<EBPhysIBCFactory>&  a_advectBC)
{
  if (m_isDefined)
    {
      for (DataIterator dit = m_ebPatchAdvect.dataIterator(); dit.ok(); ++dit)
        {
          m_ebPatchAdvect[dit()]->setEBPhysIBC(*a_advectBC);
        }
    }
Example #28
0
// Constant Dirichlet Boundary condition
void constDiri(Real* pos, int* dir, Side::LoHiSide* side, Real* a_values)
{
  a_values[0] = exactSolution(RealVect(D_DECL(pos[0], pos[1], pos[2])));
}
Example #29
0
BaseIF* makePlate(const Real& height,
                  const Real& thick,
                  const Real& radius,
                  const int&  doHoles,
                  const Real& holeRadius,
                  const Real& holeSpace)
{
  RealVect zero(D_DECL(0.0,0.0,0.0));
  RealVect xAxis(D_DECL(1.0,0.0,0.0));
  bool inside = true;

  // Create the plate without holes
  Vector<BaseIF*> pieces;

  RealVect normal1(D_DECL(1.0,0.0,0.0));
  RealVect point1(D_DECL(height,0.0,0.0));
  PlaneIF plane1(normal1,point1,inside);

  pieces.push_back(&plane1);

  RealVect normal2(D_DECL(-1.0,0.0,0.0));
  RealVect point2(D_DECL(height+thick,0.0,0.0));
  PlaneIF plane2(normal2,point2,inside);

  pieces.push_back(&plane2);

  TiltedCylinderIF middle(radius,xAxis,zero,inside);

  pieces.push_back(&middle);

  IntersectionIF plate(pieces);

  // Make the drills
  Vector<BaseIF*> drillBits;

  // Compute how many drills are needed in each direciton - 2*num+1 -
  // conservatively
  int num = (int)((radius - holeRadius) / holeSpace + 1.0);

  if (doHoles != 0)
  {
    for (int i = -num; i <= num; i++)
    {
      for (int j = -num; j <= num; j++)
      {
        RealVect center(D_DECL(0.0,i*holeSpace,j*holeSpace));
        TiltedCylinderIF* drill = new TiltedCylinderIF(holeRadius,xAxis,center,inside);

        drillBits.push_back(drill);
      }
    }
  }

  UnionIF drills(drillBits);
  ComplementIF notDrills(drills,true);

  // Drill the plate
  IntersectionIF* holyPlate = new IntersectionIF(plate,notDrills);

  return holyPlate;
}
Example #30
0
BaseIF* makeVane(const Real&     thick,
                 const RealVect& normal,
                 const Real&     innerRadius,
                 const Real&     outerRadius,
                 const Real&     offset,
                 const Real&     height,
                 const Real&     angle)
{
  RealVect zeroVect(D_DECL(0.0,0.0,0.0));
  RealVect xAxis(D_DECL(1.0,0.0,0.0));
  bool inside = true;

  Vector<BaseIF*> vaneParts;

  Real sinTheta = sin(angle);
#if CH_SPACEDIM == 3
  Real cosTheta = cos(angle);

  // Each side of the vane (infinite)
  // rotate the normal around x-axis
  RealVect normal1(D_DECL(normal[0],cosTheta*normal[1]-sinTheta*normal[2],sinTheta*normal[1]+cosTheta*normal[2]));
  // rotate point on top of vane around x-axis
  RealVect point(D_DECL(offset+height/2.0,-thick/2.0,0.0));
  RealVect point1(D_DECL(point[0],cosTheta*point[1]-sinTheta*point[2],sinTheta*point[1]+cosTheta*point[2]));
  PlaneIF plane1(normal1,point1,inside);

  vaneParts.push_back(&plane1);

  RealVect normal2(-normal1);
  // rotate point on bottom (-point[2] of vane around x-axis
  RealVect point2(D_DECL(point[0],-cosTheta*point[1]-sinTheta*point[2],-sinTheta*point[1]+cosTheta*point[2]));
  PlaneIF plane2(normal2,point2,inside);

  vaneParts.push_back(&plane2);
#endif

  // Make sure we only get something to the right of the origin
  RealVect normal3(D_DECL(0.0,-sinTheta,cosTheta));
  RealVect point3(D_DECL(0.0,0.0,0.0));
  PlaneIF plane3(normal3,point3,inside);

  vaneParts.push_back(&plane3);

  // Cut off the top and bottom
  RealVect normal4(D_DECL(1.0,0.0,0.0));
  RealVect point4(D_DECL(offset,0.0,0.0));
  PlaneIF plane4(normal4,point4,inside);

  vaneParts.push_back(&plane4);

  RealVect normal5(D_DECL(-1.0,0.0,0.0));
  RealVect point5(D_DECL(offset+height,0.0,0.0));
  PlaneIF plane5(normal5,point5,inside);

  vaneParts.push_back(&plane5);

  // The outside of the inner cylinder
  TiltedCylinderIF inner(innerRadius,xAxis,zeroVect,!inside);

  vaneParts.push_back(&inner);

  // The inside of the outer cylinder
  TiltedCylinderIF outer(outerRadius,xAxis,zeroVect,inside);

  vaneParts.push_back(&outer);

  IntersectionIF* vane = new IntersectionIF(vaneParts);

  return vane;
}