Forum Message

 

 

We have moved the forum to https://forum.ngsolve.org . This is an archived version of the topics until 05/05/23. All the topics were moved to the new forum and conversations can be continued there. This forum is just kept as legacy to not invalidate old links. If you want to continue a conversation just look for the topic in the new forum.

Notice

The forum is in read only mode.

Netgen Draw in Loops

More
10 months 2 weeks ago #4635 by NGUnsolved
Hello,

i am working on an iterative algorithm that solves a PDE in every step and I am trying to save a snapshot in every step. This looks conceptually similar to

import netgen.gui
for i in range(N):
      solution = SolvePDE()
      Draw(solution,mesh,'solution')
      time.sleep(1)
      SnapShot()

The problem is, that the "Draw"-function does not change the GUI until the loop is over and therefore will only produce one image.
I tried this in and without Jupyter Notebooks but I can't find a workarount.
Can someone help me?
More
10 months 2 weeks ago #4637 by matthiash
Replied by matthiash on topic Netgen Draw in Loops
Hello,

The Draw command is handled by a parallel thread, that's why time.sleep(1) doesn't make any difference.
Put "ngsolve.Redraw(blocking=True)" between Draw() and SnapShot() to force a synchronization.
netgen.gui.SnapShot does this already, unfortunately this function is not working in the latest release. A fix is already on master: github.com/NGSolve/netgen/commit/8f11802...a00ccf7250e288ab09d9

Best,
Matthias
The following user(s) said Thank You: NGUnsolved
More
10 months 3 days ago #4646 by NGUnsolved
Replied by NGUnsolved on topic Netgen Draw in Loops
Hello.
For some reason it works now (with the altered SnapShot function) if I put the Redraw(blocking=True) after the SnapShot function.
Thank you for your help,
NGUnsolved

 
Time to create page: 0.114 seconds