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

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