OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

PrimitivePatchPointAddressing.C

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software; you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM; if not, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 Description
00026      Point addressing on the patch: pointEdges and pointFaces.
00027 
00028 \*---------------------------------------------------------------------------*/
00029 
00030 #include "PrimitivePatch.H"
00031 #include "SLList.H"
00032 
00033 
00034 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
00035 
00036 template
00037 <
00038     class Face,
00039     template<class> class FaceList,
00040     class PointField,
00041     class PointType
00042 >
00043 
00044 void
00045 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
00046 calcPointEdges() const
00047 {
00048     if (debug)
00049     {
00050         Info<< "PrimitivePatch<Face, FaceList, PointField, PointType>::"
00051             << "calcPointEdges() : calculating pointEdges"
00052             << endl;
00053     }
00054 
00055     if (pointEdgesPtr_)
00056     {
00057         // it is considered an error to attempt to recalculate
00058         // if already allocated
00059         FatalErrorIn
00060         (
00061             "PrimitivePatch<Face, FaceList, PointField, PointType>::"
00062             "calcPointEdges()"
00063         )   << "pointEdges already calculated"
00064             << abort(FatalError);
00065     }
00066 
00067     const edgeList& e = edges();
00068 
00069     // set up storage for pointEdges
00070     List<SLList<label> > pointEdges(meshPoints().size());
00071 
00072     forAll (e, edgeI)
00073     {
00074         pointEdges[e[edgeI].start()].append(edgeI);
00075         pointEdges[e[edgeI].end()].append(edgeI);
00076     }
00077 
00078     // sort out the list
00079     pointEdgesPtr_ = new labelListList(pointEdges.size());
00080 
00081     labelListList& pe = *pointEdgesPtr_;
00082 
00083     forAll (pointEdges, pointI)
00084     {
00085         pe[pointI].setSize(pointEdges[pointI].size());
00086 
00087         label i = 0;
00088         for
00089         (
00090             SLList<label>::iterator curEdgesIter = pointEdges[pointI].begin();
00091             curEdgesIter != pointEdges[pointI].end();
00092             ++curEdgesIter, ++i
00093         )
00094         {
00095             pe[pointI][i] = curEdgesIter();
00096         }
00097     }
00098 
00099     if (debug)
00100     {
00101         Info<< "PrimitivePatch<Face, FaceList, PointField, PointType>::"
00102             << "calcPointEdges() finished calculating pointEdges"
00103             << endl;
00104     }
00105 }
00106 
00107 
00108 template
00109 <
00110     class Face,
00111     template<class> class FaceList,
00112     class PointField,
00113     class PointType
00114 >
00115 
00116 void
00117 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
00118 calcPointFaces() const
00119 {
00120     if (debug)
00121     {
00122         Info<< "PrimitivePatch<Face, FaceList, PointField, PointType>::"
00123             << "calcPointFaces() : calculating pointFaces"
00124             << endl;
00125     }
00126 
00127     if (pointFacesPtr_)
00128     {
00129         // it is considered an error to attempt to recalculate
00130         // if already allocated
00131         FatalErrorIn
00132         (
00133             "PrimitivePatch<Face, FaceList, PointField, PointType>::"
00134             "calcPointFaces()"
00135         )   << "pointFaces already calculated"
00136             << abort(FatalError);
00137     }
00138 
00139     const List<Face>& f = localFaces();
00140 
00141     // set up storage for pointFaces
00142     List<SLList<label> > pointFcs(meshPoints().size());
00143 
00144     forAll (f, faceI)
00145     {
00146         const Face& curPoints = f[faceI];
00147 
00148         forAll (curPoints, pointI)
00149         {
00150             pointFcs[curPoints[pointI]].append(faceI);
00151         }
00152     }
00153 
00154     // sort out the list
00155     pointFacesPtr_ = new labelListList(pointFcs.size());
00156 
00157     labelListList& pf = *pointFacesPtr_;
00158 
00159     forAll (pointFcs, pointI)
00160     {
00161         pf[pointI].setSize(pointFcs[pointI].size());
00162 
00163         label i = 0;
00164         for
00165         (
00166             SLList<label>::iterator curFacesIter = pointFcs[pointI].begin();
00167             curFacesIter != pointFcs[pointI].end();
00168             ++curFacesIter, ++i
00169         )
00170         {
00171             pf[pointI][i] = curFacesIter();
00172         }
00173     }
00174 
00175     if (debug)
00176     {
00177         Info<< "PrimitivePatch<Face, FaceList, PointField, PointType>::"
00178             << "calcPointFaces() finished calculating pointFaces"
00179             << endl;
00180     }
00181 }
00182 
00183 
00184 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd