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.
This commit is contained in:
mattijs
2022-09-12 16:37:37 +01:00
committed by Andrew Heather
parent 5fb0cd77f1
commit c439968390
3 changed files with 86 additions and 13 deletions

View File

@ -48,11 +48,12 @@ namespace Foam
Foam::topoSetSource::addToUsageTable Foam::cellToFace::usage_ Foam::topoSetSource::addToUsageTable Foam::cellToFace::usage_
( (
cellToFace::typeName, cellToFace::typeName,
"\n Usage: cellToFace <cellSet> all|both\n\n" "\n Usage: cellToFace <cellSet> all|both|outside\n\n"
" Select -all : all faces of cells in the cellSet\n" " Select -all : all faces of cells in the cellSet\n"
" -both: faces where both neighbours are in the cellSet\n\n" " -both: faces where both neighbours are in the cellSet\n\n"
); );
const Foam::Enum const Foam::Enum
< <
Foam::cellToFace::cellAction Foam::cellToFace::cellAction
@ -61,6 +62,7 @@ Foam::cellToFace::cellActionNames_
({ ({
{ cellAction::ALL, "all" }, { cellAction::ALL, "all" },
{ cellAction::BOTH, "both" }, { 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);
}
} }

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011 OpenFOAM Foundation Copyright (C) 2011 OpenFOAM Foundation
Copyright (C) 2018-2020 OpenCFD Ltd. Copyright (C) 2018-2022 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -33,8 +33,8 @@ Description
Operands: Operands:
\table \table
Operand | Type | Location Operand | Type | Location
input | cellSet(s) | $FOAM_CASE/constant/polyMesh/sets/\<set\> input | cellSet(s) | constant/polyMesh/sets/\<set\>
output | faceSet | $FOAM_CASE/constant/polyMesh/sets/\<set\> output | faceSet | constant/polyMesh/sets/\<set\>
\endtable \endtable
Usage Usage
@ -68,7 +68,7 @@ Usage
where the entries mean: where the entries mean:
\table \table
Property | Description | Type | Req'd | Dflt Property | Description | Type | Reqd | Deflt
name | Name of faceSet | word | yes | - name | Name of faceSet | word | yes | -
type | Type name: faceSet | word | yes | - type | Type name: faceSet | word | yes | -
action | Action applied on faces - see below | word | yes | - action | Action applied on faces - see below | word | yes | -
@ -87,18 +87,20 @@ Usage
\verbatim \verbatim
all | All faces of cells in the cellSet all | All faces of cells in the cellSet
both | Faces where both neighbours are in the cellSet both | Faces where both neighbours are in the cellSet
outside | Faces with only one neighbour in the cellSet
\endverbatim \endverbatim
Options for the conditional mandatory entries: Options for the conditional mandatory entries:
\verbatim \verbatim
Entry | Description | Type | Req'd | Dflt Entry | Description | Type | Reqd | Deflt
sets | Names of input cellSets | wordList | cond'l | - sets | Names of input cellSets | wordList | choice | -
set | Name of input cellSet | word | cond'l | - set | Name of input cellSet | word | choice | -
\endverbatim \endverbatim
Note 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. highest to the lowest is \c sets, and \c set.
- The \c outside option applies to the cellSets individually.
See also See also
- Foam::topoSetSource - Foam::topoSetSource
@ -109,8 +111,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#ifndef cellToFace_H #ifndef Foam_cellToFace_H
#define cellToFace_H #define Foam_cellToFace_H
#include "topoSetFaceSource.H" #include "topoSetFaceSource.H"
#include "Enum.H" #include "Enum.H"
@ -121,7 +123,7 @@ namespace Foam
{ {
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class cellToFace Declaration Class cellToFace Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
class cellToFace class cellToFace
@ -133,7 +135,8 @@ public:
enum cellAction enum cellAction
{ {
ALL, ALL,
BOTH BOTH,
OUTSIDE
}; };

View File

@ -303,6 +303,15 @@ actions
set cylinder1; set cylinder1;
} }
{
name faceCell1c;
type faceSet;
action new;
source cellToFace;
option outside;
set cylinder1;
}
{ {
name faceCylinder1; name faceCylinder1;
type faceSet; type faceSet;