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

Updating GLVis mesh vector or scalar solution without drawing a new mesh #272

Open altineller opened 7 months ago

altineller commented 7 months ago

Hello,

I am about to make a plugin for glVis that listens on a different socket, and updates the mesh node positions.

My purpose is to get an animation of displacements.

I have read the code for the b button press, which is at vsvector3d.cpp and

` void VisualizationSceneVector3d::NPressed() { if (drawdisp) { PrepareDisplacedMesh(); } else { Prepare(); PrepareLines(); }

SendExposeEvent(); } `

I am intending to make a connector, that triggers a method like NPressed above, so I can edit displace mesh, or update solution.

But before I do this, has there been any work done in similar direction?

Any ideas / reccomendations / help greatly appreciated.

Best Regards, C.

tzanio commented 7 months ago

How is this different than what happens e.g. in ex10 by pushing updated fields to the same socket?

altineller commented 6 months ago

Hello,

In ex10.cpp, line 381: void visualize(ostream &os, Mesh mesh, GridFunction deformed_nodes, GridFunction field, const char field_name, bool init_vis) ..

GridFunction *nodes = deformed_nodes;
int owns_nodes = 0;
mesh->SwapNodes(nodes, owns_nodes);
os << "solution\n" << *mesh << *field;
mesh->SwapNodes(nodes, owns_nodes);

Where the nodes of the mesh are temporarily swapped, and sent to glVis trough socket. but mesh is being resent again.

I am interesting modifying mesh inside glVis programmatically, and also pass binary data, instead of ascii, to get at least 10hz update rate, for a mesh with around 65K nodes. So I would like to pass as little as possible data.

Is there any reason for the underlying visualized mesh in glVis memory to be unmodifiable?

Best Regards, Can

tzanio commented 6 months ago

Interesting 👍

Currently when the solution is updated the mesh is also sent as if it is done for the first time. See the logic in https://github.com/GLVis/glvis/blob/master/lib/threads.cpp#L760

This and https://github.com/GLVis/glvis/blob/master/lib/threads.cpp#L425 could probably be changed, e.g. by adding a new keyword, to just send the grid function and reuse the current mesh.

Tzanio

joetristano commented 6 months ago

Would love to have this feature!!!! Was just wondering about the same thing. Redundant data tranfer can be easily eliminated...