ENH: consolidate read handling within various regIOobjects
This commit is contained in:
parent
35106b60c6
commit
4cbe0a81ac
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||
Copyright (C) 2015-2020 OpenCFD Ltd.
|
||||
Copyright (C) 2015-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
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>
|
||||
bool Foam::CompactIOList<T, BaseType>::overflows() const
|
||||
{
|
||||
@ -82,14 +99,7 @@ Foam::CompactIOList<T, BaseType>::CompactIOList(const IOobject& io)
|
||||
:
|
||||
regIOobject(io)
|
||||
{
|
||||
if
|
||||
(
|
||||
io.readOpt() == IOobject::MUST_READ
|
||||
|| (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
|
||||
)
|
||||
{
|
||||
readFromStream();
|
||||
}
|
||||
readContents();
|
||||
}
|
||||
|
||||
|
||||
@ -102,17 +112,9 @@ Foam::CompactIOList<T, BaseType>::CompactIOList
|
||||
:
|
||||
regIOobject(io)
|
||||
{
|
||||
if
|
||||
(
|
||||
io.readOpt() == IOobject::MUST_READ
|
||||
|| (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
|
||||
)
|
||||
if (!readContents())
|
||||
{
|
||||
readFromStream();
|
||||
}
|
||||
else
|
||||
{
|
||||
List<T>::setSize(len);
|
||||
List<T>::resize(len);
|
||||
}
|
||||
}
|
||||
|
||||
@ -126,15 +128,7 @@ Foam::CompactIOList<T, BaseType>::CompactIOList
|
||||
:
|
||||
regIOobject(io)
|
||||
{
|
||||
if
|
||||
(
|
||||
io.readOpt() == IOobject::MUST_READ
|
||||
|| (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
|
||||
)
|
||||
{
|
||||
readFromStream();
|
||||
}
|
||||
else
|
||||
if (!readContents())
|
||||
{
|
||||
List<T>::operator=(content);
|
||||
}
|
||||
@ -152,14 +146,7 @@ Foam::CompactIOList<T, BaseType>::CompactIOList
|
||||
{
|
||||
List<T>::transfer(content);
|
||||
|
||||
if
|
||||
(
|
||||
io.readOpt() == IOobject::MUST_READ
|
||||
|| (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
|
||||
)
|
||||
{
|
||||
readFromStream();
|
||||
}
|
||||
readContents();
|
||||
}
|
||||
|
||||
|
||||
|
@ -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.
|
||||
@ -39,8 +39,8 @@ SourceFiles
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef CompactIOList_H
|
||||
#define CompactIOList_H
|
||||
#ifndef Foam_CompactIOList_H
|
||||
#define Foam_CompactIOList_H
|
||||
|
||||
#include "IOList.H"
|
||||
#include "regIOobject.H"
|
||||
@ -50,7 +50,7 @@ SourceFiles
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward declarations
|
||||
// Forward Declarations
|
||||
class Istream;
|
||||
class Ostream;
|
||||
template<class T, class BaseType> class CompactIOList;
|
||||
@ -81,11 +81,19 @@ class CompactIOList
|
||||
//- Read according to header type
|
||||
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?
|
||||
bool overflows() const;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- The underlying content type
|
||||
typedef List<T> content_type;
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("CompactList");
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||
Copyright (C) 2016-2018 OpenCFD Ltd.
|
||||
Copyright (C) 2016-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -28,6 +28,29 @@ License
|
||||
|
||||
#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 * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
@ -38,18 +61,7 @@ Foam::IOField<Type>::IOField(const IOobject& io)
|
||||
// Check for MUST_READ_IF_MODIFIED
|
||||
warnNoRereading<IOField<Type>>();
|
||||
|
||||
if
|
||||
(
|
||||
(
|
||||
io.readOpt() == IOobject::MUST_READ
|
||||
|| io.readOpt() == IOobject::MUST_READ_IF_MODIFIED
|
||||
)
|
||||
|| (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
|
||||
)
|
||||
{
|
||||
readStream(typeName) >> *this;
|
||||
close();
|
||||
}
|
||||
readContents();
|
||||
}
|
||||
|
||||
|
||||
@ -91,28 +103,16 @@ Foam::IOField<Type>::IOField(const IOobject& io, const bool valid)
|
||||
|
||||
|
||||
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)
|
||||
{
|
||||
// Check for MUST_READ_IF_MODIFIED
|
||||
warnNoRereading<IOField<Type>>();
|
||||
|
||||
if
|
||||
(
|
||||
(
|
||||
io.readOpt() == IOobject::MUST_READ
|
||||
|| io.readOpt() == IOobject::MUST_READ_IF_MODIFIED
|
||||
)
|
||||
|| (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
|
||||
)
|
||||
if (!readContents())
|
||||
{
|
||||
readStream(typeName) >> *this;
|
||||
close();
|
||||
}
|
||||
else
|
||||
{
|
||||
Field<Type>::setSize(size);
|
||||
Field<Type>::resize(len);
|
||||
}
|
||||
}
|
||||
|
||||
@ -125,19 +125,7 @@ Foam::IOField<Type>::IOField(const IOobject& io, const UList<Type>& content)
|
||||
// Check for MUST_READ_IF_MODIFIED
|
||||
warnNoRereading<IOField<Type>>();
|
||||
|
||||
if
|
||||
(
|
||||
(
|
||||
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 (!readContents())
|
||||
{
|
||||
Field<Type>::operator=(content);
|
||||
}
|
||||
@ -154,18 +142,7 @@ Foam::IOField<Type>::IOField(const IOobject& io, Field<Type>&& content)
|
||||
|
||||
Field<Type>::transfer(content);
|
||||
|
||||
if
|
||||
(
|
||||
(
|
||||
io.readOpt() == IOobject::MUST_READ
|
||||
|| io.readOpt() == IOobject::MUST_READ_IF_MODIFIED
|
||||
)
|
||||
|| (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
|
||||
)
|
||||
{
|
||||
readStream(typeName) >> *this;
|
||||
close();
|
||||
}
|
||||
readContents();
|
||||
}
|
||||
|
||||
|
||||
@ -181,19 +158,7 @@ Foam::IOField<Type>::IOField(const IOobject& io, const tmp<Field<Type>>& tfld)
|
||||
Field<Type>::transfer(tfld.ref());
|
||||
}
|
||||
|
||||
if
|
||||
(
|
||||
(
|
||||
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)
|
||||
if (!readContents() && !reuse)
|
||||
{
|
||||
Field<Type>::operator=(tfld());
|
||||
}
|
||||
|
@ -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.
|
||||
@ -35,8 +35,8 @@ SourceFiles
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef IOField_H
|
||||
#define IOField_H
|
||||
#ifndef Foam_IOField_H
|
||||
#define Foam_IOField_H
|
||||
|
||||
#include "regIOobject.H"
|
||||
#include "Field.H"
|
||||
@ -56,8 +56,17 @@ class IOField
|
||||
public regIOobject,
|
||||
public Field<Type>
|
||||
{
|
||||
// Private Member Functions
|
||||
|
||||
//- Read if IOobject flags set. Return true if read.
|
||||
bool readContents();
|
||||
|
||||
public:
|
||||
|
||||
//- The underlying content type
|
||||
typedef Field<Type> content_type;
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("Field");
|
||||
|
||||
|
||||
|
@ -28,6 +28,29 @@ License
|
||||
|
||||
#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 * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class T>
|
||||
@ -38,18 +61,7 @@ Foam::IOList<T>::IOList(const IOobject& io)
|
||||
// Check for MUST_READ_IF_MODIFIED
|
||||
warnNoRereading<IOList<T>>();
|
||||
|
||||
if
|
||||
(
|
||||
(
|
||||
io.readOpt() == IOobject::MUST_READ
|
||||
|| io.readOpt() == IOobject::MUST_READ_IF_MODIFIED
|
||||
)
|
||||
|| (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
|
||||
)
|
||||
{
|
||||
readStream(typeName) >> *this;
|
||||
close();
|
||||
}
|
||||
readContents();
|
||||
}
|
||||
|
||||
|
||||
@ -61,21 +73,9 @@ Foam::IOList<T>::IOList(const IOobject& io, const label len)
|
||||
// Check for MUST_READ_IF_MODIFIED
|
||||
warnNoRereading<IOList<T>>();
|
||||
|
||||
if
|
||||
(
|
||||
(
|
||||
io.readOpt() == IOobject::MUST_READ
|
||||
|| io.readOpt() == IOobject::MUST_READ_IF_MODIFIED
|
||||
)
|
||||
|| (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
|
||||
)
|
||||
if (!readContents())
|
||||
{
|
||||
readStream(typeName) >> *this;
|
||||
close();
|
||||
}
|
||||
else
|
||||
{
|
||||
List<T>::setSize(len);
|
||||
List<T>::resize(len);
|
||||
}
|
||||
}
|
||||
|
||||
@ -88,19 +88,7 @@ Foam::IOList<T>::IOList(const IOobject& io, const UList<T>& content)
|
||||
// Check for MUST_READ_IF_MODIFIED
|
||||
warnNoRereading<IOList<T>>();
|
||||
|
||||
if
|
||||
(
|
||||
(
|
||||
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 (!readContents())
|
||||
{
|
||||
List<T>::operator=(content);
|
||||
}
|
||||
@ -117,18 +105,7 @@ Foam::IOList<T>::IOList(const IOobject& io, List<T>&& content)
|
||||
|
||||
List<T>::transfer(content);
|
||||
|
||||
if
|
||||
(
|
||||
(
|
||||
io.readOpt() == IOobject::MUST_READ
|
||||
|| io.readOpt() == IOobject::MUST_READ_IF_MODIFIED
|
||||
)
|
||||
|| (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
|
||||
)
|
||||
{
|
||||
readStream(typeName) >> *this;
|
||||
close();
|
||||
}
|
||||
readContents();
|
||||
}
|
||||
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2018 OpenCFD Ltd.
|
||||
Copyright (C) 2018-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -35,8 +35,8 @@ SourceFiles
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef IOList_H
|
||||
#define IOList_H
|
||||
#ifndef Foam_IOList_H
|
||||
#define Foam_IOList_H
|
||||
|
||||
#include "List.H"
|
||||
#include "regIOobject.H"
|
||||
@ -56,8 +56,16 @@ class IOList
|
||||
public regIOobject,
|
||||
public List<T>
|
||||
{
|
||||
// Private Member Functions
|
||||
|
||||
//- Read if IOobject flags set. Return true if read.
|
||||
bool readContents();
|
||||
|
||||
public:
|
||||
|
||||
//- The underlying content type
|
||||
typedef List<T> content_type;
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("List");
|
||||
|
||||
@ -96,7 +104,6 @@ public:
|
||||
|
||||
//- Copy or move assignment of entries
|
||||
using List<T>::operator=;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
@ -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.
|
||||
@ -28,6 +28,33 @@ License
|
||||
|
||||
#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 * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class T>
|
||||
@ -35,46 +62,18 @@ Foam::IOMap<T>::IOMap(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())
|
||||
)
|
||||
{
|
||||
// For if MUST_READ_IF_MODIFIED
|
||||
addWatch();
|
||||
|
||||
readStream(typeName) >> *this;
|
||||
close();
|
||||
}
|
||||
readContents();
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
Foam::IOMap<T>::IOMap(const IOobject& io, const label size)
|
||||
:
|
||||
regIOobject(io)
|
||||
{
|
||||
if
|
||||
(
|
||||
(
|
||||
io.readOpt() == IOobject::MUST_READ
|
||||
|| io.readOpt() == IOobject::MUST_READ_IF_MODIFIED
|
||||
)
|
||||
|| (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
|
||||
)
|
||||
if (!readContents())
|
||||
{
|
||||
// For if MUST_READ_IF_MODIFIED
|
||||
addWatch();
|
||||
|
||||
readStream(typeName) >> *this;
|
||||
close();
|
||||
}
|
||||
else
|
||||
{
|
||||
Map<T>::setSize(size);
|
||||
Map<T>::resize(size);
|
||||
}
|
||||
}
|
||||
|
||||
@ -84,22 +83,7 @@ Foam::IOMap<T>::IOMap(const IOobject& io, const Map<T>& content)
|
||||
:
|
||||
regIOobject(io)
|
||||
{
|
||||
if
|
||||
(
|
||||
(
|
||||
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
|
||||
if (!readContents())
|
||||
{
|
||||
Map<T>::operator=(content);
|
||||
}
|
||||
@ -113,21 +97,7 @@ Foam::IOMap<T>::IOMap(const IOobject& io, Map<T>&& content)
|
||||
{
|
||||
Map<T>::transfer(content);
|
||||
|
||||
if
|
||||
(
|
||||
(
|
||||
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();
|
||||
}
|
||||
readContents();
|
||||
}
|
||||
|
||||
|
||||
|
@ -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,8 +36,8 @@ SourceFiles
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef IOMap_H
|
||||
#define IOMap_H
|
||||
#ifndef Foam_IOMap_H
|
||||
#define Foam_IOMap_H
|
||||
|
||||
#include "Map.H"
|
||||
#include "regIOobject.H"
|
||||
@ -57,8 +57,16 @@ class IOMap
|
||||
public regIOobject,
|
||||
public Map<T>
|
||||
{
|
||||
// Private Member Functions
|
||||
|
||||
//- Read if IOobject flags set. Return true if read.
|
||||
bool readContents();
|
||||
|
||||
public:
|
||||
|
||||
//- The underlying content type
|
||||
typedef Map<T> content_type;
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("Map");
|
||||
|
||||
@ -102,6 +110,7 @@ public:
|
||||
return globalFilePath(type());
|
||||
}
|
||||
|
||||
|
||||
// Member Operators
|
||||
|
||||
//- Copy assignment of entries
|
||||
|
@ -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 * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::IOmapDistribute::IOmapDistribute(const IOobject& io)
|
||||
@ -45,18 +67,7 @@ Foam::IOmapDistribute::IOmapDistribute(const IOobject& io)
|
||||
// Warn for MUST_READ_IF_MODIFIED
|
||||
warnNoRereading<IOmapDistribute>();
|
||||
|
||||
if
|
||||
(
|
||||
(
|
||||
io.readOpt() == IOobject::MUST_READ
|
||||
|| io.readOpt() == IOobject::MUST_READ_IF_MODIFIED
|
||||
)
|
||||
|| (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
|
||||
)
|
||||
{
|
||||
readStream(typeName) >> *this;
|
||||
close();
|
||||
}
|
||||
readContents();
|
||||
}
|
||||
|
||||
|
||||
@ -71,19 +82,7 @@ Foam::IOmapDistribute::IOmapDistribute
|
||||
// Warn for MUST_READ_IF_MODIFIED
|
||||
warnNoRereading<IOmapDistribute>();
|
||||
|
||||
if
|
||||
(
|
||||
(
|
||||
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 (!readContents())
|
||||
{
|
||||
mapDistribute::operator=(map);
|
||||
}
|
||||
@ -103,18 +102,7 @@ Foam::IOmapDistribute::IOmapDistribute
|
||||
|
||||
mapDistribute::transfer(map);
|
||||
|
||||
if
|
||||
(
|
||||
(
|
||||
io.readOpt() == IOobject::MUST_READ
|
||||
|| io.readOpt() == IOobject::MUST_READ_IF_MODIFIED
|
||||
)
|
||||
|| (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
|
||||
)
|
||||
{
|
||||
readStream(typeName) >> *this;
|
||||
close();
|
||||
}
|
||||
readContents();
|
||||
}
|
||||
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2014 OpenFOAM Foundation
|
||||
Copyright (C) 2018 OpenCFD Ltd.
|
||||
Copyright (C) 2018-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -37,8 +37,8 @@ SourceFiles
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef IOmapDistribute_H
|
||||
#define IOmapDistribute_H
|
||||
#ifndef Foam_IOmapDistribute_H
|
||||
#define Foam_IOmapDistribute_H
|
||||
|
||||
#include "mapDistribute.H"
|
||||
#include "regIOobject.H"
|
||||
@ -57,6 +57,10 @@ class IOmapDistribute
|
||||
public regIOobject,
|
||||
public mapDistribute
|
||||
{
|
||||
// Private Member Functions
|
||||
|
||||
//- Read if IOobject flags set. Return true if read.
|
||||
bool readContents();
|
||||
|
||||
public:
|
||||
|
||||
@ -65,13 +69,13 @@ public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct given an IOobject
|
||||
//- Construct from IOobject
|
||||
IOmapDistribute(const IOobject& io);
|
||||
|
||||
//- Construct given an IOobject, copying mapDistribute contents
|
||||
//- Construct from IOobject, copying mapDistribute contents
|
||||
IOmapDistribute(const IOobject& io, const mapDistribute& map);
|
||||
|
||||
//- Construct, moving mapDistribute contents
|
||||
//- Construct from IOobject, moving mapDistribute contents
|
||||
IOmapDistribute(const IOobject& io, mapDistribute&& map);
|
||||
|
||||
|
||||
@ -79,14 +83,13 @@ public:
|
||||
virtual ~IOmapDistribute() = default;
|
||||
|
||||
|
||||
// Member functions
|
||||
// Member Functions
|
||||
|
||||
//- ReadData function required for regIOobject read operation
|
||||
virtual bool readData(Istream&);
|
||||
|
||||
//- WriteData function required for regIOobject write operation
|
||||
virtual bool writeData(Ostream&) const;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
@ -6,6 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2015 OpenFOAM Foundation
|
||||
Copyright (C) 2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -31,7 +32,29 @@ License
|
||||
|
||||
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
|
||||
warnNoRereading<IOmapDistributePolyMesh>();
|
||||
|
||||
if
|
||||
(
|
||||
(
|
||||
io.readOpt() == IOobject::MUST_READ
|
||||
|| io.readOpt() == IOobject::MUST_READ_IF_MODIFIED
|
||||
)
|
||||
|| (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
|
||||
)
|
||||
{
|
||||
readStream(typeName) >> *this;
|
||||
close();
|
||||
}
|
||||
readContents();
|
||||
}
|
||||
|
||||
|
||||
@ -70,19 +82,7 @@ Foam::IOmapDistributePolyMesh::IOmapDistributePolyMesh
|
||||
// Warn for MUST_READ_IF_MODIFIED
|
||||
warnNoRereading<IOmapDistributePolyMesh>();
|
||||
|
||||
if
|
||||
(
|
||||
(
|
||||
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 (!readContents())
|
||||
{
|
||||
mapDistributePolyMesh::operator=(map);
|
||||
}
|
||||
@ -102,18 +102,7 @@ Foam::IOmapDistributePolyMesh::IOmapDistributePolyMesh
|
||||
|
||||
mapDistributePolyMesh::transfer(map);
|
||||
|
||||
if
|
||||
(
|
||||
(
|
||||
io.readOpt() == IOobject::MUST_READ
|
||||
|| io.readOpt() == IOobject::MUST_READ_IF_MODIFIED
|
||||
)
|
||||
|| (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
|
||||
)
|
||||
{
|
||||
readStream(typeName) >> *this;
|
||||
close();
|
||||
}
|
||||
readContents();
|
||||
}
|
||||
|
||||
|
||||
|
@ -6,6 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2015 OpenFOAM Foundation
|
||||
Copyright (C) 2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -36,8 +37,8 @@ SourceFiles
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef IOmapDistributePolyMesh_H
|
||||
#define IOmapDistributePolyMesh_H
|
||||
#ifndef Foam_IOmapDistributePolyMesh_H
|
||||
#define Foam_IOmapDistributePolyMesh_H
|
||||
|
||||
#include "mapDistributePolyMesh.H"
|
||||
#include "regIOobject.H"
|
||||
@ -56,25 +57,30 @@ class IOmapDistributePolyMesh
|
||||
public regIOobject,
|
||||
public mapDistributePolyMesh
|
||||
{
|
||||
// Private Member Functions
|
||||
|
||||
//- Read if IOobject flags set. Return true if read.
|
||||
bool readContents();
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("mapDistributePolyMesh");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct given an IOobject
|
||||
IOmapDistributePolyMesh(const IOobject& io);
|
||||
//- Construct from IOobject
|
||||
explicit IOmapDistributePolyMesh(const IOobject& io);
|
||||
|
||||
//- Construct given an IOobject and mapDistributePolyMesh
|
||||
//- Construct from IOobject, copying mapDistributePolyMesh contents
|
||||
IOmapDistributePolyMesh
|
||||
(
|
||||
const IOobject& io,
|
||||
const mapDistributePolyMesh& map
|
||||
);
|
||||
|
||||
//- Construct given an IOobject and mapDistributePolyMesh
|
||||
//- Construct from IOobject, moving mapDistributePolyMesh contents
|
||||
IOmapDistributePolyMesh
|
||||
(
|
||||
const IOobject& io,
|
||||
@ -93,7 +99,6 @@ public:
|
||||
|
||||
//- The writeData method for regIOobject write operation
|
||||
virtual bool writeData(Ostream& os) const;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
@ -107,22 +107,17 @@ void Foam::polyBoundaryMesh::calcGroupIDs() const
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::polyBoundaryMesh::polyBoundaryMesh
|
||||
(
|
||||
const IOobject& io,
|
||||
const polyMesh& mesh
|
||||
)
|
||||
:
|
||||
polyPatchList(),
|
||||
regIOobject(io),
|
||||
mesh_(mesh)
|
||||
bool Foam::polyBoundaryMesh::readContents(const bool allowReadIfPresent)
|
||||
{
|
||||
if
|
||||
(
|
||||
readOpt() == IOobject::MUST_READ
|
||||
|| readOpt() == IOobject::MUST_READ_IF_MODIFIED
|
||||
this->readOpt() == IOobject::MUST_READ
|
||||
|| this->readOpt() == IOobject::MUST_READ_IF_MODIFIED
|
||||
||
|
||||
(
|
||||
allowReadIfPresent
|
||||
&& (this->readOpt() == IOobject::READ_IF_PRESENT && this->headerOk())
|
||||
)
|
||||
)
|
||||
{
|
||||
// Warn for MUST_READ_IF_MODIFIED
|
||||
@ -133,9 +128,11 @@ Foam::polyBoundaryMesh::polyBoundaryMesh
|
||||
// Read polyPatchList
|
||||
Istream& is = readStream(typeName);
|
||||
|
||||
// Read patches as entries
|
||||
PtrList<entry> patchEntries(is);
|
||||
patches.setSize(patchEntries.size());
|
||||
patches.resize(patchEntries.size());
|
||||
|
||||
// Transcribe
|
||||
forAll(patches, patchi)
|
||||
{
|
||||
patches.set
|
||||
@ -152,9 +149,27 @@ Foam::polyBoundaryMesh::polyBoundaryMesh
|
||||
}
|
||||
|
||||
is.check(FUNCTION_NAME);
|
||||
|
||||
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),
|
||||
mesh_(pm)
|
||||
{
|
||||
if
|
||||
(
|
||||
(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
|
||||
if (!readContents(true)) // READ_IF_PRESENT allowed: True
|
||||
{
|
||||
polyPatchList& patches = *this;
|
||||
patches.setSize(ppl.size());
|
||||
patches.resize(ppl.size());
|
||||
forAll(patches, patchi)
|
||||
{
|
||||
patches.set(patchi, ppl[patchi].clone(*this));
|
||||
|
@ -91,6 +91,9 @@ class polyBoundaryMesh
|
||||
//- Calculate group name to patch ids lookup
|
||||
void calcGroupIDs() const;
|
||||
|
||||
//- Read if IOobject flags set. Return true if read.
|
||||
bool readContents(const bool allowReadIfPresent);
|
||||
|
||||
//- No copy construct
|
||||
polyBoundaryMesh(const polyBoundaryMesh&) = delete;
|
||||
|
||||
|
@ -152,7 +152,7 @@ void Foam::ZoneMesh<ZoneType, MeshType>::calcGroupIDs() const
|
||||
|
||||
|
||||
template<class ZoneType, class MeshType>
|
||||
bool Foam::ZoneMesh<ZoneType, MeshType>::read()
|
||||
bool Foam::ZoneMesh<ZoneType, MeshType>::readContents()
|
||||
{
|
||||
if
|
||||
(
|
||||
@ -166,12 +166,13 @@ bool Foam::ZoneMesh<ZoneType, MeshType>::read()
|
||||
|
||||
PtrList<ZoneType>& zones = *this;
|
||||
|
||||
// Read zones
|
||||
// Read zones as entries
|
||||
Istream& is = readStream(typeName);
|
||||
|
||||
PtrList<entry> patchEntries(is);
|
||||
zones.resize(patchEntries.size());
|
||||
|
||||
// Transcribe
|
||||
forAll(zones, zonei)
|
||||
{
|
||||
zones.set
|
||||
@ -187,11 +188,8 @@ bool Foam::ZoneMesh<ZoneType, MeshType>::read()
|
||||
);
|
||||
}
|
||||
|
||||
// Check state of IOstream
|
||||
is.check(FUNCTION_NAME);
|
||||
|
||||
close();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -213,7 +211,7 @@ Foam::ZoneMesh<ZoneType, MeshType>::ZoneMesh
|
||||
regIOobject(io),
|
||||
mesh_(mesh)
|
||||
{
|
||||
read();
|
||||
readContents();
|
||||
}
|
||||
|
||||
|
||||
@ -230,7 +228,7 @@ Foam::ZoneMesh<ZoneType, MeshType>::ZoneMesh
|
||||
mesh_(mesh)
|
||||
{
|
||||
// Optionally read contents, otherwise keep size
|
||||
read();
|
||||
readContents();
|
||||
}
|
||||
|
||||
|
||||
@ -246,7 +244,7 @@ Foam::ZoneMesh<ZoneType, MeshType>::ZoneMesh
|
||||
regIOobject(io),
|
||||
mesh_(mesh)
|
||||
{
|
||||
if (!read())
|
||||
if (!readContents())
|
||||
{
|
||||
// Nothing read. Use supplied zones
|
||||
PtrList<ZoneType>& zones = *this;
|
||||
|
@ -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.
|
||||
@ -35,8 +35,8 @@ SourceFiles
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef ZoneMesh_H
|
||||
#define ZoneMesh_H
|
||||
#ifndef Foam_ZoneMesh_H
|
||||
#define Foam_ZoneMesh_H
|
||||
|
||||
#include "regIOobject.H"
|
||||
#include "pointField.H"
|
||||
@ -83,7 +83,7 @@ class ZoneMesh
|
||||
// Private Member Functions
|
||||
|
||||
//- Read if IOobject flags set. Return true if read.
|
||||
bool read();
|
||||
bool readContents();
|
||||
|
||||
//- Create zone map
|
||||
void calcZoneMap() const;
|
||||
|
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||
Copyright (C) 2015-2020 OpenCFD Ltd.
|
||||
Copyright (C) 2015-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -43,6 +43,24 @@ namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * 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
|
||||
(
|
||||
const List<splitCell8>& splitCells,
|
||||
@ -554,16 +572,7 @@ Foam::refinementHistory::refinementHistory(const IOobject& io)
|
||||
// Warn for MUST_READ_IF_MODIFIED
|
||||
warnNoRereading<refinementHistory>();
|
||||
|
||||
if
|
||||
(
|
||||
io.readOpt() == IOobject::MUST_READ
|
||||
|| io.readOpt() == IOobject::MUST_READ_IF_MODIFIED
|
||||
|| (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
|
||||
)
|
||||
{
|
||||
readStream(typeName) >> *this;
|
||||
close();
|
||||
}
|
||||
readContents();
|
||||
|
||||
// When running in redistributePar + READ_IF_PRESENT it can happen
|
||||
// that some processors do have refinementHistory and some don't so
|
||||
@ -593,22 +602,13 @@ Foam::refinementHistory::refinementHistory
|
||||
regIOobject(io),
|
||||
active_(active),
|
||||
splitCells_(splitCells),
|
||||
freeSplitCells_(0),
|
||||
freeSplitCells_(),
|
||||
visibleCells_(visibleCells)
|
||||
{
|
||||
// Warn for MUST_READ_IF_MODIFIED
|
||||
warnNoRereading<refinementHistory>();
|
||||
|
||||
if
|
||||
(
|
||||
io.readOpt() == IOobject::MUST_READ
|
||||
|| io.readOpt() == IOobject::MUST_READ_IF_MODIFIED
|
||||
|| (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
|
||||
)
|
||||
{
|
||||
readStream(typeName) >> *this;
|
||||
close();
|
||||
}
|
||||
readContents();
|
||||
|
||||
// Check indices.
|
||||
checkIndices();
|
||||
@ -633,22 +633,12 @@ Foam::refinementHistory::refinementHistory
|
||||
:
|
||||
regIOobject(io),
|
||||
active_(false),
|
||||
freeSplitCells_(0)
|
||||
freeSplitCells_()
|
||||
{
|
||||
// Warn for MUST_READ_IF_MODIFIED
|
||||
warnNoRereading<refinementHistory>();
|
||||
|
||||
if
|
||||
(
|
||||
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 (!readContents())
|
||||
{
|
||||
visibleCells_.setSize(nCells);
|
||||
splitCells_.setCapacity(nCells);
|
||||
@ -688,22 +678,12 @@ Foam::refinementHistory::refinementHistory
|
||||
:
|
||||
regIOobject(io),
|
||||
active_(active),
|
||||
freeSplitCells_(0)
|
||||
freeSplitCells_()
|
||||
{
|
||||
// Warn for MUST_READ_IF_MODIFIED
|
||||
warnNoRereading<refinementHistory>();
|
||||
|
||||
if
|
||||
(
|
||||
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 (!readContents())
|
||||
{
|
||||
visibleCells_.setSize(nCells);
|
||||
splitCells_.setCapacity(nCells);
|
||||
@ -870,7 +850,7 @@ Foam::refinementHistory::refinementHistory(const IOobject& io, Istream& is)
|
||||
:
|
||||
regIOobject(io),
|
||||
splitCells_(is),
|
||||
freeSplitCells_(0),
|
||||
freeSplitCells_(),
|
||||
visibleCells_(is)
|
||||
{
|
||||
active_ = (returnReduce(visibleCells_.size(), sumOp<label>()) > 0);
|
||||
|
@ -175,6 +175,9 @@ private:
|
||||
const List<splitCell8>&
|
||||
);
|
||||
|
||||
//- Read if IOobject flags set. Return true if read.
|
||||
bool readContents();
|
||||
|
||||
//- Check consistency of structure, i.e. indices into splitCells_.
|
||||
void checkIndices() const;
|
||||
|
||||
|
@ -42,7 +42,7 @@ namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::polyTopoChanger::readModifiers()
|
||||
bool Foam::polyTopoChanger::readContents()
|
||||
{
|
||||
if
|
||||
(
|
||||
@ -51,9 +51,6 @@ void Foam::polyTopoChanger::readModifiers()
|
||||
|| (readOpt() == IOobject::READ_IF_PRESENT && headerOk())
|
||||
)
|
||||
{
|
||||
// Warn for MUST_READ_IF_MODIFIED
|
||||
warnNoRereading<polyTopoChanger>();
|
||||
|
||||
PtrList<polyMeshModifier>& modifiers = *this;
|
||||
|
||||
// Read modifiers
|
||||
@ -78,9 +75,11 @@ void Foam::polyTopoChanger::readModifiers()
|
||||
}
|
||||
|
||||
is.check(FUNCTION_NAME);
|
||||
|
||||
close();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@ -96,7 +95,10 @@ Foam::polyTopoChanger::polyTopoChanger
|
||||
regIOobject(io),
|
||||
mesh_(mesh)
|
||||
{
|
||||
readModifiers();
|
||||
// Warn for MUST_READ_IF_MODIFIED
|
||||
warnNoRereading<polyTopoChanger>();
|
||||
|
||||
readContents();
|
||||
}
|
||||
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2017-2020 OpenCFD Ltd.
|
||||
Copyright (C) 2017-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -35,8 +35,8 @@ SourceFiles
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef polyTopoChanger_H
|
||||
#define polyTopoChanger_H
|
||||
#ifndef Foam_polyTopoChanger_H
|
||||
#define Foam_polyTopoChanger_H
|
||||
|
||||
#include "regIOobject.H"
|
||||
#include "PtrList.H"
|
||||
@ -67,7 +67,8 @@ class polyTopoChanger
|
||||
{
|
||||
// Private Member Functions
|
||||
|
||||
void readModifiers();
|
||||
//- Read if IOobject flags set, set modifiers. Return true if read.
|
||||
bool readContents();
|
||||
|
||||
//- No copy construct
|
||||
polyTopoChanger(const polyTopoChanger&) = delete;
|
||||
|
@ -100,22 +100,17 @@ void Foam::faBoundaryMesh::calcGroupIDs() const
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::faBoundaryMesh::faBoundaryMesh
|
||||
(
|
||||
const IOobject& io,
|
||||
const faMesh& mesh
|
||||
)
|
||||
:
|
||||
faPatchList(),
|
||||
regIOobject(io),
|
||||
mesh_(mesh)
|
||||
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())
|
||||
)
|
||||
)
|
||||
{
|
||||
// Warn for MUST_READ_IF_MODIFIED
|
||||
@ -126,9 +121,11 @@ Foam::faBoundaryMesh::faBoundaryMesh
|
||||
// Read faPatch list
|
||||
Istream& is = readStream(typeName);
|
||||
|
||||
// Read patches as entries
|
||||
PtrList<entry> patchEntries(is);
|
||||
patches.setSize(patchEntries.size());
|
||||
patches.resize(patchEntries.size());
|
||||
|
||||
// Transcribe
|
||||
forAll(patches, patchi)
|
||||
{
|
||||
patches.set
|
||||
@ -145,9 +142,27 @@ Foam::faBoundaryMesh::faBoundaryMesh
|
||||
}
|
||||
|
||||
is.check(FUNCTION_NAME);
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
|
||||
|
@ -86,6 +86,9 @@ class faBoundaryMesh
|
||||
//- Calculate group name to patch ids lookup
|
||||
void calcGroupIDs() const;
|
||||
|
||||
//- Read if IOobject flags set. Return true if read.
|
||||
bool readContents(const bool allowReadIfPresent);
|
||||
|
||||
//- No copy construct
|
||||
faBoundaryMesh(const faBoundaryMesh&) = delete;
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2018-2021 OpenCFD Ltd.
|
||||
Copyright (C) 2018-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
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
|
||||
(
|
||||
(
|
||||
io.readOpt() == IOobject::MUST_READ
|
||||
|| io.readOpt() == IOobject::MUST_READ_IF_MODIFIED
|
||||
readOpt() == IOobject::MUST_READ
|
||||
|| readOpt() == IOobject::MUST_READ_IF_MODIFIED
|
||||
)
|
||||
|| (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
|
||||
|| (readOpt() == IOobject::READ_IF_PRESENT && headerOk())
|
||||
)
|
||||
{
|
||||
readFromStream();
|
||||
@ -105,7 +105,6 @@ bool Foam::coordinateSystems::readObject(const IOobject& io)
|
||||
}
|
||||
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::coordinateSystems::coordinateSystems(const IOobject& io)
|
||||
@ -113,7 +112,7 @@ Foam::coordinateSystems::coordinateSystems(const IOobject& io)
|
||||
regIOobject(io),
|
||||
PtrList<coordinateSystem>()
|
||||
{
|
||||
readObject(io);
|
||||
readContents();
|
||||
}
|
||||
|
||||
|
||||
@ -126,7 +125,7 @@ Foam::coordinateSystems::coordinateSystems
|
||||
regIOobject(io),
|
||||
PtrList<coordinateSystem>()
|
||||
{
|
||||
if (!readObject(io))
|
||||
if (!readContents())
|
||||
{
|
||||
static_cast<PtrList<coordinateSystem>&>(*this) = content;
|
||||
}
|
||||
@ -142,7 +141,7 @@ Foam::coordinateSystems::coordinateSystems
|
||||
regIOobject(io),
|
||||
PtrList<coordinateSystem>(std::move(content))
|
||||
{
|
||||
readObject(io);
|
||||
readContents();
|
||||
}
|
||||
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2018-2021 OpenCFD Ltd.
|
||||
Copyright (C) 2018-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -59,8 +59,8 @@ SourceFiles
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef coordinateSystems_H
|
||||
#define coordinateSystems_H
|
||||
#ifndef Foam_coordinateSystems_H
|
||||
#define Foam_coordinateSystems_H
|
||||
|
||||
#include "regIOobject.H"
|
||||
#include "PtrList.H"
|
||||
@ -86,10 +86,8 @@ class coordinateSystems
|
||||
//- Read "coordinateSystems" or older "IOPtrList<coordinateSystem>"
|
||||
void readFromStream(const bool valid = true);
|
||||
|
||||
//- Attempt read if MUST_READ.., or READ_IF_PRESENT and has header
|
||||
// \return False if no read should have been attempted
|
||||
bool readObject(const IOobject& io);
|
||||
|
||||
//- Read if IOobject flags set. Return true if read.
|
||||
bool readContents();
|
||||
|
||||
//- No copy construct
|
||||
coordinateSystems(const coordinateSystems&) = delete;
|
||||
|
Loading…
Reference in New Issue
Block a user