mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: update coding for VTK fileFormats, make open() virtual
- add writer support for VERTICES - updated use of globalIndex ENH: add base vtk writer for points/verts/lines STYLE: noexcept, explicit constructors etc
This commit is contained in:
@ -55,25 +55,25 @@ std::size_t Foam::base64Layer::encodedLength(std::size_t n)
|
|||||||
|
|
||||||
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
|
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
|
||||||
|
|
||||||
inline unsigned char Foam::base64Layer::encode0() const
|
inline unsigned char Foam::base64Layer::encode0() const noexcept
|
||||||
{
|
{
|
||||||
// Top 6 bits of char0
|
// Top 6 bits of char0
|
||||||
return base64Chars[((group_[0] & 0xFC) >> 2)];
|
return base64Chars[((group_[0] & 0xFC) >> 2)];
|
||||||
}
|
}
|
||||||
|
|
||||||
inline unsigned char Foam::base64Layer::encode1() const
|
inline unsigned char Foam::base64Layer::encode1() const noexcept
|
||||||
{
|
{
|
||||||
// Bottom 2 bits of char0, Top 4 bits of char1
|
// Bottom 2 bits of char0, Top 4 bits of char1
|
||||||
return base64Chars[((group_[0] & 0x03) << 4) | ((group_[1] & 0xF0) >> 4)];
|
return base64Chars[((group_[0] & 0x03) << 4) | ((group_[1] & 0xF0) >> 4)];
|
||||||
}
|
}
|
||||||
|
|
||||||
inline unsigned char Foam::base64Layer::encode2() const
|
inline unsigned char Foam::base64Layer::encode2() const noexcept
|
||||||
{
|
{
|
||||||
// Bottom 4 bits of char1, Top 2 bits of char2
|
// Bottom 4 bits of char1, Top 2 bits of char2
|
||||||
return base64Chars[((group_[1] & 0x0F) << 2) | ((group_[2] & 0xC0) >> 6)];
|
return base64Chars[((group_[1] & 0x0F) << 2) | ((group_[2] & 0xC0) >> 6)];
|
||||||
}
|
}
|
||||||
|
|
||||||
inline unsigned char Foam::base64Layer::encode3() const
|
inline unsigned char Foam::base64Layer::encode3() const noexcept
|
||||||
{
|
{
|
||||||
// Bottom 6 bits of char2
|
// Bottom 6 bits of char2
|
||||||
return base64Chars[(group_[2] & 0x3F)];
|
return base64Chars[(group_[2] & 0x3F)];
|
||||||
|
|||||||
@ -39,8 +39,8 @@ SourceFiles
|
|||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#ifndef base64Layer_H
|
#ifndef Foam_base64Layer_H
|
||||||
#define base64Layer_H
|
#define Foam_base64Layer_H
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
@ -72,16 +72,10 @@ class base64Layer
|
|||||||
|
|
||||||
// Private Member Functions
|
// Private Member Functions
|
||||||
|
|
||||||
inline unsigned char encode0() const;
|
inline unsigned char encode0() const noexcept;
|
||||||
inline unsigned char encode1() const;
|
inline unsigned char encode1() const noexcept;
|
||||||
inline unsigned char encode2() const;
|
inline unsigned char encode2() const noexcept;
|
||||||
inline unsigned char encode3() const;
|
inline unsigned char encode3() const noexcept;
|
||||||
|
|
||||||
//- No copy construct
|
|
||||||
base64Layer(const base64Layer&) = delete;
|
|
||||||
|
|
||||||
//- No copy assignment
|
|
||||||
void operator=(const base64Layer&) = delete;
|
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@ -91,6 +85,12 @@ protected:
|
|||||||
//- Add a character to the group, outputting when the group is full.
|
//- Add a character to the group, outputting when the group is full.
|
||||||
void add(char c);
|
void add(char c);
|
||||||
|
|
||||||
|
//- No copy construct
|
||||||
|
base64Layer(const base64Layer&) = delete;
|
||||||
|
|
||||||
|
//- No copy assignment
|
||||||
|
void operator=(const base64Layer&) = delete;
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
\\ / A nd | www.openfoam.com
|
\\ / A nd | www.openfoam.com
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2016-2021 OpenCFD Ltd.
|
Copyright (C) 2016-2022 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -52,7 +52,7 @@ namespace vtk
|
|||||||
// Enumerations
|
// Enumerations
|
||||||
|
|
||||||
//- The context when outputting a VTK file (XML or legacy).
|
//- The context when outputting a VTK file (XML or legacy).
|
||||||
enum OutputContext
|
enum OutputContext : uint8_t
|
||||||
{
|
{
|
||||||
INLINE, //!< Generate header and inline data
|
INLINE, //!< Generate header and inline data
|
||||||
HEADER, //!< Generate header only
|
HEADER, //!< Generate header only
|
||||||
@ -72,21 +72,21 @@ namespace vtk
|
|||||||
LEGACY_BINARY = 0x22, //!< Legacy raw binary, legacyRawFormatter
|
LEGACY_BINARY = 0x22, //!< Legacy raw binary, legacyRawFormatter
|
||||||
};
|
};
|
||||||
|
|
||||||
//- Test for XML append format
|
//- Test for vtk append format (xml)
|
||||||
inline bool isAppend(enum formatType fmt)
|
inline bool isAppend(enum formatType fmt) noexcept
|
||||||
{
|
{
|
||||||
return (uint8_t(fmt) & 0x10);
|
return (uint8_t(fmt) & 0x10);
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Test for vtk legacy format
|
//- Test for vtk legacy format
|
||||||
inline bool isLegacy(enum formatType fmt)
|
inline bool isLegacy(enum formatType fmt) noexcept
|
||||||
{
|
{
|
||||||
return (uint8_t(fmt) & 0x20);
|
return (uint8_t(fmt) & 0x20);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//- Equivalent to enumeration in "vtkCellType.h"
|
//- Equivalent to enumeration in "vtkCellType.h" (should be uint8_t)
|
||||||
enum cellType
|
enum cellType : uint8_t
|
||||||
{
|
{
|
||||||
VTK_EMPTY_CELL = 0,
|
VTK_EMPTY_CELL = 0,
|
||||||
VTK_VERTEX = 1,
|
VTK_VERTEX = 1,
|
||||||
@ -110,7 +110,7 @@ namespace vtk
|
|||||||
|
|
||||||
|
|
||||||
//- Some common XML tags for vtk files
|
//- Some common XML tags for vtk files
|
||||||
enum class fileTag
|
enum class fileTag : uint8_t
|
||||||
{
|
{
|
||||||
VTK_FILE, //!< "VTKFile"
|
VTK_FILE, //!< "VTKFile"
|
||||||
DATA_ARRAY, //!< "DataArray"
|
DATA_ARRAY, //!< "DataArray"
|
||||||
@ -140,7 +140,7 @@ namespace vtk
|
|||||||
extern const Foam::Enum<fileTag> fileTagNames;
|
extern const Foam::Enum<fileTag> fileTagNames;
|
||||||
|
|
||||||
//- Some common XML attributes for vtk files
|
//- Some common XML attributes for vtk files
|
||||||
enum class fileAttr
|
enum class fileAttr : uint8_t
|
||||||
{
|
{
|
||||||
OFFSET, //!< "offset"
|
OFFSET, //!< "offset"
|
||||||
NUMBER_OF_COMPONENTS, //!< "NumberOfComponents"
|
NUMBER_OF_COMPONENTS, //!< "NumberOfComponents"
|
||||||
@ -156,7 +156,7 @@ namespace vtk
|
|||||||
extern const Foam::Enum<fileAttr> fileAttrNames;
|
extern const Foam::Enum<fileAttr> fileAttrNames;
|
||||||
|
|
||||||
//- Some common names for XML DataArray entries
|
//- Some common names for XML DataArray entries
|
||||||
enum class dataArrayAttr
|
enum class dataArrayAttr : uint8_t
|
||||||
{
|
{
|
||||||
POINTS, //!< "Points"
|
POINTS, //!< "Points"
|
||||||
OFFSETS, //!< "offsets"
|
OFFSETS, //!< "offsets"
|
||||||
|
|||||||
@ -42,17 +42,17 @@ Description
|
|||||||
namespace Foam
|
namespace Foam
|
||||||
{
|
{
|
||||||
|
|
||||||
// Forward declarations
|
// Forward Declarations
|
||||||
class endian;
|
class endian;
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*\
|
/*---------------------------------------------------------------------------*\
|
||||||
Class vtkPTraits Declaration
|
Class vtkPTraits Declaration
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
template<class PrimitiveType>
|
template<class Type>
|
||||||
struct vtkPTraits
|
struct vtkPTraits
|
||||||
{
|
{
|
||||||
// Static data members
|
// Static Data Members
|
||||||
static const char* const typeName;
|
static const char* const typeName;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -290,10 +290,10 @@ Foam::vtk::fileWriter::fileWriter
|
|||||||
const vtk::outputOptions opts
|
const vtk::outputOptions opts
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
contentType_(contentType),
|
|
||||||
opts_(opts),
|
|
||||||
parallel_(false),
|
|
||||||
state_(outputState::CLOSED),
|
state_(outputState::CLOSED),
|
||||||
|
contentType_(contentType),
|
||||||
|
parallel_(false),
|
||||||
|
opts_(opts),
|
||||||
nCellData_(0),
|
nCellData_(0),
|
||||||
nPointData_(0),
|
nPointData_(0),
|
||||||
outputFile_(),
|
outputFile_(),
|
||||||
@ -360,7 +360,7 @@ bool Foam::vtk::fileWriter::open(const fileName& file, bool parallel)
|
|||||||
// This means we can always check if format_ is defined to know if output
|
// This means we can always check if format_ is defined to know if output
|
||||||
// is desired on any particular process.
|
// is desired on any particular process.
|
||||||
|
|
||||||
if (Pstream::master() || !parallel_)
|
if (!parallel_ || Pstream::master())
|
||||||
{
|
{
|
||||||
mkDir(outputFile_.path());
|
mkDir(outputFile_.path());
|
||||||
|
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
\\ / A nd | www.openfoam.com
|
\\ / A nd | www.openfoam.com
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2018-2021 OpenCFD Ltd.
|
Copyright (C) 2018-2022 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -42,6 +42,8 @@ Description
|
|||||||
|
|
||||||
SourceFiles
|
SourceFiles
|
||||||
foamVtkFileWriter.C
|
foamVtkFileWriter.C
|
||||||
|
foamVtkFileWriterI.H
|
||||||
|
foamVtkFileWriterTemplates.C
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
@ -71,7 +73,7 @@ protected:
|
|||||||
// Protected Member Data
|
// Protected Member Data
|
||||||
|
|
||||||
//- Internal tracking of the output state.
|
//- Internal tracking of the output state.
|
||||||
enum outputState
|
enum outputState : uint8_t
|
||||||
{
|
{
|
||||||
CLOSED = 0, //!< File is closed
|
CLOSED = 0, //!< File is closed
|
||||||
OPENED, //!< File is opened
|
OPENED, //!< File is opened
|
||||||
@ -86,18 +88,18 @@ protected:
|
|||||||
static const Enum<outputState> stateNames;
|
static const Enum<outputState> stateNames;
|
||||||
|
|
||||||
|
|
||||||
//- The content type
|
|
||||||
vtk::fileTag contentType_;
|
|
||||||
|
|
||||||
//- The requested output options
|
|
||||||
outputOptions opts_;
|
|
||||||
|
|
||||||
//- Writing in parallel (via master)
|
|
||||||
bool parallel_;
|
|
||||||
|
|
||||||
//- The output state
|
//- The output state
|
||||||
outputState state_;
|
outputState state_;
|
||||||
|
|
||||||
|
//- The content type (PolyData, UnstructuredGrid ...)
|
||||||
|
vtk::fileTag contentType_;
|
||||||
|
|
||||||
|
//- Parallel writing (via master)
|
||||||
|
bool parallel_;
|
||||||
|
|
||||||
|
//- Requested output options
|
||||||
|
vtk::outputOptions opts_;
|
||||||
|
|
||||||
//- The number of CellData written for the Piece thus far.
|
//- The number of CellData written for the Piece thus far.
|
||||||
label nCellData_;
|
label nCellData_;
|
||||||
|
|
||||||
@ -128,7 +130,7 @@ protected:
|
|||||||
//- The backend ostream in use
|
//- The backend ostream in use
|
||||||
inline std::ofstream& os() noexcept;
|
inline std::ofstream& os() noexcept;
|
||||||
|
|
||||||
//- The VTK formatter in use
|
//- The VTK formatter in use. FatalError for off-processor.
|
||||||
inline vtk::formatter& format();
|
inline vtk::formatter& format();
|
||||||
|
|
||||||
//- True if output state corresponds to the test state.
|
//- True if output state corresponds to the test state.
|
||||||
@ -231,16 +233,16 @@ public:
|
|||||||
// Member Functions
|
// Member Functions
|
||||||
|
|
||||||
//- The content type
|
//- The content type
|
||||||
inline vtk::fileTag contentType() const;
|
inline vtk::fileTag contentType() const noexcept;
|
||||||
|
|
||||||
//- The output options in use
|
//- The output options in use
|
||||||
inline vtk::outputOptions opts() const;
|
inline vtk::outputOptions opts() const noexcept;
|
||||||
|
|
||||||
//- File extension for current format type.
|
//- File extension for current format type.
|
||||||
inline word ext() const;
|
inline word ext() const;
|
||||||
|
|
||||||
//- Commonly used query
|
//- Commonly used query
|
||||||
inline bool legacy() const;
|
inline bool legacy() const noexcept;
|
||||||
|
|
||||||
//- Parallel output requested?
|
//- Parallel output requested?
|
||||||
inline bool parallel() const noexcept;
|
inline bool parallel() const noexcept;
|
||||||
@ -258,7 +260,11 @@ public:
|
|||||||
// If the file name has an extension, it will be used where if
|
// If the file name has an extension, it will be used where if
|
||||||
// appropriate or changed to suit the format (legacy/xml) type.
|
// appropriate or changed to suit the format (legacy/xml) type.
|
||||||
// \note Expected calling states: (CLOSED).
|
// \note Expected calling states: (CLOSED).
|
||||||
bool open(const fileName& file, bool parallel=Pstream::parRun());
|
virtual bool open
|
||||||
|
(
|
||||||
|
const fileName& file,
|
||||||
|
bool parallel = Pstream::parRun()
|
||||||
|
);
|
||||||
|
|
||||||
//- End the file contents and close the file after writing.
|
//- End the file contents and close the file after writing.
|
||||||
// \note Expected calling states: (PIECE | CELL_DATA | POINT_DATA).
|
// \note Expected calling states: (PIECE | CELL_DATA | POINT_DATA).
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
\\ / A nd | www.openfoam.com
|
\\ / A nd | www.openfoam.com
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2018 OpenCFD Ltd.
|
Copyright (C) 2018-2022 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -53,13 +53,13 @@ inline bool Foam::vtk::fileWriter::notState(outputState test) const noexcept
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
inline Foam::vtk::fileTag Foam::vtk::fileWriter::contentType() const
|
inline Foam::vtk::fileTag Foam::vtk::fileWriter::contentType() const noexcept
|
||||||
{
|
{
|
||||||
return contentType_;
|
return contentType_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline Foam::vtk::outputOptions Foam::vtk::fileWriter::opts() const
|
inline Foam::vtk::outputOptions Foam::vtk::fileWriter::opts() const noexcept
|
||||||
{
|
{
|
||||||
return opts_;
|
return opts_;
|
||||||
}
|
}
|
||||||
@ -71,7 +71,7 @@ inline Foam::word Foam::vtk::fileWriter::ext() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline bool Foam::vtk::fileWriter::legacy() const
|
inline bool Foam::vtk::fileWriter::legacy() const noexcept
|
||||||
{
|
{
|
||||||
return opts_.legacy();
|
return opts_.legacy();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -40,7 +40,7 @@ void Foam::vtk::vtmWriter::vtmEntry::clear()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Foam::vtk::vtmWriter::vtmEntry::good() const
|
bool Foam::vtk::vtmWriter::vtmEntry::good() const noexcept
|
||||||
{
|
{
|
||||||
return
|
return
|
||||||
(
|
(
|
||||||
@ -397,9 +397,7 @@ Foam::label Foam::vtk::vtmWriter::beginBlock(const word& blockName)
|
|||||||
|
|
||||||
Foam::label Foam::vtk::vtmWriter::endBlock(const word& blockName)
|
Foam::label Foam::vtk::vtmWriter::endBlock(const word& blockName)
|
||||||
{
|
{
|
||||||
label nblock = blocks_.size();
|
if (!blocks_.empty())
|
||||||
|
|
||||||
if (nblock)
|
|
||||||
{
|
{
|
||||||
const word curr(blocks_.remove());
|
const word curr(blocks_.remove());
|
||||||
|
|
||||||
|
|||||||
@ -118,7 +118,7 @@ class vtmWriter
|
|||||||
vtmEntry& operator=(const vtmEntry&) = default;
|
vtmEntry& operator=(const vtmEntry&) = default;
|
||||||
vtmEntry& operator=(vtmEntry&&) = default;
|
vtmEntry& operator=(vtmEntry&&) = default;
|
||||||
|
|
||||||
//- Construct null
|
//- Default construct
|
||||||
vtmEntry()
|
vtmEntry()
|
||||||
:
|
:
|
||||||
type_(NONE)
|
type_(NONE)
|
||||||
@ -157,7 +157,7 @@ class vtmWriter
|
|||||||
// Member Functions
|
// Member Functions
|
||||||
|
|
||||||
//- Test the type
|
//- Test the type
|
||||||
bool isType(Type what) const
|
bool isType(Type what) const noexcept
|
||||||
{
|
{
|
||||||
return type_ == what;
|
return type_ == what;
|
||||||
}
|
}
|
||||||
@ -166,7 +166,7 @@ class vtmWriter
|
|||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
//- True if the entry is good.
|
//- True if the entry is good.
|
||||||
bool good() const;
|
bool good() const noexcept;
|
||||||
|
|
||||||
//- Output valid entry as XML
|
//- Output valid entry as XML
|
||||||
bool write(vtk::formatter& format) const;
|
bool write(vtk::formatter& format) const;
|
||||||
@ -207,7 +207,7 @@ public:
|
|||||||
|
|
||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
//- Construct null, with autoName on
|
//- Default construct, with autoName on
|
||||||
vtmWriter();
|
vtmWriter();
|
||||||
|
|
||||||
//- Construct with specified behaviour for autoName
|
//- Construct with specified behaviour for autoName
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
\\ / A nd | www.openfoam.com
|
\\ / A nd | www.openfoam.com
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2016-2018 OpenCFD Ltd.
|
Copyright (C) 2016-2022 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -53,7 +53,7 @@ namespace vtk
|
|||||||
|
|
||||||
class appendBase64Formatter
|
class appendBase64Formatter
|
||||||
:
|
:
|
||||||
public foamVtkBase64Layer
|
public vtk::foamVtkBase64Layer
|
||||||
{
|
{
|
||||||
// Private Data Members
|
// Private Data Members
|
||||||
|
|
||||||
@ -78,7 +78,7 @@ public:
|
|||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
//- Construct and attach to an output stream
|
//- Construct and attach to an output stream
|
||||||
appendBase64Formatter(std::ostream& os);
|
explicit appendBase64Formatter(std::ostream& os);
|
||||||
|
|
||||||
|
|
||||||
//- Destructor. Closes/flushes the underlying layer.
|
//- Destructor. Closes/flushes the underlying layer.
|
||||||
@ -88,7 +88,7 @@ public:
|
|||||||
// Member Functions
|
// Member Functions
|
||||||
|
|
||||||
//- The output is APPEND_BASE64.
|
//- The output is APPEND_BASE64.
|
||||||
virtual const outputOptions& opts() const;
|
virtual const vtk::outputOptions& opts() const;
|
||||||
|
|
||||||
//- Output name for XML type ("append")
|
//- Output name for XML type ("append")
|
||||||
virtual const char* name() const;
|
virtual const char* name() const;
|
||||||
@ -101,6 +101,7 @@ public:
|
|||||||
virtual uint64_t offset(const uint64_t numbytes);
|
virtual uint64_t offset(const uint64_t numbytes);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
} // End namespace vtk
|
} // End namespace vtk
|
||||||
|
|||||||
@ -54,7 +54,7 @@ void Foam::vtk::appendRawFormatter::write
|
|||||||
|
|
||||||
Foam::vtk::appendRawFormatter::appendRawFormatter(std::ostream& os)
|
Foam::vtk::appendRawFormatter::appendRawFormatter(std::ostream& os)
|
||||||
:
|
:
|
||||||
formatter(os),
|
vtk::formatter(os),
|
||||||
offset_(0)
|
offset_(0)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
\\ / A nd | www.openfoam.com
|
\\ / A nd | www.openfoam.com
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2016-2018 OpenCFD Ltd.
|
Copyright (C) 2016-2022 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -52,7 +52,7 @@ namespace vtk
|
|||||||
|
|
||||||
class appendRawFormatter
|
class appendRawFormatter
|
||||||
:
|
:
|
||||||
public formatter
|
public vtk::formatter
|
||||||
{
|
{
|
||||||
// Private Data Members
|
// Private Data Members
|
||||||
|
|
||||||
@ -64,7 +64,12 @@ class appendRawFormatter
|
|||||||
uint64_t offset_;
|
uint64_t offset_;
|
||||||
|
|
||||||
|
|
||||||
// Private Member Functions
|
protected:
|
||||||
|
|
||||||
|
// Protected Member Functions
|
||||||
|
|
||||||
|
//- Write
|
||||||
|
void write(const char* s, std::streamsize n);
|
||||||
|
|
||||||
//- No copy construct
|
//- No copy construct
|
||||||
appendRawFormatter(const appendRawFormatter&) = delete;
|
appendRawFormatter(const appendRawFormatter&) = delete;
|
||||||
@ -73,20 +78,12 @@ class appendRawFormatter
|
|||||||
void operator=(const appendRawFormatter&) = delete;
|
void operator=(const appendRawFormatter&) = delete;
|
||||||
|
|
||||||
|
|
||||||
protected:
|
|
||||||
|
|
||||||
// Protected Member Functions
|
|
||||||
|
|
||||||
//- Write
|
|
||||||
void write(const char* s, std::streamsize n);
|
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
//- Construct and attach to an output stream
|
//- Construct and attach to an output stream
|
||||||
appendRawFormatter(std::ostream& os);
|
explicit appendRawFormatter(std::ostream& os);
|
||||||
|
|
||||||
|
|
||||||
//- Destructor
|
//- Destructor
|
||||||
@ -96,7 +93,7 @@ public:
|
|||||||
// Member Functions
|
// Member Functions
|
||||||
|
|
||||||
//- The output is APPEND_BINARY.
|
//- The output is APPEND_BINARY.
|
||||||
virtual const outputOptions& opts() const;
|
virtual const vtk::outputOptions& opts() const;
|
||||||
|
|
||||||
//- Output name for XML type ("append")
|
//- Output name for XML type ("append")
|
||||||
virtual const char* name() const;
|
virtual const char* name() const;
|
||||||
@ -122,9 +119,9 @@ public:
|
|||||||
|
|
||||||
//- A no-op for this format
|
//- A no-op for this format
|
||||||
virtual void flush();
|
virtual void flush();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
} // End namespace vtk
|
} // End namespace vtk
|
||||||
|
|||||||
@ -68,7 +68,7 @@ inline void Foam::vtk::asciiFormatter::done()
|
|||||||
|
|
||||||
Foam::vtk::asciiFormatter::asciiFormatter(std::ostream& os)
|
Foam::vtk::asciiFormatter::asciiFormatter(std::ostream& os)
|
||||||
:
|
:
|
||||||
formatter(os),
|
vtk::formatter(os),
|
||||||
pos_(0)
|
pos_(0)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
@ -76,13 +76,13 @@ Foam::vtk::asciiFormatter::asciiFormatter(std::ostream& os)
|
|||||||
Foam::vtk::asciiFormatter::asciiFormatter
|
Foam::vtk::asciiFormatter::asciiFormatter
|
||||||
(
|
(
|
||||||
std::ostream& os,
|
std::ostream& os,
|
||||||
unsigned precision
|
unsigned prec
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
formatter(os),
|
vtk::formatter(os),
|
||||||
pos_(0)
|
pos_(0)
|
||||||
{
|
{
|
||||||
os.precision(precision);
|
os.precision(prec);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
\\ / A nd | www.openfoam.com
|
\\ / A nd | www.openfoam.com
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2016-2021 OpenCFD Ltd.
|
Copyright (C) 2016-2022 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -54,7 +54,7 @@ namespace vtk
|
|||||||
|
|
||||||
class asciiFormatter
|
class asciiFormatter
|
||||||
:
|
:
|
||||||
public formatter
|
public vtk::formatter
|
||||||
{
|
{
|
||||||
// Private Data Members
|
// Private Data Members
|
||||||
|
|
||||||
@ -89,10 +89,10 @@ public:
|
|||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
//- Construct and attach to an output stream, use default precision
|
//- Construct and attach to an output stream, use default precision
|
||||||
asciiFormatter(std::ostream& os);
|
explicit asciiFormatter(std::ostream& os);
|
||||||
|
|
||||||
//- Construct and attach to an output stream, use specified precision
|
//- Construct and attach to an output stream, use specified precision
|
||||||
asciiFormatter(std::ostream& os, unsigned precision);
|
asciiFormatter(std::ostream& os, unsigned prec);
|
||||||
|
|
||||||
|
|
||||||
//- Destructor. Finishes the output line as required.
|
//- Destructor. Finishes the output line as required.
|
||||||
@ -102,7 +102,7 @@ public:
|
|||||||
// Member Functions
|
// Member Functions
|
||||||
|
|
||||||
//- The output is INLINE_ASCII.
|
//- The output is INLINE_ASCII.
|
||||||
virtual const outputOptions& opts() const;
|
virtual const vtk::outputOptions& opts() const;
|
||||||
|
|
||||||
//- Name for the XML output type ("ascii")
|
//- Name for the XML output type ("ascii")
|
||||||
virtual const char* name() const;
|
virtual const char* name() const;
|
||||||
@ -127,9 +127,9 @@ public:
|
|||||||
//- The encoded length for ascii output is not applicable.
|
//- The encoded length for ascii output is not applicable.
|
||||||
// \return 0
|
// \return 0
|
||||||
virtual std::size_t encodedLength(std::size_t ignored) const;
|
virtual std::size_t encodedLength(std::size_t ignored) const;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
} // End namespace vtk
|
} // End namespace vtk
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
\\ / A nd | www.openfoam.com
|
\\ / A nd | www.openfoam.com
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2016-2017 OpenCFD Ltd.
|
Copyright (C) 2016-2022 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -51,7 +51,7 @@ namespace vtk
|
|||||||
|
|
||||||
class base64Formatter
|
class base64Formatter
|
||||||
:
|
:
|
||||||
public foamVtkBase64Layer
|
public vtk::foamVtkBase64Layer
|
||||||
{
|
{
|
||||||
// Private Data Members
|
// Private Data Members
|
||||||
|
|
||||||
@ -73,7 +73,7 @@ public:
|
|||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
//- Construct and attach to an output stream
|
//- Construct and attach to an output stream
|
||||||
base64Formatter(std::ostream& os);
|
explicit base64Formatter(std::ostream& os);
|
||||||
|
|
||||||
|
|
||||||
//- Destructor. Closes/flushes the underlying layer.
|
//- Destructor. Closes/flushes the underlying layer.
|
||||||
@ -83,7 +83,7 @@ public:
|
|||||||
// Member Functions
|
// Member Functions
|
||||||
|
|
||||||
//- The output is INLINE_BASE64.
|
//- The output is INLINE_BASE64.
|
||||||
virtual const outputOptions& opts() const;
|
virtual const vtk::outputOptions& opts() const;
|
||||||
|
|
||||||
//- Name for the XML output type ("binary")
|
//- Name for the XML output type ("binary")
|
||||||
virtual const char* name() const;
|
virtual const char* name() const;
|
||||||
@ -92,9 +92,9 @@ public:
|
|||||||
//- End the encoding sequence (padding the final characters with '=')
|
//- End the encoding sequence (padding the final characters with '=')
|
||||||
// and write a newline to the output if any encoding was done.
|
// and write a newline to the output if any encoding was done.
|
||||||
virtual void flush();
|
virtual void flush();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
} // End namespace vtk
|
} // End namespace vtk
|
||||||
|
|||||||
@ -41,7 +41,7 @@ void Foam::vtk::foamVtkBase64Layer::write
|
|||||||
std::streamsize n
|
std::streamsize n
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
base64Layer::write(s, n);
|
Foam::base64Layer::write(s, n);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -49,8 +49,8 @@ void Foam::vtk::foamVtkBase64Layer::write
|
|||||||
|
|
||||||
Foam::vtk::foamVtkBase64Layer::foamVtkBase64Layer(std::ostream& os)
|
Foam::vtk::foamVtkBase64Layer::foamVtkBase64Layer(std::ostream& os)
|
||||||
:
|
:
|
||||||
formatter(os),
|
vtk::formatter(os),
|
||||||
base64Layer(os)
|
Foam::base64Layer(os)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
@ -58,7 +58,7 @@ Foam::vtk::foamVtkBase64Layer::foamVtkBase64Layer(std::ostream& os)
|
|||||||
|
|
||||||
Foam::vtk::foamVtkBase64Layer::~foamVtkBase64Layer()
|
Foam::vtk::foamVtkBase64Layer::~foamVtkBase64Layer()
|
||||||
{
|
{
|
||||||
base64Layer::close();
|
Foam::base64Layer::close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -79,7 +79,7 @@ bool Foam::vtk::foamVtkBase64Layer::writeSize(const uint64_t numbytes)
|
|||||||
|
|
||||||
void Foam::vtk::foamVtkBase64Layer::write(const uint8_t val)
|
void Foam::vtk::foamVtkBase64Layer::write(const uint8_t val)
|
||||||
{
|
{
|
||||||
base64Layer::add(val);
|
Foam::base64Layer::add(val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -120,13 +120,13 @@ void Foam::vtk::foamVtkBase64Layer::write(const double val)
|
|||||||
|
|
||||||
void Foam::vtk::foamVtkBase64Layer::flush()
|
void Foam::vtk::foamVtkBase64Layer::flush()
|
||||||
{
|
{
|
||||||
base64Layer::close();
|
Foam::base64Layer::close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::size_t Foam::vtk::foamVtkBase64Layer::encodedLength(std::size_t n) const
|
std::size_t Foam::vtk::foamVtkBase64Layer::encodedLength(std::size_t n) const
|
||||||
{
|
{
|
||||||
return base64Layer::encodedLength(n);
|
return Foam::base64Layer::encodedLength(n);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -50,23 +50,14 @@ namespace vtk
|
|||||||
|
|
||||||
class foamVtkBase64Layer
|
class foamVtkBase64Layer
|
||||||
:
|
:
|
||||||
public formatter,
|
public vtk::formatter,
|
||||||
protected base64Layer
|
protected Foam::base64Layer
|
||||||
{
|
{
|
||||||
// Private Data Members
|
// Private Data Members
|
||||||
|
|
||||||
static const char* encoding_;
|
static const char* encoding_;
|
||||||
|
|
||||||
|
|
||||||
// Private Member Functions
|
|
||||||
|
|
||||||
//- No copy construct
|
|
||||||
foamVtkBase64Layer(const foamVtkBase64Layer&) = delete;
|
|
||||||
|
|
||||||
//- No copy assignment
|
|
||||||
void operator=(const foamVtkBase64Layer&) = delete;
|
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
// Protected Member Functions
|
// Protected Member Functions
|
||||||
@ -74,11 +65,17 @@ protected:
|
|||||||
//- Write
|
//- Write
|
||||||
void write(const char* s, std::streamsize n);
|
void write(const char* s, std::streamsize n);
|
||||||
|
|
||||||
|
//- No copy construct
|
||||||
|
foamVtkBase64Layer(const foamVtkBase64Layer&) = delete;
|
||||||
|
|
||||||
|
//- No copy assignment
|
||||||
|
void operator=(const foamVtkBase64Layer&) = delete;
|
||||||
|
|
||||||
|
|
||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
//- Construct and attach to an output stream
|
//- Construct and attach to an output stream
|
||||||
foamVtkBase64Layer(std::ostream& os);
|
explicit foamVtkBase64Layer(std::ostream& os);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@ -105,9 +102,9 @@ public:
|
|||||||
|
|
||||||
//- The encoded length for base64 encoded output.
|
//- The encoded length for base64 encoded output.
|
||||||
virtual std::size_t encodedLength(std::size_t n) const;
|
virtual std::size_t encodedLength(std::size_t n) const;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
} // End namespace vtk
|
} // End namespace vtk
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
\\ / A nd | www.openfoam.com
|
\\ / A nd | www.openfoam.com
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2016-2018 OpenCFD Ltd.
|
Copyright (C) 2016-2022 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -132,7 +132,7 @@ protected:
|
|||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
//- Construct and attach to an output stream
|
//- Construct and attach to an output stream
|
||||||
inline formatter(std::ostream& os);
|
inline explicit formatter(std::ostream& os);
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -155,10 +155,10 @@ public:
|
|||||||
// Access
|
// Access
|
||||||
|
|
||||||
//- Access to the underlying output stream
|
//- Access to the underlying output stream
|
||||||
inline std::ostream& os();
|
inline std::ostream& os() noexcept;
|
||||||
|
|
||||||
//- The format-type / output options.
|
//- The format-type / output options.
|
||||||
virtual const outputOptions& opts() const = 0;
|
virtual const vtk::outputOptions& opts() const = 0;
|
||||||
|
|
||||||
//- Name for the XML output type or the legacy output type.
|
//- Name for the XML output type or the legacy output type.
|
||||||
virtual const char* name() const = 0;
|
virtual const char* name() const = 0;
|
||||||
@ -540,7 +540,6 @@ public:
|
|||||||
dataName, formatter::npos, true
|
dataName, formatter::npos, true
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -67,7 +67,7 @@ inline Foam::vtk::formatter::formatter(std::ostream& os)
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
inline std::ostream& Foam::vtk::formatter::os()
|
inline std::ostream& Foam::vtk::formatter::os() noexcept
|
||||||
{
|
{
|
||||||
return os_;
|
return os_;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -50,10 +50,10 @@ Foam::vtk::legacyAsciiFormatter::legacyAsciiFormatter
|
|||||||
Foam::vtk::legacyAsciiFormatter::legacyAsciiFormatter
|
Foam::vtk::legacyAsciiFormatter::legacyAsciiFormatter
|
||||||
(
|
(
|
||||||
std::ostream& os,
|
std::ostream& os,
|
||||||
unsigned precision
|
unsigned prec
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
asciiFormatter(os, precision)
|
asciiFormatter(os, prec)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
\\ / A nd | www.openfoam.com
|
\\ / A nd | www.openfoam.com
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2017-2018 OpenCFD Ltd.
|
Copyright (C) 2017-2022 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -53,7 +53,7 @@ namespace vtk
|
|||||||
|
|
||||||
class legacyAsciiFormatter
|
class legacyAsciiFormatter
|
||||||
:
|
:
|
||||||
public asciiFormatter
|
public vtk::asciiFormatter
|
||||||
{
|
{
|
||||||
// Private Data Members
|
// Private Data Members
|
||||||
|
|
||||||
@ -75,10 +75,10 @@ public:
|
|||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
//- Construct and attach to an output stream, use default precision
|
//- Construct and attach to an output stream, use default precision
|
||||||
legacyAsciiFormatter(std::ostream& os);
|
explicit legacyAsciiFormatter(std::ostream& os);
|
||||||
|
|
||||||
//- Construct and attach to an output stream, use specified precision
|
//- Construct and attach to an output stream, use specified precision
|
||||||
legacyAsciiFormatter(std::ostream& os, unsigned precision);
|
legacyAsciiFormatter(std::ostream& os, unsigned prec);
|
||||||
|
|
||||||
|
|
||||||
//- Destructor
|
//- Destructor
|
||||||
@ -88,7 +88,7 @@ public:
|
|||||||
// Member Functions
|
// Member Functions
|
||||||
|
|
||||||
//- The output is LEGACY_ASCII.
|
//- The output is LEGACY_ASCII.
|
||||||
virtual const outputOptions& opts() const;
|
virtual const vtk::outputOptions& opts() const;
|
||||||
|
|
||||||
//- Name for the legacy ascii output type ("ASCII")
|
//- Name for the legacy ascii output type ("ASCII")
|
||||||
virtual const char* name() const;
|
virtual const char* name() const;
|
||||||
@ -107,9 +107,9 @@ public:
|
|||||||
inline virtual formatter& endPointData() { return *this; }
|
inline virtual formatter& endPointData() { return *this; }
|
||||||
inline virtual formatter& endPiece() { return *this; }
|
inline virtual formatter& endPiece() { return *this; }
|
||||||
inline virtual formatter& endVTKFile() { return *this; }
|
inline virtual formatter& endVTKFile() { return *this; }
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
} // End namespace vtk
|
} // End namespace vtk
|
||||||
|
|||||||
@ -57,7 +57,7 @@ Foam::vtk::legacyRawFormatter::legacyRawFormatter
|
|||||||
std::ostream& os
|
std::ostream& os
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
formatter(os)
|
vtk::formatter(os)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
\\ / A nd | www.openfoam.com
|
\\ / A nd | www.openfoam.com
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2017-2018 OpenCFD Ltd.
|
Copyright (C) 2017-2022 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -55,21 +55,12 @@ namespace vtk
|
|||||||
|
|
||||||
class legacyRawFormatter
|
class legacyRawFormatter
|
||||||
:
|
:
|
||||||
public formatter
|
public vtk::formatter
|
||||||
{
|
{
|
||||||
// Private Data Members
|
// Private Data Members
|
||||||
|
|
||||||
static const char* legacyName_;
|
static const char* legacyName_;
|
||||||
static const outputOptions opts_;
|
static const vtk::outputOptions opts_;
|
||||||
|
|
||||||
|
|
||||||
// Private Member Functions
|
|
||||||
|
|
||||||
//- No copy construct
|
|
||||||
legacyRawFormatter(const legacyRawFormatter&) = delete;
|
|
||||||
|
|
||||||
//- No copy assignment
|
|
||||||
void operator=(const legacyRawFormatter&) = delete;
|
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@ -79,13 +70,19 @@ protected:
|
|||||||
//- Write
|
//- Write
|
||||||
void write(const char* s, std::streamsize n);
|
void write(const char* s, std::streamsize n);
|
||||||
|
|
||||||
|
//- No copy construct
|
||||||
|
legacyRawFormatter(const legacyRawFormatter&) = delete;
|
||||||
|
|
||||||
|
//- No copy assignment
|
||||||
|
void operator=(const legacyRawFormatter&) = delete;
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
//- Construct and attach to an output stream
|
//- Construct and attach to an output stream
|
||||||
legacyRawFormatter(std::ostream& os);
|
explicit legacyRawFormatter(std::ostream& os);
|
||||||
|
|
||||||
|
|
||||||
//- Destructor
|
//- Destructor
|
||||||
@ -95,7 +92,7 @@ public:
|
|||||||
// Member Functions
|
// Member Functions
|
||||||
|
|
||||||
//- The output is LEGACY_BINARY.
|
//- The output is LEGACY_BINARY.
|
||||||
virtual const outputOptions& opts() const;
|
virtual const vtk::outputOptions& opts() const;
|
||||||
|
|
||||||
//- 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;
|
||||||
@ -127,9 +124,9 @@ public:
|
|||||||
inline virtual formatter& endPointData() { return *this; }
|
inline virtual formatter& endPointData() { return *this; }
|
||||||
inline virtual formatter& endPiece() { return *this; }
|
inline virtual formatter& endPiece() { return *this; }
|
||||||
inline virtual formatter& endVTKFile() { return *this; }
|
inline virtual formatter& endVTKFile() { return *this; }
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
} // End namespace vtk
|
} // End namespace vtk
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
\\ / A nd | www.openfoam.com
|
\\ / A nd | www.openfoam.com
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2016-2021 OpenCFD Ltd.
|
Copyright (C) 2016-2022 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -254,11 +254,29 @@ namespace legacy
|
|||||||
//- Emit header for POINTS (with trailing newline).
|
//- Emit header for POINTS (with trailing newline).
|
||||||
inline void beginPoints(std::ostream& os, label nPoints);
|
inline void beginPoints(std::ostream& os, label nPoints);
|
||||||
|
|
||||||
|
//- Emit header for VERTICES (with trailing newline).
|
||||||
|
// The nConnectivity is the sum of all connectivity points used,
|
||||||
|
// but \b without additional space for the size prefixes.
|
||||||
|
// The additional prefix sizes are added internally.
|
||||||
|
// \note With nConnectivity == 0, assume one point per element
|
||||||
|
inline void beginVerts
|
||||||
|
(
|
||||||
|
std::ostream& os,
|
||||||
|
label nVerts,
|
||||||
|
label nConnectivity = 0
|
||||||
|
);
|
||||||
|
|
||||||
//- Emit header for LINES (with trailing newline).
|
//- Emit header for LINES (with trailing newline).
|
||||||
// The nConnectivity is the sum of all connectivity points used,
|
// The nConnectivity is the sum of all connectivity points used,
|
||||||
// but \b without additional space for the size prefixes.
|
// but \b without additional space for the size prefixes.
|
||||||
// The additional prefix sizes are added internally.
|
// The additional prefix sizes are added internally.
|
||||||
inline void beginLines(std::ostream& os, label nLines, label nConnectivity);
|
// \note With nConnectivity == 0, assume two points per element
|
||||||
|
inline void beginLines
|
||||||
|
(
|
||||||
|
std::ostream& os,
|
||||||
|
label nLines,
|
||||||
|
label nConnectivity = 0
|
||||||
|
);
|
||||||
|
|
||||||
//- Emit header for POLYGONS (with trailing newline).
|
//- Emit header for POLYGONS (with trailing newline).
|
||||||
// The nConnectivity is the sum of all connectivity points used,
|
// The nConnectivity is the sum of all connectivity points used,
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
\\ / A nd | www.openfoam.com
|
\\ / A nd | www.openfoam.com
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2017-2021 OpenCFD Ltd.
|
Copyright (C) 2017-2022 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -119,6 +119,24 @@ inline void Foam::vtk::legacy::beginPoints(std::ostream& os, label nPoints)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline void Foam::vtk::legacy::beginVerts
|
||||||
|
(
|
||||||
|
std::ostream& os,
|
||||||
|
label nVerts,
|
||||||
|
label nConnectivity
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (!nConnectivity)
|
||||||
|
{
|
||||||
|
nConnectivity = nVerts;
|
||||||
|
}
|
||||||
|
os << nl
|
||||||
|
<< legacy::fileTagNames[vtk::fileTag::VERTS]
|
||||||
|
<< ' ' << nVerts
|
||||||
|
<< ' ' << (nVerts + nConnectivity) << nl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
inline void Foam::vtk::legacy::beginLines
|
inline void Foam::vtk::legacy::beginLines
|
||||||
(
|
(
|
||||||
std::ostream& os,
|
std::ostream& os,
|
||||||
@ -126,6 +144,10 @@ inline void Foam::vtk::legacy::beginLines
|
|||||||
label nConnectivity
|
label nConnectivity
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
if (!nConnectivity)
|
||||||
|
{
|
||||||
|
nConnectivity = 2*nLines;
|
||||||
|
}
|
||||||
os << nl
|
os << nl
|
||||||
<< legacy::fileTagNames[vtk::fileTag::LINES]
|
<< legacy::fileTagNames[vtk::fileTag::LINES]
|
||||||
<< ' ' << nLines
|
<< ' ' << nLines
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
\\ / A nd | www.openfoam.com
|
\\ / A nd | www.openfoam.com
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2016-2019 OpenCFD Ltd.
|
Copyright (C) 2016-2022 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -61,15 +61,15 @@ class outputOptions
|
|||||||
{
|
{
|
||||||
// Private Member Data
|
// Private Member Data
|
||||||
|
|
||||||
//- The output style tuning
|
/// //- The output style tuning
|
||||||
enum styleType
|
/// enum styleType
|
||||||
{
|
/// {
|
||||||
NONE = 0x00, //!< Normal
|
/// NONE = 0x00, //!< Normal
|
||||||
HEADER = 0x01 //!< Emit xml header
|
/// HEADER = 0x01 //!< Emit xml header
|
||||||
};
|
/// };
|
||||||
|
|
||||||
//- The output format type
|
//- The output format type
|
||||||
formatType fmtType_;
|
vtk::formatType fmtType_;
|
||||||
|
|
||||||
//- ASCII write precision
|
//- ASCII write precision
|
||||||
mutable unsigned precision_;
|
mutable unsigned precision_;
|
||||||
@ -79,15 +79,16 @@ public:
|
|||||||
|
|
||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
//- Construct null - XML insitu ASCII format with default precision
|
//- Default construct - XML insitu ASCII format with default precision
|
||||||
inline outputOptions();
|
inline outputOptions();
|
||||||
|
|
||||||
//- Construct with specified format and default (ASCII) precision
|
//- Construct with specified format and default (ASCII) precision
|
||||||
|
//
|
||||||
// \note This constructor should remain non-explicit.
|
// \note This constructor should remain non-explicit.
|
||||||
inline outputOptions(enum formatType fmtType);
|
inline outputOptions(enum vtk::formatType fmtType);
|
||||||
|
|
||||||
//- Construct with specified format and (ASCII) write precision
|
//- Construct with specified format and (ASCII) write precision
|
||||||
inline outputOptions(enum formatType fmtType, unsigned prec);
|
inline outputOptions(enum vtk::formatType fmtType, unsigned prec);
|
||||||
|
|
||||||
|
|
||||||
// Selectors
|
// Selectors
|
||||||
@ -101,28 +102,28 @@ public:
|
|||||||
// Access
|
// Access
|
||||||
|
|
||||||
//- The output format type
|
//- The output format type
|
||||||
inline formatType fmt() const;
|
inline vtk::formatType fmt() const noexcept;
|
||||||
|
|
||||||
//- The file extension (legacy or xml) for the given content-type
|
//- The file extension (legacy or xml) for the given content-type
|
||||||
inline word ext(vtk::fileTag contentType) const;
|
inline word ext(vtk::fileTag contentType) const;
|
||||||
|
|
||||||
//- True if writer uses legacy file format
|
//- True if writer uses legacy file format
|
||||||
inline bool legacy() const;
|
inline bool legacy() const noexcept;
|
||||||
|
|
||||||
//- True if writer uses XML file format (non-legacy)
|
//- True if writer uses XML file format (non-legacy)
|
||||||
inline bool xml() const;
|
inline bool xml() const noexcept;
|
||||||
|
|
||||||
//- True if output format uses an append mode
|
//- True if output format uses an append mode
|
||||||
inline bool append() const;
|
inline bool append() const noexcept;
|
||||||
|
|
||||||
//- True if output format does not use an append mode
|
//- True if output format does not use an append mode
|
||||||
inline bool insitu() const;
|
inline bool insitu() const noexcept;
|
||||||
|
|
||||||
//- True if output format is ASCII
|
//- True if output format is ASCII
|
||||||
inline bool ascii() const;
|
inline bool ascii() const noexcept;
|
||||||
|
|
||||||
//- Return the ASCII write precision
|
//- Return the ASCII write precision
|
||||||
inline unsigned precision() const;
|
inline unsigned precision() const noexcept;
|
||||||
|
|
||||||
|
|
||||||
// Edit
|
// Edit
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
\\ / A nd | www.openfoam.com
|
\\ / A nd | www.openfoam.com
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2016-2019 OpenCFD Ltd.
|
Copyright (C) 2016-2022 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -25,8 +25,6 @@ License
|
|||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include "foamVtkOutput.H"
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
inline Foam::vtk::outputOptions::outputOptions()
|
inline Foam::vtk::outputOptions::outputOptions()
|
||||||
@ -38,7 +36,7 @@ inline Foam::vtk::outputOptions::outputOptions()
|
|||||||
|
|
||||||
inline Foam::vtk::outputOptions::outputOptions
|
inline Foam::vtk::outputOptions::outputOptions
|
||||||
(
|
(
|
||||||
enum formatType fmtType
|
enum vtk::formatType fmtType
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
fmtType_(fmtType),
|
fmtType_(fmtType),
|
||||||
@ -48,7 +46,7 @@ inline Foam::vtk::outputOptions::outputOptions
|
|||||||
|
|
||||||
inline Foam::vtk::outputOptions::outputOptions
|
inline Foam::vtk::outputOptions::outputOptions
|
||||||
(
|
(
|
||||||
enum formatType fmtType,
|
enum vtk::formatType fmtType,
|
||||||
unsigned prec
|
unsigned prec
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
@ -68,7 +66,7 @@ Foam::vtk::outputOptions::newFormatter(std::ostream& os) const
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
inline Foam::vtk::formatType Foam::vtk::outputOptions::fmt() const
|
inline Foam::vtk::formatType Foam::vtk::outputOptions::fmt() const noexcept
|
||||||
{
|
{
|
||||||
return fmtType_;
|
return fmtType_;
|
||||||
}
|
}
|
||||||
@ -85,7 +83,7 @@ inline Foam::word Foam::vtk::outputOptions::ext(vtk::fileTag contentType) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline bool Foam::vtk::outputOptions::legacy() const
|
inline bool Foam::vtk::outputOptions::legacy() const noexcept
|
||||||
{
|
{
|
||||||
return
|
return
|
||||||
(
|
(
|
||||||
@ -95,13 +93,13 @@ inline bool Foam::vtk::outputOptions::legacy() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline bool Foam::vtk::outputOptions::xml() const
|
inline bool Foam::vtk::outputOptions::xml() const noexcept
|
||||||
{
|
{
|
||||||
return !legacy();
|
return !legacy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline bool Foam::vtk::outputOptions::append() const
|
inline bool Foam::vtk::outputOptions::append() const noexcept
|
||||||
{
|
{
|
||||||
return
|
return
|
||||||
(
|
(
|
||||||
@ -111,19 +109,19 @@ inline bool Foam::vtk::outputOptions::append() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline bool Foam::vtk::outputOptions::insitu() const
|
inline bool Foam::vtk::outputOptions::insitu() const noexcept
|
||||||
{
|
{
|
||||||
return !append();
|
return !append();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline bool Foam::vtk::outputOptions::ascii() const
|
inline bool Foam::vtk::outputOptions::ascii() const noexcept
|
||||||
{
|
{
|
||||||
return !(unsigned(fmtType_) & 0x0F);
|
return !(unsigned(fmtType_) & 0x0F);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline unsigned Foam::vtk::outputOptions::precision() const
|
inline unsigned Foam::vtk::outputOptions::precision() const noexcept
|
||||||
{
|
{
|
||||||
return precision_;
|
return precision_;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -67,6 +67,7 @@ void Foam::vtk::polyWriter::beginPiece
|
|||||||
{
|
{
|
||||||
// Basic sizes
|
// Basic sizes
|
||||||
nLocalPoints_ = points.size();
|
nLocalPoints_ = points.size();
|
||||||
|
nLocalVerts_ = 0;
|
||||||
nLocalLines_ = edges.size();
|
nLocalLines_ = edges.size();
|
||||||
nLocalPolys_ = 0;
|
nLocalPolys_ = 0;
|
||||||
|
|
||||||
@ -104,6 +105,7 @@ void Foam::vtk::polyWriter::beginPiece
|
|||||||
{
|
{
|
||||||
// Basic sizes
|
// Basic sizes
|
||||||
nLocalPoints_ = points.size();
|
nLocalPoints_ = points.size();
|
||||||
|
nLocalVerts_ = 0;
|
||||||
nLocalLines_ = 0;
|
nLocalLines_ = 0;
|
||||||
nLocalPolys_ = faces.size();
|
nLocalPolys_ = faces.size();
|
||||||
|
|
||||||
@ -568,6 +570,7 @@ Foam::vtk::polyWriter::polyWriter
|
|||||||
numberOfPoints_(0),
|
numberOfPoints_(0),
|
||||||
numberOfCells_(0),
|
numberOfCells_(0),
|
||||||
nLocalPoints_(0),
|
nLocalPoints_(0),
|
||||||
|
nLocalVerts_(0),
|
||||||
nLocalLines_(0),
|
nLocalLines_(0),
|
||||||
nLocalPolys_(0)
|
nLocalPolys_(0)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
\\ / A nd | www.openfoam.com
|
\\ / A nd | www.openfoam.com
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2018-2021 OpenCFD Ltd.
|
Copyright (C) 2018-2022 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -82,6 +82,9 @@ protected:
|
|||||||
//- Local number of points
|
//- Local number of points
|
||||||
label nLocalPoints_;
|
label nLocalPoints_;
|
||||||
|
|
||||||
|
//- Local number of vertices (points)
|
||||||
|
label nLocalVerts_;
|
||||||
|
|
||||||
//- Local number of lines (edges)
|
//- Local number of lines (edges)
|
||||||
label nLocalLines_;
|
label nLocalLines_;
|
||||||
|
|
||||||
|
|||||||
@ -143,6 +143,7 @@ $(setWriters)/gltf/gltfSetWriterRunTime.C
|
|||||||
$(setWriters)/gnuplot/gnuplotSetWriterRunTime.C
|
$(setWriters)/gnuplot/gnuplotSetWriterRunTime.C
|
||||||
$(setWriters)/nastran/nastranSetWriterRunTime.C
|
$(setWriters)/nastran/nastranSetWriterRunTime.C
|
||||||
$(setWriters)/raw/rawSetWriterRunTime.C
|
$(setWriters)/raw/rawSetWriterRunTime.C
|
||||||
|
$(setWriters)/vtk/foamVtkCoordSetWriter.C
|
||||||
$(setWriters)/vtk/vtkSetWriterRunTime.C
|
$(setWriters)/vtk/vtkSetWriterRunTime.C
|
||||||
$(setWriters)/xmgrace/xmgraceSetWriterRunTime.C
|
$(setWriters)/xmgrace/xmgraceSetWriterRunTime.C
|
||||||
|
|
||||||
|
|||||||
574
src/meshTools/coordSet/writers/vtk/foamVtkCoordSetWriter.C
Normal file
574
src/meshTools/coordSet/writers/vtk/foamVtkCoordSetWriter.C
Normal file
@ -0,0 +1,574 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | www.openfoam.com
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
Copyright (C) 2022 OpenCFD Ltd.
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
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 "foamVtkCoordSetWriter.H"
|
||||||
|
#include "foamVtkOutput.H"
|
||||||
|
#include "globalIndex.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
|
void Foam::vtk::coordSetWriter::beginPiece()
|
||||||
|
{
|
||||||
|
// Basic sizes
|
||||||
|
nLocalPoints_ = 0;
|
||||||
|
nLocalVerts_ = 0;
|
||||||
|
nLocalLines_ = 0;
|
||||||
|
nLocalPolys_ = 0;
|
||||||
|
|
||||||
|
for (const pointField& pts : points_)
|
||||||
|
{
|
||||||
|
const label npts = pts.size();
|
||||||
|
nLocalPoints_ += npts;
|
||||||
|
|
||||||
|
if (npts)
|
||||||
|
{
|
||||||
|
++nLocalLines_;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (elemOutput_)
|
||||||
|
{
|
||||||
|
case elemOutputType::NO_ELEMENTS:
|
||||||
|
{
|
||||||
|
nLocalVerts_ = nLocalLines_ = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case elemOutputType::DEFAULT_ELEMENTS:
|
||||||
|
{
|
||||||
|
if (points_.size() < 2)
|
||||||
|
{
|
||||||
|
//OR nLocalVerts_ = nLocalPoints_;
|
||||||
|
nLocalVerts_ = 0;
|
||||||
|
nLocalLines_ = 0;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case elemOutputType::POINT_ELEMENTS:
|
||||||
|
{
|
||||||
|
nLocalVerts_ = nLocalPoints_;
|
||||||
|
nLocalLines_ = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case elemOutputType::LINE_ELEMENTS:
|
||||||
|
{
|
||||||
|
// Already determined
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Nothing else to do for legacy
|
||||||
|
if (legacy()) return;
|
||||||
|
|
||||||
|
if (format_)
|
||||||
|
{
|
||||||
|
format().openTag
|
||||||
|
(
|
||||||
|
vtk::fileTag::PIECE,
|
||||||
|
vtk::fileAttr::NUMBER_OF_POINTS, nLocalPoints_
|
||||||
|
);
|
||||||
|
if (nLocalVerts_)
|
||||||
|
{
|
||||||
|
format().xmlAttr(vtk::fileAttr::NUMBER_OF_VERTS, nLocalVerts_);
|
||||||
|
}
|
||||||
|
if (nLocalLines_)
|
||||||
|
{
|
||||||
|
format().xmlAttr(vtk::fileAttr::NUMBER_OF_LINES, nLocalLines_);
|
||||||
|
}
|
||||||
|
format().closeTag();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::vtk::coordSetWriter::writePoints()
|
||||||
|
{
|
||||||
|
this->beginPoints(nLocalPoints_);
|
||||||
|
|
||||||
|
{
|
||||||
|
for (const pointField& pts : points_)
|
||||||
|
{
|
||||||
|
vtk::writeList(format(), pts);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this->endPoints();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::vtk::coordSetWriter::writeVertsLegacy()
|
||||||
|
{
|
||||||
|
if (!nLocalVerts_)
|
||||||
|
{
|
||||||
|
return; // Nothing to do
|
||||||
|
}
|
||||||
|
|
||||||
|
// connectivity = 1 per vertex
|
||||||
|
const label nLocalConns = nLocalVerts_;
|
||||||
|
|
||||||
|
legacy::beginVerts(os_, nLocalVerts_, nLocalConns);
|
||||||
|
|
||||||
|
labelList vertLabels(nLocalVerts_ + nLocalConns);
|
||||||
|
|
||||||
|
auto iter = vertLabels.begin();
|
||||||
|
|
||||||
|
for (label pointi = 0; pointi < nLocalVerts_; ++pointi)
|
||||||
|
{
|
||||||
|
*iter++ = 1;
|
||||||
|
*iter++ = pointi;
|
||||||
|
}
|
||||||
|
|
||||||
|
vtk::writeList(format(), vertLabels);
|
||||||
|
|
||||||
|
if (format_)
|
||||||
|
{
|
||||||
|
format().flush();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::vtk::coordSetWriter::writeLinesLegacy()
|
||||||
|
{
|
||||||
|
if (!nLocalLines_)
|
||||||
|
{
|
||||||
|
return; // Nothing to do
|
||||||
|
}
|
||||||
|
|
||||||
|
// connectivity = use each point
|
||||||
|
label nLocalConns = nLocalPoints_;
|
||||||
|
|
||||||
|
legacy::beginLines(os_, nLocalLines_, nLocalConns);
|
||||||
|
|
||||||
|
labelList vertLabels(nLocalLines_ + nLocalConns);
|
||||||
|
|
||||||
|
auto iter = vertLabels.begin();
|
||||||
|
|
||||||
|
label localPointi = 0;
|
||||||
|
for (const pointField& pts : points_)
|
||||||
|
{
|
||||||
|
label npts = pts.size();
|
||||||
|
|
||||||
|
if (npts)
|
||||||
|
{
|
||||||
|
*iter++ = npts;
|
||||||
|
while (npts--)
|
||||||
|
{
|
||||||
|
*iter++ = localPointi;
|
||||||
|
++localPointi;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
vtk::writeList(format(), vertLabels);
|
||||||
|
|
||||||
|
if (format_)
|
||||||
|
{
|
||||||
|
format().flush();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::vtk::coordSetWriter::writeVerts()
|
||||||
|
{
|
||||||
|
if (!nLocalVerts_)
|
||||||
|
{
|
||||||
|
return; // Nothing to do
|
||||||
|
}
|
||||||
|
|
||||||
|
// connectivity = 1 per vertex
|
||||||
|
const label nLocalConns = nLocalVerts_;
|
||||||
|
|
||||||
|
if (format_)
|
||||||
|
{
|
||||||
|
format().tag(vtk::fileTag::VERTS);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// 'offsets' (connectivity offsets)
|
||||||
|
//
|
||||||
|
{
|
||||||
|
labelList vertOffsets(nLocalVerts_);
|
||||||
|
label nOffs = vertOffsets.size();
|
||||||
|
|
||||||
|
// if (parallel_)
|
||||||
|
// {
|
||||||
|
// reduce(nOffs, sumOp<label>());
|
||||||
|
// }
|
||||||
|
|
||||||
|
if (format_)
|
||||||
|
{
|
||||||
|
const uint64_t payLoad = vtk::sizeofData<label>(nOffs);
|
||||||
|
|
||||||
|
format().beginDataArray<label>(vtk::dataArrayAttr::OFFSETS);
|
||||||
|
format().writeSize(payLoad);
|
||||||
|
}
|
||||||
|
|
||||||
|
// processor-local connectivity offsets
|
||||||
|
|
||||||
|
label off = 0;
|
||||||
|
|
||||||
|
/// label off =
|
||||||
|
/// (
|
||||||
|
/// parallel_ ? globalIndex(nLocalConns).localStart() : 0
|
||||||
|
/// );
|
||||||
|
|
||||||
|
auto iter = vertOffsets.begin();
|
||||||
|
|
||||||
|
for (label pointi = 0; pointi < nLocalVerts_; ++pointi)
|
||||||
|
{
|
||||||
|
off += 1; // End offset
|
||||||
|
*iter = off;
|
||||||
|
++iter;
|
||||||
|
}
|
||||||
|
|
||||||
|
vtk::writeList(format_.ref(), vertOffsets);
|
||||||
|
|
||||||
|
if (format_)
|
||||||
|
{
|
||||||
|
format().flush();
|
||||||
|
format().endDataArray();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// 'connectivity'
|
||||||
|
//
|
||||||
|
{
|
||||||
|
labelList vertLabels(nLocalConns);
|
||||||
|
|
||||||
|
label nConns = nLocalConns;
|
||||||
|
|
||||||
|
// if (parallel_)
|
||||||
|
// {
|
||||||
|
// reduce(nConns, sumOp<label>());
|
||||||
|
// }
|
||||||
|
|
||||||
|
if (format_)
|
||||||
|
{
|
||||||
|
const uint64_t payLoad = vtk::sizeofData<label>(nConns);
|
||||||
|
|
||||||
|
format().beginDataArray<label>(vtk::dataArrayAttr::CONNECTIVITY);
|
||||||
|
format().writeSize(payLoad * sizeof(label));
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
// XML: connectivity only
|
||||||
|
// [id1, id2, ..., id1, id2, ...]
|
||||||
|
|
||||||
|
auto iter = vertLabels.begin();
|
||||||
|
|
||||||
|
for (label pointi = 0; pointi < nLocalVerts_; ++pointi)
|
||||||
|
{
|
||||||
|
*iter++ = pointi;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
vtk::writeList(format(), vertLabels);
|
||||||
|
|
||||||
|
if (format_)
|
||||||
|
{
|
||||||
|
format().flush();
|
||||||
|
format().endDataArray();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (format_)
|
||||||
|
{
|
||||||
|
format().endTag(vtk::fileTag::VERTS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::vtk::coordSetWriter::writeLines()
|
||||||
|
{
|
||||||
|
if (!nLocalLines_)
|
||||||
|
{
|
||||||
|
return; // Nothing to do
|
||||||
|
}
|
||||||
|
|
||||||
|
// connectivity = use each point
|
||||||
|
label nLocalConns = nLocalPoints_;
|
||||||
|
|
||||||
|
if (format_)
|
||||||
|
{
|
||||||
|
format().tag(vtk::fileTag::LINES);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// 'offsets' (connectivity offsets)
|
||||||
|
//
|
||||||
|
{
|
||||||
|
labelList vertOffsets(nLocalLines_);
|
||||||
|
label nOffs = vertOffsets.size();
|
||||||
|
|
||||||
|
// if (parallel_)
|
||||||
|
// {
|
||||||
|
// reduce(nOffs, sumOp<label>());
|
||||||
|
// }
|
||||||
|
|
||||||
|
if (format_)
|
||||||
|
{
|
||||||
|
const uint64_t payLoad = vtk::sizeofData<label>(nOffs);
|
||||||
|
|
||||||
|
format().beginDataArray<label>(vtk::dataArrayAttr::OFFSETS);
|
||||||
|
format().writeSize(payLoad);
|
||||||
|
}
|
||||||
|
|
||||||
|
// processor-local connectivity offsets
|
||||||
|
|
||||||
|
label off = 0;
|
||||||
|
|
||||||
|
/// label off =
|
||||||
|
/// (
|
||||||
|
/// parallel_ ? globalIndex(nLocalConns).localStart() : 0
|
||||||
|
/// );
|
||||||
|
|
||||||
|
auto iter = vertOffsets.begin();
|
||||||
|
|
||||||
|
for (const pointField& pts : points_)
|
||||||
|
{
|
||||||
|
const label npts = pts.size();
|
||||||
|
|
||||||
|
if (npts)
|
||||||
|
{
|
||||||
|
off += npts; // End offset
|
||||||
|
*iter = off;
|
||||||
|
++iter;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
vtk::writeList(format_.ref(), vertOffsets);
|
||||||
|
|
||||||
|
if (format_)
|
||||||
|
{
|
||||||
|
format().flush();
|
||||||
|
format().endDataArray();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// 'connectivity'
|
||||||
|
//
|
||||||
|
{
|
||||||
|
labelList vertLabels(nLocalConns);
|
||||||
|
|
||||||
|
label nConns = nLocalConns;
|
||||||
|
|
||||||
|
// if (parallel_)
|
||||||
|
// {
|
||||||
|
// reduce(nConns, sumOp<label>());
|
||||||
|
// }
|
||||||
|
|
||||||
|
if (format_)
|
||||||
|
{
|
||||||
|
const uint64_t payLoad = vtk::sizeofData<label>(nConns);
|
||||||
|
|
||||||
|
format().beginDataArray<label>(vtk::dataArrayAttr::CONNECTIVITY);
|
||||||
|
format().writeSize(payLoad * sizeof(label));
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
// XML: connectivity only
|
||||||
|
// [id1, id2, ..., id1, id2, ...]
|
||||||
|
|
||||||
|
auto iter = vertLabels.begin();
|
||||||
|
|
||||||
|
label localPointi = 0;
|
||||||
|
for (const pointField& pts : points_)
|
||||||
|
{
|
||||||
|
label npts = pts.size();
|
||||||
|
|
||||||
|
while (npts--)
|
||||||
|
{
|
||||||
|
*iter++ = localPointi;
|
||||||
|
++localPointi;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
vtk::writeList(format(), vertLabels);
|
||||||
|
|
||||||
|
if (format_)
|
||||||
|
{
|
||||||
|
format().flush();
|
||||||
|
format().endDataArray();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (format_)
|
||||||
|
{
|
||||||
|
format().endTag(vtk::fileTag::LINES);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::vtk::coordSetWriter::coordSetWriter
|
||||||
|
(
|
||||||
|
const UPtrList<const pointField>& points,
|
||||||
|
const vtk::outputOptions opts
|
||||||
|
)
|
||||||
|
:
|
||||||
|
vtk::polyWriter(opts),
|
||||||
|
|
||||||
|
points_(points),
|
||||||
|
instant_(),
|
||||||
|
elemOutput_(DEFAULT_ELEMENTS)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::vtk::coordSetWriter::coordSetWriter
|
||||||
|
(
|
||||||
|
const UPtrList<const pointField>& points,
|
||||||
|
const fileName& file,
|
||||||
|
bool parallel
|
||||||
|
)
|
||||||
|
:
|
||||||
|
coordSetWriter(points)
|
||||||
|
{
|
||||||
|
open(file, parallel);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::vtk::coordSetWriter::coordSetWriter
|
||||||
|
(
|
||||||
|
const UPtrList<const pointField>& points,
|
||||||
|
const vtk::outputOptions opts,
|
||||||
|
const fileName& file,
|
||||||
|
bool parallel
|
||||||
|
)
|
||||||
|
:
|
||||||
|
coordSetWriter(points, opts)
|
||||||
|
{
|
||||||
|
open(file, parallel);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
void Foam::vtk::coordSetWriter::setElementType
|
||||||
|
(
|
||||||
|
const elemOutputType elemOutput
|
||||||
|
)
|
||||||
|
{
|
||||||
|
elemOutput_ = elemOutput;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool Foam::vtk::coordSetWriter::open
|
||||||
|
(
|
||||||
|
const fileName& file,
|
||||||
|
bool parallel
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return vtk::polyWriter::open(file, false); // non-parallel only
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::vtk::coordSetWriter::setTime(const instant& inst)
|
||||||
|
{
|
||||||
|
instant_ = inst;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool Foam::vtk::coordSetWriter::beginFile(std::string title)
|
||||||
|
{
|
||||||
|
if (title.size())
|
||||||
|
{
|
||||||
|
return vtk::fileWriter::beginFile(title);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!instant_.name().empty())
|
||||||
|
{
|
||||||
|
return vtk::fileWriter::beginFile
|
||||||
|
(
|
||||||
|
"time='" + instant_.name() + "'"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Provide default title
|
||||||
|
return vtk::fileWriter::beginFile("coord-set");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool Foam::vtk::coordSetWriter::writeGeometry()
|
||||||
|
{
|
||||||
|
enter_Piece();
|
||||||
|
|
||||||
|
beginPiece();
|
||||||
|
|
||||||
|
writePoints();
|
||||||
|
|
||||||
|
//const label pointOffset =
|
||||||
|
//(
|
||||||
|
// parallel_ ? globalIndex(nLocalPoints_).localStart() : 0
|
||||||
|
//);
|
||||||
|
|
||||||
|
if (legacy())
|
||||||
|
{
|
||||||
|
writeVertsLegacy();
|
||||||
|
writeLinesLegacy();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
writeVerts();
|
||||||
|
writeLines();
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::vtk::coordSetWriter::writeTimeValue()
|
||||||
|
{
|
||||||
|
if (!instant_.name().empty())
|
||||||
|
{
|
||||||
|
vtk::fileWriter::writeTimeValue(instant_.value());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::vtk::coordSetWriter::piece
|
||||||
|
(
|
||||||
|
const UPtrList<const pointField>& points
|
||||||
|
)
|
||||||
|
{
|
||||||
|
endPiece();
|
||||||
|
|
||||||
|
points_ = points;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool Foam::vtk::coordSetWriter::writeProcIDs()
|
||||||
|
{
|
||||||
|
// Ignore
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
236
src/meshTools/coordSet/writers/vtk/foamVtkCoordSetWriter.H
Normal file
236
src/meshTools/coordSet/writers/vtk/foamVtkCoordSetWriter.H
Normal file
@ -0,0 +1,236 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | www.openfoam.com
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
Copyright (C) 2022 OpenCFD Ltd.
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
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::vtk::coordSetWriter
|
||||||
|
|
||||||
|
Description
|
||||||
|
Write as points/lines, optionally with fields,
|
||||||
|
as a vtp file or a legacy vtk file.
|
||||||
|
|
||||||
|
The file output states are managed by the Foam::vtk::fileWriter class.
|
||||||
|
FieldData (eg, TimeValue) must appear before any geometry pieces.
|
||||||
|
|
||||||
|
Note
|
||||||
|
Non-parallel only
|
||||||
|
|
||||||
|
SourceFiles
|
||||||
|
foamVtkCoordSetWriter.C
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef Foam_vtk_coordSetWriter_H
|
||||||
|
#define Foam_vtk_coordSetWriter_H
|
||||||
|
|
||||||
|
#include "foamVtkPolyWriter.H"
|
||||||
|
#include "UPtrList.H"
|
||||||
|
#include "Field.H"
|
||||||
|
#include "instant.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
namespace vtk
|
||||||
|
{
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class vtk::coordSetWriter Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
class coordSetWriter
|
||||||
|
:
|
||||||
|
public vtk::polyWriter
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
// Data Types
|
||||||
|
|
||||||
|
//- Types of element output.
|
||||||
|
enum elemOutputType
|
||||||
|
{
|
||||||
|
NO_ELEMENTS = 0,
|
||||||
|
DEFAULT_ELEMENTS = 1,
|
||||||
|
POINT_ELEMENTS = 2,
|
||||||
|
LINE_ELEMENTS = 3
|
||||||
|
};
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
// Private Member Data
|
||||||
|
|
||||||
|
//- Reference to the points
|
||||||
|
UPtrList<const pointField> points_;
|
||||||
|
|
||||||
|
//- Time name/value
|
||||||
|
instant instant_;
|
||||||
|
|
||||||
|
//- Preferred output element type
|
||||||
|
elemOutputType elemOutput_;
|
||||||
|
|
||||||
|
|
||||||
|
// Private Member Functions
|
||||||
|
|
||||||
|
|
||||||
|
// Private Member Functions
|
||||||
|
|
||||||
|
//- Determine sizes (nLocalPoints_, nLocalLines_),
|
||||||
|
//- and begin piece
|
||||||
|
void beginPiece();
|
||||||
|
|
||||||
|
//- Write points
|
||||||
|
void writePoints();
|
||||||
|
|
||||||
|
//- Write vertices, legacy format
|
||||||
|
// \param pointOffset processor-local point offset
|
||||||
|
void writeVertsLegacy();
|
||||||
|
|
||||||
|
//- Write vertices
|
||||||
|
// \param pointOffset processor-local point offset
|
||||||
|
void writeVerts();
|
||||||
|
|
||||||
|
//- Write lines, legacy format
|
||||||
|
// \param pointOffset processor-local point offset
|
||||||
|
void writeLinesLegacy();
|
||||||
|
|
||||||
|
//- Write lines
|
||||||
|
// \param pointOffset processor-local point offset
|
||||||
|
void writeLines();
|
||||||
|
|
||||||
|
|
||||||
|
//- No copy construct
|
||||||
|
coordSetWriter(const coordSetWriter&) = delete;
|
||||||
|
|
||||||
|
//- No copy assignment
|
||||||
|
void operator=(const coordSetWriter&) = delete;
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
//- Construct from components (default format INLINE_BASE64)
|
||||||
|
coordSetWriter
|
||||||
|
(
|
||||||
|
const UPtrList<const pointField>& pts,
|
||||||
|
const vtk::outputOptions opts = vtk::formatType::INLINE_BASE64
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Construct from components (default format INLINE_BASE64),
|
||||||
|
//- and open the file for writing.
|
||||||
|
// The file name is with/without an extension.
|
||||||
|
coordSetWriter
|
||||||
|
(
|
||||||
|
const UPtrList<const pointField>& pts,
|
||||||
|
const fileName& file,
|
||||||
|
bool paralel = false /* ignored: always false */
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Construct from components and open the file for writing.
|
||||||
|
// The file name is with/without an extension.
|
||||||
|
coordSetWriter
|
||||||
|
(
|
||||||
|
const UPtrList<const pointField>& pts,
|
||||||
|
const vtk::outputOptions opts,
|
||||||
|
const fileName& file,
|
||||||
|
bool paralel = false /* ignored: always false */
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
//- Destructor
|
||||||
|
virtual ~coordSetWriter() = default;
|
||||||
|
|
||||||
|
|
||||||
|
// Member Functions
|
||||||
|
|
||||||
|
//- Define preferred element type
|
||||||
|
void setElementType(const elemOutputType elemOutput);
|
||||||
|
|
||||||
|
//- Open file for writing. Non-parallel only
|
||||||
|
virtual bool open
|
||||||
|
(
|
||||||
|
const fileName& file,
|
||||||
|
bool parallel = false /* ignored: always false */
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Define a time name/value for the output
|
||||||
|
virtual void setTime(const instant& inst);
|
||||||
|
|
||||||
|
//- Write file header (non-collective)
|
||||||
|
// \note Expected calling states: (OPENED).
|
||||||
|
virtual bool beginFile(std::string title = "");
|
||||||
|
|
||||||
|
//- Write patch topology
|
||||||
|
// Also writes the file header if not previously written.
|
||||||
|
// \note Must be called prior to writing CellData or PointData
|
||||||
|
virtual bool writeGeometry();
|
||||||
|
|
||||||
|
//- Write "TimeValue" FieldData (name as per Catalyst output)
|
||||||
|
// Must be called within the FIELD_DATA state.
|
||||||
|
// \note As a convenience this can also be called from
|
||||||
|
// (OPENED | DECLARED) states, in which case it invokes
|
||||||
|
// beginFieldData(1) internally.
|
||||||
|
using vtk::fileWriter::writeTimeValue;
|
||||||
|
|
||||||
|
//- Write the currently set time as "TimeValue" FieldData
|
||||||
|
void writeTimeValue();
|
||||||
|
|
||||||
|
//- Reset point references to begin a new piece
|
||||||
|
void piece(const UPtrList<const pointField>& points);
|
||||||
|
|
||||||
|
|
||||||
|
//- Write processor ids for each line as CellData
|
||||||
|
//- (no-op in serial)
|
||||||
|
bool writeProcIDs();
|
||||||
|
|
||||||
|
|
||||||
|
// Write
|
||||||
|
|
||||||
|
//- Write primitive field of PointData
|
||||||
|
template<class Type>
|
||||||
|
void writePointData
|
||||||
|
(
|
||||||
|
const word& fieldName,
|
||||||
|
const UPtrList<const Field<Type>>& fieldPtrs
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace vtk
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#ifdef NoRepository
|
||||||
|
#include "foamVtkCoordSetWriterTemplates.C"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,81 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | www.openfoam.com
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
Copyright (C) 2022 OpenCFD Ltd.
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
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/>.
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
void Foam::vtk::coordSetWriter::writePointData
|
||||||
|
(
|
||||||
|
const word& fieldName,
|
||||||
|
const UPtrList<const Field<Type>>& fieldPtrs
|
||||||
|
)
|
||||||
|
{
|
||||||
|
// Could check sizes:
|
||||||
|
|
||||||
|
if (isState(outputState::POINT_DATA))
|
||||||
|
{
|
||||||
|
++nPointData_;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
reportBadState(FatalErrorInFunction, outputState::POINT_DATA)
|
||||||
|
<< " for field " << fieldName << nl << endl
|
||||||
|
<< exit(FatalError);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
label nValues = 0;
|
||||||
|
|
||||||
|
for (const Field<Type>& field : fieldPtrs)
|
||||||
|
{
|
||||||
|
nValues += field.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
// if (parallel_)
|
||||||
|
// {
|
||||||
|
// reduce(nValues, sumOp<label>());
|
||||||
|
// }
|
||||||
|
|
||||||
|
this->beginDataArray<Type>(fieldName, nValues);
|
||||||
|
|
||||||
|
// if (parallel_)
|
||||||
|
// {
|
||||||
|
// vtk::writeListParallel(format_.ref(), field);
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
{
|
||||||
|
for (const Field<Type>& field : fieldPtrs)
|
||||||
|
{
|
||||||
|
vtk::writeList(format(), field);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this->endDataArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -5,7 +5,7 @@
|
|||||||
\\ / A nd | www.openfoam.com
|
\\ / A nd | www.openfoam.com
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2016-2021 OpenCFD Ltd.
|
Copyright (C) 2016-2022 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -39,7 +39,7 @@ void Foam::vtk::patchMeshWriter::beginPiece()
|
|||||||
const polyBoundaryMesh& patches = mesh_.boundaryMesh();
|
const polyBoundaryMesh& patches = mesh_.boundaryMesh();
|
||||||
|
|
||||||
nLocalPoints_ = nLocalPolys_ = 0;
|
nLocalPoints_ = nLocalPolys_ = 0;
|
||||||
nLocalVerts_ = 0;
|
nLocalPolyConn_ = 0;
|
||||||
|
|
||||||
for (const label patchId : patchIDs_)
|
for (const label patchId : patchIDs_)
|
||||||
{
|
{
|
||||||
@ -50,7 +50,7 @@ void Foam::vtk::patchMeshWriter::beginPiece()
|
|||||||
|
|
||||||
for (const face& f : pp)
|
for (const face& f : pp)
|
||||||
{
|
{
|
||||||
nLocalVerts_ += f.size();
|
nLocalPolyConn_ += f.size();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -150,12 +150,12 @@ void Foam::vtk::patchMeshWriter::writePolysLegacy(const label pointOffset)
|
|||||||
// Connectivity count without additional storage (done internally)
|
// Connectivity count without additional storage (done internally)
|
||||||
|
|
||||||
label nPolys = nLocalPolys_;
|
label nPolys = nLocalPolys_;
|
||||||
label nVerts = nLocalVerts_;
|
label nPolyConn = nLocalPolyConn_;
|
||||||
|
|
||||||
if (parallel_)
|
if (parallel_)
|
||||||
{
|
{
|
||||||
reduce(nPolys, sumOp<label>());
|
reduce(nPolys, sumOp<label>());
|
||||||
reduce(nVerts, sumOp<label>());
|
reduce(nPolyConn, sumOp<label>());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nPolys != numberOfCells_)
|
if (nPolys != numberOfCells_)
|
||||||
@ -166,9 +166,9 @@ void Foam::vtk::patchMeshWriter::writePolysLegacy(const label pointOffset)
|
|||||||
<< exit(FatalError);
|
<< exit(FatalError);
|
||||||
}
|
}
|
||||||
|
|
||||||
legacy::beginPolys(os_, nPolys, nVerts);
|
legacy::beginPolys(os_, nPolys, nPolyConn);
|
||||||
|
|
||||||
labelList vertLabels(nLocalPolys_ + nLocalVerts_);
|
labelList vertLabels(nLocalPolys_ + nLocalPolyConn_);
|
||||||
|
|
||||||
{
|
{
|
||||||
// Legacy: size + connectivity together
|
// Legacy: size + connectivity together
|
||||||
@ -227,9 +227,9 @@ void Foam::vtk::patchMeshWriter::writePolys(const label pointOffset)
|
|||||||
// 'connectivity'
|
// 'connectivity'
|
||||||
//
|
//
|
||||||
{
|
{
|
||||||
labelList vertLabels(nLocalVerts_);
|
labelList vertLabels(nLocalPolyConn_);
|
||||||
|
|
||||||
label nVerts = nLocalVerts_;
|
label nVerts = nLocalPolyConn_;
|
||||||
|
|
||||||
if (parallel_)
|
if (parallel_)
|
||||||
{
|
{
|
||||||
@ -312,7 +312,7 @@ void Foam::vtk::patchMeshWriter::writePolys(const label pointOffset)
|
|||||||
// processor-local connectivity offsets
|
// processor-local connectivity offsets
|
||||||
label off =
|
label off =
|
||||||
(
|
(
|
||||||
parallel_ ? globalIndex(nLocalVerts_).localStart() : 0
|
parallel_ ? globalIndex(nLocalPolyConn_).localStart() : 0
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
@ -369,7 +369,7 @@ Foam::vtk::patchMeshWriter::patchMeshWriter
|
|||||||
numberOfCells_(0),
|
numberOfCells_(0),
|
||||||
nLocalPoints_(0),
|
nLocalPoints_(0),
|
||||||
nLocalPolys_(0),
|
nLocalPolys_(0),
|
||||||
nLocalVerts_(0),
|
nLocalPolyConn_(0),
|
||||||
|
|
||||||
mesh_(mesh),
|
mesh_(mesh),
|
||||||
patchIDs_(patchIDs)
|
patchIDs_(patchIDs)
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
\\ / A nd | www.openfoam.com
|
\\ / A nd | www.openfoam.com
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2016-2021 OpenCFD Ltd.
|
Copyright (C) 2016-2022 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -85,8 +85,8 @@ protected:
|
|||||||
//- Local number of polys (faces)
|
//- Local number of polys (faces)
|
||||||
label nLocalPolys_;
|
label nLocalPolys_;
|
||||||
|
|
||||||
//- Local face vertices (connectivity) count. Sum of face sizes.
|
//- Local connectivity count for polys (faces) == sum of face sizes
|
||||||
label nLocalVerts_;
|
label nLocalPolyConn_;
|
||||||
|
|
||||||
//- Reference to the OpenFOAM mesh (or subset)
|
//- Reference to the OpenFOAM mesh (or subset)
|
||||||
const polyMesh& mesh_;
|
const polyMesh& mesh_;
|
||||||
|
|||||||
Reference in New Issue
Block a user