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

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