ENH: consolidate read handling within various regIOobjects

This commit is contained in:
Mark Olesen
2022-04-07 21:08:18 +02:00
parent 35106b60c6
commit 4cbe0a81ac
24 changed files with 370 additions and 473 deletions

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2015-2020 OpenCFD Ltd. Copyright (C) 2015-2022 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -58,6 +58,23 @@ void Foam::CompactIOList<T, BaseType>::readFromStream()
} }
template<class T, class BaseType>
bool Foam::CompactIOList<T, BaseType>::readContents()
{
if
(
readOpt() == IOobject::MUST_READ
|| (readOpt() == IOobject::READ_IF_PRESENT && headerOk())
)
{
readFromStream();
return true;
}
return false;
}
template<class T, class BaseType> template<class T, class BaseType>
bool Foam::CompactIOList<T, BaseType>::overflows() const bool Foam::CompactIOList<T, BaseType>::overflows() const
{ {
@ -82,14 +99,7 @@ Foam::CompactIOList<T, BaseType>::CompactIOList(const IOobject& io)
: :
regIOobject(io) regIOobject(io)
{ {
if readContents();
(
io.readOpt() == IOobject::MUST_READ
|| (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
)
{
readFromStream();
}
} }
@ -102,17 +112,9 @@ Foam::CompactIOList<T, BaseType>::CompactIOList
: :
regIOobject(io) regIOobject(io)
{ {
if if (!readContents())
(
io.readOpt() == IOobject::MUST_READ
|| (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
)
{ {
readFromStream(); List<T>::resize(len);
}
else
{
List<T>::setSize(len);
} }
} }
@ -126,15 +128,7 @@ Foam::CompactIOList<T, BaseType>::CompactIOList
: :
regIOobject(io) regIOobject(io)
{ {
if if (!readContents())
(
io.readOpt() == IOobject::MUST_READ
|| (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
)
{
readFromStream();
}
else
{ {
List<T>::operator=(content); List<T>::operator=(content);
} }
@ -152,14 +146,7 @@ Foam::CompactIOList<T, BaseType>::CompactIOList
{ {
List<T>::transfer(content); List<T>::transfer(content);
if readContents();
(
io.readOpt() == IOobject::MUST_READ
|| (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
)
{
readFromStream();
}
} }

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2018-2020 OpenCFD Ltd. Copyright (C) 2018-2022 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -39,8 +39,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#ifndef CompactIOList_H #ifndef Foam_CompactIOList_H
#define CompactIOList_H #define Foam_CompactIOList_H
#include "IOList.H" #include "IOList.H"
#include "regIOobject.H" #include "regIOobject.H"
@ -50,7 +50,7 @@ SourceFiles
namespace Foam namespace Foam
{ {
// Forward declarations // Forward Declarations
class Istream; class Istream;
class Ostream; class Ostream;
template<class T, class BaseType> class CompactIOList; template<class T, class BaseType> class CompactIOList;
@ -81,11 +81,19 @@ class CompactIOList
//- Read according to header type //- Read according to header type
void readFromStream(); void readFromStream();
//- Read if IOobject flags set. Return true if read.
// Reads according to the header type
bool readContents();
//- Has too many elements in it? //- Has too many elements in it?
bool overflows() const; bool overflows() const;
public: public:
//- The underlying content type
typedef List<T> content_type;
//- Runtime type information //- Runtime type information
TypeName("CompactList"); TypeName("CompactList");

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2016-2018 OpenCFD Ltd. Copyright (C) 2016-2022 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -28,6 +28,29 @@ License
#include "IOField.H" #include "IOField.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
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())
)
{
readStream(typeName) >> *this;
close();
return true;
}
return false;
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Type> template<class Type>
@ -38,18 +61,7 @@ Foam::IOField<Type>::IOField(const IOobject& io)
// Check for MUST_READ_IF_MODIFIED // Check for MUST_READ_IF_MODIFIED
warnNoRereading<IOField<Type>>(); warnNoRereading<IOField<Type>>();
if readContents();
(
(
io.readOpt() == IOobject::MUST_READ
|| io.readOpt() == IOobject::MUST_READ_IF_MODIFIED
)
|| (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
)
{
readStream(typeName) >> *this;
close();
}
} }
@ -91,28 +103,16 @@ Foam::IOField<Type>::IOField(const IOobject& io, const bool valid)
template<class Type> template<class Type>
Foam::IOField<Type>::IOField(const IOobject& io, const label size) Foam::IOField<Type>::IOField(const IOobject& io, const label len)
: :
regIOobject(io) regIOobject(io)
{ {
// Check for MUST_READ_IF_MODIFIED // Check for MUST_READ_IF_MODIFIED
warnNoRereading<IOField<Type>>(); warnNoRereading<IOField<Type>>();
if if (!readContents())
(
(
io.readOpt() == IOobject::MUST_READ
|| io.readOpt() == IOobject::MUST_READ_IF_MODIFIED
)
|| (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
)
{ {
readStream(typeName) >> *this; Field<Type>::resize(len);
close();
}
else
{
Field<Type>::setSize(size);
} }
} }
@ -125,19 +125,7 @@ Foam::IOField<Type>::IOField(const IOobject& io, const UList<Type>& content)
// Check for MUST_READ_IF_MODIFIED // Check for MUST_READ_IF_MODIFIED
warnNoRereading<IOField<Type>>(); warnNoRereading<IOField<Type>>();
if if (!readContents())
(
(
io.readOpt() == IOobject::MUST_READ
|| io.readOpt() == IOobject::MUST_READ_IF_MODIFIED
)
|| (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
)
{
readStream(typeName) >> *this;
close();
}
else
{ {
Field<Type>::operator=(content); Field<Type>::operator=(content);
} }
@ -154,18 +142,7 @@ Foam::IOField<Type>::IOField(const IOobject& io, Field<Type>&& content)
Field<Type>::transfer(content); Field<Type>::transfer(content);
if readContents();
(
(
io.readOpt() == IOobject::MUST_READ
|| io.readOpt() == IOobject::MUST_READ_IF_MODIFIED
)
|| (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
)
{
readStream(typeName) >> *this;
close();
}
} }
@ -181,19 +158,7 @@ Foam::IOField<Type>::IOField(const IOobject& io, const tmp<Field<Type>>& tfld)
Field<Type>::transfer(tfld.ref()); Field<Type>::transfer(tfld.ref());
} }
if if (!readContents() && !reuse)
(
(
io.readOpt() == IOobject::MUST_READ
|| io.readOpt() == IOobject::MUST_READ_IF_MODIFIED
)
|| (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
)
{
readStream(typeName) >> *this;
close();
}
else if (!reuse)
{ {
Field<Type>::operator=(tfld()); Field<Type>::operator=(tfld());
} }

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2018 OpenCFD Ltd. Copyright (C) 2018-2022 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -35,8 +35,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#ifndef IOField_H #ifndef Foam_IOField_H
#define IOField_H #define Foam_IOField_H
#include "regIOobject.H" #include "regIOobject.H"
#include "Field.H" #include "Field.H"
@ -56,8 +56,17 @@ class IOField
public regIOobject, public regIOobject,
public Field<Type> public Field<Type>
{ {
// Private Member Functions
//- Read if IOobject flags set. Return true if read.
bool readContents();
public: public:
//- The underlying content type
typedef Field<Type> content_type;
//- Runtime type information
TypeName("Field"); TypeName("Field");

View File

@ -28,6 +28,29 @@ License
#include "IOList.H" #include "IOList.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
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())
)
{
readStream(typeName) >> *this;
close();
return true;
}
return false;
}
// * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * //
template<class T> template<class T>
@ -38,18 +61,7 @@ Foam::IOList<T>::IOList(const IOobject& io)
// Check for MUST_READ_IF_MODIFIED // Check for MUST_READ_IF_MODIFIED
warnNoRereading<IOList<T>>(); warnNoRereading<IOList<T>>();
if readContents();
(
(
io.readOpt() == IOobject::MUST_READ
|| io.readOpt() == IOobject::MUST_READ_IF_MODIFIED
)
|| (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
)
{
readStream(typeName) >> *this;
close();
}
} }
@ -61,21 +73,9 @@ Foam::IOList<T>::IOList(const IOobject& io, const label len)
// Check for MUST_READ_IF_MODIFIED // Check for MUST_READ_IF_MODIFIED
warnNoRereading<IOList<T>>(); warnNoRereading<IOList<T>>();
if if (!readContents())
(
(
io.readOpt() == IOobject::MUST_READ
|| io.readOpt() == IOobject::MUST_READ_IF_MODIFIED
)
|| (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
)
{ {
readStream(typeName) >> *this; List<T>::resize(len);
close();
}
else
{
List<T>::setSize(len);
} }
} }
@ -88,19 +88,7 @@ Foam::IOList<T>::IOList(const IOobject& io, const UList<T>& content)
// Check for MUST_READ_IF_MODIFIED // Check for MUST_READ_IF_MODIFIED
warnNoRereading<IOList<T>>(); warnNoRereading<IOList<T>>();
if if (!readContents())
(
(
io.readOpt() == IOobject::MUST_READ
|| io.readOpt() == IOobject::MUST_READ_IF_MODIFIED
)
|| (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
)
{
readStream(typeName) >> *this;
close();
}
else
{ {
List<T>::operator=(content); List<T>::operator=(content);
} }
@ -117,18 +105,7 @@ Foam::IOList<T>::IOList(const IOobject& io, List<T>&& content)
List<T>::transfer(content); List<T>::transfer(content);
if readContents();
(
(
io.readOpt() == IOobject::MUST_READ
|| io.readOpt() == IOobject::MUST_READ_IF_MODIFIED
)
|| (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
)
{
readStream(typeName) >> *this;
close();
}
} }

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2018 OpenCFD Ltd. Copyright (C) 2018-2022 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -35,8 +35,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#ifndef IOList_H #ifndef Foam_IOList_H
#define IOList_H #define Foam_IOList_H
#include "List.H" #include "List.H"
#include "regIOobject.H" #include "regIOobject.H"
@ -56,8 +56,16 @@ class IOList
public regIOobject, public regIOobject,
public List<T> public List<T>
{ {
// Private Member Functions
//- Read if IOobject flags set. Return true if read.
bool readContents();
public: public:
//- The underlying content type
typedef List<T> content_type;
//- Runtime type information //- Runtime type information
TypeName("List"); TypeName("List");
@ -96,7 +104,6 @@ public:
//- Copy or move assignment of entries //- Copy or move assignment of entries
using List<T>::operator=; using List<T>::operator=;
}; };

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2018 OpenCFD Ltd. Copyright (C) 2018-2022 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -28,6 +28,33 @@ License
#include "IOMap.H" #include "IOMap.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
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())
)
{
// For if MUST_READ_IF_MODIFIED
addWatch();
readStream(typeName) >> *this;
close();
return true;
}
return false;
}
// * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * //
template<class T> template<class T>
@ -35,46 +62,18 @@ Foam::IOMap<T>::IOMap(const IOobject& io)
: :
regIOobject(io) regIOobject(io)
{ {
if readContents();
(
(
io.readOpt() == IOobject::MUST_READ
|| io.readOpt() == IOobject::MUST_READ_IF_MODIFIED
)
|| (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
)
{
// For if MUST_READ_IF_MODIFIED
addWatch();
readStream(typeName) >> *this;
close();
}
} }
template<class T> template<class T>
Foam::IOMap<T>::IOMap(const IOobject& io, const label size) Foam::IOMap<T>::IOMap(const IOobject& io, const label size)
: :
regIOobject(io) regIOobject(io)
{ {
if if (!readContents())
(
(
io.readOpt() == IOobject::MUST_READ
|| io.readOpt() == IOobject::MUST_READ_IF_MODIFIED
)
|| (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
)
{ {
// For if MUST_READ_IF_MODIFIED Map<T>::resize(size);
addWatch();
readStream(typeName) >> *this;
close();
}
else
{
Map<T>::setSize(size);
} }
} }
@ -84,22 +83,7 @@ Foam::IOMap<T>::IOMap(const IOobject& io, const Map<T>& content)
: :
regIOobject(io) regIOobject(io)
{ {
if if (!readContents())
(
(
io.readOpt() == IOobject::MUST_READ
|| io.readOpt() == IOobject::MUST_READ_IF_MODIFIED
)
|| (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
)
{
// For if MUST_READ_IF_MODIFIED
addWatch();
readStream(typeName) >> *this;
close();
}
else
{ {
Map<T>::operator=(content); Map<T>::operator=(content);
} }
@ -113,21 +97,7 @@ Foam::IOMap<T>::IOMap(const IOobject& io, Map<T>&& content)
{ {
Map<T>::transfer(content); Map<T>::transfer(content);
if readContents();
(
(
io.readOpt() == IOobject::MUST_READ
|| io.readOpt() == IOobject::MUST_READ_IF_MODIFIED
)
|| (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
)
{
// For if MUST_READ_IF_MODIFIED
addWatch();
readStream(typeName) >> *this;
close();
}
} }

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2018 OpenCFD Ltd. Copyright (C) 2018-2022 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -36,8 +36,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#ifndef IOMap_H #ifndef Foam_IOMap_H
#define IOMap_H #define Foam_IOMap_H
#include "Map.H" #include "Map.H"
#include "regIOobject.H" #include "regIOobject.H"
@ -57,8 +57,16 @@ class IOMap
public regIOobject, public regIOobject,
public Map<T> public Map<T>
{ {
// Private Member Functions
//- Read if IOobject flags set. Return true if read.
bool readContents();
public: public:
//- The underlying content type
typedef Map<T> content_type;
//- Runtime type information //- Runtime type information
TypeName("Map"); TypeName("Map");
@ -102,6 +110,7 @@ public:
return globalFilePath(type()); return globalFilePath(type());
} }
// Member Operators // Member Operators
//- Copy assignment of entries //- Copy assignment of entries

View File

@ -36,6 +36,28 @@ namespace Foam
} }
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
bool Foam::IOmapDistribute::readContents()
{
if
(
(
readOpt() == IOobject::MUST_READ
|| readOpt() == IOobject::MUST_READ_IF_MODIFIED
)
|| (readOpt() == IOobject::READ_IF_PRESENT && headerOk())
)
{
readStream(typeName) >> *this;
close();
return true;
}
return false;
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::IOmapDistribute::IOmapDistribute(const IOobject& io) Foam::IOmapDistribute::IOmapDistribute(const IOobject& io)
@ -45,18 +67,7 @@ Foam::IOmapDistribute::IOmapDistribute(const IOobject& io)
// Warn for MUST_READ_IF_MODIFIED // Warn for MUST_READ_IF_MODIFIED
warnNoRereading<IOmapDistribute>(); warnNoRereading<IOmapDistribute>();
if readContents();
(
(
io.readOpt() == IOobject::MUST_READ
|| io.readOpt() == IOobject::MUST_READ_IF_MODIFIED
)
|| (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
)
{
readStream(typeName) >> *this;
close();
}
} }
@ -71,19 +82,7 @@ Foam::IOmapDistribute::IOmapDistribute
// Warn for MUST_READ_IF_MODIFIED // Warn for MUST_READ_IF_MODIFIED
warnNoRereading<IOmapDistribute>(); warnNoRereading<IOmapDistribute>();
if if (!readContents())
(
(
io.readOpt() == IOobject::MUST_READ
|| io.readOpt() == IOobject::MUST_READ_IF_MODIFIED
)
|| (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
)
{
readStream(typeName) >> *this;
close();
}
else
{ {
mapDistribute::operator=(map); mapDistribute::operator=(map);
} }
@ -103,18 +102,7 @@ Foam::IOmapDistribute::IOmapDistribute
mapDistribute::transfer(map); mapDistribute::transfer(map);
if readContents();
(
(
io.readOpt() == IOobject::MUST_READ
|| io.readOpt() == IOobject::MUST_READ_IF_MODIFIED
)
|| (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
)
{
readStream(typeName) >> *this;
close();
}
} }

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2014 OpenFOAM Foundation Copyright (C) 2014 OpenFOAM Foundation
Copyright (C) 2018 OpenCFD Ltd. Copyright (C) 2018-2022 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -37,8 +37,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#ifndef IOmapDistribute_H #ifndef Foam_IOmapDistribute_H
#define IOmapDistribute_H #define Foam_IOmapDistribute_H
#include "mapDistribute.H" #include "mapDistribute.H"
#include "regIOobject.H" #include "regIOobject.H"
@ -57,6 +57,10 @@ class IOmapDistribute
public regIOobject, public regIOobject,
public mapDistribute public mapDistribute
{ {
// Private Member Functions
//- Read if IOobject flags set. Return true if read.
bool readContents();
public: public:
@ -65,13 +69,13 @@ public:
// Constructors // Constructors
//- Construct given an IOobject //- Construct from IOobject
IOmapDistribute(const IOobject& io); IOmapDistribute(const IOobject& io);
//- Construct given an IOobject, copying mapDistribute contents //- Construct from IOobject, copying mapDistribute contents
IOmapDistribute(const IOobject& io, const mapDistribute& map); IOmapDistribute(const IOobject& io, const mapDistribute& map);
//- Construct, moving mapDistribute contents //- Construct from IOobject, moving mapDistribute contents
IOmapDistribute(const IOobject& io, mapDistribute&& map); IOmapDistribute(const IOobject& io, mapDistribute&& map);
@ -79,14 +83,13 @@ public:
virtual ~IOmapDistribute() = default; virtual ~IOmapDistribute() = default;
// Member functions // Member Functions
//- ReadData function required for regIOobject read operation //- ReadData function required for regIOobject read operation
virtual bool readData(Istream&); virtual bool readData(Istream&);
//- WriteData function required for regIOobject write operation //- WriteData function required for regIOobject write operation
virtual bool writeData(Ostream&) const; virtual bool writeData(Ostream&) const;
}; };

View File

@ -6,6 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2015 OpenFOAM Foundation Copyright (C) 2015 OpenFOAM Foundation
Copyright (C) 2022 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -31,7 +32,29 @@ License
namespace Foam namespace Foam
{ {
defineTypeNameAndDebug(IOmapDistributePolyMesh, 0); defineTypeNameAndDebug(IOmapDistributePolyMesh, 0);
}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
bool Foam::IOmapDistributePolyMesh::readContents()
{
if
(
(
readOpt() == IOobject::MUST_READ
|| readOpt() == IOobject::MUST_READ_IF_MODIFIED
)
|| (readOpt() == IOobject::READ_IF_PRESENT && headerOk())
)
{
readStream(typeName) >> *this;
close();
return true;
}
return false;
} }
@ -44,18 +67,7 @@ Foam::IOmapDistributePolyMesh::IOmapDistributePolyMesh(const IOobject& io)
// Warn for MUST_READ_IF_MODIFIED // Warn for MUST_READ_IF_MODIFIED
warnNoRereading<IOmapDistributePolyMesh>(); warnNoRereading<IOmapDistributePolyMesh>();
if readContents();
(
(
io.readOpt() == IOobject::MUST_READ
|| io.readOpt() == IOobject::MUST_READ_IF_MODIFIED
)
|| (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
)
{
readStream(typeName) >> *this;
close();
}
} }
@ -70,19 +82,7 @@ Foam::IOmapDistributePolyMesh::IOmapDistributePolyMesh
// Warn for MUST_READ_IF_MODIFIED // Warn for MUST_READ_IF_MODIFIED
warnNoRereading<IOmapDistributePolyMesh>(); warnNoRereading<IOmapDistributePolyMesh>();
if if (!readContents())
(
(
io.readOpt() == IOobject::MUST_READ
|| io.readOpt() == IOobject::MUST_READ_IF_MODIFIED
)
|| (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
)
{
readStream(typeName) >> *this;
close();
}
else
{ {
mapDistributePolyMesh::operator=(map); mapDistributePolyMesh::operator=(map);
} }
@ -102,18 +102,7 @@ Foam::IOmapDistributePolyMesh::IOmapDistributePolyMesh
mapDistributePolyMesh::transfer(map); mapDistributePolyMesh::transfer(map);
if readContents();
(
(
io.readOpt() == IOobject::MUST_READ
|| io.readOpt() == IOobject::MUST_READ_IF_MODIFIED
)
|| (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
)
{
readStream(typeName) >> *this;
close();
}
} }

View File

@ -6,6 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2015 OpenFOAM Foundation Copyright (C) 2015 OpenFOAM Foundation
Copyright (C) 2022 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -36,8 +37,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#ifndef IOmapDistributePolyMesh_H #ifndef Foam_IOmapDistributePolyMesh_H
#define IOmapDistributePolyMesh_H #define Foam_IOmapDistributePolyMesh_H
#include "mapDistributePolyMesh.H" #include "mapDistributePolyMesh.H"
#include "regIOobject.H" #include "regIOobject.H"
@ -56,25 +57,30 @@ class IOmapDistributePolyMesh
public regIOobject, public regIOobject,
public mapDistributePolyMesh public mapDistributePolyMesh
{ {
// Private Member Functions
//- Read if IOobject flags set. Return true if read.
bool readContents();
public: public:
//- Runtime type information //- Runtime type information
TypeName("mapDistributePolyMesh"); TypeName("mapDistributePolyMesh");
// Constructors // Constructors
//- Construct given an IOobject //- Construct from IOobject
IOmapDistributePolyMesh(const IOobject& io); explicit IOmapDistributePolyMesh(const IOobject& io);
//- Construct given an IOobject and mapDistributePolyMesh //- Construct from IOobject, copying mapDistributePolyMesh contents
IOmapDistributePolyMesh IOmapDistributePolyMesh
( (
const IOobject& io, const IOobject& io,
const mapDistributePolyMesh& map const mapDistributePolyMesh& map
); );
//- Construct given an IOobject and mapDistributePolyMesh //- Construct from IOobject, moving mapDistributePolyMesh contents
IOmapDistributePolyMesh IOmapDistributePolyMesh
( (
const IOobject& io, const IOobject& io,
@ -93,7 +99,6 @@ public:
//- The writeData method for regIOobject write operation //- The writeData method for regIOobject write operation
virtual bool writeData(Ostream& os) const; virtual bool writeData(Ostream& os) const;
}; };

View File

@ -107,22 +107,17 @@ void Foam::polyBoundaryMesh::calcGroupIDs() const
} }
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // bool Foam::polyBoundaryMesh::readContents(const bool allowReadIfPresent)
Foam::polyBoundaryMesh::polyBoundaryMesh
(
const IOobject& io,
const polyMesh& mesh
)
:
polyPatchList(),
regIOobject(io),
mesh_(mesh)
{ {
if if
( (
readOpt() == IOobject::MUST_READ this->readOpt() == IOobject::MUST_READ
|| readOpt() == IOobject::MUST_READ_IF_MODIFIED || this->readOpt() == IOobject::MUST_READ_IF_MODIFIED
||
(
allowReadIfPresent
&& (this->readOpt() == IOobject::READ_IF_PRESENT && this->headerOk())
)
) )
{ {
// Warn for MUST_READ_IF_MODIFIED // Warn for MUST_READ_IF_MODIFIED
@ -133,9 +128,11 @@ Foam::polyBoundaryMesh::polyBoundaryMesh
// Read polyPatchList // Read polyPatchList
Istream& is = readStream(typeName); Istream& is = readStream(typeName);
// Read patches as entries
PtrList<entry> patchEntries(is); PtrList<entry> patchEntries(is);
patches.setSize(patchEntries.size()); patches.resize(patchEntries.size());
// Transcribe
forAll(patches, patchi) forAll(patches, patchi)
{ {
patches.set patches.set
@ -152,9 +149,27 @@ Foam::polyBoundaryMesh::polyBoundaryMesh
} }
is.check(FUNCTION_NAME); is.check(FUNCTION_NAME);
close(); close();
return true;
} }
return false;
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::polyBoundaryMesh::polyBoundaryMesh
(
const IOobject& io,
const polyMesh& mesh
)
:
polyPatchList(),
regIOobject(io),
mesh_(mesh)
{
readContents(false); // READ_IF_PRESENT allowed: False
} }
@ -182,47 +197,10 @@ Foam::polyBoundaryMesh::polyBoundaryMesh
regIOobject(io), regIOobject(io),
mesh_(pm) mesh_(pm)
{ {
if if (!readContents(true)) // READ_IF_PRESENT allowed: True
(
(this->readOpt() == IOobject::READ_IF_PRESENT && this->headerOk())
|| this->readOpt() == IOobject::MUST_READ
|| this->readOpt() == IOobject::MUST_READ_IF_MODIFIED
)
{
// Warn for MUST_READ_IF_MODIFIED
warnNoRereading<polyBoundaryMesh>();
polyPatchList& patches = *this;
// Read polyPatchList
Istream& is = readStream(typeName);
PtrList<entry> patchEntries(is);
patches.resize(patchEntries.size());
forAll(patches, patchi)
{
patches.set
(
patchi,
polyPatch::New
(
patchEntries[patchi].keyword(),
patchEntries[patchi].dict(),
patchi,
*this
)
);
}
is.check(FUNCTION_NAME);
close();
}
else
{ {
polyPatchList& patches = *this; polyPatchList& patches = *this;
patches.setSize(ppl.size()); patches.resize(ppl.size());
forAll(patches, patchi) forAll(patches, patchi)
{ {
patches.set(patchi, ppl[patchi].clone(*this)); patches.set(patchi, ppl[patchi].clone(*this));

View File

@ -91,6 +91,9 @@ class polyBoundaryMesh
//- Calculate group name to patch ids lookup //- Calculate group name to patch ids lookup
void calcGroupIDs() const; void calcGroupIDs() const;
//- Read if IOobject flags set. Return true if read.
bool readContents(const bool allowReadIfPresent);
//- No copy construct //- No copy construct
polyBoundaryMesh(const polyBoundaryMesh&) = delete; polyBoundaryMesh(const polyBoundaryMesh&) = delete;

View File

@ -152,7 +152,7 @@ void Foam::ZoneMesh<ZoneType, MeshType>::calcGroupIDs() const
template<class ZoneType, class MeshType> template<class ZoneType, class MeshType>
bool Foam::ZoneMesh<ZoneType, MeshType>::read() bool Foam::ZoneMesh<ZoneType, MeshType>::readContents()
{ {
if if
( (
@ -166,12 +166,13 @@ bool Foam::ZoneMesh<ZoneType, MeshType>::read()
PtrList<ZoneType>& zones = *this; PtrList<ZoneType>& zones = *this;
// Read zones // Read zones as entries
Istream& is = readStream(typeName); Istream& is = readStream(typeName);
PtrList<entry> patchEntries(is); PtrList<entry> patchEntries(is);
zones.resize(patchEntries.size()); zones.resize(patchEntries.size());
// Transcribe
forAll(zones, zonei) forAll(zones, zonei)
{ {
zones.set zones.set
@ -187,11 +188,8 @@ bool Foam::ZoneMesh<ZoneType, MeshType>::read()
); );
} }
// Check state of IOstream
is.check(FUNCTION_NAME); is.check(FUNCTION_NAME);
close(); close();
return true; return true;
} }
@ -213,7 +211,7 @@ Foam::ZoneMesh<ZoneType, MeshType>::ZoneMesh
regIOobject(io), regIOobject(io),
mesh_(mesh) mesh_(mesh)
{ {
read(); readContents();
} }
@ -230,7 +228,7 @@ Foam::ZoneMesh<ZoneType, MeshType>::ZoneMesh
mesh_(mesh) mesh_(mesh)
{ {
// Optionally read contents, otherwise keep size // Optionally read contents, otherwise keep size
read(); readContents();
} }
@ -246,7 +244,7 @@ Foam::ZoneMesh<ZoneType, MeshType>::ZoneMesh
regIOobject(io), regIOobject(io),
mesh_(mesh) mesh_(mesh)
{ {
if (!read()) if (!readContents())
{ {
// Nothing read. Use supplied zones // Nothing read. Use supplied zones
PtrList<ZoneType>& zones = *this; PtrList<ZoneType>& zones = *this;

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2016-2021 OpenCFD Ltd. Copyright (C) 2016-2022 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -35,8 +35,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#ifndef ZoneMesh_H #ifndef Foam_ZoneMesh_H
#define ZoneMesh_H #define Foam_ZoneMesh_H
#include "regIOobject.H" #include "regIOobject.H"
#include "pointField.H" #include "pointField.H"
@ -83,7 +83,7 @@ class ZoneMesh
// Private Member Functions // Private Member Functions
//- Read if IOobject flags set. Return true if read. //- Read if IOobject flags set. Return true if read.
bool read(); bool readContents();
//- Create zone map //- Create zone map
void calcZoneMap() const; void calcZoneMap() const;

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2015-2020 OpenCFD Ltd. Copyright (C) 2015-2022 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -43,6 +43,24 @@ namespace Foam
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
bool Foam::refinementHistory::readContents()
{
if
(
readOpt() == IOobject::MUST_READ
|| readOpt() == IOobject::MUST_READ_IF_MODIFIED
|| (readOpt() == IOobject::READ_IF_PRESENT && headerOk())
)
{
readStream(typeName) >> *this;
close();
return true;
}
return false;
}
void Foam::refinementHistory::writeEntry void Foam::refinementHistory::writeEntry
( (
const List<splitCell8>& splitCells, const List<splitCell8>& splitCells,
@ -554,16 +572,7 @@ Foam::refinementHistory::refinementHistory(const IOobject& io)
// Warn for MUST_READ_IF_MODIFIED // Warn for MUST_READ_IF_MODIFIED
warnNoRereading<refinementHistory>(); warnNoRereading<refinementHistory>();
if readContents();
(
io.readOpt() == IOobject::MUST_READ
|| io.readOpt() == IOobject::MUST_READ_IF_MODIFIED
|| (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
)
{
readStream(typeName) >> *this;
close();
}
// When running in redistributePar + READ_IF_PRESENT it can happen // When running in redistributePar + READ_IF_PRESENT it can happen
// that some processors do have refinementHistory and some don't so // that some processors do have refinementHistory and some don't so
@ -593,22 +602,13 @@ Foam::refinementHistory::refinementHistory
regIOobject(io), regIOobject(io),
active_(active), active_(active),
splitCells_(splitCells), splitCells_(splitCells),
freeSplitCells_(0), freeSplitCells_(),
visibleCells_(visibleCells) visibleCells_(visibleCells)
{ {
// Warn for MUST_READ_IF_MODIFIED // Warn for MUST_READ_IF_MODIFIED
warnNoRereading<refinementHistory>(); warnNoRereading<refinementHistory>();
if readContents();
(
io.readOpt() == IOobject::MUST_READ
|| io.readOpt() == IOobject::MUST_READ_IF_MODIFIED
|| (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
)
{
readStream(typeName) >> *this;
close();
}
// Check indices. // Check indices.
checkIndices(); checkIndices();
@ -633,22 +633,12 @@ Foam::refinementHistory::refinementHistory
: :
regIOobject(io), regIOobject(io),
active_(false), active_(false),
freeSplitCells_(0) freeSplitCells_()
{ {
// Warn for MUST_READ_IF_MODIFIED // Warn for MUST_READ_IF_MODIFIED
warnNoRereading<refinementHistory>(); warnNoRereading<refinementHistory>();
if if (!readContents())
(
io.readOpt() == IOobject::MUST_READ
|| io.readOpt() == IOobject::MUST_READ_IF_MODIFIED
|| (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
)
{
readStream(typeName) >> *this;
close();
}
else
{ {
visibleCells_.setSize(nCells); visibleCells_.setSize(nCells);
splitCells_.setCapacity(nCells); splitCells_.setCapacity(nCells);
@ -688,22 +678,12 @@ Foam::refinementHistory::refinementHistory
: :
regIOobject(io), regIOobject(io),
active_(active), active_(active),
freeSplitCells_(0) freeSplitCells_()
{ {
// Warn for MUST_READ_IF_MODIFIED // Warn for MUST_READ_IF_MODIFIED
warnNoRereading<refinementHistory>(); warnNoRereading<refinementHistory>();
if if (!readContents())
(
io.readOpt() == IOobject::MUST_READ
|| io.readOpt() == IOobject::MUST_READ_IF_MODIFIED
|| (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
)
{
readStream(typeName) >> *this;
close();
}
else
{ {
visibleCells_.setSize(nCells); visibleCells_.setSize(nCells);
splitCells_.setCapacity(nCells); splitCells_.setCapacity(nCells);
@ -870,7 +850,7 @@ Foam::refinementHistory::refinementHistory(const IOobject& io, Istream& is)
: :
regIOobject(io), regIOobject(io),
splitCells_(is), splitCells_(is),
freeSplitCells_(0), freeSplitCells_(),
visibleCells_(is) visibleCells_(is)
{ {
active_ = (returnReduce(visibleCells_.size(), sumOp<label>()) > 0); active_ = (returnReduce(visibleCells_.size(), sumOp<label>()) > 0);

View File

@ -175,6 +175,9 @@ private:
const List<splitCell8>& const List<splitCell8>&
); );
//- Read if IOobject flags set. Return true if read.
bool readContents();
//- Check consistency of structure, i.e. indices into splitCells_. //- Check consistency of structure, i.e. indices into splitCells_.
void checkIndices() const; void checkIndices() const;

View File

@ -42,7 +42,7 @@ namespace Foam
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::polyTopoChanger::readModifiers() bool Foam::polyTopoChanger::readContents()
{ {
if if
( (
@ -51,9 +51,6 @@ void Foam::polyTopoChanger::readModifiers()
|| (readOpt() == IOobject::READ_IF_PRESENT && headerOk()) || (readOpt() == IOobject::READ_IF_PRESENT && headerOk())
) )
{ {
// Warn for MUST_READ_IF_MODIFIED
warnNoRereading<polyTopoChanger>();
PtrList<polyMeshModifier>& modifiers = *this; PtrList<polyMeshModifier>& modifiers = *this;
// Read modifiers // Read modifiers
@ -78,9 +75,11 @@ void Foam::polyTopoChanger::readModifiers()
} }
is.check(FUNCTION_NAME); is.check(FUNCTION_NAME);
close(); close();
return true;
} }
return false;
} }
@ -96,7 +95,10 @@ Foam::polyTopoChanger::polyTopoChanger
regIOobject(io), regIOobject(io),
mesh_(mesh) mesh_(mesh)
{ {
readModifiers(); // Warn for MUST_READ_IF_MODIFIED
warnNoRereading<polyTopoChanger>();
readContents();
} }

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2017-2020 OpenCFD Ltd. Copyright (C) 2017-2022 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -35,8 +35,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#ifndef polyTopoChanger_H #ifndef Foam_polyTopoChanger_H
#define polyTopoChanger_H #define Foam_polyTopoChanger_H
#include "regIOobject.H" #include "regIOobject.H"
#include "PtrList.H" #include "PtrList.H"
@ -67,7 +67,8 @@ class polyTopoChanger
{ {
// Private Member Functions // Private Member Functions
void readModifiers(); //- Read if IOobject flags set, set modifiers. Return true if read.
bool readContents();
//- No copy construct //- No copy construct
polyTopoChanger(const polyTopoChanger&) = delete; polyTopoChanger(const polyTopoChanger&) = delete;

View File

@ -100,22 +100,17 @@ void Foam::faBoundaryMesh::calcGroupIDs() const
} }
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // bool Foam::faBoundaryMesh::readContents(const bool allowReadIfPresent)
Foam::faBoundaryMesh::faBoundaryMesh
(
const IOobject& io,
const faMesh& mesh
)
:
faPatchList(),
regIOobject(io),
mesh_(mesh)
{ {
if if
( (
readOpt() == IOobject::MUST_READ readOpt() == IOobject::MUST_READ
|| readOpt() == IOobject::MUST_READ_IF_MODIFIED || readOpt() == IOobject::MUST_READ_IF_MODIFIED
||
(
allowReadIfPresent
&& (readOpt() == IOobject::READ_IF_PRESENT && headerOk())
)
) )
{ {
// Warn for MUST_READ_IF_MODIFIED // Warn for MUST_READ_IF_MODIFIED
@ -126,9 +121,11 @@ Foam::faBoundaryMesh::faBoundaryMesh
// Read faPatch list // Read faPatch list
Istream& is = readStream(typeName); Istream& is = readStream(typeName);
// Read patches as entries
PtrList<entry> patchEntries(is); PtrList<entry> patchEntries(is);
patches.setSize(patchEntries.size()); patches.resize(patchEntries.size());
// Transcribe
forAll(patches, patchi) forAll(patches, patchi)
{ {
patches.set patches.set
@ -145,9 +142,27 @@ Foam::faBoundaryMesh::faBoundaryMesh
} }
is.check(FUNCTION_NAME); is.check(FUNCTION_NAME);
close(); close();
return true;
} }
return false;
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::faBoundaryMesh::faBoundaryMesh
(
const IOobject& io,
const faMesh& mesh
)
:
faPatchList(),
regIOobject(io),
mesh_(mesh)
{
readContents(false); // READ_IF_PRESENT allowed: False
} }

View File

@ -86,6 +86,9 @@ class faBoundaryMesh
//- Calculate group name to patch ids lookup //- Calculate group name to patch ids lookup
void calcGroupIDs() const; void calcGroupIDs() const;
//- Read if IOobject flags set. Return true if read.
bool readContents(const bool allowReadIfPresent);
//- No copy construct //- No copy construct
faBoundaryMesh(const faBoundaryMesh&) = delete; faBoundaryMesh(const faBoundaryMesh&) = delete;

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2018-2021 OpenCFD Ltd. Copyright (C) 2018-2022 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -86,15 +86,15 @@ void Foam::coordinateSystems::readFromStream(const bool valid)
} }
bool Foam::coordinateSystems::readObject(const IOobject& io) bool Foam::coordinateSystems::readContents()
{ {
if if
( (
( (
io.readOpt() == IOobject::MUST_READ readOpt() == IOobject::MUST_READ
|| io.readOpt() == IOobject::MUST_READ_IF_MODIFIED || readOpt() == IOobject::MUST_READ_IF_MODIFIED
) )
|| (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk()) || (readOpt() == IOobject::READ_IF_PRESENT && headerOk())
) )
{ {
readFromStream(); readFromStream();
@ -105,7 +105,6 @@ bool Foam::coordinateSystems::readObject(const IOobject& io)
} }
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::coordinateSystems::coordinateSystems(const IOobject& io) Foam::coordinateSystems::coordinateSystems(const IOobject& io)
@ -113,7 +112,7 @@ Foam::coordinateSystems::coordinateSystems(const IOobject& io)
regIOobject(io), regIOobject(io),
PtrList<coordinateSystem>() PtrList<coordinateSystem>()
{ {
readObject(io); readContents();
} }
@ -126,7 +125,7 @@ Foam::coordinateSystems::coordinateSystems
regIOobject(io), regIOobject(io),
PtrList<coordinateSystem>() PtrList<coordinateSystem>()
{ {
if (!readObject(io)) if (!readContents())
{ {
static_cast<PtrList<coordinateSystem>&>(*this) = content; static_cast<PtrList<coordinateSystem>&>(*this) = content;
} }
@ -142,7 +141,7 @@ Foam::coordinateSystems::coordinateSystems
regIOobject(io), regIOobject(io),
PtrList<coordinateSystem>(std::move(content)) PtrList<coordinateSystem>(std::move(content))
{ {
readObject(io); readContents();
} }

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2018-2021 OpenCFD Ltd. Copyright (C) 2018-2022 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -59,8 +59,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#ifndef coordinateSystems_H #ifndef Foam_coordinateSystems_H
#define coordinateSystems_H #define Foam_coordinateSystems_H
#include "regIOobject.H" #include "regIOobject.H"
#include "PtrList.H" #include "PtrList.H"
@ -86,10 +86,8 @@ class coordinateSystems
//- Read "coordinateSystems" or older "IOPtrList<coordinateSystem>" //- Read "coordinateSystems" or older "IOPtrList<coordinateSystem>"
void readFromStream(const bool valid = true); void readFromStream(const bool valid = true);
//- Attempt read if MUST_READ.., or READ_IF_PRESENT and has header //- Read if IOobject flags set. Return true if read.
// \return False if no read should have been attempted bool readContents();
bool readObject(const IOobject& io);
//- No copy construct //- No copy construct
coordinateSystems(const coordinateSystems&) = delete; coordinateSystems(const coordinateSystems&) = delete;