initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / applications / utilities / postProcessing / dataConversion / foamToVTK / writeFunsTemplates.C
blob762f4b41a0d5a1b9d322a3cb4f8d1b7189291f8c
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2009 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 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 Description
27 \*---------------------------------------------------------------------------*/
29 #include "writeFuns.H"
30 #include "interpolatePointToCell.H"
32 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
34 // Store List in dest
35 template<class Type>
36 void Foam::writeFuns::insert
38     const List<Type>& source,
39     DynamicList<floatScalar>& dest
42     forAll(source, i)
43     {
44         insert(source[i], dest);
45     }
49 //// Store List (indexed through map) in dest
50 //template<class Type>
51 //void Foam::writeFuns::insert
52 //(
53 //    const labelList& map,
54 //    const List<Type>& source,
55 //    DynamicList<floatScalar>& dest
56 //)
57 //{
58 //    forAll(map, i)
59 //    {
60 //        insert(source[map[i]], dest);
61 //    }
62 //}
65 template<class Type>
66 void Foam::writeFuns::write
68     std::ostream& os,
69     const bool binary,
70     const GeometricField<Type, fvPatchField, volMesh>& vvf,
71     const vtkMesh& vMesh
74     const fvMesh& mesh = vMesh.mesh();
76     const labelList& superCells = vMesh.topo().superCells();
78     label nValues = mesh.nCells() + superCells.size();
80     os  << vvf.name() << ' ' << pTraits<Type>::nComponents << ' '
81         << nValues << " float" << std::endl;
83     DynamicList<floatScalar> fField(pTraits<Type>::nComponents*nValues);
85     insert(vvf.internalField(), fField);
87     forAll(superCells, superCellI)
88     {
89         label origCellI = superCells[superCellI];
91         insert(vvf[origCellI], fField);
92     }
93     write(os, binary, fField);
97 template<class Type>
98 void Foam::writeFuns::write
100     std::ostream& os,
101     const bool binary,
102     const GeometricField<Type, pointPatchField, pointMesh>& pvf,
103     const vtkMesh& vMesh
106     const fvMesh& mesh = vMesh.mesh();
107     const vtkTopo& topo = vMesh.topo();
109     const labelList& addPointCellLabels = topo.addPointCellLabels();
110     const label nTotPoints = mesh.nPoints() + addPointCellLabels.size();
112     os  << pvf.name() << ' ' << pTraits<Type>::nComponents << ' '
113         << nTotPoints << " float" << std::endl;
115     DynamicList<floatScalar> fField(pTraits<Type>::nComponents*nTotPoints);
117     insert(pvf, fField);
119     forAll(addPointCellLabels, api)
120     {
121         label origCellI = addPointCellLabels[api];
123         insert(interpolatePointToCell(pvf, origCellI), fField);
124     }
125     write(os, binary, fField);
129 template<class Type>
130 void Foam::writeFuns::write
132     std::ostream& os,
133     const bool binary,
134     const GeometricField<Type, fvPatchField, volMesh>& vvf,
135     const GeometricField<Type, pointPatchField, pointMesh>& pvf,
136     const vtkMesh& vMesh
139     const fvMesh& mesh = vMesh.mesh();
140     const vtkTopo& topo = vMesh.topo();
142     const labelList& addPointCellLabels = topo.addPointCellLabels();
143     const label nTotPoints = mesh.nPoints() + addPointCellLabels.size();
145     os  << vvf.name() << ' ' << pTraits<Type>::nComponents << ' '
146         << nTotPoints << " float" << std::endl;
148     DynamicList<floatScalar> fField(pTraits<Type>::nComponents*nTotPoints);
150     insert(pvf, fField);
152     forAll(addPointCellLabels, api)
153     {
154         label origCellI = addPointCellLabels[api];
156         insert(vvf[origCellI], fField);
157     }
158     write(os, binary, fField);
162 template<class Type, template<class> class PatchField, class GeoMesh>
163 void Foam::writeFuns::write
165     std::ostream& os,
166     const bool binary,
167     const PtrList<GeometricField<Type, PatchField, GeoMesh> >& flds,
168     const vtkMesh& vMesh
171     forAll(flds, i)
172     {
173         write(os, binary, flds[i], vMesh);
174     }
178 template<class Type>
179 void Foam::writeFuns::write
181     std::ostream& os,
182     const bool binary,
183     const volPointInterpolation& pInterp,
184     const PtrList<GeometricField<Type, fvPatchField, volMesh> >& flds,
185     const vtkMesh& vMesh
188     forAll(flds, i)
189     {
190         write(os, binary, flds[i], pInterp.interpolate(flds[i])(), vMesh);
191     }
195 // ************************************************************************* //