void advance (MultiFab& old_phi, MultiFab& new_phi, PArray<MultiFab>& flux, Real time, Real dt, const Geometry& geom, PhysBCFunct& physbcf, BCRec& bcr) { // Fill the ghost cells of each grid from the other grids // includes periodic domain boundaries old_phi.FillBoundary(geom.periodicity()); // Fill physical boundaries physbcf.FillBoundary(old_phi, time); int Ncomp = old_phi.nComp(); int ng_p = old_phi.nGrow(); int ng_f = flux[0].nGrow(); const Real* dx = geom.CellSize(); // // Note that this simple example is not optimized. // The following two MFIter loops could be merged // and we do not have to use flux MultiFab. // // Compute fluxes one grid at a time for ( MFIter mfi(old_phi); mfi.isValid(); ++mfi ) { const Box& bx = mfi.validbox(); compute_flux(old_phi[mfi].dataPtr(), &ng_p, flux[0][mfi].dataPtr(), flux[1][mfi].dataPtr(), #if (BL_SPACEDIM == 3) flux[2][mfi].dataPtr(), #endif &ng_f, bx.loVect(), bx.hiVect(), (geom.Domain()).loVect(), (geom.Domain()).hiVect(), bcr.vect(), &dx[0]); } // Advance the solution one grid at a time for ( MFIter mfi(old_phi); mfi.isValid(); ++mfi ) { const Box& bx = mfi.validbox(); update_phi(old_phi[mfi].dataPtr(), new_phi[mfi].dataPtr(), &ng_p, flux[0][mfi].dataPtr(), flux[1][mfi].dataPtr(), #if (BL_SPACEDIM == 3) flux[2][mfi].dataPtr(), #endif &ng_f, bx.loVect(), bx.hiVect(), &dx[0] , &dt); } }
void setup_coeffs4(BoxArray& bs, MultiFab& alpha, MultiFab& beta, const Geometry& geom) { ParmParse pp; Real sigma, w; pp.get("sigma", sigma); pp.get("w", w); for ( MFIter mfi(alpha); mfi.isValid(); ++mfi ) { const Box& bx = mfi.validbox(); const int* alo = alpha[mfi].loVect(); const int* ahi = alpha[mfi].hiVect(); const Box& abx = alpha[mfi].box(); FORT_SET_ALPHA(alpha[mfi].dataPtr(),ARLIM(alo),ARLIM(ahi), abx.loVect(),abx.hiVect(),dx); const int* clo = beta[mfi].loVect(); const int* chi = beta[mfi].hiVect(); FORT_SET_CC_COEF(beta[mfi].dataPtr(),ARLIM(clo),ARLIM(chi), bx.loVect(),bx.hiVect(),dx, sigma, w); } if (plot_beta == 1) { writePlotFile("BETA4", beta, geom); } }
void setup_coeffs(BoxArray& bs, MultiFab& alpha, PArray<MultiFab>& beta, const Geometry& geom, MultiFab& cc_coef) { BL_PROFILE("setup_coeffs()"); ParmParse pp; Real sigma, w; pp.get("sigma", sigma); pp.get("w", w); for ( MFIter mfi(alpha); mfi.isValid(); ++mfi ) { const Box& bx = mfi.validbox(); const int* alo = alpha[mfi].loVect(); const int* ahi = alpha[mfi].hiVect(); FORT_SET_ALPHA(alpha[mfi].dataPtr(),ARLIM(alo),ARLIM(ahi), bx.loVect(),bx.hiVect(),dx); const int* clo = cc_coef[mfi].loVect(); const int* chi = cc_coef[mfi].hiVect(); FORT_SET_CC_COEF(cc_coef[mfi].dataPtr(),ARLIM(clo),ARLIM(chi), bx.loVect(),bx.hiVect(),dx, sigma, w); } BoxLib::average_cellcenter_to_face(beta, cc_coef, geom); if (plot_beta == 1) { writePlotFile("BETA", cc_coef, geom); } }
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); } }
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(); }
void average_down (MultiFab& S_fine, MultiFab& S_crse, int scomp, int ncomp, const IntVect& ratio) { BL_ASSERT(S_crse.nComp() == S_fine.nComp()); // // Coarsen() the fine stuff on processors owning the fine data. // BoxArray crse_S_fine_BA = S_fine.boxArray(); crse_S_fine_BA.coarsen(ratio); MultiFab crse_S_fine(crse_S_fine_BA,ncomp,0); #ifdef _OPENMP #pragma omp parallel #endif for (MFIter mfi(crse_S_fine,true); mfi.isValid(); ++mfi) { // NOTE: The tilebox is defined at the coarse level. const Box& tbx = mfi.tilebox(); // NOTE: We copy from component scomp of the fine fab into component 0 of the crse fab // because the crse fab is a temporary which was made starting at comp 0, it is // not part of the actual crse multifab which came in. BL_FORT_PROC_CALL(BL_AVGDOWN,bl_avgdown) (tbx.loVect(), tbx.hiVect(), BL_TO_FORTRAN_N(S_fine[mfi],scomp), BL_TO_FORTRAN_N(crse_S_fine[mfi],0), ratio.getVect(),&ncomp); } S_crse.copy(crse_S_fine,0,scomp,ncomp); }
int iMultiFab::max (int comp, int nghost, bool local) const { BL_ASSERT(nghost >= 0 && nghost <= n_grow); int mx = -std::numeric_limits<int>::max(); #ifdef _OPENMP #pragma omp parallel #endif { int priv_mx = -std::numeric_limits<int>::max(); for ( MFIter mfi(*this,true); mfi.isValid(); ++mfi) { priv_mx = std::max(priv_mx, get(mfi).max(mfi.growntilebox(nghost),comp)); } #ifdef _OPENMP #pragma omp critical (imultifab_max) #endif { mx = std::max(mx, priv_mx); } } if (!local) ParallelDescriptor::ReduceIntMax(mx); return mx; }
int iMultiFab::min (int comp, int nghost, bool local) const { BL_ASSERT(nghost >= 0 && nghost <= n_grow); int mn = std::numeric_limits<int>::max(); #ifdef _OPENMP #pragma omp parallel #endif { int priv_mn = std::numeric_limits<int>::max(); for (MFIter mfi(*this,true); mfi.isValid(); ++mfi) { const Box& bx = mfi.growntilebox(nghost); priv_mn = std::min(priv_mn,get(mfi).min(bx,comp)); } #ifdef _OPENMP #pragma omp critical (imultifab_min) #endif { mn = std::min(mn, priv_mn); } } if (!local) ParallelDescriptor::ReduceIntMin(mn); return mn; }
int iMultiFab::norm0 (int comp, bool local) const { int nm0 = -std::numeric_limits<int>::max(); #ifdef _OPENMP #pragma omp parallel #endif { int priv_nm0 = -std::numeric_limits<int>::max(); for (MFIter mfi(*this,true); mfi.isValid(); ++mfi) { priv_nm0 = std::max(priv_nm0, get(mfi).norm(mfi.tilebox(), 0, comp, 1)); } #ifdef _OPENMP #pragma omp critical (imultifab_norm0) #endif { nm0 = std::max(nm0, priv_nm0); } } if (!local) ParallelDescriptor::ReduceIntMax(nm0); return nm0; }
void setup_rhs(MultiFab& rhs, const Geometry& geom, Real a, Real b) { BL_PROFILE("setup_rhs"); Real sigma = 1.0; Real w = 1.0; int ibnd = static_cast<int>(bc_type); // We test the sum of the RHS to check solvability Real sum_rhs = 0.; for ( MFIter mfi(rhs); mfi.isValid(); ++mfi ) { const int* rlo = rhs[mfi].loVect(); const int* rhi = rhs[mfi].hiVect(); const Box& bx = mfi.validbox(); FORT_SET_RHS(rhs[mfi].dataPtr(),ARLIM(rlo),ARLIM(rhi), bx.loVect(),bx.hiVect(),dx, a, b, sigma, w, ibnd); sum_rhs += rhs[mfi].sum(0,1); } for (int n=0; n < BL_SPACEDIM; n++) { sum_rhs *= dx[n]; } ParallelDescriptor::ReduceRealSum(sum_rhs, ParallelDescriptor::IOProcessorNumber()); if (ParallelDescriptor::IOProcessor()) { std::cout << "Sum of RHS : " << sum_rhs << std::endl; } }
void MultiGrid::interpolate (MultiFab& f, const MultiFab& c) { BL_PROFILE("MultiGrid::interpolate()"); // // Use fortran function to interpolate up (prolong) c to f // Note: returns f=f+P(c) , i.e. ADDS interp'd c to f. // // OMP over boxes #ifdef _OPENMP #pragma omp parallel #endif for (MFIter mfi(c); mfi.isValid(); ++mfi) { const int k = mfi.index(); const Box& bx = c.boxArray()[k]; const int nc = f.nComp(); const FArrayBox& cfab = c[mfi]; FArrayBox& ffab = f[mfi]; FORT_INTERP(ffab.dataPtr(), ARLIM(ffab.loVect()), ARLIM(ffab.hiVect()), cfab.dataPtr(), ARLIM(cfab.loVect()), ARLIM(cfab.hiVect()), bx.loVect(), bx.hiVect(), &nc); } }
int iMultiFab::norm0 (int comp, const BoxArray& ba, bool local) const { int nm0 = -std::numeric_limits<int>::max(); #ifdef _OPENMP #pragma omp parallel #endif { std::vector< std::pair<int,Box> > isects; int priv_nm0 = -std::numeric_limits<int>::max(); for (MFIter mfi(*this); mfi.isValid(); ++mfi) { ba.intersections(mfi.validbox(),isects); for (int i = 0, N = isects.size(); i < N; i++) { priv_nm0 = std::max(priv_nm0, get(mfi).norm(isects[i].second, 0, comp, 1)); } } #ifdef _OPENMP #pragma omp critical (imultifab_norm0_ba) #endif { nm0 = std::max(nm0, priv_nm0); } } if (!local) ParallelDescriptor::ReduceIntMax(nm0); return nm0; }
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); } }
static void Write_N_Read (const MultiFab& mf, const std::string& mf_name) { if (ParallelDescriptor::IOProcessor()) { std::cout << "Writing the MultiFab to disk ...\n"; } double start, end; ParallelDescriptor::Barrier(); if (ParallelDescriptor::IOProcessor()) { start = BoxLib::wsecond(); } ParallelDescriptor::Barrier(); if (ParallelDescriptor::IOProcessor()) { end = BoxLib::wsecond(); std::cout << "\nWallclock time for MF write: " << (end-start) << '\n'; std::cout << "Reading the MultiFab from disk ...\n"; } VisMF vmf(mf_name); BL_ASSERT(vmf.size() == mf.boxArray().size()); for (MFIter mfi(mf); mfi.isValid(); ++mfi) { //const FArrayBox& fab = vmf[mfi.index()]; const FArrayBox& fab = vmf.GetFab(mfi.index(), 0); std::cout << "\tCPU #" << ParallelDescriptor::MyProc() << " read FAB #" << mfi.index() << '\n'; } ParallelDescriptor::Barrier(); if (ParallelDescriptor::IOProcessor()) { std::cout << "Building new MultiFab from disk version ....\n\n"; } MultiFab new_mf; VisMF::Read(new_mf, mf_name); }
static void advance (MultiFab* old_phi, MultiFab* new_phi, MultiFab* flux, Real* dx, Real dt, Geometry geom) { // Fill the ghost cells of each grid from the other grids old_phi->FillBoundary(); // Fill periodic boundary ghost cells geom.FillPeriodicBoundary(*old_phi); int Ncomp = old_phi->nComp(); int ng_p = old_phi->nGrow(); int ng_f = flux->nGrow(); // Compute fluxes one grid at a time for ( MFIter mfi(*old_phi); mfi.isValid(); ++mfi ) { const Box& bx = mfi.validbox(); FORT_COMPUTE_FLUX((*old_phi)[mfi].dataPtr(), &ng_p, flux[0][mfi].dataPtr(), flux[1][mfi].dataPtr(), #if (BL_SPACEDIM == 3) flux[2][mfi].dataPtr(), #endif &ng_f, bx.loVect(), bx.hiVect(), &(dx[0])); } // Advance the solution one grid at a time for ( MFIter mfi(*old_phi); mfi.isValid(); ++mfi ) { const Box& bx = mfi.validbox(); FORT_UPDATE_PHI((*old_phi)[mfi].dataPtr(), (*new_phi)[mfi].dataPtr(), &ng_p, flux[0][mfi].dataPtr(), flux[1][mfi].dataPtr(), #if (BL_SPACEDIM == 3) flux[2][mfi].dataPtr(), #endif &ng_f, bx.loVect(), bx.hiVect(), &(dx[0]) , &dt); } }
void set_boundary(BndryData& bd, const MultiFab& rhs, int comp=0) { BL_PROFILE("set_boundary"); Real bc_value = 0.0; for (int n=0; n<BL_SPACEDIM; ++n) { for (MFIter mfi(rhs); mfi.isValid(); ++mfi ) { int i = mfi.index(); const Box& bx = mfi.validbox(); // Our default will be that the face of this grid is either touching another grid // across an interior boundary or a periodic boundary. We will test for the other // cases below. { // Define the type of boundary conditions to be Dirichlet (even for periodic) bd.setBoundCond(Orientation(n, Orientation::low) ,i,comp,LO_DIRICHLET); bd.setBoundCond(Orientation(n, Orientation::high),i,comp,LO_DIRICHLET); // Set the boundary conditions to the cell centers outside the domain bd.setBoundLoc(Orientation(n, Orientation::low) ,i,0.5*dx[n]); bd.setBoundLoc(Orientation(n, Orientation::high),i,0.5*dx[n]); } // Now test to see if we should override the above with Dirichlet or Neumann physical bc's if (bc_type != Periodic) { int ibnd = static_cast<int>(bc_type); // either LO_DIRICHLET or LO_NEUMANN const Geometry& geom = bd.getGeom(); // We are on the low side of the domain in coordinate direction n if (bx.smallEnd(n) == geom.Domain().smallEnd(n)) { // Set the boundary conditions to live exactly on the faces of the domain bd.setBoundLoc(Orientation(n, Orientation::low) ,i,0.0 ); // Set the Dirichlet/Neumann boundary values bd.setValue(Orientation(n, Orientation::low) ,i, bc_value); // Define the type of boundary conditions bd.setBoundCond(Orientation(n, Orientation::low) ,i,comp,ibnd); } // We are on the high side of the domain in coordinate direction n if (bx.bigEnd(n) == geom.Domain().bigEnd(n)) { // Set the boundary conditions to live exactly on the faces of the domain bd.setBoundLoc(Orientation(n, Orientation::high) ,i,0.0 ); // Set the Dirichlet/Neumann boundary values bd.setValue(Orientation(n, Orientation::high) ,i, bc_value); // Define the type of boundary conditions bd.setBoundCond(Orientation(n, Orientation::high) ,i,comp,ibnd); } } } } }
static Real norm_inf (const MultiFab& res, bool local = false) { Real restot = 0.0; for (MFIter mfi(res); mfi.isValid(); ++mfi) { restot = std::max(restot, res[mfi].norm(mfi.validbox(), 0, 0, res.nComp())); } if ( !local ) ParallelDescriptor::ReduceRealMax(restot); return restot; }
void setup_coeffs(BoxArray& bs, MultiFab& alpha, MultiFab beta[], const Geometry& geom) { BL_PROFILE("setup_coeffs"); Real sigma = 1.0; Real w = 1.0; MultiFab cc_coef(bs,Ncomp,1); // cell-centered beta for ( MFIter mfi(alpha); mfi.isValid(); ++mfi ) { const Box& bx = mfi.validbox(); const int* alo = alpha[mfi].loVect(); const int* ahi = alpha[mfi].hiVect(); FORT_SET_ALPHA(alpha[mfi].dataPtr(),ARLIM(alo),ARLIM(ahi), bx.loVect(),bx.hiVect(),dx); const int* clo = cc_coef[mfi].loVect(); const int* chi = cc_coef[mfi].hiVect(); FORT_SET_CC_COEF(cc_coef[mfi].dataPtr(),ARLIM(clo),ARLIM(chi), bx.loVect(),bx.hiVect(),dx, sigma, w); } // convert cell-centered beta to edges for ( int n=0; n<BL_SPACEDIM; ++n ) { for ( MFIter mfi(beta[n]); mfi.isValid(); ++mfi ) { int i = mfi.index(); Box bx(bs[i]); const int* clo = cc_coef[mfi].loVect(); const int* chi = cc_coef[mfi].hiVect(); const int* edgelo = beta[n][mfi].loVect(); const int* edgehi = beta[n][mfi].hiVect(); FORT_COEF_TO_EDGES(&n,beta[n][mfi].dataPtr(),ARLIM(edgelo),ARLIM(edgehi), cc_coef[mfi].dataPtr(),ARLIM(clo),ARLIM(chi), bx.loVect(),bx.hiVect()); } } }
void Diffusion::applyMetricTerms(int level, MultiFab& Rhs, PArray<MultiFab>& coeffs) { const Real* dx = parent->Geom(level).CellSize(); int coord_type = Geometry::Coord(); #ifdef _OPENMP #pragma omp parallel #endif for (MFIter mfi(Rhs,true); mfi.isValid(); ++mfi) { const Box& bx = mfi.tilebox(); D_TERM(const Box xbx = mfi.nodaltilebox(0);, const Box ybx = mfi.nodaltilebox(1);,
void advance (MultiFab* old_phi, MultiFab* new_phi, Real* dx, Real dt, Geometry geom) { int Ncomp = old_phi->nComp(); // Fill the ghost cells of each grid from the other grids Real t1 = ParallelDescriptor::second(); old_phi->FillBoundary(geom.periodicity()); FB_time += ParallelDescriptor::second() - t1; Real t0 = ParallelDescriptor::second(); if (do_tiling) { #ifdef _OPENMP #pragma omp parallel #endif for ( MFIter mfi(*old_phi,true); mfi.isValid(); ++mfi ) { const Box& bx = mfi.tilebox(); advance_phi(bx.loVect(), bx.hiVect(), BL_TO_FORTRAN((*old_phi)[mfi]), BL_TO_FORTRAN((*new_phi)[mfi]), Ncomp,dx, dt); } } else { for ( MFIter mfi(*old_phi); mfi.isValid(); ++mfi ) { const Box& bx = mfi.validbox(); advance_phi2(bx.loVect(), bx.hiVect(), BL_TO_FORTRAN((*old_phi)[mfi]), BL_TO_FORTRAN((*new_phi)[mfi]), Ncomp,dx, dt); } } kernel_time += ParallelDescriptor::second() - t0; }
void compute_analyticSolution(MultiFab& anaSoln, const Array<Real>& offset) { BL_PROFILE("compute_analyticSolution()"); int ibnd = static_cast<int>(bc_type); for (MFIter mfi(anaSoln); mfi.isValid(); ++mfi) { const int* alo = anaSoln[mfi].loVect(); const int* ahi = anaSoln[mfi].hiVect(); const Box& bx = mfi.validbox(); FORT_COMP_ASOL(anaSoln[mfi].dataPtr(), ARLIM(alo), ARLIM(ahi), bx.loVect(),bx.hiVect(),dx, ibnd, offset.dataPtr()); } }
void average_down (MultiFab& S_fine, MultiFab& S_crse, const Geometry& fgeom, const Geometry& cgeom, int scomp, int ncomp, const IntVect& ratio) { if (S_fine.is_nodal() || S_crse.is_nodal()) { BoxLib::Error("Can't use BoxLib::average_down for nodal MultiFab!"); } #if (BL_SPACEDIM == 3) BoxLib::average_down(S_fine, S_crse, scomp, ncomp, ratio); return; #else BL_ASSERT(S_crse.nComp() == S_fine.nComp()); // // Coarsen() the fine stuff on processors owning the fine data. // const BoxArray& fine_BA = S_fine.boxArray(); BoxArray crse_S_fine_BA = fine_BA; crse_S_fine_BA.coarsen(ratio); MultiFab crse_S_fine(crse_S_fine_BA,ncomp,0); MultiFab fvolume; fgeom.GetVolume(fvolume, fine_BA, 0); #ifdef _OPENMP #pragma omp parallel #endif for (MFIter mfi(crse_S_fine,true); mfi.isValid(); ++mfi) { // NOTE: The tilebox is defined at the coarse level. const Box& tbx = mfi.tilebox(); // NOTE: We copy from component scomp of the fine fab into component 0 of the crse fab // because the crse fab is a temporary which was made starting at comp 0, it is // not part of the actual crse multifab which came in. BL_FORT_PROC_CALL(BL_AVGDOWN_WITH_VOL,bl_avgdown_with_vol) (tbx.loVect(), tbx.hiVect(), BL_TO_FORTRAN_N(S_fine[mfi],scomp), BL_TO_FORTRAN_N(crse_S_fine[mfi],0), BL_TO_FORTRAN(fvolume[mfi]), ratio.getVect(),&ncomp); } S_crse.copy(crse_S_fine,0,scomp,ncomp); #endif }
void BndryRegister::init (const BndryRegister& src) { grids.define(src.grids); for (int i = 0; i < 2*BL_SPACEDIM; i++) { bndry[i].define(src.bndry[i].boxArray(), src.bndry[i].nComp()); for (FabSetIter mfi(src.bndry[i]); mfi.isValid(); ++mfi) { bndry[i][mfi].copy(src.bndry[i][mfi]); } } }
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; }
void iMultiFab::negate (int comp, int num_comp, int nghost) { BL_ASSERT(nghost >= 0 && nghost <= n_grow); BL_ASSERT(comp+num_comp <= n_comp); #ifdef _OPENMP #pragma omp parallel #endif for (MFIter mfi(*this,true); mfi.isValid(); ++mfi) { get(mfi).negate(mfi.growntilebox(nghost),comp,num_comp); } }
void iMultiFab::FillBoundary (int scomp, int ncomp, bool local, bool cross) { if ( n_grow <= 0 ) return; if ( local ) { // // Do what you can with the FABs you own. No parallelism allowed. // const BoxArray& ba = boxArray(); const DistributionMapping& DMap = DistributionMap(); const int MyProc = ParallelDescriptor::MyProc(); #ifdef _OPENMP #pragma omp parallel #endif { std::vector< std::pair<int,Box> > isects; for (MFIter mfi(*this); mfi.isValid(); ++mfi) { const int i = mfi.index(); ba.intersections((*this)[mfi].box(),isects); for (int ii = 0, N = isects.size(); ii < N; ii++) { const Box& bx = isects[ii].second; const int iii = isects[ii].first; if (i != iii && DMap[iii] == MyProc) { (*this)[mfi].copy((*this)[iii], bx, scomp, bx, scomp, ncomp); } } } } } else { FabArray<IArrayBox>::FillBoundary(scomp,ncomp,cross); } }
void MultiFab_C_to_F::share (MultiFab& cmf, const std::string& fmf_name) { const Box& bx = cmf.boxArray()[0]; int nodal[BL_SPACEDIM]; for ( int i = 0; i < BL_SPACEDIM; ++i ) { nodal[i] = (bx.type(i) == IndexType::NODE) ? 1 : 0; } share_multifab_with_f (fmf_name.c_str(), cmf.nComp(), cmf.nGrow(), nodal); for (MFIter mfi(cmf); mfi.isValid(); ++mfi) { int li = mfi.LocalIndex(); const FArrayBox& fab = cmf[mfi]; share_fab_with_f (li, fab.dataPtr()); } }
void ABec4::cc2ca(const MultiFab& cc, MultiFab& ca, int sComp, int dComp, int nComp) { #ifdef _OPENMP #pragma omp parallel #endif for (MFIter mfi(ca,true); mfi.isValid(); ++mfi) { const FArrayBox& ccf = cc[mfi]; FArrayBox& caf = ca[mfi]; const Box& box = mfi.growntilebox(); BL_ASSERT(ccf.box().contains(BoxLib::grow(box,1))); FORT_CC2CA(box.loVect(), box.hiVect(), ccf.dataPtr(sComp), ARLIM(ccf.box().loVect()), ARLIM(ccf.box().hiVect()), caf.dataPtr(dComp), ARLIM(caf.box().loVect()), ARLIM(caf.box().hiVect()), &nComp); } }
int iMultiFab::norm1 (int comp, int ngrow, bool local) const { int nm1 = 0.e0; #ifdef _OPENMP #pragma omp parallel reduction(+:nm1) #endif for (MFIter mfi(*this); mfi.isValid(); ++mfi) { nm1 += get(mfi).norm(mfi.growntilebox(ngrow), 1, comp, 1); } if (!local) ParallelDescriptor::ReduceIntSum(nm1); return nm1; }
void ABec4::lo_cc2ec(const MultiFab& cc, MultiFab& ec, int sComp, int dComp, int nComp, int dir, bool do_harm) { #ifdef _OPENMP #pragma omp parallel #endif for (MFIter mfi(ec,true); mfi.isValid(); ++mfi) { const FArrayBox& ccf = cc[mfi]; FArrayBox& ecf = ec[mfi]; const Box& box = mfi.growntilebox(); BL_ASSERT(ccf.box().contains(Box(box).enclosedCells().grow(dir,1))); int iharm = (int)do_harm; FORT_LO_CC2EC(box.loVect(), box.hiVect(), ccf.dataPtr(sComp), ARLIM(ccf.box().loVect()), ARLIM(ccf.box().hiVect()), ecf.dataPtr(dComp), ARLIM(ecf.box().loVect()), ARLIM(ecf.box().hiVect()), &nComp,&dir,&iharm); } }