1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2009 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 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
26 Create intermediate mesh files from SAMM files
28 \*---------------------------------------------------------------------------*/
32 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
34 void sammMesh::calcPointCells() const
36 const static label UNIT_POINT_CELLS = 12;
40 FatalErrorIn("sammMesh::calcPointCells()")
41 << "PointCells already calculated"
46 pointCellsPtr_ = new labelListList(points_.size());
48 labelListList& pc = *pointCellsPtr_;
52 pc[i].setSize(UNIT_POINT_CELLS);
55 // Initialise the list of labels which will hold the count the
56 // actual number of cells per point during the analysis
57 labelList cellCount(points_.size());
64 // Note. Unlike the standard point-cell algorithm, which asks the cell for
65 // the supporting point labels, we need to work based on the cell faces.
66 // This is because some of the faces for meshes with arbitrary interfaces
67 // do not come from the cell shape, but from the slaves of the coupled
68 // match. It is also adventageous to remove the duplicates from the
69 // point-cell addressing, because this removes a lot of waste later.
73 forAll(cellShapes_, cellI)
75 const faceList& faces = cellFaces_[cellI];
80 const labelList& labels = faces[i];
84 // Set working point label
85 label curPoint = labels[j];
86 labelList& curPointCells = pc[curPoint];
87 label curCount = cellCount[curPoint];
89 // check if the cell has been added before
92 for (label f = 0; f < curCount; f++)
94 if (curPointCells[f] == cellI)
105 // If the list of pointCells is not big enough, double it
106 if (curPointCells.size() <= curCount)
108 curPointCells.setSize(curPointCells.size()*2);
111 // Enter the cell label in the point's cell list
112 curPointCells[curCount] = cellI;
114 // Increment the cell count for the point addressed
115 cellCount[curPoint]++;
121 // Finally, truncate the lists made to their active size
124 pc[i].setSize(cellCount[i]);
129 const labelListList& sammMesh::pointCells() const
136 return *pointCellsPtr_;
140 // ************************************************************************* //