1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
11 OpenFOAM is free software: you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by
13 the Free Software Foundation, either version 3 of the License, or
14 (at your option) any later version.
16 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "primitiveMesh.H"
29 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
31 void Foam::primitiveMesh::calcPointCells() const
33 // Loop through cells and mark up points
37 Pout<< "primitiveMesh::calcPointCells() : "
38 << "calculating pointCells"
43 // For checking calls:abort so we can quickly hunt down
45 FatalErrorIn("primitiveMesh::calcPointCells()")
50 // It is an error to attempt to recalculate pointCells
51 // if the pointer is already set
54 FatalErrorIn("primitiveMesh::calcPointCells() const")
55 << "pointCells already calculated"
60 const cellList& cf = cells();
62 // Count number of cells per point
64 labelList npc(nPoints(), 0);
68 const labelList curPoints = cf[cellI].labels(faces());
70 forAll(curPoints, pointI)
72 label ptI = curPoints[pointI];
79 // Size and fill cells per point
81 pcPtr_ = new labelListList(npc.size());
82 labelListList& pointCellAddr = *pcPtr_;
84 forAll(pointCellAddr, pointI)
86 pointCellAddr[pointI].setSize(npc[pointI]);
93 const labelList curPoints = cf[cellI].labels(faces());
95 forAll(curPoints, pointI)
97 label ptI = curPoints[pointI];
99 pointCellAddr[ptI][npc[ptI]++] = cellI;
106 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
108 const Foam::labelListList& Foam::primitiveMesh::pointCells() const
119 const Foam::labelList& Foam::primitiveMesh::pointCells
122 DynamicList<label>& storage
127 return pointCells()[pointI];
131 const labelList& own = faceOwner();
132 const labelList& nei = faceNeighbour();
133 const labelList& pFaces = pointFaces()[pointI];
139 const label faceI = pFaces[i];
142 storage.append(own[faceI]);
145 if (faceI < nInternalFaces())
147 storage.append(nei[faceI]);
152 if (storage.size() > 1)
157 for (label i = 1; i < storage.size(); i++)
159 if (storage[i-1] != storage[i])
161 storage[n++] = storage[i];
165 // truncate addressed list
174 const Foam::labelList& Foam::primitiveMesh::pointCells(const label pointI) const
176 return pointCells(pointI, labels_);
180 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
182 // ************************************************************************* //