FreeFOAM The Cross-Platform CFD Toolkit
fvMeshAdder.H
Go to the documentation of this file.
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.
10 
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.
15 
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.
20 
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/>.
23 
24 Class
25  Foam::fvMeshAdder
26 
27 Description
28  Adds two fvMeshes without using any polyMesh morphing.
29  Uses fvMeshAdder.
30 
31 SourceFiles
32  fvMeshAdder.C
33  fvMeshAdderTemplates.C
34 
35 \*---------------------------------------------------------------------------*/
36 
37 #ifndef fvMeshAdder_H
38 #define fvMeshAdder_H
39 
44 
45 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
46 
47 namespace Foam
48 {
49 
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;
58 
59 /*---------------------------------------------------------------------------*\
60  Class fvMeshAdder Declaration
61 \*---------------------------------------------------------------------------*/
62 
64 :
65  public polyMeshAdder
66 {
67 
68 private:
69 
70 
71  // Private class
72 
73  class directFvPatchFieldMapper
74  :
75  public fvPatchFieldMapper
76  {
77  // Private data
78 
79  const labelList& directAddressing_;
80 
81  public:
82 
83  // Constructors
84 
85  //- Construct from components
86  directFvPatchFieldMapper(const labelList& directAddressing)
87  :
89  directAddressing_(directAddressing)
90  {}
91 
92 
93  // Destructor
94 
95  virtual ~directFvPatchFieldMapper()
96  {}
97 
98 
99  // Member Functions
100 
101  label size() const
102  {
103  return directAddressing_.size();
104  }
105 
106  bool direct() const
107  {
108  return true;
109  }
110 
111  const unallocLabelList& directAddressing() const
112  {
113  return directAddressing_;
114  }
115  };
116 
117 
118  // Private Member Functions
119 
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  );
130 
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  );
139 
140  //- Update single volField.
141  template<class Type>
142  static void MapVolField
143  (
144  const mapAddedPolyMesh& meshMap,
145 
148  );
149 
150  //- Update single surfaceField.
151  template<class Type>
152  static void MapSurfaceField
153  (
154  const mapAddedPolyMesh& meshMap,
155 
158  );
159 
160 public:
161 
162  // Member Functions
163 
164  //- Inplace add mesh to fvMesh. Maps all stored fields. Returns map.
166  (
167  fvMesh& mesh0,
168  const fvMesh& mesh1,
169  const faceCoupleInfo& coupleInfo,
170  const bool validBoundary = true
171  );
172 
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  );
181 
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  );
190 };
191 
192 
193 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
194 
195 } // End namespace Foam
196 
197 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
198 
199 #ifdef NoRepository
201 #endif
202 
203 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
204 
205 #endif
206 
207 // ************************ vim: set sw=4 sts=4 et: ************************ //