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 #include "internalWriter.H"
00027 #include "writeFuns.H"
00028
00029
00030
00031
00032 Foam::internalWriter::internalWriter
00033 (
00034 const vtkMesh& vMesh,
00035 const bool binary,
00036 const fileName& fName
00037 )
00038 :
00039 vMesh_(vMesh),
00040 binary_(binary),
00041 fName_(fName),
00042 os_(fName.c_str())
00043 {
00044 const fvMesh& mesh = vMesh_.mesh();
00045 const vtkTopo& topo = vMesh_.topo();
00046
00047
00048 writeFuns::writeHeader(os_, binary_, mesh.time().caseName());
00049 os_ << "DATASET UNSTRUCTURED_GRID" << std::endl;
00050
00051
00052
00053
00054
00055
00056
00057
00058 const labelList& addPointCellLabels = topo.addPointCellLabels();
00059 const label nTotPoints = mesh.nPoints() + addPointCellLabels.size();
00060
00061 os_ << "POINTS " << nTotPoints
00062 << " float" << std::endl;
00063
00064 DynamicList<floatScalar> ptField(3*nTotPoints);
00065
00066 writeFuns::insert(mesh.points(), ptField);
00067
00068 const pointField& ctrs = mesh.cellCentres();
00069 forAll(addPointCellLabels, api)
00070 {
00071 writeFuns::insert(ctrs[addPointCellLabels[api]], ptField);
00072 }
00073 writeFuns::write(os_, binary_, ptField);
00074
00075
00076
00077
00078
00079
00080 const labelListList& vtkVertLabels = topo.vertLabels();
00081
00082
00083 label nFaceVerts = 0;
00084
00085 forAll(vtkVertLabels, cellI)
00086 {
00087 nFaceVerts += vtkVertLabels[cellI].size() + 1;
00088 }
00089
00090 os_ << "CELLS " << vtkVertLabels.size() << ' ' << nFaceVerts
00091 << std::endl;
00092
00093
00094 DynamicList<label> vertLabels(nFaceVerts);
00095
00096 forAll(vtkVertLabels, cellI)
00097 {
00098 const labelList& vtkVerts = vtkVertLabels[cellI];
00099
00100 vertLabels.append(vtkVerts.size());
00101
00102 writeFuns::insert(vtkVerts, vertLabels);
00103 }
00104 writeFuns::write(os_, binary_, vertLabels);
00105
00106
00107
00108 const labelList& vtkCellTypes = topo.cellTypes();
00109
00110 os_ << "CELL_TYPES " << vtkCellTypes.size() << std::endl;
00111
00112
00113 DynamicList<label> cellTypes(vtkCellTypes.size());
00114
00115 writeFuns::insert(vtkCellTypes, cellTypes);
00116
00117 writeFuns::write(os_, binary_, cellTypes);
00118 }
00119
00120
00121
00122
00123 void Foam::internalWriter::writeCellIDs()
00124 {
00125 const fvMesh& mesh = vMesh_.mesh();
00126 const vtkTopo& topo = vMesh_.topo();
00127 const labelList& vtkCellTypes = topo.cellTypes();
00128 const labelList& superCells = topo.superCells();
00129
00130
00131 os_ << "cellID 1 " << vtkCellTypes.size() << " int"
00132 << std::endl;
00133
00134 labelList cellId(vtkCellTypes.size());
00135 label labelI = 0;
00136
00137
00138 if (vMesh_.useSubMesh())
00139 {
00140 const labelList& cMap = vMesh_.subsetter().cellMap();
00141
00142 forAll(mesh.cells(), cellI)
00143 {
00144 cellId[labelI++] = cMap[cellI];
00145 }
00146 forAll(superCells, superCellI)
00147 {
00148 label origCellI = cMap[superCells[superCellI]];
00149
00150 cellId[labelI++] = origCellI;
00151 }
00152 }
00153 else
00154 {
00155 forAll(mesh.cells(), cellI)
00156 {
00157 cellId[labelI++] = cellI;
00158 }
00159 forAll(superCells, superCellI)
00160 {
00161 label origCellI = superCells[superCellI];
00162
00163 cellId[labelI++] = origCellI;
00164 }
00165 }
00166
00167 writeFuns::write(os_, binary_, cellId);
00168 }
00169
00170
00171