BUGFIX: Illegal use of uninitialised value (backport)
[foam-extend-3.2.git] / applications / utilities / parallelProcessing / decomposePar / tetPointFieldDecomposer.H
blobf4b5665ad2d99f45db0652e081cbc82d0f8f4542
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     tetPointFieldDecomposer
28 Description
29     Tetrahedral point field decomposer.
31 SourceFiles
32     tetPointFieldDecomposer.C
33     tetPointFieldDecomposerDecomposeFields.C
35 \*---------------------------------------------------------------------------*/
37 #ifndef tetPointFieldDecomposer_H
38 #define tetPointFieldDecomposer_H
40 #include "tetPolyMesh.H"
41 #include "tetPointMesh.H"
42 #include "elementMesh.H"
43 #include "tetPolyPatch.H"
44 #include "PointPatchFieldMapperPatchRef.H"
45 #include "tetPolyPatchFields.H"
46 #include "elementPatchFields.H"
47 #include "GeometricField.H"
49 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
51 namespace Foam
54 /*---------------------------------------------------------------------------*\
55                        Class tetPointFieldDecomposer Declaration
56 \*---------------------------------------------------------------------------*/
58 class tetPointFieldDecomposer
60 public:
62         //- Patch field decomposer class
63         class tetPolyPatchFieldDecomposer
64         :
65             public PointPatchFieldMapperPatchRef<tetPolyPatch>
66         {
67             // Private data
69                 //- Size before mapping
70                 label sizeBeforeMapping_;
72                 //- Reference to direct addressing
73                 const labelList& directAddressing_;
76             // Demand-driven data
78                 //- Addressing
79                 mutable labelList* directPatchAddressingPtr_;
82             // Private Member Functions
84                 //- Disallow default bitwise copy construct
85                 tetPolyPatchFieldDecomposer
86                 (
87                     const tetPolyPatchFieldDecomposer&
88                 );
90                 //- Disallow default bitwise assignment
91                 void operator=(const tetPolyPatchFieldDecomposer&);
94             // Member functions to calculate demand driven data
96                 //- Calculate addressing
97                 void calcPatchAddressing() const;
100         public:
102             // Constructors
104                 //- Construct given addressing
105                 tetPolyPatchFieldDecomposer
106                 (
107                     const tetPolyPatch& sourcePatch,
108                     const tetPolyPatch& targetPatch,
109                     const labelList& directAddr
110                 )
111                 :
112                     PointPatchFieldMapperPatchRef<tetPolyPatch>
113                     (
114                         sourcePatch,
115                         targetPatch
116                     ),
117                     sizeBeforeMapping_(sourcePatch.size()),
118                     directAddressing_(directAddr),
119                     directPatchAddressingPtr_(NULL)
120                 {}
123             // Destructor
125                 virtual ~tetPolyPatchFieldDecomposer()
126                 {}
129             // Member functions
131                 virtual label size() const
132                 {
133                     return directAddressing().size();
134                 }
136                 virtual label sizeBeforeMapping() const
137                 {
138                     return sizeBeforeMapping_;
139                 }
141                 virtual bool direct() const
142                 {
143                     return true;
144                 }
146                 virtual const unallocLabelList& directAddressing() const
147                 {
148                     if (!directPatchAddressingPtr_)
149                     {
150                         calcPatchAddressing();
151                     }
153                     return *directPatchAddressingPtr_;
154                 }
155         };
157 private:
159     // Private data
161         //- Reference to original mesh
162         const tetPolyMesh& originalMesh_;
164         //- Reference to processor mesh
165         const tetPolyMesh& processorMesh_;
167         //- Reference to point addressing
168         const labelList& pointAddressing_;
170         //- Reference to face addressing
171         const labelList& faceAddressing_;
173         //- Reference to cell addressing
174         const labelList& cellAddressing_;
176         //- Reference to boundary addressing
177         const labelList& boundaryAddressing_;
179         //- List of patch field decomposers
180         List<tetPolyPatchFieldDecomposer*> patchFieldDecompPtrs_;
182     // Demand-driven data
184         //- Addressing
185         mutable labelList* directAddressingPtr_;
188     // Private Member Functions
190         //- Disallow default bitwise copy construct
191         tetPointFieldDecomposer
192         (
193             const tetPointFieldDecomposer&
194         );
196         //- Disallow default bitwise assignment
197         void operator=(const tetPointFieldDecomposer&);
199     // Member functions for demand driven data
201         //- Return addressing
202         const labelList& directAddressing() const;
204         //- Calculate addressing
205         void calcAddressing() const;
208 public:
210     // Constructors
212         //- Construct from components
213         tetPointFieldDecomposer
214         (
215             const tetPolyMesh& originalMesh,
216             const tetPolyMesh& processorMesh,
217             const labelList& pointAddressing,
218             const labelList& faceAddressing,
219             const labelList& cellAddressing,
220             const labelList& boundaryAddressing
221         );
223     // Destructor
225         ~tetPointFieldDecomposer();
228     // Member Functions
230         //- Decompose point field
231         template<class Type>
232         tmp<GeometricField<Type, tetPolyPatchField, tetPointMesh> >
233         decomposeField
234         (
235             const GeometricField<Type, tetPolyPatchField, tetPointMesh>&
236         ) const;
238         //- Decompose element field
239         template<class Type>
240         tmp<GeometricField<Type, elementPatchField, elementMesh> >
241         decomposeField
242         (
243             const GeometricField<Type, elementPatchField, elementMesh>&
244         ) const;
246         template<class GeoField>
247         void decomposeFields(const PtrList<GeoField>& fields) const;
251 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
253 } // End namespace Foam
255 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
257 #ifdef NoRepository
258 #   include "tetPointFieldDecomposerDecomposeFields.C"
259 #endif
261 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
263 #endif
265 // ************************************************************************* //