From d938e01d7a48768ed6718ce70be2e5f38d0932da Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Tue, 27 Sep 2022 13:07:29 +0200 Subject: [PATCH] ENH: refactor IOobject options - IOobjectOption class encapsulates read/write, storage flags for lightweight handling, independent of objectRegistry etc. ENH: add IOobject isReadRequired() and isReadOptional() queries - encapsulates test of MUST_READ, MUST_READ_IF_MODIFIED, READ_IF_PRESENT for convenience / less clutter. Example, if (isReadRequired() || (isReadOptional() && headerOk())) { ... } Instead of if ( ( readOpt() == IOobject::MUST_READ || readOpt() == IOobject::MUST_READ_IF_MODIFIED ) || (readOpt() == IOobject::READ_IF_PRESENT && headerOk()) ) { ... } --- applications/test/IOField/Test-IOField.C | 9 +- applications/test/sizeof/Test-sizeof.C | 1 + src/OpenFOAM/db/IOobject/IOobject.C | 126 +++---- src/OpenFOAM/db/IOobject/IOobject.H | 171 ++++------ src/OpenFOAM/db/IOobject/IOobjectI.H | 152 +++++---- src/OpenFOAM/db/IOobject/IOobjectOption.H | 312 ++++++++++++++++++ src/OpenFOAM/db/IOobject/IOobjectReadHeader.C | 14 +- src/OpenFOAM/db/IOobjectList/IOobjectList.C | 4 +- src/OpenFOAM/db/IOobjectList/IOobjectList.H | 4 +- .../IOobjects/CompactIOField/CompactIOField.C | 68 ++-- .../IOobjects/CompactIOField/CompactIOField.H | 5 + .../IOobjects/CompactIOList/CompactIOList.C | 6 +- src/OpenFOAM/db/IOobjects/IOField/IOField.C | 17 +- src/OpenFOAM/db/IOobjects/IOList/IOList.C | 9 +- src/OpenFOAM/db/IOobjects/IOMap/IOMap.C | 9 +- .../db/IOobjects/IOPtrList/IOPtrList.C | 38 +-- .../decomposedBlockData/decomposedBlockData.C | 11 +- .../db/IOobjects/rawIOField/rawIOField.C | 19 +- src/OpenFOAM/db/Time/Time.C | 2 +- src/OpenFOAM/db/Time/Time.H | 2 +- .../db/objectRegistry/objectRegistry.C | 2 +- src/OpenFOAM/db/regIOobject/regIOobject.H | 7 +- src/OpenFOAM/db/regIOobject/regIOobjectRead.C | 13 +- .../db/regIOobject/regIOobjectWrite.C | 12 - .../DimensionedField/DimensionedFieldIO.C | 9 +- .../GeometricField/GeometricField.C | 8 +- .../fileOperation/fileOperation.C | 8 +- .../masterUncollatedFileOperation.C | 6 +- src/OpenFOAM/matrices/schemes/schemesLookup.C | 4 +- src/OpenFOAM/matrices/schemes/schemesLookup.H | 2 +- src/OpenFOAM/matrices/solution/solution.C | 4 +- src/OpenFOAM/matrices/solution/solution.H | 2 +- .../mapDistribute/IOmapDistribute.C | 11 +- .../mapDistribute/IOmapDistributePolyMesh.C | 9 +- .../polyBoundaryMesh/polyBoundaryMesh.C | 9 +- .../polyBoundaryMeshEntries.H | 15 +- src/OpenFOAM/meshes/polyMesh/polyMesh.H | 2 +- src/OpenFOAM/meshes/polyMesh/polyMeshIO.C | 2 +- .../meshes/polyMesh/zones/ZoneMesh/ZoneMesh.C | 7 +- .../coordinate/systems/coordinateSystems.C | 9 +- .../hexRef8/refinementHistory.C | 18 +- .../polyTopoChanger/polyTopoChanger.C | 11 +- .../polyTopoChanger/polyTopoChanger.H | 2 +- .../faMesh/faBoundaryMesh/faBoundaryMesh.C | 9 +- .../faBoundaryMesh/faBoundaryMeshEntries.H | 9 +- src/finiteArea/faSolution/faSolution.H | 4 +- .../finiteArea/faSchemes/faSchemes.H | 4 +- .../finiteVolume/fvSchemes/fvSchemes.H | 4 +- .../finiteVolume/fvSolution/fvSolution.H | 4 +- .../utilities/writeObjects/writeObjects.C | 24 +- .../utilities/writeObjects/writeObjects.H | 14 +- src/lagrangian/basic/Cloud/Cloud.H | 2 +- src/lagrangian/basic/Cloud/CloudIO.C | 4 +- .../movement/lumpedPointIOMovement.C | 12 +- .../extendedFeatureEdgeMesh.C | 9 +- .../featureEdgeMesh/featureEdgeMesh.C | 8 +- .../regionProperties/regionProperties.C | 12 +- .../regionProperties/regionProperties.H | 10 +- src/meshTools/topoSet/topoSets/cellSet.C | 46 +-- src/meshTools/topoSet/topoSets/cellSet.H | 30 +- src/meshTools/topoSet/topoSets/cellZoneSet.C | 19 +- src/meshTools/topoSet/topoSets/cellZoneSet.H | 16 +- src/meshTools/topoSet/topoSets/faceSet.C | 32 +- src/meshTools/topoSet/topoSets/faceSet.H | 22 +- src/meshTools/topoSet/topoSets/faceZoneSet.C | 19 +- src/meshTools/topoSet/topoSets/faceZoneSet.H | 16 +- src/meshTools/topoSet/topoSets/pointSet.C | 32 +- src/meshTools/topoSet/topoSets/pointSet.H | 22 +- src/meshTools/topoSet/topoSets/pointZoneSet.C | 19 +- src/meshTools/topoSet/topoSets/pointZoneSet.H | 16 +- src/meshTools/topoSet/topoSets/topoSet.C | 72 ++-- src/meshTools/topoSet/topoSets/topoSet.H | 50 +-- .../distributedTriSurfaceMesh.C | 14 +- .../MeshedSurfaceIOAllocator.C | 4 +- .../MeshedSurfaceIOAllocator.H | 8 +- src/surfMesh/surfMesh/surfMesh.H | 10 +- src/surfMesh/surfMesh/surfMeshIO.C | 6 +- src/surfMesh/surfZone/surfZoneIOList.C | 8 +- 78 files changed, 891 insertions(+), 850 deletions(-) create mode 100644 src/OpenFOAM/db/IOobject/IOobjectOption.H diff --git a/applications/test/IOField/Test-IOField.C b/applications/test/IOField/Test-IOField.C index 729a7c85e5..478d917359 100644 --- a/applications/test/IOField/Test-IOField.C +++ b/applications/test/IOField/Test-IOField.C @@ -90,7 +90,7 @@ void writeAndRead const IOobject& io, const label sz, const word& writeType, - const IOobject::readOption rOpt, + IOobjectOption::readOption rOpt, const word& readType ) { @@ -208,7 +208,8 @@ int main(int argc, char *argv[]) runTime.timeName(), mesh, IOobject::NO_READ, - IOobject::NO_WRITE + IOobject::NO_WRITE, + IOobject::NO_REGISTER ); { @@ -243,9 +244,7 @@ int main(int argc, char *argv[]) args.executable(), "constant", runTime, - IOobject::NO_READ, - IOobject::NO_WRITE, - false + IOobject::NO_REGISTER // implicit convert to IOobjectOption ); labelList ints(identity(200)); diff --git a/applications/test/sizeof/Test-sizeof.C b/applications/test/sizeof/Test-sizeof.C index dfebf13b59..a5bd8ce9a7 100644 --- a/applications/test/sizeof/Test-sizeof.C +++ b/applications/test/sizeof/Test-sizeof.C @@ -135,6 +135,7 @@ int main(int argc, char *argv[]) cout<<"string:" << sizeof(Foam::string) << nl; } + cout<<"IOobjectOption:" << sizeof(Foam::IOobjectOption) << nl; cout<<"IOobject:" << sizeof(Foam::IOobject) << nl; cout<<"IOstream:" << sizeof(Foam::IOstream) << nl; cout<<"PstreamBuffers:" << sizeof(Foam::PstreamBuffers) << nl; diff --git a/src/OpenFOAM/db/IOobject/IOobject.C b/src/OpenFOAM/db/IOobject/IOobject.C index 803c53dece..b88c622922 100644 --- a/src/OpenFOAM/db/IOobject/IOobject.C +++ b/src/OpenFOAM/db/IOobject/IOobject.C @@ -312,24 +312,19 @@ Foam::IOobject::IOobject const word& name, const fileName& instance, const objectRegistry& registry, - readOption rOpt, - writeOption wOpt, - bool registerObject, - bool globalObject + IOobjectOption ioOpt ) : + IOobjectOption(ioOpt), + objState_(objectState::GOOD), + sizeofLabel_(static_cast(sizeof(label))), + sizeofScalar_(static_cast(sizeof(scalar))), + name_(name), headerClassName_(typeName), note_(), instance_(instance), local_(), - rOpt_(rOpt), - wOpt_(wOpt), - registerObject_(registerObject), - globalObject_(globalObject), - objState_(objectState::GOOD), - sizeofLabel_(static_cast(sizeof(label))), - sizeofScalar_(static_cast(sizeof(scalar))), db_(registry) { @@ -337,8 +332,7 @@ Foam::IOobject::IOobject { InfoInFunction << "Constructing IOobject called " << name_ - << " of type " << headerClassName_ - << endl; + << " of type " << headerClassName_ << endl; } } @@ -349,24 +343,19 @@ Foam::IOobject::IOobject const fileName& instance, const fileName& local, const objectRegistry& registry, - readOption rOpt, - writeOption wOpt, - bool registerObject, - bool globalObject + IOobjectOption ioOpt ) : + IOobjectOption(ioOpt), + objState_(objectState::GOOD), + sizeofLabel_(static_cast(sizeof(label))), + sizeofScalar_(static_cast(sizeof(scalar))), + name_(name), headerClassName_(typeName), note_(), instance_(instance), local_(local), - rOpt_(rOpt), - wOpt_(wOpt), - registerObject_(registerObject), - globalObject_(globalObject), - objState_(objectState::GOOD), - sizeofLabel_(static_cast(sizeof(label))), - sizeofScalar_(static_cast(sizeof(scalar))), db_(registry) { @@ -374,8 +363,7 @@ Foam::IOobject::IOobject { InfoInFunction << "Constructing IOobject called " << name_ - << " of type " << headerClassName_ - << endl; + << " of type " << headerClassName_ << endl; } } @@ -384,24 +372,19 @@ Foam::IOobject::IOobject ( const fileName& path, const objectRegistry& registry, - readOption rOpt, - writeOption wOpt, - bool registerObject, - bool globalObject + IOobjectOption ioOpt ) : + IOobjectOption(ioOpt), + objState_(objectState::GOOD), + sizeofLabel_(static_cast(sizeof(label))), + sizeofScalar_(static_cast(sizeof(scalar))), + name_(), headerClassName_(typeName), note_(), instance_(), local_(), - rOpt_(rOpt), - wOpt_(wOpt), - registerObject_(registerObject), - globalObject_(globalObject), - objState_(objectState::GOOD), - sizeofLabel_(static_cast(sizeof(label))), - sizeofScalar_(static_cast(sizeof(scalar))), db_(registry) { @@ -416,8 +399,7 @@ Foam::IOobject::IOobject { InfoInFunction << "Constructing IOobject called " << name_ - << " of type " << headerClassName_ - << endl; + << " of type " << headerClassName_ << endl; } } @@ -428,18 +410,16 @@ Foam::IOobject::IOobject const objectRegistry& registry ) : + IOobjectOption(static_cast(io)), + objState_(io.objState_), + sizeofLabel_(io.sizeofLabel_), + sizeofScalar_(io.sizeofScalar_), + name_(io.name_), headerClassName_(io.headerClassName_), note_(io.note_), instance_(io.instance_), local_(io.local_), - rOpt_(io.rOpt_), - wOpt_(io.wOpt_), - registerObject_(io.registerObject_), - globalObject_(io.globalObject_), - objState_(io.objState_), - sizeofLabel_(io.sizeofLabel_), - sizeofScalar_(io.sizeofScalar_), db_(registry) {} @@ -451,50 +431,21 @@ Foam::IOobject::IOobject const word& name ) : + IOobjectOption(static_cast(io)), + objState_(io.objState_), + sizeofLabel_(io.sizeofLabel_), + sizeofScalar_(io.sizeofScalar_), + name_(name), headerClassName_(io.headerClassName_), note_(io.note_), instance_(io.instance_), local_(io.local_), - rOpt_(io.rOpt_), - wOpt_(io.wOpt_), - registerObject_(io.registerObject_), - globalObject_(io.globalObject_), - objState_(io.objState_), - sizeofLabel_(io.sizeofLabel_), - sizeofScalar_(io.sizeofScalar_), db_(io.db_) {} -Foam::IOobject::IOobject -( - const IOobject& io, - const word& name, - const fileName& local -) -: - IOobject(io, name) -{ - local_ = local; -} - - -Foam::IOobject::IOobject -( - const IOobject& io, - readOption rOpt, - writeOption wOpt -) -: - IOobject(io) -{ - rOpt_ = rOpt; - wOpt_ = wOpt; -} - - // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // const Foam::objectRegistry& Foam::IOobject::db() const noexcept @@ -623,17 +574,20 @@ void Foam::IOobject::setBad(const string& s) void Foam::IOobject::operator=(const IOobject& io) { + readOpt(io.readOpt()); + writeOpt(io.writeOpt()); + // No change to registerObject + globalObject(io.globalObject()); + + objState_ = io.objState_; + sizeofLabel_ = io.sizeofLabel_; + sizeofScalar_ = io.sizeofScalar_; + name_ = io.name_; headerClassName_ = io.headerClassName_; note_ = io.note_; instance_ = io.instance_; local_ = io.local_; - rOpt_ = io.rOpt_; - wOpt_ = io.wOpt_; - globalObject_ = io.globalObject_; - objState_ = io.objState_; - sizeofLabel_ = io.sizeofLabel_; - sizeofScalar_ = io.sizeofScalar_; } diff --git a/src/OpenFOAM/db/IOobject/IOobject.H b/src/OpenFOAM/db/IOobject/IOobject.H index 947fe64ea9..7321543725 100644 --- a/src/OpenFOAM/db/IOobject/IOobject.H +++ b/src/OpenFOAM/db/IOobject/IOobject.H @@ -101,9 +101,10 @@ SourceFiles #include "fileName.H" #include "typeInfo.H" #include "autoPtr.H" -#include "IOstreamOption.H" #include "InfoProxy.H" #include "Enum.H" +#include "IOobjectOption.H" +#include "IOstreamOption.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -120,27 +121,13 @@ class objectRegistry; \*---------------------------------------------------------------------------*/ class IOobject +: + public IOobjectOption { public: // Public Data Types - //- Enumeration defining the read options - enum readOption : char - { - NO_READ = 0, - MUST_READ = 1, - MUST_READ_IF_MODIFIED = 3, - READ_IF_PRESENT = 4 - }; - - //- Enumeration defining the write options - enum writeOption : char - { - NO_WRITE = 0, - AUTO_WRITE = 0x10 - }; - //- Enumeration defining the valid states of an IOobject enum objectState : char { @@ -169,7 +156,16 @@ private: static bool bannerEnabled_; - // Private Data + // Private Data (NB: byte-flags first for better alignment) + + //- The IOobject state + objectState objState_; + + //- The sizeof (label) in bytes, possibly read from the header + unsigned char sizeofLabel_; + + //- The sizeof (scalar) in bytes, possibly read from the header + unsigned char sizeofScalar_; //- Name word name_; @@ -186,27 +182,6 @@ private: //- Local path component fileName local_; - //- Read option - readOption rOpt_; - - //- Write option - writeOption wOpt_; - - //- Should object created with this IOobject be registered? - bool registerObject_; - - //- Is object same for all processors? - bool globalObject_; - - //- IOobject state - objectState objState_; - - //- The sizeof (label) in bytes, possibly read from the header - unsigned char sizeofLabel_; - - //- The sizeof (scalar) in bytes, possibly read from the header - unsigned char sizeofScalar_; - //- Reference to the objectRegistry const objectRegistry& db_; @@ -355,26 +330,62 @@ public: // Constructors //- Construct from name, instance, registry, io options + // (default: NO_READ, NO_WRITE, register, non-global) IOobject ( const word& name, const fileName& instance, const objectRegistry& registry, - readOption rOpt = NO_READ, - writeOption wOpt = NO_WRITE, - bool registerObject = true, - bool globalObject = false + IOobjectOption ioOpt = IOobjectOption() ); //- Construct from name, instance, local, registry, io options + // (default: NO_READ, NO_WRITE, register, non-global) IOobject ( const word& name, const fileName& instance, const fileName& local, const objectRegistry& registry, - readOption rOpt = NO_READ, - writeOption wOpt = NO_WRITE, + IOobjectOption ioOpt = IOobjectOption() + ); + + //- Construct from path, registry, io options. + // (default: NO_READ, NO_WRITE, register, non-global) + // + // Uses fileNameComponents() to split path into components. + // A path that starts with a '/' is regarded as a file system path. + // Paths starting with either './' or '../' are relative to + // current working directory (and replaced with absolute equivalents). + // All other paths are considered to be relative to the case. + IOobject + ( + const fileName& path, + const objectRegistry& registry, + IOobjectOption ioOpt = IOobjectOption() + ); + + //- Construct from name, instance, registry, io options + inline IOobject + ( + const word& name, + const fileName& instance, + const objectRegistry& registry, + IOobjectOption::readOption rOpt, + IOobjectOption::writeOption wOpt = IOobjectOption::NO_WRITE, + bool registerObject = true, + bool globalObject = false + ); + + //- Construct from name, instance, local, registry, io options + inline IOobject + ( + const word& name, + const fileName& instance, + const fileName& local, + const objectRegistry& registry, + IOobjectOption::readOption rOpt, + IOobjectOption::writeOption wOpt = IOobjectOption::NO_WRITE, bool registerObject = true, bool globalObject = false ); @@ -385,12 +396,12 @@ public: // Paths starting with either './' or '../' are relative to // current working directory (and replaced with absolute equivalents). // All other paths are considered to be relative to the case. - IOobject + inline IOobject ( const fileName& path, const objectRegistry& registry, - readOption rOpt = NO_READ, - writeOption wOpt = NO_WRITE, + IOobjectOption::readOption rOpt, + IOobjectOption::writeOption wOpt = IOobjectOption::NO_WRITE, bool registerObject = true, bool globalObject = false ); @@ -402,10 +413,20 @@ public: IOobject(const IOobject& io, const word& name); //- Copy construct, resetting name and local component - IOobject(const IOobject& io, const word& name, const fileName& local); + inline IOobject + ( + const IOobject& io, + const word& name, + const fileName& local + ); //- Copy construct, resetting read/write options - IOobject(const IOobject& io, readOption rOpt, writeOption wOpt); + inline IOobject + ( + const IOobject& io, + IOobjectOption::readOption rOpt, + IOobjectOption::writeOption wOpt + ); //- Clone @@ -452,18 +473,6 @@ public: name_ = newName; } - //- Should object created with this IOobject be registered? - inline bool registerObject() const noexcept; - - //- Change registration preference, return previous value - inline bool registerObject(bool on) noexcept; - - //- Is object same for all processors? - inline bool globalObject() const noexcept; - - //- Change global-object status, return previous value - inline bool globalObject(bool on) noexcept; - //- The sizeof (label) in bytes, possibly read from the header inline unsigned labelByteSize() const noexcept; @@ -491,21 +500,6 @@ public: virtual const dictionary* findMetaData() const noexcept; - // Read/write options - - //- The read option - inline readOption readOpt() const noexcept; - - //- Change the read option, return previous value - inline readOption readOpt(readOption opt) noexcept; - - //- The write option - inline writeOption writeOpt() const noexcept; - - //- Change the write option, return previous value - inline writeOption writeOpt(writeOption opt) noexcept; - - // Path components //- Return group (extension part of name) @@ -545,7 +539,7 @@ public: //- The object path relative to the root fileName objectRelPath() const; - //- Helper for filePath that searches locally. + //- Redirect to fileHandler filePath, searching locally. // When search is false, simply use the current instance, // otherwise search previous instances. fileName localFilePath @@ -554,7 +548,7 @@ public: const bool search=true ) const; - //- Helper for filePath that searches up if in parallel + //- Redirect to fileHandler filePath, searching up if in parallel. // When search is false, simply use the current instance, // otherwise search previous instances. fileName globalFilePath @@ -650,25 +644,6 @@ public: //- Copy assignment, copies all values (except the registry) void operator=(const IOobject& io); - - - // Housekeeping - - //- Access to the read option - // \deprecated(2021-03) - use readOpt(readOption) - readOption& readOpt() noexcept { return rOpt_; } - - //- Access to the write option - // \deprecated(2021-03) - use writeOpt(writeOption) - writeOption& writeOpt() noexcept { return wOpt_; } - - //- Access to the register object option - // \deprecated(2021-03) - use registerObject(bool) - bool& registerObject() noexcept { return registerObject_; } - - //- Access to the global object option - // \deprecated(2021-03) - use globalObject(bool) - bool& globalObject() noexcept { return globalObject_; } }; diff --git a/src/OpenFOAM/db/IOobject/IOobjectI.H b/src/OpenFOAM/db/IOobject/IOobjectI.H index 8c081bf7b1..41a410fc2e 100644 --- a/src/OpenFOAM/db/IOobject/IOobjectI.H +++ b/src/OpenFOAM/db/IOobject/IOobjectI.H @@ -58,6 +58,98 @@ inline Foam::word Foam::IOobject::scopedName } +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +inline Foam::IOobject::IOobject +( + const word& name, + const fileName& instance, + const objectRegistry& registry, + IOobjectOption::readOption rOpt, + IOobjectOption::writeOption wOpt, + bool registerObject, + bool globalObject +) +: + IOobject + ( + name, + instance, + registry, + IOobjectOption(rOpt, wOpt, registerObject, globalObject) + ) +{} + + +inline Foam::IOobject::IOobject +( + const word& name, + const fileName& instance, + const fileName& local, + const objectRegistry& registry, + IOobjectOption::readOption rOpt, + IOobjectOption::writeOption wOpt, + bool registerObject, + bool globalObject +) +: + IOobject + ( + name, + instance, + local, + registry, + IOobjectOption(rOpt, wOpt, registerObject, globalObject) + ) +{} + + +inline Foam::IOobject::IOobject +( + const fileName& path, + const objectRegistry& registry, + IOobjectOption::readOption rOpt, + IOobjectOption::writeOption wOpt, + bool registerObject, + bool globalObject +) +: + IOobject + ( + path, + registry, + IOobjectOption(rOpt, wOpt, registerObject, globalObject) + ) +{} + + +inline Foam::IOobject::IOobject +( + const IOobject& io, + const word& name, + const fileName& local +) +: + IOobject(io, name) +{ + local_ = local; +} + + +inline Foam::IOobject::IOobject +( + const IOobject& io, + IOobjectOption::readOption rOpt, + IOobjectOption::writeOption wOpt +) +: + IOobject(io) +{ + readOpt(rOpt); + writeOpt(wOpt); +} + + // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // General access @@ -104,34 +196,6 @@ inline Foam::string& Foam::IOobject::note() noexcept } -inline bool Foam::IOobject::registerObject() const noexcept -{ - return registerObject_; -} - - -inline bool Foam::IOobject::registerObject(bool on) noexcept -{ - bool old(registerObject_); - registerObject_ = on; - return old; -} - - -inline bool Foam::IOobject::globalObject() const noexcept -{ - return globalObject_; -} - - -inline bool Foam::IOobject::globalObject(bool on) noexcept -{ - bool old(globalObject_); - globalObject_ = on; - return old; -} - - inline unsigned Foam::IOobject::labelByteSize() const noexcept { return static_cast(sizeofLabel_); @@ -159,38 +223,6 @@ inline bool Foam::IOobject::isHeaderClass() const } -// Read/write options - -inline Foam::IOobject::readOption Foam::IOobject::readOpt() const noexcept -{ - return rOpt_; -} - - -inline Foam::IOobject::readOption -Foam::IOobject::readOpt(readOption opt) noexcept -{ - readOption old(rOpt_); - rOpt_ = opt; - return old; -} - - -inline Foam::IOobject::writeOption Foam::IOobject::writeOpt() const noexcept -{ - return wOpt_; -} - - -inline Foam::IOobject::writeOption -Foam::IOobject::writeOpt(writeOption opt) noexcept -{ - writeOption old(wOpt_); - wOpt_ = opt; - return old; -} - - // Path components inline const Foam::fileName& Foam::IOobject::instance() const noexcept diff --git a/src/OpenFOAM/db/IOobject/IOobjectOption.H b/src/OpenFOAM/db/IOobject/IOobjectOption.H new file mode 100644 index 0000000000..6887143b7d --- /dev/null +++ b/src/OpenFOAM/db/IOobject/IOobjectOption.H @@ -0,0 +1,312 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2011 OpenFOAM Foundation + Copyright (C) 2016-2022 OpenCFD Ltd. +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +Class + Foam::IOobjectOption + +Description + A simple container of IOobject preferences. + Can also be used for general handling of read/no-read/read-if-present + logic outside of an IOobject. + +Note + In the future may include an Enumeration defining register preferences + (NO_REGISTER, REGISTER) + +See also + Foam::IOobject + +\*---------------------------------------------------------------------------*/ + +#ifndef Foam_IOobjectOption_H +#define Foam_IOobjectOption_H + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class IOobjectOption Declaration +\*---------------------------------------------------------------------------*/ + +class IOobjectOption +{ +public: + + // Public Data Types + + //- Enumeration defining read preferences + // Lowest bit encodes must read + enum readOption : unsigned char + { + //! Nothing to be read + NO_READ = 0, + + //! Reading required + MUST_READ = 0x1, + + //! Reading required, file watched for runTime modification + MUST_READ_IF_MODIFIED = 0x3, + + //! Reading is optional + READ_IF_PRESENT = 0x4 + }; + + //- Enumeration defining write preferences + enum writeOption : unsigned char + { + //! Ignore writing from objectRegistry::writeObject() + NO_WRITE = 0, + + //! Automatically write from objectRegistry::writeObject() + AUTO_WRITE = 0x10 + }; + + //- Enumeration for use with registerObject(). + //- Values map to bool (false/true) + enum registerOption : unsigned char + { + //! Do not request registration (bool: false) + NO_REGISTER = 0, + + //! Request registration (bool: true) + REGISTER = 1 + }; + + +private: + + // Private Data + + //- Read option + readOption readOpt_; + + //- Write option + writeOption writeOpt_; + + //- Should created objects be registered? + bool registerObject_; + + //- Is object same for all processors? + bool globalObject_; + + +public: + + // Constructors + + //- Default construct (NO_READ, NO_WRITE, register, non-global) + //- or construct with specified options + constexpr IOobjectOption + ( + readOption rOpt = readOption::NO_READ, + writeOption wOpt = writeOption::NO_WRITE, + registerOption registerObject = registerOption::REGISTER, + bool globalObject = false + ) noexcept + : + readOpt_(rOpt), + writeOpt_(wOpt), + registerObject_(registerObject), + globalObject_(globalObject) + {} + + //- Construct NO_WRITE with specified read/register options + constexpr IOobjectOption + ( + readOption rOpt, + registerOption registerObject = registerOption::REGISTER, + bool globalObject = false + ) noexcept + : + readOpt_(rOpt), + writeOpt_(writeOption::NO_WRITE), + registerObject_(registerObject), + globalObject_(globalObject) + {} + + //- Construct NO_READ with specified write/register options + constexpr IOobjectOption + ( + writeOption wOpt, + registerOption registerObject = registerOption::REGISTER, + bool globalObject = false + ) noexcept + : + readOpt_(readOption::NO_READ), + writeOpt_(wOpt), + registerObject_(registerObject), + globalObject_(globalObject) + {} + + //- Construct (NO_READ, NO_WRITE) with specified register option + constexpr IOobjectOption + ( + registerOption registerObject, + bool globalObject = false + ) noexcept + : + readOpt_(readOption::NO_READ), + writeOpt_(writeOption::NO_WRITE), + registerObject_(registerObject), + globalObject_(globalObject) + {} + + //- Construct from components + //- with specified register option as bool + constexpr IOobjectOption + ( + readOption rOpt, + writeOption wOpt, + bool registerObject, + bool globalObject = false + ) noexcept + : + readOpt_(rOpt), + writeOpt_(wOpt), + registerObject_(registerObject ? REGISTER : NO_REGISTER), + globalObject_(globalObject) + {} + + //- Construct (NO_READ, NO_WRITE) + //- with specified register option as bool + explicit constexpr IOobjectOption + ( + bool registerObject, + bool globalObject = false + ) noexcept + : + readOpt_(readOption::NO_READ), + writeOpt_(writeOption::NO_WRITE), + registerObject_(registerObject ? REGISTER : NO_REGISTER), + globalObject_(globalObject) + {} + + + // Member Functions + + //- Get the read option + readOption readOpt() const noexcept { return readOpt_; } + + //- Set the read option \return the previous value + readOption readOpt(readOption opt) noexcept + { + readOption old(readOpt_); + readOpt_ = opt; + return old; + } + + //- Get the write option + writeOption writeOpt() const noexcept { return writeOpt_; } + + //- Set the write option \return the previous value + writeOption writeOpt(writeOption opt) noexcept + { + writeOption old(writeOpt_); + writeOpt_ = opt; + return old; + } + + //- Should objects created with this IOobject be registered? + bool registerObject() const noexcept { return registerObject_; } + + //- Change registration preference \return previous value + bool registerObject(bool on) noexcept + { + bool old(registerObject_); + registerObject_ = on; + return old; + } + + //- True if object is treated the same for all processors + bool globalObject() const noexcept { return globalObject_; } + + //- Change global-object status \return previous value + bool globalObject(bool on) noexcept + { + bool old(globalObject_); + globalObject_ = on; + return old; + } + + + // Checks + + //- True if (MUST_READ | MUST_READ_IF_MODIFIED) bits are set + static bool isReadRequired(readOption opt) noexcept + { + return static_cast(opt & readOption::MUST_READ); + } + + //- True if (MUST_READ | MUST_READ_IF_MODIFIED) bits are set + bool isReadRequired() const noexcept + { + return static_cast(readOpt_ & readOption::MUST_READ); + } + + //- True if (READ_IF_PRESENT) bits are set + static bool isReadOptional(readOption opt) noexcept + { + return (opt == readOption::READ_IF_PRESENT); + } + + //- True if (READ_IF_PRESENT) bits are set + bool isReadOptional() const noexcept + { + return (readOpt_ == readOption::READ_IF_PRESENT); + } + + + // Housekeeping + + //- Access to the read option + // \deprecated(2021-03) - use readOpt(readOption) + readOption& readOpt() noexcept { return readOpt_; } + + //- Access to the write option + // \deprecated(2021-03) - use writeOpt(writeOption) + writeOption& writeOpt() noexcept { return writeOpt_; } + + //- Access to the register object option + // \deprecated(2021-03) - use registerObject(bool) + bool& registerObject() noexcept { return registerObject_; } + + //- Access to the global object option + // \deprecated(2021-03) - use globalObject(bool) + bool& globalObject() noexcept { return globalObject_; } +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/OpenFOAM/db/IOobject/IOobjectReadHeader.C b/src/OpenFOAM/db/IOobject/IOobjectReadHeader.C index ca0d304433..36ff0f2b8d 100644 --- a/src/OpenFOAM/db/IOobject/IOobjectReadHeader.C +++ b/src/OpenFOAM/db/IOobject/IOobjectReadHeader.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2019-2021 OpenCFD Ltd. + Copyright (C) 2019-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -80,11 +80,7 @@ bool Foam::IOobject::readHeader(dictionary& headerDict, Istream& is) // Check Istream not already bad if (!is.good()) { - if - ( - rOpt_ == IOobject::MUST_READ - || rOpt_ == IOobject::MUST_READ_IF_MODIFIED - ) + if (isReadRequired()) { FatalIOErrorInFunction(is) << " stream not open for reading essential object from file " @@ -140,11 +136,7 @@ bool Foam::IOobject::readHeader(dictionary& headerDict, Istream& is) if (objState_ == objectState::BAD) { - if - ( - rOpt_ == IOobject::MUST_READ - || rOpt_ == IOobject::MUST_READ_IF_MODIFIED - ) + if (isReadRequired()) { FatalIOErrorInFunction(is) << " stream failure while reading header" diff --git a/src/OpenFOAM/db/IOobjectList/IOobjectList.C b/src/OpenFOAM/db/IOobjectList/IOobjectList.C index b3a5963981..cdfd9e97da 100644 --- a/src/OpenFOAM/db/IOobjectList/IOobjectList.C +++ b/src/OpenFOAM/db/IOobjectList/IOobjectList.C @@ -130,8 +130,8 @@ Foam::IOobjectList::IOobjectList const objectRegistry& db, const fileName& instance, const fileName& local, - IOobject::readOption rOpt, - IOobject::writeOption wOpt, + IOobjectOption::readOption rOpt, + IOobjectOption::writeOption wOpt, bool registerObject ) : diff --git a/src/OpenFOAM/db/IOobjectList/IOobjectList.H b/src/OpenFOAM/db/IOobjectList/IOobjectList.H index 4d366cd03b..b6d1fad9bd 100644 --- a/src/OpenFOAM/db/IOobjectList/IOobjectList.H +++ b/src/OpenFOAM/db/IOobjectList/IOobjectList.H @@ -182,8 +182,8 @@ public: const objectRegistry& db, const fileName& instance, const fileName& local = "", - IOobject::readOption rOpt = IOobject::MUST_READ, - IOobject::writeOption wOpt = IOobject::NO_WRITE, + IOobjectOption::readOption rOpt = IOobjectOption::MUST_READ, + IOobjectOption::writeOption wOpt = IOobjectOption::NO_WRITE, bool registerObject = true ); diff --git a/src/OpenFOAM/db/IOobjects/CompactIOField/CompactIOField.C b/src/OpenFOAM/db/IOobjects/CompactIOField/CompactIOField.C index 4dc60f292e..e89d103913 100644 --- a/src/OpenFOAM/db/IOobjects/CompactIOField/CompactIOField.C +++ b/src/OpenFOAM/db/IOobjects/CompactIOField/CompactIOField.C @@ -61,6 +61,23 @@ void Foam::CompactIOField::readFromStream(const bool valid) } +template +bool Foam::CompactIOField::readContents() +{ + if + ( + readOpt() == IOobject::MUST_READ + || (isReadOptional() && headerOk()) + ) + { + readFromStream(); + return true; + } + + return false; +} + + // * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * // template @@ -68,14 +85,7 @@ Foam::CompactIOField::CompactIOField(const IOobject& io) : regIOobject(io) { - if - ( - io.readOpt() == IOobject::MUST_READ - || (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk()) - ) - { - readFromStream(); - } + readContents(); } @@ -88,11 +98,11 @@ Foam::CompactIOField::CompactIOField : regIOobject(io) { - if (io.readOpt() == IOobject::MUST_READ) + if (readOpt() == IOobject::MUST_READ) { readFromStream(valid); } - else if (io.readOpt() == IOobject::READ_IF_PRESENT) + else if (isReadOptional()) { bool haveFile = headerOk(); readFromStream(valid && haveFile); @@ -109,14 +119,7 @@ Foam::CompactIOField::CompactIOField : regIOobject(io) { - if - ( - io.readOpt() == IOobject::MUST_READ - || (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk()) - ) - { - readFromStream(); - } + readContents(); } @@ -129,15 +132,7 @@ Foam::CompactIOField::CompactIOField : regIOobject(io) { - if - ( - io.readOpt() == IOobject::MUST_READ - || (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk()) - ) - { - readFromStream(); - } - else + if (!readContents()) { Field::resize(len); } @@ -153,15 +148,7 @@ Foam::CompactIOField::CompactIOField : regIOobject(io) { - if - ( - io.readOpt() == IOobject::MUST_READ - || (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk()) - ) - { - readFromStream(); - } - else + if (!readContents()) { Field::operator=(content); } @@ -179,14 +166,7 @@ Foam::CompactIOField::CompactIOField { Field::transfer(content); - if - ( - io.readOpt() == IOobject::MUST_READ - || (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk()) - ) - { - readFromStream(); - } + readContents(); } diff --git a/src/OpenFOAM/db/IOobjects/CompactIOField/CompactIOField.H b/src/OpenFOAM/db/IOobjects/CompactIOField/CompactIOField.H index d4e9b193f7..fe7baa3a7e 100644 --- a/src/OpenFOAM/db/IOobjects/CompactIOField/CompactIOField.H +++ b/src/OpenFOAM/db/IOobjects/CompactIOField/CompactIOField.H @@ -79,6 +79,11 @@ class CompactIOField //- Read according to header type void readFromStream(const bool valid = true); + //- Read if IOobject flags set. Return true if read. + // Reads according to the header type + bool readContents(); + + public: //- Runtime type information diff --git a/src/OpenFOAM/db/IOobjects/CompactIOList/CompactIOList.C b/src/OpenFOAM/db/IOobjects/CompactIOList/CompactIOList.C index 096caede17..3780264f83 100644 --- a/src/OpenFOAM/db/IOobjects/CompactIOList/CompactIOList.C +++ b/src/OpenFOAM/db/IOobjects/CompactIOList/CompactIOList.C @@ -50,8 +50,8 @@ void Foam::CompactIOList::readFromStream() { FatalIOErrorInFunction(is) << "unexpected class name " << headerClassName() - << " expected " << typeName << " or " << IOList::typeName - << endl + << " expected " << typeName + << " or " << IOList::typeName << endl << " while reading object " << name() << exit(FatalIOError); } @@ -64,7 +64,7 @@ bool Foam::CompactIOList::readContents() if ( readOpt() == IOobject::MUST_READ - || (readOpt() == IOobject::READ_IF_PRESENT && headerOk()) + || (isReadOptional() && headerOk()) ) { readFromStream(); diff --git a/src/OpenFOAM/db/IOobjects/IOField/IOField.C b/src/OpenFOAM/db/IOobjects/IOField/IOField.C index c4edcd27da..fd24992488 100644 --- a/src/OpenFOAM/db/IOobjects/IOField/IOField.C +++ b/src/OpenFOAM/db/IOobjects/IOField/IOField.C @@ -33,14 +33,7 @@ License template bool Foam::IOField::readContents() { - if - ( - ( - readOpt() == IOobject::MUST_READ - || readOpt() == IOobject::MUST_READ_IF_MODIFIED - ) - || (readOpt() == IOobject::READ_IF_PRESENT && headerOk()) - ) + if (isReadRequired() || (isReadOptional() && headerOk())) { readStream(typeName) >> *this; close(); @@ -73,11 +66,7 @@ Foam::IOField::IOField(const IOobject& io, const bool valid) // Check for MUST_READ_IF_MODIFIED warnNoRereading>(); - if - ( - io.readOpt() == IOobject::MUST_READ - || io.readOpt() == IOobject::MUST_READ_IF_MODIFIED - ) + if (isReadRequired()) { Istream& is = readStream(typeName, valid); @@ -87,7 +76,7 @@ Foam::IOField::IOField(const IOobject& io, const bool valid) } close(); } - else if (io.readOpt() == IOobject::READ_IF_PRESENT) + else if (isReadOptional()) { bool haveFile = headerOk(); diff --git a/src/OpenFOAM/db/IOobjects/IOList/IOList.C b/src/OpenFOAM/db/IOobjects/IOList/IOList.C index 79c9cd690e..bb29720f1c 100644 --- a/src/OpenFOAM/db/IOobjects/IOList/IOList.C +++ b/src/OpenFOAM/db/IOobjects/IOList/IOList.C @@ -33,14 +33,7 @@ License template bool Foam::IOList::readContents() { - if - ( - ( - readOpt() == IOobject::MUST_READ - || readOpt() == IOobject::MUST_READ_IF_MODIFIED - ) - || (readOpt() == IOobject::READ_IF_PRESENT && headerOk()) - ) + if (isReadRequired() || (isReadOptional() && headerOk())) { readStream(typeName) >> *this; close(); diff --git a/src/OpenFOAM/db/IOobjects/IOMap/IOMap.C b/src/OpenFOAM/db/IOobjects/IOMap/IOMap.C index b44711ee55..253d9960a2 100644 --- a/src/OpenFOAM/db/IOobjects/IOMap/IOMap.C +++ b/src/OpenFOAM/db/IOobjects/IOMap/IOMap.C @@ -33,14 +33,7 @@ License template bool Foam::IOMap::readContents() { - if - ( - ( - readOpt() == IOobject::MUST_READ - || readOpt() == IOobject::MUST_READ_IF_MODIFIED - ) - || (readOpt() == IOobject::READ_IF_PRESENT && headerOk()) - ) + if (isReadRequired() || (isReadOptional() && headerOk())) { // For if MUST_READ_IF_MODIFIED addWatch(); diff --git a/src/OpenFOAM/db/IOobjects/IOPtrList/IOPtrList.C b/src/OpenFOAM/db/IOobjects/IOPtrList/IOPtrList.C index 556b48e150..e1e2a9dc3a 100644 --- a/src/OpenFOAM/db/IOobjects/IOPtrList/IOPtrList.C +++ b/src/OpenFOAM/db/IOobjects/IOPtrList/IOPtrList.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation - Copyright (C) 2018 OpenCFD Ltd. + Copyright (C) 2018-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -36,14 +36,7 @@ Foam::IOPtrList::IOPtrList(const IOobject& io, const INew& inewt) : regIOobject(io) { - if - ( - ( - io.readOpt() == IOobject::MUST_READ - || io.readOpt() == IOobject::MUST_READ_IF_MODIFIED - ) - || (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk()) - ) + if (isReadRequired() || (isReadOptional() && headerOk())) { // For if MUST_READ_IF_MODIFIED addWatch(); @@ -59,14 +52,7 @@ Foam::IOPtrList::IOPtrList(const IOobject& io) : regIOobject(io) { - if - ( - ( - io.readOpt() == IOobject::MUST_READ - || io.readOpt() == IOobject::MUST_READ_IF_MODIFIED - ) - || (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk()) - ) + if (isReadRequired() || (isReadOptional() && headerOk())) { // For if MUST_READ_IF_MODIFIED addWatch(); @@ -97,14 +83,7 @@ Foam::IOPtrList::IOPtrList(const IOobject& io, const PtrList& content) : regIOobject(io) { - if - ( - ( - io.readOpt() == IOobject::MUST_READ - || io.readOpt() == IOobject::MUST_READ_IF_MODIFIED - ) - || (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk()) - ) + if (isReadRequired() || (isReadOptional() && headerOk())) { // For if MUST_READ_IF_MODIFIED addWatch(); @@ -126,14 +105,7 @@ Foam::IOPtrList::IOPtrList(const IOobject& io, PtrList&& content) { PtrList::transfer(content); - if - ( - ( - io.readOpt() == IOobject::MUST_READ - || io.readOpt() == IOobject::MUST_READ_IF_MODIFIED - ) - || (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk()) - ) + if (isReadRequired() || (isReadOptional() && headerOk())) { // For if MUST_READ_IF_MODIFIED addWatch(); diff --git a/src/OpenFOAM/db/IOobjects/decomposedBlockData/decomposedBlockData.C b/src/OpenFOAM/db/IOobjects/decomposedBlockData/decomposedBlockData.C index 61b8732963..1d5105688b 100644 --- a/src/OpenFOAM/db/IOobjects/decomposedBlockData/decomposedBlockData.C +++ b/src/OpenFOAM/db/IOobjects/decomposedBlockData/decomposedBlockData.C @@ -86,7 +86,7 @@ Foam::decomposedBlockData::decomposedBlockData contentData_() { // Temporary warning - if (io.readOpt() == IOobject::MUST_READ_IF_MODIFIED) + if (readOpt() == IOobject::MUST_READ_IF_MODIFIED) { WarningInFunction << "decomposedBlockData " << name() @@ -94,14 +94,7 @@ Foam::decomposedBlockData::decomposedBlockData " but decomposedBlockData does not support automatic rereading." << endl; } - if - ( - ( - io.readOpt() == IOobject::MUST_READ - || io.readOpt() == IOobject::MUST_READ_IF_MODIFIED - ) - || (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk()) - ) + if (isReadRequired() || (isReadOptional() && headerOk())) { read(); } diff --git a/src/OpenFOAM/db/IOobjects/rawIOField/rawIOField.C b/src/OpenFOAM/db/IOobjects/rawIOField/rawIOField.C index 8ea42a6ef4..b084f6a985 100644 --- a/src/OpenFOAM/db/IOobjects/rawIOField/rawIOField.C +++ b/src/OpenFOAM/db/IOobjects/rawIOField/rawIOField.C @@ -40,15 +40,10 @@ Foam::rawIOField::rawIOField(const IOobject& io, const bool readAverage) // Check for MUST_READ_IF_MODIFIED warnNoRereading>(); - if - ( - io.readOpt() == IOobject::MUST_READ - || io.readOpt() == IOobject::MUST_READ_IF_MODIFIED - || io.readOpt() == IOobject::READ_IF_PRESENT - ) + if (io.isReadRequired() || io.isReadOptional()) { bool haveFile = false; - bool headerOk = false; + bool haveHeader = false; // Replacement of regIOobject::headerok() since that one complains // if there is no header. TBD - Move up to headerOk()/fileHandler. @@ -66,19 +61,19 @@ Foam::rawIOField::rawIOField(const IOobject& io, const bool readAverage) const token firstToken(is); - headerOk = is.good() && firstToken.isWord("FoamFile"); + haveHeader = is.good() && firstToken.isWord("FoamFile"); } if (debug) { Pout<< "rawIOField : object:" << io.name() << " haveFile:" << haveFile - << " headerOk:" << headerOk << endl; + << " haveHeader:" << haveHeader << endl; } } - if (headerOk) + if (haveHeader) { // Read but don't fail upon wrong class. Could extend by providing // wanted typeName. Tbd. @@ -113,8 +108,8 @@ Foam::rawIOField::rawIOField(const IOobject& io, const bool readAverage) } else { - // Error if missing and MUST_READ or MUST_READ_IF_MODIFIED - if (io.readOpt() != IOobject::READ_IF_PRESENT) + // Error if required but missing + if (io.isReadRequired()) { FatalIOErrorInFunction(*isPtr) << "Trying to read raw field" << endl diff --git a/src/OpenFOAM/db/Time/Time.C b/src/OpenFOAM/db/Time/Time.C index d83ba735f2..defc0a8b4e 100644 --- a/src/OpenFOAM/db/Time/Time.C +++ b/src/OpenFOAM/db/Time/Time.C @@ -787,7 +787,7 @@ Foam::word Foam::Time::findInstance ( const fileName& dir, const word& name, - const IOobject::readOption rOpt, + IOobjectOption::readOption rOpt, const word& stopInstance ) const { diff --git a/src/OpenFOAM/db/Time/Time.H b/src/OpenFOAM/db/Time/Time.H index 516c52c81a..da2d6c9731 100644 --- a/src/OpenFOAM/db/Time/Time.H +++ b/src/OpenFOAM/db/Time/Time.H @@ -433,7 +433,7 @@ public: ( const fileName& dir, const word& name = word::null, - const IOobject::readOption rOpt = IOobject::MUST_READ, + IOobjectOption::readOption rOpt = IOobjectOption::MUST_READ, const word& stopInstance = word::null ) const; diff --git a/src/OpenFOAM/db/objectRegistry/objectRegistry.C b/src/OpenFOAM/db/objectRegistry/objectRegistry.C index 95156bf687..4aeab33f6f 100644 --- a/src/OpenFOAM/db/objectRegistry/objectRegistry.C +++ b/src/OpenFOAM/db/objectRegistry/objectRegistry.C @@ -518,7 +518,7 @@ bool Foam::objectRegistry::writeObject << " to file " << obj.objectRelPath() << endl; } - if (iter.val()->writeOpt() != NO_WRITE) + if (iter.val()->writeOpt() != IOobjectOption::NO_WRITE) { ok = iter.val()->writeObject(streamOpt, valid) && ok; } diff --git a/src/OpenFOAM/db/regIOobject/regIOobject.H b/src/OpenFOAM/db/regIOobject/regIOobject.H index cb0dff3f56..f7060a5e7b 100644 --- a/src/OpenFOAM/db/regIOobject/regIOobject.H +++ b/src/OpenFOAM/db/regIOobject/regIOobject.H @@ -377,9 +377,12 @@ public: ( IOstreamOption::streamFormat fmt, IOstreamOption::versionNumber ver, - IOstreamOption::compressionType comp, + IOstreamOption::compressionType cmp, const bool valid - ) const; + ) const + { + return writeObject(IOstreamOption(fmt, ver, cmp), valid); + } }; diff --git a/src/OpenFOAM/db/regIOobject/regIOobjectRead.C b/src/OpenFOAM/db/regIOobject/regIOobjectRead.C index 7ec6bbd2a0..56c94bc2f5 100644 --- a/src/OpenFOAM/db/regIOobject/regIOobjectRead.C +++ b/src/OpenFOAM/db/regIOobject/regIOobjectRead.C @@ -54,7 +54,7 @@ bool Foam::regIOobject::readHeaderOk // Check if header is ok for READ_IF_PRESENT bool isHeaderOk = false; - if (readOpt() == IOobject::READ_IF_PRESENT) + if (isReadOptional()) { if (masterOnly) { @@ -70,14 +70,7 @@ bool Foam::regIOobject::readHeaderOk } } - if - ( - ( - readOpt() == IOobject::MUST_READ - || readOpt() == IOobject::MUST_READ_IF_MODIFIED - ) - || isHeaderOk - ) + if (isReadRequired() || isHeaderOk) { return fileHandler().read(*this, masterOnly, fmt, typeName); } @@ -90,7 +83,7 @@ bool Foam::regIOobject::readHeaderOk void Foam::regIOobject::readStream(const bool valid) { - if (readOpt() == NO_READ) + if (readOpt() == IOobject::NO_READ) { FatalErrorInFunction << "NO_READ specified for read-constructor of object " << name() diff --git a/src/OpenFOAM/db/regIOobject/regIOobjectWrite.C b/src/OpenFOAM/db/regIOobject/regIOobjectWrite.C index 95ac8e84c8..42864ee98a 100644 --- a/src/OpenFOAM/db/regIOobject/regIOobjectWrite.C +++ b/src/OpenFOAM/db/regIOobject/regIOobjectWrite.C @@ -141,16 +141,4 @@ bool Foam::regIOobject::write(const bool valid) const } -bool Foam::regIOobject::writeObject -( - IOstreamOption::streamFormat fmt, - IOstreamOption::versionNumber ver, - IOstreamOption::compressionType cmp, - const bool valid -) const -{ - return writeObject(IOstreamOption(fmt, ver, cmp), valid); -} - - // ************************************************************************* // diff --git a/src/OpenFOAM/fields/DimensionedFields/DimensionedField/DimensionedFieldIO.C b/src/OpenFOAM/fields/DimensionedFields/DimensionedField/DimensionedFieldIO.C index 6dd9e2560c..0f27a6fb1d 100644 --- a/src/OpenFOAM/fields/DimensionedFields/DimensionedField/DimensionedFieldIO.C +++ b/src/OpenFOAM/fields/DimensionedFields/DimensionedField/DimensionedFieldIO.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2017-2021 OpenCFD Ltd. + Copyright (C) 2017-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -60,12 +60,7 @@ void Foam::DimensionedField::readIfPresent const word& fieldDictEntry ) { - if - ( - (this->readOpt() == IOobject::READ_IF_PRESENT && this->headerOk()) - || this->readOpt() == IOobject::MUST_READ - || this->readOpt() == IOobject::MUST_READ_IF_MODIFIED - ) + if (this->isReadRequired() || (this->isReadOptional() && this->headerOk())) { readField(dictionary(readStream(typeName)), fieldDictEntry); } diff --git a/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.C b/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.C index aed30fbe20..1ac929c4f4 100644 --- a/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.C +++ b/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.C @@ -99,11 +99,7 @@ void Foam::GeometricField::readFields() template class PatchField, class GeoMesh> bool Foam::GeometricField::readIfPresent() { - if - ( - this->readOpt() == IOobject::MUST_READ - || this->readOpt() == IOobject::MUST_READ_IF_MODIFIED - ) + if (this->isReadRequired()) { WarningInFunction << "read option IOobject::MUST_READ or MUST_READ_IF_MODIFIED" @@ -112,7 +108,7 @@ bool Foam::GeometricField::readIfPresent() } else if ( - this->readOpt() == IOobject::READ_IF_PRESENT + this->isReadOptional() && this->template typeHeaderOk> ( true diff --git a/src/OpenFOAM/global/fileOperations/fileOperation/fileOperation.C b/src/OpenFOAM/global/fileOperations/fileOperation/fileOperation.C index f8af19d9da..2c580b8ab9 100644 --- a/src/OpenFOAM/global/fileOperations/fileOperation/fileOperation.C +++ b/src/OpenFOAM/global/fileOperations/fileOperation/fileOperation.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2017-2018 OpenFOAM Foundation - Copyright (C) 2019-2021 OpenCFD Ltd. + Copyright (C) 2019-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -1025,11 +1025,7 @@ Foam::IOobject Foam::fileOperation::findInstance } // Handling failures afterwards - const bool exitIfMissing - ( - startIO.readOpt() == IOobject::MUST_READ - || startIO.readOpt() == IOobject::MUST_READ_IF_MODIFIED - ); + const bool exitIfMissing = startIO.isReadRequired(); enum failureCodes { FAILED_STOPINST = 1, FAILED_CONSTINST = 2 }; int failed(0); diff --git a/src/OpenFOAM/global/fileOperations/masterUncollatedFileOperation/masterUncollatedFileOperation.C b/src/OpenFOAM/global/fileOperations/masterUncollatedFileOperation/masterUncollatedFileOperation.C index d189af6e92..d0cf1f6620 100644 --- a/src/OpenFOAM/global/fileOperations/masterUncollatedFileOperation/masterUncollatedFileOperation.C +++ b/src/OpenFOAM/global/fileOperations/masterUncollatedFileOperation/masterUncollatedFileOperation.C @@ -1485,11 +1485,7 @@ Foam::fileOperations::masterUncollatedFileOperation::findInstance // Handling failures afterwards - const bool exitIfMissing - ( - startIO.readOpt() == IOobject::MUST_READ - || startIO.readOpt() == IOobject::MUST_READ_IF_MODIFIED - ); + const bool exitIfMissing = startIO.isReadRequired(); enum failureCodes { FAILED_STOPINST = 1, FAILED_CONSTINST = 2 }; int failed(0); diff --git a/src/OpenFOAM/matrices/schemes/schemesLookup.C b/src/OpenFOAM/matrices/schemes/schemesLookup.C index 2ad72c04a5..1695b23b62 100644 --- a/src/OpenFOAM/matrices/schemes/schemesLookup.C +++ b/src/OpenFOAM/matrices/schemes/schemesLookup.C @@ -107,7 +107,7 @@ void Foam::schemesLookup::read(const dictionary& dict) Foam::schemesLookup::schemesLookup ( const objectRegistry& obr, - const IOobject::readOption rOpt, + IOobjectOption::readOption rOpt, const word& dictName, const dictionary* fallback ) @@ -144,7 +144,7 @@ Foam::schemesLookup::schemesLookup if ( readOpt() == IOobject::MUST_READ - || (readOpt() == IOobject::READ_IF_PRESENT && headerOk()) + || (isReadOptional() && headerOk()) ) { readOpt(IOobject::MUST_READ_IF_MODIFIED); diff --git a/src/OpenFOAM/matrices/schemes/schemesLookup.H b/src/OpenFOAM/matrices/schemes/schemesLookup.H index 57f152c485..68473daea5 100644 --- a/src/OpenFOAM/matrices/schemes/schemesLookup.H +++ b/src/OpenFOAM/matrices/schemes/schemesLookup.H @@ -173,7 +173,7 @@ public: schemesLookup ( const objectRegistry& obr, - const IOobject::readOption rOpt, + IOobjectOption::readOption rOpt, const word& dictName, const dictionary* fallback = nullptr ); diff --git a/src/OpenFOAM/matrices/solution/solution.C b/src/OpenFOAM/matrices/solution/solution.C index d9265a5f5e..cad46df74c 100644 --- a/src/OpenFOAM/matrices/solution/solution.C +++ b/src/OpenFOAM/matrices/solution/solution.C @@ -147,7 +147,7 @@ void Foam::solution::read(const dictionary& dict) Foam::solution::solution ( const objectRegistry& obr, - const IOobject::readOption rOpt, + IOobjectOption::readOption rOpt, const fileName& dictName, const dictionary* fallback ) @@ -174,7 +174,7 @@ Foam::solution::solution if ( readOpt() == IOobject::MUST_READ - || (readOpt() == IOobject::READ_IF_PRESENT && headerOk()) + || (isReadOptional() && headerOk()) ) { readOpt(IOobject::MUST_READ_IF_MODIFIED); diff --git a/src/OpenFOAM/matrices/solution/solution.H b/src/OpenFOAM/matrices/solution/solution.H index f7a2da7ea7..65730fb8fb 100644 --- a/src/OpenFOAM/matrices/solution/solution.H +++ b/src/OpenFOAM/matrices/solution/solution.H @@ -124,7 +124,7 @@ public: solution ( const objectRegistry& obr, - const IOobject::readOption rOpt, + IOobjectOption::readOption rOpt, const fileName& dictName, const dictionary* fallback = nullptr ); diff --git a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/IOmapDistribute.C b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/IOmapDistribute.C index 98b4686a93..de98bcf879 100644 --- a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/IOmapDistribute.C +++ b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/IOmapDistribute.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2014-2015 OpenFOAM Foundation - Copyright (C) 2015-2018 OpenCFD Ltd. + Copyright (C) 2015-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -40,14 +40,7 @@ namespace Foam bool Foam::IOmapDistribute::readContents() { - if - ( - ( - readOpt() == IOobject::MUST_READ - || readOpt() == IOobject::MUST_READ_IF_MODIFIED - ) - || (readOpt() == IOobject::READ_IF_PRESENT && headerOk()) - ) + if (isReadRequired() || (isReadOptional() && headerOk())) { readStream(typeName) >> *this; close(); diff --git a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/IOmapDistributePolyMesh.C b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/IOmapDistributePolyMesh.C index ab1b4be762..d4dd4c6f07 100644 --- a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/IOmapDistributePolyMesh.C +++ b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/IOmapDistributePolyMesh.C @@ -40,14 +40,7 @@ namespace Foam bool Foam::IOmapDistributePolyMesh::readContents() { - if - ( - ( - readOpt() == IOobject::MUST_READ - || readOpt() == IOobject::MUST_READ_IF_MODIFIED - ) - || (readOpt() == IOobject::READ_IF_PRESENT && headerOk()) - ) + if (isReadRequired() || (isReadOptional() && headerOk())) { readStream(typeName) >> *this; close(); diff --git a/src/OpenFOAM/meshes/polyMesh/polyBoundaryMesh/polyBoundaryMesh.C b/src/OpenFOAM/meshes/polyMesh/polyBoundaryMesh/polyBoundaryMesh.C index 4112a015bf..ba934b81c6 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyBoundaryMesh/polyBoundaryMesh.C +++ b/src/OpenFOAM/meshes/polyMesh/polyBoundaryMesh/polyBoundaryMesh.C @@ -111,13 +111,8 @@ bool Foam::polyBoundaryMesh::readContents(const bool allowReadIfPresent) { if ( - this->readOpt() == IOobject::MUST_READ - || this->readOpt() == IOobject::MUST_READ_IF_MODIFIED - || - ( - allowReadIfPresent - && (this->readOpt() == IOobject::READ_IF_PRESENT && this->headerOk()) - ) + this->isReadRequired() + || (allowReadIfPresent && this->isReadOptional() && this->headerOk()) ) { // Warn for MUST_READ_IF_MODIFIED diff --git a/src/OpenFOAM/meshes/polyMesh/polyBoundaryMesh/polyBoundaryMeshEntries.H b/src/OpenFOAM/meshes/polyMesh/polyBoundaryMesh/polyBoundaryMeshEntries.H index 4b89aa41b7..aa2f97635a 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyBoundaryMesh/polyBoundaryMeshEntries.H +++ b/src/OpenFOAM/meshes/polyMesh/polyBoundaryMesh/polyBoundaryMeshEntries.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2015 OpenFOAM Foundation - Copyright (C) 2020 OpenCFD Ltd. + Copyright (C) 2020-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -35,8 +35,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef polyBoundaryMeshEntries_H -#define polyBoundaryMeshEntries_H +#ifndef Foam_polyBoundaryMeshEntries_H +#define Foam_polyBoundaryMeshEntries_H #include "regIOobject.H" #include "PtrList.H" @@ -69,14 +69,7 @@ public: regIOobject(io), PtrList() { - if - ( - ( - io.readOpt() == IOobject::MUST_READ - || io.readOpt() == IOobject::MUST_READ_IF_MODIFIED - ) - || (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk()) - ) + if (isReadRequired() || (isReadOptional() && headerOk())) { readStream(typeName) >> *this; } diff --git a/src/OpenFOAM/meshes/polyMesh/polyMesh.H b/src/OpenFOAM/meshes/polyMesh/polyMesh.H index de0134d5ab..46210bb085 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyMesh.H +++ b/src/OpenFOAM/meshes/polyMesh/polyMesh.H @@ -414,7 +414,7 @@ public: void setInstance ( const fileName& instance, - const IOobject::writeOption wOpt = IOobject::AUTO_WRITE + const IOobjectOption::writeOption wOpt = IOobject::AUTO_WRITE ); diff --git a/src/OpenFOAM/meshes/polyMesh/polyMeshIO.C b/src/OpenFOAM/meshes/polyMesh/polyMeshIO.C index 6cc2ab9ac3..fc6df40fc2 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyMeshIO.C +++ b/src/OpenFOAM/meshes/polyMesh/polyMeshIO.C @@ -35,7 +35,7 @@ License void Foam::polyMesh::setInstance ( const fileName& inst, - const IOobject::writeOption wOpt + const IOobjectOption::writeOption wOpt ) { DebugInFunction << "Resetting file instance to " << inst << endl; diff --git a/src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/ZoneMesh.C b/src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/ZoneMesh.C index e0d75e7e69..8ddc5dae04 100644 --- a/src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/ZoneMesh.C +++ b/src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/ZoneMesh.C @@ -155,12 +155,7 @@ void Foam::ZoneMesh::calcGroupIDs() const template bool Foam::ZoneMesh::readContents() { - if - ( - readOpt() == IOobject::MUST_READ - || readOpt() == IOobject::MUST_READ_IF_MODIFIED - || (readOpt() == IOobject::READ_IF_PRESENT && headerOk()) - ) + if (isReadRequired() || (isReadOptional() && headerOk())) { // Warn for MUST_READ_IF_MODIFIED warnNoRereading>(); diff --git a/src/OpenFOAM/primitives/coordinate/systems/coordinateSystems.C b/src/OpenFOAM/primitives/coordinate/systems/coordinateSystems.C index 2188ae4d67..296f9aae28 100644 --- a/src/OpenFOAM/primitives/coordinate/systems/coordinateSystems.C +++ b/src/OpenFOAM/primitives/coordinate/systems/coordinateSystems.C @@ -88,14 +88,7 @@ void Foam::coordinateSystems::readFromStream(const bool valid) bool Foam::coordinateSystems::readContents() { - if - ( - ( - readOpt() == IOobject::MUST_READ - || readOpt() == IOobject::MUST_READ_IF_MODIFIED - ) - || (readOpt() == IOobject::READ_IF_PRESENT && headerOk()) - ) + if (isReadRequired() || (isReadOptional() && headerOk())) { readFromStream(); return true; diff --git a/src/dynamicMesh/polyTopoChange/polyTopoChange/hexRef8/refinementHistory.C b/src/dynamicMesh/polyTopoChange/polyTopoChange/hexRef8/refinementHistory.C index 93a78cd277..981ed540ba 100644 --- a/src/dynamicMesh/polyTopoChange/polyTopoChange/hexRef8/refinementHistory.C +++ b/src/dynamicMesh/polyTopoChange/polyTopoChange/hexRef8/refinementHistory.C @@ -45,12 +45,7 @@ namespace Foam bool Foam::refinementHistory::readContents() { - if - ( - readOpt() == IOobject::MUST_READ - || readOpt() == IOobject::MUST_READ_IF_MODIFIED - || (readOpt() == IOobject::READ_IF_PRESENT && headerOk()) - ) + if (isReadRequired() || (isReadOptional() && headerOk())) { readStream(typeName) >> *this; close(); @@ -740,16 +735,11 @@ Foam::refinementHistory::refinementHistory regIOobject(io), active_(false) { - if - ( - io.readOpt() == IOobject::MUST_READ - || io.readOpt() == IOobject::MUST_READ_IF_MODIFIED - || (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk()) - ) + if (io.readOpt() != IOobject::NO_READ) { WarningInFunction - << "read option IOobject::MUST_READ, READ_IF_PRESENT or " - << "MUST_READ_IF_MODIFIED" + << "read option IOobject::MUST_READ or READ_IF_PRESENT " + << "or MUST_READ_IF_MODIFIED" << " suggests that a read constructor would be more appropriate." << endl; } diff --git a/src/dynamicMesh/polyTopoChange/polyTopoChanger/polyTopoChanger.C b/src/dynamicMesh/polyTopoChange/polyTopoChanger/polyTopoChanger.C index 2bd56c078d..a7e671f55f 100644 --- a/src/dynamicMesh/polyTopoChange/polyTopoChanger/polyTopoChanger.C +++ b/src/dynamicMesh/polyTopoChange/polyTopoChanger/polyTopoChanger.C @@ -44,12 +44,7 @@ namespace Foam bool Foam::polyTopoChanger::readContents() { - if - ( - readOpt() == IOobject::MUST_READ - || readOpt() == IOobject::MUST_READ_IF_MODIFIED - || (readOpt() == IOobject::READ_IF_PRESENT && headerOk()) - ) + if (isReadRequired() || (isReadOptional() && headerOk())) { PtrList& modifiers = *this; @@ -105,7 +100,7 @@ Foam::polyTopoChanger::polyTopoChanger Foam::polyTopoChanger::polyTopoChanger ( polyMesh& mesh, - const IOobject::readOption rOpt + IOobjectOption::readOption rOpt ) : @@ -137,7 +132,7 @@ Foam::polyTopoChanger::polyTopoChanger Foam::polyTopoChanger::polyTopoChanger(polyMesh& mesh) : - polyTopoChanger(mesh, IOobject::readOption::READ_IF_PRESENT) + polyTopoChanger(mesh, IOobjectOption::READ_IF_PRESENT) {} diff --git a/src/dynamicMesh/polyTopoChange/polyTopoChanger/polyTopoChanger.H b/src/dynamicMesh/polyTopoChange/polyTopoChanger/polyTopoChanger.H index a779157117..8ed5efdda1 100644 --- a/src/dynamicMesh/polyTopoChange/polyTopoChanger/polyTopoChanger.H +++ b/src/dynamicMesh/polyTopoChange/polyTopoChanger/polyTopoChanger.H @@ -96,7 +96,7 @@ public: polyTopoChanger(const IOobject& io, polyMesh& mesh); //- Read construct for given polyMesh and read-option - polyTopoChanger(polyMesh& mesh, const IOobject::readOption rOpt); + polyTopoChanger(polyMesh& mesh, IOobjectOption::readOption rOpt); //- Read construct for given polyMesh. // Uses read-option READ_IF_PRESENT diff --git a/src/finiteArea/faMesh/faBoundaryMesh/faBoundaryMesh.C b/src/finiteArea/faMesh/faBoundaryMesh/faBoundaryMesh.C index df80a98e6d..a93ec4adfc 100644 --- a/src/finiteArea/faMesh/faBoundaryMesh/faBoundaryMesh.C +++ b/src/finiteArea/faMesh/faBoundaryMesh/faBoundaryMesh.C @@ -106,13 +106,8 @@ bool Foam::faBoundaryMesh::readContents(const bool allowReadIfPresent) { if ( - readOpt() == IOobject::MUST_READ - || readOpt() == IOobject::MUST_READ_IF_MODIFIED - || - ( - allowReadIfPresent - && (readOpt() == IOobject::READ_IF_PRESENT && headerOk()) - ) + isReadRequired() + || (allowReadIfPresent && isReadOptional() && headerOk()) ) { // Warn for MUST_READ_IF_MODIFIED diff --git a/src/finiteArea/faMesh/faBoundaryMesh/faBoundaryMeshEntries.H b/src/finiteArea/faMesh/faBoundaryMesh/faBoundaryMeshEntries.H index 9059813c2b..a8f954b551 100644 --- a/src/finiteArea/faMesh/faBoundaryMesh/faBoundaryMeshEntries.H +++ b/src/finiteArea/faMesh/faBoundaryMesh/faBoundaryMeshEntries.H @@ -69,14 +69,7 @@ public: regIOobject(io), PtrList() { - if - ( - ( - io.readOpt() == IOobject::MUST_READ - || io.readOpt() == IOobject::MUST_READ_IF_MODIFIED - ) - || (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk()) - ) + if (isReadRequired() || (isReadOptional() && headerOk())) { readStream(typeName) >> *this; } diff --git a/src/finiteArea/faSolution/faSolution.H b/src/finiteArea/faSolution/faSolution.H index 8e4ffa3802..3320150cfb 100644 --- a/src/finiteArea/faSolution/faSolution.H +++ b/src/finiteArea/faSolution/faSolution.H @@ -74,7 +74,7 @@ public: faSolution ( const objectRegistry& obr, - const IOobject::readOption rOpt, + IOobjectOption::readOption rOpt, const word& dictName, const dictionary* fallback = nullptr ) @@ -99,7 +99,7 @@ public: faSolution ( const objectRegistry& obr, - const IOobject::readOption rOpt, + IOobjectOption::readOption rOpt, const dictionary* fallback = nullptr ) : diff --git a/src/finiteArea/finiteArea/faSchemes/faSchemes.H b/src/finiteArea/finiteArea/faSchemes/faSchemes.H index b714b0f7de..3c2b345e8e 100644 --- a/src/finiteArea/finiteArea/faSchemes/faSchemes.H +++ b/src/finiteArea/finiteArea/faSchemes/faSchemes.H @@ -74,7 +74,7 @@ public: faSchemes ( const objectRegistry& obr, - const IOobject::readOption rOpt, + IOobjectOption::readOption rOpt, const word& dictName, const dictionary* fallback = nullptr ) @@ -99,7 +99,7 @@ public: faSchemes ( const objectRegistry& obr, - const IOobject::readOption rOpt, + IOobjectOption::readOption rOpt, const dictionary* fallback = nullptr ) : diff --git a/src/finiteVolume/finiteVolume/fvSchemes/fvSchemes.H b/src/finiteVolume/finiteVolume/fvSchemes/fvSchemes.H index f0307a295e..a1d8bb401a 100644 --- a/src/finiteVolume/finiteVolume/fvSchemes/fvSchemes.H +++ b/src/finiteVolume/finiteVolume/fvSchemes/fvSchemes.H @@ -74,7 +74,7 @@ public: fvSchemes ( const objectRegistry& obr, - const IOobject::readOption rOpt, + IOobjectOption::readOption rOpt, const word& dictName, const dictionary* fallback = nullptr ) @@ -99,7 +99,7 @@ public: fvSchemes ( const objectRegistry& obr, - const IOobject::readOption rOpt, + IOobjectOption::readOption rOpt, const dictionary* fallback = nullptr ) : diff --git a/src/finiteVolume/finiteVolume/fvSolution/fvSolution.H b/src/finiteVolume/finiteVolume/fvSolution/fvSolution.H index 14d93970a8..f41ea679f5 100644 --- a/src/finiteVolume/finiteVolume/fvSolution/fvSolution.H +++ b/src/finiteVolume/finiteVolume/fvSolution/fvSolution.H @@ -74,7 +74,7 @@ public: fvSolution ( const objectRegistry& obr, - const IOobject::readOption rOpt, + IOobjectOption::readOption rOpt, const word& dictName, const dictionary* fallback = nullptr ) @@ -100,7 +100,7 @@ public: fvSolution ( const objectRegistry& obr, - const IOobject::readOption rOpt, + IOobjectOption::readOption rOpt, const dictionary* fallback = nullptr ) : diff --git a/src/functionObjects/utilities/writeObjects/writeObjects.C b/src/functionObjects/utilities/writeObjects/writeObjects.C index e0a3d83cab..4d796125d8 100644 --- a/src/functionObjects/utilities/writeObjects/writeObjects.C +++ b/src/functionObjects/utilities/writeObjects/writeObjects.C @@ -55,8 +55,8 @@ const Foam::Enum > Foam::functionObjects::writeObjects::writeOptionNames_ ({ - { writeOption::AUTO_WRITE, "autoWrite" }, { writeOption::NO_WRITE, "noWrite" }, + { writeOption::AUTO_WRITE, "autoWrite" }, { writeOption::ANY_WRITE, "anyWrite" }, }); @@ -173,16 +173,7 @@ bool Foam::functionObjects::writeObjects::write() switch (writeOption_) { - case AUTO_WRITE: - { - if (obj.writeOpt() != IOobject::AUTO_WRITE) - { - continue; - } - - break; - } - case NO_WRITE: + case writeOption::NO_WRITE: { if (obj.writeOpt() != IOobject::NO_WRITE) { @@ -191,7 +182,16 @@ bool Foam::functionObjects::writeObjects::write() break; } - case ANY_WRITE: + case writeOption::AUTO_WRITE: + { + if (obj.writeOpt() != IOobject::AUTO_WRITE) + { + continue; + } + + break; + } + case writeOption::ANY_WRITE: { break; } diff --git a/src/functionObjects/utilities/writeObjects/writeObjects.H b/src/functionObjects/utilities/writeObjects/writeObjects.H index a8edb47ca5..6198eb8827 100644 --- a/src/functionObjects/utilities/writeObjects/writeObjects.H +++ b/src/functionObjects/utilities/writeObjects/writeObjects.H @@ -83,8 +83,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef functionObjects_writeObjects_H -#define functionObjects_writeObjects_H +#ifndef Foam_functionObjects_writeObjects_H +#define Foam_functionObjects_writeObjects_H #include "functionObject.H" #include "wordRes.H" @@ -111,14 +111,14 @@ class writeObjects { public: - // Public data types + // Public Data Types - //- Re-enumeration defining the write options, based on the original - // ones at IOobject::writeOption + //- Re-enumeration defining the write options, + //- Naming based on the IOobjectOption::writeOption enum writeOption { - AUTO_WRITE, NO_WRITE, + AUTO_WRITE, ANY_WRITE }; @@ -126,7 +126,7 @@ public: private: - // Private data + // Private Data //- Reference to registry const objectRegistry& obr_; diff --git a/src/lagrangian/basic/Cloud/Cloud.H b/src/lagrangian/basic/Cloud/Cloud.H index dd448fcd7a..5a92cc0320 100644 --- a/src/lagrangian/basic/Cloud/Cloud.H +++ b/src/lagrangian/basic/Cloud/Cloud.H @@ -222,7 +222,7 @@ public: IOobject fieldIOobject ( const word& fieldName, - const IOobject::readOption r + IOobjectOption::readOption rOpt ) const; //- Check lagrangian data field diff --git a/src/lagrangian/basic/Cloud/CloudIO.C b/src/lagrangian/basic/Cloud/CloudIO.C index 30190ac688..993fef90f1 100644 --- a/src/lagrangian/basic/Cloud/CloudIO.C +++ b/src/lagrangian/basic/Cloud/CloudIO.C @@ -190,7 +190,7 @@ template Foam::IOobject Foam::Cloud::fieldIOobject ( const word& fieldName, - const IOobject::readOption r + IOobjectOption::readOption rOpt ) const { return IOobject @@ -198,7 +198,7 @@ Foam::IOobject Foam::Cloud::fieldIOobject fieldName, time().timeName(), *this, - r, + rOpt, IOobject::NO_WRITE, false ); diff --git a/src/lumpedPointMotion/movement/lumpedPointIOMovement.C b/src/lumpedPointMotion/movement/lumpedPointIOMovement.C index 786d987394..4ab2ec39c6 100644 --- a/src/lumpedPointMotion/movement/lumpedPointIOMovement.C +++ b/src/lumpedPointMotion/movement/lumpedPointIOMovement.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2016-2020 OpenCFD Ltd. + Copyright (C) 2016-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -82,15 +82,9 @@ Foam::lumpedPointIOMovement::lumpedPointIOMovement lumpedPointMovement(), regIOobject(io) { - bool ok = - ( - readOpt() == IOobject::MUST_READ - || readOpt() == IOobject::MUST_READ_IF_MODIFIED - ); - - if (ok) + if (isReadRequired()) { - ok = readData(readStream(typeName)); + bool ok = readData(readStream(typeName)); close(); if (ok) diff --git a/src/meshTools/edgeMesh/extendedFeatureEdgeMesh/extendedFeatureEdgeMesh.C b/src/meshTools/edgeMesh/extendedFeatureEdgeMesh/extendedFeatureEdgeMesh.C index b51de2697b..377a69140a 100644 --- a/src/meshTools/edgeMesh/extendedFeatureEdgeMesh/extendedFeatureEdgeMesh.C +++ b/src/meshTools/edgeMesh/extendedFeatureEdgeMesh/extendedFeatureEdgeMesh.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation - Copyright (C) 2020 OpenCFD Ltd. + Copyright (C) 2020-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -43,12 +43,7 @@ Foam::extendedFeatureEdgeMesh::extendedFeatureEdgeMesh(const IOobject& io) regIOobject(io), extendedEdgeMesh() { - if - ( - io.readOpt() == IOobject::MUST_READ - || io.readOpt() == IOobject::MUST_READ_IF_MODIFIED - || (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk()) - ) + if (isReadRequired() || (isReadOptional() && headerOk())) { // Warn for MUST_READ_IF_MODIFIED warnNoRereading(); diff --git a/src/meshTools/edgeMesh/featureEdgeMesh/featureEdgeMesh.C b/src/meshTools/edgeMesh/featureEdgeMesh/featureEdgeMesh.C index 9878115b97..c7caba1299 100644 --- a/src/meshTools/edgeMesh/featureEdgeMesh/featureEdgeMesh.C +++ b/src/meshTools/edgeMesh/featureEdgeMesh/featureEdgeMesh.C @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation + Copyright (C) 2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -42,12 +43,7 @@ Foam::featureEdgeMesh::featureEdgeMesh(const IOobject& io) regIOobject(io), edgeMesh() { - if - ( - io.readOpt() == IOobject::MUST_READ - || io.readOpt() == IOobject::MUST_READ_IF_MODIFIED - || (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk()) - ) + if (isReadRequired() || (isReadOptional() && headerOk())) { readStream(typeName) >> *this; close(); diff --git a/src/meshTools/regionModel/regionProperties/regionProperties.C b/src/meshTools/regionModel/regionProperties/regionProperties.C index 55fbf78b04..1f49743ef4 100644 --- a/src/meshTools/regionModel/regionProperties/regionProperties.C +++ b/src/meshTools/regionModel/regionProperties/regionProperties.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2012 OpenFOAM Foundation - Copyright (C) 2018 OpenCFD Ltd. + Copyright (C) 2018-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -41,7 +41,7 @@ Foam::regionProperties::regionProperties(const Time& runTime) Foam::regionProperties::regionProperties ( const Time& runTime, - IOobject::readOption rOpt + IOobjectOption::readOption rOpt ) { HashTable& props = *this; @@ -54,15 +54,11 @@ Foam::regionProperties::regionProperties runTime.time().constant(), runTime.db(), rOpt, - IOobject::NO_WRITE + IOobjectOption::NO_WRITE ) ); - if - ( - (rOpt == IOobject::MUST_READ || rOpt == IOobject::MUST_READ_IF_MODIFIED) - || iodict.size() - ) + if (IOobject::isReadRequired(rOpt) || iodict.size()) { iodict.readEntry("regions", props); } diff --git a/src/meshTools/regionModel/regionProperties/regionProperties.H b/src/meshTools/regionModel/regionProperties/regionProperties.H index 68624f43b5..2f5eb67403 100644 --- a/src/meshTools/regionModel/regionProperties/regionProperties.H +++ b/src/meshTools/regionModel/regionProperties/regionProperties.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2015 OpenFOAM Foundation - Copyright (C) 2018 OpenCFD Ltd. + Copyright (C) 2018-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -39,8 +39,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef regionProperties_H -#define regionProperties_H +#ifndef Foam_regionProperties_H +#define Foam_regionProperties_H #include "HashTable.H" #include "wordList.H" @@ -69,11 +69,11 @@ public: //- Construct from Time explicit regionProperties(const Time& runTime); - //- Construct from Time with specified read options + //- Construct from Time with specified read option regionProperties ( const Time& runTime, - IOobject::readOption rOpt + IOobjectOption::readOption rOpt ); diff --git a/src/meshTools/topoSet/topoSets/cellSet.C b/src/meshTools/topoSet/topoSets/cellSet.C index 72c58b47a1..4e2ca99bc3 100644 --- a/src/meshTools/topoSet/topoSets/cellSet.C +++ b/src/meshTools/topoSet/topoSets/cellSet.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011 OpenFOAM Foundation - Copyright (C) 2016-2018 OpenCFD Ltd. + Copyright (C) 2016-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -47,9 +47,9 @@ addToRunTimeSelectionTable(topoSet, cellSet, set); // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -Foam::cellSet::cellSet(const IOobject& obj) +Foam::cellSet::cellSet(const IOobject& io) : - topoSet(obj, typeName) + topoSet(io, typeName) {} @@ -57,11 +57,11 @@ Foam::cellSet::cellSet ( const polyMesh& mesh, const word& name, - readOption r, - writeOption w + IOobjectOption::readOption rOpt, + IOobjectOption::writeOption wOpt ) : - topoSet(mesh, typeName, name, r, w) + topoSet(mesh, typeName, name, rOpt, wOpt) { // Make sure set within valid range check(mesh.nCells()); @@ -73,10 +73,10 @@ Foam::cellSet::cellSet const polyMesh& mesh, const word& name, const label size, - writeOption w + IOobjectOption::writeOption wOpt ) : - topoSet(mesh, name, size, w) + topoSet(mesh, name, size, wOpt) {} @@ -85,10 +85,10 @@ Foam::cellSet::cellSet const polyMesh& mesh, const word& name, const topoSet& set, - writeOption w + IOobjectOption::writeOption wOpt ) : - topoSet(mesh, name, set, w) + topoSet(mesh, name, set, wOpt) {} @@ -97,10 +97,10 @@ Foam::cellSet::cellSet const polyMesh& mesh, const word& name, const labelHashSet& labels, - writeOption w + IOobjectOption::writeOption wOpt ) : - topoSet(mesh, name, labels, w) + topoSet(mesh, name, labels, wOpt) {} @@ -109,10 +109,10 @@ Foam::cellSet::cellSet const polyMesh& mesh, const word& name, labelHashSet&& labels, - writeOption w + IOobjectOption::writeOption wOpt ) : - topoSet(mesh, name, std::move(labels), w) + topoSet(mesh, name, std::move(labels), wOpt) {} @@ -121,10 +121,10 @@ Foam::cellSet::cellSet const polyMesh& mesh, const word& name, const labelUList& labels, - writeOption w + IOobjectOption::writeOption wOpt ) : - topoSet(mesh, name, labels, w) + topoSet(mesh, name, labels, wOpt) {} @@ -133,13 +133,13 @@ Foam::cellSet::cellSet ( const Time& runTime, const word& name, - readOption r, - writeOption w + IOobjectOption::readOption rOpt, + IOobjectOption::writeOption wOpt ) : topoSet ( - findIOobject(runTime, name, r, w), + findIOobject(runTime, name, rOpt, wOpt), typeName ) {} @@ -150,12 +150,12 @@ Foam::cellSet::cellSet const Time& runTime, const word& name, const label size, - writeOption w + IOobjectOption::writeOption wOpt ) : topoSet ( - findIOobject(runTime, name, IOobject::NO_READ, w), + findIOobject(runTime, name, IOobject::NO_READ, wOpt), size ) {} @@ -166,12 +166,12 @@ Foam::cellSet::cellSet const Time& runTime, const word& name, const labelHashSet& labels, - writeOption w + IOobjectOption::writeOption wOpt ) : topoSet ( - findIOobject(runTime, name, IOobject::NO_READ, w), + findIOobject(runTime, name, IOobject::NO_READ, wOpt), labels ) {} diff --git a/src/meshTools/topoSet/topoSets/cellSet.H b/src/meshTools/topoSet/topoSets/cellSet.H index 3f03edb070..b678b047b0 100644 --- a/src/meshTools/topoSet/topoSets/cellSet.H +++ b/src/meshTools/topoSet/topoSets/cellSet.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011 OpenFOAM Foundation - Copyright (C) 2016-2018 OpenCFD Ltd. + Copyright (C) 2016-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -35,8 +35,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef cellSet_H -#define cellSet_H +#ifndef Foam_cellSet_H +#define Foam_cellSet_H #include "topoSet.H" @@ -68,15 +68,15 @@ public: // Constructors //- Construct from IOobject. No checking. - explicit cellSet(const IOobject& obj); + explicit cellSet(const IOobject& io); //- Construct from polyMesh and name. Checks for valid cell ids. cellSet ( const polyMesh& mesh, const word& name, - readOption r=MUST_READ, - writeOption w=NO_WRITE + IOobjectOption::readOption rOpt = IOobjectOption::MUST_READ, + IOobjectOption::writeOption wOpt = IOobjectOption::NO_WRITE ); //- Construct empty with initial size for labelHashSet @@ -85,7 +85,7 @@ public: const polyMesh& mesh, const word& name, const label size, - writeOption w=NO_WRITE + IOobjectOption::writeOption wOpt = IOobjectOption::NO_WRITE ); //- Construct from existing set @@ -94,7 +94,7 @@ public: const polyMesh& mesh, const word& name, const topoSet& set, - writeOption w=NO_WRITE + IOobjectOption::writeOption wOpt = IOobjectOption::NO_WRITE ); //- Construct (no-read) with copy of labelHashSet @@ -103,7 +103,7 @@ public: const polyMesh& mesh, const word& name, const labelHashSet& labels, - writeOption w=NO_WRITE + IOobjectOption::writeOption wOpt = IOobjectOption::NO_WRITE ); //- Construct (no-read) with moving labelHashSet @@ -112,7 +112,7 @@ public: const polyMesh& mesh, const word& name, labelHashSet&& labels, - writeOption w=NO_WRITE + IOobjectOption::writeOption wOpt = IOobjectOption::NO_WRITE ); //- Construct (no-read) with copy labels @@ -121,7 +121,7 @@ public: const polyMesh& mesh, const word& name, const labelUList& labels, - writeOption w=NO_WRITE + IOobjectOption::writeOption wOpt = IOobjectOption::NO_WRITE ); @@ -132,8 +132,8 @@ public: ( const Time&, const word& name, - readOption r=MUST_READ, - writeOption w=NO_WRITE + IOobjectOption::readOption rOpt = IOobjectOption::MUST_READ, + IOobjectOption::writeOption wOpt = IOobjectOption::NO_WRITE ); //- Construct empty from objectRegistry. @@ -142,7 +142,7 @@ public: const Time&, const word& name, const label size, - writeOption w=NO_WRITE + IOobjectOption::writeOption wOpt = IOobjectOption::NO_WRITE ); //- Construct from labelHashSet @@ -151,7 +151,7 @@ public: const Time&, const word& name, const labelHashSet& labels, - writeOption w=NO_WRITE + IOobjectOption::writeOption wOpt = IOobjectOption::NO_WRITE ); diff --git a/src/meshTools/topoSet/topoSets/cellZoneSet.C b/src/meshTools/topoSet/topoSets/cellZoneSet.C index 1db2ab0215..bc4ef675a0 100644 --- a/src/meshTools/topoSet/topoSets/cellZoneSet.C +++ b/src/meshTools/topoSet/topoSets/cellZoneSet.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation - Copyright (C) 2018-2020 OpenCFD Ltd. + Copyright (C) 2018-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -61,8 +61,8 @@ Foam::cellZoneSet::cellZoneSet ( const polyMesh& mesh, const word& name, - readOption r, - writeOption w + IOobjectOption::readOption rOpt, + IOobjectOption::writeOption wOpt ) : cellSet(mesh, name, 1024), // do not read cellSet @@ -74,9 +74,8 @@ Foam::cellZoneSet::cellZoneSet if ( - (r == IOobject::MUST_READ) - || (r == IOobject::MUST_READ_IF_MODIFIED) - || (r == IOobject::READ_IF_PRESENT && zoneID != -1) + IOobjectOption::isReadRequired(rOpt) + || (IOobjectOption::isReadOptional(rOpt) && zoneID != -1) ) { const cellZone& fz = cellZones[zoneID]; @@ -94,10 +93,10 @@ Foam::cellZoneSet::cellZoneSet const polyMesh& mesh, const word& name, const label size, - writeOption w + IOobjectOption::writeOption wOpt ) : - cellSet(mesh, name, size, w), + cellSet(mesh, name, size, wOpt), mesh_(mesh), addressing_() { @@ -110,10 +109,10 @@ Foam::cellZoneSet::cellZoneSet const polyMesh& mesh, const word& name, const topoSet& set, - writeOption w + IOobjectOption::writeOption wOpt ) : - cellSet(mesh, name, set.size(), w), + cellSet(mesh, name, set.size(), wOpt), mesh_(mesh), addressing_(refCast(set).addressing()) { diff --git a/src/meshTools/topoSet/topoSets/cellZoneSet.H b/src/meshTools/topoSet/topoSets/cellZoneSet.H index cfc0ca64a3..e0f9f8fc08 100644 --- a/src/meshTools/topoSet/topoSets/cellZoneSet.H +++ b/src/meshTools/topoSet/topoSets/cellZoneSet.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation - Copyright (C) 2018-2020 OpenCFD Ltd. + Copyright (C) 2018-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -31,12 +31,12 @@ Description Like cellSet but -reads data from cellZone -updates cellZone when writing. SourceFiles - cellZone.C + cellZoneSet.C \*---------------------------------------------------------------------------*/ -#ifndef cellZoneSet_H -#define cellZoneSet_H +#ifndef Foam_cellZoneSet_H +#define Foam_cellZoneSet_H #include "cellSet.H" @@ -72,8 +72,8 @@ public: ( const polyMesh& mesh, const word& name, - readOption r=MUST_READ, - writeOption w=NO_WRITE + IOobjectOption::readOption rOpt = IOobjectOption::MUST_READ, + IOobjectOption::writeOption wOpt = IOobjectOption::NO_WRITE ); //- Construct from initial size for labelHashSet @@ -82,7 +82,7 @@ public: const polyMesh& mesh, const word& name, const label size, - writeOption w=NO_WRITE + IOobjectOption::writeOption wOpt = IOobjectOption::NO_WRITE ); //- Copy construct from existing set @@ -91,7 +91,7 @@ public: const polyMesh& mesh, const word& name, const topoSet& set, - writeOption w=NO_WRITE + IOobjectOption::writeOption wOpt = IOobjectOption::NO_WRITE ); diff --git a/src/meshTools/topoSet/topoSets/faceSet.C b/src/meshTools/topoSet/topoSets/faceSet.C index 8b2f8be501..053ee10527 100644 --- a/src/meshTools/topoSet/topoSets/faceSet.C +++ b/src/meshTools/topoSet/topoSets/faceSet.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2016-2018 OpenCFD Ltd. + Copyright (C) 2016-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -45,9 +45,9 @@ namespace Foam // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -Foam::faceSet::faceSet(const IOobject& obj) +Foam::faceSet::faceSet(const IOobject& io) : - topoSet(obj, typeName) + topoSet(io, typeName) {} @@ -55,11 +55,11 @@ Foam::faceSet::faceSet ( const polyMesh& mesh, const word& name, - readOption r, - writeOption w + IOobjectOption::readOption rOpt, + IOobjectOption::writeOption wOpt ) : - topoSet(mesh, typeName, name, r, w) + topoSet(mesh, typeName, name, rOpt, wOpt) { check(mesh.nFaces()); } @@ -70,10 +70,10 @@ Foam::faceSet::faceSet const polyMesh& mesh, const word& name, const label size, - writeOption w + IOobjectOption::writeOption wOpt ) : - topoSet(mesh, name, size, w) + topoSet(mesh, name, size, wOpt) {} @@ -82,10 +82,10 @@ Foam::faceSet::faceSet const polyMesh& mesh, const word& name, const topoSet& set, - writeOption w + IOobjectOption::writeOption wOpt ) : - topoSet(mesh, name, set, w) + topoSet(mesh, name, set, wOpt) {} @@ -94,10 +94,10 @@ Foam::faceSet::faceSet const polyMesh& mesh, const word& name, const labelHashSet& labels, - writeOption w + IOobjectOption::writeOption wOpt ) : - topoSet(mesh, name, labels, w) + topoSet(mesh, name, labels, wOpt) {} @@ -106,10 +106,10 @@ Foam::faceSet::faceSet const polyMesh& mesh, const word& name, labelHashSet&& labels, - writeOption w + IOobjectOption::writeOption wOpt ) : - topoSet(mesh, name, std::move(labels), w) + topoSet(mesh, name, std::move(labels), wOpt) {} @@ -118,10 +118,10 @@ Foam::faceSet::faceSet const polyMesh& mesh, const word& name, const labelUList& labels, - writeOption w + IOobjectOption::writeOption wOpt ) : - topoSet(mesh, name, labels, w) + topoSet(mesh, name, labels, wOpt) {} diff --git a/src/meshTools/topoSet/topoSets/faceSet.H b/src/meshTools/topoSet/topoSets/faceSet.H index 5965ed75fb..02f6e940e8 100644 --- a/src/meshTools/topoSet/topoSets/faceSet.H +++ b/src/meshTools/topoSet/topoSets/faceSet.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011 OpenFOAM Foundation - Copyright (C) 2016-2018 OpenCFD Ltd. + Copyright (C) 2016-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -35,8 +35,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef faceSet_H -#define faceSet_H +#ifndef Foam_faceSet_H +#define Foam_faceSet_H #include "topoSet.H" @@ -62,15 +62,15 @@ public: // Constructors //- Construct from IOobject - explicit faceSet(const IOobject& obj); + explicit faceSet(const IOobject& io); //- Construct from objectRegistry and name faceSet ( const polyMesh& mesh, const word& name, - readOption r=MUST_READ, - writeOption w=NO_WRITE + IOobjectOption::readOption rOpt = IOobjectOption::MUST_READ, + IOobjectOption::writeOption wOpt = IOobjectOption::NO_WRITE ); //- Construct empty with initial size for labelHashSet @@ -79,7 +79,7 @@ public: const polyMesh& mesh, const word& name, const label size, - writeOption w=NO_WRITE + IOobjectOption::writeOption wOpt = IOobjectOption::NO_WRITE ); //- Construct from existing set @@ -88,7 +88,7 @@ public: const polyMesh& mesh, const word& name, const topoSet& set, - writeOption w=NO_WRITE + IOobjectOption::writeOption wOpt = IOobjectOption::NO_WRITE ); //- Construct (no-read) with copy of labelHashSet @@ -97,7 +97,7 @@ public: const polyMesh& mesh, const word& name, const labelHashSet& labels, - writeOption w=NO_WRITE + IOobjectOption::writeOption wOpt = IOobjectOption::NO_WRITE ); //- Construct (no-read) with moving labelHashSet @@ -106,7 +106,7 @@ public: const polyMesh& mesh, const word& name, labelHashSet&& labels, - writeOption w=NO_WRITE + IOobjectOption::writeOption wOpt = IOobjectOption::NO_WRITE ); //- Construct (no-read) with copy of labels @@ -115,7 +115,7 @@ public: const polyMesh& mesh, const word& name, const labelUList& labels, - writeOption w=NO_WRITE + IOobjectOption::writeOption wOpt = IOobjectOption::NO_WRITE ); diff --git a/src/meshTools/topoSet/topoSets/faceZoneSet.C b/src/meshTools/topoSet/topoSets/faceZoneSet.C index 94dae8b702..d44b4f3695 100644 --- a/src/meshTools/topoSet/topoSets/faceZoneSet.C +++ b/src/meshTools/topoSet/topoSets/faceZoneSet.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation - Copyright (C) 2018-2020 OpenCFD Ltd. + Copyright (C) 2018-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -66,8 +66,8 @@ Foam::faceZoneSet::faceZoneSet ( const polyMesh& mesh, const word& name, - readOption r, - writeOption w + IOobjectOption::readOption rOpt, + IOobjectOption::writeOption wOpt ) : faceSet(mesh, name, 1024), // do not read faceSet @@ -80,9 +80,8 @@ Foam::faceZoneSet::faceZoneSet if ( - (r == IOobject::MUST_READ) - || (r == IOobject::MUST_READ_IF_MODIFIED) - || (r == IOobject::READ_IF_PRESENT && zoneID != -1) + IOobjectOption::isReadRequired(rOpt) + || (IOobjectOption::isReadOptional(rOpt) && zoneID != -1) ) { const faceZone& fz = faceZones[zoneID]; @@ -101,10 +100,10 @@ Foam::faceZoneSet::faceZoneSet const polyMesh& mesh, const word& name, const label size, - writeOption w + IOobjectOption::writeOption wOpt ) : - faceSet(mesh, name, size, w), + faceSet(mesh, name, size, wOpt), mesh_(mesh), addressing_(), flipMap_() @@ -118,10 +117,10 @@ Foam::faceZoneSet::faceZoneSet const polyMesh& mesh, const word& name, const topoSet& set, - writeOption w + IOobjectOption::writeOption wOpt ) : - faceSet(mesh, name, set.size(), w), + faceSet(mesh, name, set.size(), wOpt), mesh_(mesh), addressing_(refCast(set).addressing()), flipMap_(refCast(set).flipMap()) diff --git a/src/meshTools/topoSet/topoSets/faceZoneSet.H b/src/meshTools/topoSet/topoSets/faceZoneSet.H index 8e3ffd2e7f..cfdf54e30d 100644 --- a/src/meshTools/topoSet/topoSets/faceZoneSet.H +++ b/src/meshTools/topoSet/topoSets/faceZoneSet.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation - Copyright (C) 2018-2020 OpenCFD Ltd. + Copyright (C) 2018-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -31,12 +31,12 @@ Description Like faceSet but -reads data from faceZone -updates faceZone when writing. SourceFiles - faceZone.C + faceZoneSet.C \*---------------------------------------------------------------------------*/ -#ifndef faceZoneSet_H -#define faceZoneSet_H +#ifndef Foam_faceZoneSet_H +#define Foam_faceZoneSet_H #include "faceSet.H" @@ -75,8 +75,8 @@ public: ( const polyMesh& mesh, const word& name, - readOption r=MUST_READ, - writeOption w=NO_WRITE + IOobjectOption::readOption rOpt = IOobjectOption::MUST_READ, + IOobjectOption::writeOption wOpt = IOobjectOption::NO_WRITE ); //- Construct with initial size for labelHashSet @@ -85,7 +85,7 @@ public: const polyMesh& mesh, const word& name, const label size, - writeOption w=NO_WRITE + IOobjectOption::writeOption wOpt = IOobjectOption::NO_WRITE ); //- Copy construct from existing set @@ -94,7 +94,7 @@ public: const polyMesh& mesh, const word& name, const topoSet& set, - writeOption w=NO_WRITE + IOobjectOption::writeOption wOpt = IOobjectOption::NO_WRITE ); diff --git a/src/meshTools/topoSet/topoSets/pointSet.C b/src/meshTools/topoSet/topoSets/pointSet.C index fe5369a0cf..68e3b87e44 100644 --- a/src/meshTools/topoSet/topoSets/pointSet.C +++ b/src/meshTools/topoSet/topoSets/pointSet.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2016-2018 OpenCFD Ltd. + Copyright (C) 2016-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -45,9 +45,9 @@ namespace Foam // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -Foam::pointSet::pointSet(const IOobject& obj) +Foam::pointSet::pointSet(const IOobject& io) : - topoSet(obj, typeName) + topoSet(io, typeName) {} @@ -55,11 +55,11 @@ Foam::pointSet::pointSet ( const polyMesh& mesh, const word& name, - readOption r, - writeOption w + IOobjectOption::readOption rOpt, + IOobjectOption::writeOption wOpt ) : - topoSet(mesh, typeName, name, r, w) + topoSet(mesh, typeName, name, rOpt, wOpt) { check(mesh.nPoints()); } @@ -70,10 +70,10 @@ Foam::pointSet::pointSet const polyMesh& mesh, const word& name, const label size, - writeOption w + IOobjectOption::writeOption wOpt ) : - topoSet(mesh, name, size, w) + topoSet(mesh, name, size, wOpt) {} @@ -82,10 +82,10 @@ Foam::pointSet::pointSet const polyMesh& mesh, const word& name, const topoSet& set, - writeOption w + IOobjectOption::writeOption wOpt ) : - topoSet(mesh, name, set, w) + topoSet(mesh, name, set, wOpt) {} @@ -94,10 +94,10 @@ Foam::pointSet::pointSet const polyMesh& mesh, const word& name, const labelHashSet& labels, - writeOption w + IOobjectOption::writeOption wOpt ) : - topoSet(mesh, name, labels, w) + topoSet(mesh, name, labels, wOpt) {} @@ -106,10 +106,10 @@ Foam::pointSet::pointSet const polyMesh& mesh, const word& name, labelHashSet&& labels, - writeOption w + IOobjectOption::writeOption wOpt ) : - topoSet(mesh, name, std::move(labels), w) + topoSet(mesh, name, std::move(labels), wOpt) {} @@ -118,10 +118,10 @@ Foam::pointSet::pointSet const polyMesh& mesh, const word& name, const labelUList& labels, - writeOption w + IOobjectOption::writeOption wOpt ) : - topoSet(mesh, name, labels, w) + topoSet(mesh, name, labels, wOpt) {} diff --git a/src/meshTools/topoSet/topoSets/pointSet.H b/src/meshTools/topoSet/topoSets/pointSet.H index 3a0d0124c9..eff97e122c 100644 --- a/src/meshTools/topoSet/topoSets/pointSet.H +++ b/src/meshTools/topoSet/topoSets/pointSet.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011 OpenFOAM Foundation - Copyright (C) 2016-2018 OpenCFD Ltd. + Copyright (C) 2016-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -35,8 +35,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef pointSet_H -#define pointSet_H +#ifndef Foam_pointSet_H +#define Foam_pointSet_H #include "topoSet.H" @@ -62,15 +62,15 @@ public: // Constructors //- Construct from IOobject - explicit pointSet(const IOobject& obj); + explicit pointSet(const IOobject& io); //- Construct from objectRegistry and name pointSet ( const polyMesh& mesh, const word& name, - readOption r=MUST_READ, - writeOption w=NO_WRITE + IOobjectOption::readOption rOpt = IOobjectOption::MUST_READ, + IOobjectOption::writeOption wOpt = IOobjectOption::NO_WRITE ); //- Construct empty with initial size for labelHashSet @@ -79,7 +79,7 @@ public: const polyMesh& mesh, const word& name, const label size, - writeOption w=NO_WRITE + IOobjectOption::writeOption wOpt = IOobjectOption::NO_WRITE ); //- Construct from existing set @@ -88,7 +88,7 @@ public: const polyMesh& mesh, const word& name, const topoSet& set, - writeOption w=NO_WRITE + IOobjectOption::writeOption wOpt = IOobjectOption::NO_WRITE ); //- Construct (no-read) with copy of labelHashSet @@ -97,7 +97,7 @@ public: const polyMesh& mesh, const word& name, const labelHashSet& labels, - writeOption w=NO_WRITE + IOobjectOption::writeOption wOpt = IOobjectOption::NO_WRITE ); //- Construct (no-read) with moving labelHashSet @@ -106,7 +106,7 @@ public: const polyMesh& mesh, const word& name, labelHashSet&& labels, - writeOption w=NO_WRITE + IOobjectOption::writeOption wOpt = IOobjectOption::NO_WRITE ); //- Construct (no-read) with copy of labels @@ -115,7 +115,7 @@ public: const polyMesh& mesh, const word& name, const labelUList& labels, - writeOption w=NO_WRITE + IOobjectOption::writeOption wOpt = IOobjectOption::NO_WRITE ); diff --git a/src/meshTools/topoSet/topoSets/pointZoneSet.C b/src/meshTools/topoSet/topoSets/pointZoneSet.C index b94e5800eb..5cd923f598 100644 --- a/src/meshTools/topoSet/topoSets/pointZoneSet.C +++ b/src/meshTools/topoSet/topoSets/pointZoneSet.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation - Copyright (C) 2018-2020 OpenCFD Ltd. + Copyright (C) 2018-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -62,8 +62,8 @@ Foam::pointZoneSet::pointZoneSet ( const polyMesh& mesh, const word& name, - readOption r, - writeOption w + IOobjectOption::readOption rOpt, + IOobjectOption::writeOption wOpt ) : pointSet(mesh, name, 1024), // do not read pointSet @@ -75,9 +75,8 @@ Foam::pointZoneSet::pointZoneSet if ( - r == IOobject::MUST_READ - || r == IOobject::MUST_READ_IF_MODIFIED - || (r == IOobject::READ_IF_PRESENT && zoneID != -1) + IOobjectOption::isReadRequired(rOpt) + || (IOobjectOption::isReadOptional(rOpt) && zoneID != -1) ) { const pointZone& fz = pointZones[zoneID]; @@ -95,10 +94,10 @@ Foam::pointZoneSet::pointZoneSet const polyMesh& mesh, const word& name, const label size, - writeOption w + IOobjectOption::writeOption wOpt ) : - pointSet(mesh, name, size, w), + pointSet(mesh, name, size, wOpt), mesh_(mesh), addressing_() { @@ -111,10 +110,10 @@ Foam::pointZoneSet::pointZoneSet const polyMesh& mesh, const word& name, const topoSet& set, - writeOption w + IOobjectOption::writeOption wOpt ) : - pointSet(mesh, name, set.size(), w), + pointSet(mesh, name, set.size(), wOpt), mesh_(mesh), addressing_(refCast(set).addressing()) { diff --git a/src/meshTools/topoSet/topoSets/pointZoneSet.H b/src/meshTools/topoSet/topoSets/pointZoneSet.H index e08ea6f789..d8de8a3294 100644 --- a/src/meshTools/topoSet/topoSets/pointZoneSet.H +++ b/src/meshTools/topoSet/topoSets/pointZoneSet.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation - Copyright (C) 2018-2020 OpenCFD Ltd. + Copyright (C) 2018-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -32,12 +32,12 @@ Description writing. SourceFiles - pointZone.C + pointZoneSet.C \*---------------------------------------------------------------------------*/ -#ifndef pointZoneSet_H -#define pointZoneSet_H +#ifndef Foam_pointZoneSet_H +#define Foam_pointZoneSet_H #include "pointSet.H" @@ -74,8 +74,8 @@ public: ( const polyMesh& mesh, const word& name, - readOption r=MUST_READ, - writeOption w=NO_WRITE + IOobjectOption::readOption rOpt = IOobjectOption::MUST_READ, + IOobjectOption::writeOption wOpt = IOobjectOption::NO_WRITE ); //- Construct empty with initial size for labelHashSet @@ -84,7 +84,7 @@ public: const polyMesh& mesh, const word& name, const label size, - writeOption w=NO_WRITE + IOobjectOption::writeOption wOpt = IOobjectOption::NO_WRITE ); //- Copy construct from existing set @@ -93,7 +93,7 @@ public: const polyMesh& mesh, const word& name, const topoSet& set, - writeOption w=NO_WRITE + IOobjectOption::writeOption wOpt = IOobjectOption::NO_WRITE ); diff --git a/src/meshTools/topoSet/topoSets/topoSet.C b/src/meshTools/topoSet/topoSets/topoSet.C index 2b7a3772e9..31e47c8981 100644 --- a/src/meshTools/topoSet/topoSets/topoSet.C +++ b/src/meshTools/topoSet/topoSets/topoSet.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2016-2021 OpenCFD Ltd. + Copyright (C) 2016-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -56,8 +56,8 @@ Foam::topoSet::New const word& setType, const polyMesh& mesh, const word& name, - readOption r, - writeOption w + IOobjectOption::readOption rOpt, + IOobjectOption::writeOption wOpt ) { auto* ctorPtr = wordConstructorTable(setType); @@ -72,7 +72,7 @@ Foam::topoSet::New ) << exit(FatalError); } - return autoPtr(ctorPtr(mesh, name, r, w)); + return autoPtr(ctorPtr(mesh, name, rOpt, wOpt)); } @@ -83,7 +83,7 @@ Foam::topoSet::New const polyMesh& mesh, const word& name, const label size, - writeOption w + IOobjectOption::writeOption wOpt ) { auto* ctorPtr = sizeConstructorTable(setType); @@ -98,7 +98,7 @@ Foam::topoSet::New ) << exit(FatalError); } - return autoPtr(ctorPtr(mesh, name, size, w)); + return autoPtr(ctorPtr(mesh, name, size, wOpt)); } @@ -109,7 +109,7 @@ Foam::topoSet::New const polyMesh& mesh, const word& name, const topoSet& set, - writeOption w + IOobjectOption::writeOption wOpt ) { auto* ctorPtr = setConstructorTable(setType); @@ -124,7 +124,7 @@ Foam::topoSet::New ) << exit(FatalError); } - return autoPtr(ctorPtr(mesh, name, set, w)); + return autoPtr(ctorPtr(mesh, name, set, wOpt)); } @@ -318,8 +318,8 @@ Foam::IOobject Foam::topoSet::findIOobject ( const polyMesh& mesh, const word& name, - readOption r, - writeOption w + IOobjectOption::readOption rOpt, + IOobjectOption::writeOption wOpt ) { IOobject io @@ -334,8 +334,8 @@ Foam::IOobject Foam::topoSet::findIOobject ), polyMesh::meshSubDir/"sets", mesh, - r, - w + rOpt, + wOpt ); if (!io.typeHeaderOk(false) && disallowGenericSets != 0) @@ -352,8 +352,8 @@ Foam::IOobject Foam::topoSet::findIOobject ( const Time& runTime, const word& name, - readOption r, - writeOption w + IOobjectOption::readOption rOpt, + IOobjectOption::writeOption wOpt ) { return IOobject @@ -373,24 +373,19 @@ Foam::IOobject Foam::topoSet::findIOobject ), polyMesh::meshSubDir/"sets", runTime, - r, - w + rOpt, + wOpt ); } // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -Foam::topoSet::topoSet(const IOobject& obj, const word& wantedType) +Foam::topoSet::topoSet(const IOobject& io, const word& wantedType) : - regIOobject(obj) + regIOobject(io) { - if - ( - readOpt() == IOobject::MUST_READ - || readOpt() == IOobject::MUST_READ_IF_MODIFIED - || (readOpt() == IOobject::READ_IF_PRESENT && headerOk()) - ) + if (isReadRequired() || (isReadOptional() && headerOk())) { if (readStream(wantedType).good()) { @@ -407,18 +402,13 @@ Foam::topoSet::topoSet const polyMesh& mesh, const word& wantedType, const word& name, - readOption r, - writeOption w + IOobjectOption::readOption rOpt, + IOobjectOption::writeOption wOpt ) : - regIOobject(findIOobject(mesh, name, r, w)) + regIOobject(findIOobject(mesh, name, rOpt, wOpt)) { - if - ( - readOpt() == IOobject::MUST_READ - || readOpt() == IOobject::MUST_READ_IF_MODIFIED - || (readOpt() == IOobject::READ_IF_PRESENT && headerOk()) - ) + if (isReadRequired() || (isReadOptional() && headerOk())) { if (readStream(wantedType).good()) { @@ -435,10 +425,10 @@ Foam::topoSet::topoSet const polyMesh& mesh, const word& name, const label size, - writeOption w + IOobjectOption::writeOption wOpt ) : - regIOobject(findIOobject(mesh, name, IOobject::NO_READ, w)), + regIOobject(findIOobject(mesh, name, IOobject::NO_READ, wOpt)), labelHashSet(size) {} @@ -448,10 +438,10 @@ Foam::topoSet::topoSet const polyMesh& mesh, const word& name, const labelHashSet& labels, - writeOption w + IOobjectOption::writeOption wOpt ) : - regIOobject(findIOobject(mesh, name, IOobject::NO_READ, w)), + regIOobject(findIOobject(mesh, name, IOobject::NO_READ, wOpt)), labelHashSet(labels) {} @@ -461,10 +451,10 @@ Foam::topoSet::topoSet const polyMesh& mesh, const word& name, labelHashSet&& labels, - writeOption w + IOobjectOption::writeOption wOpt ) : - regIOobject(findIOobject(mesh, name, IOobject::NO_READ, w)), + regIOobject(findIOobject(mesh, name, IOobject::NO_READ, wOpt)), labelHashSet(std::move(labels)) {} @@ -474,10 +464,10 @@ Foam::topoSet::topoSet const polyMesh& mesh, const word& name, const labelUList& labels, - writeOption w + IOobjectOption::writeOption wOpt ) : - regIOobject(findIOobject(mesh, name, IOobject::NO_READ, w)), + regIOobject(findIOobject(mesh, name, IOobject::NO_READ, wOpt)), labelHashSet(labels) {} diff --git a/src/meshTools/topoSet/topoSets/topoSet.H b/src/meshTools/topoSet/topoSets/topoSet.H index 8465548d39..d8eef75299 100644 --- a/src/meshTools/topoSet/topoSets/topoSet.H +++ b/src/meshTools/topoSet/topoSets/topoSet.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2016-2019 OpenCFD Ltd. + Copyright (C) 2016-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -36,8 +36,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef topoSet_H -#define topoSet_H +#ifndef Foam_topoSet_H +#define Foam_topoSet_H #include "HashSet.H" #include "regIOobject.H" @@ -128,8 +128,8 @@ public: ( const polyMesh& mesh, const word& name, - readOption r=MUST_READ, - writeOption w=NO_WRITE + IOobjectOption::readOption rOpt = IOobjectOption::MUST_READ, + IOobjectOption::writeOption wOpt = IOobjectOption::NO_WRITE ); //- Find IOobject in the polyMesh/sets (used as constructor helper) @@ -137,8 +137,8 @@ public: ( const Time& runTime, const word& name, - readOption r=MUST_READ, - writeOption w=NO_WRITE + IOobjectOption::readOption rOpt = IOobjectOption::MUST_READ, + IOobjectOption::writeOption wOpt = IOobjectOption::NO_WRITE ); @@ -153,10 +153,10 @@ public: ( const polyMesh& mesh, const word& name, - readOption r, - writeOption w + IOobjectOption::readOption rOpt, + IOobjectOption::writeOption wOpt ), - (mesh, name, r, w) + (mesh, name, rOpt, wOpt) ); // For the constructor from size @@ -169,9 +169,9 @@ public: const polyMesh& mesh, const word& name, const label size, - writeOption w + IOobjectOption::writeOption wOpt ), - (mesh, name, size, w) + (mesh, name, size, wOpt) ); // For the constructor as copy @@ -184,9 +184,9 @@ public: const polyMesh& mesh, const word& name, const topoSet& set, - writeOption w + IOobjectOption::writeOption wOpt ), - (mesh, name, set, w) + (mesh, name, set, wOpt) ); @@ -194,7 +194,7 @@ public: //- Construct from IOobject as explicitly passed type. // Can't use typeName info here since subclasses not yet instantiated - topoSet(const IOobject& obj, const word& wantedType); + topoSet(const IOobject& io, const word& wantedType); //- Construct from polyMesh and name. // Searches for a polyMesh/sets directory but not beyond the @@ -204,8 +204,8 @@ public: const polyMesh& mesh, const word& wantedType, const word& name, - readOption r=MUST_READ, - writeOption w=NO_WRITE + IOobjectOption::readOption rOpt = IOobjectOption::MUST_READ, + IOobjectOption::writeOption wOpt = IOobjectOption::NO_WRITE ); //- Construct empty from additional size of labelHashSet. @@ -216,7 +216,7 @@ public: const polyMesh& mesh, const word& name, const label size, - writeOption w=NO_WRITE + IOobjectOption::writeOption wOpt = IOobjectOption::NO_WRITE ); //- Construct (no-read) with copy of labelHashSet @@ -227,7 +227,7 @@ public: const polyMesh& mesh, const word& name, const labelHashSet& labels, - writeOption w=NO_WRITE + IOobjectOption::writeOption wOpt = IOobjectOption::NO_WRITE ); //- Construct (no-read) with moving labelHashSet @@ -238,7 +238,7 @@ public: const polyMesh& mesh, const word& name, labelHashSet&& labels, - writeOption w=NO_WRITE + IOobjectOption::writeOption wOpt = IOobjectOption::NO_WRITE ); //- Construct (no-read) with copy of labels @@ -249,7 +249,7 @@ public: const polyMesh& mesh, const word& name, const labelUList& labels, - writeOption w=NO_WRITE + IOobjectOption::writeOption wOpt = IOobjectOption::NO_WRITE ); //- Construct empty from IOobject and HashSet size. @@ -278,8 +278,8 @@ public: const word& setType, const polyMesh& mesh, const word& name, - readOption r=MUST_READ, - writeOption w=NO_WRITE + IOobjectOption::readOption rOpt = IOobjectOption::MUST_READ, + IOobjectOption::writeOption wOpt = IOobjectOption::NO_WRITE ); //- Return a pointer to a new toposet of given size @@ -289,7 +289,7 @@ public: const polyMesh& mesh, const word& name, const label size, - writeOption w=NO_WRITE + IOobjectOption::writeOption wOpt = IOobjectOption::NO_WRITE ); //- Return a pointer to a new toposet as copy of another toposet @@ -299,7 +299,7 @@ public: const polyMesh& mesh, const word& name, const topoSet& set, - writeOption w=NO_WRITE + IOobjectOption::writeOption wOpt = IOobjectOption::NO_WRITE ); diff --git a/src/parallel/distributed/distributedTriSurfaceMesh/distributedTriSurfaceMesh.C b/src/parallel/distributed/distributedTriSurfaceMesh/distributedTriSurfaceMesh.C index 337c6cde6d..7d3e433aaa 100644 --- a/src/parallel/distributed/distributedTriSurfaceMesh/distributedTriSurfaceMesh.C +++ b/src/parallel/distributed/distributedTriSurfaceMesh/distributedTriSurfaceMesh.C @@ -2626,12 +2626,7 @@ Foam::distributedTriSurfaceMesh::distributedTriSurfaceMesh(const IOobject& io) searchableSurface::local(), searchableSurface::db(), ( - ( - searchableSurface::readOpt() - == IOobject::MUST_READ - || searchableSurface::readOpt() - == IOobject::MUST_READ_IF_MODIFIED - ) + searchableSurface::isReadRequired() ? IOobject::READ_IF_PRESENT : searchableSurface::readOpt() ), @@ -2739,12 +2734,7 @@ Foam::distributedTriSurfaceMesh::distributedTriSurfaceMesh searchableSurface::local(), searchableSurface::db(), ( - ( - searchableSurface::readOpt() - == IOobject::MUST_READ - || searchableSurface::readOpt() - == IOobject::MUST_READ_IF_MODIFIED - ) + searchableSurface::isReadRequired() ? IOobject::READ_IF_PRESENT : searchableSurface::readOpt() ), diff --git a/src/surfMesh/MeshedSurfaceAllocator/MeshedSurfaceIOAllocator.C b/src/surfMesh/MeshedSurfaceAllocator/MeshedSurfaceIOAllocator.C index 0882fdd9e5..7425bab57f 100644 --- a/src/surfMesh/MeshedSurfaceAllocator/MeshedSurfaceIOAllocator.C +++ b/src/surfMesh/MeshedSurfaceAllocator/MeshedSurfaceIOAllocator.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2016-2021 OpenCFD Ltd. + Copyright (C) 2016-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -85,7 +85,7 @@ void Foam::Detail::MeshedSurfaceIOAllocator::setInstance void Foam::Detail::MeshedSurfaceIOAllocator::setWriteOption ( - IOobject::writeOption wOpt + IOobjectOption::writeOption wOpt ) { points_.writeOpt(wOpt); diff --git a/src/surfMesh/MeshedSurfaceAllocator/MeshedSurfaceIOAllocator.H b/src/surfMesh/MeshedSurfaceAllocator/MeshedSurfaceIOAllocator.H index 041cae40c7..674a767994 100644 --- a/src/surfMesh/MeshedSurfaceAllocator/MeshedSurfaceIOAllocator.H +++ b/src/surfMesh/MeshedSurfaceAllocator/MeshedSurfaceIOAllocator.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2016-2020 OpenCFD Ltd. + Copyright (C) 2016-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -35,8 +35,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef MeshedSurfaceIOAllocator_H -#define MeshedSurfaceIOAllocator_H +#ifndef Foam_MeshedSurfaceIOAllocator_H +#define Foam_MeshedSurfaceIOAllocator_H #include "pointIOField.H" #include "faceIOList.H" @@ -110,7 +110,7 @@ public: void setInstance(const fileName& inst); //- Adjust the write option for all components - void setWriteOption(IOobject::writeOption wOpt); + void setWriteOption(IOobjectOption::writeOption wOpt); // Access diff --git a/src/surfMesh/surfMesh/surfMesh.H b/src/surfMesh/surfMesh/surfMesh.H index 9994e445d5..e324a1ebaf 100644 --- a/src/surfMesh/surfMesh/surfMesh.H +++ b/src/surfMesh/surfMesh/surfMesh.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2016-2020 OpenCFD Ltd. + Copyright (C) 2016-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -38,8 +38,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef surfMesh_H -#define surfMesh_H +#ifndef Foam_surfMesh_H +#define Foam_surfMesh_H #include "surfaceRegistry.H" #include "MeshedSurfaceIOAllocator.H" @@ -206,11 +206,11 @@ public: void setInstance ( const fileName& inst, - IOobject::writeOption wOpt = IOobject::AUTO_WRITE + IOobjectOption::writeOption wOpt = IOobjectOption::AUTO_WRITE ); //- Adjust the write option for all components - void setWriteOption(IOobject::writeOption wOpt); + void setWriteOption(IOobjectOption::writeOption wOpt); // Access diff --git a/src/surfMesh/surfMesh/surfMeshIO.C b/src/surfMesh/surfMesh/surfMeshIO.C index 5905d55912..d1edce3521 100644 --- a/src/surfMesh/surfMesh/surfMeshIO.C +++ b/src/surfMesh/surfMesh/surfMeshIO.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2016-2021 OpenCFD Ltd. + Copyright (C) 2016-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -34,7 +34,7 @@ License void Foam::surfMesh::setInstance ( const fileName& inst, - IOobject::writeOption wOpt + IOobjectOption::writeOption wOpt ) { DebugInFunction << "Resetting file instance to " << inst << endl; @@ -47,7 +47,7 @@ void Foam::surfMesh::setInstance } -void Foam::surfMesh::setWriteOption(IOobject::writeOption wOpt) +void Foam::surfMesh::setWriteOption(IOobjectOption::writeOption wOpt) { writeOpt(wOpt); Allocator::setWriteOption(wOpt); diff --git a/src/surfMesh/surfZone/surfZoneIOList.C b/src/surfMesh/surfZone/surfZoneIOList.C index 2cd1186147..d2b38ee762 100644 --- a/src/surfMesh/surfZone/surfZoneIOList.C +++ b/src/surfMesh/surfZone/surfZoneIOList.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2018-2020 OpenCFD Ltd. + Copyright (C) 2018-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -46,11 +46,7 @@ Foam::surfZoneIOList::surfZoneIOList regIOobject(io), surfZoneList() { - if - ( - readOpt() == IOobject::MUST_READ - || readOpt() == IOobject::MUST_READ_IF_MODIFIED - ) + if (isReadRequired()) { surfZoneList& zones = *this;