BUG: UListIO: byteSize overflowing on really big faceLists
[OpenFOAM-2.0.x.git] / src / OpenFOAM / meshes / primitiveMesh / PrimitivePatch / PrimitivePatchLocalPointOrder.C
blob852262c32bd98decf28362c82b8726bbf8ed6fd7
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      Orders the local points on the patch for most efficient search
27 \*---------------------------------------------------------------------------*/
29 #include "SLList.H"
30 #include "boolList.H"
32 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
34 template
36     class Face,
37     template<class> class FaceList,
38     class PointField,
39     class PointType
41 void
42 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
43 calcLocalPointOrder() const
45     // Note: Cannot use bandCompressing as point-point addressing does
46     // not exist and is not considered generally useful.
47     //
49     if (debug)
50     {
51         Pout<< "PrimitivePatch<Face, FaceList, PointField, PointType>::"
52             << "calcLocalPointOrder() : "
53             << "calculating local point order"
54             << endl;
55     }
57     if (localPointOrderPtr_)
58     {
59         // it is considered an error to attempt to recalculate
60         // if already allocated
61         FatalErrorIn
62         (
63             "PrimitivePatch<Face, FaceList, PointField, PointType>::"
64             "calcLocalPointOrder()"
65         )   << "local point order already calculated"
66             << abort(FatalError);
67     }
69     const List<Face>& lf = localFaces();
71     const labelListList& ff = faceFaces();
73     boolList visitedFace(lf.size(), false);
75     localPointOrderPtr_ = new labelList(meshPoints().size(), -1);
77     labelList& pointOrder = *localPointOrderPtr_;
79     boolList visitedPoint(pointOrder.size(), false);
81     label nPoints = 0;
83     forAll(lf, faceI)
84     {
85         if (!visitedFace[faceI])
86         {
87             SLList<label> faceOrder(faceI);
89             do
90             {
91                 const label curFace = faceOrder.first();
93                 faceOrder.removeHead();
95                 if (!visitedFace[curFace])
96                 {
97                     visitedFace[curFace] = true;
99                     const labelList& curPoints = lf[curFace];
101                     // mark points
102                     forAll(curPoints, pointI)
103                     {
104                         if (!visitedPoint[curPoints[pointI]])
105                         {
106                             visitedPoint[curPoints[pointI]] = true;
108                             pointOrder[nPoints] = curPoints[pointI];
110                             nPoints++;
111                         }
112                     }
114                     // add face neighbours to the list
115                     const labelList& nbrs = ff[curFace];
117                     forAll(nbrs, nbrI)
118                     {
119                         if (!visitedFace[nbrs[nbrI]])
120                         {
121                             faceOrder.append(nbrs[nbrI]);
122                         }
123                     }
124                 }
125             } while (faceOrder.size());
126         }
127     }
129     if (debug)
130     {
131         Pout<< "PrimitivePatch<Face, FaceList, PointField, PointType>::"
132             << "calcLocalPointOrder() "
133             << "finished calculating local point order"
134             << endl;
135     }
139 // ************************************************************************* //