Forum Message



We have moved the forum to . 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.


The forum is in read only mode.

Netgen Draw in Loops

10 months 2 weeks ago #4635 by NGUnsolved

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()

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?
10 months 2 weeks ago #4637 by matthiash
Replied by matthiash on topic Netgen Draw in Loops

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:

The following user(s) said Thank You: NGUnsolved
10 months 3 days ago #4646 by NGUnsolved
Replied by NGUnsolved on topic Netgen Draw in Loops
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,

Time to create page: 0.114 seconds