From fbb80e23737ad1d34e499470a7fbf985b5f22f03 Mon Sep 17 00:00:00 2001 From: mattijs <mattijs> Date: Fri, 4 Apr 2014 11:07:16 +0100 Subject: [PATCH] ENH: ptscotchDecomp: handle locally zero cells --- .../decompose/ptscotchDecomp/ptscotchDecomp.C | 21 ++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/parallel/decompose/ptscotchDecomp/ptscotchDecomp.C b/src/parallel/decompose/ptscotchDecomp/ptscotchDecomp.C index 8736987ca9c..3791ad53de9 100644 --- a/src/parallel/decompose/ptscotchDecomp/ptscotchDecomp.C +++ b/src/parallel/decompose/ptscotchDecomp/ptscotchDecomp.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -532,12 +532,23 @@ Foam::label Foam::ptscotchDecomp::decompose if (maxWeights > minWeights) { - // Convert to integers. - velotab.setSize(cWeights.size()); + if (cWeights.size()) + { + // Convert to integers. + velotab.setSize(cWeights.size()); - forAll(velotab, i) + forAll(velotab, i) + { + velotab[i] = int((cWeights[i]/minWeights - 1)*rangeScale) + 1; + } + } + else { - velotab[i] = int((cWeights[i]/minWeights - 1)*rangeScale) + 1; + // Locally zero cells but not globally. Make sure we have + // some size so .begin() does not return null pointer. Data + // itself is never used. + velotab.setSize(1); + velotab[0] = 1; } } -- GitLab