Forward compatibility: flex
[foam-extend-3.2.git] / applications / utilities / parallelProcessing / decomposePar / tetPointFieldDecomposer.H
blob58ca744321da5b318c47b28b461ac9359ebd9693
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     tetPointFieldDecomposer
27 Description
28     Tetrahedral point field decomposer.
30 SourceFiles
31     tetPointFieldDecomposer.C
32     tetPointFieldDecomposerDecomposeFields.C
34 \*---------------------------------------------------------------------------*/
36 #ifndef tetPointFieldDecomposer_H
37 #define tetPointFieldDecomposer_H
39 #include "tetPolyMesh.H"
40 #include "tetPointMesh.H"
41 #include "elementMesh.H"
42 #include "tetPolyPatch.H"
43 #include "PointPatchFieldMapperPatchRef.H"
44 #include "tetPolyPatchFields.H"
45 #include "elementPatchFields.H"
46 #include "GeometricField.H"
48 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
50 namespace Foam
53 /*---------------------------------------------------------------------------*\
54                        Class tetPointFieldDecomposer Declaration
55 \*---------------------------------------------------------------------------*/
57 class tetPointFieldDecomposer
59 public:
61         //- Patch field decomposer class
62         class tetPolyPatchFieldDecomposer
63         :
64             public PointPatchFieldMapperPatchRef<tetPolyPatch>
65         {
66             // Private data
68                 //- Size before mapping
69                 label sizeBeforeMapping_;
71                 //- Reference to direct addressing
72                 const labelList& directAddressing_;
75             // Demand-driven data
77                 //- Addressing
78                 mutable labelList* directPatchAddressingPtr_;
81             // Private Member Functions
83                 //- Disallow default bitwise copy construct
84                 tetPolyPatchFieldDecomposer
85                 (
86                     const tetPolyPatchFieldDecomposer&
87                 );
89                 //- Disallow default bitwise assignment
90                 void operator=(const tetPolyPatchFieldDecomposer&);
93             // Member functions to calculate demand driven data
95                 //- Calculate addressing
96                 void calcPatchAddressing() const;
99         public:
101             // Constructors
103                 //- Construct given addressing
104                 tetPolyPatchFieldDecomposer
105                 (
106                     const tetPolyPatch& sourcePatch,
107                     const tetPolyPatch& targetPatch,
108                     const labelList& directAddr
109                 )
110                 :
111                     PointPatchFieldMapperPatchRef<tetPolyPatch>
112                     (
113                         sourcePatch,
114                         targetPatch
115                     ),
116                     sizeBeforeMapping_(sourcePatch.size()),
117                     directAddressing_(directAddr),
118                     directPatchAddressingPtr_(NULL)
119                 {}
122             // Destructor
124                 virtual ~tetPolyPatchFieldDecomposer()
125                 {}
128             // Member functions
130                 virtual label size() const
131                 {
132                     return directAddressing().size();
133                 }
135                 virtual label sizeBeforeMapping() const
136                 {
137                     return sizeBeforeMapping_;
138                 }
140                 virtual bool direct() const
141                 {
142                     return true;
143                 }
145                 virtual const unallocLabelList& directAddressing() const
146                 {
147                     if (!directPatchAddressingPtr_)
148                     {
149                         calcPatchAddressing();
150                     }
152                     return *directPatchAddressingPtr_;
153                 }
154         };
156 private:
158     // Private data
160         //- Reference to original mesh
161         const tetPolyMesh& originalMesh_;
163         //- Reference to processor mesh
164         const tetPolyMesh& processorMesh_;
166         //- Reference to point addressing
167         const labelList& pointAddressing_;
169         //- Reference to face addressing
170         const labelList& faceAddressing_;
172         //- Reference to cell addressing
173         const labelList& cellAddressing_;
175         //- Reference to boundary addressing
176         const labelList& boundaryAddressing_;
178         //- List of patch field decomposers
179         List<tetPolyPatchFieldDecomposer*> patchFieldDecompPtrs_;
181     // Demand-driven data
183         //- Addressing
184         mutable labelList* directAddressingPtr_;
187     // Private Member Functions
189         //- Disallow default bitwise copy construct
190         tetPointFieldDecomposer
191         (
192             const tetPointFieldDecomposer&
193         );
195         //- Disallow default bitwise assignment
196         void operator=(const tetPointFieldDecomposer&);
198     // Member functions for demand driven data
200         //- Return addressing
201         const labelList& directAddressing() const;
203         //- Calculate addressing
204         void calcAddressing() const;
207 public:
209     // Constructors
211         //- Construct from components
212         tetPointFieldDecomposer
213         (
214             const tetPolyMesh& originalMesh,
215             const tetPolyMesh& processorMesh,
216             const labelList& pointAddressing,
217             const labelList& faceAddressing,
218             const labelList& cellAddressing,
219             const labelList& boundaryAddressing
220         );
222     // Destructor
224         ~tetPointFieldDecomposer();
227     // Member Functions
229         //- Decompose point field
230         template<class Type>
231         tmp<GeometricField<Type, tetPolyPatchField, tetPointMesh> >
232         decomposeField
233         (
234             const GeometricField<Type, tetPolyPatchField, tetPointMesh>&
235         ) const;
237         //- Decompose element field
238         template<class Type>
239         tmp<GeometricField<Type, elementPatchField, elementMesh> >
240         decomposeField
241         (
242             const GeometricField<Type, elementPatchField, elementMesh>&
243         ) const;
245         template<class GeoField>
246         void decomposeFields(const PtrList<GeoField>& fields) const;
250 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
252 } // End namespace Foam
254 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
256 #ifdef NoRepository
257 #   include "tetPointFieldDecomposerDecomposeFields.C"
258 #endif
260 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
262 #endif
264 // ************************************************************************* //