Commit 1a4190e7 authored by mattijs's avatar mattijs
Browse files

ENH: IOdictionary : tree distribution of master dictionary

parent a17c3f96
......@@ -55,46 +55,59 @@ void Foam::IOdictionary::readFile(const bool masterOnly)
close();
}
if (masterOnly)
if (masterOnly && Pstream::parRun())
{
// Scatter master data
if (Pstream::master())
// Scatter master data using communication scheme
const List<Pstream::commsStruct>& comms =
(
(Pstream::nProcs() < Pstream::nProcsSimpleSum)
? Pstream::linearCommunication()
: Pstream::treeCommunication()
);
// Get my communication order
const Pstream::commsStruct& myComm = comms[Pstream::myProcNo()];
// Reveive from up
if (myComm.above() != -1)
{
for
(
int slave=Pstream::firstSlave();
slave<=Pstream::lastSlave();
slave++
)
if (debug)
{
// Note: use ASCII for now - binary IO of dictionaries is
// not currently supported
OPstream toSlave
(
Pstream::scheduled,
slave,
0,
UPstream::msgType(),
IOstream::ASCII
);
IOdictionary::writeData(toSlave);
Pout<< "IOdictionary : Reading " << objectPath()
<< " from processor " << myComm.above() << endl;
}
// Note: use ASCII for now - binary IO of dictionaries is
// not currently supported
IPstream fromAbove
(
Pstream::scheduled,
myComm.above(),
0,
IOstream::ASCII
);
IOdictionary::readData(fromAbove);
}
else
// Send to my downstairs neighbours
forAll(myComm.below(), belowI)
{
if (debug)
{
Pout<< "IOdictionary : Reading " << objectPath()
<< " from master processor " << Pstream::masterNo() << endl;
Pout<< "IOdictionary : Sending " << objectPath()
<< " to processor " << myComm.below()[belowI] << endl;
}
IPstream fromMaster
OPstream toBelow
(
Pstream::scheduled,
Pstream::masterNo(),
myComm.below()[belowI],
0,
Pstream::msgType(),
IOstream::ASCII
);
IOdictionary::readData(fromMaster);
IOdictionary::writeData(toBelow);
}
}
}
......
......@@ -177,55 +177,69 @@ bool Foam::regIOobject::read()
regIOobject::fileModificationChecking == timeStampMaster
|| regIOobject::fileModificationChecking == inotifyMaster;
bool ok;
bool ok = true;
if (Pstream::master() || !masterOnly)
{
if (IFstream::debug)
{
Pout<< "regIOobject::read() : "
<< "reading object " << name()
<< " from file " << endl;
}
ok = readData(readStream(type()));
close();
}
if (masterOnly)
if (masterOnly && Pstream::parRun())
{
// Scatter master data
if (Pstream::master())
{
for
(
int slave=Pstream::firstSlave();
slave<=Pstream::lastSlave();
slave++
)
{
// Note: use ASCII for now - binary IO of dictionaries is
// not currently supported
OPstream toSlave
(
Pstream::scheduled,
slave,
0,
UPstream::msgType(),
IOstream::ASCII
);
writeData(toSlave);
}
}
else
// Scatter master data using communication scheme
const List<Pstream::commsStruct>& comms =
(
(Pstream::nProcs() < Pstream::nProcsSimpleSum)
? Pstream::linearCommunication()
: Pstream::treeCommunication()
);
// Get my communication order
const Pstream::commsStruct& myComm = comms[Pstream::myProcNo()];
// Reveive from up
if (myComm.above() != -1)
{
if (IFstream::debug)
{
Pout<< "regIOobject::read() : "
<< "reading object " << name()
<< " from master processor " << Pstream::masterNo()
<< " from processor " << myComm.above()
<< endl;
}
IPstream fromMaster
// Note: use ASCII for now - binary IO of dictionaries is
// not currently supported
IPstream fromAbove
(
Pstream::scheduled,
myComm.above(),
0,
IOstream::ASCII
);
ok = readData(fromAbove);
}
// Send to my downstairs neighbours
forAll(myComm.below(), belowI)
{
OPstream toBelow
(
Pstream::scheduled,
Pstream::masterNo(),
myComm.below()[belowI],
0,
Pstream::msgType(),
IOstream::ASCII
);
ok = readData(fromMaster);
writeData(toBelow);
}
}
return ok;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment