calcPointCells.C
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #include "meshReader.H"
00032
00033
00034
00035 void Foam::meshReader::calcPointCells() const
00036 {
00037 const static label UNIT_POINT_CELLS = 12;
00038
00039 if (pointCellsPtr_)
00040 {
00041 FatalErrorIn("meshReader::calcPointCells() const")
00042 << "pointCells already calculated"
00043 << abort(FatalError);
00044 }
00045
00046 label nPoints = points_.size();
00047
00048 pointCellsPtr_ = new labelListList(nPoints);
00049 labelListList& ptCells = *pointCellsPtr_;
00050
00051 forAll(ptCells, i)
00052 {
00053 ptCells[i].setSize(UNIT_POINT_CELLS);
00054 }
00055
00056
00057
00058 labelList cellCount(nPoints, 0);
00059
00060
00061
00062
00063
00064
00065
00066 faceListList& cFaces = cellFaces();
00067
00068
00069 forAll(cFaces, cellI)
00070 {
00071 const faceList& faces = cFaces[cellI];
00072
00073 forAll(faces, i)
00074 {
00075
00076 const labelList& labels = faces[i];
00077
00078 forAll(labels, j)
00079 {
00080
00081 label curPoint = labels[j];
00082 labelList& curPointCells = ptCells[curPoint];
00083 label curCount = cellCount[curPoint];
00084
00085
00086 bool found = false;
00087
00088 for (label f = 0; f < curCount; f++)
00089 {
00090 if (curPointCells[f] == cellI)
00091 {
00092 found = true;
00093 break;
00094 }
00095 }
00096
00097 if (!found)
00098 {
00099
00100 if (curPointCells.size() <= curCount)
00101 {
00102 curPointCells.setSize(curPointCells.size()*2);
00103 }
00104
00105
00106 curPointCells[curCount] = cellI;
00107
00108
00109 cellCount[curPoint]++;
00110 }
00111 }
00112 }
00113 }
00114
00115
00116
00117 label pointI = 0;
00118 labelList oldToNew(nPoints, -1);
00119
00120 forAll(ptCells, i)
00121 {
00122 ptCells[i].setSize(cellCount[i]);
00123 if (cellCount[i] > 0)
00124 {
00125 oldToNew[i] = pointI++;
00126 }
00127 }
00128
00129
00130 if (nPoints > pointI)
00131 {
00132 Info<< "removing " << (nPoints - pointI) << " unused points" << endl;
00133
00134 nPoints = pointI;
00135
00136
00137 pointField& adjustedPoints = const_cast<pointField&>(points_);
00138
00139 inplaceReorder(oldToNew, adjustedPoints);
00140 adjustedPoints.setSize(nPoints);
00141
00142
00143 inplaceReorder(oldToNew, ptCells);
00144 ptCells.setSize(nPoints);
00145
00146
00147
00148 forAll(cFaces, cellI)
00149 {
00150 faceList& faces = cFaces[cellI];
00151
00152
00153 forAll(faces, i)
00154 {
00155 inplaceRenumber(oldToNew, faces[i]);
00156 }
00157 }
00158 }
00159 }
00160
00161
00162 const Foam::labelListList& Foam::meshReader::pointCells() const
00163 {
00164 if (!pointCellsPtr_)
00165 {
00166 calcPointCells();
00167 }
00168
00169 return *pointCellsPtr_;
00170 }
00171
00172
00173
Copyright © 2000-2009 OpenCFD Ltd