BUGFIX: Uninitialised member variables
[foam-extend-3.2.git] / applications / utilities / parallelProcessing / decomposePar / fvFieldDecomposer.H
blob240e5e19b4f07d924131562323e97eeb2bdd4bff
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright held by original author
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 the
13     Free Software Foundation; either version 2 of the License, or (at your
14     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, write to the Free Software Foundation,
23     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 Class
26     Foam::fvFieldDecomposer
28 Description
29     Finite Volume volume and surface field decomposer.
31 SourceFiles
32     fvFieldDecomposer.C
33     fvFieldDecomposerDecomposeFields.C
35 \*---------------------------------------------------------------------------*/
37 #ifndef fvFieldDecomposer_H
38 #define fvFieldDecomposer_H
40 #include "fvMesh.H"
41 #include "fvPatchFieldMapper.H"
42 #include "surfaceFields.H"
44 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
46 namespace Foam
49 class IOobjectList;
51 /*---------------------------------------------------------------------------*\
52                     Class fvFieldDecomposer Declaration
53 \*---------------------------------------------------------------------------*/
55 class fvFieldDecomposer
57 public:
59         //- Patch field decomposer class
60         class patchFieldDecomposer
61         :
62             public fvPatchFieldMapper
63         {
64             // Private data
66                 label sizeBeforeMapping_;
67                 labelList directAddressing_;
69         public:
71             // Constructors
73                 //- Construct given addressing
74                 patchFieldDecomposer
75                 (
76                     const label sizeBeforeMapping,
77                     const unallocLabelList& addressingSlice,
78                     const label addressingOffset
79                 );
82             // Member functions
84                 label size() const
85                 {
86                     return directAddressing_.size();
87                 }
89                 virtual label sizeBeforeMapping() const
90                 {
91                     return sizeBeforeMapping_;
92                 }
94                 bool direct() const
95                 {
96                     return true;
97                 }
99                 const unallocLabelList& directAddressing() const
100                 {
101                     return directAddressing_;
102                 }
103         };
106         //- Processor patch field decomposer class
107         class processorVolPatchFieldDecomposer
108         :
109             public fvPatchFieldMapper
110         {
111             // Private data
113                 label sizeBeforeMapping_;
114                 labelListList addressing_;
115                 scalarListList weights_;
117         public:
119             //- Construct given addressing
120             processorVolPatchFieldDecomposer
121             (
122                 const fvMesh& mesh,
123                 const unallocLabelList& addressingSlice
124             );
127             // Member functions
129                 label size() const
130                 {
131                     return addressing_.size();
132                 }
134                 virtual label sizeBeforeMapping() const
135                 {
136                     return sizeBeforeMapping_;
137                 }
139                 bool direct() const
140                 {
141                     return false;
142                 }
144                 const labelListList& addressing() const
145                 {
146                     return addressing_;
147                 }
149                 const scalarListList& weights() const
150                 {
151                     return weights_;
152                 }
153         };
156         //- Processor patch field decomposer class
157         class processorSurfacePatchFieldDecomposer
158         :
159             public fvPatchFieldMapper
160         {
161             label sizeBeforeMapping_;
162             labelListList addressing_;
163             scalarListList weights_;
165         public:
167             //- Construct given addressing
168             processorSurfacePatchFieldDecomposer
169             (
170                 label sizeBeforeMapping,
171                 const unallocLabelList& addressingSlice
172             );
175             // Member functions
177                 label size() const
178                 {
179                     return addressing_.size();
180                 }
182                 virtual label sizeBeforeMapping() const
183                 {
184                     return sizeBeforeMapping_;
185                 }
187                 bool direct() const
188                 {
189                     return false;
190                 }
192                 const labelListList& addressing() const
193                 {
194                     return addressing_;
195                 }
197                 const scalarListList& weights() const
198                 {
199                     return weights_;
200                 }
201         };
204 private:
206     // Private data
208         //- Reference to complete mesh
209         const fvMesh& completeMesh_;
211         //- Reference to processor mesh
212         const fvMesh& procMesh_;
214         //- Reference to face addressing
215         const labelList& faceAddressing_;
217         //- Reference to cell addressing
218         const labelList& cellAddressing_;
220         //- Reference to boundary addressing
221         const labelList& boundaryAddressing_;
223         //- List of patch field decomposers
224         List<patchFieldDecomposer*> patchFieldDecomposerPtrs_;
226         List<processorVolPatchFieldDecomposer*>
227             processorVolPatchFieldDecomposerPtrs_;
229         List<processorSurfacePatchFieldDecomposer*>
230             processorSurfacePatchFieldDecomposerPtrs_;
233     // Private Member Functions
235         //- Disallow default bitwise copy construct
236         fvFieldDecomposer(const fvFieldDecomposer&);
238         //- Disallow default bitwise assignment
239         void operator=(const fvFieldDecomposer&);
242 public:
244     // Constructors
246         //- Construct from components
247         fvFieldDecomposer
248         (
249             const fvMesh& completeMesh,
250             const fvMesh& procMesh,
251             const labelList& faceAddressing,
252             const labelList& cellAddressing,
253             const labelList& boundaryAddressing
254         );
257     // Destructor
259         ~fvFieldDecomposer();
262     // Member Functions
264         //- Decompose volume field
265         template<class Type>
266         tmp<GeometricField<Type, fvPatchField, volMesh> >
267         decomposeField
268         (
269             const GeometricField<Type, fvPatchField, volMesh>& field
270         ) const;
272         //- Decompose surface field
273         template<class Type>
274         tmp<GeometricField<Type, fvsPatchField, surfaceMesh> >
275         decomposeField
276         (
277             const GeometricField<Type, fvsPatchField, surfaceMesh>& field
278         ) const;
280         template<class GeoField>
281         void decomposeFields(const PtrList<GeoField>& fields) const;
285 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
287 } // End namespace Foam
289 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
291 #ifdef NoRepository
292 #   include "fvFieldDecomposerDecomposeFields.C"
293 #endif
295 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
297 #endif
299 // ************************************************************************* //