MCMultiGrid::MCMultiGrid (MCLinOp &_lp) : initialsolution(0), Lp(_lp) { Initialize(); maxiter = def_maxiter; numiter = def_numiter; nu_0 = def_nu_0; nu_1 = def_nu_1; nu_2 = def_nu_2; nu_f = def_nu_f; usecg = def_usecg; verbose = def_verbose; rtol_b = def_rtol_b; atol_b = def_atol_b; nu_b = def_nu_b; numLevelsMAX = def_numLevelsMAX; numlevels = numLevels(); numcomps = _lp.numberComponents(); if ( ParallelDescriptor::IOProcessor() && (verbose > 2) ) { BoxArray tmp = Lp.boxArray(); std::cout << "MCMultiGrid: numlevels = " << numlevels << ": ngrid = " << tmp.size() << ", npts = ["; for ( int i = 0; i < numlevels; ++i ) { if ( i > 0 ) tmp.coarsen(2); std::cout << tmp.d_numPts() << " "; } std::cout << "]" << '\n'; std::cout << "MCMultiGrid: " << numlevels << " multigrid levels created for this solve" << '\n'; } if ( ParallelDescriptor::IOProcessor() && (verbose > 4) ) { std::cout << "Grids: " << '\n'; BoxArray tmp = Lp.boxArray(); for (int i = 0; i < numlevels; ++i) { Orientation face(0, Orientation::low); const DistributionMapping& map = Lp.bndryData().bndryValues(face).DistributionMap(); if (i > 0) tmp.coarsen(2); std::cout << " Level: " << i << '\n'; for (int k = 0; k < tmp.size(); k++) { const Box& b = tmp[k]; std::cout << " [" << k << "]: " << b << " "; for (int j = 0; j < BL_SPACEDIM; j++) std::cout << b.length(j) << ' '; std::cout << ":: " << map[k] << '\n'; } } } }
BoxList::BoxList (const BoxArray &ba) : lbox(), btype() { if (ba.size() > 0) btype = ba[0].ixType(); for (int i = 0, N = ba.size(); i < N; ++i) push_back(ba[i]); }
MultiFab_C_to_F::MultiFab_C_to_F (const Geometry& geom, const DistributionMapping& dmap, const BoxArray& ba) { BL_ASSERT(count == 0); count++; int nb = ba.size(); int dm = BL_SPACEDIM; std::vector<int> lo(nb*dm); std::vector<int> hi(nb*dm); for ( int i = 0; i < nb; ++i ) { const Box& bx = BoxLib::enclosedCells(ba[i]); for ( int j = 0; j < dm; ++j ) { lo[j + i*dm] = bx.smallEnd(j); hi[j + i*dm] = bx.bigEnd(j); } } const Box& domain = geom.Domain(); int pm[dm]; for ( int i = 0; i < dm; ++i ) { pm[i] = geom.isPeriodic(i)? 1 : 0; } const Array<int>& pmap = dmap.ProcessorMap(); build_layout_from_c(nb, dm, &lo[0], &hi[0], domain.loVect(), domain.hiVect(), pm, pmap.dataPtr()); }
void BndryRegister::setBoxes (const BoxArray& _grids) { BL_ASSERT(grids.size() == 0); BL_ASSERT(_grids.size() > 0); BL_ASSERT(_grids[0].cellCentered()); grids.define(_grids); // // Check that bndry regions are not allocated. // for (int k = 0; k < 2*BL_SPACEDIM; k++) BL_ASSERT(bndry[k].size() == 0); }
void MCLinOp::applyBC (MultiFab& inout, int level, MCBC_Mode bc_mode) { // // The inout MultiFab must have at least MCLinOp_grow ghost cells // for applyBC() // BL_ASSERT(inout.nGrow() >= MCLinOp_grow); // // The inout MultiFab must have at least Periodic_BC_grow cells for the // algorithms taking care of periodic boundary conditions. // BL_ASSERT(inout.nGrow() >= MCLinOp_grow); // // No coarsened boundary values, cannot apply inhomog at lev>0. // BL_ASSERT(!(level>0 && bc_mode == MCInhomogeneous_BC)); int flagden = 1; // fill in the bndry data and undrrelxr int flagbc = 1; // with values if (bc_mode == MCHomogeneous_BC) flagbc = 0; // nodata if homog int nc = inout.nComp(); BL_ASSERT(nc == numcomp ); inout.setBndry(-1.e30); inout.FillBoundary(); prepareForLevel(level); geomarray[level].FillPeriodicBoundary(inout,0,nc); // // Fill boundary cells. // #ifdef _OPENMP #pragma omp parallel #endif for (MFIter mfi(inout); mfi.isValid(); ++mfi) { const int gn = mfi.index(); BL_ASSERT(gbox[level][gn] == inout.box(gn)); const BndryData::RealTuple& bdl = bgb.bndryLocs(gn); const Array< Array<BoundCond> >& bdc = bgb.bndryConds(gn); const MaskTuple& msk = maskvals[level][gn]; for (OrientationIter oitr; oitr; ++oitr) { const Orientation face = oitr(); FabSet& f = (*undrrelxr[level])[face]; FabSet& td = (*tangderiv[level])[face]; int cdr(face); const FabSet& fs = bgb.bndryValues(face); Real bcl = bdl[face]; const Array<BoundCond>& bc = bdc[face]; const int *bct = (const int*) bc.dataPtr(); const FArrayBox& fsfab = fs[gn]; const Real* bcvalptr = fsfab.dataPtr(); // // Way external derivs stored. // const Real* exttdptr = fsfab.dataPtr(numcomp); const int* fslo = fsfab.loVect(); const int* fshi = fsfab.hiVect(); FArrayBox& inoutfab = inout[gn]; FArrayBox& denfab = f[gn]; FArrayBox& tdfab = td[gn]; #if BL_SPACEDIM==2 int cdir = face.coordDir(), perpdir = -1; if (cdir == 0) perpdir = 1; else if (cdir == 1) perpdir = 0; else BoxLib::Abort("MCLinOp::applyBC(): bad logic"); const Mask& m = *msk[face]; const Mask& mphi = *msk[Orientation(perpdir,Orientation::high)]; const Mask& mplo = *msk[Orientation(perpdir,Orientation::low)]; FORT_APPLYBC( &flagden, &flagbc, &maxorder, inoutfab.dataPtr(), ARLIM(inoutfab.loVect()), ARLIM(inoutfab.hiVect()), &cdr, bct, &bcl, bcvalptr, ARLIM(fslo), ARLIM(fshi), m.dataPtr(), ARLIM(m.loVect()), ARLIM(m.hiVect()), mphi.dataPtr(), ARLIM(mphi.loVect()), ARLIM(mphi.hiVect()), mplo.dataPtr(), ARLIM(mplo.loVect()), ARLIM(mplo.hiVect()), denfab.dataPtr(), ARLIM(denfab.loVect()), ARLIM(denfab.hiVect()), exttdptr, ARLIM(fslo), ARLIM(fshi), tdfab.dataPtr(),ARLIM(tdfab.loVect()),ARLIM(tdfab.hiVect()), inout.box(gn).loVect(), inout.box(gn).hiVect(), &nc, h[level]); #elif BL_SPACEDIM==3 const Mask& mn = *msk[Orientation(1,Orientation::high)]; const Mask& me = *msk[Orientation(0,Orientation::high)]; const Mask& mw = *msk[Orientation(0,Orientation::low)]; const Mask& ms = *msk[Orientation(1,Orientation::low)]; const Mask& mt = *msk[Orientation(2,Orientation::high)]; const Mask& mb = *msk[Orientation(2,Orientation::low)]; FORT_APPLYBC( &flagden, &flagbc, &maxorder, inoutfab.dataPtr(), ARLIM(inoutfab.loVect()), ARLIM(inoutfab.hiVect()), &cdr, bct, &bcl, bcvalptr, ARLIM(fslo), ARLIM(fshi), mn.dataPtr(),ARLIM(mn.loVect()),ARLIM(mn.hiVect()), me.dataPtr(),ARLIM(me.loVect()),ARLIM(me.hiVect()), mw.dataPtr(),ARLIM(mw.loVect()),ARLIM(mw.hiVect()), ms.dataPtr(),ARLIM(ms.loVect()),ARLIM(ms.hiVect()), mt.dataPtr(),ARLIM(mt.loVect()),ARLIM(mt.hiVect()), mb.dataPtr(),ARLIM(mb.loVect()),ARLIM(mb.hiVect()), denfab.dataPtr(), ARLIM(denfab.loVect()), ARLIM(denfab.hiVect()), exttdptr, ARLIM(fslo), ARLIM(fshi), tdfab.dataPtr(),ARLIM(tdfab.loVect()),ARLIM(tdfab.hiVect()), inout.box(gn).loVect(), inout.box(gn).hiVect(), &nc, h[level]); #endif } } #if 0 // This "probably" works, but is not strictly needed just because of the way Bill // coded up the tangential derivative stuff. It's handy code though, so I want to // keep it around/ // Clean up corners: // The problem here is that APPLYBC fills only grow cells normal to the boundary. // As a result, any corner cell on the boundary (either coarse-fine or fine-fine) // is not filled. For coarse-fine, the operator adjusts itself, sliding away from // the box edge to avoid referencing that corner point. On the physical boundary // though, the corner point is needed. Particularly if a fine-fine boundary intersects // the physical boundary, since we want the stencil to be independent of the box // blocking. FillBoundary operations wont fix the problem because the "good" // data we need is living in the grow region of adjacent fabs. So, here we play // the usual games to treat the newly filled grow cells as "valid" data. // Note that we only need to do something where the grids touch the physical boundary. const Geometry& geomlev = geomarray[level]; const BoxArray& grids = inout.boxArray(); const Box& domain = geomlev.Domain(); int nGrow = 1; int src_comp = 0; int num_comp = BL_SPACEDIM; // Lets do a quick check to see if we need to do anything at all here BoxArray BIGba = BoxArray(grids).grow(nGrow); if (! (domain.contains(BIGba.minimalBox())) ) { BoxArray boundary_pieces; Array<int> proc_idxs; Array<Array<int> > old_to_new(grids.size()); const DistributionMapping& dmap=inout.DistributionMap(); for (int d=0; d<BL_SPACEDIM; ++d) { if (! (geomlev.isPeriodic(d)) ) { BoxArray gba = BoxArray(grids).grow(d,nGrow); for (int i=0; i<gba.size(); ++i) { BoxArray new_pieces = BoxLib::boxComplement(gba[i],domain); int size_new = new_pieces.size(); if (size_new>0) { int size_old = boundary_pieces.size(); boundary_pieces.resize(size_old+size_new); proc_idxs.resize(boundary_pieces.size()); for (int j=0; j<size_new; ++j) { boundary_pieces.set(size_old+j,new_pieces[j]); proc_idxs[size_old+j] = dmap[i]; old_to_new[i].push_back(size_old+j); } } } } } proc_idxs.push_back(ParallelDescriptor::MyProc()); MultiFab boundary_data(boundary_pieces,num_comp,nGrow, DistributionMapping(proc_idxs)); for (MFIter mfi(inout); mfi.isValid(); ++mfi) { const FArrayBox& src_fab = inout[mfi]; for (int j=0; j<old_to_new[mfi.index()].size(); ++j) { int new_box_idx = old_to_new[mfi.index()][j]; boundary_data[new_box_idx].copy(src_fab,src_comp,0,num_comp); } } boundary_data.FillBoundary(); // Use a hacked Geometry object to handle the periodic intersections for us. // Here, the "domain" is the plane of cells on non-periodic boundary faces. // and there may be cells over the periodic boundary in the remaining directions. // We do a Geometry::PFB on each non-periodic face to sync these up. if (geomlev.isAnyPeriodic()) { Array<int> is_per(BL_SPACEDIM,0); for (int d=0; d<BL_SPACEDIM; ++d) { is_per[d] = geomlev.isPeriodic(d); } for (int d=0; d<BL_SPACEDIM; ++d) { if (! is_per[d]) { Box tmpLo = BoxLib::adjCellLo(geomlev.Domain(),d,1); Geometry tmpGeomLo(tmpLo,&(geomlev.ProbDomain()),(int)geomlev.Coord(),is_per.dataPtr()); tmpGeomLo.FillPeriodicBoundary(boundary_data); Box tmpHi = BoxLib::adjCellHi(geomlev.Domain(),d,1); Geometry tmpGeomHi(tmpHi,&(geomlev.ProbDomain()),(int)geomlev.Coord(),is_per.dataPtr()); tmpGeomHi.FillPeriodicBoundary(boundary_data); } } } for (MFIter mfi(inout); mfi.isValid(); ++mfi) { int idx = mfi.index(); FArrayBox& dst_fab = inout[mfi]; for (int j=0; j<old_to_new[idx].size(); ++j) { int new_box_idx = old_to_new[mfi.index()][j]; const FArrayBox& src_fab = boundary_data[new_box_idx]; const Box& src_box = src_fab.box(); BoxArray pieces_outside_domain = BoxLib::boxComplement(src_box,domain); for (int k=0; k<pieces_outside_domain.size(); ++k) { const Box& outside = pieces_outside_domain[k] & dst_fab.box(); if (outside.ok()) { dst_fab.copy(src_fab,outside,0,outside,src_comp,num_comp); } } } } } #endif }
static BoxArray GetBndryCells (const BoxArray& ba, int ngrow, const Geometry& geom) { // // First get list of all ghost cells. // BoxList gcells, bcells; for (int i = 0; i < ba.size(); ++i) gcells.join(BoxLib::boxDiff(BoxLib::grow(ba[i],ngrow),ba[i])); // // Now strip out intersections with original BoxArray. // for (BoxList::const_iterator it = gcells.begin(); it != gcells.end(); ++it) { std::vector< std::pair<int,Box> > isects = ba.intersections(*it); if (isects.empty()) bcells.push_back(*it); else { // // Collect all the intersection pieces. // BoxList pieces; for (int i = 0; i < isects.size(); i++) pieces.push_back(isects[i].second); BoxList leftover = BoxLib::complementIn(*it,pieces); bcells.catenate(leftover); } } // // Now strip out overlaps. // gcells.clear(); gcells = BoxLib::removeOverlap(bcells); bcells.clear(); if (geom.isAnyPeriodic()) { Array<IntVect> pshifts(27); const Box& domain = geom.Domain(); for (BoxList::const_iterator it = gcells.begin(); it != gcells.end(); ++it) { if (!domain.contains(*it)) { // // Add in periodic ghost cells shifted to valid region. // geom.periodicShift(domain, *it, pshifts); for (int i = 0; i < pshifts.size(); i++) { const Box& shftbox = *it + pshifts[i]; const Box& ovlp = domain & shftbox; BoxList bl = BoxLib::complementIn(ovlp,BoxList(ba)); bcells.catenate(bl); } } } gcells.catenate(bcells); } return BoxArray(gcells); }
int main (int argc, char* argv[]) { BoxLib::Initialize(argc,argv); std::cout << std::setprecision(10); if (argc < 2) { std::cerr << "usage: " << argv[0] << " inputsfile [options]" << '\n'; exit(-1); } ParmParse pp; int n; BoxArray bs; #if BL_SPACEDIM == 2 Box domain(IntVect(0,0),IntVect(11,11)); std::string boxfile("gr.2_small_a") ; #elif BL_SPACEDIM == 3 Box domain(IntVect(0,0,0),IntVect(11,11,11)); std::string boxfile("grids/gr.3_2x3x4") ; #endif pp.query("boxes", boxfile); std::ifstream ifs(boxfile.c_str(), std::ios::in); if (!ifs) { std::string msg = "problem opening grids file: "; msg += boxfile.c_str(); BoxLib::Abort(msg.c_str()); } ifs >> domain; if (ParallelDescriptor::IOProcessor()) std::cout << "domain: " << domain << std::endl; bs.readFrom(ifs); if (ParallelDescriptor::IOProcessor()) std::cout << "grids:\n" << bs << std::endl; Geometry geom(domain); const Real* H = geom.CellSize(); int ratio=2; pp.query("ratio", ratio); // allocate/init soln and rhs int Ncomp=BL_SPACEDIM; int Nghost=0; int Ngrids=bs.size(); MultiFab soln(bs, Ncomp, Nghost, Fab_allocate); soln.setVal(0.0); MultiFab out(bs, Ncomp, Nghost, Fab_allocate); MultiFab rhs(bs, Ncomp, Nghost, Fab_allocate); rhs.setVal(0.0); for(MFIter rhsmfi(rhs); rhsmfi.isValid(); ++rhsmfi) { FORT_FILLRHS(rhs[rhsmfi].dataPtr(), ARLIM(rhs[rhsmfi].loVect()),ARLIM(rhs[rhsmfi].hiVect()), H,&Ncomp); } // Create the boundary object MCViscBndry vbd(bs,geom); BCRec phys_bc; Array<int> lo_bc(BL_SPACEDIM), hi_bc(BL_SPACEDIM); pp.getarr("lo_bc",lo_bc,0,BL_SPACEDIM); pp.getarr("hi_bc",hi_bc,0,BL_SPACEDIM); for (int i = 0; i < BL_SPACEDIM; i++) { phys_bc.setLo(i,lo_bc[i]); phys_bc.setHi(i,hi_bc[i]); } // Create the BCRec's interpreted by ViscBndry objects #if BL_SPACEDIM==2 Array<BCRec> pbcarray(4); pbcarray[0] = BCRec(D_DECL(REFLECT_ODD,REFLECT_EVEN,EXT_DIR), D_DECL(EXT_DIR,EXT_DIR,EXT_DIR)); pbcarray[1] = BCRec(D_DECL(REFLECT_EVEN,REFLECT_ODD,EXT_DIR), D_DECL(EXT_DIR,EXT_DIR,EXT_DIR)); pbcarray[2] = BCRec(D_DECL(EXT_DIR,EXT_DIR,EXT_DIR), D_DECL(EXT_DIR,EXT_DIR,EXT_DIR)); pbcarray[3] = BCRec(D_DECL(EXT_DIR,EXT_DIR,EXT_DIR), D_DECL(EXT_DIR,EXT_DIR,EXT_DIR)); #elif BL_SPACEDIM==3 Array<BCRec> pbcarray(12); #if 1 pbcarray[0] = BCRec(EXT_DIR,EXT_DIR,EXT_DIR,EXT_DIR,EXT_DIR,EXT_DIR); pbcarray[1] = BCRec(EXT_DIR,EXT_DIR,EXT_DIR,EXT_DIR,EXT_DIR,EXT_DIR); pbcarray[2] = BCRec(EXT_DIR,EXT_DIR,EXT_DIR,EXT_DIR,EXT_DIR,EXT_DIR); pbcarray[3] = BCRec(D_DECL(EXT_DIR,EXT_DIR,EXT_DIR), D_DECL(EXT_DIR,EXT_DIR,EXT_DIR)); pbcarray[4] = BCRec(D_DECL(EXT_DIR,EXT_DIR,EXT_DIR), D_DECL(EXT_DIR,EXT_DIR,EXT_DIR)); pbcarray[5] = BCRec(D_DECL(EXT_DIR,EXT_DIR,EXT_DIR), D_DECL(EXT_DIR,EXT_DIR,EXT_DIR)); pbcarray[6] = BCRec(D_DECL(EXT_DIR,EXT_DIR,EXT_DIR), D_DECL(EXT_DIR,EXT_DIR,EXT_DIR)); pbcarray[7] = BCRec(D_DECL(EXT_DIR,EXT_DIR,EXT_DIR), D_DECL(EXT_DIR,EXT_DIR,EXT_DIR)); pbcarray[8] = BCRec(D_DECL(EXT_DIR,EXT_DIR,EXT_DIR), D_DECL(EXT_DIR,EXT_DIR,EXT_DIR)); pbcarray[9] = BCRec(D_DECL(EXT_DIR,EXT_DIR,EXT_DIR), D_DECL(EXT_DIR,EXT_DIR,EXT_DIR)); pbcarray[10] = BCRec(D_DECL(EXT_DIR,EXT_DIR,EXT_DIR), D_DECL(EXT_DIR,EXT_DIR,EXT_DIR)); pbcarray[11] = BCRec(D_DECL(EXT_DIR,EXT_DIR,EXT_DIR), D_DECL(EXT_DIR,EXT_DIR,EXT_DIR)); #else for (int i = 0; i < 12; i++) pbcarray[i] = phys_bc; #endif #endif Nghost = 1; // need space for bc info MultiFab fine(bs,Ncomp,Nghost,Fab_allocate); for(MFIter finemfi(fine); finemfi.isValid(); ++finemfi) { FORT_FILLFINE(fine[finemfi].dataPtr(), ARLIM(fine[finemfi].loVect()),ARLIM(fine[finemfi].hiVect()), H,&Ncomp); } // Create "background coarse data" Box crse_bx = Box(domain).coarsen(ratio).grow(1); BoxArray cba(crse_bx); cba.maxSize(32); Real h_crse[BL_SPACEDIM]; for (n=0; n<BL_SPACEDIM; n++) h_crse[n] = H[n]*ratio; MultiFab crse_mf(cba, Ncomp, 0); // FArrayBox crse_fab(crse_bx,Ncomp); for (MFIter mfi(crse_mf); mfi.isValid(); ++mfi) { FORT_FILLCRSE(crse_mf[mfi].dataPtr(), ARLIM(crse_mf[mfi].loVect()),ARLIM(crse_mf[mfi].hiVect()), h_crse,&Ncomp); } // Create coarse boundary register, fill w/data from coarse FAB int bndry_InRad=0; int bndry_OutRad=1; int bndry_Extent=1; BoxArray cbs = BoxArray(bs).coarsen(ratio); BndryRegister cbr(cbs,bndry_InRad,bndry_OutRad,bndry_Extent,Ncomp); for (OrientationIter face; face; ++face) { Orientation f = face(); FabSet& bnd_fs(cbr[f]); bnd_fs.copyFrom(crse_mf, 0, 0, 0, Ncomp); } // Interpolate crse data to fine boundary, where applicable int cbr_Nstart=0; int fine_Nstart=0; int bndry_Nstart=0; vbd.setBndryValues(cbr,cbr_Nstart,fine,fine_Nstart, bndry_Nstart,Ncomp,ratio,pbcarray); Nghost = 1; // other variables don't need extra space DivVis lp(vbd,H); Real a = 0.0; Real b[BL_SPACEDIM]; b[0] = 1.0; b[1] = 1.0; #if BL_SPACEDIM>2 b[2] = 1.0; #endif MultiFab acoefs; int NcompA = (BL_SPACEDIM == 2 ? 2 : 1); acoefs.define(bs, NcompA, Nghost, Fab_allocate); acoefs.setVal(a); MultiFab bcoefs[BL_SPACEDIM]; for (n=0; n<BL_SPACEDIM; ++n) { BoxArray bsC(bs); bcoefs[n].define(bsC.surroundingNodes(n), 1, Nghost, Fab_allocate); #if 1 for(MFIter bmfi(bcoefs[n]); bmfi.isValid(); ++bmfi) { FORT_MAKEMU(bcoefs[n][bmfi].dataPtr(), ARLIM(bcoefs[n][bmfi].loVect()),ARLIM(bcoefs[n][bmfi].hiVect()),H,n); } #else bcoefs[n].setVal(b[n]); #endif } // -->> over dimension lp.setCoefficients(acoefs, bcoefs); #if 1 lp.maxOrder(4); #endif Nghost = 1; MultiFab tsoln(bs, Ncomp, Nghost, Fab_allocate); tsoln.setVal(0.0); #if 1 tsoln.copy(fine); #endif #if 0 // testing apply lp.apply(out,tsoln); Box subbox = out[0].box(); Real n1 = out[0].norm(subbox,1,0,BL_SPACEDIM)*pow(H[0],BL_SPACEDIM); ParallelDescriptor::ReduceRealSum(n1); if (ParallelDescriptor::IOProcessor()) { cout << "n1 output is "<<n1<<std::endl; } out.minus(rhs,0,BL_SPACEDIM,0); // special to single grid prob Real n2 = out[0].norm(subbox,1,0,BL_SPACEDIM)*pow(H[0],BL_SPACEDIM); ParallelDescriptor::ReduceRealSum(n2); if (ParallelDescriptor::IOProcessor()) { cout << "n2 difference is "<<n2<<std::endl; } #if 0 subbox.grow(-1); Real n3 = out[0].norm(subbox,0,0,BL_SPACEDIM)*pow(H[0],BL_SPACEDIM); ParallelDescriptor::ReduceRealMax(n3); if (ParallelDescriptor::IOProcessor()) { cout << "n3 difference is "<<n3<<std::endl; } #endif #endif const IntVect refRatio(D_DECL(2,2,2)); const Real bgVal = 1.0; #if 1 #ifndef NDEBUG // testing flux computation BoxArray xfluxbox(bs); xfluxbox.surroundingNodes(0); MultiFab xflux(xfluxbox,Ncomp,Nghost,Fab_allocate); xflux.setVal(1.e30); BoxArray yfluxbox(bs); yfluxbox.surroundingNodes(1); MultiFab yflux(yfluxbox,Ncomp,Nghost,Fab_allocate); yflux.setVal(1.e30); #if BL_SPACEDIM>2 BoxArray zfluxbox(bs); zfluxbox.surroundingNodes(2); MultiFab zflux(zfluxbox,Ncomp,Nghost,Fab_allocate); zflux.setVal(1.e30); #endif lp.compFlux(xflux, yflux, #if BL_SPACEDIM>2 zflux, #endif tsoln); // Write fluxes //writeMF(&xflux,"xflux.mfab"); //writeMF(&yflux,"yflux.mfab"); #if BL_SPACEDIM>2 //writeMF(&zflux,"zflux.mfab"); #endif #endif #endif Real tolerance = 1.0e-10; pp.query("tol", tolerance); Real tolerance_abs = 1.0e-10; pp.query("tol_abs", tolerance_abs); #if 0 cout << "Bndry Data object:" << std::endl; cout << lp.bndryData() << std::endl; #endif #if 0 bool use_mg_pre = false; MCCGSolver cg(lp,use_mg_pre); cg.solve(soln,rhs,tolerance,tolerance_abs); #else MCMultiGrid mg(lp); mg.solve(soln,rhs,tolerance,tolerance_abs); #endif #if 0 cout << "MCLinOp object:" << std::endl; cout << lp << std::endl; #endif VisMF::Write(soln,"soln"); #if 0 // apply operator to soln to see if really satisfies eqn tsoln.copy(soln); lp.apply(out,tsoln); soln.copy(out); // Output "apply" results on soln VisMF::Write(soln,"apply"); // Compute truncation for (MFIter smfi(soln); smfi.isValid(); ++smfi) { soln[smfi] -= fine[smfi]; } for( int icomp=0; icomp < BL_SPACEDIM ; icomp++ ) { Real solnMin = soln.min(icomp); Real solnMax = soln.max(icomp); ParallelDescriptor::ReduceRealMin(solnMin); ParallelDescriptor::ReduceRealMax(solnMax); if (ParallelDescriptor::IOProcessor()) { cout << icomp << " "<<solnMin << " " << solnMax <<std::endl; } } // Output truncation VisMF::Write(soln,"trunc"); #endif int dumpLp=0; pp.query("dumpLp",dumpLp); bool write_lp = (dumpLp == 1 ? true : false); if (write_lp) std::cout << lp << std::endl; // Output trunc ParallelDescriptor::EndParallel(); }