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

primitiveMeshEdgeFaces.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 "primitiveMesh.H"
00027 #include <OpenFOAM/ListOps.H>
00028 
00029 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00030 
00031 const Foam::labelListList& Foam::primitiveMesh::edgeFaces() const
00032 {
00033     if (!efPtr_)
00034     {
00035         if (debug)
00036         {
00037             Pout<< "primitiveMesh::edgeFaces() : calculating edgeFaces" << endl;
00038 
00039             if (debug == -1)
00040             {
00041                 // For checking calls:abort so we can quickly hunt down
00042                 // origin of call
00043                 FatalErrorIn("primitiveMesh::edgeFaces()")
00044                     << abort(FatalError);
00045             }
00046         }
00047 
00048         // Invert faceEdges
00049         efPtr_ = new labelListList(nEdges());
00050         invertManyToMany(nEdges(), faceEdges(), *efPtr_);
00051     }
00052 
00053     return *efPtr_;
00054 }
00055 
00056 
00057 const Foam::labelList& Foam::primitiveMesh::edgeFaces
00058 (
00059     const label edgeI,
00060     DynamicList<label>& storage
00061 ) const
00062 {
00063     if (hasEdgeFaces())
00064     {
00065         return edgeFaces()[edgeI];
00066     }
00067     else
00068     {
00069         // Use the fact that pointEdges are sorted in incrementing edge order
00070         const edge& e = edges()[edgeI];
00071         const labelList& pFaces0 = pointFaces()[e[0]];
00072         const labelList& pFaces1 = pointFaces()[e[1]];
00073 
00074         label i0 = 0;
00075         label i1 = 0;
00076 
00077         storage.clear();
00078 
00079         while (i0 < pFaces0.size() && i1 < pFaces1.size())
00080         {
00081             if (pFaces0[i0] < pFaces1[i1])
00082             {
00083                 ++i0;
00084             }
00085             else if (pFaces0[i0] > pFaces1[i1])
00086             {
00087                 ++i1;
00088             }
00089             else
00090             {
00091                 // Equal. Append.
00092                 storage.append(pFaces0[i0]);
00093                 ++i0;
00094                 ++i1;
00095             }
00096         }
00097 
00098         return storage;
00099     }
00100 }
00101 
00102 
00103 const Foam::labelList& Foam::primitiveMesh::edgeFaces(const label edgeI) const
00104 {
00105     return edgeFaces(edgeI, labels_);
00106 }
00107 
00108 
00109 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines