From 69dae2e0084147c0c870563f8676b64dec5fa765 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Wed, 5 Jul 2023 20:40:18 +0200 Subject: [PATCH] ENH: adjust/update debugSurfaceWriter flags - removed gatherv control. The globalIndex information is cached on the merged surface and thus not triggered often. - strip out debug mergeField method which was a precursor to what is now within surfaceWriter itself. - add 'merge' true/false handling to allow testing without parallel merging (implies no writing) --- .../writers/debug/debugSurfaceWriter.C | 99 ++++++------------- .../writers/debug/debugSurfaceWriter.H | 19 ++-- 2 files changed, 45 insertions(+), 73 deletions(-) diff --git a/src/surfMesh/writers/debug/debugSurfaceWriter.C b/src/surfMesh/writers/debug/debugSurfaceWriter.C index e2dff9953f..d11320bbeb 100644 --- a/src/surfMesh/writers/debug/debugSurfaceWriter.C +++ b/src/surfMesh/writers/debug/debugSurfaceWriter.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2022 OpenCFD Ltd. + Copyright (C) 2022-2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -60,69 +60,8 @@ Foam::surfaceWriters::debugWriter::mergeField const Field& fld ) const { - addProfiling - ( - merge, - "debugWriter::merge-field" - ); - - if (parallel_ && Pstream::parRun()) - { - // Ensure geometry is also merged - merge(); - - // Gather all values - auto tfield = tmp>::New(); - auto& allFld = tfield.ref(); - - if (mpiGatherv_) - { - globalIndex::mpiGatherOp - ( - fld, - allFld, - UPstream::worldComm, - commType_ - ); - } - else - { - const globalIndex& globIndex = - ( - this->isPointData() - ? mergedSurf_.pointGlobalIndex() - : mergedSurf_.faceGlobalIndex() - ); - - globIndex.gather - ( - fld, - allFld, - UPstream::msgType(), - commType_, - UPstream::worldComm - ); - } - - // Renumber (point data) to correspond to merged points - if - ( - Pstream::master() - && this->isPointData() - && mergedSurf_.pointsMap().size() - ) - { - inplaceReorder(mergedSurf_.pointsMap(), allFld); - allFld.resize(mergedSurf_.points().size()); - } - - return tfield; - } - - // Mark that any geometry changes have been taken care of - upToDate_ = true; - - return fld; + addProfiling(merge, "debugWriter::merge-field"); + return surfaceWriter::mergeField(fld); } @@ -131,7 +70,7 @@ Foam::surfaceWriters::debugWriter::mergeField Foam::surfaceWriters::debugWriter::debugWriter() : surfaceWriter(), - mpiGatherv_(false), + enableMerge_(true), enableWrite_(false), header_(true), streamOpt_(IOstreamOption::BINARY) @@ -144,7 +83,7 @@ Foam::surfaceWriters::debugWriter::debugWriter ) : surfaceWriter(options), - mpiGatherv_(options.getOrDefault("gatherv", false)), + enableMerge_(options.getOrDefault("merge", true)), enableWrite_(options.getOrDefault("write", false)), header_(true), streamOpt_(IOstreamOption::BINARY) @@ -152,7 +91,7 @@ Foam::surfaceWriters::debugWriter::debugWriter Info<< "Using debug surface writer (" << (this->isPointData() ? "point" : "face") << " data):" << " commsType=" << UPstream::commsTypeNames[commType_] - << " gatherv=" << Switch::name(mpiGatherv_) + << " merge=" << Switch::name(enableMerge_) << " write=" << Switch::name(enableWrite_) << endl; } @@ -252,6 +191,19 @@ Foam::fileName Foam::surfaceWriters::debugWriter::write() fileName surfaceDir = outputPath_; + if (parallel_ && !enableMerge_) + { + if (verbose_) + { + Info<< "Not merging or writing" << nl; + } + + // Pretend to have succeeded + wroteGeom_ = true; + return surfaceDir; + } + + const meshedSurf& surf = surface(); // const meshedSurfRef& surf = adjustSurface(); @@ -314,6 +266,19 @@ Foam::fileName Foam::surfaceWriters::debugWriter::writeTemplate const fileName outputFile(surfaceDir/timeName()/fieldName); + if (parallel_ && !enableMerge_) + { + if (verbose_) + { + Info<< "Not merging or writing" << nl; + } + + // Pretend to have succeeded + wroteGeom_ = true; + return surfaceDir; + } + + // Implicit geometry merge() tmp> tfield = mergeField(localValues); diff --git a/src/surfMesh/writers/debug/debugSurfaceWriter.H b/src/surfMesh/writers/debug/debugSurfaceWriter.H index b1228eb162..239f4be28c 100644 --- a/src/surfMesh/writers/debug/debugSurfaceWriter.H +++ b/src/surfMesh/writers/debug/debugSurfaceWriter.H @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2022 OpenCFD Ltd. + Copyright (C) 2022-2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -35,7 +35,8 @@ Description { debug { - write true; + merge true; + write true; } } \endverbatim @@ -44,10 +45,16 @@ Description \table Property | Description | Required | Default commsType | blocking/nonBlocking/scheduled | no | scheduled - gatherv | Use MPI gatherv when merging | no | false - write | Write boundaryData (binary + header) | no | false + merge | Enable geometry/field merging | no | true + write | Write file(s) | no | false \endtable +Note + Disabling geometry/field merging (in parallel) implicitly deactivates + writing as well. + + Output files (if any) are written as boundaryData (binary + header). + SourceFiles debugSurfaceWriter.C @@ -79,8 +86,8 @@ class debugWriter { // Private Data - //- Use MPI gatherv in globalIndex gathering - bool mpiGatherv_; + //- Enable/disable all merging in parallel + bool enableMerge_; //- Output writing? bool enableWrite_;