diff options
Diffstat (limited to 'src/plotter.py')
-rw-r--r-- | src/plotter.py | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/src/plotter.py b/src/plotter.py index c803f3f..45d95da 100644 --- a/src/plotter.py +++ b/src/plotter.py @@ -1,5 +1,6 @@ import numpy as np import matplotlib.pyplot as plt +from copy import copy from matplotlib.patches import Rectangle figure, axes = plt.subplots() @@ -33,21 +34,32 @@ class Plotter: u = u / factor v = v / factor + + shape = (model.p.shape[0] + 1, model.p.shape[1] + 1) x, y = np.meshgrid( - np.linspace(0, model.domain_size[1], model.shape[1]), - np.linspace(0, model.domain_size[0], model.shape[0]), + np.linspace(0, shape[1] * model.step, shape[1]), + np.linspace(0, shape[0] * model.step, shape[0]), ) - density = density or int((max(model.domain_size) / model.step) / 40) + u = copy(model.u) + u.resize(shape) + v = copy(model.v) + v.resize(shape) + p = copy(model.p) + p.resize(shape) + + print(shape, u.shape, v.shape) + + # density = density or int((max(model.domain_size) / model.step) / 40) - plt.contourf(x, y, model.p) + plt.contourf(x, y, p) # self.patch = axes.add_patch(Rectangle((0, 0), *reversed(model.bfs_size), color='gray')) # TODO: allow using streamplot self.plt = plt.quiver( - x[::density, ::density], - y[::density, ::density], - u[::density, ::density], - v[::density, ::density], + x, + y, + u, + v, ) self.colorbar = plt.colorbar(label='Pressure') |