From 990affa9eabfcfbdab28cb001ef03769ee7ea9b1 Mon Sep 17 00:00:00 2001 From: Hrvoje Jasak Date: Fri, 25 Aug 2017 14:06:09 +0100 Subject: [PATCH] Bugfix: error in losortStart calculation for solo cells --- .../lduMatrix/lduAddressing/lduAddressing.C | 30 +++++++++++++++---- 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/src/foam/matrices/lduMatrix/lduAddressing/lduAddressing.C b/src/foam/matrices/lduMatrix/lduAddressing/lduAddressing.C index ca87c406c..9fd2463f5 100644 --- a/src/foam/matrices/lduMatrix/lduAddressing/lduAddressing.C +++ b/src/foam/matrices/lduMatrix/lduAddressing/lduAddressing.C @@ -124,6 +124,12 @@ void Foam::lduAddressing::calcOwnerStart() const nOwnStart = curOwn; } + else + { + // No neighbours + ownStart[i] = ownStart[i - 1]; + i++; + } } } @@ -137,24 +143,30 @@ void Foam::lduAddressing::calcLosortStart() const << abort(FatalError); } - losortStartPtr_ = new labelList(size() + 1, 0); + const labelList& nbr = upperAddr(); + + losortStartPtr_ = new labelList(size() + 1, nbr.size()); labelList& lsrtStart = *losortStartPtr_; - const labelList& nbr = upperAddr(); - const labelList& lsrt = losortAddr(); // Set up first lookup by hand lsrtStart[0] = 0; - label nLsrtStart = 0; - label i = 0; + // Record current neighbour as seen from the (sorted) losort face lookup + label nLsrtStart = 0; + + // Start filling losort table form 1 + label i = 1; + + // Go through losort face ordering forAll (lsrt, faceI) { - // Get neighbour + // Get neighbour: Because of losort, they will come in increasing order const label curNbr = nbr[lsrt[faceI]]; + // If nbr is greater than the if (curNbr > nLsrtStart) { while (i <= curNbr) @@ -164,6 +176,12 @@ void Foam::lduAddressing::calcLosortStart() const nLsrtStart = curNbr; } + else + { + // No owners + lsrtStart[i] = lsrtStart[i - 1]; + i++; + } } // Set up last lookup by hand