From 25e7d800bb085bb02cead0ca11a396cc61134033 Mon Sep 17 00:00:00 2001 From: Mark Olesen <Mark.Olesen@Germany> Date: Tue, 6 Apr 2010 13:46:37 +0200 Subject: [PATCH] BUG: fix inconsistent ListOps behaviour with DynamicList --- .../containers/Lists/ListOps/ListOpsTemplates.C | 17 ++++++++++++++++- .../primitives/Lists/stringListOpsTemplates.C | 6 +++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/OpenFOAM/containers/Lists/ListOps/ListOpsTemplates.C b/src/OpenFOAM/containers/Lists/ListOps/ListOpsTemplates.C index d50fbcf0f8b..65bd73563de 100644 --- a/src/OpenFOAM/containers/Lists/ListOps/ListOpsTemplates.C +++ b/src/OpenFOAM/containers/Lists/ListOps/ListOpsTemplates.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -37,6 +37,9 @@ ListType Foam::renumber // Create copy ListType newLst(lst.size()); + // ensure consistent addressable size (eg, DynamicList) + newLst.setSize(lst.size()); + forAll(lst, elemI) { if (lst[elemI] >= 0) @@ -76,6 +79,9 @@ ListType Foam::reorder // Create copy ListType newLst(lst.size()); + // ensure consistent addressable size (eg, DynamicList) + newLst.setSize(lst.size()); + forAll(lst, elemI) { if (oldToNew[elemI] >= 0) @@ -101,6 +107,9 @@ void Foam::inplaceReorder // Create copy ListType newLst(lst.size()); + // ensure consistent addressable size (eg, DynamicList) + newLst.setSize(lst.size()); + forAll(lst, elemI) { if (oldToNew[elemI] >= 0) @@ -258,6 +267,9 @@ ListType Foam::subset ListType newLst(lst.size()); + // ensure consistent addressable size (eg, DynamicList) + newLst.setSize(lst.size()); + label nElem = 0; forAll(lst, elemI) { @@ -318,6 +330,9 @@ ListType Foam::subset ListType newLst(lst.size()); + // ensure consistent addressable size (eg, DynamicList) + newLst.setSize(lst.size()); + label nElem = 0; forAll(lst, elemI) { diff --git a/src/OpenFOAM/primitives/Lists/stringListOpsTemplates.C b/src/OpenFOAM/primitives/Lists/stringListOpsTemplates.C index 9fdfee1b0a5..695d211d61e 100644 --- a/src/OpenFOAM/primitives/Lists/stringListOpsTemplates.C +++ b/src/OpenFOAM/primitives/Lists/stringListOpsTemplates.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -57,8 +57,12 @@ StringListType Foam::subsetMatchingStrings const bool invert ) { + // Create copy StringListType newLst(lst.size()); + // ensure consistent addressable size (eg, DynamicList) + newLst.setSize(lst.size()); + label nElem = 0; forAll(lst, elemI) { -- GitLab