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

enrichedPatchPointPoints.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 
00027 \*---------------------------------------------------------------------------*/
00028 
00029 #include "enrichedPatch.H"
00030 #include "primitiveMesh.H"
00031 #include "DynamicList.H"
00032 
00033 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
00034 
00035 
00036 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
00037 
00038 void Foam::enrichedPatch::calcPointPoints() const
00039 {
00040     // Calculate point-point addressing
00041     if (pointPointsPtr_)
00042     {
00043         FatalErrorIn("void enrichedPatch::calcPointPoints() const")
00044             << "Point-point addressing already calculated."
00045             << abort(FatalError);
00046     }
00047 
00048     // Algorithm:
00049     // Go through all faces and add the previous and next point as the
00050     // neighbour for each point. While inserting points, reject the
00051     // duplicates (as every internal edge will be visited twice).
00052     List<DynamicList<label, primitiveMesh::edgesPerPoint_> >
00053         pp(meshPoints().size());
00054 
00055     const faceList& lf = localFaces();
00056 
00057     register bool found = false;
00058 
00059     forAll (lf, faceI)
00060     {
00061         const face& curFace = lf[faceI];
00062 
00063         forAll (curFace, pointI)
00064         {
00065             DynamicList<label, primitiveMesh::edgesPerPoint_>&
00066                 curPp = pp[curFace[pointI]];
00067 
00068             // Do next label
00069             label next = curFace.nextLabel(pointI);
00070 
00071             found = false;
00072 
00073             forAll (curPp, i)
00074             {
00075                 if (curPp[i] == next)
00076                 {
00077                     found = true;
00078                     break;
00079                 }
00080             }
00081 
00082             if (!found)
00083             {
00084                 curPp.append(next);
00085             }
00086 
00087             // Do previous label
00088             label prev = curFace.prevLabel(pointI);
00089             found = false;
00090 
00091             forAll (curPp, i)
00092             {
00093                 if (curPp[i] == prev)
00094                 {
00095                     found = true;
00096                     break;
00097                 }
00098             }
00099 
00100             if (!found)
00101             {
00102                 curPp.append(prev);
00103             }
00104         }
00105     }
00106 
00107     // Re-pack the list
00108     pointPointsPtr_ = new labelListList(pp.size());
00109     labelListList& ppAddr = *pointPointsPtr_;
00110 
00111     forAll (pp, pointI)
00112     {
00113         ppAddr[pointI].transfer(pp[pointI]);
00114     }
00115 }
00116 
00117 
00118 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd