question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

VTK Lagrange elements in 3D elements is not rendered correctly

See original GitHub issue

MWE using dolfinx:

from mpi4py import MPI
import vedo
import numpy as np
import dolfinx
import dolfinx.io

mesh = dolfinx.UnitCubeMesh(MPI.COMM_WORLD, 1, 1, 1, dolfinx.cpp.mesh.CellType.hexahedron)
geo = mesh.geometry.x
num_cells = mesh.topology.index_map(mesh.topology.dim).size_local
topo = dolfinx.cpp.mesh.entities_to_geometry(mesh, mesh.topology.dim, np.arange(num_cells, dtype=np.int32), False)
perm_vtk = dolfinx.cpp.io.perm_vtk(mesh.topology.cell_type, topo.shape[1])
dolfin_to_vtk = np.zeros(topo.shape[1], dtype=np.int32)
for i in range(topo.shape[1]):
    dolfin_to_vtk[perm_vtk[i]] = i

dolfinx.io.VTKFile("mesh.pvd").write(mesh)
topo = topo[:, dolfin_to_vtk]
mesh_vedo = vedo.Mesh([geo, topo])
p = vedo.Plotter(shape=(1, 1), N=1, pos=(0, 0))
p.add(mesh_vedo)
p.show()
p.screenshot("mesh.png")
print(topo,"\n", geo)

yields:

[[1 4 6 2 0 5 7 3]]
 [[1. 0. 0.]
 [0. 0. 0.]
 [0. 1. 0.]
 [1. 1. 0.]
 [0. 0. 1.]
 [1. 0. 1.]
 [0. 1. 1.]
 [1. 1. 1.]]

and mesh while the correponding VTU file contains;

<?xml version="1.0"?>
<VTKFile type="UnstructuredGrid"  version="0.1" >
<UnstructuredGrid>
<Piece  NumberOfPoints="8" NumberOfCells="1">
<Points>
<DataArray  type="Float64"  NumberOfComponents="3"  format="ascii">1 0 0  0 0 0  0 1 0  1 1 0  0 0 1  1 0 1  0 1 1  1 1 1  </DataArray>
</Points>
<Cells>
<DataArray  type="Int32"  Name="connectivity"  format="ascii">1 4 6 2 0 5 7 3  </DataArray>
<DataArray  type="Int32"  Name="offsets"  format="ascii">8 </DataArray>
<DataArray  type="Int8"  Name="types"  format="ascii">72 </DataArray>
</Cells>
</Piece>
</UnstructuredGrid>
</VTKFile>

Which is the same as the vedo mesh has, but yields hex_pvd

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:30 (14 by maintainers)

github_iconTop GitHub Comments

2reactions
jorgensdcommented, Jan 26, 2021

I forgot to add the PETSC_ARCH, i.e.

export  PETSC_ARCH="linux-gnu-real-32"
pip3  install vedo
# Install python components
pip3 install git+https://github.com/FEniCS/basix.git --upgrade && \
	pip3 install git+https://github.com/FEniCS/ufl.git --upgrade && \
	pip3 install git+https://github.com/FEniCS/ffcx.git --upgrade && \
	rm -rf /usr/local/include/dolfin /usr/local/include/dolfin.h

# Build C++ layer
git clone https://github.com/FEniCS/dolfinx.git && \
	 cd dolfinx/ && \
        git checkout  dokken/pyvista-demo && \
	 mkdir -p build && \
	 cd build && \
	 cmake -G Ninja -DCMAKE_BUILD_TYPE=Relase ../cpp/ && \
	 ninja -j3 install
source /usr/local/share/dolfinx/dolfinx.conf

cd ../python && \
pip3 -v install .
1reaction
jorgensdcommented, Jan 30, 2021

oh i haven’t thought about it! Not sure about quads, but for 3d it might be possible…

Let me know how you get along with things:) i’ve spent the day updating my dolfin-x tutorial after we removed matplotlib. When vedo is ready, Im ready to add it to some of the examples, such as: https://jorgensd.github.io/dolfinx-tutorial/chapter3/em.html or https://jorgensd.github.io/dolfinx-tutorial/chapter2/ns_code1.html Could also add a meshing demo with vedo if you have a good idea for an example application.

Read more comments on GitHub >

github_iconTop Results From Across the Web

VTK Lagrange elements in 3D elements is not rendered ...
There are basically two separate issues with the original question. The vedo.Mesh class is meant to only manage polygonal surface meshes so the ......
Read more >
Modeling Arbitrary-order Lagrange Finite Elements in the ...
I was able to create a vtk using LagrangeQuadrilaterals for 2D and LagrangeHexahedron for 3D. However, it looks like the interpolation is not...
Read more >
vtkCell Class Reference - VTK
vtkCell is an abstract class that specifies the interfaces for data cells. Data cells are simple topological elements like points, lines, polygons, and ......
Read more >
Implementation of rational Bézier cells into VTK | Coreform
While Lagrange elements were already implemented into VTK, we added the possibility for some cell types to have anisotropic degree, meaning ...
Read more >
Implementation — FEniCSx tutorial - GitHub Pages
The type of element here is “CG”, which implies the standard Lagrange family ... In FEniCSx, we do not specify boundary conditions as...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found