BUG: UListIO: byteSize overflowing on really big faceLists
[OpenFOAM-2.0.x.git] / src / OpenFOAM / meshes / primitiveMesh / PrimitivePatch / PrimitivePatchPointAddressing.C
blob5782820c57cc172b8ef555df2cfd66ef290fe91c
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 Description
25      Point addressing on the patch: pointEdges and pointFaces.
27 \*---------------------------------------------------------------------------*/
29 #include "PrimitivePatch.H"
30 #include "SLList.H"
33 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
35 template
37     class Face,
38     template<class> class FaceList,
39     class PointField,
40     class PointType
42 void
43 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
44 calcPointEdges() const
46     if (debug)
47     {
48         Info<< "PrimitivePatch<Face, FaceList, PointField, PointType>::"
49             << "calcPointEdges() : calculating pointEdges"
50             << endl;
51     }
53     if (pointEdgesPtr_)
54     {
55         // it is considered an error to attempt to recalculate
56         // if already allocated
57         FatalErrorIn
58         (
59             "PrimitivePatch<Face, FaceList, PointField, PointType>::"
60             "calcPointEdges()"
61         )   << "pointEdges already calculated"
62             << abort(FatalError);
63     }
65     const edgeList& e = edges();
67     // set up storage for pointEdges
68     List<SLList<label> > pointEdges(meshPoints().size());
70     forAll(e, edgeI)
71     {
72         pointEdges[e[edgeI].start()].append(edgeI);
73         pointEdges[e[edgeI].end()].append(edgeI);
74     }
76     // sort out the list
77     pointEdgesPtr_ = new labelListList(pointEdges.size());
79     labelListList& pe = *pointEdgesPtr_;
81     forAll(pointEdges, pointI)
82     {
83         const SLList<label>& pEdge = pointEdges[pointI];
85         pe[pointI].setSize(pEdge.size());
87         label i = 0;
88         forAllConstIter(SLList<label>, pEdge, iter)
89         {
90             pe[pointI][i++] = iter();
91         }
92     }
94     if (debug)
95     {
96         Info<< "PrimitivePatch<Face, FaceList, PointField, PointType>::"
97             << "calcPointEdges() finished calculating pointEdges"
98             << endl;
99     }
103 template
105     class Face,
106     template<class> class FaceList,
107     class PointField,
108     class PointType
110 void
111 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
112 calcPointFaces() const
114     if (debug)
115     {
116         Info<< "PrimitivePatch<Face, FaceList, PointField, PointType>::"
117             << "calcPointFaces() : calculating pointFaces"
118             << endl;
119     }
121     if (pointFacesPtr_)
122     {
123         // it is considered an error to attempt to recalculate
124         // if already allocated
125         FatalErrorIn
126         (
127             "PrimitivePatch<Face, FaceList, PointField, PointType>::"
128             "calcPointFaces()"
129         )   << "pointFaces already calculated"
130             << abort(FatalError);
131     }
133     const List<Face>& f = localFaces();
135     // set up storage for pointFaces
136     List<SLList<label> > pointFcs(meshPoints().size());
138     forAll(f, faceI)
139     {
140         const Face& curPoints = f[faceI];
142         forAll(curPoints, pointI)
143         {
144             pointFcs[curPoints[pointI]].append(faceI);
145         }
146     }
148     // sort out the list
149     pointFacesPtr_ = new labelListList(pointFcs.size());
151     labelListList& pf = *pointFacesPtr_;
153     forAll(pointFcs, pointI)
154     {
155         pf[pointI].setSize(pointFcs[pointI].size());
157         label i = 0;
158         forAllIter(SLList<label>, pointFcs[pointI], curFacesIter)
159         {
160             pf[pointI][i++] = curFacesIter();
161         }
162     }
164     if (debug)
165     {
166         Info<< "PrimitivePatch<Face, FaceList, PointField, PointType>::"
167             << "calcPointFaces() finished calculating pointFaces"
168             << endl;
169     }
173 // ************************************************************************* //