initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / OpenFOAM / meshes / primitiveMesh / PrimitivePatch / PrimitivePatchPointAddressing.C
blob7ac3612286753872aabb2ae35b9f41180a7cea65
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
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 the
13     Free Software Foundation; either version 2 of the License, or (at your
14     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, write to the Free Software Foundation,
23     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 Description
26      Point addressing on the patch: pointEdges and pointFaces.
28 \*---------------------------------------------------------------------------*/
30 #include "PrimitivePatch.H"
31 #include "SLList.H"
34 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
36 template
38     class Face,
39     template<class> class FaceList,
40     class PointField,
41     class PointType
44 void
45 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
46 calcPointEdges() const
48     if (debug)
49     {
50         Info<< "PrimitivePatch<Face, FaceList, PointField, PointType>::"
51             << "calcPointEdges() : calculating pointEdges"
52             << endl;
53     }
55     if (pointEdgesPtr_)
56     {
57         // it is considered an error to attempt to recalculate
58         // if already allocated
59         FatalErrorIn
60         (
61             "PrimitivePatch<Face, FaceList, PointField, PointType>::"
62             "calcPointEdges()"
63         )   << "pointEdges already calculated"
64             << abort(FatalError);
65     }
67     const edgeList& e = edges();
69     // set up storage for pointEdges
70     List<SLList<label> > pointEdges(meshPoints().size());
72     forAll (e, edgeI)
73     {
74         pointEdges[e[edgeI].start()].append(edgeI);
75         pointEdges[e[edgeI].end()].append(edgeI);
76     }
78     // sort out the list
79     pointEdgesPtr_ = new labelListList(pointEdges.size());
81     labelListList& pe = *pointEdgesPtr_;
83     forAll (pointEdges, pointI)
84     {
85         pe[pointI].setSize(pointEdges[pointI].size());
87         label i = 0;
88         for
89         (
90             SLList<label>::iterator curEdgesIter = pointEdges[pointI].begin();
91             curEdgesIter != pointEdges[pointI].end();
92             ++curEdgesIter, ++i
93         )
94         {
95             pe[pointI][i] = curEdgesIter();
96         }
97     }
99     if (debug)
100     {
101         Info<< "PrimitivePatch<Face, FaceList, PointField, PointType>::"
102             << "calcPointEdges() finished calculating pointEdges"
103             << endl;
104     }
108 template
110     class Face,
111     template<class> class FaceList,
112     class PointField,
113     class PointType
116 void
117 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
118 calcPointFaces() const
120     if (debug)
121     {
122         Info<< "PrimitivePatch<Face, FaceList, PointField, PointType>::"
123             << "calcPointFaces() : calculating pointFaces"
124             << endl;
125     }
127     if (pointFacesPtr_)
128     {
129         // it is considered an error to attempt to recalculate
130         // if already allocated
131         FatalErrorIn
132         (
133             "PrimitivePatch<Face, FaceList, PointField, PointType>::"
134             "calcPointFaces()"
135         )   << "pointFaces already calculated"
136             << abort(FatalError);
137     }
139     const List<Face>& f = localFaces();
141     // set up storage for pointFaces
142     List<SLList<label> > pointFcs(meshPoints().size());
144     forAll (f, faceI)
145     {
146         const Face& curPoints = f[faceI];
148         forAll (curPoints, pointI)
149         {
150             pointFcs[curPoints[pointI]].append(faceI);
151         }
152     }
154     // sort out the list
155     pointFacesPtr_ = new labelListList(pointFcs.size());
157     labelListList& pf = *pointFacesPtr_;
159     forAll (pointFcs, pointI)
160     {
161         pf[pointI].setSize(pointFcs[pointI].size());
163         label i = 0;
164         for
165         (
166             SLList<label>::iterator curFacesIter = pointFcs[pointI].begin();
167             curFacesIter != pointFcs[pointI].end();
168             ++curFacesIter, ++i
169         )
170         {
171             pf[pointI][i] = curFacesIter();
172         }
173     }
175     if (debug)
176     {
177         Info<< "PrimitivePatch<Face, FaceList, PointField, PointType>::"
178             << "calcPointFaces() finished calculating pointFaces"
179             << endl;
180     }
184 // ************************************************************************* //