本文整理汇总了C++中MultiFab::nComp方法的典型用法代码示例。如果您正苦于以下问题:C++ MultiFab::nComp方法的具体用法?C++ MultiFab::nComp怎么用?C++ MultiFab::nComp使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MultiFab
的用法示例。
在下文中一共展示了MultiFab::nComp方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: average_down
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);
}
示例2: ARLIM
void
MultiGrid::average (MultiFab& c,
const MultiFab& f)
{
BL_PROFILE("MultiGrid::average()");
//
// Use Fortran function to average down (restrict) f to c.
//
const bool tiling = true;
#ifdef _OPENMP
#pragma omp parallel
#endif
for (MFIter cmfi(c,tiling); cmfi.isValid(); ++cmfi)
{
BL_ASSERT(c.boxArray().get(cmfi.index()) == cmfi.validbox());
const int nc = c.nComp();
const Box& bx = cmfi.tilebox();
FArrayBox& cfab = c[cmfi];
const FArrayBox& ffab = f[cmfi];
FORT_AVERAGE(cfab.dataPtr(),
ARLIM(cfab.loVect()), ARLIM(cfab.hiVect()),
ffab.dataPtr(),
ARLIM(ffab.loVect()), ARLIM(ffab.hiVect()),
bx.loVect(), bx.hiVect(), &nc);
}
}
示例3: average_face_to_cellcenter
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);
}
}
示例4: apply
void
MCLinOp::residual (MultiFab& residL,
const MultiFab& rhsL,
MultiFab& solnL,
int level,
MCBC_Mode bc_mode)
{
apply(residL, solnL, level, bc_mode);
for (MFIter solnLmfi(solnL); solnLmfi.isValid(); ++solnLmfi)
{
int nc = residL.nComp();
const Box& vbox = solnLmfi.validbox();
FArrayBox& resfab = residL[solnLmfi];
const FArrayBox& rhsfab = rhsL[solnLmfi];
FORT_RESIDL(
resfab.dataPtr(),
ARLIM(resfab.loVect()), ARLIM(resfab.hiVect()),
rhsfab.dataPtr(),
ARLIM(rhsfab.loVect()), ARLIM(rhsfab.hiVect()),
resfab.dataPtr(),
ARLIM(resfab.loVect()), ARLIM(resfab.hiVect()),
vbox.loVect(), vbox.hiVect(), &nc);
}
}
示例5: reset_e_src
void
Nyx::strang_second_step (Real time, Real dt, MultiFab& S_new, MultiFab& D_new)
{
BL_PROFILE("Nyx::strang_second_step()");
Real half_dt = 0.5*dt;
int min_iter = 100000;
int max_iter = 0;
int min_iter_grid;
int max_iter_grid;
// Set a at the half of the time step in the second strang
const Real a = get_comoving_a(time-half_dt);
MultiFab reset_e_src(S_new.boxArray(), S_new.DistributionMap(), 1, NUM_GROW);
reset_e_src.setVal(0.0);
reset_internal_energy(S_new,D_new,reset_e_src);
compute_new_temp (S_new,D_new);
#ifndef FORCING
{
const Real z = 1.0/a - 1.0;
fort_interp_to_this_z(&z);
}
#endif
#ifdef _OPENMP
#pragma omp parallel private(min_iter_grid,max_iter_grid) reduction(min:min_iter) reduction(max:max_iter)
#endif
for (MFIter mfi(S_new,true); mfi.isValid(); ++mfi)
{
// Here bx is just the valid region
const Box& bx = mfi.tilebox();
min_iter_grid = 100000;
max_iter_grid = 0;
integrate_state
(bx.loVect(), bx.hiVect(),
BL_TO_FORTRAN(S_new[mfi]),
BL_TO_FORTRAN(D_new[mfi]),
&a, &half_dt, &min_iter_grid, &max_iter_grid);
if (S_new[mfi].contains_nan(bx,0,S_new.nComp()))
{
std::cout << "NANS IN THIS GRID " << bx << std::endl;
}
min_iter = std::min(min_iter,min_iter_grid);
max_iter = std::max(max_iter,max_iter_grid);
}
ParallelDescriptor::ReduceIntMax(max_iter);
ParallelDescriptor::ReduceIntMin(min_iter);
if (heat_cool_type == 1)
if (ParallelDescriptor::IOProcessor())
std::cout << "Min/Max Number of Iterations in Second Strang: " << min_iter << " " << max_iter << std::endl;
}
示例6: advance
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);
}
}
示例7: Dot
//
// Do a one-component dot product of r & z using supplied components.
//
static
Real
dotxy (const MultiFab& r,
int rcomp,
const MultiFab& z,
int zcomp,
bool local)
{
BL_PROFILE("CGSolver::dotxy()");
BL_ASSERT(r.nComp() > rcomp);
BL_ASSERT(z.nComp() > zcomp);
BL_ASSERT(r.boxArray() == z.boxArray());
const int ncomp = 1;
const int nghost = 0;
return MultiFab::Dot(r,rcomp,z,zcomp,ncomp,nghost,local);
}
示例8:
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;
}
示例9:
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());
}
}
示例10: prepareForLevel
void
MCMultiGrid::solve (MultiFab& _sol,
const MultiFab& _rhs,
Real _eps_rel,
Real _eps_abs,
MCBC_Mode bc_mode)
{
BL_ASSERT(numcomps == _sol.nComp());
//
// Prepare memory for new level, and solve the general boundary
// value problem to within relative error _eps_rel. Customized
// to solve at level=0
//
int level = 0;
prepareForLevel(level);
residualCorrectionForm(*rhs[level],_rhs,*cor[level],_sol,bc_mode,level);
if (!solve_(_sol, _eps_rel, _eps_abs, MCHomogeneous_BC, level))
BoxLib::Error("MCMultiGrid::solve(): failed to converge!");
}
示例11: apply
void
LinOp::residual (MultiFab& residL,
const MultiFab& rhsL,
MultiFab& solnL,
int level,
LinOp::BC_Mode bc_mode,
bool local)
{
BL_PROFILE("LinOp::residual()");
apply(residL, solnL, level, bc_mode, local);
const bool tiling = true;
#ifdef _OPENMP
#pragma omp parallel
#endif
for (MFIter solnLmfi(solnL,tiling); solnLmfi.isValid(); ++solnLmfi)
{
const int nc = residL.nComp();
//
// Only single-component solves supported (verified) by this class.
//
BL_ASSERT(nc == 1);
const Box& tbx = solnLmfi.tilebox();
BL_ASSERT(gbox[level][solnLmfi.index()] == solnLmfi.validbox());
FArrayBox& residfab = residL[solnLmfi];
const FArrayBox& rhsfab = rhsL[solnLmfi];
FORT_RESIDL(
residfab.dataPtr(),
ARLIM(residfab.loVect()), ARLIM(residfab.hiVect()),
rhsfab.dataPtr(),
ARLIM(rhsfab.loVect()), ARLIM(rhsfab.hiVect()),
residfab.dataPtr(),
ARLIM(residfab.loVect()), ARLIM(residfab.hiVect()),
tbx.loVect(), tbx.hiVect(), &nc);
}
}
示例12: average_edge_to_cellcenter
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])));
}
}
示例13: average_cellcenter_to_face
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);
}
}
示例14: fill_boundary
void fill_boundary(MultiFab& mf, const Geometry& geom, bool cross)
{
BoxLib::fill_boundary(mf, 0, mf.nComp(), geom, cross);
}
示例15: sorig
int
CGSolver::solve_cg (MultiFab& sol,
const MultiFab& rhs,
Real eps_rel,
Real eps_abs,
LinOp::BC_Mode bc_mode)
{
BL_PROFILE("CGSolver::solve_cg()");
const int nghost = sol.nGrow(), ncomp = 1;
const BoxArray& ba = sol.boxArray();
const DistributionMapping& dm = sol.DistributionMap();
BL_ASSERT(sol.nComp() == ncomp);
BL_ASSERT(sol.boxArray() == Lp.boxArray(lev));
BL_ASSERT(rhs.boxArray() == Lp.boxArray(lev));
MultiFab sorig(ba, ncomp, nghost, dm);
MultiFab r(ba, ncomp, nghost, dm);
MultiFab z(ba, ncomp, nghost, dm);
MultiFab q(ba, ncomp, nghost, dm);
MultiFab p(ba, ncomp, nghost, dm);
MultiFab r1(ba, ncomp, nghost, dm);
MultiFab z1(ba, ncomp, nghost, dm);
MultiFab r2(ba, ncomp, nghost, dm);
MultiFab z2(ba, ncomp, nghost, dm);
MultiFab::Copy(sorig,sol,0,0,1,0);
Lp.residual(r, rhs, sorig, lev, bc_mode);
sol.setVal(0);
const LinOp::BC_Mode temp_bc_mode=LinOp::Homogeneous_BC;
Real rnorm = norm_inf(r);
const Real rnorm0 = rnorm;
Real minrnorm = rnorm;
if ( verbose > 0 && ParallelDescriptor::IOProcessor(color()) )
{
Spacer(std::cout, lev);
std::cout << " CG: Initial error : " << rnorm0 << '\n';
}
const Real Lp_norm = Lp.norm(0, lev);
Real sol_norm = 0;
Real rho_1 = 0;
int ret = 0;
int nit = 1;
if ( rnorm == 0 || rnorm < eps_abs )
{
if ( verbose > 0 && ParallelDescriptor::IOProcessor(color()) )
{
Spacer(std::cout, lev);
std::cout << " CG: niter = 0,"
<< ", rnorm = " << rnorm
<< ", eps_rel*(Lp_norm*sol_norm + rnorm0 )" << eps_rel*(Lp_norm*sol_norm + rnorm0 )
<< ", eps_abs = " << eps_abs << std::endl;
}
return 0;
}
for (; nit <= maxiter; ++nit)
{
if (use_jbb_precond && ParallelDescriptor::NProcs(color()) > 1)
{
z.setVal(0);
jbb_precond(z,r,lev,Lp);
}
else
{
MultiFab::Copy(z,r,0,0,1,0);
}
Real rho = dotxy(z,r);
if (nit == 1)
{
MultiFab::Copy(p,z,0,0,1,0);
}
else
{
Real beta = rho/rho_1;
sxay(p, z, beta, p);
}
Lp.apply(q, p, lev, temp_bc_mode);
Real alpha;
if ( Real pw = dotxy(p,q) )
{
alpha = rho/pw;
}
else
{
ret = 1; break;
//.........这里部分代码省略.........