Netgen Draw in Loops

More
1 week 3 days 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?

Please Log in or Create an account to join the conversation.

More
1 week 3 days 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

Please Log in or Create an account to join the conversation.

More
1 week 3 days ago - 1 week 3 days ago #4639 by NGUnsolved
Replied by NGUnsolved on topic Netgen Draw in Loops
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
Last edit: 1 week 3 days ago by NGUnsolved. Reason: clarification

Please Log in or Create an account to join the conversation.

Time to create page: 0.128 seconds