ENH: provide setter methods for IOobject read/write options etc.

- simplifies local toggling.

- centralize fileModification static variables into IOobject.
  They were previously scattered between IOobject and regIOobject
This commit is contained in:
Mark Olesen
2021-03-17 11:02:10 +01:00
parent 3ce18cb6e2
commit 9a2a22a03a
85 changed files with 370 additions and 364 deletions

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2016-2018 OpenCFD Ltd.
Copyright (C) 2016-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -1025,54 +1025,54 @@ int main(int argc, char *argv[])
forAll(scalarFlds, i)
{
scalarFlds[i].rename(scalarNames[i]);
scalarFlds[i].writeOpt() = IOobject::AUTO_WRITE;
scalarFlds[i].writeOpt(IOobject::AUTO_WRITE);
}
forAll(vectorFlds, i)
{
vectorFlds[i].rename(vectorNames[i]);
vectorFlds[i].writeOpt() = IOobject::AUTO_WRITE;
vectorFlds[i].writeOpt(IOobject::AUTO_WRITE);
}
forAll(sphTensorFlds, i)
{
sphTensorFlds[i].rename(sphTensorNames[i]);
sphTensorFlds[i].writeOpt() = IOobject::AUTO_WRITE;
sphTensorFlds[i].writeOpt(IOobject::AUTO_WRITE);
}
forAll(symmTensorFlds, i)
{
symmTensorFlds[i].rename(symmTensorNames[i]);
symmTensorFlds[i].writeOpt() = IOobject::AUTO_WRITE;
symmTensorFlds[i].writeOpt(IOobject::AUTO_WRITE);
}
forAll(tensorFlds, i)
{
tensorFlds[i].rename(tensorNames[i]);
tensorFlds[i].writeOpt() = IOobject::AUTO_WRITE;
tensorFlds[i].writeOpt(IOobject::AUTO_WRITE);
}
// Surface ones.
forAll(surfScalarFlds, i)
{
surfScalarFlds[i].rename(surfScalarNames[i]);
surfScalarFlds[i].writeOpt() = IOobject::AUTO_WRITE;
surfScalarFlds[i].writeOpt(IOobject::AUTO_WRITE);
}
forAll(surfVectorFlds, i)
{
surfVectorFlds[i].rename(surfVectorNames[i]);
surfVectorFlds[i].writeOpt() = IOobject::AUTO_WRITE;
surfVectorFlds[i].writeOpt(IOobject::AUTO_WRITE);
}
forAll(surfSphericalTensorFlds, i)
{
surfSphericalTensorFlds[i].rename(surfSphTensorNames[i]);
surfSphericalTensorFlds[i].writeOpt() = IOobject::AUTO_WRITE;
surfSphericalTensorFlds[i].writeOpt(IOobject::AUTO_WRITE);
}
forAll(surfSymmTensorFlds, i)
{
surfSymmTensorFlds[i].rename(surfSymmTensorNames[i]);
surfSymmTensorFlds[i].writeOpt() = IOobject::AUTO_WRITE;
surfSymmTensorFlds[i].writeOpt(IOobject::AUTO_WRITE);
}
forAll(surfTensorNames, i)
{
surfTensorFlds[i].rename(surfTensorNames[i]);
surfTensorFlds[i].writeOpt() = IOobject::AUTO_WRITE;
surfTensorFlds[i].writeOpt(IOobject::AUTO_WRITE);
}
subsetter.subMesh().write();

View File

