ENH: IOobject hasHeaderClassName() method

- simple wrapper for (!headerClassName().empty()) when checking if
  reading was successful.
This commit is contained in:
Mark Olesen
2022-03-08 16:47:35 +01:00
parent 323daeda3c
commit c1eb5413d5
8 changed files with 22 additions and 13 deletions

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2021 OpenCFD Ltd.
Copyright (C) 2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -129,7 +129,7 @@ class readFieldsHandler
const bool ok =
(
io.typeHeaderOk<regIOobject>(false) // Preload header info
&& !io.headerClassName().empty() // Extra safety
&& io.hasHeaderClassName() // Extra safety
&&
(
loadField<scalar>(io)

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2021 OpenCFD Ltd.
Copyright (C) 2021-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -129,7 +129,7 @@ class readFieldsHandler
const bool ok =
(
io.typeHeaderOk<regIOobject>(false) // Preload header info
&& !io.headerClassName().empty() // Extra safety
&& io.hasHeaderClassName() // Extra safety
&&
(
loadField<scalar>(io)

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2016-2021 OpenCFD Ltd.
Copyright (C) 2016-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -482,6 +482,9 @@ public:
// Checks
//- True if headerClassName() is non-empty (after reading)
inline bool hasHeaderClassName() const noexcept;
//- Test if headerClassName() equals the given class name
inline bool isHeaderClassName(const word& clsName) const;

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2017-2021 OpenCFD Ltd.
Copyright (C) 2017-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -146,6 +146,12 @@ inline unsigned Foam::IOobject::scalarByteSize() const noexcept
// Checks
inline bool Foam::IOobject::hasHeaderClassName() const noexcept
{
return !headerClassName_.empty();
}
inline bool Foam::IOobject::isHeaderClassName(const word& clsName) const
{
return (clsName == headerClassName_);

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017, 2020 OpenFOAM Foundation
Copyright (C) 2016-2021 OpenCFD Ltd.
Copyright (C) 2016-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -313,7 +313,7 @@ Foam::polyMesh::polyMesh(const IOobject& io, const bool doInit)
oldPointsPtr_(nullptr),
oldCellCentresPtr_(nullptr)
{
if (!owner_.headerClassName().empty())
if (owner_.hasHeaderClassName())
{
initMesh();
}

View File

@ -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.
@ -240,7 +240,7 @@ Foam::polyMesh::readUpdateState Foam::polyMesh::readUpdate()
// Boundary is set so can use initMesh now (uses boundary_ to
// determine internal and active faces)
if (!owner_.headerClassName().empty())
if (owner_.hasHeaderClassName())
{
initMesh();
}

View File

@ -192,7 +192,7 @@ Foam::label Foam::functionObjects::fvExpressionField::loadFields
const bool ok =
(
io.typeHeaderOk<regIOobject>(false) // Preload header info
&& !io.headerClassName().empty() // Extra safety
&& io.hasHeaderClassName() // Extra safety
&&
(
loadField<scalar>(io)

View File

@ -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.
@ -104,7 +104,7 @@ bool Foam::functionObjects::readFields::execute()
const bool ok =
(
io.typeHeaderOk<regIOobject>(false) // Preload header info
&& !io.headerClassName().empty() // Extra safety
&& io.hasHeaderClassName() // Extra safety
&&
(
loadField<scalar>(io)