STYLE: readOnProc/writeOnProc instead of 'valid' for IO

This commit is contained in:
Mark Olesen
2023-03-14 17:39:28 +01:00
parent 188e61af16
commit 475ed5cc32
94 changed files with 415 additions and 383 deletions

View File

@ -46,35 +46,39 @@ using namespace Foam;
template<class Type>
void doWrite(const IOobject& io, const label sz)
{
const bool writeOnProc = (sz > 0);
IOField<Type> fld(io, sz);
forAll(fld, i)
{
fld[i] = i + 1000.25 + (0.25 * i);
}
Pout<< "writing:" << fld << endl;
fld.write(sz > 0);
fld.write(writeOnProc);
}
template<>
void doWrite<bool>(const IOobject& io, const label sz)
{
const bool writeOnProc = (sz > 0);
IOField<bool> fld(io, sz);
forAll(fld, i)
{
fld[i] = i % 2;
}
Pout<< "writing:" << fld << endl;
fld.write(sz > 0);
fld.write(writeOnProc);
}
template<class Type>
void doRead(const IOobject& io, const label sz)
{
bool valid = (sz > 0);
Pout<< " valid:" << valid << endl;
IOField<Type> fld(io, valid);
const bool readOnProc = (sz > 0);
Pout<< " readOnProc:" << readOnProc << endl;
IOField<Type> fld(io, readOnProc);
Pout<< " wanted:" << sz << " actually read:" << fld.size() << endl;
if (fld.size() != sz)

View File

@ -203,7 +203,7 @@ bool writeOptionalMeshObject
const word& name,
const fileName& meshDir,
Time& runTime,
const bool valid
const bool writeOnProc
)
{
IOobject io
@ -218,8 +218,7 @@ bool writeOptionalMeshObject
);
bool writeOk = false;
bool haveFile = io.typeHeaderOk<IOField<label>>(false);
const bool haveFile = io.typeHeaderOk<IOField<label>>(false);
// Make sure all know if there is a valid class name
wordList classNames(1, io.headerClassName());
@ -230,10 +229,10 @@ bool writeOptionalMeshObject
{
Info<< " Reading " << classNames[0]
<< " : " << name << endl;
T meshObject(io, valid && haveFile);
T meshObject(io, writeOnProc && haveFile);
Info<< " Writing " << name << endl;
writeOk = meshObject.regIOobject::write(valid && haveFile);
writeOk = meshObject.regIOobject::write(writeOnProc && haveFile);
}
return writeOk;

View File

@ -94,7 +94,7 @@ public:
{}
//- Disable writing objects
virtual bool writeObject(IOstreamOption, const bool valid) const
virtual bool writeObject(IOstreamOption, const bool writeOnProc) const
{
return true;
}