primitiveMeshPointCells.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 #include "primitiveMesh.H"
00028 #include "cell.H"
00029
00030
00031
00032 void Foam::primitiveMesh::calcPointCells() const
00033 {
00034
00035
00036 if (debug)
00037 {
00038 Pout<< "primitiveMesh::calcPointCells() : "
00039 << "calculating pointCells"
00040 << endl;
00041
00042 if (debug == -1)
00043 {
00044
00045
00046 FatalErrorIn("primitiveMesh::calcPointCells()")
00047 << abort(FatalError);
00048 }
00049 }
00050
00051
00052
00053 if (pcPtr_)
00054 {
00055 FatalErrorIn("primitiveMesh::calcPointCells() const")
00056 << "pointCells already calculated"
00057 << abort(FatalError);
00058 }
00059 else
00060 {
00061 const cellList& cf = cells();
00062
00063
00064
00065 labelList npc(nPoints(), 0);
00066
00067 forAll (cf, cellI)
00068 {
00069 const labelList curPoints = cf[cellI].labels(faces());
00070
00071 forAll (curPoints, pointI)
00072 {
00073 label ptI = curPoints[pointI];
00074
00075 npc[ptI]++;
00076 }
00077 }
00078
00079
00080
00081
00082 pcPtr_ = new labelListList(npc.size());
00083 labelListList& pointCellAddr = *pcPtr_;
00084
00085 forAll (pointCellAddr, pointI)
00086 {
00087 pointCellAddr[pointI].setSize(npc[pointI]);
00088 }
00089 npc = 0;
00090
00091
00092 forAll (cf, cellI)
00093 {
00094 const labelList curPoints = cf[cellI].labels(faces());
00095
00096 forAll (curPoints, pointI)
00097 {
00098 label ptI = curPoints[pointI];
00099
00100 pointCellAddr[ptI][npc[ptI]++] = cellI;
00101 }
00102 }
00103 }
00104 }
00105
00106
00107
00108
00109 const Foam::labelListList& Foam::primitiveMesh::pointCells() const
00110 {
00111 if (!pcPtr_)
00112 {
00113 calcPointCells();
00114 }
00115
00116 return *pcPtr_;
00117 }
00118
00119
00120 const Foam::labelList& Foam::primitiveMesh::pointCells
00121 (
00122 const label pointI,
00123 DynamicList<label>& storage
00124 ) const
00125 {
00126 if (hasPointCells())
00127 {
00128 return pointCells()[pointI];
00129 }
00130 else
00131 {
00132 const labelList& own = faceOwner();
00133 const labelList& nei = faceNeighbour();
00134 const labelList& pFaces = pointFaces()[pointI];
00135
00136 storage.clear();
00137
00138 forAll(pFaces, i)
00139 {
00140 const label faceI = pFaces[i];
00141
00142
00143 storage.append(own[faceI]);
00144
00145
00146 if (faceI < nInternalFaces())
00147 {
00148 storage.append(nei[faceI]);
00149 }
00150 }
00151
00152
00153 if (storage.size() > 1)
00154 {
00155 sort(storage);
00156
00157 label n = 1;
00158 for (label i = 1; i < storage.size(); i++)
00159 {
00160 if (storage[i-1] != storage[i])
00161 {
00162 storage[n++] = storage[i];
00163 }
00164 }
00165
00166
00167 storage.setSize(n);
00168 }
00169
00170 return storage;
00171 }
00172 }
00173
00174
00175 const Foam::labelList& Foam::primitiveMesh::pointCells(const label pointI) const
00176 {
00177 return pointCells(pointI, labels_);
00178 }
00179
00180
00181
00182
00183
Copyright © 2000-2009 OpenCFD Ltd