BUG: potentialFoam/cylinder: indexing into non-existing patch in parallel
[OpenFOAM-2.0.x.git] / src / dynamicMesh / fvMeshAdder / fvMeshAdder.H
blobf246a1887f14e6070342c62724738590d05b7842
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2011 OpenFOAM Foundation
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 "polyMeshAdder.H"
41 #include "fvPatchFieldsFwd.H"
42 #include "fvsPatchFieldsFwd.H"
43 #include "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
94         virtual ~directFvPatchFieldMapper()
95         {}
98         // Member Functions
100             label size() const
101             {
102                 return directAddressing_.size();
103             }
105             bool direct() const
106             {
107                 return true;
108             }
110             const labelUList& directAddressing() const
111             {
112                 return directAddressing_;
113             }
114     };
117     // Private Member Functions
119         //- Calculate map from new patch faces to old patch faces. -1 where
120         //  could not map.
121         static labelList calcPatchMap
122         (
123             const label oldStart,
124             const label oldSize,
125             const labelList& oldToNew,
126             const polyPatch& newPatch,
127             const label unmappedIndex
128         );
130         //- Map from old to new according to map. Handles map = -1.
131         template<class Type>
132         static void map
133         (
134             const Field<Type>&,
135             const labelList& map,
136             Field<Type>&
137         );
139         //- Update single volField.
140         template<class Type>
141         static void MapVolField
142         (
143             const mapAddedPolyMesh& meshMap,
145             GeometricField<Type, fvPatchField, volMesh>& fld,
146             const GeometricField<Type, fvPatchField, volMesh>& fldToAdd
147         );
149         //- Update single surfaceField.
150         template<class Type>
151         static void MapSurfaceField
152         (
153             const mapAddedPolyMesh& meshMap,
155             GeometricField<Type, fvsPatchField, surfaceMesh>& fld,
156             const GeometricField<Type, fvsPatchField, surfaceMesh>& fldToAdd
157         );
159 public:
161     // Member Functions
163         //- Inplace add mesh to fvMesh. Maps all stored fields. Returns map.
164         static autoPtr<mapAddedPolyMesh> add
165         (
166             fvMesh& mesh0,
167             const fvMesh& mesh1,
168             const faceCoupleInfo& coupleInfo,
169             const bool validBoundary = true
170         );
172         //- Map all volFields of Type
173         template<class Type>
174         static void MapVolFields
175         (
176             const mapAddedPolyMesh&,
177             const fvMesh& mesh,
178             const fvMesh& meshToAdd
179         );
181         //- Map all surfaceFields of Type
182         template<class Type>
183         static void MapSurfaceFields
184         (
185             const mapAddedPolyMesh&,
186             const fvMesh& mesh,
187             const fvMesh& meshToAdd
188         );
192 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
194 } // End namespace Foam
196 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
198 #ifdef NoRepository
199 #   include "fvMeshAdderTemplates.C"
200 #endif
202 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
204 #endif
206 // ************************************************************************* //