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())
    )
    {
        ...
    }
This commit is contained in:
Mark Olesen 2022-09-27 13:07:29 +02:00
parent 623c0624fb
commit d938e01d7a
78 changed files with 891 additions and 850 deletions

View File

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

View File

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

View File

@ -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<unsigned char>(sizeof(label))),
sizeofScalar_(static_cast<unsigned char>(sizeof(scalar))),
name_(name),
headerClassName_(typeName),
note_(),
instance_(instance),
local_(),
rOpt_(rOpt),
wOpt_(wOpt),
registerObject_(registerObject),
globalObject_(globalObject),
objState_(objectState::GOOD),
sizeofLabel_(static_cast<unsigned char>(sizeof(label))),
sizeofScalar_(static_cast<unsigned char>(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<unsigned char>(sizeof(label))),
sizeofScalar_(static_cast<unsigned char>(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<unsigned char>(sizeof(label))),
sizeofScalar_(static_cast<unsigned char>(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<unsigned char>(sizeof(label))),
sizeofScalar_(static_cast<unsigned char>(sizeof(scalar))),
name_(),
headerClassName_(typeName),
note_(),
instance_(),
local_(),
rOpt_(rOpt),
wOpt_(wOpt),
registerObject_(registerObject),
globalObject_(globalObject),
objState_(objectState::GOOD),
sizeofLabel_(static_cast<unsigned char>(sizeof(label))),
sizeofScalar_(static_cast<unsigned char>(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<IOobjectOption>(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<IOobjectOption>(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_;
}

View File

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

View File

@ -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<unsigned>(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

View File

@ -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 <http://www.gnu.org/licenses/>.
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<bool>(opt & readOption::MUST_READ);
}
//- True if (MUST_READ | MUST_READ_IF_MODIFIED) bits are set
bool isReadRequired() const noexcept
{
return static_cast<bool>(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
// ************************************************************************* //

View File

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

View File

@ -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
)
:

View File

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

View File

@ -61,6 +61,23 @@ void Foam::CompactIOField<T, BaseType>::readFromStream(const bool valid)
}
template<class T, class BaseType>
bool Foam::CompactIOField<T, BaseType>::readContents()
{
if
(
readOpt() == IOobject::MUST_READ
|| (isReadOptional() && headerOk())
)
{
readFromStream();
return true;
}
return false;
}
// * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * //
template<class T, class BaseType>
@ -68,14 +85,7 @@ Foam::CompactIOField<T, BaseType>::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<T, BaseType>::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<T, BaseType>::CompactIOField
:
regIOobject(io)
{
if
(
io.readOpt() == IOobject::MUST_READ
|| (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
)
{
readFromStream();
}
readContents();
}
@ -129,15 +132,7 @@ Foam::CompactIOField<T, BaseType>::CompactIOField
:
regIOobject(io)
{
if
(
io.readOpt() == IOobject::MUST_READ
|| (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
)
{
readFromStream();
}
else
if (!readContents())
{
Field<T>::resize(len);
}
@ -153,15 +148,7 @@ Foam::CompactIOField<T, BaseType>::CompactIOField
:
regIOobject(io)
{
if
(
io.readOpt() == IOobject::MUST_READ
|| (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
)
{
readFromStream();
}
else
if (!readContents())
{
Field<T>::operator=(content);
}
@ -179,14 +166,7 @@ Foam::CompactIOField<T, BaseType>::CompactIOField
{
Field<T>::transfer(content);
if
(
io.readOpt() == IOobject::MUST_READ
|| (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
)
{
readFromStream();
}
readContents();
}

View File

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

View File

@ -50,8 +50,8 @@ void Foam::CompactIOList<T, BaseType>::readFromStream()
{
FatalIOErrorInFunction(is)
<< "unexpected class name " << headerClassName()
<< " expected " << typeName << " or " << IOList<T>::typeName
<< endl
<< " expected " << typeName
<< " or " << IOList<T>::typeName << endl
<< " while reading object " << name()
<< exit(FatalIOError);
}
@ -64,7 +64,7 @@ bool Foam::CompactIOList<T, BaseType>::readContents()
if
(
readOpt() == IOobject::MUST_READ
|| (readOpt() == IOobject::READ_IF_PRESENT && headerOk())
|| (isReadOptional() && headerOk())
)
{
readFromStream();

View File

@ -33,14 +33,7 @@ License
template<class Type>
bool Foam::IOField<Type>::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<Type>::IOField(const IOobject& io, const bool valid)
// Check for MUST_READ_IF_MODIFIED
warnNoRereading<IOField<Type>>();
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<Type>::IOField(const IOobject& io, const bool valid)
}
close();
}
else if (io.readOpt() == IOobject::READ_IF_PRESENT)
else if (isReadOptional())
{
bool haveFile = headerOk();

View File

@ -33,14 +33,7 @@ License
template<class T>
bool Foam::IOList<T>::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();

View File

@ -33,14 +33,7 @@ License
template<class T>
bool Foam::IOMap<T>::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();

View File

@ -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<T>::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<T>::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<T>::IOPtrList(const IOobject& io, const PtrList<T>& 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<T>::IOPtrList(const IOobject& io, PtrList<T>&& content)
{
PtrList<T>::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();

View File

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

View File

@ -40,15 +40,10 @@ Foam::rawIOField<Type>::rawIOField(const IOobject& io, const bool readAverage)
// Check for MUST_READ_IF_MODIFIED
warnNoRereading<rawIOField<Type>>();
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<Type>::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<Type>::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

View File

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

View File

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

View File

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

View File

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

View File

@ -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()

View File

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

View File

@ -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<Type, GeoMesh>::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);
}

View File

@ -99,11 +99,7 @@ void Foam::GeometricField<Type, PatchField, GeoMesh>::readFields()
template<class Type, template<class> class PatchField, class GeoMesh>
bool Foam::GeometricField<Type, PatchField, GeoMesh>::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<Type, PatchField, GeoMesh>::readIfPresent()
}
else if
(
this->readOpt() == IOobject::READ_IF_PRESENT
this->isReadOptional()
&& this->template typeHeaderOk<GeometricField<Type, PatchField, GeoMesh>>
(
true

View File

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

View File

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

View File

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

View File

@ -173,7 +173,7 @@ public:
schemesLookup
(
const objectRegistry& obr,
const IOobject::readOption rOpt,
IOobjectOption::readOption rOpt,
const word& dictName,
const dictionary* fallback = nullptr
);

View File

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

View File

@ -124,7 +124,7 @@ public:
solution
(
const objectRegistry& obr,
const IOobject::readOption rOpt,
IOobjectOption::readOption rOpt,
const fileName& dictName,
const dictionary* fallback = nullptr
);

View File

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

View File

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

View File

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

View File

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

View File

@ -414,7 +414,7 @@ public:
void setInstance
(
const fileName& instance,
const IOobject::writeOption wOpt = IOobject::AUTO_WRITE
const IOobjectOption::writeOption wOpt = IOobject::AUTO_WRITE
);

View File

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

View File

@ -155,12 +155,7 @@ void Foam::ZoneMesh<ZoneType, MeshType>::calcGroupIDs() const
template<class ZoneType, class MeshType>
bool Foam::ZoneMesh<ZoneType, MeshType>::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<ZoneMesh<ZoneType, MeshType>>();

View File

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

View File

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

View File

@ -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<polyMeshModifier>& 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)
{}

View File

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

View File

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

View File

@ -69,14 +69,7 @@ public:
regIOobject(io),
PtrList<entry>()
{
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;
}

View File

@ -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
)
:

View File

@ -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
)
:

View File

@ -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
)
:

View File

@ -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
)
:

View File

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

View File

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

View File

@ -222,7 +222,7 @@ public:
IOobject fieldIOobject
(
const word& fieldName,
const IOobject::readOption r
IOobjectOption::readOption rOpt
) const;
//- Check lagrangian data field

View File

@ -190,7 +190,7 @@ template<class ParticleType>
Foam::IOobject Foam::Cloud<ParticleType>::fieldIOobject
(
const word& fieldName,
const IOobject::readOption r
IOobjectOption::readOption rOpt
) const
{
return IOobject
@ -198,7 +198,7 @@ Foam::IOobject Foam::Cloud<ParticleType>::fieldIOobject
fieldName,
time().timeName(),
*this,
r,
rOpt,
IOobject::NO_WRITE,
false
);

View File

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

View File

@ -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<extendedFeatureEdgeMesh>();

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -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<const cellZoneSet>(set).addressing())
{

View File

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

View File

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

View File

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

View File

@ -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<const faceZoneSet>(set).addressing()),
flipMap_(refCast<const faceZoneSet>(set).flipMap())

View File

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

View File

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

View File

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

View File

@ -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<const pointZoneSet>(set).addressing())
{

View File

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

View File

@ -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<topoSet>(ctorPtr(mesh, name, r, w));
return autoPtr<topoSet>(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<topoSet>(ctorPtr(mesh, name, size, w));
return autoPtr<topoSet>(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<topoSet>(ctorPtr(mesh, name, set, w));
return autoPtr<topoSet>(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<topoSet>(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)
{}

View File

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

View File

@ -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()
),

View File

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

View File

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

View File

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

View File

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

View File

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