From c43996839022f14e973efa730785285a855c9254 Mon Sep 17 00:00:00 2001 From: mattijs Date: Mon, 12 Sep 2022 16:37:37 +0100 Subject: [PATCH] ENH: cellToFace: new selection option 'outside' The new selection option 'outside' can be used to select faces with only one neighbour in the specified cellSet. --- .../faceSources/cellToFace/cellToFace.C | 63 ++++++++++++++++++- .../faceSources/cellToFace/cellToFace.H | 27 ++++---- .../pisoFoam/RAS/cavity/system/topoSetDict | 9 +++ 3 files changed, 86 insertions(+), 13 deletions(-) diff --git a/src/meshTools/topoSet/faceSources/cellToFace/cellToFace.C b/src/meshTools/topoSet/faceSources/cellToFace/cellToFace.C index b3401415a0..9e88902e6c 100644 --- a/src/meshTools/topoSet/faceSources/cellToFace/cellToFace.C +++ b/src/meshTools/topoSet/faceSources/cellToFace/cellToFace.C @@ -48,11 +48,12 @@ namespace Foam Foam::topoSetSource::addToUsageTable Foam::cellToFace::usage_ ( cellToFace::typeName, - "\n Usage: cellToFace all|both\n\n" + "\n Usage: cellToFace all|both|outside\n\n" " Select -all : all faces of cells in the cellSet\n" " -both: faces where both neighbours are in the cellSet\n\n" ); + const Foam::Enum < Foam::cellToFace::cellAction @@ -61,6 +62,7 @@ Foam::cellToFace::cellActionNames_ ({ { cellAction::ALL, "all" }, { cellAction::BOTH, "both" }, + { cellAction::OUTSIDE, "outside" } }); @@ -148,6 +150,65 @@ void Foam::cellToFace::combine } } } + else if (option_ == OUTSIDE) + { + // Add all faces where only one neighbour is in set. + + const label nInt = mesh_.nInternalFaces(); + const labelList& own = mesh_.faceOwner(); + const labelList& nei = mesh_.faceNeighbour(); + const polyBoundaryMesh& patches = mesh_.boundaryMesh(); + + + // Check all internal faces + for (label facei = 0; facei < nInt; ++facei) + { + if (cellLabels.found(own[facei]) != cellLabels.found(nei[facei])) + { + addOrDelete(set, facei, add); + } + } + + + // Get coupled cell status + boolList neiInSet(mesh_.nBoundaryFaces(), false); + + for (const polyPatch& pp : patches) + { + if (pp.coupled()) + { + label facei = pp.start(); + forAll(pp, i) + { + neiInSet[facei-nInt] = cellLabels.found(own[facei]); + ++facei; + } + } + } + syncTools::swapBoundaryFaceList(mesh_, neiInSet); + + + // Check all boundary faces + for (const polyPatch& pp : patches) + { + label facei = pp.start(); + forAll(pp, i) + { + if (cellLabels.found(own[facei]) != neiInSet[facei-nInt]) + { + addOrDelete(set, facei, add); + } + ++facei; + } + } + } + else + { + FatalErrorInFunction + << "Selected option is not available" + << ", option: " << cellActionNames_[option_] + << exit(FatalError); + } } diff --git a/src/meshTools/topoSet/faceSources/cellToFace/cellToFace.H b/src/meshTools/topoSet/faceSources/cellToFace/cellToFace.H index c9ce52b0fd..d1c5638a59 100644 --- a/src/meshTools/topoSet/faceSources/cellToFace/cellToFace.H +++ b/src/meshTools/topoSet/faceSources/cellToFace/cellToFace.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011 OpenFOAM Foundation - Copyright (C) 2018-2020 OpenCFD Ltd. + Copyright (C) 2018-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -33,8 +33,8 @@ Description Operands: \table Operand | Type | Location - input | cellSet(s) | $FOAM_CASE/constant/polyMesh/sets/\ - output | faceSet | $FOAM_CASE/constant/polyMesh/sets/\ + input | cellSet(s) | constant/polyMesh/sets/\ + output | faceSet | constant/polyMesh/sets/\ \endtable Usage @@ -68,7 +68,7 @@ Usage where the entries mean: \table - Property | Description | Type | Req'd | Dflt + Property | Description | Type | Reqd | Deflt name | Name of faceSet | word | yes | - type | Type name: faceSet | word | yes | - action | Action applied on faces - see below | word | yes | - @@ -87,18 +87,20 @@ Usage \verbatim all | All faces of cells in the cellSet both | Faces where both neighbours are in the cellSet + outside | Faces with only one neighbour in the cellSet \endverbatim Options for the conditional mandatory entries: \verbatim - Entry | Description | Type | Req'd | Dflt - sets | Names of input cellSets | wordList | cond'l | - - set | Name of input cellSet | word | cond'l | - + Entry | Description | Type | Reqd | Deflt + sets | Names of input cellSets | wordList | choice | - + set | Name of input cellSet | word | choice | - \endverbatim Note - The order of precedence among the conditional mandatory entries from the + - The order of precedence among the conditional mandatory entries from the highest to the lowest is \c sets, and \c set. + - The \c outside option applies to the cellSets individually. See also - Foam::topoSetSource @@ -109,8 +111,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef cellToFace_H -#define cellToFace_H +#ifndef Foam_cellToFace_H +#define Foam_cellToFace_H #include "topoSetFaceSource.H" #include "Enum.H" @@ -121,7 +123,7 @@ namespace Foam { /*---------------------------------------------------------------------------*\ - Class cellToFace Declaration + Class cellToFace Declaration \*---------------------------------------------------------------------------*/ class cellToFace @@ -133,7 +135,8 @@ public: enum cellAction { ALL, - BOTH + BOTH, + OUTSIDE }; diff --git a/tutorials/incompressible/pisoFoam/RAS/cavity/system/topoSetDict b/tutorials/incompressible/pisoFoam/RAS/cavity/system/topoSetDict index 801eafd409..93efaafab6 100644 --- a/tutorials/incompressible/pisoFoam/RAS/cavity/system/topoSetDict +++ b/tutorials/incompressible/pisoFoam/RAS/cavity/system/topoSetDict @@ -303,6 +303,15 @@ actions set cylinder1; } + { + name faceCell1c; + type faceSet; + action new; + source cellToFace; + option outside; + set cylinder1; + } + { name faceCylinder1; type faceSet;