faceZoneToCell.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-2023 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::faceZoneToCell
29 
30 Description
31  A \c topoSetCellSource to select cells based on \c front
32  or \c back side of given \c faceZone(s).
33 
34  Operands:
35  \table
36  Operand | Type | Location
37  input | faceZone(s) | $FOAM_CASE/constant/polyMesh/faceZones
38  output | cellSet | $FOAM_CASE/constant/polyMesh/sets/<set>
39  \endtable
40 
41 Usage
42  Minimal example by using \c system/topoSetDict.actions:
43  \verbatim
44  {
45  // Mandatory (inherited) entries
46  name <name>;
47  type cellSet;
48  action <action>;
49 
50  // Mandatory entries
51  source faceZoneToCell;
52  option <option>;
53 
54  // Conditional mandatory entries
55  // Select either of the below
56 
57  // Option-1
58  zones
59  (
60  <faceZoneName1>
61  <faceZoneName2>
62  ...
63  );
64 
65  // Option-2
66  set <faceZoneName>;
67  }
68  \endverbatim
69 
70  where the entries mean:
71  \table
72  Property | Description | Type | Req'd | Dflt
73  name | Name of cellSet | word | yes | -
74  type | Type name: cellSet | word | yes | -
75  action | Action applied on cells - see below | word | yes | -
76  source | Source name: faceZoneToCell | word | yes | -
77  option | Selection type - see below | word | yes | -
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 
87  Options for the \c option entry:
88  \verbatim
89  front | Cells on the front side of the faceZone (also as 'master')
90  back | Cells on the back side of the faceZone (also as 'slave')
91  both | Both front and back side of the faceZone
92  \endverbatim
93 
94  Options for the conditional mandatory entries:
95  \verbatim
96  Entry | Description | Type | Req'd | Dflt
97  zones | Names of input faceZones | wordRes | cond'l | -
98  zone | Name of input faceZone | wordRe | cond'l | -
99  \endverbatim
100 
101 Note
102  The order of precedence among the conditional mandatory entries from the
103  highest to the lowest is \c zones, and \c zone.
104 
105 See also
106  - Foam::topoSetSource
107  - Foam::topoSetCellSource
108  - Foam::faceToCell
109 
110 SourceFiles
111  faceZoneToCell.C
112 
113 \*---------------------------------------------------------------------------*/
114 
115 #ifndef faceZoneToCell_H
116 #define faceZoneToCell_H
117 
118 #include "topoSetCellSource.H"
119 #include "wordRes.H"
120 
121 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
122 
123 namespace Foam
124 {
125 
126 /*---------------------------------------------------------------------------*\
127  Class faceZoneToCell Declaration
128 \*---------------------------------------------------------------------------*/
129 
130 class faceZoneToCell
131 :
132  public topoSetCellSource
133 {
134 public:
135  //- Enumeration defining the valid options
136  enum faceAction
137  {
138  FRONT,
139  BACK,
140  BOTH,
141  // Compatibility
142  MASTER = FRONT, SLAVE = BACK
143  };
144 
145 
146 private:
147 
148  // Private Data
149 
150  static const Enum<faceAction> faceActionNames_;
151 
152  //- Add usage string
153  static addToUsageTable usage_;
154 
155  //- Matcher for face zones
156  wordRes zoneMatcher_;
157 
158  //- Selection type
159  faceAction option_;
160 
161 
162  // Private Member Functions
163 
164  void combine
165  (
166  topoSet& set,
167  const labelUList& zoneIDs,
168  const bool add,
169  const bool verbosity
170  ) const;
171 
172  void combine(topoSet& set, const bool add) const;
174 
175 public:
176 
177  //- Runtime type information
178  TypeName("faceZoneToCell");
179 
180 
181  // Constructors
182 
183  //- Construct from mesh, zones selector and selection option
185  (
186  const polyMesh& mesh,
187  const wordRes& zoneSelector,
188  const faceAction option
189  );
190 
191  //- Construct from mesh, single zone selector and selection option
193  (
194  const polyMesh& mesh,
195  const wordRe& zoneName,
196  const faceAction option
197  );
198 
199  //- Construct from dictionary
200  faceZoneToCell(const polyMesh& mesh, const dictionary& dict);
201 
202  //- Construct from Istream
203  faceZoneToCell(const polyMesh& mesh, Istream& is);
204 
205 
206  //- Destructor
207  virtual ~faceZoneToCell() = default;
208 
209 
210  // Member Functions
211 
212  //- Return the current zones selector
213  const wordRes& zones() const noexcept;
214 
215  //- Define the zones selector
216  void zones(const wordRes& zoneSelector);
217 
218  //- Define the zones selector with a single zone selector
219  void zones(const wordRe& zoneName);
220 
221 
222  virtual void applyToSet
223  (
224  const topoSetSource::setAction action,
225  topoSet& set
226  ) const;
227 };
228 
229 
230 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
231 
232 } // End namespace Foam
233 
234 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
235 
236 #endif
237 
238 // ************************************************************************* //
dictionary dict
const labelIOList & zoneIDs
Definition: correctPhi.H:59
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
const wordRes & zones() const noexcept
Return the current zones selector.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
faceZoneToCell(const polyMesh &mesh, const wordRes &zoneSelector, const faceAction option)
Construct from mesh, zones selector and selection option.
virtual ~faceZoneToCell()=default
Destructor.
virtual void applyToSet(const topoSetSource::setAction action, topoSet &set) const
Apply specified action to the topoSet.
void set(List< bool > &bools, const labelUList &locations)
Set the listed locations (assign &#39;true&#39;).
Definition: BitOps.C:30
UList< label > labelUList
A UList of labels.
Definition: UList.H:78
Base class of a source for a topoSet.
Definition: topoSetSource.H:63
faceAction
Enumeration defining the valid options.
The back (negative normal) side of the faces.
The front (positive normal) side of the faces.
const polyMesh & mesh() const noexcept
Reference to the mesh.
setAction
Enumeration defining various actions.
A List of wordRe with additional matching capabilities.
Definition: wordRes.H:53
Both front and back side of faces.
A wordRe is a Foam::word, but can contain a regular expression for matching words or strings...
Definition: wordRe.H:78
const direction noexcept
Definition: Scalar.H:258
void add(FieldField< Field1, typename typeOfSum< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
General set of labels of mesh quantity (points, cells, faces).
Definition: topoSet.H:59
TypeName("faceZoneToCell")
Runtime type information.
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
Namespace for OpenFOAM.