BUGFIX: Illegal use of uninitialised value (backport)
[foam-extend-3.2.git] / applications / utilities / postProcessing / dataConversion / foamToVTK / patchWriterTemplates.C
blob30681a2fbe1a386137df77b391599f7df1402615
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright held by original author
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
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
19     for more details.
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 "patchWriter.H"
28 #include "writeFuns.H"
30 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
32 template<class Type>
33 void Foam::patchWriter::write
35     const PtrList<GeometricField<Type, fvPatchField, volMesh> >& flds
38     forAll(flds, fieldI)
39     {
40         const GeometricField<Type, fvPatchField, volMesh>& fld = flds[fieldI];
42         os_ << fld.name() << ' ' << pTraits<Type>::nComponents << ' '
43             << nFaces_ << " float" << std::endl;
45         DynamicList<floatScalar> fField(pTraits<Type>::nComponents*nFaces_);
47         forAll(patchIDs_, j)
48         {
49             label patchI = patchIDs_[j];
51             const fvPatchField<Type>& pfld = fld.boundaryField()[patchI];
53             if (nearCellValue_)
54             {
55                 writeFuns::insert(pfld.patchInternalField()(), fField);
56             }
57             else
58             {
59                 writeFuns::insert(pfld, fField);
60             }
61         }
62         writeFuns::write(os_, binary_, fField);
63     }
67 template<class Type>
68 void Foam::patchWriter::write
70     const PtrList<GeometricField<Type, pointPatchField, pointMesh> >& flds
73     forAll(flds, fieldI)
74     {
75         const GeometricField<Type, pointPatchField, pointMesh>& fld =
76             flds[fieldI];
78         os_ << fld.name() << ' ' << pTraits<Type>::nComponents << ' '
79             << nPoints_ << " float" << std::endl;
81         DynamicList<floatScalar> fField(pTraits<Type>::nComponents*nPoints_);
83         forAll(patchIDs_, j)
84         {
85             label patchI = patchIDs_[j];
87             const pointPatchField<Type>& pfld = fld.boundaryField()[patchI];
89             writeFuns::insert(pfld.patchInternalField()(), fField);
90         }
91         writeFuns::write(os_, binary_, fField);
92     }
96 template<class Type>
97 void Foam::patchWriter::write
99     const PrimitivePatchInterpolation<primitivePatch>& pInter,
100     const PtrList<GeometricField<Type, fvPatchField, volMesh> >& flds
103     forAll(flds, fieldI)
104     {
105         const GeometricField<Type, fvPatchField, volMesh>& fld = flds[fieldI];
107         os_ << fld.name() << ' ' << pTraits<Type>::nComponents << ' '
108             << nPoints_ << " float" << std::endl;
110         DynamicList<floatScalar> fField(pTraits<Type>::nComponents*nPoints_);
112         forAll(patchIDs_, j)
113         {
114             label patchI = patchIDs_[j];
116             const fvPatchField<Type>& pfld = fld.boundaryField()[patchI];
118             if (nearCellValue_)
119             {
120                 writeFuns::insert
121                 (
122                     pInter.faceToPointInterpolate
123                     (
124                         pfld.patchInternalField()()
125                     )(),
126                     fField
127                 );
128             }
129             else
130             {
131                 writeFuns::insert
132                 (
133                     pInter.faceToPointInterpolate(pfld)(),
134                     fField
135                 );
136             }
137         }
138         writeFuns::write(os_, binary_, fField);
139     }
143 // ************************************************************************* //