mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
STYLE: use globalIndex localSize(), totalSize() in more places
- more explicit meaning than offset(), size() - respectively.
This commit is contained in:
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2019-2021 OpenCFD Ltd.
|
||||
Copyright (C) 2019-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -143,11 +143,14 @@ public:
|
||||
|
||||
// Access
|
||||
|
||||
//- True if the number of rows is zero
|
||||
inline bool empty() const noexcept;
|
||||
|
||||
//- The primary size (the number of rows)
|
||||
inline label size() const noexcept;
|
||||
|
||||
//- True if the number of rows is zero
|
||||
inline bool empty() const noexcept;
|
||||
//- The total addressed size
|
||||
inline label totalSize() const;
|
||||
|
||||
//- Return the offset table (= size()+1)
|
||||
inline const List<label>& offsets() const;
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2019-2020 OpenCFD Ltd.
|
||||
Copyright (C) 2019-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -123,6 +123,13 @@ Foam::CompactListList<T, Container>::null()
|
||||
}
|
||||
|
||||
|
||||
template<class T, class Container>
|
||||
inline bool Foam::CompactListList<T, Container>::empty() const noexcept
|
||||
{
|
||||
return !size_;
|
||||
}
|
||||
|
||||
|
||||
template<class T, class Container>
|
||||
inline Foam::label Foam::CompactListList<T, Container>::size() const noexcept
|
||||
{
|
||||
@ -131,9 +138,10 @@ inline Foam::label Foam::CompactListList<T, Container>::size() const noexcept
|
||||
|
||||
|
||||
template<class T, class Container>
|
||||
inline bool Foam::CompactListList<T, Container>::empty() const noexcept
|
||||
inline Foam::label Foam::CompactListList<T, Container>::totalSize() const
|
||||
{
|
||||
return !size_;
|
||||
const label len = (offsets_.size() - 1);
|
||||
return (len < 1) ? static_cast<label>(0) : offsets_[len];
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -157,7 +157,7 @@ void Foam::globalMeshData::calcSharedPoints() const
|
||||
// Allocate global numbers
|
||||
globalIndex masterNumbering(nMaster);
|
||||
|
||||
nGlobalPoints_ = masterNumbering.size();
|
||||
nGlobalPoints_ = masterNumbering.totalSize();
|
||||
|
||||
|
||||
// Push master number to slaves
|
||||
|
||||
@ -158,14 +158,14 @@ void Foam::PatchTools::gatherAndMerge
|
||||
}
|
||||
|
||||
|
||||
mergedFaces.setSize(globalFacesPtr().size());
|
||||
mergedPoints.setSize(globalPointsPtr().size());
|
||||
mergedFaces.setSize(globalFacesPtr().totalSize());
|
||||
mergedPoints.setSize(globalPointsPtr().totalSize());
|
||||
|
||||
// Insert master data first
|
||||
label pOffset = globalPointsPtr().offset(Pstream::masterNo());
|
||||
label pOffset = globalPointsPtr().localStart(Pstream::masterNo());
|
||||
SubList<point>(mergedPoints, myPoints.size(), pOffset) = myPoints;
|
||||
|
||||
label fOffset = globalFacesPtr().offset(Pstream::masterNo());
|
||||
label fOffset = globalFacesPtr().localStart(Pstream::masterNo());
|
||||
SubList<FaceType>(mergedFaces, myFaces.size(), fOffset) = myFaces;
|
||||
|
||||
|
||||
@ -177,11 +177,11 @@ void Foam::PatchTools::gatherAndMerge
|
||||
pointField slavePoints(fromSlave);
|
||||
List<FaceType> slaveFaces(fromSlave);
|
||||
|
||||
label pOffset = globalPointsPtr().offset(slave);
|
||||
label pOffset = globalPointsPtr().localStart(slave);
|
||||
SubList<point>(mergedPoints, slavePoints.size(), pOffset) =
|
||||
slavePoints;
|
||||
|
||||
label fOffset = globalFacesPtr().offset(slave);
|
||||
label fOffset = globalFacesPtr().localStart(slave);
|
||||
SubList<FaceType>(mergedFaces, slaveFaces.size(), fOffset) =
|
||||
slaveFaces;
|
||||
}
|
||||
|
||||
@ -39,8 +39,15 @@ void Foam::globalIndex::reportOverflowAndExit
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Overflow : sum of sizes exceeds labelMax ("
|
||||
<< labelMax << ") after index " << idx << " of "
|
||||
<< flatOutput(localSizes) << nl
|
||||
<< labelMax << ") after index " << idx;
|
||||
|
||||
if (!localSizes.empty())
|
||||
{
|
||||
FatalError << " of " << flatOutput(localSizes);
|
||||
}
|
||||
|
||||
FatalError
|
||||
<< nl
|
||||
<< "Please recompile with larger datatype for label." << nl
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
@ -89,7 +89,7 @@ class globalIndex
|
||||
static void reportOverflowAndExit
|
||||
(
|
||||
const label idx,
|
||||
const labelUList& localSizes
|
||||
const labelUList& localSizes = labelUList::null()
|
||||
);
|
||||
|
||||
public:
|
||||
@ -175,7 +175,7 @@ public:
|
||||
//- Global sum of localSizes. Same as totalSize()
|
||||
inline label size() const;
|
||||
|
||||
//- Global sum of localSizes. Same as size()
|
||||
//- Global sum of localSizes.
|
||||
inline label totalSize() const;
|
||||
|
||||
//- The local sizes
|
||||
@ -285,9 +285,6 @@ public:
|
||||
|
||||
// Global (off-processor) queries
|
||||
|
||||
//- Start of proci data
|
||||
inline label offset(const label proci) const;
|
||||
|
||||
//- Start of proci data
|
||||
inline label localStart(const label proci) const;
|
||||
|
||||
@ -328,6 +325,15 @@ public:
|
||||
inline label whichProcID(const label i) const;
|
||||
|
||||
|
||||
// Housekeeping
|
||||
|
||||
//- Same as localStart
|
||||
label offset(const label proci) const
|
||||
{
|
||||
return localStart(proci);
|
||||
}
|
||||
|
||||
|
||||
// Iteration
|
||||
|
||||
//- Forward input iterator with const access
|
||||
|
||||
@ -187,12 +187,6 @@ inline const Foam::labelUList Foam::globalIndex::localStarts() const
|
||||
}
|
||||
|
||||
|
||||
inline Foam::label Foam::globalIndex::offset(const label proci) const
|
||||
{
|
||||
return offsets_[proci];
|
||||
}
|
||||
|
||||
|
||||
inline Foam::label Foam::globalIndex::localStart(const label proci) const
|
||||
{
|
||||
return offsets_[proci];
|
||||
@ -337,7 +331,7 @@ inline Foam::label Foam::globalIndex::toLocal(const label i) const
|
||||
|
||||
inline Foam::label Foam::globalIndex::whichProcID(const label i) const
|
||||
{
|
||||
if (i < 0 || i >= size())
|
||||
if (i < 0 || i >= totalSize())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Global " << i << " does not belong on any processor."
|
||||
|
||||
@ -54,11 +54,7 @@ Foam::globalIndex::calcListOffsets
|
||||
|
||||
if (checkOverflow && start < values[i])
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Overflow : sum of sizes exceeds labelMax ("
|
||||
<< labelMax << ") after index " << i << nl
|
||||
<< "Please recompile with larger datatype for label." << nl
|
||||
<< exit(FatalError);
|
||||
reportOverflowAndExit(i);
|
||||
}
|
||||
}
|
||||
values[len] = start;
|
||||
@ -98,7 +94,7 @@ void Foam::globalIndex::gather
|
||||
|
||||
if (Pstream::myProcNo(comm) == procIDs[0])
|
||||
{
|
||||
allFld.resize_nocopy(off.last());
|
||||
allFld.resize_nocopy(off.last()); // == totalSize()
|
||||
|
||||
// Assign my local data - respect offset information
|
||||
// so that we can request 0 entries to be copied.
|
||||
@ -198,7 +194,7 @@ void Foam::globalIndex::gather
|
||||
|
||||
if (Pstream::myProcNo(comm) == procIDs[0])
|
||||
{
|
||||
allFld.resize_nocopy(off.last());
|
||||
allFld.resize_nocopy(off.last()); // == totalSize()
|
||||
|
||||
// Assign my local data - respect offset information
|
||||
// so that we can request 0 entries to be copied
|
||||
@ -441,7 +437,7 @@ void Foam::globalIndex::mpiGather
|
||||
nSendBytes = 0;
|
||||
}
|
||||
|
||||
allData.resize_nocopy(globalAddr.size());
|
||||
allData.resize_nocopy(globalAddr.totalSize());
|
||||
|
||||
recvSizes.resize(nproc);
|
||||
recvOffsets.resize(nproc+1);
|
||||
@ -451,7 +447,7 @@ void Foam::globalIndex::mpiGather
|
||||
recvSizes[proci] = globalAddr.localSize(proci) * sizeof(Type);
|
||||
recvOffsets[proci] = globalAddr.localStart(proci) * sizeof(Type);
|
||||
}
|
||||
recvOffsets[nproc] = globalAddr.size() * sizeof(Type);
|
||||
recvOffsets[nproc] = globalAddr.totalSize() * sizeof(Type);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@ -2626,7 +2626,7 @@ void Foam::polyMeshAdder::compactPoints
|
||||
|
||||
// Compact out unused points
|
||||
localPoints.setSize(meshes.size());
|
||||
labelList globalToCompact(globalPoints.size(), -1);
|
||||
labelList globalToCompact(globalPoints.totalSize(), -1);
|
||||
label nGlobal = 0;
|
||||
forAll(meshes, meshi)
|
||||
{
|
||||
|
||||
@ -135,7 +135,7 @@ void Foam::vtk::writeListParallel
|
||||
if (Pstream::master())
|
||||
{
|
||||
// Write master data - with value offset
|
||||
const label offsetId = procOffset.offset(0);
|
||||
const label offsetId = procOffset.localStart(0);
|
||||
for (const label val : values)
|
||||
{
|
||||
vtk::write(fmt, val + offsetId);
|
||||
@ -156,7 +156,7 @@ void Foam::vtk::writeListParallel
|
||||
);
|
||||
|
||||
// With value offset
|
||||
const label offsetId = procOffset.offset(proci);
|
||||
const label offsetId = procOffset.localStart(proci);
|
||||
for (const label val : recvData)
|
||||
{
|
||||
vtk::write(fmt, val + offsetId);
|
||||
|
||||
@ -76,8 +76,8 @@ bool Foam::functionObjects::columnAverage::columnAverageField
|
||||
const labelList& cellToPatchFace = ms.cellToPatchFaceAddressing();
|
||||
|
||||
// Brute force: collect per-global-patchface on all processors
|
||||
Field<Type> regionField(globalFaces_().size(), Zero);
|
||||
labelList regionCount(globalFaces_().size(), 0);
|
||||
Field<Type> regionField(globalFaces_().totalSize(), Zero);
|
||||
labelList regionCount(globalFaces_().totalSize(), Zero);
|
||||
|
||||
forAll(cellToPatchFace, celli)
|
||||
{
|
||||
|
||||
@ -141,7 +141,7 @@ void Foam::functionObjects::externalCoupled::readColumns
|
||||
<< "Trying to read data for processor " << proci
|
||||
<< " row " << rowi
|
||||
<< ". Does your file have as many rows as there are"
|
||||
<< " patch faces (" << globalFaces.size()
|
||||
<< " patch faces (" << globalFaces.totalSize()
|
||||
<< ") ?" << exit(FatalIOError);
|
||||
}
|
||||
|
||||
@ -206,7 +206,7 @@ void Foam::functionObjects::externalCoupled::readLines
|
||||
<< "Trying to read data for processor " << proci
|
||||
<< " row " << rowi
|
||||
<< ". Does your file have as many rows as there are"
|
||||
<< " patch faces (" << globalFaces.size()
|
||||
<< " patch faces (" << globalFaces.totalSize()
|
||||
<< ") ?" << exit(FatalIOError);
|
||||
}
|
||||
|
||||
|
||||
@ -59,7 +59,7 @@ void Foam::functionObjects::nearWallFields::calcAddressing()
|
||||
// Global indexing
|
||||
globalIndex globalWalls(nPatchFaces);
|
||||
|
||||
DebugInFunction << "nPatchFaces: " << globalWalls.size() << endl;
|
||||
DebugInFunction << "nPatchFaces: " << globalWalls.totalSize() << endl;
|
||||
|
||||
// Construct cloud
|
||||
Cloud<findCellParticle> cloud
|
||||
|
||||
@ -563,7 +563,7 @@ bool Foam::functionObjects::streamLineBase::writeToFile()
|
||||
|
||||
const mapDistribute distMap
|
||||
(
|
||||
globalTrackIDs.size(),
|
||||
globalTrackIDs.totalSize(),
|
||||
std::move(sendMap),
|
||||
std::move(recvMap)
|
||||
);
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||
Copyright (C) 2015-2019 OpenCFD Ltd.
|
||||
Copyright (C) 2015-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -107,17 +107,17 @@ void Foam::CellZoneInjection<CloudType>::setPositions
|
||||
|
||||
// Parallel operation manipulations
|
||||
globalIndex globalPositions(positions.size());
|
||||
List<vector> allPositions(globalPositions.size(), point::max);
|
||||
List<label> allInjectorCells(globalPositions.size(), -1);
|
||||
List<label> allInjectorTetFaces(globalPositions.size(), -1);
|
||||
List<label> allInjectorTetPts(globalPositions.size(), -1);
|
||||
List<vector> allPositions(globalPositions.totalSize(), point::max);
|
||||
List<label> allInjectorCells(globalPositions.totalSize(), -1);
|
||||
List<label> allInjectorTetFaces(globalPositions.totalSize(), -1);
|
||||
List<label> allInjectorTetPts(globalPositions.totalSize(), -1);
|
||||
|
||||
// Gather all positions on to all processors
|
||||
SubList<vector>
|
||||
(
|
||||
allPositions,
|
||||
globalPositions.localSize(Pstream::myProcNo()),
|
||||
globalPositions.offset(Pstream::myProcNo())
|
||||
globalPositions.localStart(Pstream::myProcNo())
|
||||
) = positions;
|
||||
|
||||
Pstream::listCombineGather(allPositions, minEqOp<point>());
|
||||
@ -128,19 +128,19 @@ void Foam::CellZoneInjection<CloudType>::setPositions
|
||||
(
|
||||
allInjectorCells,
|
||||
globalPositions.localSize(Pstream::myProcNo()),
|
||||
globalPositions.offset(Pstream::myProcNo())
|
||||
globalPositions.localStart(Pstream::myProcNo())
|
||||
) = injectorCells;
|
||||
SubList<label>
|
||||
(
|
||||
allInjectorTetFaces,
|
||||
globalPositions.localSize(Pstream::myProcNo()),
|
||||
globalPositions.offset(Pstream::myProcNo())
|
||||
globalPositions.localStart(Pstream::myProcNo())
|
||||
) = injectorTetFaces;
|
||||
SubList<label>
|
||||
(
|
||||
allInjectorTetPts,
|
||||
globalPositions.localSize(Pstream::myProcNo()),
|
||||
globalPositions.offset(Pstream::myProcNo())
|
||||
globalPositions.localStart(Pstream::myProcNo())
|
||||
) = injectorTetPts;
|
||||
|
||||
// Transfer data
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2019-2020 OpenCFD Ltd.
|
||||
Copyright (C) 2019-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -92,7 +92,7 @@ inline Foam::scalar Foam::SprayCloud<CloudType>::penetration
|
||||
|
||||
const label nParcel = this->size();
|
||||
globalIndex globalParcels(nParcel);
|
||||
const label nParcelSum = globalParcels.size();
|
||||
const label nParcelSum = globalParcels.totalSize();
|
||||
|
||||
if (nParcelSum == 0)
|
||||
{
|
||||
@ -139,7 +139,7 @@ inline Foam::scalar Foam::SprayCloud<CloudType>::penetration
|
||||
(
|
||||
allMass,
|
||||
globalParcels.localSize(proci),
|
||||
globalParcels.offset(proci)
|
||||
globalParcels.localStart(proci)
|
||||
) = procMass[proci];
|
||||
|
||||
// flatten the distance list
|
||||
@ -147,7 +147,7 @@ inline Foam::scalar Foam::SprayCloud<CloudType>::penetration
|
||||
(
|
||||
allDist,
|
||||
globalParcels.localSize(proci),
|
||||
globalParcels.offset(proci)
|
||||
globalParcels.localStart(proci)
|
||||
) = procDist[proci];
|
||||
}
|
||||
|
||||
|
||||
@ -294,7 +294,7 @@ public:
|
||||
//- Return total number of regions
|
||||
label nRegions() const
|
||||
{
|
||||
return globalNumbering().size();
|
||||
return globalNumbering().totalSize();
|
||||
}
|
||||
|
||||
//- Manually consolidate regions globally by swapping information
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2017-2021 OpenCFD Ltd.
|
||||
Copyright (C) 2017-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -55,15 +55,15 @@ Foam::label Foam::metisLikeDecomp::decomposeGeneral
|
||||
Info<< type() << "Decomp : running in parallel."
|
||||
<< " Decomposing all of graph on master processor." << endl;
|
||||
}
|
||||
globalIndex globalCells(xadj.size()-1);
|
||||
const globalIndex globalCells(xadj.size()-1);
|
||||
label nTotalConnections = returnReduce(adjncy.size(), sumOp<label>());
|
||||
|
||||
// Send all to master. Use scheduled to save some storage.
|
||||
if (Pstream::master())
|
||||
{
|
||||
List<label> allAdjncy(nTotalConnections);
|
||||
List<label> allXadj(globalCells.size()+1);
|
||||
List<scalar> allWeights(globalCells.size());
|
||||
List<label> allXadj(globalCells.totalSize()+1);
|
||||
List<scalar> allWeights(globalCells.totalSize());
|
||||
|
||||
// Insert my own
|
||||
label nTotalCells = 0;
|
||||
@ -117,7 +117,7 @@ Foam::label Foam::metisLikeDecomp::decomposeGeneral
|
||||
(
|
||||
allDecomp,
|
||||
globalCells.localSize(slave),
|
||||
globalCells.offset(slave)
|
||||
globalCells.localStart(slave)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||
Copyright (C) 2017-2021 OpenCFD Ltd.
|
||||
Copyright (C) 2017-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -342,7 +342,7 @@ Foam::labelList Foam::simpleGeomDecomp::decompose
|
||||
// Collect all points on master
|
||||
if (Pstream::master())
|
||||
{
|
||||
pointField allPoints(globalNumbers.size());
|
||||
pointField allPoints(globalNumbers.totalSize());
|
||||
|
||||
label nTotalPoints = 0;
|
||||
// Master first
|
||||
@ -374,7 +374,7 @@ Foam::labelList Foam::simpleGeomDecomp::decompose
|
||||
(
|
||||
finalDecomp,
|
||||
globalNumbers.localSize(subproci),
|
||||
globalNumbers.offset(subproci)
|
||||
globalNumbers.localStart(subproci)
|
||||
);
|
||||
}
|
||||
// Get my own part
|
||||
@ -425,8 +425,8 @@ Foam::labelList Foam::simpleGeomDecomp::decompose
|
||||
// Collect all points on master
|
||||
if (Pstream::master())
|
||||
{
|
||||
pointField allPoints(globalNumbers.size());
|
||||
scalarField allWeights(allPoints.size());
|
||||
pointField allPoints(globalNumbers.totalSize());
|
||||
scalarField allWeights(globalNumbers.totalSize());
|
||||
|
||||
label nTotalPoints = 0;
|
||||
// Master first
|
||||
@ -466,7 +466,7 @@ Foam::labelList Foam::simpleGeomDecomp::decompose
|
||||
(
|
||||
finalDecomp,
|
||||
globalNumbers.localSize(subproci),
|
||||
globalNumbers.offset(subproci)
|
||||
globalNumbers.localStart(subproci)
|
||||
);
|
||||
}
|
||||
// Get my own part
|
||||
|
||||
@ -452,7 +452,7 @@ public:
|
||||
//- Range of global indices that can be returned.
|
||||
virtual label globalSize() const
|
||||
{
|
||||
return globalTris().size();
|
||||
return globalTris().totalSize();
|
||||
}
|
||||
|
||||
virtual void findNearest
|
||||
|
||||
@ -116,7 +116,7 @@ void Foam::faMeshReconstructor::calcAddressing
|
||||
{
|
||||
// Determine the respective local portions of the global ordering
|
||||
|
||||
labelList procTargets(globalFaceNum.size());
|
||||
labelList procTargets(globalFaceNum.totalSize());
|
||||
|
||||
for (const label proci : Pstream::allProcs())
|
||||
{
|
||||
@ -128,7 +128,7 @@ void Foam::faMeshReconstructor::calcAddressing
|
||||
}
|
||||
|
||||
labelList procStarts(globalFaceNum.offsets());
|
||||
labelList procOrders(globalFaceNum.size());
|
||||
labelList procOrders(globalFaceNum.totalSize());
|
||||
|
||||
for (const label globali : globalOrder)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user