1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright held by original author
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
11 OpenFOAM is free software; you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by the
13 Free Software Foundation; either version 2 of the License, or (at your
14 option) any later version.
16 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 \*---------------------------------------------------------------------------*/
27 #include "writeSurfFields.H"
29 #include "floatScalar.H"
30 #include "writeFuns.H"
31 #include "emptyFvsPatchFields.H"
32 #include "fvsPatchFields.H"
34 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
39 // * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
45 const fileName& fileName,
46 const PtrList<surfaceVectorField>& surfVectorFields
49 const fvMesh& mesh = vMesh.mesh();
51 std::ofstream str(fileName.c_str());
53 str << "# vtk DataFile Version 2.0" << std::endl
54 << "surfaceFields" << std::endl;
58 str << "BINARY" << std::endl;
62 str << "ASCII" << std::endl;
64 str << "DATASET POLYDATA" << std::endl;
66 const pointField& fc = mesh.faceCentres();
68 str << "POINTS " << mesh.nFaces() << " float" << std::endl;
70 DynamicList<floatScalar> pField(3*mesh.nFaces());
72 for (label faceI = 0; faceI < mesh.nFaces(); faceI++)
74 writeFuns::insert(fc[faceI], pField);
77 writeFuns::write(str, binary, pField);
79 str << "POINT_DATA " << mesh.nFaces() << std::endl
80 << "FIELD attributes " << surfVectorFields.size() << std::endl;
83 forAll(surfVectorFields, fieldI)
85 const surfaceVectorField& svf = surfVectorFields[fieldI];
87 str << svf.name() << " 3 "
88 << mesh.nFaces() << " float" << std::endl;
90 DynamicList<floatScalar> fField(3*mesh.nFaces());
92 for (label faceI = 0; faceI < mesh.nInternalFaces(); faceI++)
94 writeFuns::insert(svf[faceI], fField);
97 forAll(svf.boundaryField(), patchI)
99 const fvsPatchVectorField& pf = svf.boundaryField()[patchI];
101 const fvPatch& pp = mesh.boundary()[patchI];
103 if (isA<emptyFvsPatchVectorField>(pf))
105 // Note: loop over polypatch size, not fvpatch size.
106 forAll(pp.patch(), i)
108 writeFuns::insert(vector::zero, fField);
115 writeFuns::insert(pf[i], fField);
120 writeFuns::write(str, binary, fField);
125 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
127 } // End namespace Foam
129 // ************************************************************************* //