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

Error: type Polys has no field vtk_id #155

Closed
Blumenkranz opened this issue Nov 5, 2024 · 2 comments · May be fixed by #156
Closed

Error: type Polys has no field vtk_id #155

Blumenkranz opened this issue Nov 5, 2024 · 2 comments · May be fixed by #156

Comments

@Blumenkranz
Copy link

Hi, I got an Error when I try to generate polygonal cells. Here's the MWE

using WriteVTK

vertices = [0.0 0.0;2.0 0.0;0.0 2.0;2.0 2.0;0.0 1.0;2.0 1.0;1.0 0.0;1.0 2.0;1.0 1.0;0.0 0.5;1.0 0.5;0.5 0.0;0.5 1.0;0.5 0.5]'
cells = Vector{MeshCell}(undef,7)
cells[1] = MeshCell(PolyData.Polys(),[1,12,10,14])
cells[2] = MeshCell(PolyData.Polys(),[12,7,14,11])
cells[3] = MeshCell(PolyData.Polys(),[10,14,5,13])
cells[4] = MeshCell(PolyData.Polys(),[14,11,13,9])
cells[5] = MeshCell(PolyData.Polys(),[7,2,9,6,11])
cells[6] = MeshCell(PolyData.Polys(),[5,9,3,8,13])
cells[7] = MeshCell(PolyData.Polys(),[9,6,8,4])
vtk_grid("test_polygon",vertices,cells;append=false) do vtk
    vtk["test",VTKCellData()] = collect(1:7)
end
@jipolanco
Copy link
Member

Hi, this is because Vector{MeshCell} is not a concrete type, and WriteVTK dispatches to the wrong function since it cannot guess the exact type of cell.

I'll push a workaround to this issue which will allow to pass a non-concrete container type.

In the meantime, to initialise a vector with the right cell type, you could do something like:

cells = resize!([MeshCell(PolyData.Polys(),[1,12,10,14])], 7)

@Blumenkranz
Copy link
Author

Thanks for your reply! It helps a lot. And it will be great if non-concrete pass becomes available.

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

Successfully merging a pull request may close this issue.

2 participants