Skip to content

Commit

Permalink
[example] Remove gui warning message (taichi-dev#7090)
Browse files Browse the repository at this point in the history
This PR removes the warning message of th example `snow_phaseField`
caused by closing the GUI.
  • Loading branch information
neozhaoliang authored and lin-hitonami committed Jan 12, 2023
1 parent 37f9ca7 commit 657b15a
Showing 1 changed file with 7 additions and 19 deletions.
26 changes: 7 additions & 19 deletions python/taichi/examples/simulation/snow_phaseField.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
space discretization: finite difference method, time integration: Runge-Kutta method
repo's link: https://github.com/mo-hanxuan/Snow-PhaseField
more details about physical interpretation refer to [Physica D 63(3-4): 410-423]"""
import os

import numpy as np

import taichi as ti
Expand Down Expand Up @@ -57,7 +55,6 @@ def __init__(
np.array([1. / 6., 1. / 3., 1. / 3., 1. / 6.]))

self.showFrameFrequency = int(4 * 1.e-4 / self.dt)
self.writeImages = False # setting to True will write images to results folder

@ti.kernel
def initialize(self, ):
Expand Down Expand Up @@ -195,22 +192,13 @@ def advance(self, ): # advance a time step

def getDendritic(self, steps=2048):
self.initialize()
gui_phi = ti.GUI("phase field", res=(self.n, self.n))

if self.writeImages:
path = "./results/"
if not os.path.exists(path):
os.makedirs(path)

for i in range(steps):
if i % self.showFrameFrequency == 0:
gui_phi.set_image(self.phi)
gui_phi.show(path + f"time_{i * self.dt :.4f}s.png" if i %
(self.showFrameFrequency *
8) == 0 and self.writeImages else None)
self.advance()

gui_phi.running = False
gui = ti.GUI("phase field", res=(self.n, self.n))
while not gui.get_event(ti.GUI.ESCAPE, ti.GUI.EXIT):
for _ in range(self.showFrameFrequency):
self.advance()

gui.set_image(self.phi)
gui.show()
return self.phi


Expand Down

0 comments on commit 657b15a

Please sign in to comment.