1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright held by original author
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 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
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
27 \*---------------------------------------------------------------------------*/
29 #include "writeFuns.H"
30 #include "interpolatePointToCell.H"
32 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
36 void Foam::writeFuns::insert
38 const List<Type>& source,
39 DynamicList<floatScalar>& dest
44 insert(source[i], dest);
49 //// Store List (indexed through map) in dest
50 //template<class Type>
51 //void Foam::writeFuns::insert
53 // const labelList& map,
54 // const List<Type>& source,
55 // DynamicList<floatScalar>& dest
60 // insert(source[map[i]], dest);
66 void Foam::writeFuns::write
70 const GeometricField<Type, fvPatchField, volMesh>& vvf,
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)
89 label origCellI = superCells[superCellI];
91 insert(vvf[origCellI], fField);
93 write(os, binary, fField);
98 void Foam::writeFuns::write
102 const GeometricField<Type, pointPatchField, pointMesh>& pvf,
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);
119 forAll(addPointCellLabels, api)
121 label origCellI = addPointCellLabels[api];
123 insert(interpolatePointToCell(pvf, origCellI), fField);
125 write(os, binary, fField);
130 void Foam::writeFuns::write
134 const GeometricField<Type, fvPatchField, volMesh>& vvf,
135 const GeometricField<Type, pointPatchField, pointMesh>& pvf,
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);
152 forAll(addPointCellLabels, api)
154 label origCellI = addPointCellLabels[api];
156 insert(vvf[origCellI], fField);
158 write(os, binary, fField);
162 template<class Type, template<class> class PatchField, class GeoMesh>
163 void Foam::writeFuns::write
167 const PtrList<GeometricField<Type, PatchField, GeoMesh> >& flds,
173 write(os, binary, flds[i], vMesh);
179 void Foam::writeFuns::write
183 const volPointInterpolation& pInterp,
184 const PtrList<GeometricField<Type, fvPatchField, volMesh> >& flds,
190 write(os, binary, flds[i], pInterp.interpolate(flds[i])(), vMesh);
195 // ************************************************************************* //