FreeFOAM The Cross-Platform CFD Toolkit
mapPolyMesh.C
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 Description
25 
26 \*---------------------------------------------------------------------------*/
27 
28 #include "mapPolyMesh.H"
29 #include <OpenFOAM/polyMesh.H>
30 
31 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
32 
33 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
34 
35 // Construct from components
36 Foam::mapPolyMesh::mapPolyMesh
37 (
38  const polyMesh& mesh,
39  const label nOldPoints,
40  const label nOldFaces,
41  const label nOldCells,
42  const labelList& pointMap,
43  const List<objectMap>& pointsFromPoints,
44  const labelList& faceMap,
45  const List<objectMap>& facesFromPoints,
46  const List<objectMap>& facesFromEdges,
47  const List<objectMap>& facesFromFaces,
48  const labelList& cellMap,
49  const List<objectMap>& cellsFromPoints,
50  const List<objectMap>& cellsFromEdges,
51  const List<objectMap>& cellsFromFaces,
52  const List<objectMap>& cellsFromCells,
53  const labelList& reversePointMap,
54  const labelList& reverseFaceMap,
55  const labelList& reverseCellMap,
56  const labelHashSet& flipFaceFlux,
57  const labelListList& patchPointMap,
58  const labelListList& pointZoneMap,
59  const labelListList& faceZonePointMap,
60  const labelListList& faceZoneFaceMap,
61  const labelListList& cellZoneMap,
62  const pointField& preMotionPoints,
63  const labelList& oldPatchStarts,
64  const labelList& oldPatchNMeshPoints
65 )
66 :
67  mesh_(mesh),
68  nOldPoints_(nOldPoints),
69  nOldFaces_(nOldFaces),
70  nOldCells_(nOldCells),
71  pointMap_(pointMap),
72  pointsFromPointsMap_(pointsFromPoints),
73  faceMap_(faceMap),
74  facesFromPointsMap_(facesFromPoints),
75  facesFromEdgesMap_(facesFromEdges),
76  facesFromFacesMap_(facesFromFaces),
77  cellMap_(cellMap),
78  cellsFromPointsMap_(cellsFromPoints),
79  cellsFromEdgesMap_(cellsFromEdges),
80  cellsFromFacesMap_(cellsFromFaces),
81  cellsFromCellsMap_(cellsFromCells),
82  reversePointMap_(reversePointMap),
83  reverseFaceMap_(reverseFaceMap),
84  reverseCellMap_(reverseCellMap),
85  flipFaceFlux_(flipFaceFlux),
86  patchPointMap_(patchPointMap),
87  pointZoneMap_(pointZoneMap),
88  faceZonePointMap_(faceZonePointMap),
89  faceZoneFaceMap_(faceZoneFaceMap),
90  cellZoneMap_(cellZoneMap),
91  preMotionPoints_(preMotionPoints),
92  oldPatchSizes_(oldPatchStarts.size()),
93  oldPatchStarts_(oldPatchStarts),
94  oldPatchNMeshPoints_(oldPatchNMeshPoints)
95 {
96  // Calculate old patch sizes
97  for (label patchI = 0; patchI < oldPatchStarts_.size() - 1; patchI++)
98  {
99  oldPatchSizes_[patchI] =
100  oldPatchStarts_[patchI + 1] - oldPatchStarts_[patchI];
101  }
102 
103  // Set the last one by hand
104  const label lastPatchID = oldPatchStarts_.size() - 1;
105 
106  oldPatchSizes_[lastPatchID] = nOldFaces_ - oldPatchStarts_[lastPatchID];
107 
108  if (polyMesh::debug)
109  {
110  if (min(oldPatchSizes_) < 0)
111  {
112  FatalErrorIn("mapPolyMesh::mapPolyMesh(...)")
113  << "Calculated negative old patch size. Error in mapping data"
114  << abort(FatalError);
115  }
116  }
117 }
118 
119 
120 // Construct from components and optionally reuse storage
121 Foam::mapPolyMesh::mapPolyMesh
122 (
123  const polyMesh& mesh,
124  const label nOldPoints,
125  const label nOldFaces,
126  const label nOldCells,
127  labelList& pointMap,
128  List<objectMap>& pointsFromPoints,
129  labelList& faceMap,
130  List<objectMap>& facesFromPoints,
131  List<objectMap>& facesFromEdges,
132  List<objectMap>& facesFromFaces,
133  labelList& cellMap,
134  List<objectMap>& cellsFromPoints,
135  List<objectMap>& cellsFromEdges,
136  List<objectMap>& cellsFromFaces,
137  List<objectMap>& cellsFromCells,
138  labelList& reversePointMap,
139  labelList& reverseFaceMap,
140  labelList& reverseCellMap,
141  labelHashSet& flipFaceFlux,
142  labelListList& patchPointMap,
143  labelListList& pointZoneMap,
144  labelListList& faceZonePointMap,
145  labelListList& faceZoneFaceMap,
146  labelListList& cellZoneMap,
147  pointField& preMotionPoints,
148  labelList& oldPatchStarts,
149  labelList& oldPatchNMeshPoints,
150  const bool reUse
151 )
152 :
153  mesh_(mesh),
154  nOldPoints_(nOldPoints),
155  nOldFaces_(nOldFaces),
156  nOldCells_(nOldCells),
157  pointMap_(pointMap, reUse),
158  pointsFromPointsMap_(pointsFromPoints, reUse),
159  faceMap_(faceMap, reUse),
160  facesFromPointsMap_(facesFromPoints, reUse),
161  facesFromEdgesMap_(facesFromEdges, reUse),
162  facesFromFacesMap_(facesFromFaces, reUse),
163  cellMap_(cellMap, reUse),
164  cellsFromPointsMap_(cellsFromPoints, reUse),
165  cellsFromEdgesMap_(cellsFromEdges, reUse),
166  cellsFromFacesMap_(cellsFromFaces, reUse),
167  cellsFromCellsMap_(cellsFromCells, reUse),
168  reversePointMap_(reversePointMap, reUse),
169  reverseFaceMap_(reverseFaceMap, reUse),
170  reverseCellMap_(reverseCellMap, reUse),
171  flipFaceFlux_(flipFaceFlux),
172  patchPointMap_(patchPointMap, reUse),
173  pointZoneMap_(pointZoneMap, reUse),
174  faceZonePointMap_(faceZonePointMap, reUse),
175  faceZoneFaceMap_(faceZoneFaceMap, reUse),
176  cellZoneMap_(cellZoneMap, reUse),
177  preMotionPoints_(preMotionPoints, reUse),
178  oldPatchSizes_(oldPatchStarts.size()),
179  oldPatchStarts_(oldPatchStarts, reUse),
180  oldPatchNMeshPoints_(oldPatchNMeshPoints, reUse)
181 {
182  // Calculate old patch sizes
183  for (label patchI = 0; patchI < oldPatchStarts_.size() - 1; patchI++)
184  {
185  oldPatchSizes_[patchI] =
186  oldPatchStarts_[patchI + 1] - oldPatchStarts_[patchI];
187  }
188 
189  // Set the last one by hand
190  const label lastPatchID = oldPatchStarts_.size() - 1;
191 
192  oldPatchSizes_[lastPatchID] = nOldFaces_ - oldPatchStarts_[lastPatchID];
193 
194  if (polyMesh::debug)
195  {
196  if (min(oldPatchSizes_) < 0)
197  {
198  FatalErrorIn("mapPolyMesh::mapPolyMesh(...)")
199  << "Calculated negative old patch size. Error in mapping data"
200  << abort(FatalError);
201  }
202  }
203 }
204 
205 
206 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
207 
208 
209 // ************************ vim: set sw=4 sts=4 et: ************************ //