From 394a3a9b6e5b37a042dc01778d32079b7df17d92 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Wed, 22 Apr 2020 18:25:37 +0200 Subject: [PATCH] ENH: retain compound type on List output (continuation of 68de05285ae4) - can help in circumstances when an zero-sized entry is written on some processors, but the compound-type may be useful for determining a particular code path when re-reading the files. Ensures that the information is consistent on all processors. STYLE: adjust separation of includes between List.H and UList.H --- .../containers/Lists/FixedList/FixedListIO.C | 4 ++-- src/OpenFOAM/containers/Lists/List/List.H | 5 +---- src/OpenFOAM/containers/Lists/UList/UList.H | 1 + src/OpenFOAM/containers/Lists/UList/UListIO.C | 13 +++++++------ 4 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/OpenFOAM/containers/Lists/FixedList/FixedListIO.C b/src/OpenFOAM/containers/Lists/FixedList/FixedListIO.C index 171c9e074e..198383ce40 100644 --- a/src/OpenFOAM/containers/Lists/FixedList/FixedListIO.C +++ b/src/OpenFOAM/containers/Lists/FixedList/FixedListIO.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2017-2019 OpenCFD Ltd. + Copyright (C) 2017-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -36,7 +36,7 @@ License template void Foam::FixedList::writeEntry(Ostream& os) const { - const word tag = "List<" + word(pTraits::typeName) + '>'; + const word tag("List<" + word(pTraits::typeName) + '>'); if (token::compound::isCompound(tag)) { os << tag << token::SPACE; diff --git a/src/OpenFOAM/containers/Lists/List/List.H b/src/OpenFOAM/containers/Lists/List/List.H index 4ae56710b7..b9ae065c13 100644 --- a/src/OpenFOAM/containers/Lists/List/List.H +++ b/src/OpenFOAM/containers/Lists/List/List.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2017-2019 OpenCFD Ltd. + Copyright (C) 2017-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -45,11 +45,8 @@ SourceFiles #include "UList.H" #include "autoPtr.H" -#include "one.H" #include "SLListFwd.H" -#include - // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam diff --git a/src/OpenFOAM/containers/Lists/UList/UList.H b/src/OpenFOAM/containers/Lists/UList/UList.H index 259aa076c9..19c8321dcd 100644 --- a/src/OpenFOAM/containers/Lists/UList/UList.H +++ b/src/OpenFOAM/containers/Lists/UList/UList.H @@ -49,6 +49,7 @@ SourceFiles #include "label.H" #include "uLabel.H" #include "zero.H" +#include "one.H" #include "contiguous.H" #include "nullObject.H" #include "stdFoam.H" diff --git a/src/OpenFOAM/containers/Lists/UList/UListIO.C b/src/OpenFOAM/containers/Lists/UList/UListIO.C index 81a6fad37f..b5369cdb9f 100644 --- a/src/OpenFOAM/containers/Lists/UList/UListIO.C +++ b/src/OpenFOAM/containers/Lists/UList/UListIO.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2016-2019 OpenCFD Ltd. + Copyright (C) 2016-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -37,13 +37,14 @@ License template void Foam::UList::writeEntry(Ostream& os) const { + const word tag("List<" + word(pTraits::typeName) + '>'); + if (token::compound::isCompound(tag)) + { + os << tag << token::SPACE; + } + if (size()) { - const word tag = "List<" + word(pTraits::typeName) + '>'; - if (token::compound::isCompound(tag)) - { - os << tag << token::SPACE; - } os << *this; } else if (os.format() == IOstream::ASCII)