Documentation ¶
Index ¶
- Constants
- func Extent(x0, x1, y0, y1, z0, z1 int) func(p *partition) error
- type DSOption
- type Grid
- type Header
- func (h *Header) Add(ops ...Option) error
- func (h *Header) FileExtension() string
- func (h *Header) NewArray() *dataArray
- func (h *Header) NewFieldArray() *dataArray
- func (h *Header) Save(filename string) error
- func (h *Header) Write(w io.Writer) error
- func (h *Header) WriteClose(w io.WriteCloser) error
- type Option
- func Appended() Option
- func Ascii() Option
- func Binary() Option
- func CellData(name string, data interface{}) Option
- func Cells(conn, offset, labels []int) Option
- func Compressed() Option
- func CompressedLevel(level int) Option
- func Data(name string, data interface{}) Option
- func FieldData(name string, data interface{}) Option
- func Origin(x, y, z float64) Option
- func Piece(opts ...func(p *partition) error) Option
- func PointData(name string, data interface{}) Option
- func Points(xyz ...interface{}) Option
- func Raw() Option
- func SetLabelType(labelType map[int]int) Option
- func Spacing(dx, dy, dz float64) Option
- func WholeExtent(x0, x1, y0, y1, z0, z1 int) Option
- type PVD
- type PVDOption
Constants ¶
const ( NoCompression = zlib.NoCompression BestSpeed = zlib.BestSpeed BestCompression = zlib.BestCompression DefaultCompression = zlib.DefaultCompression HuffmanOnly = zlib.HuffmanOnly )
These constants are copied from the zlib package, which are in turn copied from the flat package, so that code that imports "vtu" does not also have to import "compress/zlib".
const ( Vertex = iota + 1 PolyVertex Line PolyLine Triangle TriangleStrip Polygon Pixel Quad Tetra Voxel Hexahedron Wedge Pyramid )
Linear cell types in VTK
Refer to Fig.2 https://vtk.org/wp-content/uploads/2015/04/file-formats.pdf for the local element numbering
const ( QuadraticEdge = iota + 21 QuadraticTriangle QuadraticQuad QuadraticTetra QuadraticHexahedron )
Non-linear cell types in VTK
Refer to Fig.3 https://vtk.org/wp-content/uploads/2015/04/file-formats.pdf for the local element numbering
Variables ¶
This section is empty.
Functions ¶
Types ¶
type DSOption ¶
type DSOption func(d *dataSet) error
Option for the dataSet.
func Filename ¶
File sets the filename for the current header. Note: the filename is joined with the base directory of the PVD file.
type Grid ¶
type Grid struct { XMLName xml.Name Extent bounds `xml:"WholeExtent,attr,omitempty"` Origin string `xml:"Origin,attr,omitempty"` Spacing string `xml:"Spacing,attr,omitempty"` Data *dataArray `xml:"FieldData,omitempty"` Pieces []partition }
data: image or unstructured
type Header ¶
type Header struct { XMLName xml.Name `xml:"VTKFile"` Type string `xml:"type,attr"` Version float64 `xml:"version,attr"` ByteOrder string `xml:"byte_order,attr"` HeaderType string `xml:"header_type,attr,omitempty"` Compression string `xml:"compressor,attr,omitempty"` Grid Grid Appended *darray // contains filtered or unexported fields }
header of the vtu Files
func Rectilinear ¶
Create file with rectilinear grid format
func Structured ¶
Create file with structured format
func Unstructured ¶
Create file with unstructured format
func (*Header) FileExtension ¶
func (*Header) NewFieldArray ¶
func (h *Header) NewFieldArray() *dataArray
func (*Header) Write ¶
Encodes the xml towards a io.Writer. Writes a xml header (i.e. xml.Header constant) to the buffer first for both ascii and base64 formats. The header is omitted for formatRaw as this is actually not compliant with the xml standard.
func (*Header) WriteClose ¶
func (h *Header) WriteClose(w io.WriteCloser) error
Encodes the towards the WriteCloser and closes the stream after encoding.
type Option ¶
header options
func Binary ¶
func Binary() Option
The binary VTU format is actually base64 encoded to not break xml
func Cells ¶
Cells sets the element connectivity of the cell in the unstructured grid. The cells are represented with three integer slices: - conn: points to coordinates (set by Points) - offsets: indicating starting point of each cell in conn - labels: element type labels for each cell (len(offsets)-1)
The user can provide a map[int]int to map the provided labels to the corresponding VTK element types. This map is set by SetLabelType().
func Compressed ¶
func Compressed() Option
Compressed assigns the compressor using the DefaultCompression level.
func CompressedLevel ¶
CompressedLevel assigns the compressor using a specific compression level. Constants are provided: NoCompression, BestSpeed, BestCompression, DefaultCompression, and HuffmanOnly.
func Data ¶
Data adds data to the file. When len(data) matched the number of points or cells, the data is written accordingly. For ambiguous cases, the function returns an error. The PointData and CellData calls should then be considered instead.
func SetLabelType ¶
SetLabelType sets the labelType map in the header. The labelType is used in unstructured grids to map the user's provided element labels towards the internal labeling.
func WholeExtent ¶
WholeExtent sets the extent of the Image, Rectilinear, or Structured grids. The extent requires a lower and upper value for each dimension, where a single dimension can be left empty, e.g. x1 - x0 == 0.
type PVD ¶
type PVD struct { XMLName xml.Name `xml:"VTKFile"` Type string `xml:"type,attr"` // Collection holds a data set, where each file is given by a dataSet. Collection []dataSet `xml:"Collection>DataSet"` // contains filtered or unexported fields }
PVD represent a ParaViewData (PVD) format. The PVD file contains a single Collection, which contains multiple data sets. Each data set has a reference to a VTK file that might live anywhere on disk. Additionally, the data set allows to attach a time step, a group, and a part identifier. Providing the time steps of these files will ensure proper visualisation in ParaView of transient data sets.
func (*PVD) Add ¶
Add adds a header to the PVD structure. The user can provide multiple DSOption functions to set additional details of the provided header.
type PVDOption ¶
Options for the PVD collection.
func AbsoluteFilenames ¶
func AbsoluteFilenames() PVDOption
AbsoluteFilenames ensures the full pathnames are written in the PVD header.
func RelativeFilenames ¶
func RelativeFilenames() PVDOption
RelativeFilenames ensures only relative pathnames are written in PVD header.
func SetFileFormat ¶
SetFileFormat sets the formatting string for the automatic file naming. This requires a single %d for the file number and a %s for the extension.