Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hexahedron20. Incorrect convertation into vtu file #1431

Open
Mike637 opened this issue Aug 9, 2023 · 1 comment
Open

hexahedron20. Incorrect convertation into vtu file #1431

Mike637 opened this issue Aug 9, 2023 · 1 comment

Comments

@Mike637
Copy link

Mike637 commented Aug 9, 2023

Code:
`
import sys, numpy, os
BASE_DIR = os.getcwd()
import meshio
hex20_mesh = meshio.Mesh(
[
[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],

    [0.5, 0.0, 0.0],
    [1.0, 0.5, 0.0],
    [0.5, 1.0, 0.0],
    [0.0, 0.5, 0.0],
    
    [0.0, 0.0, 0.5],
    [1.0, 0.0, 0.5],
    [1.0, 1.0, 0.5],
    [0.0, 1.0, 0.5],
    
    [0.5, 0.0, 1.0],
    [1.0, 0.5, 1.0],
    [0.5, 1.0, 1.0],
    [0.0, 0.5, 1.0],
],
[("hexahedron20", [numpy.arange(20)])],

)
hex20_mesh.write(
os.path.join(BASE_DIR ,"result123.vtu"),
)
`
After covertation I opened vtu file in paraview and saw wrong view of hexahedron.
image

@kaiserls
Copy link

kaiserls commented Feb 26, 2024

The definition of the hexahedron20 requires a specific order of nodes or adapted node connectivity.
https://vtk.org/doc/nightly/html/classvtkQuadraticHexahedron.html#details

It should be:

import meshio
import numpy
import os

BASE_DIR = os.getcwd()

hex20_corrected = meshio.Mesh(
    [
        [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],
        [0.5, 0.0, 0.0],
        [1.0, 0.5, 0.0],
        [0.5, 1.0, 0.0],#10
        [0.0, 0.5, 0.0],
        [0.5, 0.0, 1.0],# first wrong node
        [1.0, 0.5, 1.0],
        [0.5, 1.0, 1.0],
        [0.0, 0.5, 1.0],
        [0.0, 0.0, 0.5],
        [1.0, 0.0, 0.5],
        [1.0, 1.0, 0.5],
        [0.0, 1.0, 0.5],
    ],
    [("hexahedron20", [numpy.arange(20)])],
)

hex20_corrected.write(
    os.path.join(BASE_DIR, "result_corrected.vtu"),
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants