Netgen Draw in Loops

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?

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: fix netgen.gui.Snapshot · NGSolve/netgen@8f11802 · GitHub

Best,
Matthias

Hello,

adding “ngsolve.Redraw(blocking=True)” did not resolve the issue.
While it takes a snapshot in every iteration, they are all of the first image and the GUI still does not get redrawn while the Jupyter notebook cell is running.
The snapshot itself works fine outside of loops (I am using “ngsolve.internal.SnapShot()” )

Thank you,
NGUnsolved

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