Transferred copyright to the OpenFOAM Foundation
[OpenFOAM-2.0.x.git] / applications / utilities / parallelProcessing / decomposePar / fvFieldDecomposer.H
blobee87db59f41bf3e00d3ffbe17f5dac53656a4cdf
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::fvFieldDecomposer
27 Description
28     Finite Volume volume and surface field decomposer.
30 SourceFiles
31     fvFieldDecomposer.C
32     fvFieldDecomposerDecomposeFields.C
34 \*---------------------------------------------------------------------------*/
36 #ifndef fvFieldDecomposer_H
37 #define fvFieldDecomposer_H
39 #include "fvMesh.H"
40 #include "fvPatchFieldMapper.H"
41 #include "surfaceFields.H"
43 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
45 namespace Foam
48 class IOobjectList;
50 /*---------------------------------------------------------------------------*\
51                     Class fvFieldDecomposer Declaration
52 \*---------------------------------------------------------------------------*/
54 class fvFieldDecomposer
56 public:
58         //- Patch field decomposer class
59         class patchFieldDecomposer
60         :
61             public fvPatchFieldMapper
62         {
63             // Private data
65                 labelList directAddressing_;
67         public:
69             // Constructors
71                 //- Construct given addressing
72                 patchFieldDecomposer
73                 (
74                     const labelUList& addressingSlice,
75                     const label addressingOffset
76                 );
79             // Member functions
81                 label size() const
82                 {
83                     return directAddressing_.size();
84                 }
86                 bool direct() const
87                 {
88                     return true;
89                 }
91                 const labelUList& directAddressing() const
92                 {
93                     return directAddressing_;
94                 }
95         };
98         //- Processor patch field decomposer class. Maps either owner or
99         //  neighbour data (no interpolate anymore - processorFvPatchField
100         //  holds neighbour data)
101         class processorVolPatchFieldDecomposer
102         :
103             public fvPatchFieldMapper
104         {
105             // Private data
107                 labelList directAddressing_;
109         public:
111             //- Construct given addressing
112             processorVolPatchFieldDecomposer
113             (
114                 const fvMesh& mesh,
115                 const labelUList& addressingSlice
116             );
119             // Member functions
121                 label size() const
122                 {
123                     return directAddressing_.size();
124                 }
126                 bool direct() const
127                 {
128                     return true;
129                 }
131                 const labelUList& directAddressing() const
132                 {
133                     return directAddressing_;
134                 }
135         };
138         //- Processor patch field decomposer class. Surface field is assumed
139         //  to have direction (so manipulates sign when mapping)
140         class processorSurfacePatchFieldDecomposer
141         :
142             public fvPatchFieldMapper
143         {
144             labelListList addressing_;
145             scalarListList weights_;
147         public:
149             //- Construct given addressing
150             processorSurfacePatchFieldDecomposer
151             (
152                 const labelUList& addressingSlice
153             );
156             // Member functions
158                 label size() const
159                 {
160                     return addressing_.size();
161                 }
163                 bool direct() const
164                 {
165                     return false;
166                 }
168                 const labelListList& addressing() const
169                 {
170                     return addressing_;
171                 }
173                 const scalarListList& weights() const
174                 {
175                     return weights_;
176                 }
177         };
180 private:
182     // Private data
184         //- Reference to complete mesh
185         const fvMesh& completeMesh_;
187         //- Reference to processor mesh
188         const fvMesh& procMesh_;
190         //- Reference to face addressing
191         const labelList& faceAddressing_;
193         //- Reference to cell addressing
194         const labelList& cellAddressing_;
196         //- Reference to boundary addressing
197         const labelList& boundaryAddressing_;
199         //- List of patch field decomposers
200         List<patchFieldDecomposer*> patchFieldDecomposerPtrs_;
202         List<processorVolPatchFieldDecomposer*>
203             processorVolPatchFieldDecomposerPtrs_;
205         List<processorSurfacePatchFieldDecomposer*>
206             processorSurfacePatchFieldDecomposerPtrs_;
209     // Private Member Functions
211         //- Disallow default bitwise copy construct
212         fvFieldDecomposer(const fvFieldDecomposer&);
214         //- Disallow default bitwise assignment
215         void operator=(const fvFieldDecomposer&);
218 public:
220     // Constructors
222         //- Construct from components
223         fvFieldDecomposer
224         (
225             const fvMesh& completeMesh,
226             const fvMesh& procMesh,
227             const labelList& faceAddressing,
228             const labelList& cellAddressing,
229             const labelList& boundaryAddressing
230         );
233     //- Destructor
234     ~fvFieldDecomposer();
237     // Member Functions
239         //- Decompose volume field
240         template<class Type>
241         tmp<GeometricField<Type, fvPatchField, volMesh> >
242         decomposeField
243         (
244             const GeometricField<Type, fvPatchField, volMesh>& field
245         ) const;
247         //- Decompose surface field
248         template<class Type>
249         tmp<GeometricField<Type, fvsPatchField, surfaceMesh> >
250         decomposeField
251         (
252             const GeometricField<Type, fvsPatchField, surfaceMesh>& field
253         ) const;
255         template<class GeoField>
256         void decomposeFields(const PtrList<GeoField>& fields) const;
260 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
262 } // End namespace Foam
264 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
266 #ifdef NoRepository
267 #   include "fvFieldDecomposerDecomposeFields.C"
268 #endif
270 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
272 #endif
274 // ************************************************************************* //