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

primitiveMeshCellPoints.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::cellPoints() const
00032 {
00033     if (!cpPtr_)
00034     {
00035         if (debug)
00036         {
00037             Pout<< "primitiveMesh::cellPoints() : "
00038                 << "calculating cellPoints" << 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::cellPoints()")
00045                     << abort(FatalError);
00046             }
00047         }
00048 
00049         // Invert pointCells
00050         cpPtr_ = new labelListList(nCells());
00051         invertManyToMany(nCells(), pointCells(), *cpPtr_);
00052     }
00053 
00054     return *cpPtr_;
00055 }
00056 
00057 
00058 const Foam::labelList& Foam::primitiveMesh::cellPoints
00059 (
00060     const label cellI,
00061     DynamicList<label>& storage
00062 ) const
00063 {
00064     if (hasCellPoints())
00065     {
00066         return cellPoints()[cellI];
00067     }
00068     else
00069     {
00070         const faceList& fcs = faces();
00071         const labelList& cFaces = cells()[cellI];
00072 
00073         labelSet_.clear();
00074 
00075         forAll(cFaces, i)
00076         {
00077             const labelList& f = fcs[cFaces[i]];
00078 
00079             forAll(f, fp)
00080             {
00081                 labelSet_.insert(f[fp]);
00082             }
00083         }
00084 
00085         storage.clear();
00086         if (labelSet_.size() > storage.capacity())
00087         {
00088             storage.setCapacity(labelSet_.size());
00089         }
00090 
00091         forAllConstIter(labelHashSet, labelSet_, iter)
00092         {
00093             storage.append(iter.key());
00094         }
00095 
00096         return storage;
00097     }
00098 }
00099 
00100 
00101 const Foam::labelList& Foam::primitiveMesh::cellPoints(const label cellI) const
00102 {
00103     return cellPoints(cellI, labels_);
00104 }
00105 
00106 
00107 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00108 
00109 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines