initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / dynamicMesh / fvMeshAdder / fvMeshAdder.H
blobb5a41636428dfca49582bf61a27ea3c147f50249
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
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     Foam::fvMeshAdder
28 Description
29     Adds two fvMeshes without using any polyMesh morphing.
30     Uses fvMeshAdder.
32 SourceFiles
33     fvMeshAdder.C
34     fvMeshAdderTemplates.C
36 \*---------------------------------------------------------------------------*/
38 #ifndef fvMeshAdder_H
39 #define fvMeshAdder_H
41 #include "polyMeshAdder.H"
42 #include "fvPatchFieldsFwd.H"
43 #include "fvsPatchFieldsFwd.H"
44 #include "fvPatchFieldMapper.H"
46 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
48 namespace Foam
51 // Forward declaration of classes
52 class IOobject;
53 class faceCoupleInfo;
54 class IOobjectList;
55 class fvMesh;
56 class volMesh;
57 class surfaceMesh;
58 class mapAddedPolyMesh;
60 /*---------------------------------------------------------------------------*\
61                            Class fvMeshAdder Declaration
62 \*---------------------------------------------------------------------------*/
64 class fvMeshAdder
66     public polyMeshAdder
69 private:
72     // Private class
74     class directFvPatchFieldMapper
75     :
76         public fvPatchFieldMapper
77     {
78         // Private data
80             const labelList& directAddressing_;
82     public:
84         // Constructors
86             //- Construct from components
87             directFvPatchFieldMapper(const labelList& directAddressing)
88             :
89                 fvPatchFieldMapper(),
90                 directAddressing_(directAddressing)
91             {}
94         // Destructor
96             virtual ~directFvPatchFieldMapper()
97             {}
100         // Member Functions
102             label size() const
103             {
104                 return directAddressing_.size();
105             }
107             bool direct() const
108             {
109                 return true;
110             }
112             const unallocLabelList& directAddressing() const
113             {
114                 return directAddressing_;
115             }
116     };
119     // Private Member Functions
121         //- Calculate map from new patch faces to old patch faces. -1 where
122         //  could not map.
123         static labelList calcPatchMap
124         (
125             const label oldStart,
126             const label oldSize,
127             const labelList& oldToNew,
128             const polyPatch& newPatch,
129             const label unmappedIndex
130         );
132         //- Map from old to new according to map. Handles map = -1.
133         template<class Type>
134         static void map
135         (
136             const Field<Type>&,
137             const labelList& map,
138             Field<Type>&
139         );
141         //- Update single volField.
142         template<class Type>
143         static void MapVolField
144         (
145             const mapAddedPolyMesh& meshMap,
147             GeometricField<Type, fvPatchField, volMesh>& fld,
148             const GeometricField<Type, fvPatchField, volMesh>& fldToAdd
149         );
151         //- Update single surfaceField.
152         template<class Type>
153         static void MapSurfaceField
154         (
155             const mapAddedPolyMesh& meshMap,
157             GeometricField<Type, fvsPatchField, surfaceMesh>& fld,
158             const GeometricField<Type, fvsPatchField, surfaceMesh>& fldToAdd
159         );
161 public:
163     // Member Functions
165         //- Inplace add mesh to fvMesh. Maps all stored fields. Returns map.
166         static autoPtr<mapAddedPolyMesh> add
167         (
168             fvMesh& mesh0,
169             const fvMesh& mesh1,
170             const faceCoupleInfo& coupleInfo,
171             const bool validBoundary = true
172         );
174         //- Map all volFields of Type
175         template<class Type>
176         static void MapVolFields
177         (
178             const mapAddedPolyMesh&,
179             const fvMesh& mesh,
180             const fvMesh& meshToAdd
181         );
183         //- Map all surfaceFields of Type
184         template<class Type>
185         static void MapSurfaceFields
186         (
187             const mapAddedPolyMesh&,
188             const fvMesh& mesh,
189             const fvMesh& meshToAdd
190         );
194 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
196 } // End namespace Foam
198 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
200 #ifdef NoRepository
201 #   include "fvMeshAdderTemplates.C"
202 #endif
204 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
206 #endif
208 // ************************************************************************* //