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

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-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 
00030 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00031 
00032 const Foam::labelListList& Foam::primitiveMesh::edgeCells() const
00033 {
00034     if (!ecPtr_)
00035     {
00036         if (debug)
00037         {
00038             Pout<< "primitiveMesh::edgeCells() : calculating edgeCells" << 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::edgeCells()")
00045                     << abort(FatalError);
00046             }
00047         }
00048         // Invert cellEdges
00049         ecPtr_ = new labelListList(nEdges());
00050         invertManyToMany(nEdges(), cellEdges(), *ecPtr_);
00051     }
00052 
00053     return *ecPtr_;
00054 }
00055 
00056 
00057 const Foam::labelList& Foam::primitiveMesh::edgeCells
00058 (
00059     const label edgeI,
00060     DynamicList<label>& storage
00061 ) const
00062 {
00063     if (hasEdgeCells())
00064     {
00065         return edgeCells()[edgeI];
00066     }
00067     else
00068     {
00069         const labelList& own = faceOwner();
00070         const labelList& nei = faceNeighbour();
00071 
00072         // Construct edgeFaces
00073         DynamicList<label> eFacesStorage;
00074         const labelList& eFaces = edgeFaces(edgeI, eFacesStorage);
00075 
00076         storage.clear();
00077 
00078         // Do quadratic insertion.
00079         forAll(eFaces, i)
00080         {
00081             label faceI = eFaces[i];
00082 
00083             {
00084                 label ownCellI = own[faceI];
00085 
00086                 // Check if not already in storage
00087                 forAll(storage, j)
00088                 {
00089                     if (storage[j] == ownCellI)
00090                     {
00091                         ownCellI = -1;
00092                         break;
00093                     }
00094                 }
00095 
00096                 if (ownCellI != -1)
00097                 {
00098                     storage.append(ownCellI);
00099                 }
00100             }
00101 
00102             if (isInternalFace(faceI))
00103             {
00104                 label neiCellI = nei[faceI];
00105 
00106                 forAll(storage, j)
00107                 {
00108                     if (storage[j] == neiCellI)
00109                     {
00110                         neiCellI = -1;
00111                         break;
00112                     }
00113                 }
00114 
00115                 if (neiCellI != -1)
00116                 {
00117                     storage.append(neiCellI);
00118                 }
00119             }
00120         }
00121 
00122         return storage;
00123     }
00124 }
00125 
00126 
00127 const Foam::labelList& Foam::primitiveMesh::edgeCells(const label edgeI) const
00128 {
00129     return edgeCells(edgeI, labels_);
00130 }
00131 
00132 
00133 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines