From 82793df60c6edf55d1506664d59c4e7ff24677bb Mon Sep 17 00:00:00 2001 From: Mark Olesen <Mark.Olesen@esi-group.com> Date: Wed, 26 Feb 2020 23:46:04 +0100 Subject: [PATCH] ENH: support for patch subsets on a sampled mesh (#1600) --- .../sampledMeshedSurface.C | 60 ++++++++++++++++++- .../sampledMeshedSurface.H | 3 +- .../sampledMeshedSurfaceNormal.H | 1 + 3 files changed, 62 insertions(+), 2 deletions(-) diff --git a/src/sampling/sampledSurface/sampledMeshedSurface/sampledMeshedSurface.C b/src/sampling/sampledSurface/sampledMeshedSurface/sampledMeshedSurface.C index 9506a9e85fa..0af0390b951 100644 --- a/src/sampling/sampledSurface/sampledMeshedSurface/sampledMeshedSurface.C +++ b/src/sampling/sampledSurface/sampledMeshedSurface/sampledMeshedSurface.C @@ -529,7 +529,65 @@ Foam::sampledMeshedSurface::sampledMeshedSurface zoneIds_(), sampleElements_(), samplePoints_() -{} +{ + wordRes includePatches; + dict.readIfPresent("patches", includePatches); + includePatches.uniq(); + + // Could also shift this to the reader itself, + // but not yet necessary. + + if (!includePatches.empty()) + { + Info<< "Subsetting surface " << surfaceName_ + << " to patches: " << flatOutput(includePatches) << nl; + + const surfZoneList& zones = surface_.surfZones(); + + const labelList zoneIndices + ( + stringListOps::findMatching + ( + zones, + includePatches, + wordRes(), + nameOp<surfZone>() + ) + ); + + // Faces to subset + bitSet includeMap(surface_.size()); + + for (const label zonei : zoneIndices) + { + const surfZone& zn = zones[zonei]; + includeMap.set(zn.range()); + } + + if (includeMap.none()) + { + WarningInFunction + << "Patch selection results in an empty surface" + << " - ignoring" << nl; + } + else if (!includeMap.all()) + { + meshedSurface newSurf(surface_.subsetMesh(includeMap)); + + if (newSurf.empty()) + { + WarningInFunction + << "Bad surface subset (empty)" + << " - skip and hope for the best" << nl; + } + else + { + // Replace + surface_.transfer(newSurf); + } + } + } +} // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // diff --git a/src/sampling/sampledSurface/sampledMeshedSurface/sampledMeshedSurface.H b/src/sampling/sampledSurface/sampledMeshedSurface/sampledMeshedSurface.H index a6ab32d799f..05da864184a 100644 --- a/src/sampling/sampledSurface/sampledMeshedSurface/sampledMeshedSurface.H +++ b/src/sampling/sampledSurface/sampledMeshedSurface/sampledMeshedSurface.H @@ -84,6 +84,7 @@ Usage Property | Description | Required | Default type | meshedSurface | yes | surface | surface name in triSurface/ | yes | + patches | Limit to named surface regions (wordRes) | no | source | cells/insideCells/boundaryFaces | yes | keepIds | pass through id numbering | no | false \endtable @@ -141,7 +142,7 @@ private: word surfaceName_; //- Surface to sample on - const meshedSurface surface_; + meshedSurface surface_; //- Whether to sample internal cell values or boundary values const samplingSource sampleSource_; diff --git a/src/sampling/sampledSurface/sampledMeshedSurface/sampledMeshedSurfaceNormal.H b/src/sampling/sampledSurface/sampledMeshedSurface/sampledMeshedSurfaceNormal.H index 7b595d64611..24a580e0353 100644 --- a/src/sampling/sampledSurface/sampledMeshedSurface/sampledMeshedSurfaceNormal.H +++ b/src/sampling/sampledSurface/sampledMeshedSurface/sampledMeshedSurfaceNormal.H @@ -54,6 +54,7 @@ Usage Property | Description | Required | Default type | meshedSurfaceNormal | yes | surface | surface name in triSurface/ | yes | + patches | Limit to named surface regions (wordRes) | no | source | cells/insideCells/boundaryFaces | yes | keepIds | pass through id numbering | no | false \endtable -- GitLab