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:
Mark Olesen
2022-05-11 17:39:18 +02:00
parent 812f4c4f09
commit 5d9456187d
10 changed files with 113 additions and 30 deletions

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2018-2020 OpenCFD Ltd.
Copyright (C) 2018-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -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);
}
}