topoBoolSet.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) 2018 OpenCFD Ltd.
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 Class
27  Foam::topoBoolSet
28 
29 Description
30  Base for a special purpose topoSet using labels stored as a boolList.
31 
32 SourceFiles
33  topoBoolSet.C
34 
35 \*---------------------------------------------------------------------------*/
36 
37 #ifndef Foam_topoBoolSet_H
38 #define Foam_topoBoolSet_H
39 
40 #include "topoSet.H"
41 #include "boolList.H"
42 
43 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
44 
45 namespace Foam
46 {
47 
48 /*---------------------------------------------------------------------------*\
49  Class topoBoolSet Declaration
50 \*---------------------------------------------------------------------------*/
51 
52 class topoBoolSet
53 :
54  public topoSet
55 {
56 protected:
57 
58  // Protected Data
59 
61 
62 
63  // Protected Member Functions
64 
65  //- Update map from map.
66  // Used to update cell/face labels after morphing
67  virtual void updateLabels(const labelUList& map);
68 
69  //- Check limits on addressable range.
70  virtual void check(const label maxSize);
71 
72 
73  //- Construct (no-read) with empty selection
74  topoBoolSet(const polyMesh& mesh, const word& setName);
75 
76  //- Construct (no-read) with \c size elements of initial value
78  (
79  const polyMesh& mesh,
80  const word& setName,
81  const label size,
82  const bool val
83  );
84 
85  //- Copy construct with list values, size elements
87  (
88  const polyMesh& mesh,
89  const word& setName,
90  const label size,
91  const boolList& bools
92  );
93 
94  //- Move construct with list values, size elements
96  (
97  const polyMesh& mesh,
98  const word& setName,
99  const label size,
100  boolList&& bools
101  );
102 
103 public:
104 
105  //- Destructor
106  virtual ~topoBoolSet() = default;
107 
108 
109  // Member Functions
110 
111  //- Return the boolList
112  const boolList& addressing() const noexcept
113  {
114  return selected_;
115  }
116 
117  //- Access the boolList
119  {
120  return selected_;
121  }
122 
123  //- Set values to false, leaving the size untouched
124  void reset()
125  {
126  selected_ = false;
127  }
128 
129  //- Has the given index?
130  virtual bool contains(const label id) const;
131 
132  //- Has the given index?
133  virtual bool found(const label id) const;
134 
135  //- Set an index
136  virtual bool set(const label id);
137 
138  //- Unset an index
139  virtual bool unset(const label id);
141  //- Set multiple indices
142  virtual void set(const labelUList& labels);
143 
144  //- Unset multiple indices
145  virtual void unset(const labelUList& labels);
146 
147  //- Invert contents.
148  // Insert all members [0,maxLen) which were not in set.
149  virtual void invert(const label maxLen);
150 
151  //- Subset contents. Only elements present in both sets remain.
152  virtual void subset(const labelUList& elems);
153 
154  //- Subset contents. Only elements present in both sets remain.
155  virtual void subset(const topoSet& set);
156 
157  //- Add given elements to the set
158  virtual void addSet(const labelUList& elems);
159 
160  //- Add given elements to the set
161  virtual void addSet(const topoSet& set);
162 
163  //- Subtract given elements from the set.
164  virtual void subtractSet(const labelUList& elems);
165 
166  //- Subtract given elements from the set.
167  virtual void subtractSet(const topoSet& set);
168 };
169 
170 
171 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
172 
173 } // End namespace Foam
174 
175 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
176 
177 #endif
178 
179 // ************************************************************************* //
virtual void subset(const labelUList &elems)
Subset contents. Only elements present in both sets remain.
Definition: topoBoolSet.C:251
virtual label maxSize(const polyMesh &mesh) const =0
Return max allowable index (+1). Not implemented.
void reset()
Set values to false, leaving the size untouched.
Definition: topoBoolSet.H:140
virtual bool unset(const label id)
Unset an index.
Definition: topoBoolSet.C:200
virtual bool contains(const label id) const
Has the given index?
Definition: topoBoolSet.C:182
virtual void invert(const label maxLen)
Invert contents.
Definition: topoBoolSet.C:224
const boolList & addressing() const noexcept
Return the boolList.
Definition: topoBoolSet.H:124
boolList selected_
Definition: topoBoolSet.H:55
virtual ~topoBoolSet()=default
Destructor.
label size() const noexcept
The number of elements in table.
Definition: HashTable.H:358
dynamicFvMesh & mesh
Base for a special purpose topoSet using labels stored as a boolList.
Definition: topoBoolSet.H:47
A class for handling words, derived from Foam::string.
Definition: word.H:63
virtual void addSet(const labelUList &elems)
Add given elements to the set.
Definition: topoBoolSet.C:280
virtual bool found(const label id) const
Has the given index?
Definition: topoBoolSet.C:188
const direction noexcept
Definition: Scalar.H:258
List< bool > bools(const labelHashSet &locations)
Transform the on locations to a boolList, with true for each non-negative location and false for all ...
Definition: HashOps.C:72
virtual void subtractSet(const labelUList &elems)
Subtract given elements from the set.
Definition: topoBoolSet.C:300
General set of labels of mesh quantity (points, cells, faces).
Definition: topoSet.H:59
topoBoolSet(const polyMesh &mesh, const word &setName)
Construct (no-read) with empty selection.
Definition: topoBoolSet.C:115
virtual void updateLabels(const labelUList &map)
Update map from map.
Definition: topoBoolSet.C:29
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:75
virtual void check(const label maxSize)
Check limits on addressable range.
Definition: topoBoolSet.C:94
Namespace for OpenFOAM.