Skip to content
Snippets Groups Projects
Commit 1a4190e7 authored by mattijs's avatar mattijs
Browse files

ENH: IOdictionary : tree distribution of master dictionary

parent a17c3f96
Branches
Tags
No related merge requests found
...@@ -55,46 +55,59 @@ void Foam::IOdictionary::readFile(const bool masterOnly) ...@@ -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 =
(
(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 if (debug)
(
int slave=Pstream::firstSlave();
slave<=Pstream::lastSlave();
slave++
)
{ {
// Note: use ASCII for now - binary IO of dictionaries is Pout<< "IOdictionary : Reading " << objectPath()
// not currently supported << " from processor " << myComm.above() << endl;
OPstream toSlave
(
Pstream::scheduled,
slave,
0,
UPstream::msgType(),
IOstream::ASCII
);
IOdictionary::writeData(toSlave);
} }
// 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) if (debug)
{ {
Pout<< "IOdictionary : Reading " << objectPath() Pout<< "IOdictionary : Sending " << objectPath()
<< " from master processor " << Pstream::masterNo() << endl; << " to processor " << myComm.below()[belowI] << endl;
} }
IPstream fromMaster OPstream toBelow
( (
Pstream::scheduled, Pstream::scheduled,
Pstream::masterNo(), myComm.below()[belowI],
0, 0,
Pstream::msgType(),
IOstream::ASCII IOstream::ASCII
); );
IOdictionary::readData(fromMaster); IOdictionary::writeData(toBelow);
} }
} }
} }
......
...@@ -177,55 +177,69 @@ bool Foam::regIOobject::read() ...@@ -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,
myComm.above(),
0,
IOstream::ASCII
);
ok = readData(fromAbove);
}
// Send to my downstairs neighbours
forAll(myComm.below(), belowI)
{
OPstream toBelow
( (
Pstream::scheduled, Pstream::scheduled,
Pstream::masterNo(), myComm.below()[belowI],
0, 0,
Pstream::msgType(),
IOstream::ASCII IOstream::ASCII
); );
ok = readData(fromMaster); writeData(toBelow);
} }
} }
return ok; return ok;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment