Copyright (C) 2020 Andreas Kloeckner
import numpy as np
import matplotlib.pyplot as pt
Consider the three equations:
$$y=x^2+\delta$$$$z=x^2-\delta$$$$y=z^2+\delta$$delta = 0.5
from mpl_toolkits.mplot3d import Axes3D
fig = pt.figure()
ax = fig.add_subplot(111, projection='3d')
res = 10
x, z = np.mgrid[-3:3:res*1j,-3:3:res*1j]
y = x**2 + delta
ax.plot_surface(x, y, z, color="red", cstride=1, rstride=1)
if 1:
y, x = np.mgrid[-3:3:res*1j,-3:3:res*1j]
z = x**2 - delta
ax.plot_surface(x, y, z, color="green", cstride=1, rstride=1)
if 0:
x, z = np.mgrid[-3:3:res*1j,-3:3:res*1j]
y = z**2 + delta
ax.plot_surface(x, y, z, color="blue", cstride=1, rstride=1)
Need better plotting tool.
!rm -f 1.vts 2.vts 3.vts
from pyvisfile.vtk import write_structured_grid
res = 50
x, z = np.mgrid[-3:3:res*1j,-3:3:res*1j]
y = x**2 + delta
mesh = np.array([x, y, z])
write_structured_grid("1.vts", mesh.reshape(3, res, 1, res))
# ----------------------------------
y, x = np.mgrid[-3:3:res*1j,-3:3:res*1j]
z = x**2 - delta
mesh = np.array([x, y, z])
write_structured_grid("2.vts", mesh.reshape(3, res, res, 1))
# ----------------------------------
x, z = np.mgrid[-3:3:res*1j,-3:3:res*1j]
y = z**2 + delta
mesh = np.array([x, y, z])
write_structured_grid("3.vts", mesh.reshape(3, res, 1, res))