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-2019 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  The LITTLE_ENDIAN is based on 32bit words.
31  It is not clear how 64bit labels should be handled, currently they are
32  split into two 32bit words and swapWord applied to these two.
33 
34  writeFuns should be a namespace rather than a class.
35 
36 SourceFiles
37  writeFuns.C
38 
39 \*---------------------------------------------------------------------------*/
40 
41 #ifndef writeFuns_H
42 #define writeFuns_H
43 
44 #include "labelList.H"
45 #include "floatScalar.H"
46 #include "OFstream.H"
47 #include "DynamicList.H"
48 #include "point.H"
49 
50 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
51 
52 namespace Foam
53 {
54 
55 /*---------------------------------------------------------------------------*\
56  Class writeFuns Declaration
57 \*---------------------------------------------------------------------------*/
58 
59 class writeFuns
60 {
61  // Private Member Functions
62 
63  //- Swap halves of word
64  static void swapWord(int32_t& word32);
65 
66  //- Swap halves of word
67  static void swapWords(const label nWords, int32_t* words32);
68 
69 
70 public:
71 
72  //- Write floats ascii or binary.
73  // If binary optionally in-place swaps argument
74  static void write(std::ostream&, const bool, DynamicList<floatScalar>&);
75 
76  //- Write labels ascii or binary.
77  // If binary optionally in-place swaps argument
78  static void write(std::ostream&, const bool, DynamicList<label>&);
79 
80  //- Write floats ascii or binary.
81  // If binary optionally in-place swaps argument
82  static void write(std::ostream&, const bool, List<floatScalar>&);
83 
84  //- Write labels ascii or binary.
85  // If binary optionally in-place swaps argument
86  static void write(std::ostream&, const bool, labelList&);
87 
88  //- Append point to given DynamicList
89  static void insert(const point&, DynamicList<floatScalar>& dest);
90 
91  //- Append elements of labelList to given DynamicList
92  static void insert(const labelList&, DynamicList<label>&);
93 
94  //- Append elements of scalarList to given DynamicList
95  static void insert(const List<scalar>&, DynamicList<floatScalar>&);
96 
97  //- Append elements of scalarList to given DynamicList using map
98  static void insert
99  (
100  const labelList& map,
101  const List<scalar>& source,
103  );
104 
105  //- Append points to given DynamicList of floats
106  static void insert(const List<point>& source, DynamicList<floatScalar>&);
107 
108  //- Append points to given DynamicList of floats using map
109  static void insert
110  (
111  const labelList& map,
112  const List<point>& source,
114  );
115 };
116 
117 
118 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
119 
120 } // End namespace Foam
121 
122 
123 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
124 
125 #endif
126 
127 // ************************************************************************* //
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
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
static void insert(const point &, DynamicList< floatScalar > &dest)
Append point to given DynamicList.
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects...
Definition: DynamicList.H:56
static void write(std::ostream &, const bool, DynamicList< floatScalar > &)
Write floats ascii or binary.
Various functions for collecting and writing binary data.
Definition: writeFuns.H:58
Namespace for OpenFOAM.