ENH: IOdictionary : tree distribution of master dictionary

This commit is contained in:
mattijs
2010-12-03 11:19:52 +00:00
parent a17c3f96bd
commit 1a4190e766
2 changed files with 86 additions and 59 deletions

View File

@ -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);
} }
} }
} }

View File

@ -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;