From 3bf15d1b33062edbd4dac6b0e189a217bebef7b0 Mon Sep 17 00:00:00 2001 From: Kutalmis Bercin Date: Sat, 16 May 2020 20:02:19 +0100 Subject: [PATCH] DOC: elaborate the usage of topoSet TUT: add topoSet examples to pisoFoam/RAS/cavity tutorial BUG: fixes #1673 --- .../boundaryToCell/boundaryToCell.H | 51 +- .../sets/cellSources/boxToCell/boxToCell.H | 83 ++- .../sets/cellSources/cellToCell/cellToCell.H | 74 +- .../cylinderAnnulusToCell.C | 14 +- .../cylinderAnnulusToCell.H | 69 +- .../cylinderToCell/cylinderToCell.C | 14 +- .../cylinderToCell/cylinderToCell.H | 63 +- .../sets/cellSources/faceToCell/faceToCell.H | 89 ++- .../faceZoneToCell/faceZoneToCell.H | 89 ++- .../cellSources/fieldToCell/fieldDictionary.H | 21 +- .../cellSources/fieldToCell/fieldToCell.C | 10 +- .../cellSources/fieldToCell/fieldToCell.H | 61 +- .../sets/cellSources/haloToCell/haloToCell.C | 3 +- .../sets/cellSources/haloToCell/haloToCell.H | 61 +- .../cellSources/labelToCell/labelToCell.H | 57 +- .../sets/cellSources/nbrToCell/nbrToCell.C | 4 +- .../sets/cellSources/nbrToCell/nbrToCell.H | 53 +- .../cellSources/nearestToCell/nearestToCell.H | 57 +- .../cellSources/patchToCell/patchToCell.H | 71 +- .../cellSources/pointToCell/pointToCell.H | 87 ++- .../cellSources/regionToCell/regionToCell.C | 2 +- .../cellSources/regionToCell/regionToCell.H | 75 +- .../rotatedBoxToCell/rotatedBoxToCell.H | 79 +- .../searchableSurfaceToCell.H | 55 +- .../cellSources/shapeToCell/shapeToCell.H | 74 +- .../cellSources/sphereToCell/sphereToCell.C | 4 +- .../cellSources/sphereToCell/sphereToCell.H | 60 +- .../cellSources/surfaceToCell/surfaceToCell.H | 92 ++- .../targetVolumeToCell/targetVolumeToCell.C | 2 +- .../targetVolumeToCell/targetVolumeToCell.H | 63 +- .../topoSetCellSource/topoSetCellSource.H | 8 +- .../sets/cellSources/zoneToCell/zoneToCell.H | 76 +- .../setToCellZone/setToCellZone.H | 54 +- .../boundaryToFace/boundaryToFace.H | 50 +- .../sets/faceSources/boxToFace/boxToFace.H | 83 ++- .../sets/faceSources/cellToFace/cellToFace.H | 91 ++- .../cylinderAnnulusToFace.C | 16 +- .../cylinderAnnulusToFace.H | 63 +- .../cylinderToFace/cylinderToFace.C | 14 +- .../cylinderToFace/cylinderToFace.H | 62 +- .../sets/faceSources/faceToFace/faceToFace.H | 76 +- .../faceSources/labelToFace/labelToFace.H | 58 +- .../faceSources/normalToFace/normalToFace.H | 58 +- .../faceSources/patchToFace/patchToFace.H | 76 +- .../faceSources/pointToFace/pointToFace.C | 1 + .../faceSources/pointToFace/pointToFace.H | 85 ++- .../faceSources/regionToFace/regionToFace.H | 57 +- .../searchableSurfaceToFace.C | 2 +- .../searchableSurfaceToFace.H | 55 +- .../faceSources/sphereToFace/sphereToFace.C | 4 +- .../faceSources/sphereToFace/sphereToFace.H | 60 +- .../topoSetFaceSource/topoSetFaceSource.H | 8 +- .../sets/faceSources/zoneToFace/zoneToFace.H | 76 +- .../faceZoneToFaceZone/faceZoneToFaceZone.H | 51 +- .../planeToFaceZone/planeToFaceZone.C | 413 +++++++++++ .../searchableSurfaceToFaceZone.H | 59 +- .../setAndNormalToFaceZone.H | 50 +- .../setToFaceZone/setToFaceZone.H | 57 +- .../setsToFaceZone/setsToFaceZone.H | 61 +- .../sets/pointSources/boxToPoint/boxToPoint.H | 85 ++- .../pointSources/cellToPoint/cellToPoint.H | 84 ++- .../cylinderToPoint/cylinderToPoint.C | 4 +- .../cylinderToPoint/cylinderToPoint.H | 61 +- .../pointSources/faceToPoint/faceToPoint.H | 85 ++- .../pointSources/labelToPoint/labelToPoint.H | 57 +- .../nearestToPoint/nearestToPoint.H | 56 +- .../pointSources/pointToPoint/pointToPoint.H | 74 +- .../searchableSurfaceToPoint.H | 54 +- .../sphereToPoint/sphereToPoint.C | 4 +- .../sphereToPoint/sphereToPoint.H | 60 +- .../surfaceToPoint/surfaceToPoint.H | 70 +- .../topoSetPointSource/topoSetPointSource.H | 8 +- .../pointSources/zoneToPoint/zoneToPoint.H | 76 +- .../setToPointZone/setToPointZone.H | 53 +- .../sets/topoSetSource/topoSetSource.H | 8 +- src/meshTools/sets/topoSets/cellZoneSet.H | 2 +- src/meshTools/sets/topoSets/faceSet.H | 2 - src/meshTools/sets/topoSets/faceZoneSet.H | 2 +- src/meshTools/sets/topoSets/pointSet.H | 1 - src/meshTools/sets/topoSets/pointZoneSet.H | 2 +- src/meshTools/sets/topoSets/topoBitSet.H | 3 +- src/meshTools/sets/topoSets/topoBoolSet.H | 3 +- src/meshTools/sets/topoSets/topoSet.H | 3 - .../pisoFoam/RAS/cavity/system/topoSetDict | 691 ++++++++++++++++++ 84 files changed, 4293 insertions(+), 616 deletions(-) create mode 100644 src/meshTools/sets/faceZoneSources/planeToFaceZone/planeToFaceZone.C create mode 100644 tutorials/incompressible/pisoFoam/RAS/cavity/system/topoSetDict diff --git a/src/meshTools/sets/cellSources/boundaryToCell/boundaryToCell.H b/src/meshTools/sets/cellSources/boundaryToCell/boundaryToCell.H index b703447e1b..f9ebfbde26 100644 --- a/src/meshTools/sets/cellSources/boundaryToCell/boundaryToCell.H +++ b/src/meshTools/sets/cellSources/boundaryToCell/boundaryToCell.H @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2018 OpenCFD Ltd. + Copyright (C) 2018-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -27,10 +27,49 @@ Class Foam::boundaryToCell Description - A topoSetCellSource to select all external (boundary) faces. + A \c topoSetCellSource to select all cells possessing + at least a single face on all external boundaries. - \heading Dictionary parameters - None + Operands: + \table + Operand | Type | Location + output | cellSet | $FOAM_CASE/constant/polyMesh/sets/\ + \endtable + +Usage + Minimal example by using \c system/topoSetDict.actions: + \verbatim + { + // Mandatory (inherited) entries + name ; + type cellSet; + action ; + + // Mandatory entries + source boundaryToCell; + } + \endverbatim + + where the entries mean: + \table + Property | Description | Type | Req'd | Dflt + name | Name of cellSet | word | yes | - + type | Type name: cellSet | word | yes | - + action | Action applied on cells - see below | word | yes | - + source | Source name: boundaryToCell | word | yes | - + \endtable + + Options for the \c action entry: + \verbatim + new | Create a new cellSet from selected cells + add | Add selected cells into this cellSet + subtract | Remove selected cells from this cellSet + \endverbatim + +See also + - Foam::topoSetSource + - Foam::topoSetCellSource + - Foam::patchToCell SourceFiles boundaryToCell.C @@ -55,7 +94,7 @@ class boundaryToCell : public topoSetCellSource { - // Private data + // Private Data //- Add usage string static addToUsageTable usage_; @@ -71,6 +110,7 @@ public: //- Runtime type information TypeName("boundaryToCell"); + // Constructors //- Construct from components @@ -94,7 +134,6 @@ public: const topoSetSource::setAction action, topoSet& set ) const; - }; diff --git a/src/meshTools/sets/cellSources/boxToCell/boxToCell.H b/src/meshTools/sets/cellSources/boxToCell/boxToCell.H index c6ee8e1972..a83a8db090 100644 --- a/src/meshTools/sets/cellSources/boxToCell/boxToCell.H +++ b/src/meshTools/sets/cellSources/boxToCell/boxToCell.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation - Copyright (C) 2018 OpenCFD Ltd. + Copyright (C) 2018-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -28,20 +28,80 @@ Class Foam::boxToCell Description - A topoSetCellSource to select cells based on cell centres inside box(es). + A \c topoSetCellSource to select all cells + whose cell centre inside given bounding box(es). - \heading Dictionary parameters + Operands: \table - Property | Description | Required | Default - boxes | Multiple bounding boxes | partly | - box | A single bounding box | partly | - min | Minimum point for a single box | partly | - max | Maximum point for a single box | partly | + Operand | Type | Location + output | cellSet | $FOAM_CASE/constant/polyMesh/sets/\ \endtable +Usage + Minimal example by using \c system/topoSetDict.actions: + \verbatim + { + // Mandatory (inherited) entries + name ; + type cellSet; + action ; + + // Mandatory entries + source boxToCell; + + // Conditional mandatory entries + // Select either of the below + + // Option-1 + boxes + ( + ( ) ( ) // box-1 + ( ) ( ) // box-2 + ... + ); + + // Option-2 + box ( ) ( ); + + // Option-3 + min ( ); + max ( ); + } + \endverbatim + + where the entries mean: + \table + Property | Description | Type | Req'd | Dflt + name | Name of cellSet | word | yes | - + type | Type name: cellSet | word | yes | - + action | Action applied on cells - see below | word | yes | - + source | Source name: boxToCell | word | yes | - + \endtable + + Options for the \c action entry: + \verbatim + new | Create a new cellSet from selected cells + add | Add selected cells into this cellSet + subtract | Remove selected cells from this cellSet + \endverbatim + + Options for the conditional mandatory entries: + \verbatim + Entry | Description | Type | Req'd | Dflt + boxes | Multiple bounding boxes | vectorList | cond'l | - + box | A single bounding box | vector | cond'l | - + min | Minimum point for a single box | vector | cond'l | - + max | Maximum point for a single box | vector | cond'l | - + \verbatim + Note - Must specify "boxes", "box" or a "min/max" pair - (compatibility with searchable box) - highest to lowest precedence. + The order of precedence among the conditional mandatory entries from the + highest to the lowest is \c boxes, \c box or a \c min-max pair + (compatibility with \c searchableBox). + +See also + - Foam::topoSetSource + - Foam::topoSetCellSource SourceFiles boxToCell.C @@ -67,7 +127,7 @@ class boxToCell : public topoSetCellSource { - // Private data + // Private Data //- Add usage string static addToUsageTable usage_; @@ -86,6 +146,7 @@ public: //- Runtime type information TypeName("boxToCell"); + // Constructors //- Construct from components, copying bounding boxes diff --git a/src/meshTools/sets/cellSources/cellToCell/cellToCell.H b/src/meshTools/sets/cellSources/cellToCell/cellToCell.H index dc52f334fc..52ae643dde 100644 --- a/src/meshTools/sets/cellSources/cellToCell/cellToCell.H +++ b/src/meshTools/sets/cellSources/cellToCell/cellToCell.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011 OpenFOAM Foundation - Copyright (C) 2018 OpenCFD Ltd. + Copyright (C) 2018-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -28,17 +28,73 @@ Class Foam::cellToCell Description - A topoSetCellSource to select the cells from another cellSet. + A \c topoSetCellSource to select all the cells from given \c cellSet(s). - \heading Dictionary parameters + Operands: \table - Property | Description | Required | Default - sets | The input cellSet names | possibly | - set | The input cellSet name | possibly | + Operand | Type | Location + input | cellSet(s) | $FOAM_CASE/constant/polyMesh/sets/\ + output | cellSet | $FOAM_CASE/constant/polyMesh/sets/\ \endtable +Usage + Minimal example by using \c system/topoSetDict.actions: + \verbatim + { + // Mandatory (inherited) entries + name ; + type cellSet; + action ; + + // Mandatory entries + source cellToCell; + + // Conditional mandatory entries + // Select either of the below + + // Option-1 + sets + ( + + + ... + ); + + // Option-2 + set ; + } + \endverbatim + + where the entries mean: + \table + Property | Description | Type | Req'd | Dflt + name | Name of cellSet | word | yes | - + type | Type name: cellSet | word | yes | - + action | Action applied on cells - see below | word | yes | - + source | Source name: cellToCell | word | yes | - + \endtable + + Options for the \c action entry: + \verbatim + new | Create a new cellSet from selected cells + add | Add selected cells into this cellSet + subtract | Remove selected cells from this 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 | - + \verbatim + Note - Must specify "sets" or "set" (highest to lowest precedence). + The order of precedence among the conditional mandatory entries from the + highest to the lowest is \c sets, and \c set. + +See also + - Foam::topoSetSource + - Foam::topoSetCellSource SourceFiles cellToCell.C @@ -63,7 +119,7 @@ class cellToCell : public topoSetCellSource { - // Private data + // Private Data //- Add usage string static addToUsageTable usage_; @@ -77,6 +133,7 @@ public: //- Runtime type information TypeName("cellToCell"); + // Constructors //- Construct from components @@ -100,7 +157,6 @@ public: const topoSetSource::setAction action, topoSet& set ) const; - }; diff --git a/src/meshTools/sets/cellSources/cylinderAnnulusToCell/cylinderAnnulusToCell.C b/src/meshTools/sets/cellSources/cylinderAnnulusToCell/cylinderAnnulusToCell.C index c233045bf9..54b4bf1903 100644 --- a/src/meshTools/sets/cellSources/cylinderAnnulusToCell/cylinderAnnulusToCell.C +++ b/src/meshTools/sets/cellSources/cylinderAnnulusToCell/cylinderAnnulusToCell.C @@ -121,7 +121,15 @@ Foam::cylinderAnnulusToCell::cylinderAnnulusToCell point2_(point2), radius_(radius), innerRadius_(innerRadius) -{} +{ + if (innerRadius_ > radius_) + { + FatalErrorInFunction + << "inner radius = " << innerRadius_ << "cannot be larger than " + << "outer radius = " << radius_ + << exit(FatalIOError); + } +} Foam::cylinderAnnulusToCell::cylinderAnnulusToCell @@ -135,8 +143,8 @@ Foam::cylinderAnnulusToCell::cylinderAnnulusToCell mesh, dict.get("p1"), dict.get("p2"), - dict.get("outerRadius"), - dict.get("innerRadius") + dict.getCheck("outerRadius", scalarMinMax::ge(SMALL)), + dict.getCheck("innerRadius", scalarMinMax::ge(0)) ) {} diff --git a/src/meshTools/sets/cellSources/cylinderAnnulusToCell/cylinderAnnulusToCell.H b/src/meshTools/sets/cellSources/cylinderAnnulusToCell/cylinderAnnulusToCell.H index fa8314b013..7a449fb2a1 100644 --- a/src/meshTools/sets/cellSources/cylinderAnnulusToCell/cylinderAnnulusToCell.H +++ b/src/meshTools/sets/cellSources/cylinderAnnulusToCell/cylinderAnnulusToCell.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011 OpenFOAM Foundation - Copyright (C) 2018 OpenCFD Ltd. + Copyright (C) 2018-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -27,19 +27,64 @@ License Class Foam::cylinderAnnulusToCell -Description - A topoSetCellSource to select cells based on cell centres inside a - cylinder annulus. +Group + grpCellSources - \heading Dictionary parameters +Description + A \c topoSetCellSource to select all cells whose cell + centre inside a given bounding cylinder annulus. + + Operands: \table - Property | Description | Required | Default - p1 | Coordinate of endpoint | yes | - p2 | Coordinate of endpoint | yes | - outerRadius | Cylinder outer radius | yes | - innerRadius | Cylinder inner radius | yes | + Operand | Type | Location + output | cellSet | $FOAM_CASE/constant/polyMesh/sets/\ \endtable +Usage + Minimal example by using \c system/topoSetDict.actions: + \verbatim + { + // Mandatory (inherited) entries + name ; + type cellSet; + action ; + + // Mandatory entries + source cylinderAnnulusToCell; + p1 ( ); + p2 ( ); + outerRadius ; + + // Optional entries + innerRadius ; + } + \endverbatim + + where the entries mean: + \table + Property | Description | Type | Req'd | Dflt + name | Name of cellSet | word | yes | - + type | Type name: cellSet | word | yes | - + action | Action applied on cells - see below | word | yes | - + source | Source name: cylinderAnnulusToCell | word | yes | - + p1 | Coordinate of one of the endpoints | vector | yes | - + p2 | Coordinate of the other endpoint | vector | yes | - + outerRadius | Cylinder outer radius | scalar | yes | - + innerRadius | Cylinder inner radius | scalar | no | 0 + \endtable + + Options for the \c action entry: + \verbatim + new | Create a new cellSet from selected cells + add | Add selected cells into this cellSet + subtract | Remove selected cells from this cellSet + \endverbatim + +See also + - Foam::topoSetSource + - Foam::topoSetCellSource + - Foam::cylinderToCell + SourceFiles cylinderAnnulusToCell.C @@ -63,8 +108,7 @@ class cylinderAnnulusToCell : public topoSetCellSource { - - // Private data + // Private Data //- Add usage string static addToUsageTable usage_; @@ -123,7 +167,6 @@ public: const topoSetSource::setAction action, topoSet& set ) const; - }; diff --git a/src/meshTools/sets/cellSources/cylinderToCell/cylinderToCell.C b/src/meshTools/sets/cellSources/cylinderToCell/cylinderToCell.C index 3114d74cf0..1856b4184d 100644 --- a/src/meshTools/sets/cellSources/cylinderToCell/cylinderToCell.C +++ b/src/meshTools/sets/cellSources/cylinderToCell/cylinderToCell.C @@ -110,7 +110,15 @@ Foam::cylinderToCell::cylinderToCell point2_(point2), radius_(radius), innerRadius_(innerRadius) -{} +{ + if (innerRadius_ > radius_) + { + FatalErrorInFunction + << "inner radius = " << innerRadius_ << "cannot be larger than " + << "outer radius = " << radius_ + << exit(FatalIOError); + } +} Foam::cylinderToCell::cylinderToCell @@ -124,8 +132,8 @@ Foam::cylinderToCell::cylinderToCell mesh, dict.get("p1"), dict.get("p2"), - dict.get("radius"), - dict.getOrDefault("innerRadius", 0) + dict.getCheck("radius", scalarMinMax::ge(SMALL)), + dict.getCheckOrDefault("innerRadius", 0, scalarMinMax::ge(0)) ) {} diff --git a/src/meshTools/sets/cellSources/cylinderToCell/cylinderToCell.H b/src/meshTools/sets/cellSources/cylinderToCell/cylinderToCell.H index d98015ac8c..035fe2283d 100644 --- a/src/meshTools/sets/cellSources/cylinderToCell/cylinderToCell.H +++ b/src/meshTools/sets/cellSources/cylinderToCell/cylinderToCell.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011 OpenFOAM Foundation - Copyright (C) 2018 OpenCFD Ltd. + Copyright (C) 2018-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -28,17 +28,60 @@ Class Foam::cylinderToCell Description - A topoSetCellSource to select cells with their centres inside a cylinder. + A \c topoSetCellSource to select all cells whose cell centre + inside a given bounding cylinder or cylinder annulus. - \heading Dictionary parameters + Operands: \table - Property | Description | Required | Default - p1 | Coordinate of endpoint | yes | - p2 | Coordinate of endpoint | yes | - radius | Cylinder (outer) radius | yes | - innerRadius | Cylinder inner radius | no | 0 + Operand | Type | Location + output | cellSet | $FOAM_CASE/constant/polyMesh/sets/\ \endtable +Usage + Minimal example by using \c system/topoSetDict.actions: + \verbatim + { + // Mandatory (inherited) entries + name ; + type cellSet; + action ; + + // Mandatory entries + source cylinderToCell; + p1 ( ); + p2 ( ); + radius ; + + // Optional entries + innerRadius ; + } + \endverbatim + + where the entries mean: + \table + Property | Description | Type | Req'd | Dflt + name | Name of cellSet | word | yes | - + type | Type name: cellSet | word | yes | - + action | Action applied on cells - see below | word | yes | - + source | Source name: cylinderToCell | word | yes | - + p1 | Coordinate of one of the endpoints | vector | yes | - + p2 | Coordinate of the other endpoint | vector | yes | - + radius | Cylinder outer radius | scalar | yes | - + innerRadius | Cylinder inner radius | scalar | no | 0 + \endtable + + Options for the \c action entry: + \verbatim + new | Create a new cellSet from selected cells + add | Add selected cells into this cellSet + subtract | Remove selected cells from this cellSet + \endverbatim + +See also + - Foam::topoSetSource + - Foam::topoSetCellSource + - Foam::cylinderAnnulusToCell + SourceFiles cylinderToCell.C @@ -62,8 +105,7 @@ class cylinderToCell : public topoSetCellSource { - - // Private data + // Private Data //- Add usage string static addToUsageTable usage_; @@ -122,7 +164,6 @@ public: const topoSetSource::setAction action, topoSet& set ) const; - }; diff --git a/src/meshTools/sets/cellSources/faceToCell/faceToCell.H b/src/meshTools/sets/cellSources/faceToCell/faceToCell.H index 68652e4cfb..8e39500ba3 100644 --- a/src/meshTools/sets/cellSources/faceToCell/faceToCell.H +++ b/src/meshTools/sets/cellSources/faceToCell/faceToCell.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011 OpenFOAM Foundation - Copyright (C) 2018 OpenCFD Ltd. + Copyright (C) 2018-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -28,18 +28,86 @@ Class Foam::faceToCell Description - A topoSetCellSource to select cells based on usage in a face set. + A \c topoSetCellSource to select all cells based on usage in given + \c faceSet(s), e.g. select cells that are the \c owner/neighbour/any + of the faces in a given \c faceSet. - \heading Dictionary parameters + Operands: \table - Property | Description | Required | Default - sets | The faceSet names to use | possibly | - set | The faceSet name to use | possibly | - option | Selection type (all/any/owner/neighbour) | yes | + Operand | Type | Location + input | faceSet(s) | $FOAM_CASE/constant/polyMesh/sets/\ + output | cellSet | $FOAM_CASE/constant/polyMesh/sets/\ \endtable +Usage + Minimal example by using \c system/topoSetDict.actions: + \verbatim + { + // Mandatory (inherited) entries + name ; + type cellSet; + action ; + + // Mandatory entries + source faceToCell; + option