writeFuns.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2018 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 "floatScalar.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<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
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<floatScalar>&);
99  static void insert(const point&, DynamicList<floatScalar>&);
100  static void insert(const sphericalTensor&, DynamicList<floatScalar>&);
101  static void insert(const symmTensor&, DynamicList<floatScalar>&);
102  static void insert(const tensor&, DynamicList<floatScalar>&);
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<floatScalar>&);
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 GeometricField<Type, fvPatchField, 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 GeometricField<Type, fvPatchField, volMesh>&,
139  const GeometricField<Type, pointPatchField, 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  //- Interpolate and write volFields
154  template<class Type>
155  static void write
156  (
157  std::ostream&,
158  const bool binary,
159  const volPointInterpolation&,
160  const PtrList<GeometricField<Type, fvPatchField, volMesh>>&,
161  const vtkMesh&
162  );
163 };
164 
165 
166 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
167 
168 } // End namespace Foam
169 
170 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
171 
172 #ifdef NoRepository
173  #include "writeFunsTemplates.C"
174 #endif
175 
176 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
177 
178 #endif
179 
180 // ************************************************************************* //
static void writeCellDataHeader(std::ostream &, const label nCells, const label nFields)
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
static void writeHeader(std::ostream &, const bool isBinary, const std::string &title)
static void insert(const point &, DynamicList< floatScalar > &dest)
Append point to given DynamicList.
SymmTensor< scalar > symmTensor
SymmTensor of scalars.
Definition: symmTensor.H:48
label nPoints
List< label > labelList
A List of labels.
Definition: labelList.H:56
static void write(std::ostream &, const bool, DynamicList< floatScalar > &)
Write floats ascii or binary.
vector point
Point is a vector.
Definition: point.H:41
SphericalTensor< scalar > sphericalTensor
SphericalTensor of scalars.
Tensor< scalar > tensor
Tensor of scalars.
Definition: tensor.H:51
static void writePointDataHeader(std::ostream &, const label nPoints, const label nFields)
Namespace for OpenFOAM.