itkwidgets icon indicating copy to clipboard operation
itkwidgets copied to clipboard

Support for high-order Lagrange elements

Open mgenet opened this issue 5 years ago • 4 comments

Hello,

Hope it is the right place to ask. I am trying to visualize ugrids with high-order elements, e.g.,

order = 2
n_points = (order + 1) * (order + 2) // 2
cell = vtk.vtkLagrangeTriangle()
cell.GetPointIds().SetNumberOfIds(n_points)
cell.GetPoints().SetNumberOfPoints(n_points)
cell.Initialize()
point = [0., 0., 0.]
barycentric_index = [0, 0, 0]
for k_point in range(n_points):
    cell.GetPointIds().SetId(k_point, k_point)
    cell.ToBarycentricIndex(k_point, barycentric_index)
    for k_dim in range(2):
      point[k_dim] = (barycentric_index[k_dim] / order)**2
    cell.GetPoints().SetPoint(k_point, point[0], point[1], point[2])
cell_array = vtk.vtkCellArray()
cell_array.InsertNextCell(cell)
ugrid = vtk.vtkUnstructuredGrid()
ugrid.SetPoints(cell.GetPoints())
ugrid.SetCells(cell.GetCellType(), cell_array)
itkwidgets.view(geometries=[ugrid])

(inspired from https://blog.kitware.com/modeling-arbitrary-order-lagrange-finite-elements-in-the-visualization-toolkit), to no avail. Is there any support for high-order elements? If not, is it planned? Thanks!

Martin

mgenet avatar May 13 '20 08:05 mgenet

Hello Martin,

This depends on vtk Python package support for these features, which @tjcorona is working on.

Be well, Matt

thewtex avatar May 13 '20 21:05 thewtex

Awesome. Thanks!

mgenet avatar May 14 '20 09:05 mgenet

This seems to be supported by other packages using VTK, such as pyvista, (ref minimal example in https://github.com/pyvista/pyvista/issues/947). Is there anything in particular missing in itkwidgets for this?

jorgensd avatar Jan 24 '21 09:01 jorgensd

Any update on this? Thanks a lot!

mgenet avatar Nov 16 '21 08:11 mgenet