BUGFIX: Uninitialised member variables
[foam-extend-3.2.git] / applications / utilities / parallelProcessing / decomposePar / tetPointFieldDecomposer.H
blobb570734acefa43dcbad5fe8e931967393a739c90
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(const tetPolyPatchFieldDecomposer&);
87                 //- Disallow default bitwise assignment
88                 void operator=(const tetPolyPatchFieldDecomposer&);
91             // Member functions to calculate demand driven data
93                 //- Calculate addressing
94                 void calcPatchAddressing() const;
97         public:
99             // Constructors
101                 //- Construct given addressing
102                 tetPolyPatchFieldDecomposer
103                 (
104                     const tetPolyPatch& sourcePatch,
105                     const tetPolyPatch& targetPatch,
106                     const labelList& directAddr
107                 )
108                 :
109                     PointPatchFieldMapperPatchRef<tetPolyPatch>
110                     (
111                         sourcePatch,
112                         targetPatch
113                     ),
114                     sizeBeforeMapping_(sourcePatch.size()),
115                     directAddressing_(directAddr),
116                     directPatchAddressingPtr_(NULL)
117                 {}
120             // Destructor
122                 virtual ~tetPolyPatchFieldDecomposer()
123                 {}
126             // Member functions
128                 virtual label size() const
129                 {
130                     return directAddressing().size();
131                 }
133                 virtual label sizeBeforeMapping() const
134                 {
135                     return sizeBeforeMapping_;
136                 }
138                 virtual bool direct() const
139                 {
140                     return true;
141                 }
143                 virtual const unallocLabelList& directAddressing() const
144                 {
145                     if (!directPatchAddressingPtr_)
146                     {
147                         calcPatchAddressing();
148                     }
150                     return *directPatchAddressingPtr_;
151                 }
152         };
154 private:
156     // Private data
158         //- Reference to original mesh
159         const tetPolyMesh& originalMesh_;
161         //- Reference to processor mesh
162         const tetPolyMesh& processorMesh_;
164         //- Reference to point addressing
165         const labelList& pointAddressing_;
167         //- Reference to face addressing
168         const labelList& faceAddressing_;
170         //- Reference to cell addressing
171         const labelList& cellAddressing_;
173         //- Reference to boundary addressing
174         const labelList& boundaryAddressing_;
176         //- List of patch field decomposers
177         List<tetPolyPatchFieldDecomposer*> patchFieldDecompPtrs_;
179     // Demand-driven data
181         //- Addressing
182         mutable labelList* directAddressingPtr_;
185     // Private Member Functions
187         //- Disallow default bitwise copy construct
188         tetPointFieldDecomposer
189         (
190             const tetPointFieldDecomposer&
191         );
193         //- Disallow default bitwise assignment
194         void operator=(const tetPointFieldDecomposer&);
196     // Member functions for demand driven data
198         //- Return addressing
199         const labelList& directAddressing() const;
201         //- Calculate addressing
202         void calcAddressing() const;
205 public:
207     // Constructors
209         //- Construct from components
210         tetPointFieldDecomposer
211         (
212             const tetPolyMesh& originalMesh,
213             const tetPolyMesh& processorMesh,
214             const labelList& pointAddressing,
215             const labelList& faceAddressing,
216             const labelList& cellAddressing,
217             const labelList& boundaryAddressing
218         );
220     // Destructor
222         ~tetPointFieldDecomposer();
225     // Member Functions
227         //- Decompose point field
228         template<class Type>
229         tmp<GeometricField<Type, tetPolyPatchField, tetPointMesh> >
230         decomposeField
231         (
232             const GeometricField<Type, tetPolyPatchField, tetPointMesh>&
233         ) const;
235         //- Decompose element field
236         template<class Type>
237         tmp<GeometricField<Type, elementPatchField, elementMesh> >
238         decomposeField
239         (
240             const GeometricField<Type, elementPatchField, elementMesh>&
241         ) const;
243         template<class GeoField>
244         void decomposeFields(const PtrList<GeoField>& fields) const;
248 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
250 } // End namespace Foam
252 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
254 #ifdef NoRepository
255 #   include "tetPointFieldDecomposerDecomposeFields.C"
256 #endif
258 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
260 #endif
262 // ************************************************************************* //