@ -1106,12 +1106,12 @@ int main(int argc, char *argv[])
{
Info<< "Not writing inconsistent processor cell decomposition"
<< " map " << cellProcAddressing.filePath() << endl;
cellProcAddressing.writeOpt() = IOobject::NO_WRITE;
cellProcAddressing.writeOpt(IOobject::NO_WRITE);
}
}
else
{
cellProcAddressing.writeOpt() = IOobject::NO_WRITE;
cellProcAddressing.writeOpt(IOobject::NO_WRITE);
}
if (faceProcAddressing.headerOk())
@ -1147,12 +1147,12 @@ int main(int argc, char *argv[])
{
Info<< "Not writing inconsistent processor face decomposition"
<< " map " << faceProcAddressing.filePath() << endl;
faceProcAddressing.writeOpt() = IOobject::NO_WRITE;
faceProcAddressing.writeOpt(IOobject::NO_WRITE);
}
}
else
{
faceProcAddressing.writeOpt() = IOobject::NO_WRITE;
faceProcAddressing.writeOpt(IOobject::NO_WRITE);
}
if (pointProcAddressing.headerOk())
@ -1173,12 +1173,12 @@ int main(int argc, char *argv[])
{
Info<< "Not writing inconsistent processor point decomposition"
<< " map " << pointProcAddressing.filePath() << endl;
pointProcAddressing.writeOpt() = IOobject::NO_WRITE;
pointProcAddressing.writeOpt(IOobject::NO_WRITE);
}
}
else
{
pointProcAddressing.writeOpt() = IOobject::NO_WRITE;
pointProcAddressing.writeOpt(IOobject::NO_WRITE);
}
if (boundaryProcAddressing.headerOk())
@ -1196,12 +1196,12 @@ int main(int argc, char *argv[])
{
Info<< "Not writing inconsistent processor patch decomposition"
<< " map " << boundaryProcAddressing.filePath() << endl;
boundaryProcAddressing.writeOpt() = IOobject::NO_WRITE;
boundaryProcAddressing.writeOpt(IOobject::NO_WRITE);
}
}
else
{
boundaryProcAddressing.writeOpt() = IOobject::NO_WRITE;
boundaryProcAddressing.writeOpt(IOobject::NO_WRITE);
}

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -134,7 +135,7 @@ int main(int argc, char *argv[])
zn = pointLabels;
mesh.pointZones().writeOpt() = IOobject::AUTO_WRITE;
mesh.pointZones().writeOpt(IOobject::AUTO_WRITE);
mesh.pointZones().instance() = mesh.facesInstance();
}
@ -261,7 +262,7 @@ int main(int argc, char *argv[])
flipMap.shrink()
);
mesh.faceZones().writeOpt() = IOobject::AUTO_WRITE;
mesh.faceZones().writeOpt(IOobject::AUTO_WRITE);
mesh.faceZones().instance() = mesh.facesInstance();
}
@ -297,7 +298,7 @@ int main(int argc, char *argv[])
zn = cellLabels;
mesh.cellZones().writeOpt() = IOobject::AUTO_WRITE;
mesh.cellZones().writeOpt(IOobject::AUTO_WRITE);
mesh.cellZones().instance() = mesh.facesInstance();
}
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2015 OpenFOAM Foundation
Copyright (C) 2016 OpenCFD Ltd.
Copyright (C) 2016-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -67,7 +67,7 @@ void interpolateFields
{
tmp<GeoField> scFld = scMesh.interpolate(flds[i]);
GeoField* scFldPtr = scFld.ptr();
scFldPtr->writeOpt() = IOobject::AUTO_WRITE;
scFldPtr->writeOpt(IOobject::AUTO_WRITE);
scFldPtr->store();
}
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2015-2020 OpenCFD Ltd.
Copyright (C) 2015-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -192,7 +192,7 @@ void subsetVolFields
// Store on subMesh
GeoField* subFld = tSubFld.ptr();
subFld->rename(fld.name());
subFld->writeOpt() = IOobject::AUTO_WRITE;
subFld->writeOpt(IOobject::AUTO_WRITE);
subFld->store();
}
}
@ -246,7 +246,7 @@ void subsetSurfaceFields
// Store on subMesh
GeoField* subFld = tSubFld.ptr();
subFld->rename(fld.name());
subFld->writeOpt() = IOobject::AUTO_WRITE;
subFld->writeOpt(IOobject::AUTO_WRITE);
subFld->store();
}
}
@ -1886,7 +1886,7 @@ int main(int argc, char *argv[])
<< zoneI << ' ' << cellZones[zoneI].name() << endl;
}
}
mesh.cellZones().writeOpt() = IOobject::AUTO_WRITE;
mesh.cellZones().writeOpt(IOobject::AUTO_WRITE);
if (!overwrite)
{

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2016-2020 OpenCFD Ltd.
Copyright (C) 2016-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -294,7 +294,7 @@ int main(int argc, char *argv[])
// Make sure we do not use the master-only reading since we read
// fields (different per processor) as dictionaries.
regIOobject::fileModificationChecking = regIOobject::timeStamp;
IOobject::fileModificationChecking = IOobject::timeStamp;
fileName meshDir = polyMesh::meshSubDir;

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2019-2020 OpenCFD Ltd.
Copyright (C) 2019-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -570,7 +570,7 @@ bool Foam::domainDecomposition::writeDecomposition(const bool decomposeSets)
if (pz.size())
{
// Force writing on all processors
procMesh.pointZones().writeOpt() = IOobject::AUTO_WRITE;
procMesh.pointZones().writeOpt(IOobject::AUTO_WRITE);
}
}
@ -664,7 +664,7 @@ bool Foam::domainDecomposition::writeDecomposition(const bool decomposeSets)
if (fz.size())
{
// Force writing on all processors
procMesh.faceZones().writeOpt() = IOobject::AUTO_WRITE;
procMesh.faceZones().writeOpt(IOobject::AUTO_WRITE);
}
}
@ -728,7 +728,7 @@ bool Foam::domainDecomposition::writeDecomposition(const bool decomposeSets)
if (cz.size())
{
// Force writing on all processors
procMesh.cellZones().writeOpt() = IOobject::AUTO_WRITE;
procMesh.cellZones().writeOpt(IOobject::AUTO_WRITE);
}
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2012-2017 OpenFOAM Foundation
Copyright (C) 2015-2020 OpenCFD Ltd.
Copyright (C) 2015-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -163,8 +163,8 @@ Foam::autoPtr<Foam::fvMesh> Foam::loadOrCreateMesh
// Create dummy mesh. Only used on procs that don't have mesh.
IOobject noReadIO(io);
noReadIO.readOpt() = IOobject::NO_READ;
noReadIO.writeOpt() = IOobject::AUTO_WRITE;
noReadIO.readOpt(IOobject::NO_READ);
noReadIO.writeOpt(IOobject::AUTO_WRITE);
fvMesh dummyMesh(noReadIO, Zero, false);
// Add patches

