Commit 0c0eea02 authored by Green, David's avatar Green, David
Browse files

Adding plotting

parent d17eb09a
......@@ -5,4 +5,16 @@ module load cuda-10.0.130-gcc-7.3.0-s6ervyw
module load gperftools-2.7-gcc-7.3.0-lwi7erl
module load cmake-3.12.2-gcc-7.3.0-duokccd
module load hdf5-1.10.3-gcc-7.3.0-dtrlkqs
spack load python
spack load py-h5py
spack load py-mpi4py
spack load py-six
spack load py-numpy
spack load py-matplotlib
spack load py-kiwisolver
spack load py-dateutil
spack load py-cycler
spack load py-backports-functools-lru-cache
spack load py-functools32
spack load py-pyparsing
......@@ -113,6 +113,7 @@ T executeSimulation(PDE<T>& pde, bool implicit, unsigned int write, bool referen
// Generate initial condition vector
auto fval = time(initial_condition_vector<T>, "initial_condition_vector", f_x, f_v, inverse_hash, pde.getDeg());
matrix2d<T> fval_2d(fval.size(), 1, fval.size(), fval);
matrix2d<T> real_fval = realConverter.convertToReal(fval_2d);
// Step 3. Generate time-independent coefficient matrices
//
......@@ -159,10 +160,9 @@ T executeSimulation(PDE<T>& pde, bool implicit, unsigned int write, bool referen
std::cout << "setup :" << duration << ": ms" << std::endl;
if(write) {
auto stat = time(write_initial_condition<T>, "write_initial_condition", fval_2d.data_container, dt, pde);
//auto stat = time(write_initial_condition<T>, "write_initial_condition", fval_2d.data_container, dt, pde);
auto stat = time(write_initial_condition<T>, "write_initial_condition", real_fval.data_container, dt, pde);
}
// Time loop
......@@ -233,13 +233,14 @@ T executeSimulation(PDE<T>& pde, bool implicit, unsigned int write, bool referen
finalRelError = compute_error(fval_analytic, out);
}
bool out_on_host = false;
if (visualize >0){
if (L % visualize == 0) {
if (L % visualize == 0) {
for(auto i = 0; i < fval_2d.size(); ++i) {
fval_2d.data[i] = out[i];
}
out_on_host = true;
matrix2d<T> real_fval = realConverter.convertToReal(fval_2d);
real_fval = realConverter.convertToReal(fval_2d);
}
}
......@@ -251,7 +252,8 @@ T executeSimulation(PDE<T>& pde, bool implicit, unsigned int write, bool referen
fval_2d.data[i] = out[i];
}
}
auto stat = time(write_timestep<T>, "write_timestep", fval_2d.data_container, writeCnt, pde, simTime);
//auto stat = time(write_timestep<T>, "write_timestep", fval_2d.data_container, writeCnt, pde, simTime);
auto stat = time(write_timestep<T>, "write_timestep", real_fval.data_container, writeCnt, pde, simTime);
++writeCnt;
}
}
......
import h5py
import os
from math import sqrt
import matplotlib
import numpy as np
import matplotlib.cm as cm
import matplotlib.pyplot as plt
f = h5py.File('fval-MWT.h5','r')
fval = f['fval']
nT = fval.shape[0]
N = fval.shape[1];
n = int(sqrt(N));
lev = fval.attrs['lev']
deg = fval.attrs['deg']
dt = fval.attrs['dt']
Lmin = fval.attrs['Lmin']
Lmax = fval.attrs['Lmax']
Vmin = fval.attrs['Vmin']
Vmax = fval.attrs['Vmax']
# Get initial condition
data0 = fval[0,0:N]
f2d0 = data0.reshape((n,n))
# Setup plots
fig, axs = plt.subplots(nrows=1,ncols=2)
ax1 = axs[0]
ax2 = axs[1]
# Create output dir
oPath = 'output'
if os.path.isdir(oPath) == 0:
os.mkdir('output')
# Loop over time slices
for t in range(nT):
print t
data = fval[t,0:N]
f2d = data.reshape((n,n))
ax1.contourf(f2d-f2d0)
ax2.contourf(f2d)
fileName = 'output/f2d_' + str(t) + '.png'
fig.savefig(fileName, bbox_inches='tight')
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment