1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | foam-extend: Open Source CFD
4 \\ / O peration | Version: 3.2
5 \\ / A nd | Web: http://www.foam-extend.org
6 \\/ M anipulation | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
9 This file is part of foam-extend.
11 foam-extend 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 3 of the License, or (at your
14 option) any later version.
16 foam-extend is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
26 \*---------------------------------------------------------------------------*/
28 #include "writeFuns.H"
29 #include "interpolatePointToCell.H"
31 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
35 void Foam::writeFuns::insert
37 const List<Type>& source,
38 DynamicList<floatScalar>& dest
43 insert(source[i], dest);
48 //// Store List (indexed through map) in dest
49 //template<class Type>
50 //void Foam::writeFuns::insert
52 // const labelList& map,
53 // const List<Type>& source,
54 // DynamicList<floatScalar>& dest
59 // insert(source[map[i]], dest);
65 void Foam::writeFuns::write
69 const GeometricField<Type, fvPatchField, volMesh>& vvf,
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)
88 label origCellI = superCells[superCellI];
90 insert(vvf[origCellI], fField);
92 write(os, binary, fField);
97 void Foam::writeFuns::write
101 const GeometricField<Type, pointPatchField, pointMesh>& pvf,
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);
118 forAll(addPointCellLabels, api)
120 label origCellI = addPointCellLabels[api];
122 insert(interpolatePointToCell(pvf, origCellI), fField);
124 write(os, binary, fField);
129 void Foam::writeFuns::write
133 const GeometricField<Type, fvPatchField, volMesh>& vvf,
134 const GeometricField<Type, pointPatchField, pointMesh>& pvf,
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);
151 forAll(addPointCellLabels, api)
153 label origCellI = addPointCellLabels[api];
155 insert(vvf[origCellI], fField);
157 write(os, binary, fField);
161 template<class Type, template<class> class PatchField, class GeoMesh>
162 void Foam::writeFuns::write
166 const PtrList<GeometricField<Type, PatchField, GeoMesh> >& flds,
172 write(os, binary, flds[i], vMesh);
178 void Foam::writeFuns::write
182 const volPointInterpolation& pInterp,
183 const PtrList<GeometricField<Type, fvPatchField, volMesh> >& flds,
189 write(os, binary, flds[i], pInterp.interpolate(flds[i])(), vMesh);
194 // ************************************************************************* //