View File

@ -648,7 +648,7 @@ void readFields
{
const word& name = masterNames[i];
IOobject& io = *objects[name];
io.writeOpt() = IOobject::AUTO_WRITE;
io.writeOpt(IOobject::AUTO_WRITE);
// Load field (but not oldTime)
readField(io, mesh, i, fields);
@ -714,7 +714,7 @@ void readFields
{
const word& name = masterNames[i];
IOobject& io = *objects[name];
io.writeOpt() = IOobject::AUTO_WRITE;
io.writeOpt(IOobject::AUTO_WRITE);
// Load field (but not oldtime)
readField(io, mesh, i, fields);

View File

@ -26,7 +26,7 @@ label timeIndex = 0;
if (io.typeHeaderOk<IOdictionary>(true, false))
{
io.readOpt() = IOobject::MUST_READ_IF_MODIFIED;
io.readOpt(IOobject::MUST_READ_IF_MODIFIED);
IOdictionary timeObject(io);
timeObject.readEntry("index", timeIndex);

View File

@ -14,7 +14,7 @@
{
Info<< "new points available" << endl;
// Read new points
io.readOpt() = IOobject::MUST_READ;
io.readOpt(IOobject::MUST_READ);
mesh.movePoints(pointIOField(io));
}
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2016-2020 OpenCFD Ltd.
Copyright (C) 2016-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -507,7 +507,7 @@ int main(int argc, char *argv[])
// Make sure we do not use the master-only reading since we read
// fields (different per processor) as dictionaries.
regIOobject::fileModificationChecking = regIOobject::timeStamp;
IOobject::fileModificationChecking = IOobject::timeStamp;
// Get the replacement rules from a dictionary

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2019-2020 OpenCFD Ltd.
Copyright (C) 2019-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -422,7 +422,7 @@ int main(int argc, char *argv[])
// Make sure we do not use the master-only reading since we read
// fields (different per processor) as dictionaries.
regIOobject::fileModificationChecking = regIOobject::timeStamp;
IOobject::fileModificationChecking = IOobject::timeStamp;
instantList timeDirs = timeSelector::select0(runTime, args);

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd.
Copyright (C) 2019-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -90,7 +90,7 @@ void MapConsistentVolFields
}
else
{
fieldTargetIOobject.readOpt() = IOobject::NO_READ;
fieldTargetIOobject.readOpt(IOobject::NO_READ);
// Interpolate field
fieldType fieldTarget

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2018 OpenCFD Ltd.
Copyright (C) 2018-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -172,7 +172,7 @@ void MapVolFields
Info<< " creating new field "
<< fieldName << endl;
targetIO.readOpt() = IOobject::NO_READ;
targetIO.readOpt(IOobject::NO_READ);
tmp<fieldType> tfieldTarget
(

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2015-2020 OpenCFD Ltd.
Copyright (C) 2015-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -261,7 +261,7 @@ int main(int argc, char *argv[])
// Construct distributedTrisurfaceMesh from components
IOobject notReadIO(io);
notReadIO.readOpt() = IOobject::NO_READ;
notReadIO.readOpt(IOobject::NO_READ);
surfMeshPtr.reset(new distributedTriSurfaceMesh(notReadIO, s, dict));
}