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 topoBoolSet_H
38 #define 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 with empty selection
74  topoBoolSet(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 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 
104 public:
105 
106  //- Destructor
107  virtual ~topoBoolSet() = default;
108 
109 
110  // Member Functions
111 
112  //- Return the boolList
113  const boolList& addressing() const
114  {
115  return selected_;
116  }
117 
118  //- Access the boolList
120  {
121  return selected_;
122  }
123 
124  //- Set values to false, leaving the size untouched
125  void reset()
126  {
127  selected_ = false;
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 // ************************************************************************* //
boolList.H
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::HashSetOps::bools
List< bool > bools(const labelHashSet &locations)
Definition: HashOps.C:81
topoSet.H
Foam::topoBoolSet::check
virtual void check(const label maxSize)
Check limits on addressable range.
Definition: topoBoolSet.C:101
Foam::topoBoolSet::invert
virtual void invert(const label maxLen)
Invert contents.
Definition: topoBoolSet.C:226
Foam::topoBoolSet::addressing
const boolList & addressing() const
Return the boolList.
Definition: topoBoolSet.H:112
Foam::topoBoolSet::subtractSet
virtual void subtractSet(const topoSet &set)
Subtract elements present in set.
Definition: topoBoolSet.C:263
Foam::topoBoolSet::updateLabels
virtual void updateLabels(const labelUList &map)
Update map from map.
Definition: topoBoolSet.C:36
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:77
Foam::topoBoolSet::addressing
boolList & addressing()
Access the boolList.
Definition: topoBoolSet.H:118
Foam::topoBoolSet::reset
void reset()
Set values to false, leaving the size untouched.
Definition: topoBoolSet.H:124
Foam::topoSet
General set of labels of mesh quantity (points, cells, faces).
Definition: topoSet.H:63
Foam::topoBoolSet::set
virtual bool set(const label id)
Set an index.
Definition: topoBoolSet.C:196
Foam::topoSet::maxSize
virtual label maxSize(const polyMesh &mesh) const =0
Return max allowable index (+1). Not implemented.
Foam::topoBoolSet
Base for a special purpose topoSet using labels stored as a boolList.
Definition: topoBoolSet.H:51
Foam::topoBoolSet::~topoBoolSet
virtual ~topoBoolSet()=default
Destructor.
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::topoBoolSet::found
virtual bool found(const label id) const
Has the given index?
Definition: topoBoolSet.C:190
Foam::topoBoolSet::addSet
virtual void addSet(const topoSet &set)
Add elements present in set.
Definition: topoBoolSet.C:253
Foam::topoBoolSet::selected_
boolList selected_
Definition: topoBoolSet.H:59
Foam::List< bool >
Foam::topoBoolSet::unset
virtual bool unset(const label id)
Unset an index.
Definition: topoBoolSet.C:202
Foam::topoBoolSet::topoBoolSet
topoBoolSet(const polyMesh &mesh, const word &setName)
Construct with empty selection.
Definition: topoBoolSet.C:122
Foam::UList< label >
Foam::topoBoolSet::subset
virtual void subset(const topoSet &set)
Subset contents. Only elements present in both sets remain.
Definition: topoBoolSet.C:236