From 9114e01de91fd16037688e207e1a401aa464717f Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Mon, 21 Nov 2022 20:54:00 +0100 Subject: [PATCH] STYLE: align faceZone handling (functionObjects, sampling) - pattern as per surfaceFieldValue::setFaceZoneFaces() 1. define faceId, facePatchId assuming an internal face 2. if actually a boundary face: - get facePatchId - ignore if emptyPolyPatch or coupledPolyPatch (neighbour side) - get patch relative faceId This currently seems to be the least amount of code clutter. ENH: recover some memory my shrinking lists in fluxSummary BUG: potentially trailing rubbish in the heatExchangerModel lists - the final resize to length actually used was missing. Does not affect any released versions --- src/fileFormats/ensight/mesh/ensightMesh.C | 17 +- .../surfaceFieldValue/surfaceFieldValue.C | 27 ++- .../field/fluxSummary/fluxSummary.C | 158 ++++++++++-------- .../faceZoneReferenceTemperature.C | 68 ++++---- ...irectionalPressureGradientExplicitSource.C | 83 ++++----- .../heatExchangerModel/heatExchangerModel.C | 88 +++++----- .../sampledFaceZone/sampledFaceZone.C | 35 ++-- 7 files changed, 247 insertions(+), 229 deletions(-) diff --git a/src/fileFormats/ensight/mesh/ensightMesh.C b/src/fileFormats/ensight/mesh/ensightMesh.C index b889b524b5..8681c14abb 100644 --- a/src/fileFormats/ensight/mesh/ensightMesh.C +++ b/src/fileFormats/ensight/mesh/ensightMesh.C @@ -314,7 +314,7 @@ void Foam::ensightMesh::correct() } - // Face exclusion for empty/processor types + // Face exclusion for empty types and neighbour side of coupled // so they are ignored for face zones if (fzoneIds.size()) @@ -324,15 +324,16 @@ void Foam::ensightMesh::correct() for (const polyPatch& p : mesh_.boundaryMesh()) { - const auto* procPatch = isA(p); + const auto* cpp = isA(p); - if (isA(p)) + if + ( + isA(p) + || (cpp && !cpp->owner()) + ) { - excludeFace.set(p.range()); - } - else if (procPatch && !procPatch->owner()) - { - // Exclude neighbour-side, retain owner-side only + // Ignore empty patch + // Ignore neighbour side of coupled excludeFace.set(p.range()); } } diff --git a/src/functionObjects/field/fieldValues/surfaceFieldValue/surfaceFieldValue.C b/src/functionObjects/field/fieldValues/surfaceFieldValue/surfaceFieldValue.C index 5ddf3663c2..22d691e199 100644 --- a/src/functionObjects/field/fieldValues/surfaceFieldValue/surfaceFieldValue.C +++ b/src/functionObjects/field/fieldValues/surfaceFieldValue/surfaceFieldValue.C @@ -168,9 +168,9 @@ void Foam::functionObjects::fieldValues::surfaceFieldValue::setFaceZoneFaces() } #endif - faceId_.resize(numFaces); - facePatchId_.resize(numFaces); - faceFlip_.resize(numFaces); + faceId_.resize_nocopy(numFaces); + facePatchId_.resize_nocopy(numFaces); + faceFlip_.resize_nocopy(numFaces); numFaces = 0; @@ -192,21 +192,20 @@ void Foam::functionObjects::fieldValues::surfaceFieldValue::setFaceZoneFaces() { facePatchId = mesh_.boundaryMesh().whichPatch(meshFacei); const polyPatch& pp = mesh_.boundaryMesh()[facePatchId]; + + if (isA(pp)) + { + continue; // Ignore empty patch + } + const auto* cpp = isA(pp); - if (cpp) + if (cpp && !cpp->owner()) { - faceId = (cpp->owner() ? pp.whichFace(meshFacei) : -1); - } - else if (!isA(pp)) - { - faceId = pp.whichFace(meshFacei); - } - else - { - faceId = -1; - facePatchId = -1; + continue; // Ignore neighbour side } + + faceId = pp.whichFace(meshFacei); } if (faceId >= 0) diff --git a/src/functionObjects/field/fluxSummary/fluxSummary.C b/src/functionObjects/field/fluxSummary/fluxSummary.C index d87ab130e6..2969be6906 100644 --- a/src/functionObjects/field/fluxSummary/fluxSummary.C +++ b/src/functionObjects/field/fluxSummary/fluxSummary.C @@ -201,56 +201,62 @@ void Foam::functionObjects::fluxSummary::initialiseFaceZone names.append(faceZoneName); directions.append(Zero); // dummy value - DynamicList