JuliaVTK / WriteVTK.jl

Julia package for writing VTK XML files
Other
151 stars 32 forks source link

Gauss-Legendre points in a Lagrangian element #114

Closed b-fg closed 1 year ago

b-fg commented 1 year ago

My flux reconstruction high-order solver uses Lagrangian-basis elements which store the solution at the Gauss-Legendre quadrature points of the element. For example:

where the blue circles are the location of the solution points, and the red circles are the vertices defining the quad. Would the VTKCellTypes.VTK_LAGRANGE_QUADRILATERAL suit this arrangement? I have the connectivity of inner solution points per element and vertices of each element (which are only useful to define the quad, but do not store the solution data). I am unsure on how to define such cells and the connectivity that needs to be passed for to the cell creation (as in the documentation):

  MeshCell(VTKCellTypes.VTK_LAGRANGE_QUADRILATERAL, [
    1, 3, 12, 10, 2, 6, 9, 11, 4, 7, 5, 8
  ]),

Any tips on this would be appreciated. Thanks!

jipolanco commented 1 year ago

Hi, sorry for the late reply. I'm personally not very experienced with high-order Lagrange cells.

If it is of any help, this thread in the ParaView forums seems to be relevant. If I understand correctly, the VTK_LAGRANGE_QUADRILATERAL assumes equidistant nodes, so you would need to evaluate/interpolate your solution from your quadrature points onto a grid of equidistant points. I take the liberty of pinging @sloede (who started the linked thread) in case he has found a solution for this.

sloede commented 1 year ago

@jipolanco is correct: You need to provide equidistant nodes to VTK_LAGRANGE_QUADRILATERAL and VTK_LAGRANGE_HEXAHEDRON to make it work, and you need to interpolate your solution to these nodes. Please also note that you have to specify the points in a particular order, and the VTK documentation has errors on that part for 3D (or at least used to have, I haven't checked for a while now).

You can find the code we use to specify the (equidistant) points in our package Trixi2Vtk.jl, specifically for 2D here: https://github.com/trixi-framework/Trixi2Vtk.jl/blob/2170dee6f1b464853ee41f4898ac6786138582fa/src/vtktools.jl#L587-L602 and for 3D here: https://github.com/trixi-framework/Trixi2Vtk.jl/blob/2170dee6f1b464853ee41f4898ac6786138582fa/src/vtktools.jl#L621-L660

All credit for implementing goes to @efaulhaber, @bennibolm, and @NichtLucas.

b-fg commented 1 year ago

Okay, thanks both for the input. I will carefully look at Trixi's VTK package then. Closing this for the moment :)