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
00032 #include "vtkTopo.H"
00033 #include <OpenFOAM/polyMesh.H>
00034 #include <OpenFOAM/cellShape.H>
00035 #include <OpenFOAM/cellModeller.H>
00036
00037
00038
00039
00040 Foam::vtkTopo::vtkTopo(const polyMesh& mesh)
00041 :
00042 mesh_(mesh),
00043 vertLabels_(),
00044 cellTypes_(),
00045 addPointCellLabels_(),
00046 superCells_()
00047 {
00048 const cellModel& tet = *(cellModeller::lookup("tet"));
00049 const cellModel& pyr = *(cellModeller::lookup("pyr"));
00050 const cellModel& prism = *(cellModeller::lookup("prism"));
00051 const cellModel& tetWedge = *(cellModeller::lookup("tetWedge"));
00052 const cellModel& hex = *(cellModeller::lookup("hex"));
00053
00054
00055 const cellShapeList& cellShapes = mesh_.cellShapes();
00056
00057
00058
00059 label nAddPoints = 0;
00060
00061
00062 label nAddCells = 0;
00063
00064
00065
00066
00067 forAll(cellShapes, cellI)
00068 {
00069 const cellModel& model = cellShapes[cellI].model();
00070
00071 if
00072 (
00073 model != hex
00074
00075 && model != prism
00076 && model != pyr
00077 && model != tet
00078 && model != tetWedge
00079 )
00080 {
00081 const cell& cFaces = mesh_.cells()[cellI];
00082
00083 forAll(cFaces, cFaceI)
00084 {
00085 const face& f = mesh_.faces()[cFaces[cFaceI]];
00086
00087 label nQuads = 0;
00088 label nTris = 0;
00089 f.nTrianglesQuads(mesh_.points(), nTris, nQuads);
00090
00091 nAddCells += nQuads + nTris;
00092 }
00093
00094 nAddCells--;
00095 nAddPoints++;
00096 }
00097 }
00098
00099
00100
00101 addPointCellLabels_.setSize(nAddPoints);
00102
00103
00104
00105 superCells_.setSize(nAddCells);
00106
00107
00108 vertLabels_.setSize(cellShapes.size() + nAddCells);
00109
00110
00111 cellTypes_.setSize(cellShapes.size() + nAddCells);
00112
00113
00114 label api = 0, aci = 0;
00115
00116 forAll(cellShapes, cellI)
00117 {
00118 const cellShape& cellShape = cellShapes[cellI];
00119 const cellModel& cellModel = cellShape.model();
00120
00121 labelList& vtkVerts = vertLabels_[cellI];
00122
00123 if (cellModel == tet)
00124 {
00125 vtkVerts = cellShape;
00126
00127 cellTypes_[cellI] = VTK_TETRA;
00128 }
00129 else if (cellModel == pyr)
00130 {
00131 vtkVerts = cellShape;
00132
00133 cellTypes_[cellI] = VTK_PYRAMID;
00134 }
00135 else if (cellModel == prism)
00136 {
00137 vtkVerts.setSize(6);
00138 vtkVerts[0] = cellShape[0];
00139 vtkVerts[1] = cellShape[2];
00140 vtkVerts[2] = cellShape[1];
00141 vtkVerts[3] = cellShape[3];
00142 vtkVerts[4] = cellShape[5];
00143 vtkVerts[5] = cellShape[4];
00144
00145
00146 cellTypes_[cellI] = VTK_WEDGE;
00147 }
00148 else if (cellModel == tetWedge)
00149 {
00150
00151 vtkVerts.setSize(6);
00152 vtkVerts[0] = cellShape[0];
00153 vtkVerts[1] = cellShape[2];
00154 vtkVerts[2] = cellShape[1];
00155 vtkVerts[3] = cellShape[3];
00156 vtkVerts[4] = cellShape[4];
00157 vtkVerts[5] = cellShape[4];
00158
00159 cellTypes_[cellI] = VTK_WEDGE;
00160 }
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176 else if (cellModel == hex)
00177 {
00178 vtkVerts.setSize(8);
00179 vtkVerts[0] = cellShape[0];
00180 vtkVerts[1] = cellShape[1];
00181 vtkVerts[2] = cellShape[2];
00182 vtkVerts[3] = cellShape[3];
00183 vtkVerts[4] = cellShape[4];
00184 vtkVerts[5] = cellShape[5];
00185 vtkVerts[6] = cellShape[6];
00186 vtkVerts[7] = cellShape[7];
00187
00188 cellTypes_[cellI] = VTK_HEXAHEDRON;
00189 }
00190 else
00191 {
00192
00193
00194
00195
00196 addPointCellLabels_[api] = cellI;
00197
00198
00199 bool substituteCell = true;
00200
00201 const labelList& cFaces = mesh_.cells()[cellI];
00202
00203 forAll(cFaces, cFaceI)
00204 {
00205 const face& f = mesh_.faces()[cFaces[cFaceI]];
00206
00207
00208 label nTris = 0;
00209 label nQuads = 0;
00210 f.nTrianglesQuads(mesh_.points(), nTris, nQuads);
00211
00212
00213 faceList triFcs(nTris);
00214 faceList quadFcs(nQuads);
00215 label trii = 0;
00216 label quadi = 0;
00217 f.trianglesQuads(mesh_.points(), trii, quadi, triFcs, quadFcs);
00218
00219 forAll(quadFcs, quadi)
00220 {
00221 label thisCellI = -1;
00222
00223 if (substituteCell)
00224 {
00225 thisCellI = cellI;
00226
00227 substituteCell = false;
00228 }
00229 else
00230 {
00231 thisCellI = mesh_.nCells() + aci;
00232
00233 superCells_[aci] = cellI;
00234
00235 aci++;
00236 }
00237
00238 labelList& addVtkVerts = vertLabels_[thisCellI];
00239
00240 addVtkVerts.setSize(5);
00241
00242 const face& quad = quadFcs[quadi];
00243
00244 addVtkVerts[0] = quad[0];
00245 addVtkVerts[1] = quad[1];
00246 addVtkVerts[2] = quad[2];
00247 addVtkVerts[3] = quad[3];
00248 addVtkVerts[4] = mesh_.nPoints() + api;
00249
00250 cellTypes_[thisCellI] = VTK_PYRAMID;
00251 }
00252
00253 forAll(triFcs, trii)
00254 {
00255 label thisCellI = -1;
00256
00257 if (substituteCell)
00258 {
00259 thisCellI = cellI;
00260
00261 substituteCell = false;
00262 }
00263 else
00264 {
00265 thisCellI = mesh_.nCells() + aci;
00266
00267 superCells_[aci] = cellI;
00268
00269 aci++;
00270 }
00271
00272
00273 labelList& addVtkVerts = vertLabels_[thisCellI];
00274
00275 const face& tri = triFcs[trii];
00276
00277 addVtkVerts.setSize(4);
00278 addVtkVerts[0] = tri[0];
00279 addVtkVerts[1] = tri[1];
00280 addVtkVerts[2] = tri[2];
00281 addVtkVerts[3] = mesh_.nPoints() + api;
00282
00283 cellTypes_[thisCellI] = VTK_TETRA;
00284 }
00285 }
00286
00287 api++;
00288 }
00289 }
00290
00291 Pout<< " Original cells:" << mesh_.nCells()
00292 << " points:" << mesh_.nPoints()
00293 << " Additional cells:" << superCells_.size()
00294 << " additional points:" << addPointCellLabels_.size()
00295 << nl << endl;
00296 }
00297
00298