Skip to content

Commit 254bc70

Browse files
author
Michael Zingale
committed
use the new simulation class
1 parent 83ec141 commit 254bc70

1 file changed

Lines changed: 21 additions & 24 deletions

File tree

pyro.py

Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -150,19 +150,15 @@
150150
#-----------------------------------------------------------------------------
151151

152152
# initialize the grid structure -- we will store the rp in the data object
153-
my_grid, my_data = solver.initialize(rp)
154-
155-
156-
# initialize the data
157-
exec 'from ' + solverName + '.problems import *'
153+
sim = solver.Simulation(problemName, rp)
158154

159-
exec problemName + '.initData(my_data)'
155+
sim.initialize()
160156

161157

162158
#-----------------------------------------------------------------------------
163159
# pre-evolve
164160
#-----------------------------------------------------------------------------
165-
solver.preevolve(my_data)
161+
sim.preevolve()
166162

167163

168164
#-----------------------------------------------------------------------------
@@ -178,30 +174,30 @@
178174
pylab.ion()
179175

180176
n = 0
181-
my_data.t = 0.0
177+
sim.cc_data.t = 0.0
182178

183179
# output the 0th data
184180
basename = rp.get_param("io.basename")
185-
my_data.write(basename + "%4.4d" % (n))
181+
sim.cc_data.write(basename + "%4.4d" % (n))
186182

187183
dovis = rp.get_param("vis.dovis")
188184
if dovis:
189185
pylab.figure(num=1, figsize=(8,6), dpi=100, facecolor='w')
190-
solver.dovis(my_data, 0)
186+
sim.dovis(0)
191187

192188

193189
nout = 0
194190

195-
while my_data.t < tmax and n < max_steps:
191+
while sim.cc_data.t < tmax and n < max_steps:
196192

197193
# fill boundary conditions
198194
pfb = profile.timer("fill_bc")
199195
pfb.begin()
200-
my_data.fill_BC_all()
196+
sim.cc_data.fill_BC_all()
201197
pfb.end()
202198

203199
# get the timestep
204-
dt = solver.timestep(my_data)
200+
dt = sim.timestep()
205201
if fix_dt > 0.0:
206202
dt = fix_dt
207203
else:
@@ -212,31 +208,31 @@
212208
dt = min(max_dt_change*dt_old, dt)
213209
dt_old = dt
214210

215-
if my_data.t + dt > tmax:
216-
dt = tmax - my_data.t
211+
if sim.cc_data.t + dt > tmax:
212+
dt = tmax - sim.cc_data.t
217213

218214
# evolve for a single timestep
219-
solver.evolve(my_data, dt)
215+
sim.evolve(dt)
220216

221217

222218
# increment the time
223-
my_data.t += dt
219+
sim.cc_data.t += dt
224220
n += 1
225-
print "%5d %10.5f %10.5f" % (n, my_data.t, dt)
221+
print "%5d %10.5f %10.5f" % (n, sim.cc_data.t, dt)
226222

227223

228224
# output
229225
dt_out = rp.get_param("io.dt_out")
230226
n_out = rp.get_param("io.n_out")
231227

232-
if my_data.t >= (nout + 1)*dt_out or n%n_out == 0:
228+
if sim.cc_data.t >= (nout + 1)*dt_out or n%n_out == 0:
233229

234230
pfc = profile.timer("output")
235231
pfc.begin()
236232

237233
msg.warning("outputting...")
238234
basename = rp.get_param("io.basename")
239-
my_data.write(basename + "%4.4d" % (n))
235+
sim.cc_data.write(basename + "%4.4d" % (n))
240236
nout += 1
241237

242238
pfc.end()
@@ -247,7 +243,7 @@
247243
pfd = profile.timer("vis")
248244
pfd.begin()
249245

250-
solver.dovis(my_data, n)
246+
sim.dovis(n)
251247
store = rp.get_param("vis.store_images")
252248

253249
if store == 1:
@@ -268,7 +264,7 @@
268264
msg.warning("comparing to: %s " % (compare_file) )
269265
bench_grid, bench_data = patch.read(compare_file)
270266

271-
result = compare.compare(my_grid, my_data, bench_grid, bench_data)
267+
result = compare.compare(sim.cc_data.grid, sim.cc_data, bench_grid, bench_data)
272268

273269
if result == 0:
274270
msg.success("results match benchmark\n")
@@ -280,7 +276,7 @@
280276
if make_bench:
281277
bench_file = solverName + "/tests/" + basename + "%4.4d" % (n)
282278
msg.warning("storing new benchmark: %s\n " % (bench_file) )
283-
my_data.write(bench_file)
279+
sim.cc_data.write(bench_file)
284280

285281

286282
#-----------------------------------------------------------------------------
@@ -289,4 +285,5 @@
289285
rp.print_unused_params()
290286
profile.timeReport()
291287

292-
exec problemName + '.finalize()'
288+
sim.finalize()
289+

0 commit comments

Comments
 (0)