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