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 "writePatch.H"
00027 #include <OpenFOAM/OFstream.H>
00028 #include "writeFuns.H"
00029 #include <OpenFOAM/primitiveFacePatch.H>
00030
00031
00032
00033 namespace Foam
00034 {
00035
00036
00037
00038 void writePatch
00039 (
00040 const bool binary,
00041 const word& setName,
00042 const primitiveFacePatch& fp,
00043 const word& fieldName,
00044 labelList& fieldValues,
00045 const fileName& fileName
00046 )
00047 {
00048 std::ofstream pStream(fileName.c_str());
00049
00050 pStream
00051 << "# vtk DataFile Version 2.0" << std::endl
00052 << setName << std::endl;
00053 if (binary)
00054 {
00055 pStream << "BINARY" << std::endl;
00056 }
00057 else
00058 {
00059 pStream << "ASCII" << std::endl;
00060 }
00061 pStream << "DATASET POLYDATA" << std::endl;
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073 pStream << "POINTS " << fp.nPoints() << " float" << std::endl;
00074
00075 DynamicList<floatScalar> ptField(3*fp.nPoints());
00076
00077 writeFuns::insert(fp.localPoints(), ptField);
00078
00079 writeFuns::write(pStream, binary, ptField);
00080
00081
00082 label nFaceVerts = 0;
00083
00084 forAll(fp.localFaces(), faceI)
00085 {
00086 nFaceVerts += fp.localFaces()[faceI].size() + 1;
00087 }
00088 pStream << "POLYGONS " << fp.size() << ' ' << nFaceVerts
00089 << std::endl;
00090
00091
00092 DynamicList<label> vertLabels(nFaceVerts);
00093
00094 forAll(fp.localFaces(), faceI)
00095 {
00096 const face& f = fp.localFaces()[faceI];
00097
00098 vertLabels.append(f.size());
00099
00100 writeFuns::insert(f, vertLabels);
00101 }
00102 writeFuns::write(pStream, binary, vertLabels);
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113 pStream
00114 << "CELL_DATA " << fp.size() << std::endl
00115 << "FIELD attributes 1" << std::endl;
00116
00117
00118 pStream << fieldName << " 1 " << fp.size() << " int" << std::endl;
00119
00120 writeFuns::write(pStream, binary, fieldValues);
00121 }
00122
00123
00124
00125 }
00126
00127