Forward compatibility: flex
[foam-extend-3.2.git] / applications / utilities / parallelProcessing / decomposePar / faFieldDecomposer.H
blob5901ee7c2970e61104820f98d2f5ac23cc3e63dc
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     faFieldDecomposer
27 Description
28     Finite Area area and edge field decomposer.
30 Author
31     Zeljko Tukovic, FSB Zagreb.  All rights reserved
33 SourceFiles
34     faFieldDecomposer.C
35     faFieldDecomposerDecomposeFields.C
37 \*---------------------------------------------------------------------------*/
39 #ifndef faFieldDecomposer_H
40 #define faFieldDecomposer_H
42 // #include "faMesh.H"
43 // #include "faPatchFieldMapper.H"
44 #include "faMesh.H"
45 #include "faPatchFieldMapper.H"
46 #include "edgeFields.H"
48 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
50 namespace Foam
53 class IOobjectList;
55 /*---------------------------------------------------------------------------*\
56                     Class faFieldDecomposer Declaration
57 \*---------------------------------------------------------------------------*/
59 class faFieldDecomposer
61 public:
63         //- Patch field decomposer class
64         class patchFieldDecomposer
65         :
66             public faPatchFieldMapper
67         {
68             // Private data
70                 label sizeBeforeMapping_;
71                 labelList directAddressing_;
73         public:
75             // Constructors
77                 //- Construct given addressing
78                 patchFieldDecomposer
79                 (
80                     const label sizeBeforeMapping,
81                     const unallocLabelList& addressingSlice,
82                     const label addressingOffset
83                 );
86             // Member functions
88                 label size() const
89                 {
90                     return directAddressing_.size();
91                 }
93                 virtual label sizeBeforeMapping() const
94                 {
95                     return sizeBeforeMapping_;
96                 }
98                 bool direct() const
99                 {
100                     return true;
101                 }
103                 const unallocLabelList& directAddressing() const
104                 {
105                     return directAddressing_;
106                 }
107         };
110         //- Processor patch field decomposer class
111         class processorAreaPatchFieldDecomposer
112         :
113             public faPatchFieldMapper
114         {
115             // Private data
117                 label sizeBeforeMapping_;
118                 labelListList addressing_;
119                 scalarListList weights_;
121         public:
123             //- Construct given addressing
124             processorAreaPatchFieldDecomposer
125             (
126                 const faMesh& mesh,
127                 const unallocLabelList& addressingSlice
128             );
131             // Member functions
133                 label size() const
134                 {
135                     return addressing_.size();
136                 }
138                 virtual label sizeBeforeMapping() const
139                 {
140                     return sizeBeforeMapping_;
141                 }
143                 bool direct() const
144                 {
145                     return false;
146                 }
148                 const labelListList& addressing() const
149                 {
150                     return addressing_;
151                 }
153                 const scalarListList& weights() const
154                 {
155                     return weights_;
156                 }
157         };
160         //- Processor patch field decomposer class
161         class processorEdgePatchFieldDecomposer
162         :
163             public faPatchFieldMapper
164         {
165             label sizeBeforeMapping_;
166             labelListList addressing_;
167             scalarListList weights_;
169         public:
171             //- Construct given addressing
172             processorEdgePatchFieldDecomposer
173             (
174                 label sizeBeforeMapping,
175                 const unallocLabelList& addressingSlice
176             );
179             // Member functions
181                 label size() const
182                 {
183                     return addressing_.size();
184                 }
186                 virtual label sizeBeforeMapping() const
187                 {
188                     return sizeBeforeMapping_;
189                 }
191                 bool direct() const
192                 {
193                     return false;
194                 }
196                 const labelListList& addressing() const
197                 {
198                     return addressing_;
199                 }
201                 const scalarListList& weights() const
202                 {
203                     return weights_;
204                 }
205         };
208 private:
210     // Private data
212         //- Reference to complete mesh
213         const faMesh& completeMesh_;
215         //- Reference to processor mesh
216         const faMesh& procMesh_;
218         //- Reference to edge addressing
219         const labelList& edgeAddressing_;
221         //- Reference to face addressing
222         const labelList& faceAddressing_;
224         //- Reference to boundary addressing
225         const labelList& boundaryAddressing_;
227         //- List of patch field decomposers
228         List<patchFieldDecomposer*> patchFieldDecomposerPtrs_;
230         List<processorAreaPatchFieldDecomposer*>
231             processorAreaPatchFieldDecomposerPtrs_;
233         List<processorEdgePatchFieldDecomposer*>
234             processorEdgePatchFieldDecomposerPtrs_;
237     // Private Member Functions
239         //- Disallow default bitwise copy construct
240         faFieldDecomposer(const faFieldDecomposer&);
242         //- Disallow default bitwise assignment
243         void operator=(const faFieldDecomposer&);
246 public:
248     // Constructors
250         //- Construct from components
251         faFieldDecomposer
252         (
253             const faMesh& completeMesh,
254             const faMesh& procMesh,
255             const labelList& edgeAddressing,
256             const labelList& faceAddressing,
257             const labelList& boundaryAddressing
258         );
261     // Destructor
263         ~faFieldDecomposer();
266     // Member Functions
268         //- Decompose area field
269         template<class Type>
270         tmp<GeometricField<Type, faPatchField, areaMesh> >
271         decomposeField
272         (
273             const GeometricField<Type, faPatchField, areaMesh>& field
274         ) const;
276         //- Decompose surface field
277         template<class Type>
278         tmp<GeometricField<Type, faePatchField, edgeMesh> >
279         decomposeField
280         (
281             const GeometricField<Type, faePatchField, edgeMesh>& field
282         ) const;
284         template<class GeoField>
285         void decomposeFields(const PtrList<GeoField>& fields) const;
289 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
291 } // End namespace Foam
293 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
295 #ifdef NoRepository
296 #   include "faFieldDecomposerDecomposeFields.C"
297 #endif
299 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
301 #endif
303 // ************************************************************************* //