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-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::faceZoneToCell
29 
30 Description
31  A \c topoSetCellSource to select cells based on \c master
32  or \c slave 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  master | Master side of the faceZone
90  slave | Slave side of the faceZone
91  \endverbatim
92 
93  Options for the conditional mandatory entries:
94  \verbatim
95  Entry | Description | Type | Req'd | Dflt
96  zones | Names of input faceZones | wordRes | cond'l | -
97  zone | Name of input faceZone | wordRe | cond'l | -
98  \endverbatim
99 
100 Note
101  The order of precedence among the conditional mandatory entries from the
102  highest to the lowest is \c zones, and \c zone.
103 
104 See also
105  - Foam::topoSetSource
106  - Foam::topoSetCellSource
107  - Foam::faceToCell
108 
109 SourceFiles
110  faceZoneToCell.C
111 
112 \*---------------------------------------------------------------------------*/
113 
114 #ifndef faceZoneToCell_H
115 #define faceZoneToCell_H
116 
117 #include "topoSetCellSource.H"
118 #include "wordRes.H"
119 
120 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
121 
122 namespace Foam
123 {
124 
125 /*---------------------------------------------------------------------------*\
126  Class faceZoneToCell Declaration
127 \*---------------------------------------------------------------------------*/
128 
129 class faceZoneToCell
130 :
131  public topoSetCellSource
132 {
133 public:
134  //- Enumeration defining the valid options
135  enum faceAction
136  {
137  MASTER,
138  SLAVE
139  };
140 
141 
142 private:
143 
144  // Private Data
145 
146  static const Enum<faceAction> faceActionNames_;
147 
148  //- Add usage string
149  static addToUsageTable usage_;
150 
151  //- Matcher for face zones
152  wordRes zoneMatcher_;
153 
154  //- Selection type
155  faceAction option_;
156 
157 
158  // Private Member Functions
159 
160  void combine
161  (
162  topoSet& set,
163  const labelUList& zoneIDs,
164  const bool add,
165  const bool verbosity
166  ) const;
167 
168  void combine(topoSet& set, const bool add) const;
169 
170 
171 public:
172 
173  //- Runtime type information
174  TypeName("faceZoneToCell");
175 
176 
177  // Constructors
178 
179  //- Construct from mesh, zones selector and selection option
181  (
182  const polyMesh& mesh,
183  const wordRes& zoneSelector,
184  const faceAction option
185  );
186 
187  //- Construct from mesh, single zone selector and selection option
189  (
190  const polyMesh& mesh,
191  const wordRe& zoneName,
192  const faceAction option
193  );
194 
195  //- Construct from dictionary
196  faceZoneToCell(const polyMesh& mesh, const dictionary& dict);
197 
198  //- Construct from Istream
199  faceZoneToCell(const polyMesh& mesh, Istream& is);
200 
201 
202  //- Destructor
203  virtual ~faceZoneToCell() = default;
204 
205 
206  // Member Functions
207 
208  //- Return the current zones selector
209  const wordRes& zones() const noexcept;
210 
211  //- Define the zones selector
212  void zones(const wordRes& zoneSelector);
213 
214  //- Define the zones selector with a single zone selector
215  void zones(const wordRe& zoneName);
216 
217 
218  virtual void applyToSet
219  (
220  const topoSetSource::setAction action,
221  topoSet& set
222  ) const;
223 };
224 
225 
226 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
227 
228 } // End namespace Foam
229 
230 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
231 
232 #endif
233 
234 // ************************************************************************* //
Foam::faceZoneToCell::faceZoneToCell
faceZoneToCell(const polyMesh &mesh, const wordRes &zoneSelector, const faceAction option)
Construct from mesh, zones selector and selection option.
Definition: faceZoneToCell.C:147
wordRes.H
Foam::Enum< faceAction >
Foam::BitOps::set
void set(List< bool > &bools, const labelRange &range)
Set the specified range 'on' in a boolList.
Definition: BitOps.C:37
Foam::combine
Definition: FaceCellWave.C:57
Foam::faceZoneToCell::SLAVE
Definition: faceZoneToCell.H:185
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::faceZoneToCell::~faceZoneToCell
virtual ~faceZoneToCell()=default
Destructor.
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:61
Foam::faceZoneToCell::TypeName
TypeName("faceZoneToCell")
Runtime type information.
Foam::topoSet
General set of labels of mesh quantity (points, cells, faces).
Definition: topoSet.H:63
Foam::faceZoneToCell::faceAction
faceAction
Enumeration defining the valid options.
Definition: faceZoneToCell.H:182
topoSetCellSource.H
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
Foam::faceZoneToCell::MASTER
Definition: faceZoneToCell.H:184
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::topoSetSource
Base class of a source for a topoSet.
Definition: topoSetSource.H:67
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::faceZoneToCell::zones
const wordRes & zones() const noexcept
Return the current zones selector.
Definition: faceZoneToCell.C:206
Foam::topoSetSource::mesh
const polyMesh & mesh() const noexcept
Reference to the mesh.
Definition: topoSetSource.H:342
Foam::faceZoneToCell
A topoSetCellSource to select cells based on master or slave side of given faceZone(s).
Definition: faceZoneToCell.H:176
Foam::labelUList
UList< label > labelUList
A UList of labels.
Definition: UList.H:85
Foam::faceZoneToCell::applyToSet
virtual void applyToSet(const topoSetSource::setAction action, topoSet &set) const
Apply specified action to the topoSet.
Definition: faceZoneToCell.C:226