faceToCell.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-2020 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::faceToCell
29 
30 Description
31  A \c topoSetCellSource to select all cells based on usage in given
32  \c faceSet(s), e.g. select cells that are the \c owner/neighbour/any
33  of the faces in a given \c faceSet.
34 
35  Operands:
36  \table
37  Operand | Type | Location
38  input | faceSet(s) | $FOAM_CASE/constant/polyMesh/sets/<set>
39  output | cellSet | $FOAM_CASE/constant/polyMesh/sets/<set>
40  \endtable
41 
42 Usage
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 faceToCell;
53  option <option>;
54 
55  // Conditional mandatory entries
56  // Select either of the below
57 
58  // Option-1
59  sets
60  (
61  <faceSetName0>
62  <faceSetName1>
63  ...
64  );
65 
66  // Option-2
67  set <faceSetName>;
68  }
69  \endverbatim
70 
71  where the entries mean:
72  \table
73  Property | Description | Type | Req'd | Dflt
74  name | Name of cellSet | word | yes | -
75  type | Type name: cellSet | word | yes | -
76  action | Action applied on cells - see below | word | yes | -
77  source | Source name: faceToCell | word | yes | -
78  option | Selection type - see below | word | yes | -
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 
88  Options for the \c option entry:
89  \verbatim
90  all | Cells that are either owner or neighbour of given faces
91  any | Cells that are either owner or neighbour of given faces
92  owner | Cells that are owner of given faces
93  neighbour | Cells that are neighbour of given faces
94  \endverbatim
95 
96  Options for the conditional mandatory entries:
97  \verbatim
98  Entry | Description | Type | Req'd | Dflt
99  sets | Names of input faceSets | wordList | cond'l | -
100  set | Name of input faceSet | word | cond'l | -
101  \endverbatim
102 
103 Note
104  The order of precedence among the conditional mandatory entries from the
105  highest to the lowest is \c sets, and \c set.
106 
107 See also
108  - Foam::topoSetSource
109  - Foam::topoSetCellSource
110  - Foam::faceZoneToCell
111 
112 SourceFiles
113  faceToCell.C
114 
115 \*---------------------------------------------------------------------------*/
116 
117 #ifndef faceToCell_H
118 #define faceToCell_H
119 
120 #include "topoSetCellSource.H"
121 #include "Enum.H"
122 
123 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
124 
125 namespace Foam
126 {
127 
128 /*---------------------------------------------------------------------------*\
129  Class faceToCell Declaration
130 \*---------------------------------------------------------------------------*/
131 
132 class faceToCell
133 :
134  public topoSetCellSource
135 {
136 public:
137  //- Enumeration defining the valid options
138  enum faceAction
139  {
140  ANY,
141  ALL,
142  OWNER,
143  NEIGHBOUR
144  };
145 
146 
147 private:
148 
149  // Private Data
150 
151  static const Enum<faceAction> faceActionNames_;
152 
153  //- Add usage string
154  static addToUsageTable usage_;
155 
156  //- Names of sets to use
157  wordList names_;
158 
159  //- Option
160  faceAction option_;
161 
162 
163  // Private Member Functions
164 
165  //- Depending on face to cell option add to or delete from cellSet.
166  void combine(topoSet& set, const bool add, const word& setName) const;
167 
168 
169 public:
170 
171  //- Runtime type information
172  TypeName("faceToCell");
173 
174 
175  // Constructors
176 
177  //- Construct from components
178  faceToCell
179  (
180  const polyMesh& mesh,
181  const word& setName,
182  const faceAction option
183  );
184 
185  //- Construct from dictionary
186  faceToCell(const polyMesh& mesh, const dictionary& dict);
187 
188  //- Construct from Istream
190 
191 
192  //- Destructor
193  virtual ~faceToCell() = default;
194 
195 
196  // Member Functions
197 
198  virtual void applyToSet
199  (
200  const topoSetSource::setAction action,
201  topoSet& set
202  ) const;
203 };
204 
205 
206 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
207 
208 } // End namespace Foam
209 
210 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
211 
212 #endif
213 
214 // ************************************************************************* //
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::faceToCell::faceAction
faceAction
Enumeration defining the valid options.
Definition: faceToCell.H:185
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::faceToCell::NEIGHBOUR
Definition: faceToCell.H:190
Foam::faceToCell::~faceToCell
virtual ~faceToCell()=default
Destructor.
Foam::combine
Definition: FaceCellWave.C:57
Foam::faceToCell::OWNER
Definition: faceToCell.H:189
Foam::faceToCell
A topoSetCellSource to select all cells based on usage in given faceSet(s), e.g. select cells that ar...
Definition: faceToCell.H:179
Foam::topoSetSource::setAction
setAction
Enumeration defining the valid actions.
Definition: topoSetSource.H:100
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:77
Foam::faceToCell::TypeName
TypeName("faceToCell")
Runtime type information.
Foam::wordList
List< word > wordList
A List of words.
Definition: fileName.H:62
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:61
Foam::topoSet
General set of labels of mesh quantity (points, cells, faces).
Definition: topoSet.H:63
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
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::faceToCell::faceToCell
faceToCell(const polyMesh &mesh, const word &setName, const faceAction option)
Construct from components.
Definition: faceToCell.C:140
Foam::List< word >
Foam::topoSetCellSource
The topoSetCellSource is a intermediate class for handling topoSet sources for selecting cells.
Definition: topoSetCellSource.H:54
Foam::faceToCell::ANY
Definition: faceToCell.H:187
Foam::topoSetSource::mesh
const polyMesh & mesh() const noexcept
Reference to the mesh.
Definition: topoSetSource.H:342
Foam::faceToCell::applyToSet
virtual void applyToSet(const topoSetSource::setAction action, topoSet &set) const
Apply specified action to the topoSet.
Definition: faceToCell.C:186
Foam::faceToCell::ALL
Definition: faceToCell.H:188
Enum.H