FreeFOAM The Cross-Platform CFD Toolkit
writeFunsTemplates.C
Go to the documentation of this file.
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.
10 
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.
15 
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.
20 
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/>.
23 
24 Description
25 
26 \*---------------------------------------------------------------------------*/
27 
28 #include "writeFuns.H"
30 
31 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
32 
33 // Store List in dest
34 template<class Type>
36 (
37  const List<Type>& source,
38  DynamicList<floatScalar>& dest
39 )
40 {
41  forAll(source, i)
42  {
43  insert(source[i], dest);
44  }
45 }
46 
47 
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 //}
62 
63 
64 template<class Type>
66 (
67  std::ostream& os,
68  const bool binary,
69  const GeometricField<Type, fvPatchField, volMesh>& vvf,
70  const vtkMesh& vMesh
71 )
72 {
73  const fvMesh& mesh = vMesh.mesh();
74 
75  const labelList& superCells = vMesh.topo().superCells();
76 
77  label nValues = mesh.nCells() + superCells.size();
78 
79  os << vvf.name() << ' ' << pTraits<Type>::nComponents << ' '
80  << nValues << " float" << std::endl;
81 
82  DynamicList<floatScalar> fField(pTraits<Type>::nComponents*nValues);
83 
84  insert(vvf.internalField(), fField);
85 
86  forAll(superCells, superCellI)
87  {
88  label origCellI = superCells[superCellI];
89 
90  insert(vvf[origCellI], fField);
91  }
92  write(os, binary, fField);
93 }
94 
95 
96 template<class Type>
98 (
99  std::ostream& os,
100  const bool binary,
101  const GeometricField<Type, pointPatchField, pointMesh>& pvf,
102  const vtkMesh& vMesh
103 )
104 {
105  const fvMesh& mesh = vMesh.mesh();
106  const vtkTopo& topo = vMesh.topo();
107 
108  const labelList& addPointCellLabels = topo.addPointCellLabels();
109  const label nTotPoints = mesh.nPoints() + addPointCellLabels.size();
110 
111  os << pvf.name() << ' ' << pTraits<Type>::nComponents << ' '
112  << nTotPoints << " float" << std::endl;
113 
114  DynamicList<floatScalar> fField(pTraits<Type>::nComponents*nTotPoints);
115 
116  insert(pvf, fField);
117 
118  forAll(addPointCellLabels, api)
119  {
120  label origCellI = addPointCellLabels[api];
121 
122  insert(interpolatePointToCell(pvf, origCellI), fField);
123  }
124  write(os, binary, fField);
125 }
126 
127 
128 template<class Type>
130 (
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
136 )
137 {
138  const fvMesh& mesh = vMesh.mesh();
139  const vtkTopo& topo = vMesh.topo();
140 
141  const labelList& addPointCellLabels = topo.addPointCellLabels();
142  const label nTotPoints = mesh.nPoints() + addPointCellLabels.size();
143 
144  os << vvf.name() << ' ' << pTraits<Type>::nComponents << ' '
145  << nTotPoints << " float" << std::endl;
146 
147  DynamicList<floatScalar> fField(pTraits<Type>::nComponents*nTotPoints);
148 
149  insert(pvf, fField);
150 
151  forAll(addPointCellLabels, api)
152  {
153  label origCellI = addPointCellLabels[api];
154 
155  insert(vvf[origCellI], fField);
156  }
157  write(os, binary, fField);
158 }
159 
160 
161 template<class Type, template<class> class PatchField, class GeoMesh>
163 (
164  std::ostream& os,
165  const bool binary,
166  const PtrList<GeometricField<Type, PatchField, GeoMesh> >& flds,
167  const vtkMesh& vMesh
168 )
169 {
170  forAll(flds, i)
171  {
172  write(os, binary, flds[i], vMesh);
173  }
174 }
175 
176 
177 template<class Type>
179 (
180  std::ostream& os,
181  const bool binary,
182  const volPointInterpolation& pInterp,
183  const PtrList<GeometricField<Type, fvPatchField, volMesh> >& flds,
184  const vtkMesh& vMesh
185 )
186 {
187  forAll(flds, i)
188  {
189  write(os, binary, flds[i], pInterp.interpolate(flds[i])(), vMesh);
190  }
191 }
192 
193 
194 // ************************ vim: set sw=4 sts=4 et: ************************ //