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

primitiveMeshEdgeCells.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 
00031 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00032 
00033 const Foam::labelListList& Foam::primitiveMesh::edgeCells() const
00034 {
00035     if (!ecPtr_)
00036     {
00037         if (debug)
00038         {
00039             Pout<< "primitiveMesh::edgeCells() : calculating edgeCells" << endl;
00040 
00041             if (debug == -1)
00042             {
00043                 // For checking calls:abort so we can quickly hunt down
00044                 // origin of call
00045                 FatalErrorIn("primitiveMesh::edgeCells()")
00046                     << abort(FatalError);
00047             }
00048         }
00049         // Invert cellEdges
00050         ecPtr_ = new labelListList(nEdges());
00051         invertManyToMany(nEdges(), cellEdges(), *ecPtr_);
00052     }
00053 
00054     return *ecPtr_;
00055 }
00056 
00057 
00058 const Foam::labelList& Foam::primitiveMesh::edgeCells
00059 (
00060     const label edgeI,
00061     DynamicList<label>& storage
00062 ) const
00063 {
00064     if (hasEdgeCells())
00065     {
00066         return edgeCells()[edgeI];
00067     }
00068     else
00069     {
00070         const labelList& own = faceOwner();
00071         const labelList& nei = faceNeighbour();
00072 
00073         // Construct edgeFaces
00074         DynamicList<label> eFacesStorage;
00075         const labelList& eFaces = edgeFaces(edgeI, eFacesStorage);
00076 
00077         storage.clear();
00078 
00079         // Do quadratic insertion.
00080         forAll(eFaces, i)
00081         {
00082             label faceI = eFaces[i];
00083 
00084             {
00085                 label ownCellI = own[faceI];
00086 
00087                 // Check if not already in storage
00088                 forAll(storage, j)
00089                 {
00090                     if (storage[j] == ownCellI)
00091                     {
00092                         ownCellI = -1;
00093                         break;
00094                     }
00095                 }
00096 
00097                 if (ownCellI != -1)
00098                 {
00099                     storage.append(ownCellI);
00100                 }
00101             }
00102 
00103             if (isInternalFace(faceI))
00104             {
00105                 label neiCellI = nei[faceI];
00106 
00107                 forAll(storage, j)
00108                 {
00109                     if (storage[j] == neiCellI)
00110                     {
00111                         neiCellI = -1;
00112                         break;
00113                     }
00114                 }
00115 
00116                 if (neiCellI != -1)
00117                 {
00118                     storage.append(neiCellI);
00119                 }
00120             }
00121         }
00122 
00123         return storage;
00124     }
00125 }
00126 
00127 
00128 const Foam::labelList& Foam::primitiveMesh::edgeCells(const label edgeI) const
00129 {
00130     return edgeCells(edgeI, labels_);
00131 }
00132 
00133 
00134 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd