我需要将简单几何和矢量场都导出到一些 VTK 文件中。我已经设法导出几何图形,但正在努力弄清楚如何导出矢量场。我需要的文件的结构/格式是什么?
这是我到目前为止所拥有的(顺便说一下,向量需要任意放置,这意味着结构化网格等不起作用):
<?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>
更新:根据 Chris 的建议(请参阅下面的答案),我已将文件更新为此表单:
<?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>