FreeFOAM The Cross-Platform CFD Toolkit
writeFuns.H
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 Class
25  Foam::writeFuns
26 
27 Description
28  Various functions for collecting and writing binary data.
29 
30 SourceFiles
31  writeFuns.C
32 
33 \*---------------------------------------------------------------------------*/
34 
35 #ifndef writeFuns_H
36 #define writeFuns_H
37 
38 #include <OpenFOAM/floatScalar.H>
39 #include <OpenFOAM/DynamicList.H>
42 #include "vtkMesh.H"
44 
45 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
46 
47 namespace Foam
48 {
49 
50 /*---------------------------------------------------------------------------*\
51  Class writeFuns Declaration
52 \*---------------------------------------------------------------------------*/
53 
54 class writeFuns
55 {
56  // Private member functions
57 
58  // Swap halves of word.
59 
60  static void swapWord(label& word32);
61  static void swapWords(const label nWords, label* words32);
62 
63 
64 public:
65 
66  // Write ascii or binary. If binary optionally in-place swaps argument
67 
68  static void write(std::ostream&, const bool, List<floatScalar>&);
69  static void write(std::ostream&, const bool, DynamicList<floatScalar>&);
70  static void write(std::ostream&, const bool, labelList&);
71  static void write(std::ostream&, const bool, DynamicList<label>&);
72 
73 
74  // Write header
75 
76  static void writeHeader(std::ostream&, const bool, const string&);
77  static void writeCellDataHeader(std::ostream&, const label, const label);
78  static void writePointDataHeader
79  (
80  std::ostream&,
81  const label,
82  const label
83  );
84 
85 
86  // Convert to VTK and store
87 
88  static void insert(const scalar&, DynamicList<floatScalar>&);
89  static void insert(const point&, DynamicList<floatScalar>&);
90  static void insert(const sphericalTensor&, DynamicList<floatScalar>&);
91  static void insert(const symmTensor&, DynamicList<floatScalar>&);
92  static void insert(const tensor&, DynamicList<floatScalar>&);
93 
94 
95  //- Append elements to DynamicList
96  static void insert(const labelList&, DynamicList<label>&);
97  template<class Type>
98  static void insert(const List<Type>&, DynamicList<floatScalar>&);
99 
100  //- Write volField with cell values (including decomposed cells)
101  template<class Type>
102  static void write
103  (
104  std::ostream&,
105  const bool binary,
106  const GeometricField<Type, fvPatchField, volMesh>&,
107  const vtkMesh&
108  );
109 
110  //- Write pointField on all mesh points. Interpolate to cell centre
111  // for decomposed cell centres.
112  template<class Type>
113  static void write
114  (
115  std::ostream&,
116  const bool binary,
117  const GeometricField<Type, pointPatchField, pointMesh>&,
118  const vtkMesh&
119  );
120 
121  //- Write interpolated field on points and original cell values on
122  // decomposed cell centres.
123  template<class Type>
124  static void write
125  (
126  std::ostream&,
127  const bool binary,
128  const GeometricField<Type, fvPatchField, volMesh>&,
129  const GeometricField<Type, pointPatchField, pointMesh>&,
130  const vtkMesh&
131  );
132 
133  //- Write generic GeometricFields
134  template<class Type, template<class> class PatchField, class GeoMesh>
135  static void write
136  (
137  std::ostream&,
138  const bool binary,
139  const PtrList<GeometricField<Type, PatchField, GeoMesh> >&,
140  const vtkMesh&
141  );
142 
143  //- Interpolate and write volFields
144  template<class Type>
145  static void write
146  (
147  std::ostream&,
148  const bool binary,
149  const volPointInterpolation&,
150  const PtrList<GeometricField<Type, fvPatchField, volMesh> >&,
151  const vtkMesh&
152  );
153 };
154 
155 
156 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
157 
158 } // End namespace Foam
159 
160 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
161 
162 #ifdef NoRepository
163 # include "writeFunsTemplates.C"
164 #endif
165 
166 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
167 
168 #endif
169 
170 // ************************ vim: set sw=4 sts=4 et: ************************ //