1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | foam-extend: Open Source CFD
4 \\ / O peration | Version: 3.2
5 \\ / A nd | Web: http://www.foam-extend.org
6 \\/ M anipulation | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
9 This file is part of foam-extend.
11 foam-extend 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 3 of the License, or (at your
14 option) any later version.
16 foam-extend is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "writeSurfFields.H"
28 #include "floatScalar.H"
29 #include "writeFuns.H"
30 #include "emptyFvsPatchFields.H"
31 #include "fvsPatchFields.H"
33 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
38 // * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
44 const fileName& fileName,
45 const PtrList<surfaceVectorField>& surfVectorFields
48 const fvMesh& mesh = vMesh.mesh();
50 std::ofstream str(fileName.c_str());
52 str << "# vtk DataFile Version 2.0" << std::endl
53 << "surfaceFields" << std::endl;
57 str << "BINARY" << std::endl;
61 str << "ASCII" << std::endl;
63 str << "DATASET POLYDATA" << std::endl;
65 const pointField& fc = mesh.faceCentres();
67 str << "POINTS " << mesh.nFaces() << " float" << std::endl;
69 DynamicList<floatScalar> pField(3*mesh.nFaces());
71 for (label faceI = 0; faceI < mesh.nFaces(); faceI++)
73 writeFuns::insert(fc[faceI], pField);
76 writeFuns::write(str, binary, pField);
78 str << "POINT_DATA " << mesh.nFaces() << std::endl
79 << "FIELD attributes " << surfVectorFields.size() << std::endl;
82 forAll(surfVectorFields, fieldI)
84 const surfaceVectorField& svf = surfVectorFields[fieldI];
86 str << svf.name() << " 3 "
87 << mesh.nFaces() << " float" << std::endl;
89 DynamicList<floatScalar> fField(3*mesh.nFaces());
91 for (label faceI = 0; faceI < mesh.nInternalFaces(); faceI++)
93 writeFuns::insert(svf[faceI], fField);
96 forAll(svf.boundaryField(), patchI)
98 const fvsPatchVectorField& pf = svf.boundaryField()[patchI];
100 const fvPatch& pp = mesh.boundary()[patchI];
102 if (isA<emptyFvsPatchVectorField>(pf))
104 // Note: loop over polypatch size, not fvpatch size.
105 forAll(pp.patch(), i)
107 writeFuns::insert(vector::zero, fField);
114 writeFuns::insert(pf[i], fField);
119 writeFuns::write(str, binary, fField);
124 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
126 } // End namespace Foam
128 // ************************************************************************* //