Loading...
Searching...
No Matches
topoBitSet.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-------------------------------------------------------------------------------
10License
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
26Class
27 Foam::topoBitSet
28
29Description
30 Base for a special purpose topoSet using labels stored as a bitSet.
31
32SourceFiles
33 topoBitSet.C
34
35\*---------------------------------------------------------------------------*/
36
37#ifndef Foam_topoBitSet_H
38#define Foam_topoBitSet_H
39
40#include "topoSet.H"
41#include "bitSet.H"
42
43// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
44
45namespace Foam
46{
48/*---------------------------------------------------------------------------*\
49 Class topoBitSet Declaration
50\*---------------------------------------------------------------------------*/
51
52class topoBitSet
53:
54 public topoSet
56protected:
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 topoBitSet(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 from bitset values, size elements
87 (
88 const polyMesh& mesh,
89 const word& setName,
90 const label size,
91 const bitSet& bits
92 );
93
94 //- Move construct from bitset values, size elements
96 (
97 const polyMesh& mesh,
98 const word& setName,
99 const label size,
100 bitSet&& bits
101 );
102
103
104public:
105
106 //- Destructor
107 virtual ~topoBitSet() = default;
108
109
110 // Member Functions
111
112 //- Return the bitSet
113 const bitSet& addressing() const noexcept
114 {
115 return selected_;
116 }
118 //- Access the bitSet
120 {
121 return selected_;
122 }
123
124 //- Set values to false, leaving the size untouched
125 void reset()
126 {
127 selected_.reset();
128 }
129
130 //- Has the given index?
131 virtual bool contains(const label id) const;
132
133 //- Has the given index?
134 virtual bool found(const label id) const;
135
136 //- Set an index
137 virtual bool set(const label id);
138
139 //- Unset an index
140 virtual bool unset(const label id);
142 //- Set multiple indices
143 virtual void set(const labelUList& labels);
144
145 //- Unset multiple indices
146 virtual void unset(const labelUList& labels);
147
148 //- Invert contents.
149 // Insert all members [0,maxLen) which were not in set.
150 virtual void invert(const label maxLen);
151
152 //- Subset contents. Only elements present in both sets remain.
153 virtual void subset(const labelUList& elems);
154
155 //- Subset contents. Only elements present in both sets remain.
156 virtual void subset(const topoSet& set);
157
158 //- Add given elements to the set
159 virtual void addSet(const labelUList& elems);
160
161 //- Add given elements to the set
162 virtual void addSet(const topoSet& set);
163
164 //- Subtract given elements from the set
165 virtual void subtractSet(const labelUList& elems);
166
167 //- Subtract given elements from the set
168 virtual void subtractSet(const topoSet& set);
169};
170
171
172// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
173
174} // End namespace Foam
175
176// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
177
178#endif
179
180// ************************************************************************* //
bool found
label size() const noexcept
The number of elements in table.
Definition HashTable.H:358
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
Definition bitSet.H:61
Mesh consisting of general polyhedral cells.
Definition polyMesh.H:79
virtual ~topoBitSet()=default
Destructor.
virtual void invert(const label maxLen)
Invert contents.
Definition topoBitSet.C:209
virtual bool unset(const label id)
Unset an index.
Definition topoBitSet.C:191
bitSet & addressing() noexcept
Access the bitSet.
Definition topoBitSet.H:133
virtual void subset(const labelUList &elems)
Subset contents. Only elements present in both sets remain.
Definition topoBitSet.C:243
topoBitSet(const polyMesh &mesh, const word &setName)
Construct (no-read) with empty selection.
Definition topoBitSet.C:106
const bitSet & addressing() const noexcept
Return the bitSet.
Definition topoBitSet.H:125
virtual void subtractSet(const labelUList &elems)
Subtract given elements from the set.
Definition topoBitSet.C:303
void reset()
Set values to false, leaving the size untouched.
Definition topoBitSet.H:141
virtual bool contains(const label id) const
Has the given index?
Definition topoBitSet.C:173
virtual void updateLabels(const labelUList &map)
Update map from map.
Definition topoBitSet.C:29
virtual bool set(const label id)
Set an index.
Definition topoBitSet.C:185
virtual void check(const label maxSize)
Check limits on addressable range.
Definition topoBitSet.C:85
virtual void addSet(const labelUList &elems)
Add given elements to the set.
Definition topoBitSet.C:278
General set of labels of mesh quantity (points, cells, faces).
Definition topoSet.H:63
topoSet(const topoSet &)=delete
No copy construct.
virtual label maxSize(const polyMesh &mesh) const =0
Return max allowable index (+1). Not implemented.
A class for handling words, derived from Foam::string.
Definition word.H:66
dynamicFvMesh & mesh
Namespace for OpenFOAM.
const direction noexcept
Definition scalarImpl.H:265
UList< label > labelUList
A UList of labels.
Definition UList.H:75