DOC: Corrected class names in the file descriptions
[freefoam.git] / applications / utilities / postProcessing / dataConversion / foamToVTK / writeFunsTemplates.C
blobaf378ccbe73b8e362563b95bbcc7e93eb64c36a6
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2010 OpenCFD Ltd.
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
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
19     for more details.
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 Description
26 \*---------------------------------------------------------------------------*/
28 #include "writeFuns.H"
29 #include <OpenFOAM/interpolatePointToCell.H>
31 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
33 // Store List in dest
34 template<class Type>
35 void Foam::writeFuns::insert
37     const List<Type>& source,
38     DynamicList<floatScalar>& dest
41     forAll(source, i)
42     {
43         insert(source[i], dest);
44     }
48 //// Store List (indexed through map) in dest
49 //template<class Type>
50 //void Foam::writeFuns::insert
51 //(
52 //    const labelList& map,
53 //    const List<Type>& source,
54 //    DynamicList<floatScalar>& dest
55 //)
56 //{
57 //    forAll(map, i)
58 //    {
59 //        insert(source[map[i]], dest);
60 //    }
61 //}
64 template<class Type>
65 void Foam::writeFuns::write
67     std::ostream& os,
68     const bool binary,
69     const GeometricField<Type, fvPatchField, volMesh>& vvf,
70     const vtkMesh& vMesh
73     const fvMesh& mesh = vMesh.mesh();
75     const labelList& superCells = vMesh.topo().superCells();
77     label nValues = mesh.nCells() + superCells.size();
79     os  << vvf.name() << ' ' << pTraits<Type>::nComponents << ' '
80         << nValues << " float" << std::endl;
82     DynamicList<floatScalar> fField(pTraits<Type>::nComponents*nValues);
84     insert(vvf.internalField(), fField);
86     forAll(superCells, superCellI)
87     {
88         label origCellI = superCells[superCellI];
90         insert(vvf[origCellI], fField);
91     }
92     write(os, binary, fField);
96 template<class Type>
97 void Foam::writeFuns::write
99     std::ostream& os,
100     const bool binary,
101     const GeometricField<Type, pointPatchField, pointMesh>& pvf,
102     const vtkMesh& vMesh
105     const fvMesh& mesh = vMesh.mesh();
106     const vtkTopo& topo = vMesh.topo();
108     const labelList& addPointCellLabels = topo.addPointCellLabels();
109     const label nTotPoints = mesh.nPoints() + addPointCellLabels.size();
111     os  << pvf.name() << ' ' << pTraits<Type>::nComponents << ' '
112         << nTotPoints << " float" << std::endl;
114     DynamicList<floatScalar> fField(pTraits<Type>::nComponents*nTotPoints);
116     insert(pvf, fField);
118     forAll(addPointCellLabels, api)
119     {
120         label origCellI = addPointCellLabels[api];
122         insert(interpolatePointToCell(pvf, origCellI), fField);
123     }
124     write(os, binary, fField);
128 template<class Type>
129 void Foam::writeFuns::write
131     std::ostream& os,
132     const bool binary,
133     const GeometricField<Type, fvPatchField, volMesh>& vvf,
134     const GeometricField<Type, pointPatchField, pointMesh>& pvf,
135     const vtkMesh& vMesh
138     const fvMesh& mesh = vMesh.mesh();
139     const vtkTopo& topo = vMesh.topo();
141     const labelList& addPointCellLabels = topo.addPointCellLabels();
142     const label nTotPoints = mesh.nPoints() + addPointCellLabels.size();
144     os  << vvf.name() << ' ' << pTraits<Type>::nComponents << ' '
145         << nTotPoints << " float" << std::endl;
147     DynamicList<floatScalar> fField(pTraits<Type>::nComponents*nTotPoints);
149     insert(pvf, fField);
151     forAll(addPointCellLabels, api)
152     {
153         label origCellI = addPointCellLabels[api];
155         insert(vvf[origCellI], fField);
156     }
157     write(os, binary, fField);
161 template<class Type, template<class> class PatchField, class GeoMesh>
162 void Foam::writeFuns::write
164     std::ostream& os,
165     const bool binary,
166     const PtrList<GeometricField<Type, PatchField, GeoMesh> >& flds,
167     const vtkMesh& vMesh
170     forAll(flds, i)
171     {
172         write(os, binary, flds[i], vMesh);
173     }
177 template<class Type>
178 void Foam::writeFuns::write
180     std::ostream& os,
181     const bool binary,
182     const volPointInterpolation& pInterp,
183     const PtrList<GeometricField<Type, fvPatchField, volMesh> >& flds,
184     const vtkMesh& vMesh
187     forAll(flds, i)
188     {
189         write(os, binary, flds[i], pInterp.interpolate(flds[i])(), vMesh);
190     }
194 // ************************ vim: set sw=4 sts=4 et: ************************ //