1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright held by original author
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 the
13 Free Software Foundation; either version 2 of the License, or (at your
14 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, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 \*---------------------------------------------------------------------------*/
27 #include "primitiveMesh.H"
30 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
32 void Foam::primitiveMesh::calcPointCells() const
34 // Loop through cells and mark up points
38 Pout<< "primitiveMesh::calcPointCells() : "
39 << "calculating pointCells"
44 // For checking calls:abort so we can quickly hunt down
46 FatalErrorIn("primitiveMesh::calcPointCells()")
51 // It is an error to attempt to recalculate pointCells
52 // if the pointer is already set
55 FatalErrorIn("primitiveMesh::calcPointCells() const")
56 << "pointCells already calculated"
61 const cellList& cf = cells();
63 // Count number of cells per point
65 labelList npc(nPoints(), 0);
69 const labelList curPoints = cf[cellI].labels(faces());
71 forAll (curPoints, pointI)
73 label ptI = curPoints[pointI];
80 // Size and fill cells per point
82 pcPtr_ = new labelListList(npc.size());
83 labelListList& pointCellAddr = *pcPtr_;
85 forAll (pointCellAddr, pointI)
87 pointCellAddr[pointI].setSize(npc[pointI]);
94 const labelList curPoints = cf[cellI].labels(faces());
96 forAll (curPoints, pointI)
98 label ptI = curPoints[pointI];
100 pointCellAddr[ptI][npc[ptI]++] = cellI;
107 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
109 const Foam::labelListList& Foam::primitiveMesh::pointCells() const
120 const Foam::labelList& Foam::primitiveMesh::pointCells
123 DynamicList<label>& storage
128 return pointCells()[pointI];
132 const labelList& own = faceOwner();
133 const labelList& nei = faceNeighbour();
134 const labelList& pFaces = pointFaces()[pointI];
140 const label faceI = pFaces[i];
143 storage.append(own[faceI]);
146 if (faceI < nInternalFaces())
148 storage.append(nei[faceI]);
153 if (storage.size() > 1)
158 for (label i = 1; i < storage.size(); i++)
160 if (storage[i-1] != storage[i])
162 storage[n++] = storage[i];
166 // truncate addressed list
175 const Foam::labelList& Foam::primitiveMesh::pointCells(const label pointI) const
177 return pointCells(pointI, labels_);
181 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
183 // ************************************************************************* //