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

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