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) 2011-2015 OpenFOAM Foundation
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 "doubleScalar.H"
39 #include "DynamicList.H"
40 #include "volFieldsFwd.H"
41 #include "pointFieldsFwd.H"
42 #include "vtkMesh.H"
43 #include "volPointInterpolation.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<doubleScalar>&);
69  static void write(std::ostream&, const bool, DynamicList<doubleScalar>&);
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
77  (
78  std::ostream&,
79  const bool isBinary,
80  const std::string& title
81  );
82  static void writeCellDataHeader
83  (
84  std::ostream&,
85  const label nCells,
86  const label nFields
87  );
88  static void writePointDataHeader
89  (
90  std::ostream&,
91  const label nPoints,
92  const label nFields
93  );
94 
95 
96  // Convert to VTK and store
97 
98  static void insert(const scalar, DynamicList<doubleScalar>&);
99  static void insert(const point&, DynamicList<doubleScalar>&);
100  static void insert(const sphericalTensor&, DynamicList<doubleScalar>&);
101  static void insert(const symmTensor&, DynamicList<doubleScalar>&);
102  static void insert(const tensor&, DynamicList<doubleScalar>&);
103 
104 
105  //- Append elements to DynamicList
106  static void insert(const labelList&, DynamicList<label>&);
107  template<class Type>
108  static void insert(const List<Type>&, DynamicList<doubleScalar>&);
109 
110  //- Write volField with cell values (including decomposed cells)
111  template<class Type>
112  static void write
113  (
114  std::ostream&,
115  const bool binary,
116  const DimensionedField<Type, volMesh>&,
117  const vtkMesh&
118  );
119 
120  //- Write pointField on all mesh points. Interpolate to cell centre
121  // for decomposed cell centres.
122  template<class Type>
123  static void write
124  (
125  std::ostream&,
126  const bool binary,
127  const GeometricField<Type, pointPatchField, pointMesh>&,
128  const vtkMesh&
129  );
130 
131  //- Write interpolated field on points and original cell values on
132  // decomposed cell centres.
133  template<class Type>
134  static void write
135  (
136  std::ostream&,
137  const bool binary,
138  const DimensionedField<Type, volMesh>&,
139  const DimensionedField<Type, pointMesh>&,
140  const vtkMesh&
141  );
142 
143  //- Write generic GeometricFields
144  template<class Type, template<class> class PatchField, class GeoMesh>
145  static void write
146  (
147  std::ostream&,
148  const bool binary,
149  const PtrList<GeometricField<Type, PatchField, GeoMesh> >&,
150  const vtkMesh&
151  );
152 
153  //- Write generic dimensioned internal fields
154  template<class Type>
155  static void write
156  (
157  std::ostream&,
158  const bool binary,
159  const PtrList<DimensionedField<Type, volMesh> >&,
160  const vtkMesh&
161  );
162 
163  //- Interpolate and write volFields
164  template<class Type>
165  static void write
166  (
167  std::ostream&,
168  const bool binary,
169  const volPointInterpolation&,
170  const PtrList<GeometricField<Type, fvPatchField, volMesh> >&,
171  const vtkMesh&
172  );
173 };
174 
175 
176 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
177 
178 } // End namespace Foam
179 
180 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
181 
182 #ifdef NoRepository
183  #include "writeFunsTemplates.C"
184 #endif
185 
186 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
187 
188 #endif
189 
190 // ************************************************************************* //
volFieldsFwd.H
Foam::sphericalTensor
SphericalTensor< scalar > sphericalTensor
SphericalTensor of scalars.
Definition: sphericalTensor.H:48
Foam::writeFuns::writeCellDataHeader
static void writeCellDataHeader(std::ostream &, const label nCells, const label nFields)
Definition: writeFuns.C:211
Foam::labelList
List< label > labelList
A List of labels.
Definition: labelList.H:56
Foam::tensor
Tensor< scalar > tensor
Tensor of scalars.
Definition: tensor.H:51
Foam::writeFuns::writePointDataHeader
static void writePointDataHeader(std::ostream &, const label nPoints, const label nFields)
Definition: writeFuns.C:223
nPoints
label nPoints
Definition: gmvOutputHeader.H:2
Foam::writeFuns::writeHeader
static void writeHeader(std::ostream &, const bool isBinary, const std::string &title)
Definition: writeFuns.C:190
doubleScalar.H
Foam::label
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
Foam::writeFuns::write
static void write(std::ostream &, const bool, DynamicList< floatScalar > &)
Write floats ascii or binary.
Definition: writeFuns.C:107
Foam::symmTensor
SymmTensor< scalar > symmTensor
SymmTensor of scalars.
Definition: symmTensor.H:48
Foam::writeFuns::swapWord
static void swapWord(int32_t &word32)
Swap halves of word.
Definition: writeFuns.C:46
vtkMesh.H
Foam::writeFuns::swapWords
static void swapWords(const label nWords, int32_t *words32)
Swap halves of word.
Definition: writeFuns.C:60
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
volPointInterpolation.H
pointFieldsFwd.H
List
Definition: Test.C:19
DynamicList.H
Foam::point
vector point
Point is a vector.
Definition: point.H:41
Foam::writeFuns::insert
static void insert(const point &, DynamicList< floatScalar > &dest)
Append point to given DynamicList.
Definition: writeFuns.C:170