From ddcc04dadce5bf4840515d5677cb8d7b725a1695 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Tue, 1 Feb 2022 15:17:51 +0100 Subject: [PATCH] BUG: vtk write of uniform field in parallel (fixes #2349) - used low-level MPI gather, but the wrapping routine contains an additional safety check for is_contiguous which is not defined for various std::pair<..> combination. So std::pair (which is actually contiguous, but not declared as is_contiguous) would falsely trip the check. Avoid by simply gathering unbundled values instead. --- .../test/contiguous/Test-contiguous.C | 2 ++ .../test/gatherValues1/Test-gatherValues1.C | 32 ++++++++++++++++++- .../vtk/output/foamVtkOutputTemplates.C | 15 +++------ 3 files changed, 38 insertions(+), 11 deletions(-) diff --git a/applications/test/contiguous/Test-contiguous.C b/applications/test/contiguous/Test-contiguous.C index 9840caedf0..22480baea0 100644 --- a/applications/test/contiguous/Test-contiguous.C +++ b/applications/test/contiguous/Test-contiguous.C @@ -104,6 +104,8 @@ int main(int argc, char *argv[]) printInfo>(); printInfo>(); + printInfo>(); + printInfo, 2>>(); printInfo(); diff --git a/applications/test/gatherValues1/Test-gatherValues1.C b/applications/test/gatherValues1/Test-gatherValues1.C index 183fcd517e..7fdbf92bf3 100644 --- a/applications/test/gatherValues1/Test-gatherValues1.C +++ b/applications/test/gatherValues1/Test-gatherValues1.C @@ -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. @@ -180,6 +180,36 @@ int main(int argc, char *argv[]) } } + // This will likely fail - not declared as is_contiguous + // Cannot even catch since it triggers an abort() + + #if 0 + { + std::pair sendData(Pstream::myProcNo(), vector::one); + + const bool oldThrowingError = FatalError.throwing(true); + + try + { + List> countValues + ( + UPstream::listGatherValues> + ( + sendData + ) + ); + + Pout<< "listGather: " << flatOutput(countValues) << nl; + } + catch (const Foam::error& err) + { + Info<< err.message().c_str() << nl; + } + + FatalError.throwing(oldThrowingError); + } + #endif + Info<< "\nEnd\n" << endl; return 0; diff --git a/src/fileFormats/vtk/output/foamVtkOutputTemplates.C b/src/fileFormats/vtk/output/foamVtkOutputTemplates.C index b1d9176415..7106db9001 100644 --- a/src/fileFormats/vtk/output/foamVtkOutputTemplates.C +++ b/src/fileFormats/vtk/output/foamVtkOutputTemplates.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2016-2021 OpenCFD Ltd. + Copyright (C) 2016-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -140,20 +140,15 @@ void Foam::vtk::writeValueParallel } // Gather [count, value] tuples, including from master - const List> countValues - ( - UPstream::listGatherValues> - ( - std::pair(count, val) - ) - ); + const List