File tree Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change 5
5
#
6
6
# License: BSD 3 clause
7
7
8
+ import os
8
9
import numpy as np
9
10
import sympy as sp
10
11
import matplotlib .pyplot as plt
@@ -294,8 +295,14 @@ def __call__(self, sol):
294
295
data [solid_cells [tuple (ind )]] = np .nan
295
296
296
297
fig , ax = plt .subplots ()
298
+ h5_file , _ = os .path .splitext (self .filename )
299
+ h5_dir , h5_file = os .path .split (h5_file )
300
+ h5 = pylbm .H5File (sol .domain .mpi_topo , f'{ h5_file } _{ sol .nt } ' , h5_dir )
301
+
297
302
if sol .dim == 1 :
298
303
x = sol .domain .x
304
+ h5 .set_grid (x )
305
+
299
306
ax .plot (x , data ,
300
307
color = 'black' ,
301
308
alpha = 0.8 ,
@@ -309,12 +316,17 @@ def __call__(self, sol):
309
316
alpha = 0.8 ,
310
317
linewidth = 1 ,
311
318
)
319
+ h5 .add_scalar ('sol_ref' , self .ref_solution )
320
+
312
321
elif sol .dim == 2 :
313
322
x , y = sol .domain .x , sol .domain .y
323
+ h5 .set_grid (x , y )
314
324
cmap = copy .copy (matplotlib .cm .get_cmap ("RdBu" ))
315
325
cmap .set_bad ('black' , 0.8 )
316
326
extent = [np .amin (x ), np .amax (x ), np .amin (y ), np .amax (y )]
317
327
imshow = ax .imshow (data .T , origin = 'lower' , cmap = cmap , extent = extent )
318
328
fig .colorbar (imshow , ax = ax )
319
329
330
+ h5 .add_scalar ('sol' , data )
320
331
fig .savefig (self .filename , dpi = 300 )
332
+ h5 .save ()
You can’t perform that action at this time.
0 commit comments