1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
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.
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
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/>.
33 \*---------------------------------------------------------------------------*/
39 #include "regIOobject.H"
40 #include "pointFieldsFwd.H"
42 #include "PackedBoolList.H"
44 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
49 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
51 // Forward declaration of friend functions and operators
53 template<class ZoneType, class MeshType> class ZoneMesh;
55 template<class ZoneType, class MeshType>
56 Ostream& operator<<(Ostream&, const ZoneMesh<ZoneType, MeshType>&);
58 /*---------------------------------------------------------------------------*\
59 Class ZoneMesh Declaration
60 \*---------------------------------------------------------------------------*/
62 template<class ZoneType, class MeshType>
65 public PtrList<ZoneType>,
71 const MeshType& mesh_;
73 //- Map of zone labels for given element
74 mutable Map<label>* zoneMapPtr_;
77 // Private Member Functions
79 //- Disallow construct as copy
80 ZoneMesh(const ZoneMesh&);
82 //- Disallow assignment
83 void operator=(const ZoneMesh<ZoneType, MeshType>&);
87 void calcZoneMap() const;
94 //- Read constructor given IOobject and a MeshType reference
101 //- Construct given size
115 //- Return the mesh reference
116 const MeshType& mesh() const
121 //- Map of zones containing zone index for all zoned elements
122 // Return -1 if the object is not in the zone
123 const Map<label>& zoneMap() const;
125 //- Given a global object index, return the zone it is in.
126 // If object does not belong to any zones, return -1
127 label whichZone(const label objectIndex) const;
129 //- Return a list of zone types
130 wordList types() const;
132 //- Return a list of zone names
133 wordList names() const;
135 //- Return zone indices for all matches
136 labelList findIndices(const keyType&) const;
138 //- Return zone index for the first match, return -1 if not found
139 label findIndex(const keyType&) const;
141 //- Find zone index given a name
142 label findZoneID(const word& zoneName) const;
144 //- Mark cells that match the zone specification
145 PackedBoolList findMatching(const keyType&) const;
148 void clearAddressing();
153 //- Check zone definition. Return true if in error.
154 bool checkDefinition(const bool report = false) const;
156 //- Check whether all procs have all zones and in same order. Return
158 bool checkParallelSync(const bool report = false) const;
160 //- Correct zone mesh after moving points
161 void movePoints(const pointField&);
163 //- writeData member function required by regIOobject
164 bool writeData(Ostream&) const;
168 //- Return const and non-const reference to ZoneType by index.
169 using PtrList<ZoneType>::operator[];
171 //- Return const reference to ZoneType by name.
172 const ZoneType& operator[](const word&) const;
174 //- Return reference to ZoneType by name.
175 ZoneType& operator[](const word&);
180 friend Ostream& operator<< <ZoneType, MeshType>
183 const ZoneMesh<ZoneType, MeshType>&
188 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
190 } // End namespace Foam
192 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
195 # include "ZoneMesh.C"
198 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
202 // ************************************************************************* //