mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: correct the selfComm procNo relative to world communicator
STYLE: qualify worldComm as UPstream instead Pstream STYLE: PPCG::gSumMagProd() as static function
This commit is contained in:
@ -89,7 +89,7 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
Info<< nl
|
Info<< nl
|
||||||
<< "parallel:" << UPstream::parRun()
|
<< "parallel:" << UPstream::parRun()
|
||||||
<< "nProcs = " << UPstream::nProcs()
|
<< " nProcs = " << UPstream::nProcs()
|
||||||
<< " with " << UPstream::nComms() << " predefined comm(s)."
|
<< " with " << UPstream::nComms() << " predefined comm(s)."
|
||||||
<< " proc:" << UPstream::myProcNo() << nl;
|
<< " proc:" << UPstream::myProcNo() << nl;
|
||||||
|
|
||||||
@ -103,11 +103,14 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
Info<< nl;
|
Info<< nl;
|
||||||
|
|
||||||
//- Process IDs within a given communicator
|
// Process IDs within a given communicator
|
||||||
Info<< "procIDs: "
|
for (label comm = 0; comm < UPstream::nComms(); ++comm)
|
||||||
<< flatOutput(UPstream::procID(UPstream::commWorld())) << endl;
|
{
|
||||||
|
Info<< "comm=" << comm
|
||||||
rankInfo(UPstream::commWorld());
|
<< " procIDs: " << flatOutput(UPstream::procID(comm)) << endl;
|
||||||
|
rankInfo(comm);
|
||||||
|
Pout<< nl;
|
||||||
|
}
|
||||||
Pout<< endl;
|
Pout<< endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -165,7 +165,7 @@ void Foam::UPstream::setParRun(const label nProcs, const bool haveThreads)
|
|||||||
// Failed sanity check
|
// Failed sanity check
|
||||||
FatalErrorInFunction
|
FatalErrorInFunction
|
||||||
<< "problem : comm:" << comm
|
<< "problem : comm:" << comm
|
||||||
<< " UPstream::globalComm:" << UPstream::globalComm
|
<< " expected globalComm:" << UPstream::globalComm
|
||||||
<< Foam::exit(FatalError);
|
<< Foam::exit(FatalError);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -176,7 +176,7 @@ void Foam::UPstream::setParRun(const label nProcs, const bool haveThreads)
|
|||||||
// Failed sanity check
|
// Failed sanity check
|
||||||
FatalErrorInFunction
|
FatalErrorInFunction
|
||||||
<< "problem : comm:" << comm
|
<< "problem : comm:" << comm
|
||||||
<< " UPstream::selfComm:" << UPstream::selfComm
|
<< " expected selfComm:" << UPstream::selfComm
|
||||||
<< Foam::exit(FatalError);
|
<< Foam::exit(FatalError);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -199,18 +199,20 @@ void Foam::UPstream::setParRun(const label nProcs, const bool haveThreads)
|
|||||||
// Failed sanity check
|
// Failed sanity check
|
||||||
FatalErrorInFunction
|
FatalErrorInFunction
|
||||||
<< "problem : comm:" << comm
|
<< "problem : comm:" << comm
|
||||||
<< " UPstream::globalComm:" << UPstream::globalComm
|
<< " expected globalComm:" << UPstream::globalComm
|
||||||
<< Foam::exit(FatalError);
|
<< Foam::exit(FatalError);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 1: selfComm
|
// 1: selfComm
|
||||||
|
// - Processor number wrt world communicator
|
||||||
|
singleProc.front() = myProcNo(UPstream::globalComm);
|
||||||
comm = allocateCommunicator(-2, singleProc, true);
|
comm = allocateCommunicator(-2, singleProc, true);
|
||||||
if (comm != UPstream::selfComm)
|
if (comm != UPstream::selfComm)
|
||||||
{
|
{
|
||||||
// Failed sanity check
|
// Failed sanity check
|
||||||
FatalErrorInFunction
|
FatalErrorInFunction
|
||||||
<< "problem : comm:" << comm
|
<< "problem : comm:" << comm
|
||||||
<< " UPstream::selfComm:" << UPstream::selfComm
|
<< " expected selfComm:" << UPstream::selfComm
|
||||||
<< Foam::exit(FatalError);
|
<< Foam::exit(FatalError);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -33,7 +33,7 @@ Note
|
|||||||
#include "fileName.H"
|
#include "fileName.H"
|
||||||
#include "dictionary.H"
|
#include "dictionary.H"
|
||||||
#include "JobInfo.H"
|
#include "JobInfo.H"
|
||||||
#include "Pstream.H"
|
#include "UPstream.H"
|
||||||
#include "StringStream.H"
|
#include "StringStream.H"
|
||||||
#include "foamVersion.H"
|
#include "foamVersion.H"
|
||||||
#include "OSspecific.H"
|
#include "OSspecific.H"
|
||||||
@ -44,7 +44,7 @@ Note
|
|||||||
bool Foam::error::master(const label communicator)
|
bool Foam::error::master(const label communicator)
|
||||||
{
|
{
|
||||||
// Trap negative value for comm as 'default'. This avoids direct use
|
// Trap negative value for comm as 'default'. This avoids direct use
|
||||||
// of Pstream::worldComm which may not have been initialised
|
// of UPstream::worldComm which may have not yet been initialised
|
||||||
|
|
||||||
return
|
return
|
||||||
(
|
(
|
||||||
|
|||||||
@ -44,14 +44,14 @@ namespace Foam
|
|||||||
|
|
||||||
Foam::LUscalarMatrix::LUscalarMatrix()
|
Foam::LUscalarMatrix::LUscalarMatrix()
|
||||||
:
|
:
|
||||||
comm_(Pstream::worldComm)
|
comm_(UPstream::worldComm)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
Foam::LUscalarMatrix::LUscalarMatrix(const scalarSquareMatrix& matrix)
|
Foam::LUscalarMatrix::LUscalarMatrix(const scalarSquareMatrix& matrix)
|
||||||
:
|
:
|
||||||
scalarSquareMatrix(matrix),
|
scalarSquareMatrix(matrix),
|
||||||
comm_(Pstream::worldComm),
|
comm_(UPstream::worldComm),
|
||||||
pivotIndices_(m())
|
pivotIndices_(m())
|
||||||
{
|
{
|
||||||
LUDecompose(*this, pivotIndices_);
|
LUDecompose(*this, pivotIndices_);
|
||||||
@ -67,9 +67,9 @@ Foam::LUscalarMatrix::LUscalarMatrix
|
|||||||
:
|
:
|
||||||
comm_(ldum.mesh().comm())
|
comm_(ldum.mesh().comm())
|
||||||
{
|
{
|
||||||
if (Pstream::parRun())
|
if (UPstream::parRun())
|
||||||
{
|
{
|
||||||
PtrList<procLduMatrix> lduMatrices(Pstream::nProcs(comm_));
|
PtrList<procLduMatrix> lduMatrices(UPstream::nProcs(comm_));
|
||||||
|
|
||||||
label lduMatrixi = 0;
|
label lduMatrixi = 0;
|
||||||
|
|
||||||
@ -84,9 +84,9 @@ Foam::LUscalarMatrix::LUscalarMatrix
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
if (Pstream::master(comm_))
|
if (UPstream::master(comm_))
|
||||||
{
|
{
|
||||||
for (const int proci : Pstream::subProcs(comm_))
|
for (const int proci : UPstream::subProcs(comm_))
|
||||||
{
|
{
|
||||||
lduMatrices.set
|
lduMatrices.set
|
||||||
(
|
(
|
||||||
@ -95,10 +95,10 @@ Foam::LUscalarMatrix::LUscalarMatrix
|
|||||||
(
|
(
|
||||||
IPstream
|
IPstream
|
||||||
(
|
(
|
||||||
Pstream::commsTypes::scheduled,
|
UPstream::commsTypes::scheduled,
|
||||||
proci,
|
proci,
|
||||||
0, // bufSize
|
0, // bufSize
|
||||||
Pstream::msgType(),
|
UPstream::msgType(),
|
||||||
comm_
|
comm_
|
||||||
)()
|
)()
|
||||||
)
|
)
|
||||||
@ -109,10 +109,10 @@ Foam::LUscalarMatrix::LUscalarMatrix
|
|||||||
{
|
{
|
||||||
OPstream toMaster
|
OPstream toMaster
|
||||||
(
|
(
|
||||||
Pstream::commsTypes::scheduled,
|
UPstream::commsTypes::scheduled,
|
||||||
Pstream::masterNo(),
|
UPstream::masterNo(),
|
||||||
0, // bufSize
|
0, // bufSize
|
||||||
Pstream::msgType(),
|
UPstream::msgType(),
|
||||||
comm_
|
comm_
|
||||||
);
|
);
|
||||||
procLduMatrix cldum
|
procLduMatrix cldum
|
||||||
@ -125,7 +125,7 @@ Foam::LUscalarMatrix::LUscalarMatrix
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Pstream::master(comm_))
|
if (UPstream::master(comm_))
|
||||||
{
|
{
|
||||||
label nCells = 0;
|
label nCells = 0;
|
||||||
forAll(lduMatrices, i)
|
forAll(lduMatrices, i)
|
||||||
@ -146,7 +146,7 @@ Foam::LUscalarMatrix::LUscalarMatrix
|
|||||||
convert(ldum, interfaceCoeffs, interfaces);
|
convert(ldum, interfaceCoeffs, interfaces);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Pstream::master(comm_))
|
if (UPstream::master(comm_))
|
||||||
{
|
{
|
||||||
if (debug)
|
if (debug)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -51,7 +51,7 @@ void Foam::PPCG::gSumMagProd
|
|||||||
const solveScalarField& sumMag,
|
const solveScalarField& sumMag,
|
||||||
UPstream::Request& request,
|
UPstream::Request& request,
|
||||||
const label comm
|
const label comm
|
||||||
) const
|
)
|
||||||
{
|
{
|
||||||
const label nCells = a.size();
|
const label nCells = a.size();
|
||||||
|
|
||||||
@ -63,14 +63,14 @@ void Foam::PPCG::gSumMagProd
|
|||||||
globalSum[2] += mag(sumMag[cell]);
|
globalSum[2] += mag(sumMag[cell]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Pstream::parRun())
|
if (UPstream::parRun())
|
||||||
{
|
{
|
||||||
Foam::reduce
|
Foam::reduce
|
||||||
(
|
(
|
||||||
globalSum.data(),
|
globalSum.data(),
|
||||||
globalSum.size(),
|
globalSum.size(),
|
||||||
sumOp<solveScalar>(),
|
sumOp<solveScalar>(),
|
||||||
Pstream::msgType(),
|
UPstream::msgType(), // (ignored): direct MPI call
|
||||||
comm,
|
comm,
|
||||||
request
|
request
|
||||||
);
|
);
|
||||||
|
|||||||
@ -69,7 +69,7 @@ class PPCG
|
|||||||
// Private Member Functions
|
// Private Member Functions
|
||||||
|
|
||||||
//- Non-blocking version of sum(a*b), sum(a*c), sum(mag(sumMag))
|
//- Non-blocking version of sum(a*b), sum(a*c), sum(mag(sumMag))
|
||||||
void gSumMagProd
|
static void gSumMagProd
|
||||||
(
|
(
|
||||||
FixedList<solveScalar, 3>& globalSum,
|
FixedList<solveScalar, 3>& globalSum,
|
||||||
const solveScalarField& a,
|
const solveScalarField& a,
|
||||||
@ -78,7 +78,7 @@ class PPCG
|
|||||||
const solveScalarField& sumMag,
|
const solveScalarField& sumMag,
|
||||||
UPstream::Request& request,
|
UPstream::Request& request,
|
||||||
const label comm
|
const label comm
|
||||||
) const;
|
);
|
||||||
|
|
||||||
//- No copy construct
|
//- No copy construct
|
||||||
PPCG(const PPCG&) = delete;
|
PPCG(const PPCG&) = delete;
|
||||||
|
|||||||
@ -299,7 +299,7 @@ bool Foam::UPstream::init(int& argc, char**& argv, const bool needsThread)
|
|||||||
Pstream::gatherList(worlds, UPstream::msgType(), UPstream::globalComm);
|
Pstream::gatherList(worlds, UPstream::msgType(), UPstream::globalComm);
|
||||||
|
|
||||||
// Compact
|
// Compact
|
||||||
if (Pstream::master(UPstream::globalComm))
|
if (UPstream::master(UPstream::globalComm))
|
||||||
{
|
{
|
||||||
DynamicList<word> worldNames(numprocs);
|
DynamicList<word> worldNames(numprocs);
|
||||||
worldIDs_.resize_nocopy(numprocs);
|
worldIDs_.resize_nocopy(numprocs);
|
||||||
|
|||||||
@ -306,7 +306,7 @@ bool Foam::faMesh::init(const bool doInit)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create global mesh data
|
// Create global mesh data
|
||||||
if (Pstream::parRun())
|
if (UPstream::parRun())
|
||||||
{
|
{
|
||||||
(void)globalData();
|
(void)globalData();
|
||||||
}
|
}
|
||||||
@ -378,7 +378,7 @@ Foam::faMesh::faMesh
|
|||||||
),
|
),
|
||||||
*this
|
*this
|
||||||
),
|
),
|
||||||
comm_(Pstream::worldComm),
|
comm_(UPstream::worldComm),
|
||||||
curTimeIndex_(time().timeIndex()),
|
curTimeIndex_(time().timeIndex()),
|
||||||
|
|
||||||
patchPtr_(nullptr),
|
patchPtr_(nullptr),
|
||||||
@ -484,7 +484,7 @@ Foam::faMesh::faMesh
|
|||||||
*this,
|
*this,
|
||||||
label(0)
|
label(0)
|
||||||
),
|
),
|
||||||
comm_(Pstream::worldComm),
|
comm_(UPstream::worldComm),
|
||||||
curTimeIndex_(time().timeIndex()),
|
curTimeIndex_(time().timeIndex()),
|
||||||
|
|
||||||
patchPtr_(nullptr),
|
patchPtr_(nullptr),
|
||||||
@ -565,7 +565,7 @@ Foam::faMesh::faMesh
|
|||||||
*this,
|
*this,
|
||||||
label(0)
|
label(0)
|
||||||
),
|
),
|
||||||
comm_(Pstream::worldComm),
|
comm_(UPstream::worldComm),
|
||||||
curTimeIndex_(time().timeIndex()),
|
curTimeIndex_(time().timeIndex()),
|
||||||
|
|
||||||
patchPtr_(nullptr),
|
patchPtr_(nullptr),
|
||||||
|
|||||||
Reference in New Issue
Block a user