diff --git a/applications/test/gatherValues1/Make/files b/applications/test/gatherValues1/Make/files new file mode 100644 index 0000000000..31bbb718f0 --- /dev/null +++ b/applications/test/gatherValues1/Make/files @@ -0,0 +1,3 @@ +Test-gatherValues1.C + +EXE = $(FOAM_USER_APPBIN)/Test-gatherValues1 diff --git a/applications/test/gatherValues1/Make/options b/applications/test/gatherValues1/Make/options new file mode 100644 index 0000000000..18e6fe47af --- /dev/null +++ b/applications/test/gatherValues1/Make/options @@ -0,0 +1,2 @@ +/* EXE_INC = */ +/* EXE_LIBS = */ diff --git a/applications/test/gatherValues1/Test-gatherValues1.C b/applications/test/gatherValues1/Test-gatherValues1.C new file mode 100644 index 0000000000..183fcd517e --- /dev/null +++ b/applications/test/gatherValues1/Test-gatherValues1.C @@ -0,0 +1,189 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2021 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 + Test-gatherValues1 + +Description + Test list gather functionality + +\*---------------------------------------------------------------------------*/ + +#include "argList.H" +#include "Time.H" +#include "IPstream.H" +#include "OPstream.H" +#include "vector.H" +#include "IOstreams.H" +#include "Pstream.H" +#include "globalIndex.H" + +using namespace Foam; + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +int main(int argc, char *argv[]) +{ + argList::noCheckProcessorDirectories(); + + #include "setRootCase.H" + + const labelList localValues + ( + identity(2 *(Pstream::myProcNo()+1), -5*Pstream::myProcNo()) + ); + + // Test resize + { + globalIndex globIdx(localValues.size()); + + Info<< "globIdx = " << flatOutput(globIdx.offsets()) << nl; + + globIdx.setLocalSize(4, 0); + Info<< "globIdx = " << flatOutput(globIdx.offsets()) << nl; + globIdx.setLocalSize(3, 0); + Info<< "globIdx = " << flatOutput(globIdx.offsets()) << nl; + } + + + // Gather all values + { + const auto& sendData = localValues; + + // One-sided sizing! master only + const globalIndex allProcAddr + ( + UPstream::listGatherValues