From b2135600a887e89f9796495338bd81f83568a4aa Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Mon, 25 Aug 2025 15:09:31 +0200 Subject: [PATCH] ENH: add readContents to CompactIOList, CompactIOField - align some of the internal handling with each other and with CompactListList ENH: add readContentsSize to IOList, IOField etc. - sometimes just need to know how many elements are stored on disk without actually caring about the content. In those cases, can frequently just get that information from the first label token without needing to read anything else. --- applications/test/CompactIOList/Make/files | 2 +- ...CompactIOList.C => Test-CompactIOList.cxx} | 106 ++++-- .../IOobjects/CompactIOField/CompactIOField.C | 342 ++++++++++++++---- .../IOobjects/CompactIOField/CompactIOField.H | 62 +++- .../IOobjects/CompactIOList/CompactIOList.C | 314 +++++++++++----- .../IOobjects/CompactIOList/CompactIOList.H | 55 ++- .../IOobjects/GlobalIOField/GlobalIOField.C | 10 +- .../IOobjects/GlobalIOField/GlobalIOField.H | 17 +- .../db/IOobjects/GlobalIOList/GlobalIOList.C | 10 +- .../db/IOobjects/GlobalIOList/GlobalIOList.H | 17 +- src/OpenFOAM/db/IOobjects/IOField/IOField.C | 64 +++- src/OpenFOAM/db/IOobjects/IOField/IOField.H | 27 +- src/OpenFOAM/db/IOobjects/IOList/IOList.C | 62 +++- src/OpenFOAM/db/IOobjects/IOList/IOList.H | 25 +- src/OpenFOAM/db/IOobjects/IOMap/IOMap.C | 10 +- src/OpenFOAM/db/IOobjects/IOMap/IOMap.H | 15 +- .../db/IOobjects/IOPtrList/IOPtrList.C | 10 +- .../db/IOobjects/IOPtrList/IOPtrList.H | 15 +- .../IOobjects/IOdictionary/baseIOdictionary.C | 8 - .../IOobjects/IOdictionary/baseIOdictionary.H | 15 +- .../db/IOobjects/rawIOField/rawIOField.C | 1 + 21 files changed, 858 insertions(+), 329 deletions(-) rename applications/test/CompactIOList/{Test-CompactIOList.C => Test-CompactIOList.cxx} (60%) diff --git a/applications/test/CompactIOList/Make/files b/applications/test/CompactIOList/Make/files index c5513ed5c1..b318569076 100644 --- a/applications/test/CompactIOList/Make/files +++ b/applications/test/CompactIOList/Make/files @@ -1,3 +1,3 @@ -Test-CompactIOList.C +Test-CompactIOList.cxx EXE = $(FOAM_USER_APPBIN)/Test-CompactIOList diff --git a/applications/test/CompactIOList/Test-CompactIOList.C b/applications/test/CompactIOList/Test-CompactIOList.cxx similarity index 60% rename from applications/test/CompactIOList/Test-CompactIOList.C rename to applications/test/CompactIOList/Test-CompactIOList.cxx index 0db36f346c..439b4b6870 100644 --- a/applications/test/CompactIOList/Test-CompactIOList.C +++ b/applications/test/CompactIOList/Test-CompactIOList.cxx @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation - Copyright (C) 2020-2022 OpenCFD Ltd. + Copyright (C) 2020-2025 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -25,7 +25,7 @@ License along with OpenFOAM. If not, see . Application - testCompactIOList + Test-CompactIOList Description Simple demonstration and test application for the CompactIOList container @@ -46,13 +46,20 @@ using namespace Foam; int main(int argc, char *argv[]) { + argList::addBoolOption("ascii", "use ascii format"); + argList::addOption("count", "number of faces"); + #include "setRootCase.H" #include "createTime.H" IOstreamOption streamOpt(IOstreamOption::BINARY); - // IOstreamOption streamOpt(IOstreamOption::ASCII); - const label size = 20000000; + if (args.found("ascii")) + { + streamOpt.format(IOstreamOption::ASCII); + } + + const label size = args.getOrDefault