mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: IOdictionary : tree distribution of master dictionary
This commit is contained in:
@ -55,46 +55,59 @@ void Foam::IOdictionary::readFile(const bool masterOnly)
|
|||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (masterOnly)
|
if (masterOnly && Pstream::parRun())
|
||||||
{
|
{
|
||||||
// Scatter master data
|
// Scatter master data using communication scheme
|
||||||
if (Pstream::master())
|
|
||||||
{
|
const List<Pstream::commsStruct>& comms =
|
||||||
for
|
(
|
||||||
(
|
(Pstream::nProcs() < Pstream::nProcsSimpleSum)
|
||||||
int slave=Pstream::firstSlave();
|
? Pstream::linearCommunication()
|
||||||
slave<=Pstream::lastSlave();
|
: Pstream::treeCommunication()
|
||||||
slave++
|
);
|
||||||
)
|
|
||||||
{
|
|
||||||
// Note: use ASCII for now - binary IO of dictionaries is
|
// Get my communication order
|
||||||
// not currently supported
|
const Pstream::commsStruct& myComm = comms[Pstream::myProcNo()];
|
||||||
OPstream toSlave
|
|
||||||
(
|
// Reveive from up
|
||||||
Pstream::scheduled,
|
if (myComm.above() != -1)
|
||||||
slave,
|
|
||||||
0,
|
|
||||||
UPstream::msgType(),
|
|
||||||
IOstream::ASCII
|
|
||||||
);
|
|
||||||
IOdictionary::writeData(toSlave);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
if (debug)
|
if (debug)
|
||||||
{
|
{
|
||||||
Pout<< "IOdictionary : Reading " << objectPath()
|
Pout<< "IOdictionary : Reading " << objectPath()
|
||||||
<< " from master processor " << Pstream::masterNo() << endl;
|
<< " from processor " << myComm.above() << endl;
|
||||||
}
|
}
|
||||||
IPstream fromMaster
|
|
||||||
|
// Note: use ASCII for now - binary IO of dictionaries is
|
||||||
|
// not currently supported
|
||||||
|
IPstream fromAbove
|
||||||
(
|
(
|
||||||
Pstream::scheduled,
|
Pstream::scheduled,
|
||||||
Pstream::masterNo(),
|
myComm.above(),
|
||||||
0,
|
0,
|
||||||
IOstream::ASCII
|
IOstream::ASCII
|
||||||
);
|
);
|
||||||
IOdictionary::readData(fromMaster);
|
IOdictionary::readData(fromAbove);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Send to my downstairs neighbours
|
||||||
|
forAll(myComm.below(), belowI)
|
||||||
|
{
|
||||||
|
if (debug)
|
||||||
|
{
|
||||||
|
Pout<< "IOdictionary : Sending " << objectPath()
|
||||||
|
<< " to processor " << myComm.below()[belowI] << endl;
|
||||||
|
}
|
||||||
|
OPstream toBelow
|
||||||
|
(
|
||||||
|
Pstream::scheduled,
|
||||||
|
myComm.below()[belowI],
|
||||||
|
0,
|
||||||
|
Pstream::msgType(),
|
||||||
|
IOstream::ASCII
|
||||||
|
);
|
||||||
|
IOdictionary::writeData(toBelow);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -177,55 +177,69 @@ bool Foam::regIOobject::read()
|
|||||||
regIOobject::fileModificationChecking == timeStampMaster
|
regIOobject::fileModificationChecking == timeStampMaster
|
||||||
|| regIOobject::fileModificationChecking == inotifyMaster;
|
|| regIOobject::fileModificationChecking == inotifyMaster;
|
||||||
|
|
||||||
bool ok;
|
bool ok = true;
|
||||||
if (Pstream::master() || !masterOnly)
|
if (Pstream::master() || !masterOnly)
|
||||||
{
|
{
|
||||||
|
if (IFstream::debug)
|
||||||
|
{
|
||||||
|
Pout<< "regIOobject::read() : "
|
||||||
|
<< "reading object " << name()
|
||||||
|
<< " from file " << endl;
|
||||||
|
}
|
||||||
ok = readData(readStream(type()));
|
ok = readData(readStream(type()));
|
||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (masterOnly)
|
if (masterOnly && Pstream::parRun())
|
||||||
{
|
{
|
||||||
// Scatter master data
|
// Scatter master data using communication scheme
|
||||||
if (Pstream::master())
|
|
||||||
{
|
const List<Pstream::commsStruct>& comms =
|
||||||
for
|
(
|
||||||
(
|
(Pstream::nProcs() < Pstream::nProcsSimpleSum)
|
||||||
int slave=Pstream::firstSlave();
|
? Pstream::linearCommunication()
|
||||||
slave<=Pstream::lastSlave();
|
: Pstream::treeCommunication()
|
||||||
slave++
|
);
|
||||||
)
|
|
||||||
{
|
|
||||||
// Note: use ASCII for now - binary IO of dictionaries is
|
// Get my communication order
|
||||||
// not currently supported
|
const Pstream::commsStruct& myComm = comms[Pstream::myProcNo()];
|
||||||
OPstream toSlave
|
|
||||||
(
|
// Reveive from up
|
||||||
Pstream::scheduled,
|
if (myComm.above() != -1)
|
||||||
slave,
|
|
||||||
0,
|
|
||||||
UPstream::msgType(),
|
|
||||||
IOstream::ASCII
|
|
||||||
);
|
|
||||||
writeData(toSlave);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
if (IFstream::debug)
|
if (IFstream::debug)
|
||||||
{
|
{
|
||||||
Pout<< "regIOobject::read() : "
|
Pout<< "regIOobject::read() : "
|
||||||
<< "reading object " << name()
|
<< "reading object " << name()
|
||||||
<< " from master processor " << Pstream::masterNo()
|
<< " from processor " << myComm.above()
|
||||||
<< endl;
|
<< endl;
|
||||||
}
|
}
|
||||||
IPstream fromMaster
|
|
||||||
|
// Note: use ASCII for now - binary IO of dictionaries is
|
||||||
|
// not currently supported
|
||||||
|
IPstream fromAbove
|
||||||
(
|
(
|
||||||
Pstream::scheduled,
|
Pstream::scheduled,
|
||||||
Pstream::masterNo(),
|
myComm.above(),
|
||||||
0,
|
0,
|
||||||
IOstream::ASCII
|
IOstream::ASCII
|
||||||
);
|
);
|
||||||
ok = readData(fromMaster);
|
ok = readData(fromAbove);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Send to my downstairs neighbours
|
||||||
|
forAll(myComm.below(), belowI)
|
||||||
|
{
|
||||||
|
OPstream toBelow
|
||||||
|
(
|
||||||
|
Pstream::scheduled,
|
||||||
|
myComm.below()[belowI],
|
||||||
|
0,
|
||||||
|
Pstream::msgType(),
|
||||||
|
IOstream::ASCII
|
||||||
|
);
|
||||||
|
writeData(toBelow);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ok;
|
return ok;
|
||||||
|
|||||||
Reference in New Issue
Block a user