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