26 #include "writeFuns.H" 30 #include <standards.h> 31 #include <sys/endian.h> 35 #ifdef __DARWIN_BYTE_ORDER 36 #if __DARWIN_BYTE_ORDER==__DARWIN_BIG_ENDIAN 43 #if defined(LITTLE_ENDIAN) \ 44 || defined(_LITTLE_ENDIAN) \ 45 || defined(__LITTLE_ENDIAN) 46 #define LITTLEENDIAN 1 47 #elif defined(BIG_ENDIAN) || defined(_BIG_ENDIAN) || defined(__BIG_ENDIAN) 50 #error "Cannot find LITTLE_ENDIAN or BIG_ENDIAN symbol defined." 51 #error "Please add to compilation options" 56 void Foam::writeFuns::swapWord(
label& word32)
58 char* mem =
reinterpret_cast<char*
>(&word32);
70 void Foam::writeFuns::swapWords(
const label nWords,
label* words32)
72 for (
label i = 0; i < nWords; i++)
83 List<floatScalar>& fField
89 swapWords(fField.size(),
reinterpret_cast<label*
>(fField.begin()));
93 reinterpret_cast<char*>(fField.begin()),
94 fField.size()*
sizeof(float)
105 if (i > 0 && (i % 10) == 0)
123 DynamicList<floatScalar>& fField
126 List<floatScalar>& fld = fField.shrink();
128 write(os, binary, fld);
142 swapWords(elems.size(),
reinterpret_cast<label*
>(elems.begin()));
146 reinterpret_cast<char*>(elems.begin()),
147 elems.size()*
sizeof(
label)
158 if (i > 0 && (i % 10) == 0)
176 DynamicList<label>& elems
181 write(os, binary, fld);
189 const std::string& title
192 os <<
"# vtk DataFile Version 2.0" << std::endl
213 os <<
"CELL_DATA " << nCells << std::endl
214 <<
"FIELD attributes " << nFields <<
std::endl;
225 os <<
"POINT_DATA " << nPoints << std::endl
226 <<
"FIELD attributes " << nFields <<
std::endl;
232 dest.append(
float(src));
240 dest.append(
float(src[cmpt]));
248 DynamicList<floatScalar>& dest
253 dest.append(
float(src[cmpt]));
261 DynamicList<floatScalar>& dest
264 dest.append(
float(src.xx()));
265 dest.append(
float(src.yy()));
266 dest.append(
float(src.zz()));
267 dest.append(
float(src.xy()));
268 dest.append(
float(src.yz()));
269 dest.append(
float(src.xz()));
277 dest.append(
float(src[cmpt]));
static void writeCellDataHeader(std::ostream &, const label nCells, const label nFields)
#define forAll(list, i)
Loop across all elements in list.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
static void writeHeader(std::ostream &, const bool isBinary, const std::string &title)
Ostream & endl(Ostream &os)
Add newline and flush stream.
static void insert(const point &, DynamicList< floatScalar > &dest)
Append point to given DynamicList.
Vector< scalar > vector
A scalar version of the templated Vector.
static const direction nComponents
Number of components in this vector space.
SymmTensor< scalar > symmTensor
SymmTensor of scalars.
List< label > labelList
A List of labels.
static void write(std::ostream &, const bool, DynamicList< floatScalar > &)
Write floats ascii or binary.
SphericalTensor< scalar > sphericalTensor
SphericalTensor of scalars.
Tensor< scalar > tensor
Tensor of scalars.
static void writePointDataHeader(std::ostream &, const label nPoints, const label nFields)