BUGFIX: Illegal use of uninitialised value (backport)
[foam-extend-3.2.git] / src / dynamicMesh / dynamicFvMesh / dynamicTopoFvMesh / coupledInfo.H
blobec65925a07b789573f02a7a4e82e993496f5d626
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     coupledInfo
28 Description
29     An interface class that provides patch coupling functionality
31 Author
32     Sandeep Menon
33     University of Massachusetts Amherst
34     All rights reserved
36 SourceFiles
37     coupledInfo.C
39 \*---------------------------------------------------------------------------*/
41 #ifndef coupledInfo_H
42 #define coupledInfo_H
44 #include "autoPtr.H"
45 #include "coupleMap.H"
46 #include "volFieldsFwd.H"
47 #include "surfaceFieldsFwd.H"
48 #include "fvPatchFieldMapper.H"
50 namespace Foam
53 // Class forward declarations
54 class dynamicTopoFvMesh;
56 /*---------------------------------------------------------------------------*\
57                          Class coupledInfo Declaration
58 \*---------------------------------------------------------------------------*/
60 class coupledInfo
62     // Reference to the parent mesh
63     const dynamicTopoFvMesh& mesh_;
65     // Auto pointer to a subMesh
66     autoPtr<dynamicTopoFvMesh> subMesh_;
68     // Flag to determine whether maps have been built.
69     bool builtMaps_;
71     // For locally coupled patches,
72     // specify a master / slave index
73     coupleMap map_;
75     // Zone IDs for patches associated with faceZones
76     label masterFaceZone_;
77     label slaveFaceZone_;
79     //- Disallow default bitwise assignment
80     inline void operator=(const coupledInfo&);
82 public:
84     // Constructor
85     inline coupledInfo
86     (
87         const dynamicTopoFvMesh& mesh,
88         const coupleMap& cMap,
89         const label mfzIndex = -1,
90         const label sfzIndex = -1
91     );
93     inline coupledInfo
94     (
95         const dynamicTopoFvMesh& mesh,
96         const bool isTwoDMesh,
97         const bool isLocal,
98         const bool isSend,
99         const label patchIndex,
100         const label mPatch,
101         const label sPatch,
102         const label mfzIndex = -1,
103         const label sfzIndex = -1
104     );
106     //- Access
108         // Return a const reference to the parent mesh
109         inline const dynamicTopoFvMesh& baseMesh() const;
111         // Set a new subMesh
112         inline void setMesh(label index, dynamicTopoFvMesh* mesh);
114         // Return a reference to the subMesh
115         inline dynamicTopoFvMesh& subMesh();
117         // Return a const reference to the subMesh
118         inline const dynamicTopoFvMesh& subMesh() const;
120         // Have maps been built?
121         inline bool builtMaps() const;
123         // Change the flag
124         inline void setBuiltMaps();
126         // Return a reference to the coupleMap
127         inline coupleMap& map();
129         // Return a const reference to the coupleMap
130         inline const coupleMap& map() const;
132         // Return the master / slave face zone IDs
133         inline label masterFaceZone() const;
134         inline label slaveFaceZone() const;
136     //- Interpolation
138         //- Generic subMesh mapper
139         class subMeshMapper
140         :
141             public fvPatchFieldMapper
142         {
143             label sizeBeforeMapping_;
145             labelField directAddressing_;
147         public:
149             // Constructors
151                 //- Construct from components
152                 inline subMeshMapper
153                 (
154                     const label sbm,
155                     const labelList& da
156                 )
157                 :
158                     sizeBeforeMapping_(sbm),
159                     directAddressing_(da)
160                 {}
162                 //- Construct given addressing
163                 inline subMeshMapper
164                 (
165                     const coupledInfo& cInfo,
166                     const label patchI
167                 );
169             // Destructor
171                 virtual ~subMeshMapper()
172                 {}
174             // Member Functions
176                 label size() const
177                 {
178                     return directAddressing_.size();
179                 }
181                 label sizeBeforeMapping() const
182                 {
183                     return directAddressing_.size();
184                 }
186                 bool direct() const
187                 {
188                     return true;
189                 }
191                 const unallocLabelList& directAddressing() const
192                 {
193                     return directAddressing_;
194                 }
195         };
197         // Set subMesh centres
198         inline void setCentres(PtrList<volVectorField>& centres) const;
200         // Subset volume field
201         template <class Type>
202         tmp<GeometricField<Type, fvPatchField, volMesh> >
203         subSetVolField
204         (
205             const GeometricField<Type, fvPatchField, volMesh>& field
206         ) const;
208         // Subset surface field
209         template <class Type>
210         tmp<GeometricField<Type, fvsPatchField, surfaceMesh> >
211         subSetSurfaceField
212         (
213             const GeometricField<Type, fvsPatchField, surfaceMesh>& field
214         ) const;
216         // Subset the volume fields from registry to output stream
217         template <class Type>
218         void mapVolField
219         (
220             const wordList& fieldNames,
221             const word& fieldType,
222             OSstream& strStream
223         ) const;
225         // Subset the surface field from registry to output stream
226         template <class Type>
227         void mapSurfaceField
228         (
229             const wordList& fieldNames,
230             const word& fieldType,
231             OSstream& strStream
232         ) const;
234         // Set volume field pointer from input dictionary
235         template <class GeomField>
236         void setField
237         (
238             const wordList& fieldNames,
239             const dictionary& fieldDicts,
240             PtrList<GeomField>& fields
241         ) const;
243         // Resize map for individual field
244         template <class GeomField>
245         static void resizeMap
246         (
247             const label srcIndex,
248             const subMeshMapper& internalMapper,
249             const List<labelList>& internalReverseMaps,
250             const PtrList<subMeshMapper>& boundaryMapper,
251             const List<labelListList>& boundaryReverseMaps,
252             const List<PtrList<GeomField> >& srcFields,
253             GeomField& field
254         );
256         // Resize map for all fields in registry
257         template <class GeomField>
258         static void resizeMap
259         (
260             const wordList& fieldNames,
261             const objectRegistry& mesh,
262             const subMeshMapper& internalMapper,
263             const List<labelList>& internalReverseMaps,
264             const PtrList<subMeshMapper>& boundaryMapper,
265             const List<labelListList>& boundaryReverseMaps,
266             const List<PtrList<GeomField> >& srcFields
267         );
270 } // End namespace Foam
272 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
274 #ifdef NoRepository
275 #    include "coupledInfo.C"
276 #endif
278 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
280 #endif
282 // ************************************************************************* //