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 "writeSurfFields.H"
00027 #include <OpenFOAM/OFstream.H>
00028 #include <OpenFOAM/floatScalar.H>
00029 #include "writeFuns.H"
00030 #include <finiteVolume/emptyFvsPatchFields.H>
00031 #include <finiteVolume/fvsPatchFields.H>
00032
00033
00034
00035 namespace Foam
00036 {
00037
00038
00039
00040 void writeSurfFields
00041 (
00042 const bool binary,
00043 const vtkMesh& vMesh,
00044 const fileName& fileName,
00045 const PtrList<surfaceVectorField>& surfVectorFields
00046 )
00047 {
00048 const fvMesh& mesh = vMesh.mesh();
00049
00050 std::ofstream str(fileName.c_str());
00051
00052 str << "# vtk DataFile Version 2.0" << std::endl
00053 << "surfaceFields" << std::endl;
00054
00055 if (binary)
00056 {
00057 str << "BINARY" << std::endl;
00058 }
00059 else
00060 {
00061 str << "ASCII" << std::endl;
00062 }
00063 str << "DATASET POLYDATA" << std::endl;
00064
00065 const pointField& fc = mesh.faceCentres();
00066
00067 str << "POINTS " << mesh.nFaces() << " float" << std::endl;
00068
00069 DynamicList<floatScalar> pField(3*mesh.nFaces());
00070
00071 for (label faceI = 0; faceI < mesh.nFaces(); faceI++)
00072 {
00073 writeFuns::insert(fc[faceI], pField);
00074 }
00075
00076 writeFuns::write(str, binary, pField);
00077
00078 str << "POINT_DATA " << mesh.nFaces() << std::endl
00079 << "FIELD attributes " << surfVectorFields.size() << std::endl;
00080
00081
00082 forAll(surfVectorFields, fieldI)
00083 {
00084 const surfaceVectorField& svf = surfVectorFields[fieldI];
00085
00086 str << svf.name() << " 3 "
00087 << mesh.nFaces() << " float" << std::endl;
00088
00089 DynamicList<floatScalar> fField(3*mesh.nFaces());
00090
00091 for (label faceI = 0; faceI < mesh.nInternalFaces(); faceI++)
00092 {
00093 writeFuns::insert(svf[faceI], fField);
00094 }
00095
00096 forAll(svf.boundaryField(), patchI)
00097 {
00098 const fvsPatchVectorField& pf = svf.boundaryField()[patchI];
00099
00100 const fvPatch& pp = mesh.boundary()[patchI];
00101
00102 if (isA<emptyFvsPatchVectorField>(pf))
00103 {
00104
00105 forAll(pp.patch(), i)
00106 {
00107 writeFuns::insert(vector::zero, fField);
00108 }
00109 }
00110 else
00111 {
00112 forAll(pf, i)
00113 {
00114 writeFuns::insert(pf[i], fField);
00115 }
00116 }
00117 }
00118
00119 writeFuns::write(str, binary, fField);
00120 }
00121 }
00122
00123
00124
00125
00126 }
00127
00128