Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7840741
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T15:54:00+00:00 2026-06-02T15:54:00+00:00

I need to export both simple geometry and a vector field to some VTK

  • 0

I need to export both simple geometry and a vector field to some VTK files. I have managed to export the geometry, but am struggeling to figure out how to export the vector field. What is the structure/format of the file I need?

This is what I have so far (by the way, the vectors need to be arbitrarily placed, meaning that strucured grid and so on won’t work):

<?xml version="1.0"?>

<VTKFile type="PolyData" version="0.1" byte_order="LittleEndian">
  <PolyData>
    <Piece NumberOfPoints="8" NumberOfVerts="0" NumberOfLines="0" NumberOfStrips="0" NumberOfPolys="5">
      <Points>
        <DataArray type="Float32" NumberOfComponents="3" format="ascii">
        //point data//
        </DataArray>
      </Points>

      <Polys>
        <DataArray type="Int32" Name="connectivity" format="ascii">
        //connectivity data//
        </DataArray>

        <DataArray type="Int32" Name="offsets" format="ascii">
        //offsett data//
        </DataArray>
      </Polys>

    </Piece>
      //Need to put vector field with it's own points here//
  </PolyData>
</VTKFile>

Update: After suggestions from Chris (see answer below) I have updated the file to this form:

<?xml version="1.0"?>

<VTKFile type="UnstructuredGrid" version="0.1" byte_order="LittleEndian">
  <UnstructuredGrid>
    <Piece NumberOfPoints="50" NumberOfCells="0">
      <PointData Vectors="Velocity">
        <DataArray Vectors="Velocity">
          //vector data//
        </DataArray>
      </PointData>
      <Points>
        <DataArray type="Float32" NumberOfComponents="3" format="ascii">
          //point data//
        </DataArray>
      </Points>
      <Cells/>
     <CellData/>
   </Piece>
 </UnstructuredGrid>
</VTKFile>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T15:54:04+00:00Added an answer on June 2, 2026 at 3:54 pm

    From you example XML file it seems that the vector field is defined at different coordinates from the nodes of your PolyData. If this is the case then you will need to use two different files. From the VTK File Format specification, which is part of the VTK User’s Guide (see http://www.vtk.org/VTK/img/file-formats.pdf):

    By convention, each data type and file type is paired with a particular file extension.

    Your vector field sounds like UnstructuredGrid data, where you have to specify the coordinates of the grid nodes explicitly (unlike, say ImageGrids, where the node coordinates are defined implicitly by the spacing and the extent of the data). This obviously cannot go in a PolyData VTK file (see the second line of your example XML file).

    So try writing a new file for your vector data with the outline (taken from the file formats document):

    <VTKFile type="UnstructuredGrid" ...>
      <UnstructuredGrid>
        <Piece NumberOfPoints="#" NumberOfCells="0">
          <Points>
              <DataArray type="Float32" NumberOfComponents="3" format="ascii">
              //point data//
              </DataArray>
          </Points>
          <Cells>
              <DataArray type="Int32" Name="connectivity" .../>
              <DataArray type="Int32" Name="offsets" .../>
              <DataArray type="UInt8" Name="types" .../>
          </Cells>
          <PointData>
              <DataArray Vectors="MyVector">
                //Vector data goes here//
              </DataArray>
          </PointData>
          <CellData/>
        </Piece>
      </UnstructuredGrid>
    </VTKFile>
    

    Update: As discussed in the comments, the Cells element must be specified (the CellData element can be left empty, as only point data is being speicifed). The Cells element specifies the cell types, connectivity and offsets. For a series of unconnected points (i.e. particles) this information is specified as arrays of length n, where n is the number of data points and where

    type = 1, 1, .... 1
    connectivity = 0, 1, 2, ... n
    offsets = 1, 2, 3, ... n
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an some code to export data form an SQL database to an
I have multiple WCF services that share some data contracts and need to generate
I need coding a feature (using .NET): Export a table(in web) to excel. But
I'm working in R, but I need to deliver some data in SPSS format
I have been using this code, but have been running into some memory issues:
I need to export an SQLite database from an Android phone to a computer.
I need to export my gridview data to excel. No problems for this. All
I need to export a gridview to excel, I put the return html code
I need to export a matrix of regression results from Stata to MATLAB. I
being in need to export a DOC file to TXT and then reimport it

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.