`VTK HEXAHEDRON`类的语法

huangapple go评论66阅读模式
英文:

Syntax for VTK HEXAHEDRON class

问题

I am trying to display the scalar field associated with 20 unconnected cubes on Paraview. For this, I am trying to use the HEXAHEDRON vtk class. The file I created reads as follows:

Test
ASCII
DATASET POLYDATA
POINTS 160 FLOAT
19.098110 12.993696 27.966301
23.098110 12.993696 27.966301
23.098110 16.993696 27.966301
...
HEXAHEDRA 120 600
4 0 1 5 4
4 1 2 6 5
4 2 3 7 6
4 3 0 4 7
4 0 1 2 3
4 4 5 6 7
4 8 9 13 12
4 9 10 14 13
4 10 11 15 14
4 11 8 12 15
4 8 9 10 11
4 12 13 14 15
...

However, Paraview gives an "Unrecognized keyword: 3" error. I have tried changing the keyword to POLYGONS, and Paraview was happy (although I wasn't, as all the cubes got joined up).

What is the right keyword for the VTK_HEXAHEDRON class? I have tried HEXAHEDRA, HEXAHEDRON, and HEXAHEDRONS with no success...

Thank you,
Marta

英文:

I am trying to display the scalar field associated with 20 unconnected cubes on Paraview. For this, I am trying to use the HEXAHEDRON vtk class. The file I created reads as follows:

Test
ASCII
DATASET POLYDATA
POINTS 160 FLOAT
19.098110 12.993696 27.966301
23.098110 12.993696 27.966301
23.098110 16.993696 27.966301
...
HEXAHEDRA 120 600
4 0 1 5 4
4 1 2 6 5
4 2 3 7 6
4 3 0 4 7
4 0 1 2 3
4 4 5 6 7
4 8 9 13 12
4 9 10 14 13
4 10 11 15 14
4 11 8 12 15
4 8 9 10 11
4 12 13 14 15
...

However, Paraview gives an "Unrecognized keyword: 3" error. I have tried changing the keyword to POLYGONS and Paraview was happy (although I wasn't, as all the cubes got joined up).

What is the right keyword for the VTK_HEXAHEDRON class? I have tried HEXAHEDRA, HEXAHEDRON and HEXAHEDRONS with no success...

Thank you,
Marta

答案1

得分: 3

你应该使用关键词 VTK_HEXAHEDRON
有关更多信息,请参阅VTK用户指南中的19.3 VTK文件格式部分。

英文:

You should use the keyword VTK_HEXAHEDRON.
For more information, see the section 19.3 VTK File Formats in VTK User’s Guide.

答案2

得分: -1

You could use Python to create the mesh and then use meshio (one of my projects) to write it in any format you like, e.g., VTK.

import meshio
import numpy

hex_mesh = meshio.Mesh(
    numpy.array(
        [
            [0.0, 0.0, 0.0],
            [1.0, 0.0, 0.0],
            [1.0, 1.0, 0.0],
            [0.0, 1.0, 0.0],
            [0.0, 0.0, 1.0],
            [1.0, 0.0, 1.0],
            [1.0, 1.0, 1.0],
            [0.0, 1.0, 1.0],
        ]
    ),
    {"hexahedron": numpy.array([[0, 1, 2, 3, 4, 5, 6, 7]])},
)

meshio.write("out.vtk", hex_mesh)
written by meshio v3.3.1
ASCII
DATASET UNSTRUCTURED_GRID
POINTS 8 double
0.0 0.0 0.0 1.0 0.0 0.0 1.0 1.0 0.0 0.0 1.0 0.0 0.0 0.0 1.0 1.0 0.0 1.0 1.0 1.0 1.0 0.0 1.0 1.0
CELLS 1 9
8
0
1
2
3
4
5
6
7
CELL_TYPES 1
12
英文:

You could use Python to create the mesh and then meshio (one of my projects) to write it any format you like, e.g., VTK.

import meshio
import numpy

hex_mesh = meshio.Mesh(
    numpy.array(
        [
            [0.0, 0.0, 0.0],
            [1.0, 0.0, 0.0],
            [1.0, 1.0, 0.0],
            [0.0, 1.0, 0.0],
            [0.0, 0.0, 1.0],
            [1.0, 0.0, 1.0],
            [1.0, 1.0, 1.0],
            [0.0, 1.0, 1.0],
        ]
    ),
    {"hexahedron": numpy.array([[0, 1, 2, 3, 4, 5, 6, 7]])},
)

meshio.write("out.vtk", hex_mesh)
# vtk DataFile Version 4.2
written by meshio v3.3.1
ASCII
DATASET UNSTRUCTURED_GRID
POINTS 8 double
0.0 0.0 0.0 1.0 0.0 0.0 1.0 1.0 0.0 0.0 1.0 0.0 0.0 0.0 1.0 1.0 0.0 1.0 1.0 1.0 1.0 0.0 1.0 1.0
CELLS 1 9
8
0
1
2
3
4
5
6
7
CELL_TYPES 1
12

huangapple
  • 本文由 发表于 2020年1月7日 00:34:44
  • 转载请务必保留本文链接:https://go.coder-hub.com/59615731.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定