zoneToCell.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 OpenFOAM Foundation
9  Copyright (C) 2018-2021 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
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 
27 Class
28  Foam::zoneToCell
29 
30 Description
31  A \c topoSetCellSource to convert \c cellZone(s) to a \c cellSet.
32 
33  Operands:
34  \table
35  Operand | Type | Location
36  input | cellZone(s) | $FOAM_CASE/constant/polyMesh/cellZones
37  output | cellSet | $FOAM_CASE/constant/polyMesh/sets/<set>
38  \endtable
39 
40 Usage
41  Minimal example by using \c system/topoSetDict.actions:
42  \verbatim
43  {
44  // Mandatory (inherited) entries
45  name <name>;
46  type cellSet;
47  action <action>;
48 
49  // Mandatory entries
50  source zoneToCell;
51 
52  // Conditional mandatory entries
53  // Select either of the below
54 
55  // Option-1
56  zones
57  (
58  <cellZoneName0>
59  <cellZoneName1>
60  ...
61  );
62 
63  // Option-2
64  zone <cellZoneName>;
65  }
66  \endverbatim
67 
68  where the entries mean:
69  \table
70  Property | Description | Type | Req'd | Dflt
71  name | Name of cellSet | word | yes | -
72  type | Type name: cellSet | word | yes | -
73  action | Action applied on cells - see below | word | yes | -
74  source | Source name: zoneToCell | word | yes | -
75  \endtable
76 
77  Options for the \c action entry:
78  \verbatim
79  new | Create a new cellSet from selected cells
80  add | Add selected cells into this cellsSet
81  subtract | Remove selected cells from this cellSet
82  \endverbatim
83 
84  Options for the conditional mandatory entries:
85  \verbatim
86  Entry | Description | Type | Req'd | Dflt
87  zones | Names of input cellZones | wordRes | cond'l | -
88  zone | Name of input cellZone | wordRe | cond'l | -
89  \endverbatim
90 
91 Note
92  The order of precedence among the conditional mandatory entries from the
93  highest to the lowest is \c zones, and \c zone.
94 
95 See also
96  - Foam::topoSetSource
97  - Foam::topoSetCellSource
98 
99 SourceFiles
100  zoneToCell.C
101 
102 \*---------------------------------------------------------------------------*/
103 
104 #ifndef zoneToCell_H
105 #define zoneToCell_H
106 
107 #include "topoSetCellSource.H"
108 #include "wordRes.H"
109 
110 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
111 
112 namespace Foam
113 {
114 
115 /*---------------------------------------------------------------------------*\
116  Class zoneToCell Declaration
117 \*---------------------------------------------------------------------------*/
118 
119 class zoneToCell
120 :
121  public topoSetCellSource
122 {
123  // Private Data
124 
125  //- Add usage string
126  static addToUsageTable usage_;
127 
128  //- Matcher for zones
129  wordRes zoneMatcher_;
130 
131  //- Explicitly specified zone ids
132  labelList zoneIDs_;
133 
134 
135  // Private Member Functions
136 
137  void combine
138  (
139  topoSet& set,
140  const labelUList& zoneIDs,
141  const bool add,
142  const bool verbosity
143  ) const;
144 
145  void combine(topoSet& set, const bool add) const;
146 
147 
148 public:
149 
150  //- Runtime type information
151  TypeName("zoneToCell");
152 
153 
154  // Constructors
155 
156  //- Construct from mesh and zones selector
157  zoneToCell(const polyMesh& mesh, const wordRes& zoneSelector);
158 
159  //- Construct from mesh and single zone selector
160  zoneToCell(const polyMesh& mesh, const wordRe& zoneName);
161 
162  //- Construct from mesh and specified zone IDs
163  zoneToCell(const polyMesh& mesh, const labelUList& zoneIDs);
164 
165  //- Construct from dictionary
166  zoneToCell(const polyMesh& mesh, const dictionary& dict);
167 
168  //- Construct from Istream
169  zoneToCell(const polyMesh& mesh, Istream& is);
170 
171 
172  //- Destructor
173  virtual ~zoneToCell() = default;
174 
175 
176  // Member Functions
177 
178  //- Return the current zones selector
179  const wordRes& zones() const noexcept;
180 
181  //- Define the zones selector
182  void zones(const wordRes& zoneSelector);
183 
184  //- Define the zones selector with a single zone selector
185  void zones(const wordRe& zoneName);
186 
187  //- Define the cellZone IDs to use (must exist).
188  // Clears the zone name matcher
189  void zones(const labelUList& zoneIDs);
190 
191  //- Define the cellZone ID to use (must exist).
192  // Clears the zone name matcher
193  void zones(const label zoneID);
194 
195 
196  virtual void applyToSet
197  (
198  const topoSetSource::setAction action,
199  topoSet& set
200  ) const;
201 };
202 
203 
204 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
205 
206 } // End namespace Foam
207 
208 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
209 
210 #endif
211 
212 // ************************************************************************* //
Foam::zoneToCell::zoneToCell
zoneToCell(const polyMesh &mesh, const wordRes &zoneSelector)
Construct from mesh and zones selector.
Definition: zoneToCell.C:145
Foam::labelList
List< label > labelList
A List of labels.
Definition: List.H:67
wordRes.H
Foam::BitOps::set
void set(List< bool > &bools, const labelRange &range)
Set the specified range 'on' in a boolList.
Definition: BitOps.C:37
Foam::zoneToCell
A topoSetCellSource to convert cellZone(s) to a cellSet.
Definition: zoneToCell.H:160
Foam::combine
Definition: FaceCellWave.C:57
Foam::topoSetSource::setAction
setAction
Enumeration defining the valid actions.
Definition: topoSetSource.H:100
Foam::wordRe
A wordRe is a Foam::word, but can contain a regular expression for matching words or strings.
Definition: wordRe.H:80
zoneIDs
const labelIOList & zoneIDs
Definition: correctPhi.H:59
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:77
Foam::zoneToCell::zones
const wordRes & zones() const noexcept
Return the current zones selector.
Definition: zoneToCell.C:209
Foam::zoneToCell::TypeName
TypeName("zoneToCell")
Runtime type information.
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:61
Foam::zoneToCell::~zoneToCell
virtual ~zoneToCell()=default
Destructor.
Foam::topoSet
General set of labels of mesh quantity (points, cells, faces).
Definition: topoSet.H:63
topoSetCellSource.H
Foam::zoneToCell::applyToSet
virtual void applyToSet(const topoSetSource::setAction action, topoSet &set) const
Apply specified action to the topoSet.
Definition: zoneToCell.C:246
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
Foam::add
void add(FieldField< Field1, typename typeOfSum< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
Definition: FieldFieldFunctions.C:939
zoneID
const labelIOList & zoneID
Definition: interpolatedFaces.H:22
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::topoSetSource
Base class of a source for a topoSet.
Definition: topoSetSource.H:67
Foam::List< label >
Foam::UList< label >
Foam::topoSetCellSource
The topoSetCellSource is a intermediate class for handling topoSet sources for selecting cells.
Definition: topoSetCellSource.H:54
Foam::wordRes
A List of wordRe with additional matching capabilities.
Definition: wordRes.H:51
Foam::topoSetSource::mesh
const polyMesh & mesh() const noexcept
Reference to the mesh.
Definition: topoSetSource.H:342
Foam::labelUList
UList< label > labelUList
A UList of labels.
Definition: UList.H:85