From 0fabbcb404b93b4224c19165fe9681ad294f5fd8 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Fri, 11 Nov 2022 15:59:06 +0100 Subject: [PATCH] ENH: direct ensight output of float/double - since ensight format is always float and also always written component-wise, perform the double -> float narrowing when extracting the components. This reduces the amount of data transferred between processors. ENH: avoid vtk/ensight parallel communication of empty messages - since ensight writes by element type (eg, tet, hex, polyhedral) the individual written field sections will tend to be relatively sparse. Skip zero-size messages, which should help reduce some of the synchronization bottlenecks. ENH: use 'data chunking' when writing ensight files in parallel - since ensight fields are written on a per-element basis, the corresponding segment can become rather sparsely distributed. With 'data chunking', we attempt to get as many send/recv messages in before flushing the buffer for writing. This should make the sequential send/recv less affected by the IO time. ENH: allow use of an external buffer when writing ensight components STYLE: remove last vestiges of autoPtr for output routines --- .../test/foamToEnsight-check/Make/files | 3 + .../test/foamToEnsight-check/Make/options | 16 + .../foamToEnsight-check/foamToEnsight-check.C | 357 ++++++++++++++++++ .../foamToEnsight/convertLagrangian.H | 46 ++- etc/controlDict | 13 +- .../ensight/output/ensightOutputAreaField.H | 33 +- .../output/ensightOutputAreaFieldTemplates.C | 4 +- .../ensight/output/ensightOutputVolField.H | 93 ++++- .../output/ensightOutputVolFieldTemplates.C | 87 +++-- src/fileFormats/ensight/file/ensightFile.C | 41 +- src/fileFormats/ensight/file/ensightFile.H | 30 +- .../ensight/file/ensightFileTemplates.C | 41 +- .../ensight/output/ensightOutput.C | 17 + .../ensight/output/ensightOutput.H | 231 ++++++++++-- .../ensight/output/ensightOutputFwd.H | 78 ++++ .../ensight/output/ensightOutputTemplates.C | 345 +++++++++++------ .../ensight/part/cells/ensightCells.C | 15 +- .../ensight/part/cells/ensightCells.H | 7 +- .../ensight/part/cells/ensightCellsI.H | 2 +- .../ensight/part/faces/ensightFaces.C | 17 +- .../ensight/part/faces/ensightFaces.H | 9 +- .../ensight/part/faces/ensightFacesI.H | 4 +- src/fileFormats/ensight/type/ensightPTraits.C | 15 +- src/fileFormats/ensight/type/ensightPTraits.H | 11 +- src/fileFormats/vtk/output/foamVtkOutput.C | 49 +-- .../vtk/output/foamVtkOutputTemplates.C | 296 +++++++++------ .../utilities/ensightWrite/ensightWrite.C | 33 +- .../utilities/ensightWrite/ensightWrite.H | 34 +- ...ghtWriteTemplates.C => ensightWriteImpl.C} | 6 +- .../conversion/ensight/ensightOutputCloud.C | 148 +++++--- .../conversion/ensight/ensightOutputCloud.H | 44 ++- .../ensight/ensightOutputCloudTemplates.C | 78 ++-- .../writers/ensight/ensightCoordSetWriter.C | 12 +- 33 files changed, 1698 insertions(+), 517 deletions(-) create mode 100644 applications/test/foamToEnsight-check/Make/files create mode 100644 applications/test/foamToEnsight-check/Make/options create mode 100644 applications/test/foamToEnsight-check/foamToEnsight-check.C create mode 100644 src/fileFormats/ensight/output/ensightOutputFwd.H rename src/functionObjects/utilities/ensightWrite/{ensightWriteTemplates.C => ensightWriteImpl.C} (92%) diff --git a/applications/test/foamToEnsight-check/Make/files b/applications/test/foamToEnsight-check/Make/files new file mode 100644 index 0000000000..d5b94d1fe7 --- /dev/null +++ b/applications/test/foamToEnsight-check/Make/files @@ -0,0 +1,3 @@ +foamToEnsight-check.C + +EXE = $(FOAM_USER_APPBIN)/foamToEnsight-check diff --git a/applications/test/foamToEnsight-check/Make/options b/applications/test/foamToEnsight-check/Make/options new file mode 100644 index 0000000000..7fd9abdcb7 --- /dev/null +++ b/applications/test/foamToEnsight-check/Make/options @@ -0,0 +1,16 @@ +EXE_INC = \ + -I$(LIB_SRC)/finiteVolume/lnInclude \ + -I$(LIB_SRC)/finiteArea/lnInclude \ + -I$(LIB_SRC)/fileFormats/lnInclude \ + -I$(LIB_SRC)/meshTools/lnInclude \ + -I$(LIB_SRC)/conversion/lnInclude \ + -I$(LIB_SRC)/lagrangian/intermediate/lnInclude + +EXE_LIBS = \ + -lfiniteVolume \ + -lfiniteArea \ + -lfileFormats \ + -lmeshTools \ + -lconversion \ + -llagrangianIntermediate \ + -lgenericPatchFields diff --git a/applications/test/foamToEnsight-check/foamToEnsight-check.C b/applications/test/foamToEnsight-check/foamToEnsight-check.C new file mode 100644 index 0000000000..8759fcf8db --- /dev/null +++ b/applications/test/foamToEnsight-check/foamToEnsight-check.C @@ -0,0 +1,357 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2022 OpenCFD Ltd. +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +Application + foamToEnsight-check + +Description + Check data sizes for conversion to ensight format. + +\*---------------------------------------------------------------------------*/ + +#include "argList.H" +#include "timeSelector.H" +#include "IOobjectList.H" +#include "IOmanip.H" +#include "OFstream.H" +#include "Pstream.H" +#include "HashOps.H" +#include "regionProperties.H" + +#include "fvc.H" +#include "faMesh.H" +#include "fvMesh.H" + +// file-format/conversion +#include "ensightFaMesh.H" +#include "ensightMesh.H" + +using namespace Foam; + + +void printStats(const FixedList& stats, const char *what = "") +{ + Info<< what << "max-comm: "<< stats[0] << nl + << what << "max-size: "<< stats[1] << nl + << what << "off-proc: "<< stats[2] << nl; +} + + +template +FixedList printPartInfo +( + const EnsightPartType& part, + int verbose = 0 +) +{ + Info<< "part: " << part.name().c_str() << nl + << " size: " + << (Pstream::parRun() ? part.total() : part.size()) + << " ("; + + FixedList stats(Zero); + + label& maxComm = stats[0]; + label& maxSize = stats[1]; + label& totNonLocalSize = stats[2]; + + for (int typei=0; typei < EnsightPartType::nTypes; ++typei) + { + const auto etype = typename EnsightPartType::elemType(typei); + + if (typei) Info<< ' '; + Info<< EnsightPartType::elemNames[etype] << ": " + << (Pstream::parRun() ? part.total(etype) : part.size(etype)); + + label elemCount = part.size(etype); + label commCount = (Pstream::master() ? label(0) : elemCount); + label nonLocalCount = commCount; + + if (Pstream::parRun()) + { + reduce(elemCount, maxOp