{"id":37225146,"url":"https://github.com/maxvdkolk/govtk","last_synced_at":"2026-01-15T01:45:45.109Z","repository":{"id":57520684,"uuid":"237961937","full_name":"MaxvdKolk/govtk","owner":"MaxvdKolk","description":"Write VTK XML files from Go. ","archived":false,"fork":false,"pushed_at":"2020-06-01T11:00:37.000Z","size":275,"stargazers_count":5,"open_issues_count":9,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-15T15:24:23.505Z","etag":null,"topics":["data-visualization","go","paraview","vtk"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MaxvdKolk.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-02-03T12:39:44.000Z","updated_at":"2024-10-11T14:58:52.000Z","dependencies_parsed_at":"2022-09-26T18:01:02.516Z","dependency_job_id":null,"html_url":"https://github.com/MaxvdKolk/govtk","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/MaxvdKolk/govtk","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MaxvdKolk%2Fgovtk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MaxvdKolk%2Fgovtk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MaxvdKolk%2Fgovtk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MaxvdKolk%2Fgovtk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MaxvdKolk","download_url":"https://codeload.github.com/MaxvdKolk/govtk/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MaxvdKolk%2Fgovtk/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28441031,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-15T00:55:22.719Z","status":"ssl_error","status_checked_at":"2026-01-15T00:55:20.945Z","response_time":107,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["data-visualization","go","paraview","vtk"],"created_at":"2026-01-15T01:45:44.169Z","updated_at":"2026-01-15T01:45:45.093Z","avatar_url":"https://github.com/MaxvdKolk.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# GoVTK\nA Go package to write data to VTK XML files. \n\n[![GoDoc](https://godoc.org/github.com/golang/gddo?status.svg)](https://godoc.org/github.com/maxvdkolk/govtk)\n![Go](https://github.com/MaxvdKolk/govtk/workflows/Go/badge.svg)\n\n*Note: not all feature are implemented yet. Basic VTK XML files and\nParaViewData (PVD) collections are availabe.*\n\nThe package supports a variety of VTK XML styles to be written, \ni.e. image data (.vti), rectilinear grids (.vtr), structured grids (.vts), and unstructured grids (*.vtu). \nEach format allows to write the XML using ascii, base64, or binary encoding. The \ndata can be compressed using ```zlib``` by means of the Go standard library ```compress/zlib```. \n\n## Usage\nFour different formats are supported by their constructor: \n- `Image()` for `.vti` files \n- `Rectilinear()` for `.vtr` files \n- `Structured()` for `.vts` files \n- `Unstructured()` for `.vtu` files\n\nThese support three types of encoding: `Ascii()`, \n`Base64()`, and `Raw()` (binary data). The latter two result \nin significantly smaller files. Note, `Base64()` does maintain\nvalid XML, while `Raw()` does not. \nAdditionally, `Base64()` and `Raw()` encoding allow \nto compress the data before encoding by passing `Compressed()`,\nto further reduces file size. \n\nData is added by `Add()`. Point/Cell data can be inserted as \n`Add(Data(\"fieldname\", data))`, which infers if the data should\nbe place on the points or cells. Alternatively, the `CellData`\nand `PointData` allow to directly write data to either \npoints or cells. Global, generic data fields can be \nadded by `FieldData`. \n\nThe file is written to disk by \neither `Save(filename string)` or `Write(w io.Writer)`. \nFor each file type a small example is presented. \n\n### Image data \n```go               \nvti, err := govtk.Image(govtk.WholeExtend(0, nx, 0, ny, 0, nz))\ndata := make([]float64, (nx+1)*(ny+1)*(nz+1))\nvti.Add(govtk.Data(\"fieldname\", data))\nvti.Save(\"image.vti\") \n```\n\n### Rectilinear \n```go\nvtr, err := govtk.Rectilinear(govtk.WholeExtend(0, nx, 0, ny, 0, nz)) \n\n// store x, y, z coordinates a 1D vectors \nx := make([]float64, nx+1)\ny := make([]float64, ny+1)\nz := make([]float64, nz+1)\n\n// fill x, y, z accordingly \n// ... \n\n// store coordinates\nvtr.Add(govtk.Points(x, y, z)) \nvtr.Add(govtk.Data(...)) \nvtr.Save(\"rectilinear.vtr\") \n```\n\n### Structured grid\n```go\nvts, err := govtk.Structured(govtk.WholeExtend(0, nx, 0, ny, 0, nz)) \n\n// store all x,y,z tuples for each node\nxyz := make([]float64, 3*(nx+1)*(ny+1)*(nz+1))\n\n// fill xyz with each coordinate \n// ... \n\nvts.Add(govtk.Points(xyz))\nvts.Add(govtk.Data(...))\nvts.Save(\"structured.vts\") \n```\n\n### Unstructured grid \n```go\nvtu, err := govtk.Unstructured() \n\n// store all x,y,z tuples for each node \nvtu.Add(Points(...))\n\n// provide cell connectivity, e.g. two tet elements \nconn := []int{0, 1, 2, 3, 0, 4, 5, 6}\noffset := []int{0, 4, 6} // start of each element in conn \nlabels := []int{20, 20} // VTK labels \n\nvtu.Add(govtk.Cells(conn, offset, labels))\n\n// store data and save \nvtu.Add(govtk.Data(...))\nvtk.Save(\"unstructured.vtu\" \n```\n\n## Paraview data file format (PVD)\nThe package also allows to write `PVD` collections. These \n[ParaviewData](https://www.paraview.org/Wiki/ParaView/Data_formats#PVD_File_Format) \nfiles allow to store references to multiple VTK XML files, \nwhich might be located anywhere on disk. Each file can save a\ntime step, part id, and group name as attribute. The time steps\nare directly available in ParaView, which is beneficial for data of\ntransient time series. \n\nFor example to store a time series: \n```go\n\npvd, err := govtk.NewPVD(govtk.Directory(\"./mypvd\")) \n\n// some time series \nfor t := 0; t \u003c 100; t++ {\n\n    // generate output data \n    vti, err := govtk.Image(govtk.WholeExtend(0, nx, 0, ny, 0, nz), govkt.Raw()) \n    vti.Add(govtk.Data(...))\n    \n    // attach to PVD collection\n    pvd.Add(vti, govtk.Time(float64(t))\n}\n\n// save PVD main file\npvd.Save(filepath.Join(pvd.Dir(), \"pvd.pvd\"))\n```\nProvides the following directory\n```\nmyvpd/\n    file_000.vti \n    file_001.vti\n    ...\n    file_099.vti\n    pvd.pvd\n```\n\n## Legacy format \n*Not yet supported* \n\n## Encoding and compression settings \nBasic encoding and compression is controlled by: \n```go \ngovtk.Ascii()     // plain ascii \ngovtk.Binary()    // base64 encoding \ngovtk.Raw()       // plain binary \n\n// compression only applies to `govtk.Binary()` and `govtk.Raw()`\ngovtk.Compressed()               // applies govtk.DefaultCompression\ngovtk.CompressedLevel(level int) // applies received compression level \n\n// compression levels are directly taken from `compress/zlib`\nconst ( \n    govtk.NoCompression      = zlib.NoCompression \n    govtk.BestSpeed          = zlib.BestSpeed\n    govtk.BestCompression    = zlib.BestCompression\n    govtk.DefaultCompression = zlib.DefaultCompression\n    govtk.HuffmanOnly        = zlib.HuffmanOnly\n) \n```\n\n## Command-line tools \n*to be implemented*\n\n## Installation\nInstall the package\n```\ngo get -u -v github.com/maxvdkolk/govtk/...\n```\n\n## References \n- https://vtk.org/Wiki/VTK_XML_Formats\n- https://vtk.org/wp-content/uploads/2015/04/file-formats.pdf\n- https://github.com/jipolanco/WriteVTK.jl\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaxvdkolk%2Fgovtk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmaxvdkolk%2Fgovtk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaxvdkolk%2Fgovtk/lists"}