mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: zero tag for constructing various IO types
- for int64 compilations this disambiguates between '0' as int32 (size)
or as bool 'false' for local processor validity
Eg,
IOList list(io, 0); <- With label-size 64: is this bool or label?
IOList list(io, Zero); <- Size = 0 (int32/int64), not a bool
This commit is contained in:
@ -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.
|
||||
@ -51,9 +51,9 @@ void Foam::CompactIOField<T, BaseType>::readFromStream(const bool valid)
|
||||
else
|
||||
{
|
||||
FatalIOErrorInFunction(is)
|
||||
<< "unexpected class name " << headerClassName()
|
||||
<< " expected " << typeName << " or " << IOField<T>::typeName
|
||||
<< endl
|
||||
<< "Unexpected class name " << headerClassName()
|
||||
<< " expected " << typeName
|
||||
<< " or " << IOField<T>::typeName << nl
|
||||
<< " while reading object " << name()
|
||||
<< exit(FatalIOError);
|
||||
}
|
||||
@ -104,7 +104,27 @@ template<class T, class BaseType>
|
||||
Foam::CompactIOField<T, BaseType>::CompactIOField
|
||||
(
|
||||
const IOobject& io,
|
||||
const label size
|
||||
Foam::zero
|
||||
)
|
||||
:
|
||||
regIOobject(io)
|
||||
{
|
||||
if
|
||||
(
|
||||
io.readOpt() == IOobject::MUST_READ
|
||||
|| (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
|
||||
)
|
||||
{
|
||||
readFromStream();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class T, class BaseType>
|
||||
Foam::CompactIOField<T, BaseType>::CompactIOField
|
||||
(
|
||||
const IOobject& io,
|
||||
const label len
|
||||
)
|
||||
:
|
||||
regIOobject(io)
|
||||
@ -119,7 +139,7 @@ Foam::CompactIOField<T, BaseType>::CompactIOField
|
||||
}
|
||||
else
|
||||
{
|
||||
Field<T>::setSize(size);
|
||||
Field<T>::resize(len);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -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.
|
||||
@ -39,18 +39,17 @@ SourceFiles
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef CompactIOField_H
|
||||
#define CompactIOField_H
|
||||
#ifndef Foam_CompactIOField_H
|
||||
#define Foam_CompactIOField_H
|
||||
|
||||
#include "IOField.H"
|
||||
#include "regIOobject.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward declarations
|
||||
// Forward Declarations
|
||||
template<class T, class BaseType> class CompactIOField;
|
||||
|
||||
template<class T, class BaseType> Istream& operator>>
|
||||
@ -94,11 +93,14 @@ public:
|
||||
//- Construct from IOobject
|
||||
explicit CompactIOField(const IOobject& io);
|
||||
|
||||
//- Construct from IOobject; does local processor require reading?
|
||||
//- Construct from IOobject, with local processor conditional reading
|
||||
CompactIOField(const IOobject& io, const bool valid);
|
||||
|
||||
//- Construct from IOobject and size
|
||||
CompactIOField(const IOobject& io, const label size);
|
||||
//- Construct from IOobject and zero size (if not read)
|
||||
CompactIOField(const IOobject& io, Foam::zero);
|
||||
|
||||
//- Construct from IOobject and size (if not read)
|
||||
CompactIOField(const IOobject& io, const label len);
|
||||
|
||||
//- Construct from IOobject and a List/Field content
|
||||
CompactIOField(const IOobject& io, const UList<T>& content);
|
||||
|
||||
@ -103,6 +103,19 @@ Foam::CompactIOList<T, BaseType>::CompactIOList(const IOobject& io)
|
||||
}
|
||||
|
||||
|
||||
template<class T, class BaseType>
|
||||
Foam::CompactIOList<T, BaseType>::CompactIOList
|
||||
(
|
||||
const IOobject& io,
|
||||
Foam::zero
|
||||
)
|
||||
:
|
||||
regIOobject(io)
|
||||
{
|
||||
readContents();
|
||||
}
|
||||
|
||||
|
||||
template<class T, class BaseType>
|
||||
Foam::CompactIOList<T, BaseType>::CompactIOList
|
||||
(
|
||||
|
||||
@ -67,7 +67,7 @@ template<class T, class BaseType> Ostream& operator<<
|
||||
);
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class CompactIOList Declaration
|
||||
Class CompactIOList Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class T, class BaseType>
|
||||
@ -106,6 +106,9 @@ public:
|
||||
//- Construct from IOobject
|
||||
explicit CompactIOList(const IOobject& io);
|
||||
|
||||
//- Construct from IOobject and zero size (if not read)
|
||||
CompactIOList(const IOobject& io, Foam::zero);
|
||||
|
||||
//- Construct from IOobject and default length of CompactIOList
|
||||
CompactIOList(const IOobject& io, const label len);
|
||||
|
||||
@ -115,9 +118,9 @@ public:
|
||||
//- Construct by transferring the List content
|
||||
CompactIOList(const IOobject& io, List<T>&& content);
|
||||
|
||||
// Destructor
|
||||
|
||||
virtual ~CompactIOList() = default;
|
||||
//- Destructor
|
||||
virtual ~CompactIOList() = default;
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2015 OpenFOAM Foundation
|
||||
Copyright (C) 2016-2018 OpenCFD Ltd.
|
||||
Copyright (C) 2016-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -43,7 +43,19 @@ Foam::GlobalIOList<Type>::GlobalIOList(const IOobject& io)
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::GlobalIOList<Type>::GlobalIOList(const IOobject& io, const label size)
|
||||
Foam::GlobalIOList<Type>::GlobalIOList(const IOobject& io, Foam::zero)
|
||||
:
|
||||
regIOobject(io)
|
||||
{
|
||||
// Check for MUST_READ_IF_MODIFIED
|
||||
warnNoRereading<GlobalIOList<Type>>();
|
||||
|
||||
readHeaderOk(IOstream::BINARY, typeName);
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::GlobalIOList<Type>::GlobalIOList(const IOobject& io, const label len)
|
||||
:
|
||||
regIOobject(io)
|
||||
{
|
||||
@ -52,7 +64,7 @@ Foam::GlobalIOList<Type>::GlobalIOList(const IOobject& io, const label size)
|
||||
|
||||
if (!readHeaderOk(IOstream::BINARY, typeName))
|
||||
{
|
||||
List<Type>::setSize(size);
|
||||
List<Type>::resize(len);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2015-2017 OpenFOAM Foundation
|
||||
Copyright (C) 2018 OpenCFD Ltd.
|
||||
Copyright (C) 2018-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -69,8 +69,11 @@ public:
|
||||
//- Construct from IOobject
|
||||
explicit GlobalIOList(const IOobject& io);
|
||||
|
||||
//- Construct from IOobject
|
||||
GlobalIOList(const IOobject& io, const label size);
|
||||
//- Construct from IOobject and zero size (if not read)
|
||||
GlobalIOList(const IOobject& io, Foam::zero);
|
||||
|
||||
//- Construct from IOobject and list size (if not read)
|
||||
GlobalIOList(const IOobject& io, const label len);
|
||||
|
||||
//- Construct from IOobject and a List
|
||||
GlobalIOList(const IOobject& io, const UList<Type>& content);
|
||||
|
||||
@ -102,6 +102,18 @@ Foam::IOField<Type>::IOField(const IOobject& io, const bool valid)
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::IOField<Type>::IOField(const IOobject& io, Foam::zero)
|
||||
:
|
||||
regIOobject(io)
|
||||
{
|
||||
// Check for MUST_READ_IF_MODIFIED
|
||||
warnNoRereading<IOField<Type>>();
|
||||
|
||||
readContents();
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::IOField<Type>::IOField(const IOobject& io, const label len)
|
||||
:
|
||||
|
||||
@ -79,13 +79,16 @@ public:
|
||||
//- Construct from IOobject
|
||||
explicit IOField(const IOobject& io);
|
||||
|
||||
//- Construct from IOobject; does local processor require reading?
|
||||
//- Construct from IOobject, with local processor conditional reading
|
||||
IOField(const IOobject& io, const bool valid);
|
||||
|
||||
//- Construct from IOobject and size (does not set values)
|
||||
IOField(const IOobject& io, const label size);
|
||||
//- Construct from IOobject and zero size (if not read)
|
||||
IOField(const IOobject& io, Foam::zero);
|
||||
|
||||
//- Construct from IOobject and a List/Field content
|
||||
//- Construct from IOobject and field size (if not read)
|
||||
IOField(const IOobject& io, const label len);
|
||||
|
||||
//- Construct from IOobject and copy of List/Field content
|
||||
IOField(const IOobject& io, const UList<Type>& content);
|
||||
|
||||
//- Construct by transferring the Field content
|
||||
|
||||
@ -65,6 +65,18 @@ Foam::IOList<T>::IOList(const IOobject& io)
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
Foam::IOList<T>::IOList(const IOobject& io, Foam::zero)
|
||||
:
|
||||
regIOobject(io)
|
||||
{
|
||||
// Check for MUST_READ_IF_MODIFIED
|
||||
warnNoRereading<IOList<T>>();
|
||||
|
||||
readContents();
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
Foam::IOList<T>::IOList(const IOobject& io, const label len)
|
||||
:
|
||||
|
||||
@ -79,13 +79,16 @@ public:
|
||||
//- Construct from IOobject
|
||||
explicit IOList(const IOobject& io);
|
||||
|
||||
//- Construct from IOobject and size of IOList
|
||||
//- Construct from IOobject and zero size (if not read)
|
||||
IOList(const IOobject& io, Foam::zero);
|
||||
|
||||
//- Construct from IOobject and list size (if not read)
|
||||
IOList(const IOobject& io, const label len);
|
||||
|
||||
//- Construct from IOobject and a copy of UList content
|
||||
//- Construct from IOobject and a copy of content
|
||||
IOList(const IOobject& io, const UList<T>& content);
|
||||
|
||||
//- Construct by transferring the List content
|
||||
//- Construct by transferring the content
|
||||
IOList(const IOobject& io, List<T>&& content);
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user