From 1edb2f7dd0dc085f0403202703d764711584a17a Mon Sep 17 00:00:00 2001 From: mattijs Date: Wed, 21 Mar 2018 21:54:40 +0100 Subject: [PATCH] BUG: mesh refinement crash with degenerate mesh distributions (closes #778) - occurred when the initial mesh distribution was missing cells on some processors. --- .../algorithms/indexedOctree/indexedOctree.C | 50 ++++++++++++------- 1 file changed, 33 insertions(+), 17 deletions(-) diff --git a/src/OpenFOAM/algorithms/indexedOctree/indexedOctree.C b/src/OpenFOAM/algorithms/indexedOctree/indexedOctree.C index ada7d06b5b..64346e1d25 100644 --- a/src/OpenFOAM/algorithms/indexedOctree/indexedOctree.C +++ b/src/OpenFOAM/algorithms/indexedOctree/indexedOctree.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. + \\/ M anipulation | Copyright (C) 2016-2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -2560,6 +2560,11 @@ Foam::labelBits Foam::indexedOctree::findNode template Foam::label Foam::indexedOctree::findInside(const point& sample) const { + if (nodes_.empty()) + { + return -1; + } + labelBits index = findNode(0, sample); const node& nod = nodes_[getNode(index)]; @@ -2592,6 +2597,11 @@ const Foam::labelList& Foam::indexedOctree::findIndices const point& sample ) const { + if (nodes_.empty()) + { + return emptyList