primitiveMeshCellCells.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
00029
00030
00031
00032 void Foam::primitiveMesh::calcCellCells() const
00033 {
00034
00035
00036 if (debug)
00037 {
00038 Pout<< "primitiveMesh::calcCellCells() : calculating cellCells"
00039 << endl;
00040
00041 if (debug == -1)
00042 {
00043
00044
00045 FatalErrorIn("primitiveMesh::calcCellCells()")
00046 << abort(FatalError);
00047 }
00048 }
00049
00050
00051
00052 if (ccPtr_)
00053 {
00054 FatalErrorIn("primitiveMesh::calcCellCells() const")
00055 << "cellCells already calculated"
00056 << abort(FatalError);
00057 }
00058 else
00059 {
00060
00061
00062 labelList ncc(nCells(), 0);
00063
00064 const labelList& own = faceOwner();
00065 const labelList& nei = faceNeighbour();
00066
00067 forAll (nei, faceI)
00068 {
00069 ncc[own[faceI]]++;
00070 ncc[nei[faceI]]++;
00071 }
00072
00073
00074 ccPtr_ = new labelListList(ncc.size());
00075 labelListList& cellCellAddr = *ccPtr_;
00076
00077
00078
00079
00080
00081 forAll (cellCellAddr, cellI)
00082 {
00083 cellCellAddr[cellI].setSize(ncc[cellI]);
00084 }
00085 ncc = 0;
00086
00087 forAll (nei, faceI)
00088 {
00089 label ownCellI = own[faceI];
00090 label neiCellI = nei[faceI];
00091
00092 cellCellAddr[ownCellI][ncc[ownCellI]++] = neiCellI;
00093 cellCellAddr[neiCellI][ncc[neiCellI]++] = ownCellI;
00094 }
00095 }
00096 }
00097
00098
00099
00100
00101 const Foam::labelListList& Foam::primitiveMesh::cellCells() const
00102 {
00103 if (!ccPtr_)
00104 {
00105 calcCellCells();
00106 }
00107
00108 return *ccPtr_;
00109 }
00110
00111
00112 const Foam::labelList& Foam::primitiveMesh::cellCells
00113 (
00114 const label cellI,
00115 DynamicList<label>& storage
00116 ) const
00117 {
00118 if (hasCellCells())
00119 {
00120 return cellCells()[cellI];
00121 }
00122 else
00123 {
00124 const labelList& own = faceOwner();
00125 const labelList& nei = faceNeighbour();
00126 const cell& cFaces = cells()[cellI];
00127
00128 storage.clear();
00129
00130 forAll(cFaces, i)
00131 {
00132 label faceI = cFaces[i];
00133
00134 if (faceI < nInternalFaces())
00135 {
00136 if (own[faceI] == cellI)
00137 {
00138 storage.append(nei[faceI]);
00139 }
00140 else
00141 {
00142 storage.append(own[faceI]);
00143 }
00144 }
00145 }
00146
00147 return storage;
00148 }
00149 }
00150
00151
00152 const Foam::labelList& Foam::primitiveMesh::cellCells(const label cellI) const
00153 {
00154 return cellCells(cellI, labels_);
00155 }
00156
00157
00158
Copyright © 2000-2009 OpenCFD Ltd