ENH: globalIndex: work in local mode

This commit is contained in:
mattijs 2011-12-08 16:24:15 +00:00
parent d21091c788
commit 1f1d559e20
2 changed files with 17 additions and 4 deletions

View File

@ -27,14 +27,22 @@ License
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::globalIndex::globalIndex(const label localSize, const int tag) Foam::globalIndex::globalIndex
(
const label localSize,
const int tag,
const bool parallel
)
: :
offsets_(Pstream::nProcs()+1) offsets_(Pstream::nProcs()+1)
{ {
labelList localSizes(Pstream::nProcs()); labelList localSizes(Pstream::nProcs());
localSizes[Pstream::myProcNo()] = localSize; localSizes[Pstream::myProcNo()] = localSize;
Pstream::gatherList(localSizes, tag); if (parallel)
Pstream::scatterList(localSizes, tag); {
Pstream::gatherList(localSizes, tag);
Pstream::scatterList(localSizes, tag);
}
label offset = 0; label offset = 0;
offsets_[0] = 0; offsets_[0] = 0;

View File

@ -72,7 +72,12 @@ public:
// Constructors // Constructors
//- Construct from local max size //- Construct from local max size
globalIndex(const label localSize, const int tag = Pstream::msgType()); globalIndex
(
const label localSize,
const int tag = Pstream::msgType(),
const bool parallel = true // use parallel comms
);
//- Construct from Istream //- Construct from Istream
globalIndex(Istream& is); globalIndex(Istream& is);