mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: rationalize VTK output classes and structures
- relocated to dedicated foamVtkOutput namespace. Make it easier to obtain a formatter directly without a foamVtkOutput::outputOptions. Make the logic clear within outputOptions (avoid previous, cryptic bit masking). foamVtkOutput::legacy also becomes a namespace instead of a class. Relocate commonly used things into src/fileFormats, leave volField-related parts in src/conversion.
This commit is contained in:
@ -27,6 +27,5 @@ polyDualMesh/polyDualMesh.C
|
|||||||
vtk/part/foamVtkCells.C
|
vtk/part/foamVtkCells.C
|
||||||
vtk/part/foamVtkMeshMaps.C
|
vtk/part/foamVtkMeshMaps.C
|
||||||
vtk/part/foamVtuSizing.C
|
vtk/part/foamVtuSizing.C
|
||||||
vtk/output/foamVtkOutput.C
|
|
||||||
|
|
||||||
LIB = $(FOAM_LIBBIN)/libconversion
|
LIB = $(FOAM_LIBBIN)/libconversion
|
||||||
|
|||||||
@ -1,231 +0,0 @@
|
|||||||
/*---------------------------------------------------------------------------*\
|
|
||||||
========= |
|
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
|
||||||
\\ / O peration |
|
|
||||||
\\ / A nd | Copyright (C) 2016-2107 OpenCFD Ltd.
|
|
||||||
\\/ M anipulation |
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
License
|
|
||||||
This file is part of OpenFOAM.
|
|
||||||
|
|
||||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
|
||||||
under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
|
||||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
||||||
for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
Class
|
|
||||||
foamVtkOutput
|
|
||||||
|
|
||||||
Description
|
|
||||||
A collection of functions for writing vtk file content.
|
|
||||||
|
|
||||||
SourceFiles
|
|
||||||
foamVtkOutput.C
|
|
||||||
foamVtkOutputTemplates.C
|
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
#ifndef foamVtkOutput_H
|
|
||||||
#define foamVtkOutput_H
|
|
||||||
|
|
||||||
#include "floatScalar.H"
|
|
||||||
#include "volFields.H"
|
|
||||||
#include "foamVtkFormatter.H"
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
namespace Foam
|
|
||||||
{
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*\
|
|
||||||
Class foamVtkOutput Declaration
|
|
||||||
\*---------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
class foamVtkOutput
|
|
||||||
{
|
|
||||||
// Private Member Functions
|
|
||||||
|
|
||||||
//- Disallow construction
|
|
||||||
foamVtkOutput() = delete;
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
// Public typedefs
|
|
||||||
|
|
||||||
//- Use UInt64 for header data
|
|
||||||
typedef foamVtkFormatter::headerType headerType;
|
|
||||||
|
|
||||||
|
|
||||||
// Forward declarations
|
|
||||||
class legacy;
|
|
||||||
|
|
||||||
|
|
||||||
// Static Members
|
|
||||||
|
|
||||||
//- Write vtm datasets for specified files
|
|
||||||
static Foam::label writeVtmFile
|
|
||||||
(
|
|
||||||
std::ostream& os,
|
|
||||||
const UList<fileName>& files
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
//- Write a value component-wise.
|
|
||||||
template<class Type>
|
|
||||||
inline static void write(foamVtkFormatter& fmt, const Type& val);
|
|
||||||
|
|
||||||
|
|
||||||
//- Write a list of values.
|
|
||||||
// The output does not include the payload size.
|
|
||||||
template<class Type>
|
|
||||||
static void writeList
|
|
||||||
(
|
|
||||||
foamVtkFormatter& fmt,
|
|
||||||
const UList<Type>& lst
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
//- Write a list of values via indirect addressing.
|
|
||||||
// The output does not include the payload size.
|
|
||||||
template<class Type>
|
|
||||||
static void writeList
|
|
||||||
(
|
|
||||||
foamVtkFormatter& fmt,
|
|
||||||
const UList<Type>& lst,
|
|
||||||
const UList<label>& addressing
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
//- Write internalField for mesh
|
|
||||||
// The output includes the payload size and flush.
|
|
||||||
template<class Type>
|
|
||||||
static void writeField
|
|
||||||
(
|
|
||||||
foamVtkFormatter& fmt,
|
|
||||||
const GeometricField<Type, fvPatchField, volMesh>& vf
|
|
||||||
);
|
|
||||||
|
|
||||||
//- Write internalField based on the cellMap
|
|
||||||
// The output includes the payload size and flush.
|
|
||||||
template<class Type>
|
|
||||||
static void writeField
|
|
||||||
(
|
|
||||||
foamVtkFormatter& fmt,
|
|
||||||
const GeometricField<Type, fvPatchField, volMesh>& vf,
|
|
||||||
const UList<label>& cellMap
|
|
||||||
);
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*\
|
|
||||||
Class foamVtkOutput::legacy Declaration
|
|
||||||
\*---------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
//- Basic support for legacy files
|
|
||||||
class foamVtkOutput::legacy
|
|
||||||
{
|
|
||||||
// Private Member Functions
|
|
||||||
|
|
||||||
//- Disallow construction
|
|
||||||
legacy() = delete;
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
// Static data members
|
|
||||||
|
|
||||||
//- file extension for legacy files (vtk)
|
|
||||||
static const Foam::word EXT;
|
|
||||||
|
|
||||||
|
|
||||||
// Static Members
|
|
||||||
|
|
||||||
//- Emit header for legacy file
|
|
||||||
static std::ostream& writeHeader
|
|
||||||
(
|
|
||||||
std::ostream&,
|
|
||||||
const std::string& title,
|
|
||||||
const bool binary = false
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
//- Emit header for legacy CELL_DATA
|
|
||||||
static std::ostream& writeCellDataHeader
|
|
||||||
(
|
|
||||||
std::ostream& os,
|
|
||||||
const label nCells,
|
|
||||||
const label nFields
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
//- Emit header for legacy POINT_DATA
|
|
||||||
static std::ostream& writePointDataHeader
|
|
||||||
(
|
|
||||||
std::ostream& os,
|
|
||||||
const label nPoints,
|
|
||||||
const label nFields
|
|
||||||
);
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
|
|
||||||
//- Template specialization for label
|
|
||||||
template<>
|
|
||||||
inline void Foam::foamVtkOutput::write<label>
|
|
||||||
(
|
|
||||||
foamVtkFormatter& fmt,
|
|
||||||
const label& val
|
|
||||||
)
|
|
||||||
{
|
|
||||||
fmt.write(val);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//- Template specialization for float
|
|
||||||
template<>
|
|
||||||
inline void Foam::foamVtkOutput::write<float>
|
|
||||||
(
|
|
||||||
foamVtkFormatter& fmt,
|
|
||||||
const float& val
|
|
||||||
)
|
|
||||||
{
|
|
||||||
fmt.write(val);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//- Template specialization for double
|
|
||||||
template<>
|
|
||||||
inline void Foam::foamVtkOutput::write<double>
|
|
||||||
(
|
|
||||||
foamVtkFormatter& fmt,
|
|
||||||
const double& val
|
|
||||||
)
|
|
||||||
{
|
|
||||||
fmt.write(val);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // End namespace Foam
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
#ifdef NoRepository
|
|
||||||
#include "foamVtkOutputTemplates.C"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
|
||||||
105
src/conversion/vtk/output/foamVtkOutputFields.H
Normal file
105
src/conversion/vtk/output/foamVtkOutputFields.H
Normal file
@ -0,0 +1,105 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2016-2107 OpenCFD Ltd.
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
InNamespace
|
||||||
|
Foam::foamVtkOutput
|
||||||
|
|
||||||
|
Description
|
||||||
|
Additional functions for writing fields in VTK format.
|
||||||
|
|
||||||
|
SourceFiles
|
||||||
|
foamVtkOutputFieldsTemplates.C
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef foamVtkOutputFields_H
|
||||||
|
#define foamVtkOutputFields_H
|
||||||
|
|
||||||
|
#include "foamVtkOutput.H"
|
||||||
|
#include "volFields.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
namespace foamVtkOutput
|
||||||
|
{
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
//- Write internalField for mesh
|
||||||
|
// The output includes the payload size and flush.
|
||||||
|
template<class Type>
|
||||||
|
void writeField
|
||||||
|
(
|
||||||
|
foamVtkOutput::formatter& fmt,
|
||||||
|
const GeometricField<Type, fvPatchField, volMesh>& fld
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Write internalField based on the cellMap
|
||||||
|
// The output includes the payload size and flush.
|
||||||
|
template<class Type>
|
||||||
|
void writeField
|
||||||
|
(
|
||||||
|
foamVtkOutput::formatter& fmt,
|
||||||
|
const GeometricField<Type, fvPatchField, volMesh>& fld,
|
||||||
|
const UList<label>& cellMap
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Write DimensionedField for mesh
|
||||||
|
// The output includes the payload size and flush.
|
||||||
|
template<class Type>
|
||||||
|
void writeField
|
||||||
|
(
|
||||||
|
foamVtkOutput::formatter& fmt,
|
||||||
|
const DimensionedField<Type, volMesh>& fld
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Write DimensionedField based on the cellMap
|
||||||
|
// The output includes the payload size and flush.
|
||||||
|
template<class Type>
|
||||||
|
void writeField
|
||||||
|
(
|
||||||
|
foamVtkOutput::formatter& fmt,
|
||||||
|
const DimensionedField<Type, volMesh>& fld,
|
||||||
|
const UList<label>& cellMap
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace foamVtkOutput
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#ifdef NoRepository
|
||||||
|
#include "foamVtkOutputFieldsTemplates.C"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
107
src/conversion/vtk/output/foamVtkOutputFieldsTemplates.C
Normal file
107
src/conversion/vtk/output/foamVtkOutputFieldsTemplates.C
Normal file
@ -0,0 +1,107 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2016-2107 OpenCFD Ltd.
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
void Foam::foamVtkOutput::writeField
|
||||||
|
(
|
||||||
|
foamVtkOutput::formatter& fmt,
|
||||||
|
const GeometricField<Type, fvPatchField, volMesh>& fld
|
||||||
|
)
|
||||||
|
{
|
||||||
|
const uint64_t payLoad =
|
||||||
|
(
|
||||||
|
fld.size() * pTraits<Type>::nComponents * sizeof(float)
|
||||||
|
);
|
||||||
|
|
||||||
|
fmt.writeSize(payLoad);
|
||||||
|
writeList(fmt, fld.internalField());
|
||||||
|
|
||||||
|
fmt.flush();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
void Foam::foamVtkOutput::writeField
|
||||||
|
(
|
||||||
|
foamVtkOutput::formatter& fmt,
|
||||||
|
const GeometricField<Type, fvPatchField, volMesh>& fld,
|
||||||
|
const UList<label>& cellMap
|
||||||
|
)
|
||||||
|
{
|
||||||
|
const uint64_t payLoad =
|
||||||
|
(
|
||||||
|
cellMap.size() * pTraits<Type>::nComponents * sizeof(float)
|
||||||
|
);
|
||||||
|
|
||||||
|
fmt.writeSize(payLoad);
|
||||||
|
writeList(fmt, fld.internalField(), cellMap);
|
||||||
|
|
||||||
|
fmt.flush();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
void Foam::foamVtkOutput::writeField
|
||||||
|
(
|
||||||
|
foamVtkOutput::formatter& fmt,
|
||||||
|
const DimensionedField<Type, volMesh>& fld
|
||||||
|
)
|
||||||
|
{
|
||||||
|
const uint64_t payLoad =
|
||||||
|
(
|
||||||
|
fld.size() * pTraits<Type>::nComponents * sizeof(float)
|
||||||
|
);
|
||||||
|
|
||||||
|
fmt.writeSize(payLoad);
|
||||||
|
writeList(fmt, fld);
|
||||||
|
|
||||||
|
fmt.flush();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
void Foam::foamVtkOutput::writeField
|
||||||
|
(
|
||||||
|
foamVtkOutput::formatter& fmt,
|
||||||
|
const DimensionedField<Type, volMesh>& fld,
|
||||||
|
const UList<label>& cellMap
|
||||||
|
)
|
||||||
|
{
|
||||||
|
const uint64_t payLoad =
|
||||||
|
(
|
||||||
|
cellMap.size() * pTraits<Type>::nComponents * sizeof(float)
|
||||||
|
);
|
||||||
|
|
||||||
|
fmt.writeSize(payLoad);
|
||||||
|
writeList(fmt, fld, cellMap);
|
||||||
|
|
||||||
|
fmt.flush();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -15,14 +15,16 @@ stl/STLReader.C
|
|||||||
stl/STLReaderASCII.L
|
stl/STLReaderASCII.L
|
||||||
|
|
||||||
vtk/foamVtkCore.C
|
vtk/foamVtkCore.C
|
||||||
vtk/format/foamVtkAppendBase64Formatter.C
|
vtk/format/foamVtkFormatter.C
|
||||||
vtk/format/foamVtkAppendRawFormatter.C
|
|
||||||
vtk/format/foamVtkAsciiFormatter.C
|
vtk/format/foamVtkAsciiFormatter.C
|
||||||
vtk/format/foamVtkBase64Formatter.C
|
vtk/format/foamVtkBase64Formatter.C
|
||||||
|
vtk/format/foamVtkAppendBase64Formatter.C
|
||||||
|
vtk/format/foamVtkAppendRawFormatter.C
|
||||||
vtk/format/foamVtkBase64Layer.C
|
vtk/format/foamVtkBase64Layer.C
|
||||||
vtk/format/foamVtkLegacyFormatter.C
|
vtk/format/foamVtkLegacyAsciiFormatter.C
|
||||||
vtk/format/foamVtkFormatter.C
|
vtk/format/foamVtkLegacyRawFormatter.C
|
||||||
vtk/format/foamVtkOutputOptions.C
|
vtk/output/foamVtkOutput.C
|
||||||
|
vtk/output/foamVtkOutputOptions.C
|
||||||
vtk/read/vtkUnstructuredReader.C
|
vtk/read/vtkUnstructuredReader.C
|
||||||
vtk/type/foamVtkPTraits.C
|
vtk/type/foamVtkPTraits.C
|
||||||
|
|
||||||
|
|||||||
@ -27,12 +27,12 @@ License
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
const char* Foam::foamVtkAppendBase64Formatter::name_ = "append";
|
const char* Foam::foamVtkOutput::appendBase64Formatter::name_ = "append";
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
Foam::foamVtkAppendBase64Formatter::foamVtkAppendBase64Formatter
|
Foam::foamVtkOutput::appendBase64Formatter::appendBase64Formatter
|
||||||
(
|
(
|
||||||
std::ostream& os
|
std::ostream& os
|
||||||
)
|
)
|
||||||
@ -43,7 +43,7 @@ Foam::foamVtkAppendBase64Formatter::foamVtkAppendBase64Formatter
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
Foam::foamVtkAppendBase64Formatter::~foamVtkAppendBase64Formatter()
|
Foam::foamVtkOutput::appendBase64Formatter::~appendBase64Formatter()
|
||||||
{
|
{
|
||||||
base64Layer::close();
|
base64Layer::close();
|
||||||
}
|
}
|
||||||
@ -51,7 +51,7 @@ Foam::foamVtkAppendBase64Formatter::~foamVtkAppendBase64Formatter()
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
const char* Foam::foamVtkAppendBase64Formatter::name() const
|
const char* Foam::foamVtkOutput::appendBase64Formatter::name() const
|
||||||
{
|
{
|
||||||
return name_;
|
return name_;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -22,7 +22,7 @@ License
|
|||||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
Class
|
Class
|
||||||
foamVtkAppendBase64Formatter
|
Foam::foamVtkOutput::appendBase64Formatter
|
||||||
|
|
||||||
Description
|
Description
|
||||||
Appended base-64 encoded binary output.
|
Appended base-64 encoded binary output.
|
||||||
@ -42,12 +42,14 @@ SourceFiles
|
|||||||
|
|
||||||
namespace Foam
|
namespace Foam
|
||||||
{
|
{
|
||||||
|
namespace foamVtkOutput
|
||||||
|
{
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*\
|
/*---------------------------------------------------------------------------*\
|
||||||
Class foamVtkAppendBase64Formatter Declaration
|
Class appendBase64Formatter Declaration
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
class foamVtkAppendBase64Formatter
|
class appendBase64Formatter
|
||||||
:
|
:
|
||||||
public foamVtkBase64Layer
|
public foamVtkBase64Layer
|
||||||
{
|
{
|
||||||
@ -59,10 +61,10 @@ class foamVtkAppendBase64Formatter
|
|||||||
// Private Member Functions
|
// Private Member Functions
|
||||||
|
|
||||||
//- Disallow default bitwise copy construct
|
//- Disallow default bitwise copy construct
|
||||||
foamVtkAppendBase64Formatter(const foamVtkAppendBase64Formatter&) = delete;
|
appendBase64Formatter(const appendBase64Formatter&) = delete;
|
||||||
|
|
||||||
//- Disallow default bitwise assignment
|
//- Disallow default bitwise assignment
|
||||||
void operator=(const foamVtkAppendBase64Formatter&) = delete;
|
void operator=(const appendBase64Formatter&) = delete;
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -70,15 +72,21 @@ public:
|
|||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
//- Construct and attach to an output stream
|
//- Construct and attach to an output stream
|
||||||
foamVtkAppendBase64Formatter(std::ostream& os);
|
appendBase64Formatter(std::ostream& os);
|
||||||
|
|
||||||
|
|
||||||
//- Destructor
|
//- Destructor
|
||||||
virtual ~foamVtkAppendBase64Formatter();
|
virtual ~appendBase64Formatter();
|
||||||
|
|
||||||
|
|
||||||
// Member Functions
|
// Member Functions
|
||||||
|
|
||||||
|
//- The output formatType is APPEND_BASE64.
|
||||||
|
virtual enum formatType format() const
|
||||||
|
{
|
||||||
|
return formatType::APPEND_BASE64;
|
||||||
|
}
|
||||||
|
|
||||||
//- Output name for XML type ("append")
|
//- Output name for XML type ("append")
|
||||||
virtual const char* name() const;
|
virtual const char* name() const;
|
||||||
|
|
||||||
@ -86,6 +94,7 @@ public:
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace foamVtkOutput
|
||||||
} // End namespace Foam
|
} // End namespace Foam
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|||||||
@ -27,13 +27,13 @@ License
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
const char* Foam::foamVtkAppendRawFormatter::name_ = "append";
|
const char* Foam::foamVtkOutput::appendRawFormatter::name_ = "append";
|
||||||
const char* Foam::foamVtkAppendRawFormatter::encoding_ = "raw";
|
const char* Foam::foamVtkOutput::appendRawFormatter::encoding_ = "raw";
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
void Foam::foamVtkAppendRawFormatter::write
|
void Foam::foamVtkOutput::appendRawFormatter::write
|
||||||
(
|
(
|
||||||
const char* s,
|
const char* s,
|
||||||
std::streamsize n
|
std::streamsize n
|
||||||
@ -45,59 +45,59 @@ void Foam::foamVtkAppendRawFormatter::write
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
Foam::foamVtkAppendRawFormatter::foamVtkAppendRawFormatter(std::ostream& os)
|
Foam::foamVtkOutput::appendRawFormatter::appendRawFormatter(std::ostream& os)
|
||||||
:
|
:
|
||||||
foamVtkFormatter(os)
|
formatter(os)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
Foam::foamVtkAppendRawFormatter::~foamVtkAppendRawFormatter()
|
Foam::foamVtkOutput::appendRawFormatter::~appendRawFormatter()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
const char* Foam::foamVtkAppendRawFormatter::name() const
|
const char* Foam::foamVtkOutput::appendRawFormatter::name() const
|
||||||
{
|
{
|
||||||
return name_;
|
return name_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const char* Foam::foamVtkAppendRawFormatter::encoding() const
|
const char* Foam::foamVtkOutput::appendRawFormatter::encoding() const
|
||||||
{
|
{
|
||||||
return encoding_;
|
return encoding_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Foam::foamVtkAppendRawFormatter::writeSize(const uint64_t nBytes)
|
void Foam::foamVtkOutput::appendRawFormatter::writeSize(const uint64_t nBytes)
|
||||||
{
|
{
|
||||||
write(reinterpret_cast<const char*>(&nBytes), sizeof(uint64_t));
|
write(reinterpret_cast<const char*>(&nBytes), sizeof(uint64_t));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Foam::foamVtkAppendRawFormatter::write(const uint8_t val)
|
void Foam::foamVtkOutput::appendRawFormatter::write(const uint8_t val)
|
||||||
{
|
{
|
||||||
write(reinterpret_cast<const char*>(&val), sizeof(uint8_t));
|
write(reinterpret_cast<const char*>(&val), sizeof(uint8_t));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Foam::foamVtkAppendRawFormatter::write(const label val)
|
void Foam::foamVtkOutput::appendRawFormatter::write(const label val)
|
||||||
{
|
{
|
||||||
// std::cerr<<"label:" << sizeof(val) << "=" << val << '\n';
|
// std::cerr<<"label:" << sizeof(val) << "=" << val << '\n';
|
||||||
write(reinterpret_cast<const char*>(&val), sizeof(label));
|
write(reinterpret_cast<const char*>(&val), sizeof(label));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Foam::foamVtkAppendRawFormatter::write(const float val)
|
void Foam::foamVtkOutput::appendRawFormatter::write(const float val)
|
||||||
{
|
{
|
||||||
// std::cerr<<"float:" << sizeof(val) << "=" << val << '\n';
|
// std::cerr<<"float:" << sizeof(val) << "=" << val << '\n';
|
||||||
write(reinterpret_cast<const char*>(&val), sizeof(float));
|
write(reinterpret_cast<const char*>(&val), sizeof(float));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Foam::foamVtkAppendRawFormatter::write(const double val)
|
void Foam::foamVtkOutput::appendRawFormatter::write(const double val)
|
||||||
{
|
{
|
||||||
// std::cerr<<"double as float=" << val << '\n';
|
// std::cerr<<"double as float=" << val << '\n';
|
||||||
float copy(val);
|
float copy(val);
|
||||||
@ -105,7 +105,7 @@ void Foam::foamVtkAppendRawFormatter::write(const double val)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Foam::foamVtkAppendRawFormatter::flush()
|
void Foam::foamVtkOutput::appendRawFormatter::flush()
|
||||||
{/*nop*/}
|
{/*nop*/}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
|
\\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -22,7 +22,7 @@ License
|
|||||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
Class
|
Class
|
||||||
foamVtkAppendRawFormatter
|
Foam::foamVtkOutput::appendRawFormatter
|
||||||
|
|
||||||
Description
|
Description
|
||||||
Appended raw binary output.
|
Appended raw binary output.
|
||||||
@ -41,14 +41,16 @@ SourceFiles
|
|||||||
|
|
||||||
namespace Foam
|
namespace Foam
|
||||||
{
|
{
|
||||||
|
namespace foamVtkOutput
|
||||||
|
{
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*\
|
/*---------------------------------------------------------------------------*\
|
||||||
Class foamVtkAppendRawFormatter Declaration
|
Class appendRawFormatter Declaration
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
class foamVtkAppendRawFormatter
|
class appendRawFormatter
|
||||||
:
|
:
|
||||||
public foamVtkFormatter
|
public formatter
|
||||||
{
|
{
|
||||||
// Private Data Members
|
// Private Data Members
|
||||||
|
|
||||||
@ -58,10 +60,10 @@ class foamVtkAppendRawFormatter
|
|||||||
// Private Member Functions
|
// Private Member Functions
|
||||||
|
|
||||||
//- Disallow default bitwise copy construct
|
//- Disallow default bitwise copy construct
|
||||||
foamVtkAppendRawFormatter(const foamVtkAppendRawFormatter&) = delete;
|
appendRawFormatter(const appendRawFormatter&) = delete;
|
||||||
|
|
||||||
//- Disallow default bitwise assignment
|
//- Disallow default bitwise assignment
|
||||||
void operator=(const foamVtkAppendRawFormatter&) = delete;
|
void operator=(const appendRawFormatter&) = delete;
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@ -77,15 +79,21 @@ public:
|
|||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
//- Construct and attach to an output stream
|
//- Construct and attach to an output stream
|
||||||
foamVtkAppendRawFormatter(std::ostream& os);
|
appendRawFormatter(std::ostream& os);
|
||||||
|
|
||||||
|
|
||||||
//- Destructor
|
//- Destructor
|
||||||
virtual ~foamVtkAppendRawFormatter();
|
virtual ~appendRawFormatter();
|
||||||
|
|
||||||
|
|
||||||
// Member Functions
|
// Member Functions
|
||||||
|
|
||||||
|
//- The output formatType is APPEND_BINARY.
|
||||||
|
virtual enum formatType format() const
|
||||||
|
{
|
||||||
|
return formatType::APPEND_BINARY;
|
||||||
|
}
|
||||||
|
|
||||||
//- Output name for XML type ("append")
|
//- Output name for XML type ("append")
|
||||||
virtual const char* name() const;
|
virtual const char* name() const;
|
||||||
|
|
||||||
@ -108,6 +116,7 @@ public:
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace foamVtkOutput
|
||||||
} // End namespace Foam
|
} // End namespace Foam
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|||||||
@ -27,12 +27,12 @@ License
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
const char* Foam::foamVtkAsciiFormatter::name_ = "ascii";
|
const char* Foam::foamVtkOutput::asciiFormatter::name_ = "ascii";
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
inline void Foam::foamVtkAsciiFormatter::next()
|
inline void Foam::foamVtkOutput::asciiFormatter::next()
|
||||||
{
|
{
|
||||||
if (pos_ == 6)
|
if (pos_ == 6)
|
||||||
{
|
{
|
||||||
@ -47,7 +47,7 @@ inline void Foam::foamVtkAsciiFormatter::next()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline void Foam::foamVtkAsciiFormatter::done()
|
inline void Foam::foamVtkOutput::asciiFormatter::done()
|
||||||
{
|
{
|
||||||
if (pos_)
|
if (pos_)
|
||||||
{
|
{
|
||||||
@ -59,20 +59,20 @@ inline void Foam::foamVtkAsciiFormatter::done()
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
Foam::foamVtkAsciiFormatter::foamVtkAsciiFormatter(std::ostream& os)
|
Foam::foamVtkOutput::asciiFormatter::asciiFormatter(std::ostream& os)
|
||||||
:
|
:
|
||||||
foamVtkFormatter(os),
|
formatter(os),
|
||||||
pos_(0)
|
pos_(0)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
Foam::foamVtkAsciiFormatter::foamVtkAsciiFormatter
|
Foam::foamVtkOutput::asciiFormatter::asciiFormatter
|
||||||
(
|
(
|
||||||
std::ostream& os,
|
std::ostream& os,
|
||||||
unsigned precision
|
unsigned precision
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
foamVtkFormatter(os),
|
formatter(os),
|
||||||
pos_(0)
|
pos_(0)
|
||||||
{
|
{
|
||||||
os.precision(precision);
|
os.precision(precision);
|
||||||
@ -81,7 +81,7 @@ Foam::foamVtkAsciiFormatter::foamVtkAsciiFormatter
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
Foam::foamVtkAsciiFormatter::~foamVtkAsciiFormatter()
|
Foam::foamVtkOutput::asciiFormatter::~asciiFormatter()
|
||||||
{
|
{
|
||||||
done();
|
done();
|
||||||
}
|
}
|
||||||
@ -89,58 +89,58 @@ Foam::foamVtkAsciiFormatter::~foamVtkAsciiFormatter()
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
const char* Foam::foamVtkAsciiFormatter::name() const
|
const char* Foam::foamVtkOutput::asciiFormatter::name() const
|
||||||
{
|
{
|
||||||
return name_;
|
return name_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const char* Foam::foamVtkAsciiFormatter::encoding() const
|
const char* Foam::foamVtkOutput::asciiFormatter::encoding() const
|
||||||
{
|
{
|
||||||
return name_;
|
return name_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Foam::foamVtkAsciiFormatter::writeSize(const uint64_t ignored)
|
void Foam::foamVtkOutput::asciiFormatter::writeSize(const uint64_t ignored)
|
||||||
{/*nop*/}
|
{/*nop*/}
|
||||||
|
|
||||||
|
|
||||||
void Foam::foamVtkAsciiFormatter::write(const uint8_t val)
|
void Foam::foamVtkOutput::asciiFormatter::write(const uint8_t val)
|
||||||
{
|
{
|
||||||
next();
|
next();
|
||||||
os()<< int(val);
|
os()<< int(val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Foam::foamVtkAsciiFormatter::write(const label val)
|
void Foam::foamVtkOutput::asciiFormatter::write(const label val)
|
||||||
{
|
{
|
||||||
next();
|
next();
|
||||||
os()<< val;
|
os()<< val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Foam::foamVtkAsciiFormatter::write(const float val)
|
void Foam::foamVtkOutput::asciiFormatter::write(const float val)
|
||||||
{
|
{
|
||||||
next();
|
next();
|
||||||
os()<< val;
|
os()<< val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Foam::foamVtkAsciiFormatter::write(const double val)
|
void Foam::foamVtkOutput::asciiFormatter::write(const double val)
|
||||||
{
|
{
|
||||||
next();
|
next();
|
||||||
os()<< float(val);
|
os()<< float(val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Foam::foamVtkAsciiFormatter::flush()
|
void Foam::foamVtkOutput::asciiFormatter::flush()
|
||||||
{
|
{
|
||||||
done();
|
done();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::size_t
|
std::size_t
|
||||||
Foam::foamVtkAsciiFormatter::encodedLength(std::size_t ignored) const
|
Foam::foamVtkOutput::asciiFormatter::encodedLength(std::size_t ignored) const
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -22,10 +22,10 @@ License
|
|||||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
Class
|
Class
|
||||||
foamVtkAsciiFormatter
|
Foam::foamVtkOutput::asciiFormatter
|
||||||
|
|
||||||
Description
|
Description
|
||||||
Inline ASCII binary output.
|
Inline ASCII output.
|
||||||
Adds spaces between entries and a newline every 6 items
|
Adds spaces between entries and a newline every 6 items
|
||||||
(for consistency with what VTK itself outputs).
|
(for consistency with what VTK itself outputs).
|
||||||
|
|
||||||
@ -43,14 +43,16 @@ SourceFiles
|
|||||||
|
|
||||||
namespace Foam
|
namespace Foam
|
||||||
{
|
{
|
||||||
|
namespace foamVtkOutput
|
||||||
|
{
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*\
|
/*---------------------------------------------------------------------------*\
|
||||||
Class foamVtkAsciiFormatter Declaration
|
Class asciiFormatter Declaration
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
class foamVtkAsciiFormatter
|
class asciiFormatter
|
||||||
:
|
:
|
||||||
public foamVtkFormatter
|
public formatter
|
||||||
{
|
{
|
||||||
// Private Data Members
|
// Private Data Members
|
||||||
|
|
||||||
@ -70,10 +72,10 @@ class foamVtkAsciiFormatter
|
|||||||
|
|
||||||
|
|
||||||
//- Disallow default bitwise copy construct
|
//- Disallow default bitwise copy construct
|
||||||
foamVtkAsciiFormatter(const foamVtkAsciiFormatter&) = delete;
|
asciiFormatter(const asciiFormatter&) = delete;
|
||||||
|
|
||||||
//- Disallow default bitwise assignment
|
//- Disallow default bitwise assignment
|
||||||
void operator=(const foamVtkAsciiFormatter&) = delete;
|
void operator=(const asciiFormatter&) = delete;
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -81,20 +83,25 @@ public:
|
|||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
//- Construct and attach to an output stream, use default precision
|
//- Construct and attach to an output stream, use default precision
|
||||||
foamVtkAsciiFormatter(std::ostream& os);
|
asciiFormatter(std::ostream& os);
|
||||||
|
|
||||||
//- Construct and attach to an output stream, use specified precision
|
//- Construct and attach to an output stream, use specified precision
|
||||||
foamVtkAsciiFormatter(std::ostream& os, unsigned precision);
|
asciiFormatter(std::ostream& os, unsigned precision);
|
||||||
|
|
||||||
|
|
||||||
//- Destructor
|
//- Destructor
|
||||||
virtual ~foamVtkAsciiFormatter();
|
virtual ~asciiFormatter();
|
||||||
|
|
||||||
|
|
||||||
// Member Functions
|
// Member Functions
|
||||||
|
|
||||||
|
//- The output formatType is INLINE_ASCII.
|
||||||
|
virtual enum formatType format() const
|
||||||
|
{
|
||||||
|
return formatType::INLINE_ASCII;
|
||||||
|
}
|
||||||
|
|
||||||
//- Name for the XML output type ("ascii")
|
//- Name for the XML output type ("ascii")
|
||||||
// The legacy output type is an uppercase version of this.
|
|
||||||
virtual const char* name() const;
|
virtual const char* name() const;
|
||||||
|
|
||||||
//- Name for the XML append encoding - unused.
|
//- Name for the XML append encoding - unused.
|
||||||
@ -120,6 +127,7 @@ public:
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace foamVtkOutput
|
||||||
} // End namespace Foam
|
} // End namespace Foam
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|||||||
@ -27,12 +27,12 @@ License
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
const char* Foam::foamVtkBase64Formatter::name_ = "binary";
|
const char* Foam::foamVtkOutput::base64Formatter::name_ = "binary";
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
Foam::foamVtkBase64Formatter::foamVtkBase64Formatter(std::ostream& os)
|
Foam::foamVtkOutput::base64Formatter::base64Formatter(std::ostream& os)
|
||||||
:
|
:
|
||||||
foamVtkBase64Layer(os)
|
foamVtkBase64Layer(os)
|
||||||
{}
|
{}
|
||||||
@ -40,7 +40,7 @@ Foam::foamVtkBase64Formatter::foamVtkBase64Formatter(std::ostream& os)
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
Foam::foamVtkBase64Formatter::~foamVtkBase64Formatter()
|
Foam::foamVtkOutput::base64Formatter::~base64Formatter()
|
||||||
{
|
{
|
||||||
if (base64Layer::close())
|
if (base64Layer::close())
|
||||||
{
|
{
|
||||||
@ -51,13 +51,13 @@ Foam::foamVtkBase64Formatter::~foamVtkBase64Formatter()
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
const char* Foam::foamVtkBase64Formatter::name() const
|
const char* Foam::foamVtkOutput::base64Formatter::name() const
|
||||||
{
|
{
|
||||||
return name_;
|
return name_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Foam::foamVtkBase64Formatter::flush()
|
void Foam::foamVtkOutput::base64Formatter::flush()
|
||||||
{
|
{
|
||||||
if (base64Layer::close())
|
if (base64Layer::close())
|
||||||
{
|
{
|
||||||
|
|||||||
@ -22,7 +22,7 @@ License
|
|||||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
Class
|
Class
|
||||||
foamVtkBase64Formatter
|
Foam::foamVtkOutput::base64Formatter
|
||||||
|
|
||||||
Description
|
Description
|
||||||
Inline base-64 encoded binary output.
|
Inline base-64 encoded binary output.
|
||||||
@ -39,12 +39,14 @@ Description
|
|||||||
|
|
||||||
namespace Foam
|
namespace Foam
|
||||||
{
|
{
|
||||||
|
namespace foamVtkOutput
|
||||||
|
{
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*\
|
/*---------------------------------------------------------------------------*\
|
||||||
Class foamVtkBase64Formatter Declaration
|
Class base64Formatter Declaration
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
class foamVtkBase64Formatter
|
class base64Formatter
|
||||||
:
|
:
|
||||||
public foamVtkBase64Layer
|
public foamVtkBase64Layer
|
||||||
{
|
{
|
||||||
@ -57,27 +59,32 @@ class foamVtkBase64Formatter
|
|||||||
// Private Member Functions
|
// Private Member Functions
|
||||||
|
|
||||||
//- Disallow default bitwise copy construct
|
//- Disallow default bitwise copy construct
|
||||||
foamVtkBase64Formatter(const foamVtkBase64Formatter&) = delete;
|
base64Formatter(const base64Formatter&) = delete;
|
||||||
|
|
||||||
//- Disallow default bitwise assignment
|
//- Disallow default bitwise assignment
|
||||||
void operator=(const foamVtkBase64Formatter&) = delete;
|
void operator=(const base64Formatter&) = delete;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
//- Construct and attach to an output stream
|
//- Construct and attach to an output stream
|
||||||
foamVtkBase64Formatter(std::ostream& os);
|
base64Formatter(std::ostream& os);
|
||||||
|
|
||||||
|
|
||||||
//- Destructor
|
//- Destructor
|
||||||
virtual ~foamVtkBase64Formatter();
|
virtual ~base64Formatter();
|
||||||
|
|
||||||
|
|
||||||
// Member Functions
|
// Member Functions
|
||||||
|
|
||||||
|
//- The output formatType is INLINE_BASE64.
|
||||||
|
virtual enum formatType format() const
|
||||||
|
{
|
||||||
|
return formatType::INLINE_BASE64;
|
||||||
|
}
|
||||||
|
|
||||||
//- Name for the XML output type ("binary")
|
//- Name for the XML output type ("binary")
|
||||||
// The lowercase version of the Legacy output type.
|
|
||||||
virtual const char* name() const;
|
virtual const char* name() const;
|
||||||
|
|
||||||
|
|
||||||
@ -89,6 +96,7 @@ public:
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace foamVtkOutput
|
||||||
} // End namespace Foam
|
} // End namespace Foam
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|||||||
@ -27,12 +27,12 @@ License
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
const char* Foam::foamVtkBase64Layer::encoding_ = "base64";
|
const char* Foam::foamVtkOutput::foamVtkBase64Layer::encoding_ = "base64";
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
void Foam::foamVtkBase64Layer::write
|
void Foam::foamVtkOutput::foamVtkBase64Layer::write
|
||||||
(
|
(
|
||||||
const char* s,
|
const char* s,
|
||||||
std::streamsize n
|
std::streamsize n
|
||||||
@ -44,16 +44,16 @@ void Foam::foamVtkBase64Layer::write
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
Foam::foamVtkBase64Layer::foamVtkBase64Layer(std::ostream& os)
|
Foam::foamVtkOutput::foamVtkBase64Layer::foamVtkBase64Layer(std::ostream& os)
|
||||||
:
|
:
|
||||||
foamVtkFormatter(os),
|
formatter(os),
|
||||||
base64Layer(os)
|
base64Layer(os)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
Foam::foamVtkBase64Layer::~foamVtkBase64Layer()
|
Foam::foamVtkOutput::foamVtkBase64Layer::~foamVtkBase64Layer()
|
||||||
{
|
{
|
||||||
base64Layer::close();
|
base64Layer::close();
|
||||||
}
|
}
|
||||||
@ -61,39 +61,39 @@ Foam::foamVtkBase64Layer::~foamVtkBase64Layer()
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
const char* Foam::foamVtkBase64Layer::encoding() const
|
const char* Foam::foamVtkOutput::foamVtkBase64Layer::encoding() const
|
||||||
{
|
{
|
||||||
return encoding_;
|
return encoding_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Foam::foamVtkBase64Layer::writeSize(const uint64_t nBytes)
|
void Foam::foamVtkOutput::foamVtkBase64Layer::writeSize(const uint64_t nBytes)
|
||||||
{
|
{
|
||||||
write(reinterpret_cast<const char*>(&nBytes), sizeof(uint64_t));
|
write(reinterpret_cast<const char*>(&nBytes), sizeof(uint64_t));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Foam::foamVtkBase64Layer::write(const uint8_t val)
|
void Foam::foamVtkOutput::foamVtkBase64Layer::write(const uint8_t val)
|
||||||
{
|
{
|
||||||
base64Layer::add(val);
|
base64Layer::add(val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Foam::foamVtkBase64Layer::write(const label val)
|
void Foam::foamVtkOutput::foamVtkBase64Layer::write(const label val)
|
||||||
{
|
{
|
||||||
// std::cerr<<"label:" << sizeof(val) << "=" << val << '\n';
|
// std::cerr<<"label:" << sizeof(val) << "=" << val << '\n';
|
||||||
write(reinterpret_cast<const char*>(&val), sizeof(label));
|
write(reinterpret_cast<const char*>(&val), sizeof(label));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Foam::foamVtkBase64Layer::write(const float val)
|
void Foam::foamVtkOutput::foamVtkBase64Layer::write(const float val)
|
||||||
{
|
{
|
||||||
// std::cerr<<"float:" << sizeof(val) << "=" << val << '\n';
|
// std::cerr<<"float:" << sizeof(val) << "=" << val << '\n';
|
||||||
write(reinterpret_cast<const char*>(&val), sizeof(float));
|
write(reinterpret_cast<const char*>(&val), sizeof(float));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Foam::foamVtkBase64Layer::write(const double val)
|
void Foam::foamVtkOutput::foamVtkBase64Layer::write(const double val)
|
||||||
{
|
{
|
||||||
// std::cerr<<"double as float=" << val << '\n';
|
// std::cerr<<"double as float=" << val << '\n';
|
||||||
float copy(val);
|
float copy(val);
|
||||||
@ -101,13 +101,16 @@ void Foam::foamVtkBase64Layer::write(const double val)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Foam::foamVtkBase64Layer::flush()
|
void Foam::foamVtkOutput::foamVtkBase64Layer::flush()
|
||||||
{
|
{
|
||||||
base64Layer::close();
|
base64Layer::close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::size_t Foam::foamVtkBase64Layer::encodedLength(std::size_t n) const
|
std::size_t Foam::foamVtkOutput::foamVtkBase64Layer::encodedLength
|
||||||
|
(
|
||||||
|
std::size_t n
|
||||||
|
) const
|
||||||
{
|
{
|
||||||
return base64Layer::encodedLength(n);
|
return base64Layer::encodedLength(n);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -22,10 +22,10 @@ License
|
|||||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
Class
|
Class
|
||||||
foamVtkBase64Layer
|
Foam::foamVtkOutput::foamVtkBase64Layer
|
||||||
|
|
||||||
Description
|
Description
|
||||||
Base-64 encoded output.
|
Base-64 encoded output layer - normally only used indirectly by formatters.
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
@ -39,6 +39,8 @@ Description
|
|||||||
|
|
||||||
namespace Foam
|
namespace Foam
|
||||||
{
|
{
|
||||||
|
namespace foamVtkOutput
|
||||||
|
{
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*\
|
/*---------------------------------------------------------------------------*\
|
||||||
Class foamVtkBase64Layer Declaration
|
Class foamVtkBase64Layer Declaration
|
||||||
@ -46,7 +48,7 @@ namespace Foam
|
|||||||
|
|
||||||
class foamVtkBase64Layer
|
class foamVtkBase64Layer
|
||||||
:
|
:
|
||||||
public foamVtkFormatter,
|
public formatter,
|
||||||
protected base64Layer
|
protected base64Layer
|
||||||
{
|
{
|
||||||
// Private Data Members
|
// Private Data Members
|
||||||
@ -105,6 +107,7 @@ public:
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace foamVtkOutput
|
||||||
} // End namespace Foam
|
} // End namespace Foam
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|||||||
@ -26,7 +26,7 @@ License
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
Foam::foamVtkFormatter::foamVtkFormatter(std::ostream& os)
|
Foam::foamVtkOutput::formatter::formatter(std::ostream& os)
|
||||||
:
|
:
|
||||||
os_(os),
|
os_(os),
|
||||||
xmlTags_(),
|
xmlTags_(),
|
||||||
@ -36,19 +36,19 @@ Foam::foamVtkFormatter::foamVtkFormatter(std::ostream& os)
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
Foam::foamVtkFormatter::~foamVtkFormatter()
|
Foam::foamVtkOutput::formatter::~formatter()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
std::size_t Foam::foamVtkFormatter::encodedLength(std::size_t n) const
|
std::size_t Foam::foamVtkOutput::formatter::encodedLength(std::size_t n) const
|
||||||
{
|
{
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Foam::foamVtkFormatter::indent()
|
void Foam::foamVtkOutput::formatter::indent()
|
||||||
{
|
{
|
||||||
label n = xmlTags_.size() * 2;
|
label n = xmlTags_.size() * 2;
|
||||||
while (n--)
|
while (n--)
|
||||||
@ -58,8 +58,8 @@ void Foam::foamVtkFormatter::indent()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::foamVtkFormatter&
|
Foam::foamVtkOutput::formatter&
|
||||||
Foam::foamVtkFormatter::xmlHeader()
|
Foam::foamVtkOutput::formatter::xmlHeader()
|
||||||
{
|
{
|
||||||
if (inTag_)
|
if (inTag_)
|
||||||
{
|
{
|
||||||
@ -74,8 +74,8 @@ Foam::foamVtkFormatter::xmlHeader()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::foamVtkFormatter&
|
Foam::foamVtkOutput::formatter&
|
||||||
Foam::foamVtkFormatter::comment(const std::string& text)
|
Foam::foamVtkOutput::formatter::comment(const std::string& text)
|
||||||
{
|
{
|
||||||
if (inTag_)
|
if (inTag_)
|
||||||
{
|
{
|
||||||
@ -91,8 +91,8 @@ Foam::foamVtkFormatter::comment(const std::string& text)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::foamVtkFormatter&
|
Foam::foamVtkOutput::formatter&
|
||||||
Foam::foamVtkFormatter::openTag(const word& tag)
|
Foam::foamVtkOutput::formatter::openTag(const word& tag)
|
||||||
{
|
{
|
||||||
if (inTag_)
|
if (inTag_)
|
||||||
{
|
{
|
||||||
@ -111,8 +111,8 @@ Foam::foamVtkFormatter::openTag(const word& tag)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::foamVtkFormatter&
|
Foam::foamVtkOutput::formatter&
|
||||||
Foam::foamVtkFormatter::closeTag(const bool isEmpty)
|
Foam::foamVtkOutput::formatter::closeTag(const bool isEmpty)
|
||||||
{
|
{
|
||||||
if (!inTag_)
|
if (!inTag_)
|
||||||
{
|
{
|
||||||
@ -135,8 +135,8 @@ Foam::foamVtkFormatter::closeTag(const bool isEmpty)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::foamVtkFormatter&
|
Foam::foamVtkOutput::formatter&
|
||||||
Foam::foamVtkFormatter::endTag(const word& tag)
|
Foam::foamVtkOutput::formatter::endTag(const word& tag)
|
||||||
{
|
{
|
||||||
const word curr = xmlTags_.pop();
|
const word curr = xmlTags_.pop();
|
||||||
indent();
|
indent();
|
||||||
@ -166,8 +166,8 @@ Foam::foamVtkFormatter::endTag(const word& tag)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::foamVtkFormatter&
|
Foam::foamVtkOutput::formatter&
|
||||||
Foam::foamVtkFormatter::tag(const word& tag)
|
Foam::foamVtkOutput::formatter::tag(const word& tag)
|
||||||
{
|
{
|
||||||
openTag(tag);
|
openTag(tag);
|
||||||
closeTag();
|
closeTag();
|
||||||
@ -176,8 +176,8 @@ Foam::foamVtkFormatter::tag(const word& tag)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::foamVtkFormatter&
|
Foam::foamVtkOutput::formatter&
|
||||||
Foam::foamVtkFormatter::beginVTKFile
|
Foam::foamVtkOutput::formatter::beginVTKFile
|
||||||
(
|
(
|
||||||
const word& contentType,
|
const word& contentType,
|
||||||
const word& contentVersion,
|
const word& contentVersion,
|
||||||
@ -201,8 +201,8 @@ Foam::foamVtkFormatter::beginVTKFile
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::foamVtkFormatter&
|
Foam::foamVtkOutput::formatter&
|
||||||
Foam::foamVtkFormatter::beginAppendedData()
|
Foam::foamVtkOutput::formatter::beginAppendedData()
|
||||||
{
|
{
|
||||||
openTag("AppendedData");
|
openTag("AppendedData");
|
||||||
xmlAttr("encoding", encoding());
|
xmlAttr("encoding", encoding());
|
||||||
@ -213,8 +213,8 @@ Foam::foamVtkFormatter::beginAppendedData()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::foamVtkFormatter&
|
Foam::foamVtkOutput::formatter&
|
||||||
Foam::foamVtkFormatter::xmlAttr
|
Foam::foamVtkOutput::formatter::xmlAttr
|
||||||
(
|
(
|
||||||
const word& k,
|
const word& k,
|
||||||
const std::string& v,
|
const std::string& v,
|
||||||
@ -234,8 +234,8 @@ Foam::foamVtkFormatter::xmlAttr
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::foamVtkFormatter&
|
Foam::foamVtkOutput::formatter&
|
||||||
Foam::foamVtkFormatter::xmlAttr
|
Foam::foamVtkOutput::formatter::xmlAttr
|
||||||
(
|
(
|
||||||
const word& k,
|
const word& k,
|
||||||
const int32_t v,
|
const int32_t v,
|
||||||
@ -246,8 +246,8 @@ Foam::foamVtkFormatter::xmlAttr
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::foamVtkFormatter&
|
Foam::foamVtkOutput::formatter&
|
||||||
Foam::foamVtkFormatter::xmlAttr
|
Foam::foamVtkOutput::formatter::xmlAttr
|
||||||
(
|
(
|
||||||
const word& k,
|
const word& k,
|
||||||
const int64_t v,
|
const int64_t v,
|
||||||
@ -258,8 +258,8 @@ Foam::foamVtkFormatter::xmlAttr
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::foamVtkFormatter&
|
Foam::foamVtkOutput::formatter&
|
||||||
Foam::foamVtkFormatter::xmlAttr
|
Foam::foamVtkOutput::formatter::xmlAttr
|
||||||
(
|
(
|
||||||
const word& k,
|
const word& k,
|
||||||
const uint64_t v,
|
const uint64_t v,
|
||||||
@ -270,8 +270,8 @@ Foam::foamVtkFormatter::xmlAttr
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::foamVtkFormatter&
|
Foam::foamVtkOutput::formatter&
|
||||||
Foam::foamVtkFormatter::xmlAttr
|
Foam::foamVtkOutput::formatter::xmlAttr
|
||||||
(
|
(
|
||||||
const word& k,
|
const word& k,
|
||||||
const scalar v,
|
const scalar v,
|
||||||
@ -284,36 +284,36 @@ Foam::foamVtkFormatter::xmlAttr
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
Foam::foamVtkFormatter&
|
Foam::foamVtkOutput::formatter&
|
||||||
Foam::foamVtkFormatter::operator()(const word& k, const std::string& v)
|
Foam::foamVtkOutput::formatter::operator()(const word& k, const std::string& v)
|
||||||
{
|
{
|
||||||
return xmlAttr(k, v);
|
return xmlAttr(k, v);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::foamVtkFormatter&
|
Foam::foamVtkOutput::formatter&
|
||||||
Foam::foamVtkFormatter::operator()(const word& k, const int32_t v)
|
Foam::foamVtkOutput::formatter::operator()(const word& k, const int32_t v)
|
||||||
{
|
{
|
||||||
return xmlAttr(k, v);
|
return xmlAttr(k, v);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::foamVtkFormatter&
|
Foam::foamVtkOutput::formatter&
|
||||||
Foam::foamVtkFormatter::operator()(const word& k, const int64_t v)
|
Foam::foamVtkOutput::formatter::operator()(const word& k, const int64_t v)
|
||||||
{
|
{
|
||||||
return xmlAttr(k, v);
|
return xmlAttr(k, v);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::foamVtkFormatter&
|
Foam::foamVtkOutput::formatter&
|
||||||
Foam::foamVtkFormatter::operator()(const word& k, const uint64_t v)
|
Foam::foamVtkOutput::formatter::operator()(const word& k, const uint64_t v)
|
||||||
{
|
{
|
||||||
return xmlAttr(k, v);
|
return xmlAttr(k, v);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::foamVtkFormatter&
|
Foam::foamVtkOutput::formatter&
|
||||||
Foam::foamVtkFormatter::operator()(const word& k, const scalar v)
|
Foam::foamVtkOutput::formatter::operator()(const word& k, const scalar v)
|
||||||
{
|
{
|
||||||
return xmlAttr(k, v);
|
return xmlAttr(k, v);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -22,7 +22,7 @@ License
|
|||||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
Class
|
Class
|
||||||
foamVtkFormatter
|
Foam::foamVtkOutput::formatter
|
||||||
|
|
||||||
Description
|
Description
|
||||||
Abstract class for a VTK output stream formatter.
|
Abstract class for a VTK output stream formatter.
|
||||||
@ -31,6 +31,7 @@ Description
|
|||||||
|
|
||||||
SourceFiles
|
SourceFiles
|
||||||
foamVtkFormatter.C
|
foamVtkFormatter.C
|
||||||
|
foamVtkFormatterTemplates.C
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
@ -44,6 +45,7 @@ SourceFiles
|
|||||||
#include "UList.H"
|
#include "UList.H"
|
||||||
#include "LIFOStack.H"
|
#include "LIFOStack.H"
|
||||||
#include "foamVtkPTraits.H"
|
#include "foamVtkPTraits.H"
|
||||||
|
#include "foamVtkOutputTypes.H"
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
@ -51,12 +53,14 @@ SourceFiles
|
|||||||
|
|
||||||
namespace Foam
|
namespace Foam
|
||||||
{
|
{
|
||||||
|
namespace foamVtkOutput
|
||||||
|
{
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*\
|
/*---------------------------------------------------------------------------*\
|
||||||
Class foamVtkFormatter Declaration
|
Class formatter Declaration
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
class foamVtkFormatter
|
class formatter
|
||||||
{
|
{
|
||||||
// Private Data
|
// Private Data
|
||||||
|
|
||||||
@ -72,7 +76,7 @@ class foamVtkFormatter
|
|||||||
|
|
||||||
//- Write XML attribute
|
//- Write XML attribute
|
||||||
template<class Type>
|
template<class Type>
|
||||||
foamVtkFormatter& xmlAttribute
|
formatter& xmlAttribute
|
||||||
(
|
(
|
||||||
const word& k,
|
const word& k,
|
||||||
const Type& v,
|
const Type& v,
|
||||||
@ -85,7 +89,7 @@ protected:
|
|||||||
// Protected Member Functions
|
// Protected Member Functions
|
||||||
|
|
||||||
//- Construct and attach to an output stream
|
//- Construct and attach to an output stream
|
||||||
foamVtkFormatter(std::ostream& os);
|
formatter(std::ostream& os);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@ -96,11 +100,13 @@ public:
|
|||||||
|
|
||||||
|
|
||||||
//- Destructor
|
//- Destructor
|
||||||
virtual ~foamVtkFormatter();
|
virtual ~formatter();
|
||||||
|
|
||||||
|
|
||||||
// Member Functions
|
// Member Functions
|
||||||
|
|
||||||
|
// Access
|
||||||
|
|
||||||
//- Access to the underlying output stream
|
//- Access to the underlying output stream
|
||||||
inline std::ostream& os()
|
inline std::ostream& os()
|
||||||
{
|
{
|
||||||
@ -108,8 +114,10 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//- Name for the XML output type.
|
//- The output formatType.
|
||||||
// Possibly the lowercase version of the Legacy output type
|
virtual enum formatType format() const = 0;
|
||||||
|
|
||||||
|
//- Name for the XML output type or the legacy output type.
|
||||||
virtual const char* name() const = 0;
|
virtual const char* name() const = 0;
|
||||||
|
|
||||||
//- Name for the XML append encoding
|
//- Name for the XML append encoding
|
||||||
@ -134,34 +142,43 @@ public:
|
|||||||
|
|
||||||
// Member Functions
|
// Member Functions
|
||||||
|
|
||||||
|
// Output
|
||||||
|
|
||||||
//- Indent according to the currently nested XML tags
|
//- Indent according to the currently nested XML tags
|
||||||
void indent();
|
void indent();
|
||||||
|
|
||||||
//- Write XML header
|
//- Write XML header
|
||||||
foamVtkFormatter& xmlHeader();
|
// \return formatter for chaining
|
||||||
|
formatter& xmlHeader();
|
||||||
|
|
||||||
//- Write XML comment (at the current indentation level)
|
//- Write XML comment (at the current indentation level)
|
||||||
foamVtkFormatter& comment(const std::string& text);
|
// \return formatter for chaining
|
||||||
|
formatter& comment(const std::string& text);
|
||||||
|
|
||||||
|
|
||||||
//- Open XML tag
|
//- Open XML tag
|
||||||
foamVtkFormatter& openTag(const word& tag);
|
// \return formatter for chaining
|
||||||
|
formatter& openTag(const word& tag);
|
||||||
|
|
||||||
//- Close XML tag, optional as an empty container.
|
//- Close XML tag, optional as an empty container.
|
||||||
// Always adds a trailing newline.
|
// Always adds a trailing newline.
|
||||||
foamVtkFormatter& closeTag(const bool isEmpty = false);
|
// \return formatter for chaining
|
||||||
|
formatter& closeTag(const bool isEmpty = false);
|
||||||
|
|
||||||
//- End XML tag, optional with sanity check
|
//- End XML tag, optional with sanity check
|
||||||
// Always adds a trailing newline.
|
// Always adds a trailing newline.
|
||||||
foamVtkFormatter& endTag(const word& tag = word::null);
|
// \return formatter for chaining
|
||||||
|
formatter& endTag(const word& tag = word::null);
|
||||||
|
|
||||||
//- Write XML tag without any attributes. Combines openTag/closeTag.
|
//- Write XML tag without any attributes. Combines openTag/closeTag.
|
||||||
foamVtkFormatter& tag(const word& tag);
|
// \return formatter for chaining
|
||||||
|
formatter& tag(const word& tag);
|
||||||
|
|
||||||
//- Add a "VTKFile" XML tag for contentType, followed by a tag for
|
//- Add a "VTKFile" XML tag for contentType, followed by a tag for
|
||||||
// the contentType itself. Optionally leave the contentType tag
|
// the contentType itself. Optionally leave the contentType tag
|
||||||
// open for adding additional attributes.
|
// open for adding additional attributes.
|
||||||
foamVtkFormatter& beginVTKFile
|
// \return formatter for chaining
|
||||||
|
formatter& beginVTKFile
|
||||||
(
|
(
|
||||||
const word& contentType,
|
const word& contentType,
|
||||||
const word& contentVersion,
|
const word& contentVersion,
|
||||||
@ -170,28 +187,33 @@ public:
|
|||||||
|
|
||||||
//- Add a "AppendedData" XML tag with the current encoding and output
|
//- Add a "AppendedData" XML tag with the current encoding and output
|
||||||
// the requisite '_' prefix.
|
// the requisite '_' prefix.
|
||||||
foamVtkFormatter& beginAppendedData();
|
// \return formatter for chaining
|
||||||
|
formatter& beginAppendedData();
|
||||||
|
|
||||||
|
|
||||||
//- Open "DataArray" XML tag
|
//- Open "DataArray" XML tag
|
||||||
|
// \return formatter for chaining
|
||||||
template<class Type, int nComp=0>
|
template<class Type, int nComp=0>
|
||||||
foamVtkFormatter& openDataArray(const word& dataName);
|
formatter& openDataArray(const word& dataName);
|
||||||
|
|
||||||
|
|
||||||
//- Insert a single "PDataArray" XML entry tag.
|
//- Insert a single "PDataArray" XML entry tag.
|
||||||
// For some entries, the name is optional.
|
// For some entries, the name is optional.
|
||||||
|
// \return formatter for chaining
|
||||||
template<class Type, int nComp=0>
|
template<class Type, int nComp=0>
|
||||||
foamVtkFormatter& PDataArray(const word& dataName);
|
formatter& PDataArray(const word& dataName);
|
||||||
|
|
||||||
|
|
||||||
//- End "DataArray" XML tag
|
//- End "DataArray" XML tag
|
||||||
inline foamVtkFormatter& endDataArray()
|
// \return formatter for chaining
|
||||||
|
inline formatter& endDataArray()
|
||||||
{
|
{
|
||||||
return endTag("DataArray");
|
return endTag("DataArray");
|
||||||
}
|
}
|
||||||
|
|
||||||
//- End "AppendedData" XML tag
|
//- End "AppendedData" XML tag
|
||||||
inline foamVtkFormatter& endAppendedData()
|
// \return formatter for chaining
|
||||||
|
inline formatter& endAppendedData()
|
||||||
{
|
{
|
||||||
flush(); // flush any pending encoded content
|
flush(); // flush any pending encoded content
|
||||||
os_ << '\n'; // clear separation from content.
|
os_ << '\n'; // clear separation from content.
|
||||||
@ -199,14 +221,16 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
//- End "VTKFile" XML tag
|
//- End "VTKFile" XML tag
|
||||||
inline foamVtkFormatter& endVTKFile()
|
// \return formatter for chaining
|
||||||
|
inline formatter& endVTKFile()
|
||||||
{
|
{
|
||||||
return endTag("VTKFile");
|
return endTag("VTKFile");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//- Write XML attribute
|
//- Write XML attribute
|
||||||
foamVtkFormatter& xmlAttr
|
// \return formatter for chaining
|
||||||
|
formatter& xmlAttr
|
||||||
(
|
(
|
||||||
const word& k,
|
const word& k,
|
||||||
const std::string& v,
|
const std::string& v,
|
||||||
@ -214,7 +238,8 @@ public:
|
|||||||
);
|
);
|
||||||
|
|
||||||
//- Write XML attribute
|
//- Write XML attribute
|
||||||
foamVtkFormatter& xmlAttr
|
// \return formatter for chaining
|
||||||
|
formatter& xmlAttr
|
||||||
(
|
(
|
||||||
const word& k,
|
const word& k,
|
||||||
const int32_t v,
|
const int32_t v,
|
||||||
@ -222,7 +247,8 @@ public:
|
|||||||
);
|
);
|
||||||
|
|
||||||
//- Write XML attribute
|
//- Write XML attribute
|
||||||
foamVtkFormatter& xmlAttr
|
// \return formatter for chaining
|
||||||
|
formatter& xmlAttr
|
||||||
(
|
(
|
||||||
const word& k,
|
const word& k,
|
||||||
const int64_t v,
|
const int64_t v,
|
||||||
@ -230,7 +256,8 @@ public:
|
|||||||
);
|
);
|
||||||
|
|
||||||
//- Write XML attribute
|
//- Write XML attribute
|
||||||
foamVtkFormatter& xmlAttr
|
// \return formatter for chaining
|
||||||
|
formatter& xmlAttr
|
||||||
(
|
(
|
||||||
const word& k,
|
const word& k,
|
||||||
const uint64_t v,
|
const uint64_t v,
|
||||||
@ -238,7 +265,8 @@ public:
|
|||||||
);
|
);
|
||||||
|
|
||||||
//- Write XML attribute
|
//- Write XML attribute
|
||||||
foamVtkFormatter& xmlAttr
|
// \return formatter for chaining
|
||||||
|
formatter& xmlAttr
|
||||||
(
|
(
|
||||||
const word& k,
|
const word& k,
|
||||||
const scalar v,
|
const scalar v,
|
||||||
@ -246,29 +274,34 @@ public:
|
|||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Member Operators
|
// Member Operators
|
||||||
|
|
||||||
//- Write XML attribute
|
//- Write XML attribute
|
||||||
foamVtkFormatter& operator()(const word& k, const std::string& v);
|
// \return formatter for chaining
|
||||||
|
formatter& operator()(const word& k, const std::string& v);
|
||||||
|
|
||||||
//- Write XML attribute
|
//- Write XML attribute
|
||||||
foamVtkFormatter& operator()(const word& k, const int32_t v);
|
// \return formatter for chaining
|
||||||
|
formatter& operator()(const word& k, const int32_t v);
|
||||||
|
|
||||||
//- Write XML attribute
|
//- Write XML attribute
|
||||||
foamVtkFormatter& operator()(const word& k, const int64_t v);
|
// \return formatter for chaining
|
||||||
|
formatter& operator()(const word& k, const int64_t v);
|
||||||
|
|
||||||
//- Write XML attribute
|
//- Write XML attribute
|
||||||
foamVtkFormatter& operator()(const word& k, const uint64_t v);
|
// \return formatter for chaining
|
||||||
|
formatter& operator()(const word& k, const uint64_t v);
|
||||||
|
|
||||||
//- Write XML attribute
|
//- Write XML attribute
|
||||||
foamVtkFormatter& operator()(const word& k, const scalar v);
|
// \return formatter for chaining
|
||||||
|
formatter& operator()(const word& k, const scalar v);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace foamVtkOutput
|
||||||
} // End namespace Foam
|
} // End namespace Foam
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
|
\\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -27,8 +27,8 @@ License
|
|||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class Type>
|
template<class Type>
|
||||||
Foam::foamVtkFormatter&
|
Foam::foamVtkOutput::formatter&
|
||||||
Foam::foamVtkFormatter::xmlAttribute
|
Foam::foamVtkOutput::formatter::xmlAttribute
|
||||||
(
|
(
|
||||||
const word& k,
|
const word& k,
|
||||||
const Type& v,
|
const Type& v,
|
||||||
@ -49,7 +49,8 @@ Foam::foamVtkFormatter::xmlAttribute
|
|||||||
|
|
||||||
|
|
||||||
template<class Type, int nComp>
|
template<class Type, int nComp>
|
||||||
Foam::foamVtkFormatter& Foam::foamVtkFormatter::openDataArray
|
Foam::foamVtkOutput::formatter&
|
||||||
|
Foam::foamVtkOutput::formatter::openDataArray
|
||||||
(
|
(
|
||||||
const word& dataName
|
const word& dataName
|
||||||
)
|
)
|
||||||
@ -68,7 +69,8 @@ Foam::foamVtkFormatter& Foam::foamVtkFormatter::openDataArray
|
|||||||
|
|
||||||
|
|
||||||
template<class Type, int nComp>
|
template<class Type, int nComp>
|
||||||
Foam::foamVtkFormatter& Foam::foamVtkFormatter::PDataArray
|
Foam::foamVtkOutput::formatter&
|
||||||
|
Foam::foamVtkOutput::formatter::PDataArray
|
||||||
(
|
(
|
||||||
const word& dataName
|
const word& dataName
|
||||||
)
|
)
|
||||||
@ -89,4 +91,5 @@ Foam::foamVtkFormatter& Foam::foamVtkFormatter::PDataArray
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
|
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -23,33 +23,51 @@ License
|
|||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
inline bool Foam::foamVtkOutputOptions::legacy() const
|
#include "foamVtkLegacyAsciiFormatter.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
const char* Foam::foamVtkOutput::legacyAsciiFormatter::legacyName_ = "ASCII";
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::foamVtkOutput::legacyAsciiFormatter::legacyAsciiFormatter
|
||||||
|
(
|
||||||
|
std::ostream& os
|
||||||
|
)
|
||||||
|
:
|
||||||
|
asciiFormatter(os)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::foamVtkOutput::legacyAsciiFormatter::legacyAsciiFormatter
|
||||||
|
(
|
||||||
|
std::ostream& os,
|
||||||
|
unsigned precision
|
||||||
|
)
|
||||||
|
:
|
||||||
|
asciiFormatter(os, precision)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::foamVtkOutput::legacyAsciiFormatter::~legacyAsciiFormatter()
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
const char* Foam::foamVtkOutput::legacyAsciiFormatter::name() const
|
||||||
{
|
{
|
||||||
return (type_ & LEGACY);
|
return legacyName_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline bool Foam::foamVtkOutputOptions::xml() const
|
const char* Foam::foamVtkOutput::legacyAsciiFormatter::encoding() const
|
||||||
{
|
{
|
||||||
return !legacy();
|
return legacyName_;
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
inline bool Foam::foamVtkOutputOptions::append() const
|
|
||||||
{
|
|
||||||
return (type_ & APPEND);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
inline bool Foam::foamVtkOutputOptions::insitu() const
|
|
||||||
{
|
|
||||||
return !(type_ & APPEND);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
inline bool Foam::foamVtkOutputOptions::ascii() const
|
|
||||||
{
|
|
||||||
return !(type_ & (BINARY | BASE64));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
108
src/fileFormats/vtk/format/foamVtkLegacyAsciiFormatter.H
Normal file
108
src/fileFormats/vtk/format/foamVtkLegacyAsciiFormatter.H
Normal file
@ -0,0 +1,108 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd.
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Class
|
||||||
|
Foam::foamVtkOutput::legacyAsciiFormatter
|
||||||
|
|
||||||
|
Description
|
||||||
|
Formatting as per Foam::foamVtkOutput::asciiFormatter, but with
|
||||||
|
naming for legacy output.
|
||||||
|
|
||||||
|
SourceFiles
|
||||||
|
foamVtkLegacyAsciiFormatter.C
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef foamVtkLegacyAsciiFormatter_H
|
||||||
|
#define foamVtkLegacyAsciiFormatter_H
|
||||||
|
|
||||||
|
#include "foamVtkAsciiFormatter.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
namespace foamVtkOutput
|
||||||
|
{
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class legacyAsciiFormatter Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
class legacyAsciiFormatter
|
||||||
|
:
|
||||||
|
public asciiFormatter
|
||||||
|
{
|
||||||
|
// Private Data Members
|
||||||
|
|
||||||
|
static const char* legacyName_;
|
||||||
|
|
||||||
|
//- Disallow default bitwise copy construct
|
||||||
|
legacyAsciiFormatter(const legacyAsciiFormatter&) = delete;
|
||||||
|
|
||||||
|
//- Disallow default bitwise assignment
|
||||||
|
void operator=(const legacyAsciiFormatter&) = delete;
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
//- Construct and attach to an output stream, use default precision
|
||||||
|
legacyAsciiFormatter(std::ostream& os);
|
||||||
|
|
||||||
|
//- Construct and attach to an output stream, use specified precision
|
||||||
|
legacyAsciiFormatter(std::ostream& os, unsigned precision);
|
||||||
|
|
||||||
|
|
||||||
|
//- Destructor
|
||||||
|
virtual ~legacyAsciiFormatter();
|
||||||
|
|
||||||
|
|
||||||
|
// Member Functions
|
||||||
|
|
||||||
|
//- The output formatType is LEGACY_ASCII.
|
||||||
|
virtual enum formatType format() const
|
||||||
|
{
|
||||||
|
return formatType::LEGACY_ASCII;
|
||||||
|
}
|
||||||
|
|
||||||
|
//- Name for the legacy ascii output type ("ASCII")
|
||||||
|
virtual const char* name() const;
|
||||||
|
|
||||||
|
//- Name for the XML append encoding (unused).
|
||||||
|
// Currently identical to name(), but do not rely on this.
|
||||||
|
virtual const char* encoding() const;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace foamVtkOutput
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -23,17 +23,17 @@ License
|
|||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include "foamVtkLegacyFormatter.H"
|
#include "foamVtkLegacyRawFormatter.H"
|
||||||
#include "endian.H"
|
#include "endian.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
const char* Foam::foamVtkLegacyFormatter::name_ = "BINARY";
|
const char* Foam::foamVtkOutput::legacyRawFormatter::legacyName_ = "BINARY";
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
void Foam::foamVtkLegacyFormatter::write
|
void Foam::foamVtkOutput::legacyRawFormatter::write
|
||||||
(
|
(
|
||||||
const char* s,
|
const char* s,
|
||||||
std::streamsize n
|
std::streamsize n
|
||||||
@ -45,37 +45,46 @@ void Foam::foamVtkLegacyFormatter::write
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
Foam::foamVtkLegacyFormatter::foamVtkLegacyFormatter(std::ostream& os)
|
Foam::foamVtkOutput::legacyRawFormatter::legacyRawFormatter
|
||||||
|
(
|
||||||
|
std::ostream& os
|
||||||
|
)
|
||||||
:
|
:
|
||||||
foamVtkFormatter(os)
|
formatter(os)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
Foam::foamVtkLegacyFormatter::~foamVtkLegacyFormatter()
|
Foam::foamVtkOutput::legacyRawFormatter::~legacyRawFormatter()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
const char* Foam::foamVtkLegacyFormatter::name() const
|
const char* Foam::foamVtkOutput::legacyRawFormatter::name() const
|
||||||
{
|
{
|
||||||
return name_;
|
return legacyName_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const char* Foam::foamVtkLegacyFormatter::encoding() const
|
const char* Foam::foamVtkOutput::legacyRawFormatter::encoding() const
|
||||||
{
|
{
|
||||||
return name_;
|
return legacyName_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Foam::foamVtkLegacyFormatter::writeSize(const uint64_t ignored)
|
void Foam::foamVtkOutput::legacyRawFormatter::writeSize
|
||||||
|
(
|
||||||
|
const uint64_t ignored
|
||||||
|
)
|
||||||
{/*nop*/}
|
{/*nop*/}
|
||||||
|
|
||||||
|
|
||||||
void Foam::foamVtkLegacyFormatter::write(const uint8_t val)
|
void Foam::foamVtkOutput::legacyRawFormatter::write
|
||||||
|
(
|
||||||
|
const uint8_t val
|
||||||
|
)
|
||||||
{
|
{
|
||||||
// Legacy can only handle 32-bit integers.
|
// Legacy can only handle 32-bit integers.
|
||||||
// Nonetheless promote to 'label' (32 or 64 bit) and deal with it later
|
// Nonetheless promote to 'label' (32 or 64 bit) and deal with it later
|
||||||
@ -84,7 +93,10 @@ void Foam::foamVtkLegacyFormatter::write(const uint8_t val)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Foam::foamVtkLegacyFormatter::write(const label val)
|
void Foam::foamVtkOutput::legacyRawFormatter::write
|
||||||
|
(
|
||||||
|
const label val
|
||||||
|
)
|
||||||
{
|
{
|
||||||
// std::cerr<<"label is:" << sizeof(val) << '\n';
|
// std::cerr<<"label is:" << sizeof(val) << '\n';
|
||||||
|
|
||||||
@ -104,7 +116,10 @@ void Foam::foamVtkLegacyFormatter::write(const label val)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Foam::foamVtkLegacyFormatter::write(const float val)
|
void Foam::foamVtkOutput::legacyRawFormatter::write
|
||||||
|
(
|
||||||
|
const float val
|
||||||
|
)
|
||||||
{
|
{
|
||||||
// std::cerr<<"float is:" << sizeof(val) << '\n';
|
// std::cerr<<"float is:" << sizeof(val) << '\n';
|
||||||
|
|
||||||
@ -122,7 +137,10 @@ void Foam::foamVtkLegacyFormatter::write(const float val)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Foam::foamVtkLegacyFormatter::write(const double val)
|
void Foam::foamVtkOutput::legacyRawFormatter::write
|
||||||
|
(
|
||||||
|
const double val
|
||||||
|
)
|
||||||
{
|
{
|
||||||
// Legacy cannot support Float64 anyhow.
|
// Legacy cannot support Float64 anyhow.
|
||||||
// std::cerr<<"write double as float:" << val << '\n';
|
// std::cerr<<"write double as float:" << val << '\n';
|
||||||
@ -131,7 +149,7 @@ void Foam::foamVtkLegacyFormatter::write(const double val)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Foam::foamVtkLegacyFormatter::flush()
|
void Foam::foamVtkOutput::legacyRawFormatter::flush()
|
||||||
{
|
{
|
||||||
os()<< '\n';
|
os()<< '\n';
|
||||||
}
|
}
|
||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd.
|
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -22,7 +22,7 @@ License
|
|||||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
Class
|
Class
|
||||||
foamVtkLegacyFormatter
|
Foam::foamVtkOutput::legacyRawFormatter
|
||||||
|
|
||||||
Description
|
Description
|
||||||
Binary output for the VTK legacy format, always written as big-endian
|
Binary output for the VTK legacy format, always written as big-endian
|
||||||
@ -31,12 +31,12 @@ Description
|
|||||||
This format should never be used for OpenFOAM with 64-bit label sizes.
|
This format should never be used for OpenFOAM with 64-bit label sizes.
|
||||||
|
|
||||||
SourceFiles
|
SourceFiles
|
||||||
foamVtkLegacyFormatter.C
|
foamVtkLegacyRawFormatter.C
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#ifndef foamVtkLegacyFormatter_H
|
#ifndef foamVtkLegacyRawFormatter_H
|
||||||
#define foamVtkLegacyFormatter_H
|
#define foamVtkLegacyRawFormatter_H
|
||||||
|
|
||||||
#include "foamVtkFormatter.H"
|
#include "foamVtkFormatter.H"
|
||||||
|
|
||||||
@ -44,27 +44,29 @@ SourceFiles
|
|||||||
|
|
||||||
namespace Foam
|
namespace Foam
|
||||||
{
|
{
|
||||||
|
namespace foamVtkOutput
|
||||||
|
{
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*\
|
/*---------------------------------------------------------------------------*\
|
||||||
Class foamVtkLegacyFormatter Declaration
|
Class legacyRawFormatter Declaration
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
class foamVtkLegacyFormatter
|
class legacyRawFormatter
|
||||||
:
|
:
|
||||||
public foamVtkFormatter
|
public formatter
|
||||||
{
|
{
|
||||||
// Private Data Members
|
// Private Data Members
|
||||||
|
|
||||||
static const char* name_;
|
static const char* legacyName_;
|
||||||
|
|
||||||
|
|
||||||
// Private Member Functions
|
// Private Member Functions
|
||||||
|
|
||||||
//- Disallow default bitwise copy construct
|
//- Disallow default bitwise copy construct
|
||||||
foamVtkLegacyFormatter(const foamVtkLegacyFormatter&) = delete;
|
legacyRawFormatter(const legacyRawFormatter&) = delete;
|
||||||
|
|
||||||
//- Disallow default bitwise assignment
|
//- Disallow default bitwise assignment
|
||||||
void operator=(const foamVtkLegacyFormatter&) = delete;
|
void operator=(const legacyRawFormatter&) = delete;
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@ -80,15 +82,21 @@ public:
|
|||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
//- Construct and attach to an output stream
|
//- Construct and attach to an output stream
|
||||||
foamVtkLegacyFormatter(std::ostream& os);
|
legacyRawFormatter(std::ostream& os);
|
||||||
|
|
||||||
|
|
||||||
//- Destructor
|
//- Destructor
|
||||||
virtual ~foamVtkLegacyFormatter();
|
virtual ~legacyRawFormatter();
|
||||||
|
|
||||||
|
|
||||||
// Member Functions
|
// Member Functions
|
||||||
|
|
||||||
|
//- The output formatType is LEGACY_BINARY.
|
||||||
|
virtual enum formatType format() const
|
||||||
|
{
|
||||||
|
return formatType::LEGACY_BINARY;
|
||||||
|
}
|
||||||
|
|
||||||
//- Name for the legacy binary output type ("BINARY")
|
//- Name for the legacy binary output type ("BINARY")
|
||||||
virtual const char* name() const;
|
virtual const char* name() const;
|
||||||
|
|
||||||
@ -112,6 +120,7 @@ public:
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace foamVtkOutput
|
||||||
} // End namespace Foam
|
} // End namespace Foam
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
@ -1,235 +0,0 @@
|
|||||||
/*---------------------------------------------------------------------------*\
|
|
||||||
========= |
|
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
|
||||||
\\ / O peration |
|
|
||||||
\\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd.
|
|
||||||
\\/ M anipulation |
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
License
|
|
||||||
This file is part of OpenFOAM.
|
|
||||||
|
|
||||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
|
||||||
under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
|
||||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
||||||
for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
#include "foamVtkOutputOptions.H"
|
|
||||||
|
|
||||||
#include "foamVtkAppendBase64Formatter.H"
|
|
||||||
#include "foamVtkAppendRawFormatter.H"
|
|
||||||
#include "foamVtkAsciiFormatter.H"
|
|
||||||
#include "foamVtkBase64Formatter.H"
|
|
||||||
#include "foamVtkLegacyFormatter.H"
|
|
||||||
|
|
||||||
#include "IOstream.H"
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * Constructor * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
Foam::foamVtkOutputOptions::foamVtkOutputOptions()
|
|
||||||
:
|
|
||||||
type_(ASCII),
|
|
||||||
precision_(IOstream::defaultPrecision())
|
|
||||||
{}
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
Foam::autoPtr<Foam::foamVtkFormatter>
|
|
||||||
Foam::foamVtkOutputOptions::newFormatter(std::ostream& os) const
|
|
||||||
{
|
|
||||||
switch (type_)
|
|
||||||
{
|
|
||||||
case (LEGACY | BINARY):
|
|
||||||
return autoPtr<foamVtkFormatter>
|
|
||||||
(
|
|
||||||
new foamVtkLegacyFormatter(os)
|
|
||||||
);
|
|
||||||
|
|
||||||
case BASE64: // xml insitu
|
|
||||||
return autoPtr<foamVtkFormatter>
|
|
||||||
(
|
|
||||||
new foamVtkBase64Formatter(os)
|
|
||||||
);
|
|
||||||
|
|
||||||
case (APPEND | BASE64):
|
|
||||||
return autoPtr<foamVtkFormatter>
|
|
||||||
(
|
|
||||||
new foamVtkAppendBase64Formatter(os)
|
|
||||||
);
|
|
||||||
|
|
||||||
case (APPEND | BINARY):
|
|
||||||
return autoPtr<foamVtkFormatter>
|
|
||||||
(
|
|
||||||
new foamVtkAppendRawFormatter(os)
|
|
||||||
);
|
|
||||||
|
|
||||||
default: // ASCII (legacy or xml) must always work
|
|
||||||
return autoPtr<foamVtkFormatter>
|
|
||||||
(
|
|
||||||
new foamVtkAsciiFormatter(os, precision_)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
void Foam::foamVtkOutputOptions::ascii(bool on)
|
|
||||||
{
|
|
||||||
if (on)
|
|
||||||
{
|
|
||||||
// Force ASCII:
|
|
||||||
|
|
||||||
if (type_ & APPEND)
|
|
||||||
{
|
|
||||||
// Append: ascii = base64 (vs raw binary)
|
|
||||||
type_ = (APPEND | BASE64);
|
|
||||||
}
|
|
||||||
else if (type_ & LEGACY)
|
|
||||||
{
|
|
||||||
// Legacy: ascii = ascii
|
|
||||||
type_ = (LEGACY | ASCII);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// XML: ascii = ascii
|
|
||||||
type_ = ASCII;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Non-ASCII:
|
|
||||||
|
|
||||||
if (type_ & APPEND)
|
|
||||||
{
|
|
||||||
// Append: binary == (raw) binary
|
|
||||||
type_ = APPEND | BINARY;
|
|
||||||
}
|
|
||||||
else if (type_ & LEGACY)
|
|
||||||
{
|
|
||||||
// Legacy: binary = binary
|
|
||||||
type_ = LEGACY | BINARY;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// XML: binary == (inline) binary == base64
|
|
||||||
type_ = BASE64;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Foam::foamVtkOutputOptions::append(bool on)
|
|
||||||
{
|
|
||||||
if (on)
|
|
||||||
{
|
|
||||||
if (!(type_ & APPEND))
|
|
||||||
{
|
|
||||||
// XML: base64 -> raw binary, ascii -> base64
|
|
||||||
// Legacy: binary -> raw binary, ascii -> base64
|
|
||||||
type_ = APPEND | ((type_ & (BASE64 | BINARY)) ? BINARY : BASE64);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (type_ & APPEND)
|
|
||||||
{
|
|
||||||
// Only revert back to inline XML base64 versions
|
|
||||||
// ASCII needs another step.
|
|
||||||
|
|
||||||
type_ = BASE64;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Foam::foamVtkOutputOptions::legacy(bool on)
|
|
||||||
{
|
|
||||||
if (on)
|
|
||||||
{
|
|
||||||
if (type_ & APPEND)
|
|
||||||
{
|
|
||||||
// Append: base64 -> ascii, binary -> binary
|
|
||||||
type_ = (LEGACY | ((type_ & BINARY) ? BINARY : ASCII));
|
|
||||||
}
|
|
||||||
else if (type_ & LEGACY)
|
|
||||||
{
|
|
||||||
// no-op
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// XML: ascii -> ascii, base64 -> binary
|
|
||||||
type_ = (LEGACY | ((type_ & BASE64) ? BINARY : ASCII));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (type_ & LEGACY)
|
|
||||||
{
|
|
||||||
// Legacy: ascii -> xml ascii, binary -> xml base64
|
|
||||||
type_ = (type_ & BINARY) ? BASE64 : ASCII;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Foam::foamVtkOutputOptions::precision(unsigned prec) const
|
|
||||||
{
|
|
||||||
precision_ = prec;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Foam::Ostream& Foam::foamVtkOutputOptions::info(Ostream& os) const
|
|
||||||
{
|
|
||||||
os << "type: " << type_;
|
|
||||||
|
|
||||||
switch (type_)
|
|
||||||
{
|
|
||||||
case (LEGACY | ASCII):
|
|
||||||
os << " legacy ascii";
|
|
||||||
break;
|
|
||||||
|
|
||||||
case (LEGACY | BINARY):
|
|
||||||
os << " legacy binary";
|
|
||||||
break;
|
|
||||||
|
|
||||||
case BASE64:
|
|
||||||
os << " xml insitu base64";
|
|
||||||
break;
|
|
||||||
|
|
||||||
case (APPEND | BASE64):
|
|
||||||
os << " xml-append base64";
|
|
||||||
break;
|
|
||||||
|
|
||||||
case (APPEND | BINARY):
|
|
||||||
os << " xml-append binary";
|
|
||||||
break;
|
|
||||||
|
|
||||||
case ASCII:
|
|
||||||
os << " xml insitu ascii";
|
|
||||||
break;
|
|
||||||
|
|
||||||
case BINARY:
|
|
||||||
os << " xml insitu binary - WRONG";
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
os << " unknown";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (legacy()) os << " legacy";
|
|
||||||
if (xml()) os << " xml";
|
|
||||||
if (append()) os << " append";
|
|
||||||
if (ascii()) os << " ascii";
|
|
||||||
|
|
||||||
return os;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
|
||||||
@ -24,31 +24,63 @@ License
|
|||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include "foamVtkOutput.H"
|
#include "foamVtkOutput.H"
|
||||||
#include "foamVtkAsciiFormatter.H"
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
#include "foamVtkFormatter.H"
|
||||||
|
#include "foamVtkAsciiFormatter.H"
|
||||||
|
#include "foamVtkBase64Formatter.H"
|
||||||
|
#include "foamVtkAppendBase64Formatter.H"
|
||||||
|
#include "foamVtkAppendRawFormatter.H"
|
||||||
|
#include "foamVtkLegacyAsciiFormatter.H"
|
||||||
|
#include "foamVtkLegacyRawFormatter.H"
|
||||||
|
#include "typeInfo.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Static Data * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
const Foam::word Foam::foamVtkOutput::legacy::EXT = "vtk";
|
const Foam::word Foam::foamVtkOutput::legacy::EXT = "vtk";
|
||||||
|
|
||||||
|
|
||||||
//! \cond fileScope
|
// * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * * //
|
||||||
static inline std::ostream& legacyDataHeader
|
|
||||||
|
Foam::autoPtr<Foam::foamVtkOutput::formatter>
|
||||||
|
Foam::foamVtkOutput::newFormatter
|
||||||
(
|
(
|
||||||
std::ostream& os,
|
std::ostream& os,
|
||||||
const char* tag,
|
const enum formatType fmtType,
|
||||||
const Foam::label nItems,
|
unsigned prec
|
||||||
const Foam::label nFields
|
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
os << tag << ' ' << nItems << '\n'
|
autoPtr<foamVtkOutput::formatter> fmt;
|
||||||
<< "FIELD attributes " << nFields << '\n';
|
|
||||||
|
|
||||||
return os;
|
switch (fmtType)
|
||||||
|
{
|
||||||
|
case INLINE_ASCII:
|
||||||
|
fmt.set(new foamVtkOutput::asciiFormatter(os, prec));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case INLINE_BASE64:
|
||||||
|
fmt.set(new foamVtkOutput::base64Formatter(os));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case APPEND_BASE64:
|
||||||
|
fmt.set(new foamVtkOutput::appendBase64Formatter(os));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case APPEND_BINARY:
|
||||||
|
fmt.set(new foamVtkOutput::appendRawFormatter(os));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case LEGACY_ASCII:
|
||||||
|
fmt.set(new foamVtkOutput::legacyAsciiFormatter(os, prec));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case LEGACY_BINARY:
|
||||||
|
fmt.set(new foamVtkOutput::legacyRawFormatter(os));
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
//! \endcond
|
|
||||||
|
|
||||||
|
return fmt;
|
||||||
|
}
|
||||||
|
|
||||||
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
Foam::label Foam::foamVtkOutput::writeVtmFile
|
Foam::label Foam::foamVtkOutput::writeVtmFile
|
||||||
(
|
(
|
||||||
@ -58,7 +90,7 @@ Foam::label Foam::foamVtkOutput::writeVtmFile
|
|||||||
{
|
{
|
||||||
const word& content = "vtkMultiBlockDataSet";
|
const word& content = "vtkMultiBlockDataSet";
|
||||||
|
|
||||||
foamVtkAsciiFormatter vtmFile(os);
|
asciiFormatter vtmFile(os);
|
||||||
|
|
||||||
vtmFile
|
vtmFile
|
||||||
.xmlHeader()
|
.xmlHeader()
|
||||||
@ -79,7 +111,7 @@ Foam::label Foam::foamVtkOutput::writeVtmFile
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::ostream& Foam::foamVtkOutput::legacy::writeHeader
|
std::ostream& Foam::foamVtkOutput::legacy::fileHeader
|
||||||
(
|
(
|
||||||
std::ostream& os,
|
std::ostream& os,
|
||||||
const std::string& title,
|
const std::string& title,
|
||||||
@ -94,25 +126,41 @@ std::ostream& Foam::foamVtkOutput::legacy::writeHeader
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::ostream& Foam::foamVtkOutput::legacy::writeCellDataHeader
|
std::ostream& Foam::foamVtkOutput::legacy::fileHeader
|
||||||
|
(
|
||||||
|
foamVtkOutput::formatter& fmt,
|
||||||
|
const std::string& title
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return fileHeader(fmt.os(), title, isType<legacyRawFormatter>(fmt));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
std::ostream& Foam::foamVtkOutput::legacy::cellDataHeader
|
||||||
(
|
(
|
||||||
std::ostream& os,
|
std::ostream& os,
|
||||||
const label nCells,
|
const label nCells,
|
||||||
const label nFields
|
const label nFields
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return legacyDataHeader(os, "CELL_DATA", nCells, nFields);
|
os << "CELL_DATA " << nCells << nl
|
||||||
|
<< "FIELD attributes " << nFields << nl;
|
||||||
|
|
||||||
|
return os;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::ostream& Foam::foamVtkOutput::legacy::writePointDataHeader
|
std::ostream& Foam::foamVtkOutput::legacy::pointDataHeader
|
||||||
(
|
(
|
||||||
std::ostream& os,
|
std::ostream& os,
|
||||||
const label nPoints,
|
const label nPoints,
|
||||||
const label nFields
|
const label nFields
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return legacyDataHeader(os, "POINT_DATA", nPoints, nFields);
|
os << "POINT_DATA " << nPoints << nl
|
||||||
|
<< "FIELD attributes " << nFields << nl;
|
||||||
|
|
||||||
|
return os;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
211
src/fileFormats/vtk/output/foamVtkOutput.H
Normal file
211
src/fileFormats/vtk/output/foamVtkOutput.H
Normal file
@ -0,0 +1,211 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd.
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Namespace
|
||||||
|
Foam::foamVtkOutput
|
||||||
|
|
||||||
|
Description
|
||||||
|
Namespace for handling VTK output.
|
||||||
|
Contains classes and functions for writing VTK file content.
|
||||||
|
|
||||||
|
Namespace
|
||||||
|
Foam::foamVtkOutput::legacy
|
||||||
|
|
||||||
|
Description
|
||||||
|
Namespace for legacy VTK output functions.
|
||||||
|
|
||||||
|
SourceFiles
|
||||||
|
foamVtkOutput.C
|
||||||
|
foamVtkOutputTemplates.C
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef foamVtkOutput_H
|
||||||
|
#define foamVtkOutput_H
|
||||||
|
|
||||||
|
#include "autoPtr.H"
|
||||||
|
#include "foamVtkOutputTypes.H"
|
||||||
|
#include "foamVtkFormatter.H"
|
||||||
|
#include "floatScalar.H"
|
||||||
|
#include "IOstream.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
namespace foamVtkOutput
|
||||||
|
{
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
// Typedefs
|
||||||
|
|
||||||
|
//- Use UInt64 for header data
|
||||||
|
typedef formatter::headerType headerType;
|
||||||
|
|
||||||
|
|
||||||
|
// General Functions
|
||||||
|
|
||||||
|
//- Return a default asciiFormatter
|
||||||
|
autoPtr<foamVtkOutput::formatter> newFormatter(std::ostream& os);
|
||||||
|
|
||||||
|
|
||||||
|
//- Return a new formatter based on the specified format type
|
||||||
|
autoPtr<foamVtkOutput::formatter> newFormatter
|
||||||
|
(
|
||||||
|
std::ostream& os,
|
||||||
|
const enum formatType fmtType,
|
||||||
|
unsigned prec = IOstream::defaultPrecision()
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
//- Write vtm datasets for specified files
|
||||||
|
label writeVtmFile(std::ostream& os, const UList<fileName>& files);
|
||||||
|
|
||||||
|
|
||||||
|
//- Write a value component-wise.
|
||||||
|
template<class Type>
|
||||||
|
inline void write
|
||||||
|
(
|
||||||
|
foamVtkOutput::formatter& fmt,
|
||||||
|
const Type& val
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
//- Write a list of values.
|
||||||
|
// The output does not include the payload size.
|
||||||
|
template<class Type>
|
||||||
|
void writeList
|
||||||
|
(
|
||||||
|
foamVtkOutput::formatter& fmt,
|
||||||
|
const UList<Type>& lst
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
//- Write a list of values via indirect addressing.
|
||||||
|
// The output does not include the payload size.
|
||||||
|
template<class Type>
|
||||||
|
void writeList
|
||||||
|
(
|
||||||
|
foamVtkOutput::formatter& fmt,
|
||||||
|
const UList<Type>& lst,
|
||||||
|
const UList<label>& addressing
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Namespace legacy
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
//- Some minimal additional support for writing legacy files
|
||||||
|
namespace legacy
|
||||||
|
{
|
||||||
|
// Constants
|
||||||
|
|
||||||
|
//- File extension for legacy files (vtk)
|
||||||
|
extern const Foam::word EXT;
|
||||||
|
|
||||||
|
|
||||||
|
// Functions
|
||||||
|
|
||||||
|
//- Emit header for legacy file.
|
||||||
|
// Writes "ASCII" or "BINARY" depending on specified type.
|
||||||
|
std::ostream& fileHeader
|
||||||
|
(
|
||||||
|
std::ostream& os,
|
||||||
|
const std::string& title,
|
||||||
|
const bool binary = false
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Emit header for legacy file.
|
||||||
|
// Writes "ASCII" or "BINARY" depending on the formatter type.
|
||||||
|
std::ostream& fileHeader
|
||||||
|
(
|
||||||
|
foamVtkOutput::formatter& fmt,
|
||||||
|
const std::string& title
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Emit header for legacy CELL_DATA
|
||||||
|
std::ostream& cellDataHeader
|
||||||
|
(
|
||||||
|
std::ostream& os,
|
||||||
|
const label nCells,
|
||||||
|
const label nFields
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
//- Emit header for legacy POINT_DATA
|
||||||
|
std::ostream& pointDataHeader
|
||||||
|
(
|
||||||
|
std::ostream& os,
|
||||||
|
const label nPoints,
|
||||||
|
const label nFields
|
||||||
|
);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
//- Template specialization for label
|
||||||
|
template<>
|
||||||
|
inline void write<label>(foamVtkOutput::formatter& fmt, const label& val)
|
||||||
|
{
|
||||||
|
fmt.write(val);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//- Template specialization for float
|
||||||
|
template<>
|
||||||
|
inline void write<float>(foamVtkOutput::formatter& fmt, const float& val)
|
||||||
|
{
|
||||||
|
fmt.write(val);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//- Template specialization for double
|
||||||
|
template<>
|
||||||
|
inline void write<double>(foamVtkOutput::formatter& fmt, const double& val)
|
||||||
|
{
|
||||||
|
fmt.write(val);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // End namespace foamVtkOutput
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#ifdef NoRepository
|
||||||
|
#include "foamVtkOutputTemplates.C"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
131
src/fileFormats/vtk/output/foamVtkOutputOptions.C
Normal file
131
src/fileFormats/vtk/output/foamVtkOutputOptions.C
Normal file
@ -0,0 +1,131 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd.
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "foamVtkOutputOptions.H"
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::foamVtkOutput::outputOptions&
|
||||||
|
Foam::foamVtkOutput::outputOptions::ascii(bool on)
|
||||||
|
{
|
||||||
|
if (on)
|
||||||
|
{
|
||||||
|
switch (fmtType_)
|
||||||
|
{
|
||||||
|
case INLINE_BASE64: fmtType_ = INLINE_ASCII; break;
|
||||||
|
case APPEND_BINARY: fmtType_ = APPEND_BASE64; break;
|
||||||
|
case LEGACY_BINARY: fmtType_ = LEGACY_ASCII; break;
|
||||||
|
default: break; // no change
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
switch (fmtType_)
|
||||||
|
{
|
||||||
|
case INLINE_ASCII: fmtType_ = INLINE_BASE64; break;
|
||||||
|
case APPEND_BASE64: fmtType_ = APPEND_BINARY; break;
|
||||||
|
case LEGACY_ASCII: fmtType_ = LEGACY_BINARY; break;
|
||||||
|
default: break; // no change
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::foamVtkOutput::outputOptions&
|
||||||
|
Foam::foamVtkOutput::outputOptions::append(bool on)
|
||||||
|
{
|
||||||
|
if (on)
|
||||||
|
{
|
||||||
|
switch (fmtType_)
|
||||||
|
{
|
||||||
|
case INLINE_ASCII: fmtType_ = APPEND_BASE64; break;
|
||||||
|
case LEGACY_ASCII: fmtType_ = APPEND_BASE64; break;
|
||||||
|
case INLINE_BASE64: fmtType_ = APPEND_BINARY; break;
|
||||||
|
case LEGACY_BINARY: fmtType_ = APPEND_BINARY; break;
|
||||||
|
default: break; // no change
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
switch (fmtType_)
|
||||||
|
{
|
||||||
|
case APPEND_BASE64: fmtType_ = INLINE_ASCII; break;
|
||||||
|
case APPEND_BINARY: fmtType_ = INLINE_BASE64; break;
|
||||||
|
default: break; // no change
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::foamVtkOutput::outputOptions&
|
||||||
|
Foam::foamVtkOutput::outputOptions::legacy(bool on)
|
||||||
|
{
|
||||||
|
if (on)
|
||||||
|
{
|
||||||
|
switch (fmtType_)
|
||||||
|
{
|
||||||
|
case INLINE_ASCII: fmtType_ = LEGACY_ASCII; break;
|
||||||
|
case INLINE_BASE64: fmtType_ = LEGACY_BINARY; break;
|
||||||
|
case APPEND_BASE64: fmtType_ = LEGACY_ASCII; break;
|
||||||
|
case APPEND_BINARY: fmtType_ = LEGACY_BINARY; break;
|
||||||
|
default: break; // no change
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
switch (fmtType_)
|
||||||
|
{
|
||||||
|
case LEGACY_ASCII: fmtType_ = INLINE_ASCII; break;
|
||||||
|
case LEGACY_BINARY: fmtType_ = INLINE_BASE64; break;
|
||||||
|
default: break; // no change
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::string Foam::foamVtkOutput::outputOptions::description() const
|
||||||
|
{
|
||||||
|
switch (fmtType_)
|
||||||
|
{
|
||||||
|
case INLINE_ASCII: return "xml ascii";
|
||||||
|
case INLINE_BASE64: return "xml base64";
|
||||||
|
case APPEND_BASE64: return "xml-append base64";
|
||||||
|
case APPEND_BINARY: return "xml-append binary";
|
||||||
|
case LEGACY_ASCII: return "legacy ascii";
|
||||||
|
case LEGACY_BINARY: return "legacy binary";
|
||||||
|
}
|
||||||
|
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -22,10 +22,12 @@ License
|
|||||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
Class
|
Class
|
||||||
foamVtkOutputOptions
|
Foam::foamVtkOutput::outputOptions
|
||||||
|
|
||||||
Description
|
Description
|
||||||
Encapsulate combinations of output format options.
|
Encapsulated combinations of output format options.
|
||||||
|
This is primarily useful when defining the output type based on some
|
||||||
|
command-line arguments or dictionary contents.
|
||||||
|
|
||||||
SourceFiles
|
SourceFiles
|
||||||
foamVtkOutputOptions.C
|
foamVtkOutputOptions.C
|
||||||
@ -35,43 +37,36 @@ SourceFiles
|
|||||||
#ifndef foamVtkOutputOptions_H
|
#ifndef foamVtkOutputOptions_H
|
||||||
#define foamVtkOutputOptions_H
|
#define foamVtkOutputOptions_H
|
||||||
|
|
||||||
#include "autoPtr.H"
|
#include "foamVtkOutput.H"
|
||||||
#include "foamVtkFormatter.H"
|
#include "string.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
namespace Foam
|
namespace Foam
|
||||||
{
|
{
|
||||||
class Ostream;
|
namespace foamVtkOutput
|
||||||
|
{
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*\
|
/*---------------------------------------------------------------------------*\
|
||||||
Class foamVtkOutputOptions Declaration
|
Class outputOptions Declaration
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
class foamVtkOutputOptions
|
class outputOptions
|
||||||
{
|
{
|
||||||
// Private data
|
private:
|
||||||
|
|
||||||
//- The supported output/format types
|
// Private Member Data
|
||||||
enum foamVtkOptionTypes
|
|
||||||
{
|
|
||||||
ASCII = 0x0000, //!< ASCII formatting for data
|
|
||||||
BINARY = 0x0001, //!< Raw binary formatting for data
|
|
||||||
BASE64 = 0x0002, //!< Base64 encoding for data
|
|
||||||
LEGACY = 0x0100, //!< Legacy vtk file format
|
|
||||||
APPEND = 0x0200 //!< XML append format
|
|
||||||
};
|
|
||||||
|
|
||||||
//- The output style tuning
|
//- The output style tuning
|
||||||
enum foamVtkStyleOptions
|
enum styleType
|
||||||
{
|
{
|
||||||
NONE = 0x0000, //!< Normal
|
NONE = 0x00, //!< Normal
|
||||||
HEADER = 0x0001 //!< Emit xml header
|
HEADER = 0x01 //!< Emit xml header
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
//- The output format type
|
//- The output format type
|
||||||
unsigned short type_;
|
formatType fmtType_;
|
||||||
|
|
||||||
//- ASCII write precision
|
//- ASCII write precision
|
||||||
mutable unsigned precision_;
|
mutable unsigned precision_;
|
||||||
@ -82,19 +77,25 @@ public:
|
|||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
//- Construct null - XML insitu ASCII format with default precision
|
//- Construct null - XML insitu ASCII format with default precision
|
||||||
foamVtkOutputOptions();
|
inline outputOptions();
|
||||||
|
|
||||||
|
//- Construct with specified format
|
||||||
|
inline outputOptions(enum formatType fmtType);
|
||||||
|
|
||||||
|
|
||||||
// Selectors
|
// Selectors
|
||||||
|
|
||||||
//- Return new data formatter based on the writer options
|
//- Return new formatter based on the selected output options
|
||||||
autoPtr<foamVtkFormatter> newFormatter(std::ostream& os) const;
|
inline autoPtr<formatter> newFormatter(std::ostream& os) const;
|
||||||
|
|
||||||
|
|
||||||
// Member Functions
|
// Member Functions
|
||||||
|
|
||||||
// Access
|
// Access
|
||||||
|
|
||||||
|
//- The output format type
|
||||||
|
inline formatType format() const;
|
||||||
|
|
||||||
//- True if writer uses legacy file format
|
//- True if writer uses legacy file format
|
||||||
inline bool legacy() const;
|
inline bool legacy() const;
|
||||||
|
|
||||||
@ -114,31 +115,36 @@ public:
|
|||||||
// Edit
|
// Edit
|
||||||
|
|
||||||
//- Toggle ASCII mode on/off.
|
//- Toggle ASCII mode on/off.
|
||||||
// In append mode, this switches between base64 and raw binary.
|
// In XML append mode, this switches between base64 and raw binary.
|
||||||
// In XML mode, this switches between ASCII and base64.
|
// In XML inline mode, this switches between ASCII and base64.
|
||||||
// In legacy mode, this switches between ASCII and binary.
|
// In legacy mode, this switches between ASCII and binary.
|
||||||
void ascii(bool on);
|
// \return outputOptions for chaining
|
||||||
|
outputOptions& ascii(bool on);
|
||||||
|
|
||||||
//- Toggle append mode on/off.
|
//- Toggle append mode on/off.
|
||||||
void append(bool on);
|
// \return outputOptions for chaining
|
||||||
|
outputOptions& append(bool on);
|
||||||
|
|
||||||
//- Toggle legacy mode on/off.
|
//- Toggle legacy mode on/off.
|
||||||
void legacy(bool on);
|
// \return outputOptions for chaining
|
||||||
|
outputOptions& legacy(bool on);
|
||||||
|
|
||||||
//- Set the write precision to be used for new ASCII formatters
|
//- Set the write precision to be used for new ASCII formatters
|
||||||
void precision(unsigned prec) const;
|
// \return outputOptions for chaining
|
||||||
|
inline const outputOptions& precision(unsigned prec) const;
|
||||||
|
|
||||||
|
|
||||||
// Other
|
// Other
|
||||||
|
|
||||||
//- Report information about the options
|
//- Report description about the option selected
|
||||||
Ostream& info(Ostream&) const;
|
string description() const;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace foamVtkOutput
|
||||||
} // End namespace Foam
|
} // End namespace Foam
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
102
src/fileFormats/vtk/output/foamVtkOutputOptionsI.H
Normal file
102
src/fileFormats/vtk/output/foamVtkOutputOptionsI.H
Normal file
@ -0,0 +1,102 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd.
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
inline Foam::foamVtkOutput::outputOptions::outputOptions()
|
||||||
|
:
|
||||||
|
fmtType_(INLINE_ASCII),
|
||||||
|
precision_(IOstream::defaultPrecision())
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
inline Foam::foamVtkOutput::outputOptions::outputOptions
|
||||||
|
(
|
||||||
|
enum formatType fmtType
|
||||||
|
)
|
||||||
|
:
|
||||||
|
fmtType_(fmtType),
|
||||||
|
precision_(IOstream::defaultPrecision())
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
inline Foam::autoPtr<Foam::foamVtkOutput::formatter>
|
||||||
|
Foam::foamVtkOutput::outputOptions::newFormatter(std::ostream& os) const
|
||||||
|
{
|
||||||
|
return foamVtkOutput::newFormatter(os, fmtType_, precision_);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
inline Foam::foamVtkOutput::formatType
|
||||||
|
Foam::foamVtkOutput::outputOptions::format() const
|
||||||
|
{
|
||||||
|
return fmtType_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline bool Foam::foamVtkOutput::outputOptions::legacy() const
|
||||||
|
{
|
||||||
|
return (fmtType_ & formatType::LEGACY_ASCII & formatType::LEGACY_BINARY);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline bool Foam::foamVtkOutput::outputOptions::xml() const
|
||||||
|
{
|
||||||
|
return !legacy();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline bool Foam::foamVtkOutput::outputOptions::append() const
|
||||||
|
{
|
||||||
|
return (fmtType_ & formatType::APPEND_BASE64 & formatType::APPEND_BINARY);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline bool Foam::foamVtkOutput::outputOptions::insitu() const
|
||||||
|
{
|
||||||
|
return !append();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline bool Foam::foamVtkOutput::outputOptions::ascii() const
|
||||||
|
{
|
||||||
|
return !(fmtType_ & 0xF);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline const Foam::foamVtkOutput::outputOptions&
|
||||||
|
Foam::foamVtkOutput::outputOptions::precision(unsigned prec) const
|
||||||
|
{
|
||||||
|
precision_ = prec;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -25,11 +25,10 @@ License
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
|
||||||
template<class Type>
|
template<class Type>
|
||||||
inline void Foam::foamVtkOutput::write
|
inline void Foam::foamVtkOutput::write
|
||||||
(
|
(
|
||||||
foamVtkFormatter& fmt,
|
foamVtkOutput::formatter& fmt,
|
||||||
const Type& val
|
const Type& val
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
@ -43,7 +42,7 @@ inline void Foam::foamVtkOutput::write
|
|||||||
template<class Type>
|
template<class Type>
|
||||||
void Foam::foamVtkOutput::writeList
|
void Foam::foamVtkOutput::writeList
|
||||||
(
|
(
|
||||||
foamVtkFormatter& fmt,
|
foamVtkOutput::formatter& fmt,
|
||||||
const UList<Type>& lst
|
const UList<Type>& lst
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
@ -57,7 +56,7 @@ void Foam::foamVtkOutput::writeList
|
|||||||
template<class Type>
|
template<class Type>
|
||||||
void Foam::foamVtkOutput::writeList
|
void Foam::foamVtkOutput::writeList
|
||||||
(
|
(
|
||||||
foamVtkFormatter& fmt,
|
foamVtkOutput::formatter& fmt,
|
||||||
const UList<Type>& lst,
|
const UList<Type>& lst,
|
||||||
const UList<label>& addressing
|
const UList<label>& addressing
|
||||||
)
|
)
|
||||||
@ -69,43 +68,4 @@ void Foam::foamVtkOutput::writeList
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class Type>
|
|
||||||
void Foam::foamVtkOutput::writeField
|
|
||||||
(
|
|
||||||
foamVtkFormatter& fmt,
|
|
||||||
const GeometricField<Type, fvPatchField, volMesh>& vf
|
|
||||||
)
|
|
||||||
{
|
|
||||||
const uint64_t payLoad =
|
|
||||||
(
|
|
||||||
vf.size() * pTraits<Type>::nComponents * sizeof(float)
|
|
||||||
);
|
|
||||||
|
|
||||||
fmt.writeSize(payLoad);
|
|
||||||
writeList(fmt, vf.internalField());
|
|
||||||
|
|
||||||
fmt.flush();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class Type>
|
|
||||||
void Foam::foamVtkOutput::writeField
|
|
||||||
(
|
|
||||||
foamVtkFormatter& fmt,
|
|
||||||
const GeometricField<Type, fvPatchField, volMesh>& vf,
|
|
||||||
const UList<label>& cellMap
|
|
||||||
)
|
|
||||||
{
|
|
||||||
const uint64_t payLoad =
|
|
||||||
(
|
|
||||||
cellMap.size() * pTraits<Type>::nComponents * sizeof(float)
|
|
||||||
);
|
|
||||||
|
|
||||||
fmt.writeSize(payLoad);
|
|
||||||
writeList(fmt, vf.internalField(), cellMap);
|
|
||||||
|
|
||||||
fmt.flush();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
77
src/fileFormats/vtk/type/foamVtkOutputTypes.H
Normal file
77
src/fileFormats/vtk/type/foamVtkOutputTypes.H
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd.
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
InNamespace
|
||||||
|
Foam::foamVtkOutput
|
||||||
|
|
||||||
|
Description
|
||||||
|
Enumerations and typedefs for VTK output.
|
||||||
|
|
||||||
|
SourceFiles
|
||||||
|
foamVtkOutputTypes.H
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef foamVtkOutputTypes_H
|
||||||
|
#define foamVtkOutputTypes_H
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
namespace foamVtkOutput
|
||||||
|
{
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
// Enumerations
|
||||||
|
|
||||||
|
//- The output format type for file contents.
|
||||||
|
// Upper bits for output type, lower bits for the format itself.
|
||||||
|
enum formatType
|
||||||
|
{
|
||||||
|
/** XML inline ASCII, using the asciiFormatter */
|
||||||
|
INLINE_ASCII = 0,
|
||||||
|
/** XML inline base64, using the base64Formatter */
|
||||||
|
INLINE_BASE64 = 0x01,
|
||||||
|
/** XML append base64, using the appendBase64Formatter */
|
||||||
|
APPEND_BASE64 = 0x11,
|
||||||
|
/** XML append raw binary, using the appendRawFormatter */
|
||||||
|
APPEND_BINARY = 0x12,
|
||||||
|
/** Legacy ASCII, using the legacyAsciiFormatter */
|
||||||
|
LEGACY_ASCII = 0x20,
|
||||||
|
/** Legacy raw binary, using the legacyRawFormatter */
|
||||||
|
LEGACY_BINARY = 0x22,
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace foamVtkOutput
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
Reference in New Issue
Block a user