1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
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
13 the Free Software Foundation, either version 3 of the License, or
14 (at your 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, 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 writeFuns::writeHeader
59 str << "DATASET POLYDATA" << std::endl;
61 const pointField& fc = mesh.faceCentres();
63 str << "POINTS " << mesh.nFaces() << " float" << std::endl;
65 DynamicList<floatScalar> pField(3*mesh.nFaces());
67 for (label faceI = 0; faceI < mesh.nFaces(); faceI++)
69 writeFuns::insert(fc[faceI], pField);
72 writeFuns::write(str, binary, pField);
74 str << "POINT_DATA " << mesh.nFaces() << std::endl
75 << "FIELD attributes " << surfVectorFields.size() << std::endl;
78 forAll(surfVectorFields, fieldI)
80 const surfaceVectorField& svf = surfVectorFields[fieldI];
82 str << svf.name() << " 3 "
83 << mesh.nFaces() << " float" << std::endl;
85 DynamicList<floatScalar> fField(3*mesh.nFaces());
87 for (label faceI = 0; faceI < mesh.nInternalFaces(); faceI++)
89 writeFuns::insert(svf[faceI], fField);
92 forAll(svf.boundaryField(), patchI)
94 const fvsPatchVectorField& pf = svf.boundaryField()[patchI];
96 const fvPatch& pp = mesh.boundary()[patchI];
98 if (isA<emptyFvsPatchVectorField>(pf))
100 // Note: loop over polypatch size, not fvpatch size.
101 forAll(pp.patch(), i)
103 writeFuns::insert(vector::zero, fField);
110 writeFuns::insert(pf[i], fField);
115 writeFuns::write(str, binary, fField);
120 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
122 } // End namespace Foam
124 // ************************************************************************* //