1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
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/>.
25 Create intermediate mesh files from SAMM files
27 \*---------------------------------------------------------------------------*/
31 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
33 void sammMesh::calcPointCells() const
35 static const label UNIT_POINT_CELLS = 12;
39 FatalErrorIn("sammMesh::calcPointCells()")
40 << "PointCells already calculated"
45 pointCellsPtr_ = new labelListList(points_.size());
47 labelListList& pc = *pointCellsPtr_;
51 pc[i].setSize(UNIT_POINT_CELLS);
54 // Initialise the list of labels which will hold the count the
55 // actual number of cells per point during the analysis
56 labelList cellCount(points_.size());
63 // Note. Unlike the standard point-cell algorithm, which asks the cell for
64 // the supporting point labels, we need to work based on the cell faces.
65 // This is because some of the faces for meshes with arbitrary interfaces
66 // do not come from the cell shape, but from the slaves of the coupled
67 // match. It is also adventageous to remove the duplicates from the
68 // point-cell addressing, because this removes a lot of waste later.
72 forAll(cellShapes_, cellI)
74 const faceList& faces = cellFaces_[cellI];
79 const labelList& labels = faces[i];
83 // Set working point label
84 label curPoint = labels[j];
85 labelList& curPointCells = pc[curPoint];
86 label curCount = cellCount[curPoint];
88 // check if the cell has been added before
91 for (label f = 0; f < curCount; f++)
93 if (curPointCells[f] == cellI)
104 // If the list of pointCells is not big enough, double it
105 if (curPointCells.size() <= curCount)
107 curPointCells.setSize(curPointCells.size()*2);
110 // Enter the cell label in the point's cell list
111 curPointCells[curCount] = cellI;
113 // Increment the cell count for the point addressed
114 cellCount[curPoint]++;
120 // Finally, truncate the lists made to their active size
123 pc[i].setSize(cellCount[i]);
128 const labelListList& sammMesh::pointCells() const
135 return *pointCellsPtr_;
139 // ************************************************************************* //