polyTopoChangeMap.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
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 \*---------------------------------------------------------------------------*/
25 
26 #include "polyTopoChangeMap.H"
27 #include "polyMesh.H"
28 
29 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
30 
32 :
33  mesh_(mesh),
34  nOldPoints_(-1),
35  nOldFaces_(-1),
36  nOldCells_(-1)
37 {}
38 
39 
41 (
42  const polyMesh& mesh,
43  const label nOldPoints,
44  const label nOldFaces,
45  const label nOldCells,
46  const labelList& pointMap,
47  const List<objectMap>& pointsFromPoints,
48  const labelList& faceMap,
49  const List<objectMap>& facesFromPoints,
50  const List<objectMap>& facesFromEdges,
51  const List<objectMap>& facesFromFaces,
52  const labelList& cellMap,
53  const List<objectMap>& cellsFromPoints,
54  const List<objectMap>& cellsFromEdges,
55  const List<objectMap>& cellsFromFaces,
56  const List<objectMap>& cellsFromCells,
57  const labelList& reversePointMap,
58  const labelList& reverseFaceMap,
59  const labelList& reverseCellMap,
60  const labelHashSet& flipFaceFlux,
61  const labelListList& patchPointMap,
62  const labelListList& pointZoneMap,
63  const labelListList& faceZonePointMap,
64  const labelListList& faceZoneFaceMap,
65  const labelListList& cellZoneMap,
66  const pointField& preMotionPoints,
67  const labelList& oldPatchStarts,
68  const labelList& oldPatchNMeshPoints,
69  const autoPtr<scalarField>& oldCellVolumesPtr
70 )
71 :
72  mesh_(mesh),
73  nOldPoints_(nOldPoints),
74  nOldFaces_(nOldFaces),
75  nOldCells_(nOldCells),
76  pointMap_(pointMap),
77  pointsFromPointsMap_(pointsFromPoints),
78  faceMap_(faceMap),
79  facesFromPointsMap_(facesFromPoints),
80  facesFromEdgesMap_(facesFromEdges),
81  facesFromFacesMap_(facesFromFaces),
82  cellMap_(cellMap),
83  cellsFromPointsMap_(cellsFromPoints),
84  cellsFromEdgesMap_(cellsFromEdges),
85  cellsFromFacesMap_(cellsFromFaces),
86  cellsFromCellsMap_(cellsFromCells),
87  reversePointMap_(reversePointMap),
88  reverseFaceMap_(reverseFaceMap),
89  reverseCellMap_(reverseCellMap),
90  flipFaceFlux_(flipFaceFlux),
91  patchPointMap_(patchPointMap),
92  pointZoneMap_(pointZoneMap),
93  faceZonePointMap_(faceZonePointMap),
94  faceZoneFaceMap_(faceZoneFaceMap),
95  cellZoneMap_(cellZoneMap),
96  preMotionPoints_(preMotionPoints),
97  oldPatchSizes_(oldPatchStarts.size()),
98  oldPatchStarts_(oldPatchStarts),
99  oldPatchNMeshPoints_(oldPatchNMeshPoints),
100  oldCellVolumesPtr_(oldCellVolumesPtr)
101 {
102  if (oldPatchStarts_.size())
103  {
104  // Calculate old patch sizes
105  for (label patchi = 0; patchi < oldPatchStarts_.size() - 1; patchi++)
106  {
107  oldPatchSizes_[patchi] =
108  oldPatchStarts_[patchi + 1] - oldPatchStarts_[patchi];
109  }
110 
111  // Set the last one by hand
112  const label lastPatchID = oldPatchStarts_.size() - 1;
113 
114  oldPatchSizes_[lastPatchID] = nOldFaces_ - oldPatchStarts_[lastPatchID];
115 
116  if (polyMesh::debug)
117  {
118  if (min(oldPatchSizes_) < 0)
119  {
121  << abort(FatalError);
122  }
123  }
124  }
125 }
126 
127 
129 (
130  const polyMesh& mesh,
131  const label nOldPoints,
132  const label nOldFaces,
133  const label nOldCells,
134  labelList& pointMap,
135  List<objectMap>& pointsFromPoints,
137  List<objectMap>& facesFromPoints,
138  List<objectMap>& facesFromEdges,
139  List<objectMap>& facesFromFaces,
140  labelList& cellMap,
141  List<objectMap>& cellsFromPoints,
142  List<objectMap>& cellsFromEdges,
143  List<objectMap>& cellsFromFaces,
144  List<objectMap>& cellsFromCells,
145  labelList& reversePointMap,
146  labelList& reverseFaceMap,
147  labelList& reverseCellMap,
148  labelHashSet& flipFaceFlux,
149  labelListList& patchPointMap,
150  labelListList& pointZoneMap,
151  labelListList& faceZonePointMap,
152  labelListList& faceZoneFaceMap,
153  labelListList& cellZoneMap,
154  pointField& preMotionPoints,
155  labelList& oldPatchStarts,
156  labelList& oldPatchNMeshPoints,
157  autoPtr<scalarField>& oldCellVolumesPtr,
158  const bool reuse
159 )
160 :
161  mesh_(mesh),
162  nOldPoints_(nOldPoints),
163  nOldFaces_(nOldFaces),
164  nOldCells_(nOldCells),
165  pointMap_(pointMap, reuse),
166  pointsFromPointsMap_(pointsFromPoints, reuse),
167  faceMap_(faceMap, reuse),
168  facesFromPointsMap_(facesFromPoints, reuse),
169  facesFromEdgesMap_(facesFromEdges, reuse),
170  facesFromFacesMap_(facesFromFaces, reuse),
171  cellMap_(cellMap, reuse),
172  cellsFromPointsMap_(cellsFromPoints, reuse),
173  cellsFromEdgesMap_(cellsFromEdges, reuse),
174  cellsFromFacesMap_(cellsFromFaces, reuse),
175  cellsFromCellsMap_(cellsFromCells, reuse),
176  reversePointMap_(reversePointMap, reuse),
177  reverseFaceMap_(reverseFaceMap, reuse),
178  reverseCellMap_(reverseCellMap, reuse),
179  flipFaceFlux_(flipFaceFlux),
180  patchPointMap_(patchPointMap, reuse),
181  pointZoneMap_(pointZoneMap, reuse),
182  faceZonePointMap_(faceZonePointMap, reuse),
183  faceZoneFaceMap_(faceZoneFaceMap, reuse),
184  cellZoneMap_(cellZoneMap, reuse),
185  preMotionPoints_(preMotionPoints, reuse),
186  oldPatchSizes_(oldPatchStarts.size()),
187  oldPatchStarts_(oldPatchStarts, reuse),
188  oldPatchNMeshPoints_(oldPatchNMeshPoints, reuse),
189  oldCellVolumesPtr_(oldCellVolumesPtr, reuse)
190 {
191  if (oldPatchStarts_.size() > 0)
192  {
193  // Calculate old patch sizes
194  for (label patchi = 0; patchi < oldPatchStarts_.size() - 1; patchi++)
195  {
196  oldPatchSizes_[patchi] =
197  oldPatchStarts_[patchi + 1] - oldPatchStarts_[patchi];
198  }
199 
200  // Set the last one by hand
201  const label lastPatchID = oldPatchStarts_.size() - 1;
202 
203  oldPatchSizes_[lastPatchID] = nOldFaces_ - oldPatchStarts_[lastPatchID];
204 
205  if (polyMesh::debug)
206  {
207  if (min(oldPatchSizes_) < 0)
208  {
210  << "Calculated negative old patch size."
211  << " Error in mapping data"
212  << abort(FatalError);
213  }
214  }
215  }
216 }
217 
218 
219 // ************************************************************************* //
void size(const label)
Override size to be inconsistent with allocated storage.
Definition: ListI.H:164
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: autoPtr.H:51
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:80
polyTopoChangeMap(const polyMesh &mesh)
Construct from mesh only, no topology change.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:306
label patchi
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
errorManip< error > abort(error &err)
Definition: errorManip.H:131
layerAndWeight min(const layerAndWeight &a, const layerAndWeight &b)
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
error FatalError