FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

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-2010 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
00013     the Free Software Foundation, either version 3 of the License, or
00014     (at your 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, see <http://www.gnu.org/licenses/>.
00023 
00024 Description
00025      Point addressing on the patch: pointEdges and pointFaces.
00026 
00027 \*---------------------------------------------------------------------------*/
00028 
00029 #include "PrimitivePatch_.H"
00030 #include <OpenFOAM/SLList.H>
00031 
00032 
00033 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
00034 
00035 template
00036 <
00037     class Face,
00038     template<class> class FaceList,
00039     class PointField,
00040     class PointType
00041 >
00042 void
00043 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
00044 calcPointEdges() const
00045 {
00046     if (debug)
00047     {
00048         Info<< "PrimitivePatch<Face, FaceList, PointField, PointType>::"
00049             << "calcPointEdges() : calculating pointEdges"
00050             << endl;
00051     }
00052 
00053     if (pointEdgesPtr_)
00054     {
00055         // it is considered an error to attempt to recalculate
00056         // if already allocated
00057         FatalErrorIn
00058         (
00059             "PrimitivePatch<Face, FaceList, PointField, PointType>::"
00060             "calcPointEdges()"
00061         )   << "pointEdges already calculated"
00062             << abort(FatalError);
00063     }
00064 
00065     const edgeList& e = edges();
00066 
00067     // set up storage for pointEdges
00068     List<SLList<label> > pointEdges(meshPoints().size());
00069 
00070     forAll (e, edgeI)
00071     {
00072         pointEdges[e[edgeI].start()].append(edgeI);
00073         pointEdges[e[edgeI].end()].append(edgeI);
00074     }
00075 
00076     // sort out the list
00077     pointEdgesPtr_ = new labelListList(pointEdges.size());
00078 
00079     labelListList& pe = *pointEdgesPtr_;
00080 
00081     forAll (pointEdges, pointI)
00082     {
00083         pe[pointI].setSize(pointEdges[pointI].size());
00084 
00085         label i = 0;
00086         for
00087         (
00088             SLList<label>::iterator curEdgesIter = pointEdges[pointI].begin();
00089             curEdgesIter != pointEdges[pointI].end();
00090             ++curEdgesIter, ++i
00091         )
00092         {
00093             pe[pointI][i] = curEdgesIter();
00094         }
00095     }
00096 
00097     if (debug)
00098     {
00099         Info<< "PrimitivePatch<Face, FaceList, PointField, PointType>::"
00100             << "calcPointEdges() finished calculating pointEdges"
00101             << endl;
00102     }
00103 }
00104 
00105 
00106 template
00107 <
00108     class Face,
00109     template<class> class FaceList,
00110     class PointField,
00111     class PointType
00112 >
00113 void
00114 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
00115 calcPointFaces() const
00116 {
00117     if (debug)
00118     {
00119         Info<< "PrimitivePatch<Face, FaceList, PointField, PointType>::"
00120             << "calcPointFaces() : calculating pointFaces"
00121             << endl;
00122     }
00123 
00124     if (pointFacesPtr_)
00125     {
00126         // it is considered an error to attempt to recalculate
00127         // if already allocated
00128         FatalErrorIn
00129         (
00130             "PrimitivePatch<Face, FaceList, PointField, PointType>::"
00131             "calcPointFaces()"
00132         )   << "pointFaces already calculated"
00133             << abort(FatalError);
00134     }
00135 
00136     const List<Face>& f = localFaces();
00137 
00138     // set up storage for pointFaces
00139     List<SLList<label> > pointFcs(meshPoints().size());
00140 
00141     forAll (f, faceI)
00142     {
00143         const Face& curPoints = f[faceI];
00144 
00145         forAll (curPoints, pointI)
00146         {
00147             pointFcs[curPoints[pointI]].append(faceI);
00148         }
00149     }
00150 
00151     // sort out the list
00152     pointFacesPtr_ = new labelListList(pointFcs.size());
00153 
00154     labelListList& pf = *pointFacesPtr_;
00155 
00156     forAll (pointFcs, pointI)
00157     {
00158         pf[pointI].setSize(pointFcs[pointI].size());
00159 
00160         label i = 0;
00161         for
00162         (
00163             SLList<label>::iterator curFacesIter = pointFcs[pointI].begin();
00164             curFacesIter != pointFcs[pointI].end();
00165             ++curFacesIter, ++i
00166         )
00167         {
00168             pf[pointI][i] = curFacesIter();
00169         }
00170     }
00171 
00172     if (debug)
00173     {
00174         Info<< "PrimitivePatch<Face, FaceList, PointField, PointType>::"
00175             << "calcPointFaces() finished calculating pointFaces"
00176             << endl;
00177     }
00178 }
00179 
00180 
00181 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines