From 51f501b668371d233c7af3e5c7571120dbbf549f Mon Sep 17 00:00:00 2001 From: mattijs Date: Wed, 8 May 2019 12:27:24 +0100 Subject: [PATCH 01/66] ENH: decomposition: added 'random' method for testing. This will use a random-number generator to select for each cell the processor. Useful for testing parallel/non-parallel consistent behaviour. --- .../decompose/decompositionMethods/Make/files | 1 + .../randomDecomp/randomDecomp.C | 93 ++++++++++++++ .../randomDecomp/randomDecomp.H | 116 ++++++++++++++++++ 3 files changed, 210 insertions(+) create mode 100644 src/parallel/decompose/decompositionMethods/randomDecomp/randomDecomp.C create mode 100644 src/parallel/decompose/decompositionMethods/randomDecomp/randomDecomp.H diff --git a/src/parallel/decompose/decompositionMethods/Make/files b/src/parallel/decompose/decompositionMethods/Make/files index 575366dfae..59d3154da7 100644 --- a/src/parallel/decompose/decompositionMethods/Make/files +++ b/src/parallel/decompose/decompositionMethods/Make/files @@ -6,6 +6,7 @@ manualDecomp/manualDecomp.C multiLevelDecomp/multiLevelDecomp.C metisLikeDecomp/metisLikeDecomp.C structuredDecomp/structuredDecomp.C +randomDecomp/randomDecomp.C noDecomp/noDecomp.C diff --git a/src/parallel/decompose/decompositionMethods/randomDecomp/randomDecomp.C b/src/parallel/decompose/decompositionMethods/randomDecomp/randomDecomp.C new file mode 100644 index 0000000000..29ea4abff0 --- /dev/null +++ b/src/parallel/decompose/decompositionMethods/randomDecomp/randomDecomp.C @@ -0,0 +1,93 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2019 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +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 . + +\*---------------------------------------------------------------------------*/ + +#include "randomDecomp.H" +#include "addToRunTimeSelectionTable.H" +#include "Random.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + defineTypeNameAndDebug(randomDecomp, 0); + + addToRunTimeSelectionTable + ( + decompositionMethod, + randomDecomp, + dictionary + ); +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::randomDecomp::randomDecomp(const dictionary& decompositionDict) +: + decompositionMethod(decompositionDict) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +Foam::labelList Foam::randomDecomp::decompose +( + const polyMesh& mesh, + const pointField& points, + const scalarField& pointWeights +) const +{ + Random rndGen(0); + + labelList finalDecomp(mesh.nCells()); + forAll(finalDecomp, celli) + { + finalDecomp[celli] = rndGen.position