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