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

PrimitivePatchLocalPointOrder.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      Orders the local points on the patch for most efficient search
00026 
00027 \*---------------------------------------------------------------------------*/
00028 
00029 #include <OpenFOAM/SLList.H>
00030 #include <OpenFOAM/boolList.H>
00031 
00032 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
00033 
00034 template
00035 <
00036     class Face,
00037     template<class> class FaceList,
00038     class PointField,
00039     class PointType
00040 >
00041 void
00042 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
00043 calcLocalPointOrder() const
00044 {
00045     // Note: Cannot use bandCompressing as point-point addressing does
00046     // not exist and is not considered generally useful.
00047     //
00048 
00049     if (debug)
00050     {
00051         Pout<< "PrimitivePatch<Face, FaceList, PointField, PointType>::"
00052             << "calcLocalPointOrder() : "
00053             << "calculating local point order"
00054             << endl;
00055     }
00056 
00057     if (localPointOrderPtr_)
00058     {
00059         // it is considered an error to attempt to recalculate
00060         // if already allocated
00061         FatalErrorIn
00062         (
00063             "PrimitivePatch<Face, FaceList, PointField, PointType>::"
00064             "calcLocalPointOrder()"
00065         )   << "local point order already calculated"
00066             << abort(FatalError);
00067     }
00068 
00069     const List<Face>& lf = localFaces();
00070 
00071     const labelListList& ff = faceFaces();
00072 
00073     boolList visitedFace(lf.size(), false);
00074 
00075     localPointOrderPtr_ = new labelList(meshPoints().size(), -1);
00076 
00077     labelList& pointOrder = *localPointOrderPtr_;
00078 
00079     boolList visitedPoint(pointOrder.size(), false);
00080 
00081     label nPoints = 0;
00082 
00083     forAll (lf, faceI)
00084     {
00085         if (!visitedFace[faceI])
00086         {
00087             SLList<label> faceOrder(faceI);
00088 
00089             do
00090             {
00091                 const label curFace = faceOrder.first();
00092 
00093                 faceOrder.removeHead();
00094 
00095                 if (!visitedFace[curFace])
00096                 {
00097                     visitedFace[curFace] = true;
00098 
00099                     const labelList& curPoints = lf[curFace];
00100 
00101                     // mark points
00102                     forAll (curPoints, pointI)
00103                     {
00104                         if (!visitedPoint[curPoints[pointI]])
00105                         {
00106                             visitedPoint[curPoints[pointI]] = true;
00107 
00108                             pointOrder[nPoints] = curPoints[pointI];
00109 
00110                             nPoints++;
00111                         }
00112                     }
00113 
00114                     // add face neighbours to the list
00115                     const labelList& nbrs = ff[curFace];
00116 
00117                     forAll (nbrs, nbrI)
00118                     {
00119                         if (!visitedFace[nbrs[nbrI]])
00120                         {
00121                             faceOrder.append(nbrs[nbrI]);
00122                         }
00123                     }
00124                 }
00125             } while (faceOrder.size());
00126         }
00127     }
00128 
00129     if (debug)
00130     {
00131         Pout<< "PrimitivePatch<Face, FaceList, PointField, PointType>::"
00132             << "calcLocalPointOrder() "
00133             << "finished calculating local point order"
00134             << endl;
00135     }
00136 }
00137 
00138 
00139 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines