Loading...
Searching...
No Matches
regionToCell.H
Go to the documentation of this file.
1/*---------------------------------------------------------------------------*\
2 ========= |
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4 \\ / O peration |
5 \\ / A nd | www.openfoam.com
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2011-2012 OpenFOAM Foundation
9 Copyright (C) 2018-2024 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
12 This file is part of OpenFOAM.
13
14 OpenFOAM is free software: you can redistribute it and/or modify it
15 under the terms of the GNU General Public License as published by
16 the Free Software Foundation, either version 3 of the License, or
17 (at your option) any later version.
18
19 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26
27Class
28 Foam::regionToCell
29
30Description
31 A \c topoSetCellSource to select cells belonging to a topologically
32 connected region (that contains given points). If started inside
33 a given \c subCellSet keeps to it; if started outside stays outside.
34
35 Operands:
36 \table
37 Operand | Type | Location
38 input | region | $FOAM_CASE/constant/\{<region>, polyMesh\}
39 output | cellSet | $FOAM_CASE/constant/polyMesh/sets/<set>
40 \endtable
41
42Usage
43 Minimal example by using \c system/topoSetDict.actions:
44 \verbatim
45 {
46 // Mandatory (inherited) entries
47 name <name>;
48 type cellSet;
49 action <action>;
50
51 // Mandatory entries
52 source regionToCell;
53 insidePoints
54 (
55 (<p1x> <p1y> <p1z>)
56 (<p2x> <p2y> <p2z>)
57 ...
58 );
59
60 // Optional entries
61 set <cellSetName>;
62 zone <cellZoneName>;
63 nErode <label>;
64 }
65 \endverbatim
66
67 where the entries mean:
68 \table
69 Property | Description | Type | Req'd | Dflt
70 name | Name of cellSet | word | yes | -
71 type | Type name: cellSet | word | yes | -
72 action | Action applied on cells - see below | word | yes | -
73 source | Source name: regionToCell | word | yes | -
74 insidePoints | Coordinate(s) that is inside connected region <!--
75 --> | vectorList | yes | -
76 set / zone | Name of cellSet / zone giving mesh subset | word | no | -
77 nErode | Number of cell layers to erode mesh to detect holes <!--
78 --> in the mesh - set to 0 if not used | label | no | 0
79 \endtable
80
81 Options for the \c action entry:
82 \verbatim
83 new | Create a new cellSet from selected cells
84 add | Add selected cells into this cellSet
85 subtract | Remove selected cells from this cellSet
86 \endverbatim
87
88See also
89 - Foam::topoSetSource
90 - Foam::topoSetCellSource
91
92SourceFiles
93 regionToCell.C
94
95\*---------------------------------------------------------------------------*/
96
97#ifndef Foam_regionToCell_H
98#define Foam_regionToCell_H
99
100#include "topoSetCellSource.H"
101#include "boolList.H"
102
103// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
104
105namespace Foam
106{
107
108class regionSplit;
109
110/*---------------------------------------------------------------------------*\
111 Class regionToCell Declaration
112\*---------------------------------------------------------------------------*/
113
114class regionToCell
115:
116 public topoSetCellSource
117{
118 // Private Data
119
120 //- Add usage string
121 static addToUsageTable usage_;
122
123 //- Name of cellSet or cellZone to keep to
124 word setName_;
125
126 //- Is name a set or a zone
127 bool isZone_;
128
129 //- Coordinate(s) that is inside connected region
130 const pointField insidePoints_;
131
132 //- Number of layers to erode
133 const label nErode_;
134
135
136 // Private Member Functions
137
138 //- Mark faces inbetween selected and unselected elements
139 void markRegionFaces
140 (
141 const boolList& selectedCell,
142 boolList& regionFace
143 ) const;
144
145 //- Determine for every disconnected region in the mesh whether
146 //- it contains a locationInMesh
147 boolList findRegions(const bool verbose, const regionSplit&) const;
148
149 //- Unselect regions not containing a locationInMesh
150 void unselectOutsideRegions(boolList& selectedCell) const;
151
152 //- Unselect one layer of cells from selectedCell
153 void shrinkRegions(boolList& selectedCell) const;
154
155 //- Erode a given number of layers from selectedCell. Remove any
156 //- region that gets disconnected that way.
157 void erode(boolList& selectedCell) const;
158
159 void combine(topoSet& set, const bool add) const;
160
161
162public:
163
164 //- Runtime type information
165 TypeName("regionToCell");
166
167
168 // Constructors
169
170 //- Construct from components
172 (
174 const word& setName,
176 const label nErode
177 );
178
179 //- Construct from dictionary
180 regionToCell(const polyMesh& mesh, const dictionary& dict);
181
182 //- Construct from Istream
183 regionToCell(const polyMesh& mesh, Istream& is);
184
185
186 //- Destructor
187 virtual ~regionToCell() = default;
188
189
190 // Member Functions
191
192 virtual void applyToSet
193 (
194 const topoSetSource::setAction action,
195 topoSet& set
196 ) const;
197};
198
199
200// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
201
202} // End namespace Foam
203
204// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
205
206#endif
207
208// ************************************************************************* //
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition Istream.H:60
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
Mesh consisting of general polyhedral cells.
Definition polyMesh.H:79
This class separates the mesh into distinct unconnected regions, each of which is then given a label ...
A topoSetCellSource to select cells belonging to a topologically connected region (that contains give...
TypeName("regionToCell")
Runtime type information.
regionToCell(const polyMesh &mesh, const word &setName, const pointField &insidePoints, const label nErode)
Construct from components.
virtual void applyToSet(const topoSetSource::setAction action, topoSet &set) const
Apply specified action to the topoSet.
virtual ~regionToCell()=default
Destructor.
The topoSetCellSource is a intermediate class for handling topoSet sources for selecting cells.
topoSetCellSource(const polyMesh &mesh)
Construct from mesh.
Class with constructor to add usage string to table.
setAction
Enumeration defining various actions.
bool verbose() const noexcept
Get output verbosity.
const polyMesh & mesh() const noexcept
Reference to the mesh.
General set of labels of mesh quantity (points, cells, faces).
Definition topoSet.H:63
A class for handling words, derived from Foam::string.
Definition word.H:66
Namespace for OpenFOAM.
void add(DimensionedField< scalar, GeoMesh > &result, const dimensioned< scalar > &dt1, const DimensionedField< scalar, GeoMesh > &f2)
List< bool > boolList
A List of bools.
Definition List.H:60
vectorField pointField
pointField is a vectorField.
nErode
insidePoints((1 2 3))
dictionary dict
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition typeInfo.H:68