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 "writeFuns.H"
27 #include "interpolatePointToCell.H"
29 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
33 void Foam::writeFuns::insert
35 const List<Type>& source,
36 DynamicList<floatScalar>& dest
41 insert(source[i], dest);
46 //// Store List (indexed through map) in dest
47 //template<class Type>
48 //void Foam::writeFuns::insert
50 // const labelList& map,
51 // const List<Type>& source,
52 // DynamicList<floatScalar>& dest
57 // insert(source[map[i]], dest);
63 void Foam::writeFuns::write
67 const GeometricField<Type, fvPatchField, volMesh>& vvf,
71 const fvMesh& mesh = vMesh.mesh();
73 const labelList& superCells = vMesh.topo().superCells();
75 label nValues = mesh.nCells() + superCells.size();
77 os << vvf.name() << ' ' << pTraits<Type>::nComponents << ' '
78 << nValues << " float" << std::endl;
80 DynamicList<floatScalar> fField(pTraits<Type>::nComponents*nValues);
82 insert(vvf.internalField(), fField);
84 forAll(superCells, superCellI)
86 label origCellI = superCells[superCellI];
88 insert(vvf[origCellI], fField);
90 write(os, binary, fField);
95 void Foam::writeFuns::write
99 const GeometricField<Type, pointPatchField, pointMesh>& pvf,
103 const fvMesh& mesh = vMesh.mesh();
104 const vtkTopo& topo = vMesh.topo();
106 const labelList& addPointCellLabels = topo.addPointCellLabels();
107 const label nTotPoints = mesh.nPoints() + addPointCellLabels.size();
109 os << pvf.name() << ' ' << pTraits<Type>::nComponents << ' '
110 << nTotPoints << " float" << std::endl;
112 DynamicList<floatScalar> fField(pTraits<Type>::nComponents*nTotPoints);
116 forAll(addPointCellLabels, api)
118 label origCellI = addPointCellLabels[api];
120 insert(interpolatePointToCell(pvf, origCellI), fField);
122 write(os, binary, fField);
127 void Foam::writeFuns::write
131 const GeometricField<Type, fvPatchField, volMesh>& vvf,
132 const GeometricField<Type, pointPatchField, pointMesh>& pvf,
136 const fvMesh& mesh = vMesh.mesh();
137 const vtkTopo& topo = vMesh.topo();
139 const labelList& addPointCellLabels = topo.addPointCellLabels();
140 const label nTotPoints = mesh.nPoints() + addPointCellLabels.size();
142 os << vvf.name() << ' ' << pTraits<Type>::nComponents << ' '
143 << nTotPoints << " float" << std::endl;
145 DynamicList<floatScalar> fField(pTraits<Type>::nComponents*nTotPoints);
149 forAll(addPointCellLabels, api)
151 label origCellI = addPointCellLabels[api];
153 insert(vvf[origCellI], fField);
155 write(os, binary, fField);
159 template<class Type, template<class> class PatchField, class GeoMesh>
160 void Foam::writeFuns::write
164 const PtrList<GeometricField<Type, PatchField, GeoMesh> >& flds,
170 write(os, binary, flds[i], vMesh);
176 void Foam::writeFuns::write
180 const volPointInterpolation& pInterp,
181 const PtrList<GeometricField<Type, fvPatchField, volMesh> >& flds,
187 write(os, binary, flds[i], pInterp.interpolate(flds[i])(), vMesh);
192 // ************************************************************************* //