Forward compatibility: flex
[foam-extend-3.2.git] / applications / utilities / parallelProcessing / decomposePar / fvFieldDecomposer.H
blobc38d7b6b305ea7baca8f9afc2658ddcbc530ea00
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | foam-extend: Open Source CFD
4    \\    /   O peration     | Version:     3.2
5     \\  /    A nd           | Web:         http://www.foam-extend.org
6      \\/     M anipulation  | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
8 License
9     This file is part of foam-extend.
11     foam-extend 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 3 of the License, or (at your
14     option) any later version.
16     foam-extend is distributed in the hope that it will be useful, but
17     WITHOUT ANY WARRANTY; without even the implied warranty of
18     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19     General Public License for more details.
21     You should have received a copy of the GNU General Public License
22     along with foam-extend.  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                 label sizeBeforeMapping_;
66                 labelList directAddressing_;
68         public:
70             // Constructors
72                 //- Construct given addressing
73                 patchFieldDecomposer
74                 (
75                     const label sizeBeforeMapping,
76                     const unallocLabelList& addressingSlice,
77                     const label addressingOffset
78                 );
81             // Member functions
83                 label size() const
84                 {
85                     return directAddressing_.size();
86                 }
88                 virtual label sizeBeforeMapping() const
89                 {
90                     return sizeBeforeMapping_;
91                 }
93                 bool direct() const
94                 {
95                     return true;
96                 }
98                 const unallocLabelList& directAddressing() const
99                 {
100                     return directAddressing_;
101                 }
102         };
105         //- Processor patch field decomposer class
106         class processorVolPatchFieldDecomposer
107         :
108             public fvPatchFieldMapper
109         {
110             // Private data
112                 label sizeBeforeMapping_;
113                 labelListList addressing_;
114                 scalarListList weights_;
116         public:
118             //- Construct given addressing
119             processorVolPatchFieldDecomposer
120             (
121                 const fvMesh& mesh,
122                 const unallocLabelList& addressingSlice
123             );
126             // Member functions
128                 label size() const
129                 {
130                     return addressing_.size();
131                 }
133                 virtual label sizeBeforeMapping() const
134                 {
135                     return sizeBeforeMapping_;
136                 }
138                 bool direct() const
139                 {
140                     return false;
141                 }
143                 const labelListList& addressing() const
144                 {
145                     return addressing_;
146                 }
148                 const scalarListList& weights() const
149                 {
150                     return weights_;
151                 }
152         };
155         //- Processor patch field decomposer class
156         class processorSurfacePatchFieldDecomposer
157         :
158             public fvPatchFieldMapper
159         {
160             label sizeBeforeMapping_;
161             labelListList addressing_;
162             scalarListList weights_;
164         public:
166             //- Construct given addressing
167             processorSurfacePatchFieldDecomposer
168             (
169                 label sizeBeforeMapping,
170                 const unallocLabelList& addressingSlice
171             );
174             // Member functions
176                 label size() const
177                 {
178                     return addressing_.size();
179                 }
181                 virtual label sizeBeforeMapping() const
182                 {
183                     return sizeBeforeMapping_;
184                 }
186                 bool direct() const
187                 {
188                     return false;
189                 }
191                 const labelListList& addressing() const
192                 {
193                     return addressing_;
194                 }
196                 const scalarListList& weights() const
197                 {
198                     return weights_;
199                 }
200         };
203 private:
205     // Private data
207         //- Reference to complete mesh
208         const fvMesh& completeMesh_;
210         //- Reference to processor mesh
211         const fvMesh& procMesh_;
213         //- Reference to face addressing
214         const labelList& faceAddressing_;
216         //- Reference to cell addressing
217         const labelList& cellAddressing_;
219         //- Reference to boundary addressing
220         const labelList& boundaryAddressing_;
222         //- List of patch field decomposers
223         List<patchFieldDecomposer*> patchFieldDecomposerPtrs_;
225         List<processorVolPatchFieldDecomposer*>
226             processorVolPatchFieldDecomposerPtrs_;
228         List<processorSurfacePatchFieldDecomposer*>
229             processorSurfacePatchFieldDecomposerPtrs_;
232     // Private Member Functions
234         //- Disallow default bitwise copy construct
235         fvFieldDecomposer(const fvFieldDecomposer&);
237         //- Disallow default bitwise assignment
238         void operator=(const fvFieldDecomposer&);
241 public:
243     // Constructors
245         //- Construct from components
246         fvFieldDecomposer
247         (
248             const fvMesh& completeMesh,
249             const fvMesh& procMesh,
250             const labelList& faceAddressing,
251             const labelList& cellAddressing,
252             const labelList& boundaryAddressing
253         );
256     // Destructor
258         ~fvFieldDecomposer();
261     // Member Functions
263         //- Decompose volume field
264         template<class Type>
265         tmp<GeometricField<Type, fvPatchField, volMesh> >
266         decomposeField
267         (
268             const GeometricField<Type, fvPatchField, volMesh>& field
269         ) const;
271         //- Decompose surface field
272         template<class Type>
273         tmp<GeometricField<Type, fvsPatchField, surfaceMesh> >
274         decomposeField
275         (
276             const GeometricField<Type, fvsPatchField, surfaceMesh>& field
277         ) const;
279         template<class GeoField>
280         void decomposeFields(const PtrList<GeoField>& fields) const;
284 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
286 } // End namespace Foam
288 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
290 #ifdef NoRepository
291 #   include "fvFieldDecomposerDecomposeFields.C"
292 #endif
294 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
296 #endif
298 // ************************************************************************* //