BUG: UListIO: byteSize overflowing on really big faceLists
[OpenFOAM-2.0.x.git] / src / finiteVolume / fvMesh / singleCellFvMesh / singleCellFvMesh.H
blob7ee6c37b687597df61e8630db4604057b3c7cd1e
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2011 OpenFOAM Foundation
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
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
19     for more details.
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/>.
24 Class
25     Foam::singleCellFvMesh
27 Description
28     fvMesh as subset of other mesh. Consists of one cell and all original
29     bounday faces. Useful when manipulating boundary data. Single internal
30     cell only needed to be able to manipulate in a standard way.
32 SourceFiles
33     singleCellFvMesh.C
34     singleCellFvMeshInterpolate.C
36 \*---------------------------------------------------------------------------*/
38 #ifndef singleCellFvMesh_H
39 #define singleCellFvMesh_H
41 #include "fvPatchFieldMapper.H"
42 #include "fvMesh.H"
43 #include "labelListIOList.H"
45 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
47 namespace Foam
50 /*---------------------------------------------------------------------------*\
51                           Class singleCellFvMesh Declaration
52 \*---------------------------------------------------------------------------*/
54 class singleCellFvMesh
56     public fvMesh
58     // Private data
60         const labelListIOList patchFaceAgglomeration_;
62         //- From patch faces back to agglomeration or fine mesh
63         labelListIOList patchFaceMap_;
65         //- From fine mesh faces to coarse mesh
66         labelIOList reverseFaceMap_;
68         //- From coarse points back to original mesh
69         labelIOList pointMap_;
71         //- From fine points to coarse mesh
72         labelIOList reversePointMap_;
75     // Private Member Functions
77         //- Calculate agglomerated mesh
78         void agglomerateMesh(const fvMesh&, const labelListList&);
81         //- Disallow default bitwise copy construct
82         singleCellFvMesh(const singleCellFvMesh&);
84         //- Disallow default bitwise assignment
85         void operator=(const singleCellFvMesh&);
88 public:
90         //- Patch field mapper class for non-agglomerated meshes
91         class directPatchFieldMapper
92         :
93             public fvPatchFieldMapper
94         {
95             // Private data
97                 const labelUList& directAddressing_;
99         public:
101                 //- Construct given addressing
102                 directPatchFieldMapper(const labelUList& directAddressing)
103                 :
104                     directAddressing_(directAddressing)
105                 {}
107                 virtual label size() const
108                 {
109                     return directAddressing_.size();
110                 }
112                 virtual bool direct() const
113                 {
114                     return true;
115                 }
117                 virtual const labelUList& directAddressing() const
118                 {
119                     return directAddressing_;
120                 }
121         };
123         //- Patch field mapper class for agglomerated meshes
124         class agglomPatchFieldMapper
125         :
126             public fvPatchFieldMapper
127         {
128             // Private data
130                 const labelListList& addressing_;
131                 const scalarListList& weights_;
133         public:
135                 //- Construct given addressing
136                 agglomPatchFieldMapper
137                 (
138                     const labelListList& addressing,
139                     const scalarListList& weights
140                 )
141                 :
142                     addressing_(addressing),
143                     weights_(weights)
144                 {}
146                 virtual label size() const
147                 {
148                     return addressing_.size();
149                 }
151                 virtual bool direct() const
152                 {
153                     return false;
154                 }
156                 virtual const labelListList& addressing() const
157                 {
158                     return addressing_;
159                 }
161                 virtual const scalarListList& weights() const
162                 {
163                     return weights_;
164                 }
165         };
169     // Constructors
171         //- Construct from fvMesh and no agglomeration
172         singleCellFvMesh(const IOobject& io, const fvMesh&);
174         //- Construct from fvMesh and agglomeration of boundary faces.
175         //  agglomeration is per patch, per patch face index the agglomeration
176         //  the face goes into.
177         singleCellFvMesh
178         (
179             const IOobject& io,
180             const fvMesh&,
181             const labelListList& patchFaceAgglomeration
182         );
184         //- Read from IOobject
185         singleCellFvMesh(const IOobject& io);
187     // Member Functions
189         bool agglomerate() const
190         {
191             return patchFaceAgglomeration_.size() > 0;
192         }
194         //- From patchFace on this back to original mesh or agglomeration
195         const labelListList& patchFaceMap() const
196         {
197             return patchFaceMap_;
198         }
200         //- From point on this back to original mesh
201         const labelList& pointMap() const
202         {
203             return pointMap_;
204         }
206         //- From face on original mesh to face on this
207         const labelList& reverseFaceMap() const
208         {
209             return reverseFaceMap_;
210         }
212         //- From point on original mesh to point on this (or -1 for removed
213         //  points)
214         const labelList& reversePointMap() const
215         {
216             return reversePointMap_;
217         }
219         //- Map volField. Internal field set to average, patch fields straight
220         //  copies.
221         template<class Type>
222         tmp<GeometricField<Type, fvPatchField, volMesh> >
223         interpolate
224         (
225             const GeometricField<Type, fvPatchField, volMesh>&
226         ) const;
231 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
233 } // End namespace Foam
235 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
237 #ifdef NoRepository
238 #   include "singleCellFvMeshInterpolate.C"
239 #endif
241 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
243 #endif
245 // ************************************************************************* //