本文整理匯總了C++中Interval::size方法的典型用法代碼示例。如果您正苦於以下問題:C++ Interval::size方法的具體用法?C++ Interval::size怎麽用?C++ Interval::size使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Interval
的用法示例。
在下文中一共展示了Interval::size方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: thisBox
// ---------------------------------------------------------
// 27 March 2003:
// This is called by other functions, and should not be called directly.
Real
maxnorm(const BoxLayoutData<NodeFArrayBox>& a_layout,
const Interval& a_interval,
bool a_verbose)
{
Real normTotal = 0.;
// a_p == 0: max norm
for (DataIterator it = a_layout.dataIterator(); it.ok(); ++it)
{
const Box& thisBox(a_layout.box(it())); // CELL-centered
const NodeFArrayBox& thisNfab = a_layout[it()];
Real thisNfabNorm =
maxnorm(thisNfab, thisBox, a_interval.begin(), a_interval.size());
if (a_verbose)
cout << "maxnorm(" << thisBox << ") = " << thisNfabNorm << endl;
normTotal = Max(normTotal, thisNfabNorm);
}
# ifdef CH_MPI
Real recv;
int result = MPI_Allreduce(&normTotal, &recv, 1, MPI_CH_REAL,
MPI_MAX, Chombo_MPI::comm);
if (result != MPI_SUCCESS)
{ //bark!!!
MayDay::Error("sorry, but I had a communication error on maxnorm");
}
normTotal = recv;
# endif
return normTotal;
}
示例2: thisBox
// ---------------------------------------------------------
// 28 March 2003:
// This is called by other functions, and should not be called directly.
Real
integral(const BoxLayoutData<NodeFArrayBox>& a_layout,
const Real a_dx,
const Interval& a_interval,
bool a_verbose)
{
Real integralTotal = 0.;
for (DataIterator it = a_layout.dataIterator(); it.ok(); ++it)
{
const NodeFArrayBox& thisNfab = a_layout[it()];
const Box& thisBox(a_layout.box(it())); // CELL-centered
Real thisNfabIntegral =
integral(thisNfab, a_dx, thisBox,
a_interval.begin(), a_interval.size());
integralTotal += thisNfabIntegral;
}
# ifdef CH_MPI
Real recv;
// add up
int result = MPI_Allreduce(&integralTotal, &recv, 1, MPI_CH_REAL,
MPI_SUM, Chombo_MPI::comm);
if (result != MPI_SUCCESS)
{ //bark!!!
MayDay::Error("sorry, but I had a communication error on integral");
}
integralTotal = recv;
# endif
return integralTotal;
}
示例3: construct
void IntensityDistributionHistogram::construct( const Billon &billon, const Interval<uint> &sliceInterval, const Interval<int> &intensityInterval, const uint &smoothingRadius )
{
const uint &width = billon.n_cols;
const uint &height = billon.n_rows;
const int &minVal = intensityInterval.min();
uint i, j, k;
clear();
resize(intensityInterval.size()+1);
for ( k=sliceInterval.min() ; k<=sliceInterval.max() ; ++k )
{
const Slice &slice = billon.slice(k);
for ( j=0 ; j<height ; ++j )
{
for ( i=0 ; i<width ; ++i )
{
if ( intensityInterval.containsClosed(slice.at(j,i)) ) ++((*this)[slice.at(j,i)-minVal]);
}
}
}
meansSmoothing(smoothingRadius,false);
}
示例4: newcomps
// ------------------------------------------------------------
// version of 27 March 2003: no finer level
Real
integral(const LevelData<NodeFArrayBox>& a_phi,
const ProblemDomain& a_domain,
const LayoutData< Vector<IntVectSet> >& a_IVSVext,
const Real a_dx,
const Interval a_comps,
bool a_verbose)
{
// Idea: copy a_phi to temp, then zero out temp on
// exterior nodes of grids at this level.
int ncomps = a_comps.size();
const DisjointBoxLayout& grids = a_phi.getBoxes();
LevelData<NodeFArrayBox> temp(grids, ncomps);
// Copy a_phi to temp.
Interval newcomps(0, ncomps-1);
for (DataIterator dit(grids.dataIterator()); dit.ok(); ++dit)
{
const NodeFArrayBox& nfab = a_phi[dit()];
const Box& bx = grids.get(dit());
temp[dit()].copy(bx, newcomps, bx, nfab, a_comps);
}
// Zero out temp on exterior nodes.
zeroBoundaryNodes(temp, a_IVSVext);
Real integralLevel = integral(temp, a_dx, newcomps, a_verbose);
return integralLevel;
}
示例5: incrementFine
void
LevelFluxRegisterEdge::incrementFine(
FArrayBox& a_fineFlux,
Real a_scale,
const DataIndex& a_fineDataIndex,
const Interval& a_srcInterval,
const Interval& a_dstInterval)
{
CH_assert(isDefined());
CH_assert(!a_fineFlux.box().isEmpty());
CH_assert(a_srcInterval.size() == a_dstInterval.size());
CH_assert(a_srcInterval.begin() >= 0);
CH_assert(a_srcInterval.end() < a_fineFlux.nComp());
CH_assert(a_dstInterval.begin() >= 0);
CH_assert(a_dstInterval.end() < m_nComp);
int edgeDir = -1;
for (int sideDir = 0; sideDir<SpaceDim; sideDir++)
{
if (a_fineFlux.box().type(sideDir) == IndexType::CELL)
{
edgeDir = sideDir;
}
}
CH_assert(edgeDir >= 0);
CH_assert(edgeDir < SpaceDim);
for (int faceDir=0; faceDir<SpaceDim; faceDir++)
{
if (faceDir != edgeDir)
{
SideIterator sit;
for (sit.begin(); sit.ok(); ++sit)
{
incrementFine(a_fineFlux,
a_scale,
a_fineDataIndex,
a_srcInterval,
a_dstInterval,
faceDir,
sit());
}
}
}
}
示例6: linearIn
virtual void linearIn(EBCellFAB& arg, void* buf, const Box& R,
const Interval& comps) const
{
EBCellFAB tmp;
tmp.clone(arg);
tmp.linearIn(buf, R, comps);
arg.plus(tmp, R, comps.begin(), comps.begin(), comps.size());
}
示例7: op
void op(EBCellFAB& dest,
const Box& RegionFrom,
const Interval& Cdest,
const Box& RegionTo,
const EBCellFAB& src,
const Interval& Csrc) const
{
dest.plus(src, RegionFrom, Csrc.begin(), Cdest.begin(), Cdest.size());
}
示例8: sign
void
MappedLevelFluxRegister::incrementCoarse(const FArrayBox& a_coarseFlux,
Real a_scale,
const DataIndex& a_coarseDataIndex,
const Interval& a_srcInterval,
const Interval& a_dstInterval,
int a_dir,
Side::LoHiSide a_sd)
{
CH_assert(isDefined());
if (!(m_isDefined & FluxRegCoarseDefined)) return;
CH_TIME("MappedLevelFluxRegister::incrementCoarse");
const Vector<Box>& intersect =
m_coarseLocations[a_dir + a_sd * CH_SPACEDIM][a_coarseDataIndex];
FArrayBox& coarse = m_coarFlux[a_coarseDataIndex];
// We cast away the constness in a_coarseFlux for the scope of this function. This
// should be acceptable, since at the end of the day there is no change to it. -JNJ
FArrayBox& coarseFlux = const_cast<FArrayBox&>(a_coarseFlux); // Muhahaha.
coarseFlux.shiftHalf(a_dir, sign(a_sd));
Real scale = -sign(a_sd) * a_scale;
int s = a_srcInterval.begin();
int d = a_dstInterval.begin();
int size = a_srcInterval.size();
for (int b = 0; b < intersect.size(); ++b) {
const Box& box = intersect[b];
Vector<Real> regbefore(coarse.nComp());
Vector<Real> regafter(coarse.nComp());
if (s_verbose && (a_dir == debugdir) && box.contains(ivdebnoeb)) {
for (int ivar = 0; ivar < coarse.nComp(); ivar++) {
regbefore[ivar] = coarse(ivdebnoeb, ivar);
}
}
coarse.plus(coarseFlux, box, box, scale, s, d, size);
if (s_verbose && (a_dir == debugdir) && box.contains(ivdebnoeb)) {
for (int ivar = 0; ivar < coarse.nComp(); ivar++) {
regafter[ivar] = coarse(ivdebnoeb, ivar);
}
pout() << "levelfluxreg::incrementCoar: scale = " << scale << ", ";
for (int ivar = 0; ivar < coarse.nComp(); ivar++) {
pout() << " input flux = " << coarseFlux(ivdebnoeb, ivar) << ", ";
pout() << " reg before = " << regbefore[ivar] << ", ";
pout() << " reg after = " << regafter[ivar] << ", ";
}
pout() << endl;
}
}
coarseFlux.shiftHalf(a_dir, - sign(a_sd));
}
示例9: dataMasked
// ---------------------------------------------------------
// 7 Dec 2005
Real
maxnorm(const BoxLayoutData<NodeFArrayBox>& a_layout,
const LevelData<NodeFArrayBox>& a_mask,
const ProblemDomain& a_domain,
const Interval& a_interval,
bool a_verbose)
{
Real normTotal = 0.;
// a_p == 0: max norm
int ncomp = a_interval.size();
for (DataIterator it = a_layout.dataIterator(); it.ok(); ++it)
{
const NodeFArrayBox& thisNfab = a_layout[it()];
const FArrayBox& dataFab = thisNfab.getFab();
const FArrayBox& maskFab = a_mask[it()].getFab();
const Box& thisBox(a_layout.box(it())); // CELL-centered
NodeFArrayBox dataMasked(thisBox, ncomp);
FArrayBox& dataMaskedFab = dataMasked.getFab();
dataMaskedFab.copy(dataFab);
// dataMaskedFab *= maskFab;
for (int comp = a_interval.begin(); comp <= a_interval.end(); comp++)
{
// Set dataMaskedFab[comp] *= maskFab[0].
dataMaskedFab.mult(maskFab, 0, comp);
}
Real thisNfabNorm =
maxnorm(dataMasked, thisBox, a_interval.begin(), a_interval.size());
if (a_verbose)
cout << "maxnorm(" << thisBox << ") = " << thisNfabNorm << endl;
normTotal = Max(normTotal, thisNfabNorm);
}
# ifdef CH_MPI
Real recv;
// add up (a_p is not 0)
int result = MPI_Allreduce(&normTotal, &recv, 1, MPI_CH_REAL,
MPI_MAX, Chombo_MPI::comm);
if (result != MPI_SUCCESS)
{ //bark!!!
MayDay::Error("sorry, but I had a communication error on norm");
}
normTotal = recv;
# endif
return normTotal;
}
示例10:
void
LevelFluxRegisterEdge::incrementCoarse(FArrayBox& a_coarseFlux,
Real a_scale,
const DataIndex& a_coarseDataIndex,
const Interval& a_srcInterval,
const Interval& a_dstInterval)
{
CH_assert(isDefined());
CH_assert(!a_coarseFlux.box().isEmpty());
CH_assert(a_srcInterval.size() == a_dstInterval.size());
CH_assert(a_srcInterval.begin() >= 0);
CH_assert(a_srcInterval.end() < a_coarseFlux.nComp());
CH_assert(a_dstInterval.begin() >= 0);
CH_assert(a_dstInterval.end() < m_nComp);
// get edge-centering of coarseFlux
const Box& edgeBox = a_coarseFlux.box();
int edgeDir = -1;
for (int dir=0; dir<SpaceDim; dir++)
{
if (edgeBox.type(dir) == IndexType::CELL)
{
if (edgeDir == -1)
{
edgeDir = dir;
}
else
{
// already found a cell-centered direction (should only be
// one for edge-centering)
MayDay::Error("LevelFluxRegisterEdge::incrementCoarse -- e-field not edge-centered");
}
}
} // end loop over directions
CH_assert(edgeDir != -1);
FArrayBox& thisCrseReg = m_regCoarse[a_coarseDataIndex][edgeDir];
thisCrseReg.plus(a_coarseFlux, -a_scale, a_srcInterval.begin(),
a_dstInterval.begin(), a_srcInterval.size());
}
示例11: maxnorm
// ---------------------------------------------------------
// 27 March 2003:
// This is called by other functions, and should not be called directly.
Real
norm(const BoxLayoutData<NodeFArrayBox>& a_layout,
const Real a_dx,
const int a_p,
const Interval& a_interval,
bool a_verbose)
{
if (a_p == 0)
return maxnorm(a_layout, a_interval, a_verbose);
Real normTotal = 0.;
for (DataIterator it = a_layout.dataIterator(); it.ok(); ++it)
{
const NodeFArrayBox& thisNfab = a_layout[it()];
const Box& thisBox(a_layout.box(it())); // CELL-centered
Real thisNfabNorm = norm(thisNfab, a_dx, thisBox, a_p,
a_interval.begin(), a_interval.size());
if (a_verbose)
cout << a_p << "norm(" << thisBox << ") = " << thisNfabNorm << endl;
if (a_p == 1)
{
normTotal += thisNfabNorm;
}
else if (a_p == 2)
{
normTotal += thisNfabNorm * thisNfabNorm;
}
else
{
normTotal += pow(thisNfabNorm, Real(a_p));
}
}
# ifdef CH_MPI
Real recv;
// add up (a_p is not 0)
int result = MPI_Allreduce(&normTotal, &recv, 1, MPI_CH_REAL,
MPI_SUM, Chombo_MPI::comm);
if (result != MPI_SUCCESS)
{ //bark!!!
MayDay::Error("sorry, but I had a communication error on norm");
}
normTotal = recv;
# endif
// now do sqrt, etc
if (a_p == 2)
normTotal = sqrt(normTotal);
else
if ((a_p != 0) && (a_p != 1))
normTotal = pow(normTotal, (Real)1.0/Real(a_p));
return normTotal;
}
示例12: newcomps
// ------------------------------------------------------------
// version of 27 March 2003
Real
norm(const LevelData<NodeFArrayBox>& a_phi,
const ProblemDomain& a_domain,
const DisjointBoxLayout& a_finerGridsCoarsened,
const LayoutData< Vector<Box> >& a_IVSVext,
const LayoutData< Vector<Box> >& a_IVSVintFinerCoarsened,
const int a_nRefFine,
const Real a_dx,
const Interval& a_comps,
const int a_p,
bool a_verbose)
{
// Idea: copy a_phi to temp, then zero out temp on:
// - exterior nodes of grids at this level;
// - projections of interior nodes of the finer grids.
int ncomps = a_comps.size();
const DisjointBoxLayout& grids = a_phi.getBoxes();
LevelData<NodeFArrayBox> temp(grids, ncomps);
// Copy a_phi to temp.
Interval newcomps(0, ncomps-1);
for (DataIterator dit(grids.dataIterator()); dit.ok(); ++dit)
{
const NodeFArrayBox& nfab = a_phi[dit()];
const Box& bx = grids.get(dit());
temp[dit()].copy(bx, newcomps, bx, nfab, a_comps);
}
// Zero out temp on exterior nodes.
zeroBoundaryNodes(temp, a_IVSVext);
// Define zeroCoarsened to be all zero on the coarsened finer grids.
LevelData<NodeFArrayBox>
zeroCoarsened(a_finerGridsCoarsened, ncomps, IntVect::Zero);
for (DataIterator dit(a_finerGridsCoarsened.dataIterator()); dit.ok(); ++dit)
zeroCoarsened[dit()].getFab().setVal(0.);
// Set temp to zero on interior nodes of coarsened finer grids.
copyInteriorNodes(temp, zeroCoarsened, a_IVSVintFinerCoarsened);
Real normLevel = norm(temp, a_dx, a_p, newcomps, a_verbose);
return normLevel;
}
示例13: aliasLevelData
void TimeInterpolatorRK4::interpolate(/// interpolated solution on this level coarsened
LevelData<FArrayBox>& a_U,
/// time interpolation coefficient in range [0:1]
const Real& a_timeInterpCoeff,
/// interval of a_U to fill in
const Interval& a_intvl)
{
CH_assert(m_defined);
CH_assert(m_gotFullTaylorPoly);
CH_assert(a_U.nComp() == m_numStates);
LevelData<FArrayBox> UComp;
aliasLevelData(UComp, &a_U, a_intvl);
// For i in 0:m_numCoeffs-1,
// coeffFirst[i] is index of first component of m_taylorCoeffs
// that corresponds to a coefficient of t^i.
Vector<int> coeffFirst(m_numCoeffs);
int intervalLength = a_intvl.size();
for (int i = 0; i < m_numCoeffs; i++)
{
coeffFirst[i] = a_intvl.begin() + i * m_numStates;
}
DataIterator dit = UComp.dataIterator();
for (dit.begin(); dit.ok(); ++dit)
{
FArrayBox& UFab = UComp[dit];
const FArrayBox& taylorFab = m_taylorCoeffs[dit];
// Evaluate a0 + a1*t + a2*t^2 + a3*t^3
// as a0 + t * (a1 + t * (a2 + t * a3)).
UFab.copy(taylorFab, coeffFirst[m_numCoeffs-1], 0, intervalLength);
for (int ind = m_numCoeffs - 2; ind >=0; ind--)
{
UFab *= a_timeInterpCoeff;
UFab.plus(taylorFab, coeffFirst[ind], 0, intervalLength);
}
}
// dummy statement in order to get around gdb bug
int dummy_unused = 0; dummy_unused = 0;
}
示例14: main
//.........這裏部分代碼省略.........
}
// This is safe to do since b1 and b2 are built with the same layout.
for (i = 0; i < b1.numPatchesLocal(); ++i)
{
b1.patchLocal(i) += 1.5;
b2.patchLocal(i) += 1.5;
}
for (i = 0; i < bb0.numPatchesLocal(); ++i)
{
Patch<Field_t>::Type_t patch = bb0.patchLocal(i);
// tester.out() << "context " << Pooma::context() << ": assigning to patch on bb0 " << i
// << " with domain " << patch.domain() << std::endl;
patch += 1.5;
}
// This is safe to do since bb1 and bb2 are built with the same layout.
for (i = 0; i < bb1.numPatchesLocal(); ++i)
{
bb1.patchLocal(i) += 1.5;
bb2.patchLocal(i) += 1.5;
}
tester.check("cell centered field is 2.5", all(b0 == 2.5));
tester.check("vert centered field is 2.5", all(b1 == 2.5));
tester.check("edge centered field is 2.5", all(b2 == 2.5));
tester.out() << "b0.all():" << std::endl << b0.all() << std::endl;
tester.out() << "b1.all():" << std::endl << b1.all() << std::endl;
tester.out() << "b2.all():" << std::endl << b2.all() << std::endl;
tester.check("didn't write into b0 boundary",
sum(b0.all()) == 2.5 * b0.physicalDomain().size());
tester.check("didn't write into b1 boundary",
sum(b1.all()) == 2.5 * b1.physicalDomain().size());
tester.check("didn't write into b2 boundary",
sum(b2.all()) == 2.5 * b2.physicalDomain().size());
tester.check("cell centered field is 2.5", all(bb0 == 2.5));
tester.check("vert centered field is 2.5", all(bb1 == 2.5));
tester.check("edge centered field is 2.5", all(bb2 == 2.5));
tester.out() << "bb0:" << std::endl << bb0 << std::endl;
tester.out() << "bb1:" << std::endl << bb1 << std::endl;
tester.out() << "bb2:" << std::endl << bb2 << std::endl;
typedef
Field<UniformRectilinearMesh<2>, double,
MultiPatch<GridTag, CompressibleBrickTag_t> > CField_t;
CField_t c0(cell, layout1, origin, spacings);
CField_t c1(vert, layout1, origin, spacings);
CField_t c2(yedge, layout1, origin, spacings);
CField_t cb0(cell, layout0, origin, spacings);
CField_t cb1(vert, layout0, origin, spacings);
CField_t cb2(yedge, layout0, origin, spacings);
c0.all() = 0.0;
c1.all() = 0.0;
c2.all() = 0.0;
c0 = 1.0;
c1 = 1.0;
c2 = 1.0;
cb0.all() = 0.0;
示例15: refbox
void
MappedLevelFluxRegister::incrementFine(const FArrayBox& a_fineFlux,
Real a_scale,
const DataIndex& a_fineDataIndex,
const Interval& a_srcInterval,
const Interval& a_dstInterval,
int a_dir,
Side::LoHiSide a_sd)
{
CH_assert(isDefined());
if (!(m_isDefined & FluxRegFineDefined)) return;
CH_assert(a_srcInterval.size() == a_dstInterval.size());
CH_TIME("MappedLevelFluxRegister::incrementFine");
// We cast away the constness in a_coarseFlux for the scope of this function. This
// should be acceptable, since at the end of the day there is no change to it. -JNJ
FArrayBox& fineFlux = const_cast<FArrayBox&>(a_fineFlux); // Muhahaha.
fineFlux.shiftHalf(a_dir, sign(a_sd));
Real denom = 1.0;
if (m_scaleFineFluxes) {
denom = m_nRefine.product() / m_nRefine[a_dir];
}
Real scale = sign(a_sd) * a_scale / denom;
FArrayBox& cFine = m_fineFlux[a_fineDataIndex];
// FArrayBox cFineFortran(cFine.box(), cFine.nComp());
// cFineFortran.copy(cFine);
Box clipBox = m_fineFlux.box(a_fineDataIndex);
clipBox.refine(m_nRefine);
Box fineBox;
if (a_sd == Side::Lo) {
fineBox = adjCellLo(clipBox, a_dir, 1);
fineBox &= fineFlux.box();
} else {
fineBox = adjCellHi(clipBox, a_dir, 1);
fineBox &= fineFlux.box();
}
#if 0
for (BoxIterator b(fineBox); b.ok(); ++b) {
int s = a_srcInterval.begin();
int d = a_dstInterval.begin();
for (; s <= a_srcInterval.end(); ++s, ++d) {
cFine(coarsen(b(), m_nRefine), d) += scale * fineFlux(b(), s);
}
}
#else
// shifting to ensure fineBox is in the positive quadrant, so IntVect coarening
// is just integer division.
const Box& box = coarsen(fineBox, m_nRefine);
Vector<Real> regbefore(cFine.nComp());
Vector<Real> regafter(cFine.nComp());
if (s_verbose && (a_dir == debugdir) && box.contains(ivdebnoeb)) {
for (int ivar = 0; ivar < cFine.nComp(); ivar++) {
regbefore[ivar] = cFine(ivdebnoeb, ivar);
}
}
const IntVect& iv = fineBox.smallEnd();
IntVect civ = coarsen(iv, m_nRefine);
int srcComp = a_srcInterval.begin();
int destComp = a_dstInterval.begin();
int ncomp = a_srcInterval.size();
FORT_MAPPEDINCREMENTFINE(CHF_CONST_FRA_SHIFT(fineFlux, iv),
CHF_FRA_SHIFT(cFine, civ),
CHF_BOX_SHIFT(fineBox, iv),
CHF_CONST_INTVECT(m_nRefine),
CHF_CONST_REAL(scale),
CHF_CONST_INT(srcComp),
CHF_CONST_INT(destComp),
CHF_CONST_INT(ncomp));
if (s_verbose && (a_dir == debugdir) && box.contains(ivdebnoeb)) {
for (int ivar = 0; ivar < cFine.nComp(); ivar++) {
regafter[ivar] = cFine(ivdebnoeb, ivar);
}
}
if (s_verbose && (a_dir == debugdir) && box.contains(ivdebnoeb)) {
pout() << "levelfluxreg::incrementFine: scale = " << scale << endl;
Box refbox(ivdebnoeb, ivdebnoeb);
refbox.refine(m_nRefine);
refbox &= fineBox;
if (!refbox.isEmpty()) {
pout() << "fine fluxes = " << endl;
for (BoxIterator bit(refbox); bit.ok(); ++bit) {
for (int ivar = 0; ivar < cFine.nComp(); ivar++) {
pout() << "iv = " << bit() << "(";
for (int ivar = 0; ivar < cFine.nComp(); ivar++) {
pout() << fineFlux(bit(), ivar);
}
pout() << ")" << endl;
}
//.........這裏部分代碼省略.........