本文整理汇总了C++中BoxArray::size方法的典型用法代码示例。如果您正苦于以下问题:C++ BoxArray::size方法的具体用法?C++ BoxArray::size怎么用?C++ BoxArray::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BoxArray
的用法示例。
在下文中一共展示了BoxArray::size方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: face
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';
}
}
}
}
示例2: lbox
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]);
}
示例3: lo
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());
}
示例4:
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);
}
示例5: cdr
//.........这里部分代码省略.........
#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];
示例6: BoxArray
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);
}
示例7: domain
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));
//.........这里部分代码省略.........