GLVis / glvis

Lightweight OpenGL tool for accurate and flexible finite element visualization
http://glvis.org
BSD 3-Clause "New" or "Revised" License
249 stars 51 forks source link

ND_R2D visualization with glvis fails #291

Open Rickbude opened 1 month ago

Rickbude commented 1 month ago

This is a companion issue to the identically-named issue in MFEM: https://github.com/mfem/mfem/issues/4403

Loading a solution that is expressed in terms of ND_R1D, ND_R2D, RT_R1D and RT_R2D elements gives an error that looks like:

Verification failed: (dim >= 1 && dim <= 3) is false:
 --> ND_FECollection requires 1 <= dim <= 3.
 ... in function: mfem::ND_FECollection::ND_FECollection(int, int, int, int)
 ... in file: /home/rick/tmp/mfem/fem/fe_coll.cpp:2708

Aborted (core dumped)

This error is caused by missing code in MFEM (see the linked issue for more information). Adding the missing code resolves things on the MFEM side, but now glvis throws a segmentation fault. This is the trace obtained with gdb:

#0  0x00007ffff5e195aa in _XEventsQueued () from /lib64/libX11.so.6
#1  0x00007ffff5df5e87 in XCheckIfEvent () from /lib64/libX11.so.6
#2  0x00007ffff6a0c3a5 in ?? () from /lib64/libSDL2-2.0.so.0
#3  0x00007ffff6951442 in ?? () from /lib64/libSDL2-2.0.so.0
#4  0x00007ffff6951867 in ?? () from /lib64/libSDL2-2.0.so.0
#5  0x000000000044a9ca in SdlMainThread::DispatchSDLEvents (this=this@entry=0x933e00 <GetMainThread()::inst>) at /home/rick/tmp/glvis/lib/sdl_main.cpp:191
#6  0x000000000044aea3 in SdlMainThread::MainLoop (this=0x933e00 <GetMainThread()::inst>, server=<optimized out>) at /home/rick/tmp/glvis/lib/sdl_main.cpp:140
#7  0x0000000000442ab4 in SdlWindow::StartSDL (server_mode=<optimized out>) at /home/rick/tmp/glvis/lib/sdl.cpp:85
#8  0x000000000042fb99 in SDLMainLoop (server_mode=<optimized out>) at /home/rick/tmp/glvis/lib/aux_vis.cpp:55
#9  0x000000000041f3d2 in main (argc=<optimized out>, argv=<optimized out>) at /home/rick/tmp/glvis/glvis.cpp:1400
Rickbude commented 1 month ago

I noticed that loading an H1^3 space also causes glvis to crash. To be clear, the header of the solution file contains:

FiniteElementSpace
FiniteElementCollection: H1_2D_P2
VDim: 3
Ordering: 0

The errors are different from the ones reported above (no segfault), so this might be different / unrelated issue. But I thought I'd report anyway. I get various errors, like:

Using GLSL 450
VisualizationSceneVector::VisualizationSceneVector
XIO:  fatal IO error 11 (Resource temporarily unavailable) on X server "p$"
      after 301 requests (301 known processed) with 0 events remaining.

and

VisualizationSceneVector::VisualizationSceneVector
X Error of failed request:  BadCursor (invalid Cursor parameter)
  Major opcode of failed request:  2 (X_ChangeWindowAttributes)
  Resource id in failed request:  0x12dafa50
  Serial number of failed request:  310
  Current serial number in output stream:  317
tzanio commented 1 month ago

Can you post the mesh and the grid function you are trying to load?

Rickbude commented 1 month ago

Of course. Please find attached 1 mesh and 3 grid functions for that mesh. (1x ND_R2D and 2x H1^3)

issue_files.zip

tzanio commented 1 month ago

Oh, currently you can't visualize 3D vector field on a 2D mesh.

One way to do that will be to make the 2D mesh into a surface mesh embedded in 3D -- see this version.

That worked for me with the first two examples.

Rickbude commented 1 month ago

Ahh!! And with the changes in MFEM suggested in https://github.com/mfem/mfem/issues/4403, the ND_R2D vector field also loads on this surface mesh.

What would be the "proper" way of generating such a surface mesh from an existing 2D mesh? I found the following to work, but I am not sure if this is the right way to go:

mfem::Mesh surf_mesh(m_mesh);
surf_mesh.SetCurvature(m_element_order,false,3);
surf_mesh.Save("surf-mesh.mesh");

Sorry for not catching this earlier; the error messages generated by glvis did not really indicate that the mesh being 2D was the problem.

By the way: I noted that the visualization of the results on this surface mesh seems a bit restricted compared to equivalent visualizations of 2D vector fields on 2D meshes:

Is this by design?

tzanio commented 1 month ago

Yep, SetCurvature is the right way to make a 2D into a surface mesh. If you have existing 2D mesh files, you can also manually change the VDim of the nodes to 3 and add a zero at the end of each node coordinate (for the z component).

tzanio commented 1 month ago

By the way: I noted that the visualization of the results on this surface mesh seems a bit restricted compared to equivalent visualizations of 2D vector fields on 2D meshes:

  • Pressing 'v' multiple times does not rescale the vector quivers (they just disappear)
  • F' cycles only through the magnitude and x/y/z components, not the divergence and curl.

Is this by design?

Good question, @v-dobrev or @najlkin -- do you know?