Highly improved efficiency in processing.animate to find grid
This commit is contained in:
parent
47bf31fb3a
commit
f7261d2e6b
1 changed files with 12 additions and 13 deletions
|
@ -38,21 +38,19 @@ x0 = config.getfloat("post", "x")
|
||||||
z0 = config.getfloat("post", "z")
|
z0 = config.getfloat("post", "z")
|
||||||
i0 = np.argmin(np.abs((model.x - x0) + 1j * (model.z - z0)))
|
i0 = np.argmin(np.abs((model.x - x0) + 1j * (model.z - z0)))
|
||||||
|
|
||||||
X, Z = np.meshgrid(np.unique(model.x), np.unique(model.z))
|
x0, idx0 = np.unique(model.x.astype(np.half), return_inverse=True)
|
||||||
|
z0, idz0 = np.unique(model.z.astype(np.half), return_inverse=True)
|
||||||
|
|
||||||
C = np.where(
|
X, Z = np.meshgrid(x0, z0)
|
||||||
(model.x[:, None, None].astype(np.single) == X[None, :, :].astype(np.single))
|
|
||||||
& (model.z[:, None, None].astype(np.single) == Z[None, :, :].astype(np.single))
|
|
||||||
)
|
|
||||||
|
|
||||||
P = np.full((model.t.size, *X.shape), np.nan)
|
P = np.full((model.t.size, *X.shape), np.nan)
|
||||||
P[:, C[1], C[2]] = model.fields["porosity"][:, C[0]]
|
P[:, idz0, idx0] = model.fields["porosity"]
|
||||||
|
|
||||||
AW = np.full((model.t.size, *X.shape), np.nan)
|
AW = np.full((model.t.size, *X.shape), np.nan)
|
||||||
AW[:, C[1], C[2]] = model.fields["alpha.water"][:, C[0]]
|
AW[:, idz0, idx0] = model.fields["alpha.water"]
|
||||||
|
|
||||||
U = np.full((model.t.size, *X.shape), np.nan)
|
U = np.full((model.t.size, *X.shape), np.nan)
|
||||||
U[:, C[1], C[2]] = np.linalg.norm(model.fields["U"], axis=1)[:, C[0]]
|
U[:, idz0, idx0] = np.linalg.norm(model.fields["U"], axis=1)
|
||||||
|
|
||||||
fig, ax = plt.subplots(figsize=(19.2, 10.8), dpi=100)
|
fig, ax = plt.subplots(figsize=(19.2, 10.8), dpi=100)
|
||||||
tit = ax.text(
|
tit = ax.text(
|
||||||
|
@ -129,9 +127,10 @@ def animU(i):
|
||||||
ur_m.set_array(U[i])
|
ur_m.set_array(U[i])
|
||||||
ur_m.set_alpha(1 - np.nan_to_num(AW[i]).clip(0, 1))
|
ur_m.set_alpha(1 - np.nan_to_num(AW[i]).clip(0, 1))
|
||||||
|
|
||||||
|
plt.show()
|
||||||
|
|
||||||
ani = animation.FuncAnimation(fig, anim, frames=model.t.size, interval=1 / 24)
|
#ani = animation.FuncAnimation(fig, anim, frames=model.t.size, interval=1/24)
|
||||||
aniU = animation.FuncAnimation(figU, animU, frames=model.t.size, interval=1 / 24)
|
#aniU = animation.FuncAnimation(figU, animU, frames=model.t.size, interval=1/24)
|
||||||
|
#
|
||||||
ani.save(out.joinpath("anim.mp4"), fps=24)
|
#ani.save(out.joinpath("anim.mp4"), fps=24)
|
||||||
aniU.save(out.joinpath("animU.mp4"), fps=24)
|
#aniU.save(out.joinpath("animU.mp4"), fps=24)
|
||||||
|
|
Loading…
Reference in a new issue