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-2020 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 nErode <label>;
63 }
64 \endverbatim
65
66 where the entries mean:
67 \table
68 Property | Description | Type | Req'd | Dflt
69 name | Name of cellSet | word | yes | -
70 type | Type name: cellSet | word | yes | -
71 action | Action applied on cells - see below | word | yes | -
72 source | Source name: regionToCell | word | yes | -
73 insidePoints | Coordinate(s) that is inside connected region <!--
74 --> | vectorList | yes | -
75 set | Name of cellSet giving mesh subset | word | no | none
76 nErode | Number of cell layers to erode mesh to detect holes <!--
77 --> in the mesh - set to 0 if not used | label | no | 0
78 \endtable
79
80 Options for the \c action entry:
81 \verbatim
82 new | Create a new cellSet from selected cells
83 add | Add selected cells into this cellSet
84 subtract | Remove selected cells from this cellSet
85 \endverbatim
86
87See also
88 - Foam::topoSetSource
89 - Foam::topoSetCellSource
90
91SourceFiles
92 regionToCell.C
93
94\*---------------------------------------------------------------------------*/
95
96#ifndef regionToCell_H
97#define regionToCell_H
98
99#include "topoSetCellSource.H"
100#include "boolList.H"
101
102// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
103
104namespace Foam
105{
106
107class regionSplit;
108
109/*---------------------------------------------------------------------------*\
110 Class regionToCell Declaration
111\*---------------------------------------------------------------------------*/
112
113class regionToCell
114:
115 public topoSetCellSource
116{
117 // Private Data
118
119 //- Add usage string
120 static addToUsageTable usage_;
121
122 //- Name of cellSet to keep to
123 const word setName_;
124
125 //- Coordinate(s) that is inside connected region
126 const pointField insidePoints_;
127
128 //- Number of layers to erode
129 const label nErode_;
130
131
132 // Private Member Functions
133
134 //- Mark faces inbetween selected and unselected elements
135 void markRegionFaces
136 (
137 const boolList& selectedCell,
138 boolList& regionFace
139 ) const;
140
141 //- Determine for every disconnected region in the mesh whether
142 //- it contains a locationInMesh
143 boolList findRegions(const bool verbose, const regionSplit&) const;
144
145 //- Unselect regions not containing a locationInMesh
146 void unselectOutsideRegions(boolList& selectedCell) const;
147
148 //- Unselect one layer of cells from selectedCell
149 void shrinkRegions(boolList& selectedCell) const;
150
151 //- Erode a given number of layers from selectedCell. Remove any
152 //- region that gets disconnected that way.
153 void erode(boolList& selectedCell) const;
154
155 void combine(topoSet& set, const bool add) const;
156
157
158public:
159
160 //- Runtime type information
161 TypeName("regionToCell");
162
163
164 // Constructors
165
166 //- Construct from components
168 (
169 const polyMesh& mesh,
170 const word& setName,
172 const label nErode
173 );
174
175 //- Construct from dictionary
177
178 //- Construct from Istream
179 regionToCell(const polyMesh& mesh, Istream& is);
180
181
182 //- Destructor
183 virtual ~regionToCell() = default;
184
185
186 // Member Functions
187
188 virtual void applyToSet
189 (
190 const topoSetSource::setAction action,
191 topoSet& set
192 ) const;
193};
194
195
196// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
197
198} // End namespace Foam
199
200// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
201
202#endif
203
204// ************************************************************************* //
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:64
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:81
This class separates the mesh into distinct unconnected regions, each of which is then given a label ...
Definition: regionSplit.H:144
A topoSetCellSource to select cells belonging to a topologically connected region (that contains give...
Definition: regionToCell.H:179
TypeName("regionToCell")
Runtime type information.
regionToCell(const polyMesh &mesh, const word &setName, const pointField &insidePoints, const label nErode)
Construct from components.
Definition: regionToCell.C:387
virtual void applyToSet(const topoSetSource::setAction action, topoSet &set) const
Apply specified action to the topoSet.
Definition: regionToCell.C:433
virtual ~regionToCell()=default
Destructor.
The topoSetCellSource is a intermediate class for handling topoSet sources for selecting cells.
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:67
A class for handling words, derived from Foam::string.
Definition: word.H:68
Namespace for OpenFOAM.
vectorField pointField
pointField is a vectorField.
Definition: pointFieldFwd.H:44
void add(FieldField< Field1, typename typeOfSum< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
List< bool > boolList
A List of bools.
Definition: List.H:64
nErode
Definition: regionsToCell.H:39
insidePoints((1 2 3))
dictionary dict
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition: typeInfo.H:73