本文整理匯總了C++中BL_ASSERT函數的典型用法代碼示例。如果您正苦於以下問題:C++ BL_ASSERT函數的具體用法?C++ BL_ASSERT怎麽用?C++ BL_ASSERT使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了BL_ASSERT函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: BL_ASSERT
void
BaseFab<Real>::performSetVal (Real val,
const Box& bx,
int comp,
int ncomp)
{
BL_ASSERT(domain.contains(bx));
BL_ASSERT(comp >= 0 && comp + ncomp <= nvar);
Real* data = dataPtr(comp);
if (bx == domain)
{
for (long i = 0, N = ncomp*numpts; i < N; i++)
{
*data++ = val;
}
}
else
{
const int* _box_lo = bx.loVect();
const int* _box_hi = bx.hiVect();
const int* _th_plo = loVect();
const int* _th_phi = hiVect();
FORT_FASTSETVAL(&val,
_box_lo,
_box_hi,
data,
ARLIM(_th_plo),
ARLIM(_th_phi),
&ncomp);
}
}
示例2: average_face_to_cellcenter
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);
}
}
示例3: BL_ASSERT
Real
FMultiGrid::solve (PArray<MultiFab>& phi,
PArray<MultiFab>& rhs,
Real rel_tol, Real abs_tol,
int always_use_bnorm ,
int need_grad_phi,
int verbose)
{
BL_ASSERT( m_bc.initilized || m_bndry != 0);
BL_ASSERT(!(m_bc.initilized && m_bndry != 0));
BL_ASSERT(m_coeff.eq_type != invalid_eq);
BL_ASSERT(m_mgt_solver == 0);
MultiFab* phi_p[m_nlevels];
MultiFab* rhs_p[m_nlevels];
for (int ilev=0; ilev < m_nlevels; ++ilev)
{
phi_p[ilev] = &phi[ilev];
rhs_p[ilev] = &rhs[ilev];
}
init_mgt_solver(phi);
Real final_resnorm;
m_mgt_solver->solve(phi_p, rhs_p, *m_bndry, rel_tol, abs_tol,
always_use_bnorm, final_resnorm, need_grad_phi);
return final_resnorm;
}
示例4: BL_ASSERT
void
BoxList::catenate (BoxList& blist)
{
BL_ASSERT(ixType() == blist.ixType());
lbox.splice(lbox.end(), blist.lbox);
BL_ASSERT(blist.isEmpty());
}
示例5: sm
Box
Box::chop (int dir,
int chop_pnt)
{
//
// Define new high end Box including chop_pnt.
//
IntVect sm(smallend);
IntVect bg(bigend);
sm.setVal(dir,chop_pnt);
if (btype[dir])
{
//
// NODE centered Box.
//
BL_ASSERT(chop_pnt > smallend[dir] && chop_pnt < bigend[dir]);
//
// Shrink original Box to just contain chop_pnt.
//
bigend.setVal(dir,chop_pnt);
}
else
{
//
// CELL centered Box.
//
BL_ASSERT(chop_pnt > smallend[dir] && chop_pnt <= bigend[dir]);
//
// Shrink origional Box to one below chop_pnt.
//
bigend.setVal(dir,chop_pnt-1);
}
return Box(sm,bg,btype);
}
示例6: BL_ASSERT
void
StateData::copyNew (const StateData& state)
{
BL_ASSERT(state.hasNewData());
BL_ASSERT(new_data != 0);
const MultiFab& MF = state.newData();
int nc = MF.nComp();
int ng = MF.nGrow();
BL_ASSERT(nc == (*new_data).nComp());
BL_ASSERT(ng == (*new_data).nGrow());
MultiFab::Copy(*new_data, state.newData(), 0, 0, nc, ng);
StateDescriptor::TimeCenter t_typ(desc->timeType());
if (t_typ == StateDescriptor::Point)
{
new_time.start = new_time.stop = state.curTime();
}
else
{
Real dt = state.curTime() - state.prevTime();
new_time.start = state.curTime() - dt/2.0;
new_time.stop = state.curTime() + dt/2.0;
}
}
示例7: BL_ASSERT
void
ABec4::aCoefficients (const MultiFab& _a)
{
BL_ASSERT(_a.ok());
BL_ASSERT(_a.boxArray() == (acoefs[0])->boxArray());
invalidate_a_to_level(0);
MultiFab::Copy(*acoefs[0],_a,0,0,acoefs[0]->nComp(),acoefs[0]->nGrow());
}
示例8: StoreObject
//----------------------------------------------------------------------------
// like C-style
void StoreObject(int i, int maxCntObject, std::string nameClass, void* pThis)
{
static TMapStrInt mMapClassCnt;// для нахождения по имени класса макс. кол-ва объектов
static TMapPtrStr mMapPtrName; // по указателю на объект имя класса
int cntMake = 0;
bool res = false;
LockThread(nsLockThread::eLock);// блокировка
switch(i)
{
case nsStoreObject::ePush:
{
//-------------------------------
TMapStrInt::iterator fit = mMapClassCnt.find(nameClass);
if(fit==mMapClassCnt.end())
{
// не нашли - добавить
mMapClassCnt.insert(TMapStrInt::value_type(nameClass,1));
fit = mMapClassCnt.find(nameClass);
// что бы потом найти в деструкторе
mMapPtrName.insert(TMapPtrStr::value_type(pThis,nameClass));
}
else
fit->second++;
cntMake = fit->second;
}
break;
case nsStoreObject::ePop:
{
//-------------------------------
TMapPtrStr::iterator fit_name = mMapPtrName.find(pThis);
if(fit_name!=mMapPtrName.end())
{
TMapStrInt::iterator fit = mMapClassCnt.find(fit_name->second);
if(fit!=mMapClassCnt.end())
{
fit->second--;
cntMake = fit->second;
res = true;
}
}
}
break;
}
LockThread(nsLockThread::eUnlock);// разблокировать
// проверка результатов
switch(i)
{
case nsStoreObject::ePush:
BL_ASSERT(cntMake <= maxCntObject);
break;
case nsStoreObject::ePop:
BL_ASSERT(cntMake >= 0 && res);
break;
}
}
示例9: BL_PROFILE
void
BoxLib::WriteMultiLevelPlotfile (const std::string& plotfilename, int nlevels,
const Array<const MultiFab*>& mf,
const Array<std::string>& varnames,
const Array<Geometry>& geom, Real time, const Array<int>& level_steps,
const Array<IntVect>& ref_ratio)
{
BL_PROFILE("WriteMultiLevelPlotfile()");
BL_ASSERT(nlevels <= mf.size());
BL_ASSERT(nlevels <= geom.size());
BL_ASSERT(nlevels <= ref_ratio.size()+1);
BL_ASSERT(nlevels <= level_steps.size());
BL_ASSERT(mf[0]->nComp() == varnames.size());
int finest_level = nlevels-1;
//
// Only let 64 CPUs be writing at any one time.
//
int saveNFiles(VisMF::GetNOutFiles());
VisMF::SetNOutFiles(64);
const std::string versionName("HyperCLaw-V1.1");
const std::string levelPrefix("Level_");
const std::string mfPrefix("Cell");
bool callBarrier(true);
BoxLib::PreBuildDirectorHierarchy(plotfilename, levelPrefix, nlevels, callBarrier);
if (ParallelDescriptor::IOProcessor()) {
std::string HeaderFileName(plotfilename + "/Header");
std::ofstream HeaderFile(HeaderFileName.c_str(), std::ofstream::out |
std::ofstream::trunc |
std::ofstream::binary);
if( ! HeaderFile.good()) {
BoxLib::FileOpenFailed(HeaderFileName);
}
Array<BoxArray> boxArrays(nlevels);
for(int level(0); level < boxArrays.size(); ++level) {
boxArrays[level] = mf[level]->boxArray();
}
BoxLib::WriteGenericPlotfileHeader(HeaderFile, nlevels, boxArrays, varnames,
geom, time, level_steps, ref_ratio);
}
for (int level = 0; level <= finest_level; ++level)
{
VisMF::Write(*mf[level], MultiFabFileFullPrefix(level, plotfilename, levelPrefix, mfPrefix));
}
VisMF::SetNOutFiles(saveNFiles);
}
示例10: BL_ASSERT
CArena::CArena (size_t hunk_size)
{
//
// Force alignment of hunksize.
//
m_hunk = Arena::align(hunk_size == 0 ? DefaultHunkSize : hunk_size);
m_used = 0;
BL_ASSERT(m_hunk >= hunk_size);
BL_ASSERT(m_hunk%Arena::align_size == 0);
}
示例11: BL_ASSERT
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);
}
示例12: BL_ASSERT
void
AuxBoundaryData::copy (const AuxBoundaryData& src,
int src_comp,
int dst_comp,
int num_comp)
{
if (m_empty || src.m_empty) return;
BL_ASSERT(m_initialized);
BL_ASSERT(src_comp + num_comp <= src.m_fabs.nComp());
BL_ASSERT(dst_comp + num_comp <= m_fabs.nComp());
m_fabs.copy(src.m_fabs,src_comp,dst_comp,num_comp);
}
示例13: BL_ASSERT
bool
StateDescriptor::identicalInterps (int scomp,
int ncomp) const
{
BL_ASSERT(scomp >= 0);
BL_ASSERT(ncomp >= 1);
Interpolater* map = interp(scomp);
for (int i = scomp+1; i < scomp+ncomp; i++)
if (!(map == interp(i)))
return false;
return true;
}
示例14: 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);
}
示例15: BL_ASSERT
void
Box::next (IntVect& p,
const int* shv) const
{
BL_ASSERT(contains(p));
#if BL_SPACEDIM==1
p.shift(0,shv[0]);
#elif BL_SPACEDIM==2
p.shift(0,shv[0]);
if (!(p <= bigend))
{
//
// Reset 1 coord is on edge, and 2 coord is incremented.
//
p.setVal(0,smallend[0]);
p.shift(1,shv[1]);
}
#elif BL_SPACEDIM==3
p.shift(0,shv[0]);
if (!(p <= bigend))
{
//
// Reset 1 coord is on edge, and 2 coord is incremented.
//
p.setVal(0,smallend[0]);
p.shift(1,shv[1]);
if(!(p <= bigend))
{
p.setVal(1,smallend[1]);
p.shift(2,shv[2]);
}
}
#endif
}