initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / applications / utilities / parallelProcessing / decomposePar / fvFieldDecomposer.H
blob89b69a17813895772c74686a47c921fcff44b277
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
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                 labelList directAddressing_;
68         public:
70             // Constructors
72                 //- Construct given addressing
73                 patchFieldDecomposer
74                 (
75                     const unallocLabelList& addressingSlice,
76                     const label addressingOffset
77                 );
80             // Member functions
82                 label size() const
83                 {
84                     return directAddressing_.size();
85                 }
87                 bool direct() const
88                 {
89                     return true;
90                 }
92                 const unallocLabelList& directAddressing() const
93                 {
94                     return directAddressing_;
95                 }
96         };
99         //- Processor patch field decomposer class. Maps either owner or
100         //  neighbour data (no interpolate anymore - processorFvPatchField
101         //  holds neighbour data)
102         class processorVolPatchFieldDecomposer
103         :
104             public fvPatchFieldMapper
105         {
106             // Private data
108                 labelList directAddressing_;
110         public:
112             //- Construct given addressing
113             processorVolPatchFieldDecomposer
114             (
115                 const fvMesh& mesh,
116                 const unallocLabelList& addressingSlice
117             );
120             // Member functions
122                 label size() const
123                 {
124                     return directAddressing_.size();
125                 }
127                 bool direct() const
128                 {
129                     return true;
130                 }
132                 const unallocLabelList& directAddressing() const
133                 {
134                     return directAddressing_;
135                 }
136         };
139         //- Processor patch field decomposer class. Surface field is assumed
140         //  to have direction (so manipulates sign when mapping)
141         class processorSurfacePatchFieldDecomposer
142         :
143             public fvPatchFieldMapper
144         {
145             labelListList addressing_;
146             scalarListList weights_;
148         public:
150             //- Construct given addressing
151             processorSurfacePatchFieldDecomposer
152             (
153                 const unallocLabelList& addressingSlice
154             );
157             // Member functions
159                 label size() const
160                 {
161                     return addressing_.size();
162                 }
164                 bool direct() const
165                 {
166                     return false;
167                 }
169                 const labelListList& addressing() const
170                 {
171                     return addressing_;
172                 }
174                 const scalarListList& weights() const
175                 {
176                     return weights_;
177                 }
178         };
181 private:
183     // Private data
185         //- Reference to complete mesh
186         const fvMesh& completeMesh_;
188         //- Reference to processor mesh
189         const fvMesh& procMesh_;
191         //- Reference to face addressing
192         const labelList& faceAddressing_;
194         //- Reference to cell addressing
195         const labelList& cellAddressing_;
197         //- Reference to boundary addressing
198         const labelList& boundaryAddressing_;
200         //- List of patch field decomposers
201         List<patchFieldDecomposer*> patchFieldDecomposerPtrs_;
203         List<processorVolPatchFieldDecomposer*> 
204             processorVolPatchFieldDecomposerPtrs_;
206         List<processorSurfacePatchFieldDecomposer*> 
207             processorSurfacePatchFieldDecomposerPtrs_;
210     // Private Member Functions
212         //- Disallow default bitwise copy construct
213         fvFieldDecomposer(const fvFieldDecomposer&);
215         //- Disallow default bitwise assignment
216         void operator=(const fvFieldDecomposer&);
219 public:
221     // Constructors
223         //- Construct from components
224         fvFieldDecomposer
225         (
226             const fvMesh& completeMesh,
227             const fvMesh& procMesh,
228             const labelList& faceAddressing,
229             const labelList& cellAddressing,
230             const labelList& boundaryAddressing
231         );
234     // Destructor
236         ~fvFieldDecomposer();
239     // Member Functions
241         //- Decompose volume field
242         template<class Type>
243         tmp<GeometricField<Type, fvPatchField, volMesh> >
244         decomposeField
245         (
246             const GeometricField<Type, fvPatchField, volMesh>& field
247         ) const;
249         //- Decompose surface field
250         template<class Type>
251         tmp<GeometricField<Type, fvsPatchField, surfaceMesh> >
252         decomposeField
253         (
254             const GeometricField<Type, fvsPatchField, surfaceMesh>& field
255         ) const;
257         template<class GeoField>
258         void decomposeFields(const PtrList<GeoField>& fields) const;
262 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
264 } // End namespace Foam
266 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
268 #ifdef NoRepository
269 #   include "fvFieldDecomposerDecomposeFields.C"
270 #endif
272 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
274 #endif
276 // ************************************************************************* //