Added faceCentres member function.
[OpenFOAM-1.6.x.git] / src / OpenFOAM / meshes / primitiveMesh / PrimitivePatch / PrimitivePatchPointAddressing.C
blobe28cfc4d2383cf83288ee2ce3fa1d781478e3de8
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
43 void
44 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
45 calcPointEdges() const
47     if (debug)
48     {
49         Info<< "PrimitivePatch<Face, FaceList, PointField, PointType>::"
50             << "calcPointEdges() : calculating pointEdges"
51             << endl;
52     }
54     if (pointEdgesPtr_)
55     {
56         // it is considered an error to attempt to recalculate
57         // if already allocated
58         FatalErrorIn
59         (
60             "PrimitivePatch<Face, FaceList, PointField, PointType>::"
61             "calcPointEdges()"
62         )   << "pointEdges already calculated"
63             << abort(FatalError);
64     }
66     const edgeList& e = edges();
68     // set up storage for pointEdges
69     List<SLList<label> > pointEdges(meshPoints().size());
71     forAll (e, edgeI)
72     {
73         pointEdges[e[edgeI].start()].append(edgeI);
74         pointEdges[e[edgeI].end()].append(edgeI);
75     }
77     // sort out the list
78     pointEdgesPtr_ = new labelListList(pointEdges.size());
80     labelListList& pe = *pointEdgesPtr_;
82     forAll (pointEdges, pointI)
83     {
84         pe[pointI].setSize(pointEdges[pointI].size());
86         label i = 0;
87         for
88         (
89             SLList<label>::iterator curEdgesIter = pointEdges[pointI].begin();
90             curEdgesIter != pointEdges[pointI].end();
91             ++curEdgesIter, ++i
92         )
93         {
94             pe[pointI][i] = curEdgesIter();
95         }
96     }
98     if (debug)
99     {
100         Info<< "PrimitivePatch<Face, FaceList, PointField, PointType>::"
101             << "calcPointEdges() finished calculating pointEdges"
102             << endl;
103     }
107 template
109     class Face,
110     template<class> class FaceList,
111     class PointField,
112     class PointType
114 void
115 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
116 calcPointFaces() const
118     if (debug)
119     {
120         Info<< "PrimitivePatch<Face, FaceList, PointField, PointType>::"
121             << "calcPointFaces() : calculating pointFaces"
122             << endl;
123     }
125     if (pointFacesPtr_)
126     {
127         // it is considered an error to attempt to recalculate
128         // if already allocated
129         FatalErrorIn
130         (
131             "PrimitivePatch<Face, FaceList, PointField, PointType>::"
132             "calcPointFaces()"
133         )   << "pointFaces already calculated"
134             << abort(FatalError);
135     }
137     const List<Face>& f = localFaces();
139     // set up storage for pointFaces
140     List<SLList<label> > pointFcs(meshPoints().size());
142     forAll (f, faceI)
143     {
144         const Face& curPoints = f[faceI];
146         forAll (curPoints, pointI)
147         {
148             pointFcs[curPoints[pointI]].append(faceI);
149         }
150     }
152     // sort out the list
153     pointFacesPtr_ = new labelListList(pointFcs.size());
155     labelListList& pf = *pointFacesPtr_;
157     forAll (pointFcs, pointI)
158     {
159         pf[pointI].setSize(pointFcs[pointI].size());
161         label i = 0;
162         for
163         (
164             SLList<label>::iterator curFacesIter = pointFcs[pointI].begin();
165             curFacesIter != pointFcs[pointI].end();
166             ++curFacesIter, ++i
167         )
168         {
169             pf[pointI][i] = curFacesIter();
170         }
171     }
173     if (debug)
174     {
175         Info<< "PrimitivePatch<Face, FaceList, PointField, PointType>::"
176             << "calcPointFaces() finished calculating pointFaces"
177             << endl;
178     }
182 // ************************************************************************* //