本文整理汇总了C++中UList::size方法的典型用法代码示例。如果您正苦于以下问题:C++ UList::size方法的具体用法?C++ UList::size怎么用?C++ UList::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UList
的用法示例。
在下文中一共展示了UList::size方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: forAll
void Foam::fileFormats::OFSsurfaceFormatCore::writeHeader
(
Ostream& os,
const pointField& pointLst,
const UList<surfZone>& zoneLst
)
{
// just emit some information until we get a nice IOobject
IOobject::writeBanner(os)
<< "// OpenFOAM Surface Format - written "
<< clock::dateTime().c_str() << nl
<< "// ~~~~~~~~~~~~~~~~~~~~~~~" << nl << nl
<< "// surfZones:" << nl;
// treat a single zone as being unzoned
if (zoneLst.size() <= 1)
{
os << "0" << token::BEGIN_LIST << token::END_LIST << nl << nl;
}
else
{
os << zoneLst.size() << nl << token::BEGIN_LIST << incrIndent << nl;
forAll(zoneLst, zoneI)
{
zoneLst[zoneI].writeDict(os);
}
os << decrIndent << token::END_LIST << nl << nl;
}
示例2: abort
void Foam::AMIInterpolation::interpolateToTarget
(
const UList<Type>& fld,
const CombineOp& cop,
List<Type>& result,
const UList<Type>& defaultValues
) const
{
if (fld.size() != srcAddress_.size())
{
FatalErrorInFunction
<< "Supplied field size is not equal to source patch size" << nl
<< " source patch = " << srcAddress_.size() << nl
<< " target patch = " << tgtAddress_.size() << nl
<< " supplied field = " << fld.size()
<< abort(FatalError);
}
if (lowWeightCorrection_ > 0)
{
if (defaultValues.size() != tgtAddress_.size())
{
FatalErrorInFunction
<< "Employing default values when sum of weights falls below "
<< lowWeightCorrection_
<< " but supplied default field size is not equal to target "
<< "patch size" << nl
<< " default values = " << defaultValues.size() << nl
<< " target patch = " << tgtAddress_.size() << nl
<< abort(FatalError);
}
}
result.setSize(tgtAddress_.size());
if (singlePatchProc_ == -1)
{
const mapDistribute& map = srcMapPtr_();
List<Type> work(fld);
map.distribute(work);
forAll(result, facei)
{
if (tgtWeightsSum_[facei] < lowWeightCorrection_)
{
result[facei] = defaultValues[facei];
}
else
{
const labelList& faces = tgtAddress_[facei];
const scalarList& weights = tgtWeights_[facei];
forAll(faces, i)
{
cop(result[facei], facei, work[faces[i]], weights[i]);
}
}
}
}
示例3: ParentType
Foam::UnsortedMeshedSurface<Face>::UnsortedMeshedSurface
(
const Xfer< pointField >& pointLst,
const Xfer< List<Face> >& faceLst,
const UList<label>& zoneSizes,
const UList<word>& zoneNames
)
:
ParentType(pointLst, faceLst)
{
if (zoneSizes.size())
{
if (zoneNames.size())
{
setZones(zoneSizes, zoneNames);
}
else
{
setZones(zoneSizes);
}
}
else
{
setOneZone();
}
}
示例4: abort
void Foam::syncTools::swapBoundaryCellPositions
(
const polyMesh& mesh,
const UList<point>& cellData,
List<point>& neighbourCellData
)
{
if (cellData.size() != mesh.nCells())
{
FatalErrorInFunction
<< "Number of cell values " << cellData.size()
<< " is not equal to the number of cells in the mesh "
<< mesh.nCells() << abort(FatalError);
}
const polyBoundaryMesh& patches = mesh.boundaryMesh();
label nBnd = mesh.nFaces()-mesh.nInternalFaces();
neighbourCellData.setSize(nBnd);
forAll(patches, patchI)
{
const polyPatch& pp = patches[patchI];
const labelUList& faceCells = pp.faceCells();
forAll(faceCells, i)
{
label bFaceI = pp.start()+i-mesh.nInternalFaces();
neighbourCellData[bFaceI] = cellData[faceCells[i]];
}
}
示例5: sumProd
scalar sumProd(const UList<scalar>& f1, const UList<scalar>& f2)
{
if (f1.size() && (f1.size() == f2.size()))
{
scalar SumProd = 0.0;
TFOR_ALL_S_OP_F_OP_F(scalar, SumProd, +=, scalar, f1, *, scalar, f2)
return SumProd;
}
示例6: if
void Foam::processorLduInterface::compressedReceive
(
const Pstream::commsTypes commsType,
UList<Type>& f
) const
{
if (sizeof(scalar) != sizeof(float) && Pstream::floatTransfer && f.size())
{
static const label nCmpts = sizeof(Type)/sizeof(scalar);
label nm1 = (f.size() - 1)*nCmpts;
label nlast = sizeof(Type)/sizeof(float);
label nFloats = nm1 + nlast;
label nBytes = nFloats*sizeof(float);
if
(
commsType == Pstream::commsTypes::blocking
|| commsType == Pstream::commsTypes::scheduled
)
{
resizeBuf(receiveBuf_, nBytes);
IPstream::read
(
commsType,
neighbProcNo(),
receiveBuf_.begin(),
nBytes,
tag(),
comm()
);
}
else if (commsType != Pstream::commsTypes::nonBlocking)
{
FatalErrorInFunction
<< "Unsupported communications type " << int(commsType)
<< exit(FatalError);
}
const float *fArray =
reinterpret_cast<const float*>(receiveBuf_.begin());
f.last() = reinterpret_cast<const Type&>(fArray[nm1]);
scalar *sArray = reinterpret_cast<scalar*>(f.begin());
const scalar *slast = &sArray[nm1];
for (label i=0; i<nm1; i++)
{
sArray[i] = fArray[i] + slast[i%nCmpts];
}
}
else
{
this->receive<Type>(commsType, f);
}
}
示例7: sizeof
void Foam::Pstream::exchange
(
const UList<Container>& sendBufs,
const labelUList& recvSizes,
List<Container>& recvBufs,
const int tag,
const label comm,
const bool block
)
{
if (!contiguous<T>())
{
FatalErrorInFunction
<< "Continuous data only." << sizeof(T) << Foam::abort(FatalError);
}
if (sendBufs.size() != UPstream::nProcs(comm))
{
FatalErrorInFunction
<< "Size of list " << sendBufs.size()
<< " does not equal the number of processors "
<< UPstream::nProcs(comm)
<< Foam::abort(FatalError);
}
recvBufs.setSize(sendBufs.size());
recvBufs.setSize(sendBufs.size());
if (UPstream::parRun() && UPstream::nProcs(comm) > 1)
{
label startOfRequests = Pstream::nRequests();
// Set up receives
// ~~~~~~~~~~~~~~~
forAll(recvSizes, proci)
{
label nRecv = recvSizes[proci];
if (proci != Pstream::myProcNo(comm) && nRecv > 0)
{
recvBufs[proci].setSize(nRecv);
UIPstream::read
(
UPstream::commsTypes::nonBlocking,
proci,
reinterpret_cast<char*>(recvBufs[proci].begin()),
nRecv*sizeof(T),
tag,
comm
);
}
}
示例8: forAll
void Foam::fileFormats::VTKedgeFormat::writeEdges
(
Ostream& os,
const UList<edge>& edgeLst
)
{
os << "LINES " << edgeLst.size() << ' ' << 3*edgeLst.size() << nl;
forAll(edgeLst, edgeI)
{
const edge& e = edgeLst[edgeI];
os << "2 " << e[0] << ' ' << e[1] << nl;
}
}
示例9: boundBox
// Construct as the bounding box of the given pointField
Foam::treeBoundBox::treeBoundBox
(
const UList<point>& points,
const UList<label>& meshPoints
)
:
boundBox()
{
if (points.empty() || meshPoints.empty())
{
WarningIn
(
"treeBoundBox::treeBoundBox"
"(const UList<point>&, const UList<label>&)"
) << "cannot find bounding box for zero-sized pointField"
<< "returning zero" << endl;
return;
}
min() = points[meshPoints[0]];
max() = points[meshPoints[0]];
for (label i = 1; i < meshPoints.size(); i++)
{
min() = ::Foam::min(min(), points[meshPoints[i]]);
max() = ::Foam::max(max(), points[meshPoints[i]]);
}
}
示例10: point
void Foam::boundBox::calculate(const UList<point>& points, const bool doReduce)
{
if (points.empty())
{
min_ = Zero;
max_ = Zero;
if (doReduce && Pstream::parRun())
{
// Use values that get overwritten by reduce minOp, maxOp below
min_ = point(VGREAT, VGREAT, VGREAT);
max_ = point(-VGREAT, -VGREAT, -VGREAT);
}
}
else
{
min_ = points[0];
max_ = points[0];
for (label i = 1; i < points.size(); i++)
{
min_ = ::Foam::min(min_, points[i]);
max_ = ::Foam::max(max_, points[i]);
}
}
// Reduce parallel information
if (doReduce)
{
reduce(min_, minOp<point>());
reduce(max_, maxOp<point>());
}
}
示例11: size
inline void Foam::DecoupledCoeffField<Type>::checkSize
(
const UList<Type2>& f
) const
{
if (f.size() != this->size())
{
FatalErrorIn
(
"void DecoupledCoeffField<Type>::checkSize("
"const Field<Type2>& f) const"
) << "Incorrect field size: " << f.size()
<< " local size: " << size()
<< abort(FatalError);
}
}
示例12: sum
Foam::label Foam::mergePoints
(
const UList<Type>& points,
const scalar mergeTol,
const bool verbose,
labelList& pointMap,
const Type& origin
)
{
Type compareOrigin = origin;
if (origin == Type::max)
{
if (points.size())
{
compareOrigin = sum(points)/points.size();
}
}
// Create a old to new point mapping array
pointMap.setSize(points.size());
pointMap = -1;
if (points.empty())
{
return points.size();
}
// We're comparing distance squared to origin first.
// Say if starting from two close points:
// x, y, z
// x+mergeTol, y+mergeTol, z+mergeTol
// Then the magSqr of both will be
// x^2+y^2+z^2
// x^2+y^2+z^2 + 2*mergeTol*(x+z+y) + mergeTol^2*...
// so the difference will be 2*mergeTol*(x+y+z)
const scalar mergeTolSqr = Foam::sqr(scalar(mergeTol));
// Sort points by magSqr
const Field<Type> d(points - compareOrigin);
List<scalar> magSqrD(d.size());
forAll(d, pointI)
{
magSqrD[pointI] = magSqr(d[pointI]);
}
示例13: procSlot
void Foam::globalIndex::gather
(
const labelUList& off,
const label comm,
const labelList& procIDs,
const UList<Type>& fld,
List<Type>& allFld,
const int tag,
const Pstream::commsTypes commsType
)
{
if (Pstream::myProcNo(comm) == procIDs[0])
{
allFld.setSize(off.last());
// Assign my local data
SubList<Type>(allFld, fld.size(), 0) = fld;
if
(
commsType == Pstream::commsTypes::scheduled
|| commsType == Pstream::commsTypes::blocking
)
{
for (label i = 1; i < procIDs.size(); i++)
{
SubList<Type> procSlot(allFld, off[i+1]-off[i], off[i]);
if (contiguous<Type>())
{
IPstream::read
(
commsType,
procIDs[i],
reinterpret_cast<char*>(procSlot.begin()),
procSlot.byteSize(),
tag,
comm
);
}
else
{
IPstream fromSlave
(
commsType,
procIDs[i],
0,
tag,
comm
);
fromSlave >> procSlot;
}
}
}
else
{
// nonBlocking
if (!contiguous<Type>())
示例14: forAll
Foam::HashSet<Key, Hash>::HashSet(const UList<Key>& lst)
:
HashTable<nil, Key, Hash>(2*lst.size())
{
forAll(lst, elemI)
{
this->insert(lst[elemI]);
}
示例15: forAll
void Foam::fileFormats::VTKsurfaceFormat<Face>::writeHeaderPolygons
(
Ostream& os,
const UList<Face>& faceLst
)
{
label nNodes = 0;
forAll(faceLst, faceI)
{
nNodes += faceLst[faceI].size();
}
os << nl
<< "POLYGONS " << faceLst.size() << ' '
<< faceLst.size() + nNodes << nl;
}