Merge branch 'upstream/OpenFOAM' into pu
[freefoam.git] / src / dynamicMesh / fvMeshAdder / fvMeshAdder.H
blobe9b8787af07782f0267d3da195b38ce2cf687030
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2010 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
13     the Free Software Foundation, either version 3 of the License, or
14     (at your 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, see <http://www.gnu.org/licenses/>.
24 Class
25     Foam::fvMeshAdder
27 Description
28     Adds two fvMeshes without using any polyMesh morphing.
29     Uses fvMeshAdder.
31 SourceFiles
32     fvMeshAdder.C
33     fvMeshAdderTemplates.C
35 \*---------------------------------------------------------------------------*/
37 #ifndef fvMeshAdder_H
38 #define fvMeshAdder_H
40 #include <dynamicMesh/polyMeshAdder.H>
41 #include <finiteVolume/fvPatchFieldsFwd.H>
42 #include <finiteVolume/fvsPatchFieldsFwd.H>
43 #include <finiteVolume/fvPatchFieldMapper.H>
45 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
47 namespace Foam
50 // Forward declaration of classes
51 class IOobject;
52 class faceCoupleInfo;
53 class IOobjectList;
54 class fvMesh;
55 class volMesh;
56 class surfaceMesh;
57 class mapAddedPolyMesh;
59 /*---------------------------------------------------------------------------*\
60                            Class fvMeshAdder Declaration
61 \*---------------------------------------------------------------------------*/
63 class fvMeshAdder
65     public polyMeshAdder
68 private:
71     // Private class
73     class directFvPatchFieldMapper
74     :
75         public fvPatchFieldMapper
76     {
77         // Private data
79             const labelList& directAddressing_;
81     public:
83         // Constructors
85             //- Construct from components
86             directFvPatchFieldMapper(const labelList& directAddressing)
87             :
88                 fvPatchFieldMapper(),
89                 directAddressing_(directAddressing)
90             {}
93         // Destructor
95             virtual ~directFvPatchFieldMapper()
96             {}
99         // Member Functions
101             label size() const
102             {
103                 return directAddressing_.size();
104             }
106             bool direct() const
107             {
108                 return true;
109             }
111             const unallocLabelList& directAddressing() const
112             {
113                 return directAddressing_;
114             }
115     };
118     // Private Member Functions
120         //- Calculate map from new patch faces to old patch faces. -1 where
121         //  could not map.
122         static labelList calcPatchMap
123         (
124             const label oldStart,
125             const label oldSize,
126             const labelList& oldToNew,
127             const polyPatch& newPatch,
128             const label unmappedIndex
129         );
131         //- Map from old to new according to map. Handles map = -1.
132         template<class Type>
133         static void map
134         (
135             const Field<Type>&,
136             const labelList& map,
137             Field<Type>&
138         );
140         //- Update single volField.
141         template<class Type>
142         static void MapVolField
143         (
144             const mapAddedPolyMesh& meshMap,
146             GeometricField<Type, fvPatchField, volMesh>& fld,
147             const GeometricField<Type, fvPatchField, volMesh>& fldToAdd
148         );
150         //- Update single surfaceField.
151         template<class Type>
152         static void MapSurfaceField
153         (
154             const mapAddedPolyMesh& meshMap,
156             GeometricField<Type, fvsPatchField, surfaceMesh>& fld,
157             const GeometricField<Type, fvsPatchField, surfaceMesh>& fldToAdd
158         );
160 public:
162     // Member Functions
164         //- Inplace add mesh to fvMesh. Maps all stored fields. Returns map.
165         static autoPtr<mapAddedPolyMesh> add
166         (
167             fvMesh& mesh0,
168             const fvMesh& mesh1,
169             const faceCoupleInfo& coupleInfo,
170             const bool validBoundary = true
171         );
173         //- Map all volFields of Type
174         template<class Type>
175         static void MapVolFields
176         (
177             const mapAddedPolyMesh&,
178             const fvMesh& mesh,
179             const fvMesh& meshToAdd
180         );
182         //- Map all surfaceFields of Type
183         template<class Type>
184         static void MapSurfaceFields
185         (
186             const mapAddedPolyMesh&,
187             const fvMesh& mesh,
188             const fvMesh& meshToAdd
189         );
193 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
195 } // End namespace Foam
197 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
199 #ifdef NoRepository
200 #   include <dynamicMesh/fvMeshAdderTemplates.C>
201 #endif
203 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
205 #endif
207 // ************************ vim: set sw=4 sts=4 et: ************************ //