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 -------------------------------------------------------------------------------
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::topoBitSet
28 
29 Description
30  Base for a special purpose topoSet using labels stored as a bitSet.
31 
32 SourceFiles
33  topoBitSet.C
34 
35 \*---------------------------------------------------------------------------*/
36 
37 #ifndef topoBitSet_H
38 #define topoBitSet_H
39 
40 #include "topoSet.H"
41 #include "bitSet.H"
42 
43 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
44 
45 namespace Foam
46 {
47 
48 /*---------------------------------------------------------------------------*\
49  Class topoBitSet Declaration
50 \*---------------------------------------------------------------------------*/
51 
52 class topoBitSet
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 with empty selection
74  topoBitSet(const polyMesh& mesh, const word& setName);
75 
76  //- Construct with size elements
78  (
79  const polyMesh& mesh,
80  const word& setName,
81  const label size,
82  const bool val
83  );
84 
85  //- Copy construct with 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 with bitset values, size elements
96  (
97  const polyMesh& mesh,
98  const word& setName,
99  const label size,
100  bitSet&& bits
101  );
102 
103 
104 public:
105 
106  //- Destructor
107  virtual ~topoBitSet() = default;
108 
109 
110  // Member Functions
111 
112  //- Return the bitSet
113  const bitSet& addressing() const
114  {
115  return selected_;
116  }
117 
118  //- Access the bitSet
119  bitSet& addressing()
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 found(const label id) const;
132 
133  //- Set an index
134  virtual bool set(const label id);
135 
136  //- Unset an index
137  virtual bool unset(const label id);
138 
139  //- Set multiple indices
140  virtual void set(const labelUList& labels);
141 
142  //- Unset multiple indices
143  virtual void unset(const labelUList& labels);
144 
145  //- Invert contents.
146  // Insert all members [0,maxLen) which were not in set.
147  virtual void invert(const label maxLen);
148 
149  //- Subset contents. Only elements present in both sets remain.
150  virtual void subset(const topoSet& set);
151 
152  //- Add elements present in set.
153  virtual void addSet(const topoSet& set);
154 
155  //- Subtract elements present in set.
156  virtual void subtractSet(const topoSet& set);
157 };
158 
159 
160 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
161 
162 } // End namespace Foam
163 
164 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
165 
166 #endif
167 
168 // ************************************************************************* //
Foam::PackedList::reset
void reset()
Clear all bits but do not adjust the addressable size.
Definition: PackedListI.H:505
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::bitSet
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
Definition: bitSet.H:63
Foam::topoBitSet::set
virtual bool set(const label id)
Set an index.
Definition: topoBitSet.C:187
topoSet.H
Foam::topoBitSet::subtractSet
virtual void subtractSet(const topoSet &set)
Subtract elements present in set.
Definition: topoBitSet.C:259
Foam::topoBitSet::addSet
virtual void addSet(const topoSet &set)
Add elements present in set.
Definition: topoBitSet.C:242
bitSet.H
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:77
Foam::topoBitSet::topoBitSet
topoBitSet(const polyMesh &mesh, const word &setName)
Construct with empty selection.
Definition: topoBitSet.C:113
Foam::topoBitSet::check
virtual void check(const label maxSize)
Check limits on addressable range.
Definition: topoBitSet.C:92
Foam::topoBitSet::invert
virtual void invert(const label maxLen)
Invert contents.
Definition: topoBitSet.C:211
Foam::topoBitSet::unset
virtual bool unset(const label id)
Unset an index.
Definition: topoBitSet.C:193
Foam::topoSet
General set of labels of mesh quantity (points, cells, faces).
Definition: topoSet.H:63
Foam::topoBitSet::addressing
bitSet & addressing()
Access the bitSet.
Definition: topoBitSet.H:118
Foam::topoSet::maxSize
virtual label maxSize(const polyMesh &mesh) const =0
Return max allowable index (+1). Not implemented.
Foam::topoBitSet::addressing
const bitSet & addressing() const
Return the bitSet.
Definition: topoBitSet.H:112
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::topoBitSet::found
virtual bool found(const label id) const
Has the given index?
Definition: topoBitSet.C:181
Foam::topoBitSet::subset
virtual void subset(const topoSet &set)
Subset contents. Only elements present in both sets remain.
Definition: topoBitSet.C:218
Foam::topoBitSet::updateLabels
virtual void updateLabels(const labelUList &map)
Update map from map.
Definition: topoBitSet.C:36
Foam::topoBitSet
Base for a special purpose topoSet using labels stored as a bitSet.
Definition: topoBitSet.H:51
Foam::UList< label >
Foam::topoBitSet::reset
void reset()
Set values to false, leaving the size untouched.
Definition: topoBitSet.H:124
Foam::topoBitSet::selected_
bitSet selected_
Definition: topoBitSet.H:59
Foam::topoBitSet::~topoBitSet
virtual ~topoBitSet()=default
Destructor.