Netgen Draw in Loops

More
1 year 11 months 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
1 year 11 months 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
1 year 10 months 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.135 seconds