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

PrimitivePatchMeshEdges.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 \*---------------------------------------------------------------------------*/
00025 
00026 #include "PrimitivePatch_.H"
00027 
00028 
00029 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
00030 
00031 template
00032 <
00033     class Face,
00034     template<class> class FaceList,
00035     class PointField,
00036     class PointType
00037 >
00038 Foam::labelList
00039 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
00040 meshEdges
00041 (
00042     const edgeList& allEdges,
00043     const labelListList& cellEdges,
00044     const labelList& faceCells
00045 ) const
00046 {
00047     if (debug)
00048     {
00049         Info<< "labelList PrimitivePatch<Face, FaceList, PointField, PointType>"
00050             << "::meshEdges() : "
00051             << "calculating labels of patch edges in mesh edge list"
00052             << endl;
00053     }
00054 
00055     // get reference to the list of edges on the patch
00056     const edgeList& PatchEdges = edges();
00057 
00058     const labelListList& EdgeFaces = edgeFaces();
00059 
00060     // create the storage
00061     labelList meshEdges(PatchEdges.size());
00062 
00063     register bool found = false;
00064 
00065     // get reference to the points on the patch
00066     const labelList& pp = meshPoints();
00067 
00068     // WARNING: Remember that local edges address into local point list;
00069     // local-to-global point label translation is necessary
00070     forAll (PatchEdges, edgeI)
00071     {
00072         const edge curEdge
00073             (pp[PatchEdges[edgeI].start()], pp[PatchEdges[edgeI].end()]);
00074 
00075         found = false;
00076 
00077         // get the patch faces sharing the edge
00078         const labelList& curFaces = EdgeFaces[edgeI];
00079 
00080         forAll (curFaces, faceI)
00081         {
00082             // get the cell next to the face
00083             label curCell = faceCells[curFaces[faceI]];
00084 
00085             // get reference to edges on the cell
00086             const labelList& ce = cellEdges[curCell];
00087 
00088             forAll (ce, cellEdgeI)
00089             {
00090                 if (allEdges[ce[cellEdgeI]] == curEdge)
00091                 {
00092                     found = true;
00093 
00094                     meshEdges[edgeI] = ce[cellEdgeI];
00095 
00096                     break;
00097                 }
00098             }
00099 
00100             if (found) break;
00101         }
00102     }
00103 
00104     return meshEdges;
00105 }
00106 
00107 
00108 template
00109 <
00110     class Face,
00111     template<class> class FaceList,
00112     class PointField,
00113     class PointType
00114 >
00115 Foam::labelList
00116 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
00117 meshEdges
00118 (
00119     const edgeList& allEdges,
00120     const labelListList& pointEdges
00121 ) const
00122 {
00123     if (debug)
00124     {
00125         Info<< "labelList PrimitivePatch<Face, FaceList, PointField, PointType>"
00126             << "::meshEdges() : "
00127             << "calculating labels of patch edges in mesh edge list"
00128             << endl;
00129     }
00130 
00131     // get reference to the list of edges on the patch
00132     const edgeList& PatchEdges = edges();
00133 
00134     // create the storage
00135     labelList meshEdges(PatchEdges.size());
00136 
00137     // get reference to the points on the patch
00138     const labelList& pp = meshPoints();
00139 
00140     // WARNING: Remember that local edges address into local point list;
00141     // local-to-global point label translation is necessary
00142     forAll (PatchEdges, edgeI)
00143     {
00144         const label globalPointI = pp[PatchEdges[edgeI].start()];
00145         const edge curEdge(globalPointI, pp[PatchEdges[edgeI].end()]);
00146 
00147         const labelList& pe = pointEdges[globalPointI];
00148 
00149         forAll (pe, i)
00150         {
00151             if (allEdges[pe[i]] == curEdge)
00152             {
00153                 meshEdges[edgeI] = pe[i];
00154                 break;
00155             }
00156         }
00157     }
00158 
00159     return meshEdges;
00160 }
00161 
00162 
00163 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00164 
00165 template
00166 <
00167     class Face,
00168     template<class> class FaceList,
00169     class PointField,
00170     class PointType
00171 >
00172 Foam::label
00173 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
00174 whichEdge
00175 (
00176     const edge& e
00177 ) const
00178 {
00179     // Get pointEdges from the starting point and search all the candidates
00180     const edgeList& Edges = edges();
00181 
00182     if (e.start() > -1 && e.start() < nPoints())
00183     {
00184         const labelList& pe = pointEdges()[e.start()];
00185 
00186         forAll (pe, peI)
00187         {
00188             if (e == Edges[pe[peI]])
00189             {
00190                 return pe[peI];
00191             }
00192         }
00193     }
00194 
00195     // Edge not found.  Return -1
00196     return -1;
00197 }
00198 
00199 
00200 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines