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 * * * * * * * * * * * * //
|
||||
|
||||
inline unsigned char Foam::base64Layer::encode0() const
|
||||
inline unsigned char Foam::base64Layer::encode0() const noexcept
|
||||
{
|
||||
// Top 6 bits of char0
|
||||
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
|
||||
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
|
||||
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
|
||||
return base64Chars[(group_[2] & 0x3F)];
|
||||
|
||||
@ -39,8 +39,8 @@ SourceFiles
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef base64Layer_H
|
||||
#define base64Layer_H
|
||||
#ifndef Foam_base64Layer_H
|
||||
#define Foam_base64Layer_H
|
||||
|
||||
#include <iostream>
|
||||
|
||||
@ -72,16 +72,10 @@ class base64Layer
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
inline unsigned char encode0() const;
|
||||
inline unsigned char encode1() const;
|
||||
inline unsigned char encode2() const;
|
||||
inline unsigned char encode3() const;
|
||||
|
||||
//- No copy construct
|
||||
base64Layer(const base64Layer&) = delete;
|
||||
|
||||
//- No copy assignment
|
||||
void operator=(const base64Layer&) = delete;
|
||||
inline unsigned char encode0() const noexcept;
|
||||
inline unsigned char encode1() const noexcept;
|
||||
inline unsigned char encode2() const noexcept;
|
||||
inline unsigned char encode3() const noexcept;
|
||||
|
||||
|
||||
protected:
|
||||
@ -91,6 +85,12 @@ protected:
|
||||
//- Add a character to the group, outputting when the group is full.
|
||||
void add(char c);
|
||||
|
||||
//- No copy construct
|
||||
base64Layer(const base64Layer&) = delete;
|
||||
|
||||
//- No copy assignment
|
||||
void operator=(const base64Layer&) = delete;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2016-2021 OpenCFD Ltd.
|
||||
Copyright (C) 2016-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -52,7 +52,7 @@ namespace vtk
|
||||
// Enumerations
|
||||
|
||||
//- The context when outputting a VTK file (XML or legacy).
|
||||
enum OutputContext
|
||||
enum OutputContext : uint8_t
|
||||
{
|
||||
INLINE, //!< Generate header and inline data
|
||||
HEADER, //!< Generate header only
|
||||
@ -72,21 +72,21 @@ namespace vtk
|
||||
LEGACY_BINARY = 0x22, //!< Legacy raw binary, legacyRawFormatter
|
||||
};
|
||||
|
||||
//- Test for XML append format
|
||||
inline bool isAppend(enum formatType fmt)
|
||||
//- Test for vtk append format (xml)
|
||||
inline bool isAppend(enum formatType fmt) noexcept
|
||||
{
|
||||
return (uint8_t(fmt) & 0x10);
|
||||
}
|
||||
|
||||
//- Test for vtk legacy format
|
||||
inline bool isLegacy(enum formatType fmt)
|
||||
inline bool isLegacy(enum formatType fmt) noexcept
|
||||
{
|
||||
return (uint8_t(fmt) & 0x20);
|
||||
}
|
||||
|
||||
|
||||
//- Equivalent to enumeration in "vtkCellType.h"
|
||||
enum cellType
|
||||
//- Equivalent to enumeration in "vtkCellType.h" (should be uint8_t)
|
||||
enum cellType : uint8_t
|
||||
{
|
||||
VTK_EMPTY_CELL = 0,
|
||||
VTK_VERTEX = 1,
|
||||
@ -110,7 +110,7 @@ namespace vtk
|
||||
|
||||
|
||||
//- Some common XML tags for vtk files
|
||||
enum class fileTag
|
||||
enum class fileTag : uint8_t
|
||||
{
|
||||
VTK_FILE, //!< "VTKFile"
|
||||
DATA_ARRAY, //!< "DataArray"
|
||||
@ -140,7 +140,7 @@ namespace vtk
|
||||
extern const Foam::Enum<fileTag> fileTagNames;
|
||||
|
||||
//- Some common XML attributes for vtk files
|
||||
enum class fileAttr
|
||||
enum class fileAttr : uint8_t
|
||||
{
|
||||
OFFSET, //!< "offset"
|
||||
NUMBER_OF_COMPONENTS, //!< "NumberOfComponents"
|
||||
@ -156,7 +156,7 @@ namespace vtk
|
||||
extern const Foam::Enum<fileAttr> fileAttrNames;
|
||||
|
||||
//- Some common names for XML DataArray entries
|
||||
enum class dataArrayAttr
|
||||
enum class dataArrayAttr : uint8_t
|
||||
{
|
||||
POINTS, //!< "Points"
|
||||
OFFSETS, //!< "offsets"
|
||||
|
||||
@ -42,17 +42,17 @@ Description
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward declarations
|
||||
// Forward Declarations
|
||||
class endian;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class vtkPTraits Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class PrimitiveType>
|
||||
template<class Type>
|
||||
struct vtkPTraits
|
||||
{
|
||||
// Static data members
|
||||
// Static Data Members
|
||||
static const char* const typeName;
|
||||
};
|
||||
|
||||
|
||||
@ -290,10 +290,10 @@ Foam::vtk::fileWriter::fileWriter
|
||||
const vtk::outputOptions opts
|
||||
)
|
||||
:
|
||||
contentType_(contentType),
|
||||
opts_(opts),
|
||||
parallel_(false),
|
||||
state_(outputState::CLOSED),
|
||||
contentType_(contentType),
|
||||
parallel_(false),
|
||||
opts_(opts),
|
||||
nCellData_(0),
|
||||
nPointData_(0),
|
||||
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
|
||||
// is desired on any particular process.
|
||||
|
||||
if (Pstream::master() || !parallel_)
|
||||
if (!parallel_ || Pstream::master())
|
||||
{
|
||||
mkDir(outputFile_.path());
|
||||
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2018-2021 OpenCFD Ltd.
|
||||
Copyright (C) 2018-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -42,6 +42,8 @@ Description
|
||||
|
||||
SourceFiles
|
||||
foamVtkFileWriter.C
|
||||
foamVtkFileWriterI.H
|
||||
foamVtkFileWriterTemplates.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
@ -71,7 +73,7 @@ protected:
|
||||
// Protected Member Data
|
||||
|
||||
//- Internal tracking of the output state.
|
||||
enum outputState
|
||||
enum outputState : uint8_t
|
||||
{
|
||||
CLOSED = 0, //!< File is closed
|
||||
OPENED, //!< File is opened
|
||||
@ -86,18 +88,18 @@ protected:
|
||||
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
|
||||
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.
|
||||
label nCellData_;
|
||||
|
||||
@ -128,7 +130,7 @@ protected:
|
||||
//- The backend ostream in use
|
||||
inline std::ofstream& os() noexcept;
|
||||
|
||||
//- The VTK formatter in use
|
||||
//- The VTK formatter in use. FatalError for off-processor.
|
||||
inline vtk::formatter& format();
|
||||
|
||||
//- True if output state corresponds to the test state.
|
||||
@ -231,16 +233,16 @@ public:
|
||||
// Member Functions
|
||||
|
||||
//- The content type
|
||||
inline vtk::fileTag contentType() const;
|
||||
inline vtk::fileTag contentType() const noexcept;
|
||||
|
||||
//- The output options in use
|
||||
inline vtk::outputOptions opts() const;
|
||||
inline vtk::outputOptions opts() const noexcept;
|
||||
|
||||
//- File extension for current format type.
|
||||
inline word ext() const;
|
||||
|
||||
//- Commonly used query
|
||||
inline bool legacy() const;
|
||||
inline bool legacy() const noexcept;
|
||||
|
||||
//- Parallel output requested?
|
||||
inline bool parallel() const noexcept;
|
||||
@ -258,7 +260,11 @@ public:
|
||||
// If the file name has an extension, it will be used where if
|
||||
// appropriate or changed to suit the format (legacy/xml) type.
|
||||
// \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.
|
||||
// \note Expected calling states: (PIECE | CELL_DATA | POINT_DATA).
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2018 OpenCFD Ltd.
|
||||
Copyright (C) 2018-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -53,13 +53,13 @@ inline bool Foam::vtk::fileWriter::notState(outputState test) const noexcept
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
inline Foam::vtk::fileTag Foam::vtk::fileWriter::contentType() const
|
||||
inline Foam::vtk::fileTag Foam::vtk::fileWriter::contentType() const noexcept
|
||||
{
|
||||
return contentType_;
|
||||
}
|
||||
|
||||
|
||||
inline Foam::vtk::outputOptions Foam::vtk::fileWriter::opts() const
|
||||
inline Foam::vtk::outputOptions Foam::vtk::fileWriter::opts() const noexcept
|
||||
{
|
||||
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();
|
||||
}
|
||||
|
||||
@ -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
|
||||
(
|
||||
@ -397,9 +397,7 @@ Foam::label Foam::vtk::vtmWriter::beginBlock(const word& blockName)
|
||||
|
||||
Foam::label Foam::vtk::vtmWriter::endBlock(const word& blockName)
|
||||
{
|
||||
label nblock = blocks_.size();
|
||||
|
||||
if (nblock)
|
||||
if (!blocks_.empty())
|
||||
{
|
||||
const word curr(blocks_.remove());
|
||||
|
||||
|
||||
@ -118,7 +118,7 @@ class vtmWriter
|
||||
vtmEntry& operator=(const vtmEntry&) = default;
|
||||
vtmEntry& operator=(vtmEntry&&) = default;
|
||||
|
||||
//- Construct null
|
||||
//- Default construct
|
||||
vtmEntry()
|
||||
:
|
||||
type_(NONE)
|
||||
@ -157,7 +157,7 @@ class vtmWriter
|
||||
// Member Functions
|
||||
|
||||
//- Test the type
|
||||
bool isType(Type what) const
|
||||
bool isType(Type what) const noexcept
|
||||
{
|
||||
return type_ == what;
|
||||
}
|
||||
@ -166,7 +166,7 @@ class vtmWriter
|
||||
void clear();
|
||||
|
||||
//- True if the entry is good.
|
||||
bool good() const;
|
||||
bool good() const noexcept;
|
||||
|
||||
//- Output valid entry as XML
|
||||
bool write(vtk::formatter& format) const;
|
||||
@ -207,7 +207,7 @@ public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct null, with autoName on
|
||||
//- Default construct, with autoName on
|
||||
vtmWriter();
|
||||
|
||||
//- Construct with specified behaviour for autoName
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2016-2018 OpenCFD Ltd.
|
||||
Copyright (C) 2016-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -53,7 +53,7 @@ namespace vtk
|
||||
|
||||
class appendBase64Formatter
|
||||
:
|
||||
public foamVtkBase64Layer
|
||||
public vtk::foamVtkBase64Layer
|
||||
{
|
||||
// Private Data Members
|
||||
|
||||
@ -78,7 +78,7 @@ public:
|
||||
// Constructors
|
||||
|
||||
//- Construct and attach to an output stream
|
||||
appendBase64Formatter(std::ostream& os);
|
||||
explicit appendBase64Formatter(std::ostream& os);
|
||||
|
||||
|
||||
//- Destructor. Closes/flushes the underlying layer.
|
||||
@ -88,7 +88,7 @@ public:
|
||||
// Member Functions
|
||||
|
||||
//- The output is APPEND_BASE64.
|
||||
virtual const outputOptions& opts() const;
|
||||
virtual const vtk::outputOptions& opts() const;
|
||||
|
||||
//- Output name for XML type ("append")
|
||||
virtual const char* name() const;
|
||||
@ -101,6 +101,7 @@ public:
|
||||
virtual uint64_t offset(const uint64_t numbytes);
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace vtk
|
||||
|
||||
@ -54,7 +54,7 @@ void Foam::vtk::appendRawFormatter::write
|
||||
|
||||
Foam::vtk::appendRawFormatter::appendRawFormatter(std::ostream& os)
|
||||
:
|
||||
formatter(os),
|
||||
vtk::formatter(os),
|
||||
offset_(0)
|
||||
{}
|
||||
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2016-2018 OpenCFD Ltd.
|
||||
Copyright (C) 2016-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -52,7 +52,7 @@ namespace vtk
|
||||
|
||||
class appendRawFormatter
|
||||
:
|
||||
public formatter
|
||||
public vtk::formatter
|
||||
{
|
||||
// Private Data Members
|
||||
|
||||
@ -64,7 +64,12 @@ class appendRawFormatter
|
||||
uint64_t offset_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
protected:
|
||||
|
||||
// Protected Member Functions
|
||||
|
||||
//- Write
|
||||
void write(const char* s, std::streamsize n);
|
||||
|
||||
//- No copy construct
|
||||
appendRawFormatter(const appendRawFormatter&) = delete;
|
||||
@ -73,20 +78,12 @@ class appendRawFormatter
|
||||
void operator=(const appendRawFormatter&) = delete;
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
// Protected Member Functions
|
||||
|
||||
//- Write
|
||||
void write(const char* s, std::streamsize n);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct and attach to an output stream
|
||||
appendRawFormatter(std::ostream& os);
|
||||
explicit appendRawFormatter(std::ostream& os);
|
||||
|
||||
|
||||
//- Destructor
|
||||
@ -96,7 +93,7 @@ public:
|
||||
// Member Functions
|
||||
|
||||
//- The output is APPEND_BINARY.
|
||||
virtual const outputOptions& opts() const;
|
||||
virtual const vtk::outputOptions& opts() const;
|
||||
|
||||
//- Output name for XML type ("append")
|
||||
virtual const char* name() const;
|
||||
@ -122,9 +119,9 @@ public:
|
||||
|
||||
//- A no-op for this format
|
||||
virtual void flush();
|
||||
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace vtk
|
||||
|
||||
@ -68,7 +68,7 @@ inline void Foam::vtk::asciiFormatter::done()
|
||||
|
||||
Foam::vtk::asciiFormatter::asciiFormatter(std::ostream& os)
|
||||
:
|
||||
formatter(os),
|
||||
vtk::formatter(os),
|
||||
pos_(0)
|
||||
{}
|
||||
|
||||
@ -76,13 +76,13 @@ Foam::vtk::asciiFormatter::asciiFormatter(std::ostream& os)
|
||||
Foam::vtk::asciiFormatter::asciiFormatter
|
||||
(
|
||||
std::ostream& os,
|
||||
unsigned precision
|
||||
unsigned prec
|
||||
)
|
||||
:
|
||||
formatter(os),
|
||||
vtk::formatter(os),
|
||||
pos_(0)
|
||||
{
|
||||
os.precision(precision);
|
||||
os.precision(prec);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2016-2021 OpenCFD Ltd.
|
||||
Copyright (C) 2016-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -54,7 +54,7 @@ namespace vtk
|
||||
|
||||
class asciiFormatter
|
||||
:
|
||||
public formatter
|
||||
public vtk::formatter
|
||||
{
|
||||
// Private Data Members
|
||||
|
||||
@ -89,10 +89,10 @@ public:
|
||||
// Constructors
|
||||
|
||||
//- 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
|
||||
asciiFormatter(std::ostream& os, unsigned precision);
|
||||
asciiFormatter(std::ostream& os, unsigned prec);
|
||||
|
||||
|
||||
//- Destructor. Finishes the output line as required.
|
||||
@ -102,7 +102,7 @@ public:
|
||||
// Member Functions
|
||||
|
||||
//- The output is INLINE_ASCII.
|
||||
virtual const outputOptions& opts() const;
|
||||
virtual const vtk::outputOptions& opts() const;
|
||||
|
||||
//- Name for the XML output type ("ascii")
|
||||
virtual const char* name() const;
|
||||
@ -127,9 +127,9 @@ public:
|
||||
//- The encoded length for ascii output is not applicable.
|
||||
// \return 0
|
||||
virtual std::size_t encodedLength(std::size_t ignored) const;
|
||||
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace vtk
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2016-2017 OpenCFD Ltd.
|
||||
Copyright (C) 2016-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -51,7 +51,7 @@ namespace vtk
|
||||
|
||||
class base64Formatter
|
||||
:
|
||||
public foamVtkBase64Layer
|
||||
public vtk::foamVtkBase64Layer
|
||||
{
|
||||
// Private Data Members
|
||||
|
||||
@ -73,7 +73,7 @@ public:
|
||||
// Constructors
|
||||
|
||||
//- Construct and attach to an output stream
|
||||
base64Formatter(std::ostream& os);
|
||||
explicit base64Formatter(std::ostream& os);
|
||||
|
||||
|
||||
//- Destructor. Closes/flushes the underlying layer.
|
||||
@ -83,7 +83,7 @@ public:
|
||||
// Member Functions
|
||||
|
||||
//- The output is INLINE_BASE64.
|
||||
virtual const outputOptions& opts() const;
|
||||
virtual const vtk::outputOptions& opts() const;
|
||||
|
||||
//- Name for the XML output type ("binary")
|
||||
virtual const char* name() const;
|
||||
@ -92,9 +92,9 @@ public:
|
||||
//- End the encoding sequence (padding the final characters with '=')
|
||||
// and write a newline to the output if any encoding was done.
|
||||
virtual void flush();
|
||||
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace vtk
|
||||
|
||||
@ -41,7 +41,7 @@ void Foam::vtk::foamVtkBase64Layer::write
|
||||
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)
|
||||
:
|
||||
formatter(os),
|
||||
base64Layer(os)
|
||||
vtk::formatter(os),
|
||||
Foam::base64Layer(os)
|
||||
{}
|
||||
|
||||
|
||||
@ -58,7 +58,7 @@ Foam::vtk::foamVtkBase64Layer::foamVtkBase64Layer(std::ostream& os)
|
||||
|
||||
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)
|
||||
{
|
||||
base64Layer::add(val);
|
||||
Foam::base64Layer::add(val);
|
||||
}
|
||||
|
||||
|
||||
@ -120,13 +120,13 @@ void Foam::vtk::foamVtkBase64Layer::write(const double val)
|
||||
|
||||
void Foam::vtk::foamVtkBase64Layer::flush()
|
||||
{
|
||||
base64Layer::close();
|
||||
Foam::base64Layer::close();
|
||||
}
|
||||
|
||||
|
||||
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
|
||||
:
|
||||
public formatter,
|
||||
protected base64Layer
|
||||
public vtk::formatter,
|
||||
protected Foam::base64Layer
|
||||
{
|
||||
// Private Data Members
|
||||
|
||||
static const char* encoding_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- No copy construct
|
||||
foamVtkBase64Layer(const foamVtkBase64Layer&) = delete;
|
||||
|
||||
//- No copy assignment
|
||||
void operator=(const foamVtkBase64Layer&) = delete;
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
// Protected Member Functions
|
||||
@ -74,11 +65,17 @@ protected:
|
||||
//- Write
|
||||
void write(const char* s, std::streamsize n);
|
||||
|
||||
//- No copy construct
|
||||
foamVtkBase64Layer(const foamVtkBase64Layer&) = delete;
|
||||
|
||||
//- No copy assignment
|
||||
void operator=(const foamVtkBase64Layer&) = delete;
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct and attach to an output stream
|
||||
foamVtkBase64Layer(std::ostream& os);
|
||||
explicit foamVtkBase64Layer(std::ostream& os);
|
||||
|
||||
public:
|
||||
|
||||
@ -105,9 +102,9 @@ public:
|
||||
|
||||
//- The encoded length for base64 encoded output.
|
||||
virtual std::size_t encodedLength(std::size_t n) const;
|
||||
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace vtk
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2016-2018 OpenCFD Ltd.
|
||||
Copyright (C) 2016-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -132,7 +132,7 @@ protected:
|
||||
// Constructors
|
||||
|
||||
//- Construct and attach to an output stream
|
||||
inline formatter(std::ostream& os);
|
||||
inline explicit formatter(std::ostream& os);
|
||||
|
||||
|
||||
public:
|
||||
@ -155,10 +155,10 @@ public:
|
||||
// Access
|
||||
|
||||
//- Access to the underlying output stream
|
||||
inline std::ostream& os();
|
||||
inline std::ostream& os() noexcept;
|
||||
|
||||
//- 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.
|
||||
virtual const char* name() const = 0;
|
||||
@ -540,7 +540,6 @@ public:
|
||||
dataName, formatter::npos, true
|
||||
);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -67,7 +67,7 @@ inline Foam::vtk::formatter::formatter(std::ostream& os)
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
inline std::ostream& Foam::vtk::formatter::os()
|
||||
inline std::ostream& Foam::vtk::formatter::os() noexcept
|
||||
{
|
||||
return os_;
|
||||
}
|
||||
|
||||
@ -50,10 +50,10 @@ Foam::vtk::legacyAsciiFormatter::legacyAsciiFormatter
|
||||
Foam::vtk::legacyAsciiFormatter::legacyAsciiFormatter
|
||||
(
|
||||
std::ostream& os,
|
||||
unsigned precision
|
||||
unsigned prec
|
||||
)
|
||||
:
|
||||
asciiFormatter(os, precision)
|
||||
asciiFormatter(os, prec)
|
||||
{}
|
||||
|
||||
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2017-2018 OpenCFD Ltd.
|
||||
Copyright (C) 2017-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -53,7 +53,7 @@ namespace vtk
|
||||
|
||||
class legacyAsciiFormatter
|
||||
:
|
||||
public asciiFormatter
|
||||
public vtk::asciiFormatter
|
||||
{
|
||||
// Private Data Members
|
||||
|
||||
@ -75,10 +75,10 @@ public:
|
||||
// Constructors
|
||||
|
||||
//- 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
|
||||
legacyAsciiFormatter(std::ostream& os, unsigned precision);
|
||||
legacyAsciiFormatter(std::ostream& os, unsigned prec);
|
||||
|
||||
|
||||
//- Destructor
|
||||
@ -88,7 +88,7 @@ public:
|
||||
// Member Functions
|
||||
|
||||
//- The output is LEGACY_ASCII.
|
||||
virtual const outputOptions& opts() const;
|
||||
virtual const vtk::outputOptions& opts() const;
|
||||
|
||||
//- Name for the legacy ascii output type ("ASCII")
|
||||
virtual const char* name() const;
|
||||
@ -107,9 +107,9 @@ public:
|
||||
inline virtual formatter& endPointData() { return *this; }
|
||||
inline virtual formatter& endPiece() { return *this; }
|
||||
inline virtual formatter& endVTKFile() { return *this; }
|
||||
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace vtk
|
||||
|
||||
@ -57,7 +57,7 @@ Foam::vtk::legacyRawFormatter::legacyRawFormatter
|
||||
std::ostream& os
|
||||
)
|
||||
:
|
||||
formatter(os)
|
||||
vtk::formatter(os)
|
||||
{}
|
||||
|
||||
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2017-2018 OpenCFD Ltd.
|
||||
Copyright (C) 2017-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -55,21 +55,12 @@ namespace vtk
|
||||
|
||||
class legacyRawFormatter
|
||||
:
|
||||
public formatter
|
||||
public vtk::formatter
|
||||
{
|
||||
// Private Data Members
|
||||
|
||||
static const char* legacyName_;
|
||||
static const outputOptions opts_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- No copy construct
|
||||
legacyRawFormatter(const legacyRawFormatter&) = delete;
|
||||
|
||||
//- No copy assignment
|
||||
void operator=(const legacyRawFormatter&) = delete;
|
||||
static const vtk::outputOptions opts_;
|
||||
|
||||
|
||||
protected:
|
||||
@ -79,13 +70,19 @@ protected:
|
||||
//- Write
|
||||
void write(const char* s, std::streamsize n);
|
||||
|
||||
//- No copy construct
|
||||
legacyRawFormatter(const legacyRawFormatter&) = delete;
|
||||
|
||||
//- No copy assignment
|
||||
void operator=(const legacyRawFormatter&) = delete;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct and attach to an output stream
|
||||
legacyRawFormatter(std::ostream& os);
|
||||
explicit legacyRawFormatter(std::ostream& os);
|
||||
|
||||
|
||||
//- Destructor
|
||||
@ -95,7 +92,7 @@ public:
|
||||
// Member Functions
|
||||
|
||||
//- The output is LEGACY_BINARY.
|
||||
virtual const outputOptions& opts() const;
|
||||
virtual const vtk::outputOptions& opts() const;
|
||||
|
||||
//- Name for the legacy binary output type ("BINARY")
|
||||
virtual const char* name() const;
|
||||
@ -127,9 +124,9 @@ public:
|
||||
inline virtual formatter& endPointData() { return *this; }
|
||||
inline virtual formatter& endPiece() { return *this; }
|
||||
inline virtual formatter& endVTKFile() { return *this; }
|
||||
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace vtk
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2016-2021 OpenCFD Ltd.
|
||||
Copyright (C) 2016-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -254,11 +254,29 @@ namespace legacy
|
||||
//- Emit header for POINTS (with trailing newline).
|
||||
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).
|
||||
// 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.
|
||||
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).
|
||||
// The nConnectivity is the sum of all connectivity points used,
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2017-2021 OpenCFD Ltd.
|
||||
Copyright (C) 2017-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
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
|
||||
(
|
||||
std::ostream& os,
|
||||
@ -126,6 +144,10 @@ inline void Foam::vtk::legacy::beginLines
|
||||
label nConnectivity
|
||||
)
|
||||
{
|
||||
if (!nConnectivity)
|
||||
{
|
||||
nConnectivity = 2*nLines;
|
||||
}
|
||||
os << nl
|
||||
<< legacy::fileTagNames[vtk::fileTag::LINES]
|
||||
<< ' ' << nLines
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2016-2019 OpenCFD Ltd.
|
||||
Copyright (C) 2016-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -61,15 +61,15 @@ class outputOptions
|
||||
{
|
||||
// Private Member Data
|
||||
|
||||
//- The output style tuning
|
||||
enum styleType
|
||||
{
|
||||
NONE = 0x00, //!< Normal
|
||||
HEADER = 0x01 //!< Emit xml header
|
||||
};
|
||||
/// //- The output style tuning
|
||||
/// enum styleType
|
||||
/// {
|
||||
/// NONE = 0x00, //!< Normal
|
||||
/// HEADER = 0x01 //!< Emit xml header
|
||||
/// };
|
||||
|
||||
//- The output format type
|
||||
formatType fmtType_;
|
||||
vtk::formatType fmtType_;
|
||||
|
||||
//- ASCII write precision
|
||||
mutable unsigned precision_;
|
||||
@ -79,15 +79,16 @@ public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct null - XML insitu ASCII format with default precision
|
||||
//- Default construct - XML insitu ASCII format with default precision
|
||||
inline outputOptions();
|
||||
|
||||
//- Construct with specified format and default (ASCII) precision
|
||||
//
|
||||
// \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
|
||||
inline outputOptions(enum formatType fmtType, unsigned prec);
|
||||
inline outputOptions(enum vtk::formatType fmtType, unsigned prec);
|
||||
|
||||
|
||||
// Selectors
|
||||
@ -101,28 +102,28 @@ public:
|
||||
// Access
|
||||
|
||||
//- 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
|
||||
inline word ext(vtk::fileTag contentType) const;
|
||||
|
||||
//- 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)
|
||||
inline bool xml() const;
|
||||
inline bool xml() const noexcept;
|
||||
|
||||
//- 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
|
||||
inline bool insitu() const;
|
||||
inline bool insitu() const noexcept;
|
||||
|
||||
//- True if output format is ASCII
|
||||
inline bool ascii() const;
|
||||
inline bool ascii() const noexcept;
|
||||
|
||||
//- Return the ASCII write precision
|
||||
inline unsigned precision() const;
|
||||
inline unsigned precision() const noexcept;
|
||||
|
||||
|
||||
// Edit
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2016-2019 OpenCFD Ltd.
|
||||
Copyright (C) 2016-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -25,8 +25,6 @@ License
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "foamVtkOutput.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
inline Foam::vtk::outputOptions::outputOptions()
|
||||
@ -38,7 +36,7 @@ inline Foam::vtk::outputOptions::outputOptions()
|
||||
|
||||
inline Foam::vtk::outputOptions::outputOptions
|
||||
(
|
||||
enum formatType fmtType
|
||||
enum vtk::formatType fmtType
|
||||
)
|
||||
:
|
||||
fmtType_(fmtType),
|
||||
@ -48,7 +46,7 @@ inline Foam::vtk::outputOptions::outputOptions
|
||||
|
||||
inline Foam::vtk::outputOptions::outputOptions
|
||||
(
|
||||
enum formatType fmtType,
|
||||
enum vtk::formatType fmtType,
|
||||
unsigned prec
|
||||
)
|
||||
:
|
||||
@ -68,7 +66,7 @@ Foam::vtk::outputOptions::newFormatter(std::ostream& os) const
|
||||
|
||||
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||
|
||||
inline Foam::vtk::formatType Foam::vtk::outputOptions::fmt() const
|
||||
inline Foam::vtk::formatType Foam::vtk::outputOptions::fmt() const noexcept
|
||||
{
|
||||
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
|
||||
(
|
||||
@ -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();
|
||||
}
|
||||
|
||||
|
||||
inline bool Foam::vtk::outputOptions::append() const
|
||||
inline bool Foam::vtk::outputOptions::append() const noexcept
|
||||
{
|
||||
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();
|
||||
}
|
||||
|
||||
|
||||
inline bool Foam::vtk::outputOptions::ascii() const
|
||||
inline bool Foam::vtk::outputOptions::ascii() const noexcept
|
||||
{
|
||||
return !(unsigned(fmtType_) & 0x0F);
|
||||
}
|
||||
|
||||
|
||||
inline unsigned Foam::vtk::outputOptions::precision() const
|
||||
inline unsigned Foam::vtk::outputOptions::precision() const noexcept
|
||||
{
|
||||
return precision_;
|
||||
}
|
||||
|
||||
@ -67,6 +67,7 @@ void Foam::vtk::polyWriter::beginPiece
|
||||
{
|
||||
// Basic sizes
|
||||
nLocalPoints_ = points.size();
|
||||
nLocalVerts_ = 0;
|
||||
nLocalLines_ = edges.size();
|
||||
nLocalPolys_ = 0;
|
||||
|
||||
@ -104,6 +105,7 @@ void Foam::vtk::polyWriter::beginPiece
|
||||
{
|
||||
// Basic sizes
|
||||
nLocalPoints_ = points.size();
|
||||
nLocalVerts_ = 0;
|
||||
nLocalLines_ = 0;
|
||||
nLocalPolys_ = faces.size();
|
||||
|
||||
@ -568,6 +570,7 @@ Foam::vtk::polyWriter::polyWriter
|
||||
numberOfPoints_(0),
|
||||
numberOfCells_(0),
|
||||
nLocalPoints_(0),
|
||||
nLocalVerts_(0),
|
||||
nLocalLines_(0),
|
||||
nLocalPolys_(0)
|
||||
{
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2018-2021 OpenCFD Ltd.
|
||||
Copyright (C) 2018-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -82,6 +82,9 @@ protected:
|
||||
//- Local number of points
|
||||
label nLocalPoints_;
|
||||
|
||||
//- Local number of vertices (points)
|
||||
label nLocalVerts_;
|
||||
|
||||
//- Local number of lines (edges)
|
||||
label nLocalLines_;
|
||||
|
||||
|
||||
@ -143,6 +143,7 @@ $(setWriters)/gltf/gltfSetWriterRunTime.C
|
||||
$(setWriters)/gnuplot/gnuplotSetWriterRunTime.C
|
||||
$(setWriters)/nastran/nastranSetWriterRunTime.C
|
||||
$(setWriters)/raw/rawSetWriterRunTime.C
|
||||
$(setWriters)/vtk/foamVtkCoordSetWriter.C
|
||||
$(setWriters)/vtk/vtkSetWriterRunTime.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
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2016-2021 OpenCFD Ltd.
|
||||
Copyright (C) 2016-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -39,7 +39,7 @@ void Foam::vtk::patchMeshWriter::beginPiece()
|
||||
const polyBoundaryMesh& patches = mesh_.boundaryMesh();
|
||||
|
||||
nLocalPoints_ = nLocalPolys_ = 0;
|
||||
nLocalVerts_ = 0;
|
||||
nLocalPolyConn_ = 0;
|
||||
|
||||
for (const label patchId : patchIDs_)
|
||||
{
|
||||
@ -50,7 +50,7 @@ void Foam::vtk::patchMeshWriter::beginPiece()
|
||||
|
||||
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)
|
||||
|
||||
label nPolys = nLocalPolys_;
|
||||
label nVerts = nLocalVerts_;
|
||||
label nPolyConn = nLocalPolyConn_;
|
||||
|
||||
if (parallel_)
|
||||
{
|
||||
reduce(nPolys, sumOp<label>());
|
||||
reduce(nVerts, sumOp<label>());
|
||||
reduce(nPolyConn, sumOp<label>());
|
||||
}
|
||||
|
||||
if (nPolys != numberOfCells_)
|
||||
@ -166,9 +166,9 @@ void Foam::vtk::patchMeshWriter::writePolysLegacy(const label pointOffset)
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
legacy::beginPolys(os_, nPolys, nVerts);
|
||||
legacy::beginPolys(os_, nPolys, nPolyConn);
|
||||
|
||||
labelList vertLabels(nLocalPolys_ + nLocalVerts_);
|
||||
labelList vertLabels(nLocalPolys_ + nLocalPolyConn_);
|
||||
|
||||
{
|
||||
// Legacy: size + connectivity together
|
||||
@ -227,9 +227,9 @@ void Foam::vtk::patchMeshWriter::writePolys(const label pointOffset)
|
||||
// 'connectivity'
|
||||
//
|
||||
{
|
||||
labelList vertLabels(nLocalVerts_);
|
||||
labelList vertLabels(nLocalPolyConn_);
|
||||
|
||||
label nVerts = nLocalVerts_;
|
||||
label nVerts = nLocalPolyConn_;
|
||||
|
||||
if (parallel_)
|
||||
{
|
||||
@ -312,7 +312,7 @@ void Foam::vtk::patchMeshWriter::writePolys(const label pointOffset)
|
||||
// processor-local connectivity offsets
|
||||
label off =
|
||||
(
|
||||
parallel_ ? globalIndex(nLocalVerts_).localStart() : 0
|
||||
parallel_ ? globalIndex(nLocalPolyConn_).localStart() : 0
|
||||
);
|
||||
|
||||
|
||||
@ -369,7 +369,7 @@ Foam::vtk::patchMeshWriter::patchMeshWriter
|
||||
numberOfCells_(0),
|
||||
nLocalPoints_(0),
|
||||
nLocalPolys_(0),
|
||||
nLocalVerts_(0),
|
||||
nLocalPolyConn_(0),
|
||||
|
||||
mesh_(mesh),
|
||||
patchIDs_(patchIDs)
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2016-2021 OpenCFD Ltd.
|
||||
Copyright (C) 2016-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -85,8 +85,8 @@ protected:
|
||||
//- Local number of polys (faces)
|
||||
label nLocalPolys_;
|
||||
|
||||
//- Local face vertices (connectivity) count. Sum of face sizes.
|
||||
label nLocalVerts_;
|
||||
//- Local connectivity count for polys (faces) == sum of face sizes
|
||||
label nLocalPolyConn_;
|
||||
|
||||
//- Reference to the OpenFOAM mesh (or subset)
|
||||
const polyMesh& mesh_;
|
||||
|
||||
Reference in New Issue
Block a user