BUG: UListIO: byteSize overflowing on really big faceLists
[OpenFOAM-2.0.x.git] / src / OpenFOAM / meshes / primitiveMesh / PrimitivePatch / PrimitivePatch.C
blobc69fed17737a5ca4be1aac9030f66bc6b8e86f00
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 \*---------------------------------------------------------------------------*/
26 #include "Map.H"
28 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
30 template
32     class Face,
33     template<class> class FaceList,
34     class PointField,
35     class PointType
37 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
38 PrimitivePatch
40     const FaceList<Face>& faces,
41     const Field<PointType>& points
44     FaceList<Face>(faces),
45     points_(points),
46     edgesPtr_(NULL),
47     nInternalEdges_(-1),
48     boundaryPointsPtr_(NULL),
49     faceFacesPtr_(NULL),
50     edgeFacesPtr_(NULL),
51     faceEdgesPtr_(NULL),
52     pointEdgesPtr_(NULL),
53     pointFacesPtr_(NULL),
54     localFacesPtr_(NULL),
55     meshPointsPtr_(NULL),
56     meshPointMapPtr_(NULL),
57     edgeLoopsPtr_(NULL),
58     localPointsPtr_(NULL),
59     localPointOrderPtr_(NULL),
60     faceCentresPtr_(NULL),
61     faceNormalsPtr_(NULL),
62     pointNormalsPtr_(NULL)
66 template
68     class Face,
69     template<class> class FaceList,
70     class PointField,
71     class PointType
73 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
74 PrimitivePatch
76     FaceList<Face>& faces,
77     Field<PointType>& points,
78     const bool reUse
81     FaceList<Face>(faces, reUse),
82     points_(points, reUse),
83     edgesPtr_(NULL),
84     nInternalEdges_(-1),
85     boundaryPointsPtr_(NULL),
86     faceFacesPtr_(NULL),
87     edgeFacesPtr_(NULL),
88     faceEdgesPtr_(NULL),
89     pointEdgesPtr_(NULL),
90     pointFacesPtr_(NULL),
91     localFacesPtr_(NULL),
92     meshPointsPtr_(NULL),
93     meshPointMapPtr_(NULL),
94     edgeLoopsPtr_(NULL),
95     localPointsPtr_(NULL),
96     localPointOrderPtr_(NULL),
97     faceCentresPtr_(NULL),
98     faceNormalsPtr_(NULL),
99     pointNormalsPtr_(NULL)
103 template
105     class Face,
106     template<class> class FaceList,
107     class PointField,
108     class PointType
110 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
111 PrimitivePatch
113     const PrimitivePatch<Face, FaceList, PointField, PointType>& pp
116     PrimitivePatchName(),
117     FaceList<Face>(pp),
118     points_(pp.points_),
119     edgesPtr_(NULL),
120     nInternalEdges_(-1),
121     boundaryPointsPtr_(NULL),
122     faceFacesPtr_(NULL),
123     edgeFacesPtr_(NULL),
124     faceEdgesPtr_(NULL),
125     pointEdgesPtr_(NULL),
126     pointFacesPtr_(NULL),
127     localFacesPtr_(NULL),
128     meshPointsPtr_(NULL),
129     meshPointMapPtr_(NULL),
130     edgeLoopsPtr_(NULL),
131     localPointsPtr_(NULL),
132     localPointOrderPtr_(NULL),
133     faceCentresPtr_(NULL),
134     faceNormalsPtr_(NULL),
135     pointNormalsPtr_(NULL)
139 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
141 template
143     class Face,
144     template<class> class FaceList,
145     class PointField,
146     class PointType
148 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
149 ~PrimitivePatch()
151     clearOut();
155 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
157 template
159     class Face,
160     template<class> class FaceList,
161     class PointField,
162     class PointType
164 void
165 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
166 movePoints
168     const Field<PointType>&
171     if (debug)
172     {
173         Pout<< "PrimitivePatch<Face, FaceList, PointField, PointType>::"
174             << "movePoints() : "
175             << "recalculating PrimitivePatch geometry following mesh motion"
176             << endl;
177     }
179     clearGeom();
183 template
185     class Face,
186     template<class> class FaceList,
187     class PointField,
188     class PointType
190 const Foam::edgeList&
191 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
192 edges() const
194     if (!edgesPtr_)
195     {
196         calcAddressing();
197     }
199     return *edgesPtr_;
203 template
205     class Face,
206     template<class> class FaceList,
207     class PointField,
208     class PointType
210 Foam::label
211 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
212 nInternalEdges() const
214     if (!edgesPtr_)
215     {
216         calcAddressing();
217     }
219     return nInternalEdges_;
223 template
225     class Face,
226     template<class> class FaceList,
227     class PointField,
228     class PointType
230 const Foam::labelList&
231 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
232 boundaryPoints() const
234     if (!boundaryPointsPtr_)
235     {
236         calcBdryPoints();
237     }
239     return *boundaryPointsPtr_;
243 template
245     class Face,
246     template<class> class FaceList,
247     class PointField,
248     class PointType
250 const Foam::labelListList&
251 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
252 faceFaces() const
254     if (!faceFacesPtr_)
255     {
256         calcAddressing();
257     }
259     return *faceFacesPtr_;
263 template
265     class Face,
266     template<class> class FaceList,
267     class PointField,
268     class PointType
270 const Foam::labelListList&
271 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
272 edgeFaces() const
274     if (!edgeFacesPtr_)
275     {
276         calcAddressing();
277     }
279     return *edgeFacesPtr_;
283 template
285     class Face,
286     template<class> class FaceList,
287     class PointField,
288     class PointType
290 const Foam::labelListList&
291 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
292 faceEdges() const
294     if (!faceEdgesPtr_)
295     {
296         calcAddressing();
297     }
299     return *faceEdgesPtr_;
303 template
305     class Face,
306     template<class> class FaceList,
307     class PointField,
308     class PointType
310 const Foam::labelListList&
311 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
312 pointEdges() const
314     if (!pointEdgesPtr_)
315     {
316         calcPointEdges();
317     }
319     return *pointEdgesPtr_;
323 template
325     class Face,
326     template<class> class FaceList,
327     class PointField,
328     class PointType
330 const Foam::labelListList&
331 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
332 pointFaces() const
334     if (!pointFacesPtr_)
335     {
336         calcPointFaces();
337     }
339     return *pointFacesPtr_;
343 template
345     class Face,
346     template<class> class FaceList,
347     class PointField,
348     class PointType
350 const Foam::List<Face>&
351 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
352 localFaces() const
354     if (!localFacesPtr_)
355     {
356         calcMeshData();
357     }
359     return *localFacesPtr_;
363 template
365     class Face,
366     template<class> class FaceList,
367     class PointField,
368     class PointType
370 const Foam::labelList&
371 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
372 meshPoints() const
374     if (!meshPointsPtr_)
375     {
376         calcMeshData();
377     }
379     return *meshPointsPtr_;
383 template
385     class Face,
386     template<class> class FaceList,
387     class PointField,
388     class PointType
390 const Foam::Map<Foam::label>&
391 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
392 meshPointMap() const
394     if (!meshPointMapPtr_)
395     {
396         calcMeshPointMap();
397     }
399     return *meshPointMapPtr_;
403 template
405     class Face,
406     template<class> class FaceList,
407     class PointField,
408     class PointType
410 const Foam::Field<PointType>&
411 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
412 localPoints() const
414     if (!localPointsPtr_)
415     {
416         calcLocalPoints();
417     }
419     return *localPointsPtr_;
423 template
425     class Face,
426     template<class> class FaceList,
427     class PointField,
428     class PointType
430 const Foam::labelList&
431 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
432 localPointOrder() const
434     if (!localPointOrderPtr_)
435     {
436         calcLocalPointOrder();
437     }
439     return *localPointOrderPtr_;
443 template
445     class Face,
446     template<class> class FaceList,
447     class PointField,
448     class PointType
450 Foam::label
451 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
452 whichPoint
454     const label gp
455 ) const
457     Map<label>::const_iterator fnd = meshPointMap().find(gp);
459     if (fnd != meshPointMap().end())
460     {
461         return fnd();
462     }
463     else
464     {
465         // Not found
466         return -1;
467     }
471 template
473     class Face,
474     template<class> class FaceList,
475     class PointField,
476     class PointType
478 const Foam::Field<PointType>&
479 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
480 faceCentres() const
482     if (!faceCentresPtr_)
483     {
484         calcFaceCentres();
485     }
487     return *faceCentresPtr_;
491 template
493     class Face,
494     template<class> class FaceList,
495     class PointField,
496     class PointType
498 const Foam::Field<PointType>&
499 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
500 faceNormals() const
502     if (!faceNormalsPtr_)
503     {
504         calcFaceNormals();
505     }
507     return *faceNormalsPtr_;
511 template
513     class Face,
514     template<class> class FaceList,
515     class PointField,
516     class PointType
518 const Foam::Field<PointType>&
519 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
520 pointNormals() const
522     if (!pointNormalsPtr_)
523     {
524         calcPointNormals();
525     }
527     return *pointNormalsPtr_;
531 // * * * * * * * * * * * * * * * Member Operators  * * * * * * * * * * * * * //
533 template
535     class Face,
536     template<class> class FaceList,
537     class PointField,
538     class PointType
540 void
541 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
542 operator=
544     const PrimitivePatch<Face, FaceList, PointField, PointType>& pp
547     clearOut();
549     FaceList<Face>::operator=(pp);
553 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
555 #include "PrimitivePatchAddressing.C"
556 #include "PrimitivePatchEdgeLoops.C"
557 #include "PrimitivePatchClear.C"
558 #include "PrimitivePatchBdryPoints.C"
559 #include "PrimitivePatchLocalPointOrder.C"
560 #include "PrimitivePatchMeshData.C"
561 #include "PrimitivePatchMeshEdges.C"
562 #include "PrimitivePatchPointAddressing.C"
563 #include "PrimitivePatchProjectPoints.C"
564 #include "PrimitivePatchCheck.C"
566 // ************************************************************************* //