All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ZoneList.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2024 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Class
25  Foam::ZoneList
26 
27 Description
28  A list of mesh zones.
29 
30 SourceFiles
31  ZoneList.C
32 
33 \*---------------------------------------------------------------------------*/
34 
35 #ifndef ZoneList_H
36 #define ZoneList_H
37 
38 #include "PtrListDictionary.H"
39 #include "regIOobject.H"
40 #include "pointFieldFwd.H"
41 #include "Map.H"
42 #include "boolList.H"
43 #include "PackedBoolList.H"
44 
45 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
46 
47 namespace Foam
48 {
49 
50 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
51 
52 // Forward declaration of friend functions and operators
53 
54 class polyTopoChangeMap;
55 class polyMeshMap;
56 class polyDistributionMap;
57 
58 template<class ZoneType, class ZonesType, class MeshType> class ZoneList;
59 
60 template<class ZoneType, class ZonesType, class MeshType>
62 
63 /*---------------------------------------------------------------------------*\
64  Class ZoneList Declaration
65 \*---------------------------------------------------------------------------*/
66 
67 template<class ZoneType, class ZonesType, class MeshType>
68 class ZoneList
69 :
70  public regIOobject,
71  public PtrListDictionary<ZoneType>
72 {
73  // Private Data
74 
75  //- Reference to mesh
76  const MeshType& mesh_;
77 
78 
79  // Private Member Functions
80 
81  //- Read if IOobject flags set. Return true if read.
82  bool read();
83 
84 
85 public:
86 
87  // Constructors
88 
89  //- Read constructor given IOobject and a MeshType reference
90  ZoneList
91  (
92  const IOobject&,
93  const MeshType&
94  );
95 
96  //- Move constructor
97  ZoneList(ZoneList&&) = default;
98 
99  //- Disallow default bitwise copy construction
100  ZoneList(const ZoneList&) = delete;
101 
102 
103  //- Destructor
104  ~ZoneList();
105 
106 
107  // Member Functions
108 
109  //- Return the mesh reference
110  const MeshType& mesh() const
111  {
112  return mesh_;
113  }
114 
116 
117  //- Return true if objectIndex is in any zone
118  bool found(const label objectIndex) const;
119 
120  //- Given a global object index, return the list of zones it is in
121  labelList whichZones(const label objectIndex) const;
122 
123  //- Return a list of zone types
124  wordList types() const;
125 
126  //- Append or update a zone
127  void append(ZoneType*) const;
128 
129  //- Append or update a zone
130  void append(const ZoneType&) const;
131 
132  //- Clear addressing
133  void clearAddressing();
134 
135  //- Clear the zones
136  void clear();
137 
138  //- Check zone definition. Return true if in error.
139  bool checkDefinition(const bool report = false) const;
140 
141  //- Check whether all procs have all zones and in same order. Return
142  // true if in error.
143  bool checkParallelSync(const bool report = false) const;
144 
145  //- Insert given indices into zones
146  void insert(const List<labelHashSet>& zonesIndices);
147 
148  //- Correct zones after moving points
149  virtual void movePoints(const pointField&);
150 
151  //- Update topology using the given map
152  virtual void topoChange(const polyTopoChangeMap& map);
153 
154  //- Update from another mesh using the given map
155  virtual void mapMesh(const polyMeshMap&);
156 
157  //- Redistribute or update using the given distribution map
158  virtual void distribute(const polyDistributionMap&);
159 
160  //- Swap zones
161  // For run-time mesh replacement and mesh to mesh mapping
162  void swap(ZonesType&);
163 
164  //- Read zones if the zones file is present
165  bool readIfPresent();
166 
167  //- writeData member function required by regIOobject
168  virtual bool writeData(Ostream&) const;
169 
170  //- Write using given format, version and compression
171  // Only write the zones file if there are zones in the list
172  virtual bool writeObject
173  (
177  const bool write
178  ) const;
179 
180 
181  // Member Operators
182 
183  //- Return const and non-const reference to ZoneType by index.
185 
186  //- Disallow default bitwise assignment
188 
189 
190  // Ostream operator
191 
192  friend Ostream& operator<< <ZoneType, ZonesType, MeshType>
193  (
194  Ostream&,
196  );
197 };
198 
199 
200 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
201 
202 } // End namespace Foam
203 
204 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
205 
206 #ifdef NoRepository
207  #include "ZoneList.C"
208 #endif
209 
210 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
211 
212 #endif
213 
214 // ************************************************************************* //
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:99
Version number type.
Definition: IOstream.H:97
streamFormat
Enumeration for the format of data in the stream.
Definition: IOstream.H:87
compressionType
Enumeration for the format of data in the stream.
Definition: IOstream.H:194
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
Template dictionary class which manages the storage associated with it.
A list of mesh zones.
Definition: ZoneList.H:71
void append(ZoneType *) const
Append or update a zone.
Definition: ZoneList.C:176
bool checkDefinition(const bool report=false) const
Check zone definition. Return true if in error.
Definition: ZoneList.C:245
~ZoneList()
Destructor.
Definition: ZoneList.C:112
void insert(const List< labelHashSet > &zonesIndices)
Insert given indices into zones.
Definition: ZoneList.C:341
virtual bool writeData(Ostream &) const
writeData member function required by regIOobject
Definition: ZoneList.C:488
bool found(const label objectIndex) const
Return true if objectIndex is in any zone.
Definition: ZoneList.C:122
ZoneList(const IOobject &, const MeshType &)
Read constructor given IOobject and a MeshType reference.
Definition: ZoneList.C:96
wordList types() const
Return a list of zone types.
Definition: ZoneList.C:159
bool readIfPresent()
Read zones if the zones file is present.
Definition: ZoneList.C:480
virtual bool writeObject(IOstream::streamFormat, IOstream::versionNumber, IOstream::compressionType, const bool write) const
Write using given format, version and compression.
Definition: ZoneList.C:497
labelList whichZones(const label objectIndex) const
Given a global object index, return the list of zones it is in.
Definition: ZoneList.C:140
virtual void distribute(const polyDistributionMap &)
Redistribute or update using the given distribution map.
Definition: ZoneList.C:409
void swap(ZonesType &)
Swap zones.
Definition: ZoneList.C:423
virtual void mapMesh(const polyMeshMap &)
Update from another mesh using the given map.
Definition: ZoneList.C:394
void clearAddressing()
Clear addressing.
Definition: ZoneList.C:224
void operator=(const ZoneList< ZoneType, ZonesType, MeshType > &)=delete
Disallow default bitwise assignment.
virtual void movePoints(const pointField &)
Correct zones after moving points.
Definition: ZoneList.C:364
const MeshType & mesh() const
Return the mesh reference.
Definition: ZoneList.H:109
void clear()
Clear the zones.
Definition: ZoneList.C:236
bool checkParallelSync(const bool report=false) const
Check whether all procs have all zones and in same order. Return.
Definition: ZoneList.C:263
virtual void topoChange(const polyTopoChangeMap &map)
Update topology using the given map.
Definition: ZoneList.C:379
Class containing mesh-to-mesh mapping information after a mesh distribution where we send parts of me...
Class containing mesh-to-mesh mapping information.
Definition: polyMeshMap.H:51
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
Definition: regIOobject.H:55
virtual bool write(const bool write=true) const
Write using setting from DB.
Namespace for OpenFOAM.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
Ostream & operator<<(Ostream &os, const fvConstraints &constraints)