Tensor-product discretizations
- We extend one-dimensional problem to the two-dimensional rectangle
- Tensor-product grid:
\[ \{(x_i, y_j): i = 0,...,m; j = 0,...,n\}. \]
- Functions on the grid are a matrix with elements of \(f(x_i,y_j)\)
m = 4; x = range(0,2,length=m+1);
n = 2; y = range(1,3,length=n+1);
f = (x,y) -> cos(π*x*y-y);
F = [ f(x,y) for x in x, y in y ];
plotlyjs(); # use better 3D renderer
m = 60; x = range(0,2,length=m+1);
n = 50; y = range(1,3,length=n+1);
F = [ f(x,y) for x in x, y in y ];
plot(x,y,F',levels=10,fill=true,aspect_ratio=1,
color=:redsblues,clims=(-1,1),
xlabel="x",ylabel="y")
surface(x,y,F',l=0,leg=:none,
color=:redsblues,clims=(-1,1),
xlabel="x",ylabel="y",zlabel="f(x,y)")
- Parametrized surfaces allow us to define non-rectangular shapes, i.e., polar coordinates
r = range(0,1,length=41);
theta = range(0,2π,length=81);
F = [ 1-r^4 for r in r, theta in theta ];
surface(r,theta,F',legend=:none,l=0,color=:viridis,
xlabel="r",ylabel="theta",title="A polar function")
X = [ r*cos(theta) for r in r, theta in theta ];
Y = [ r*sin(theta) for r in r, theta in theta ];
surface(X',Y',F',legend=:none,l=0,color=:viridis,
xlabel="x",ylabel="y",title="Function on the unit disk")
- Partial derivatives for collocation involve transposing for y dimension:
\[ \text{mtx}\left(\frac{\delta u}{\delta x} \right) \approx \mathbf{D}_x \text{mtx}(u), \quad \text{mtx}\left(\frac{\delta u}{\delta y} \right) \approx \text{mtx}(u) \mathbf{D}_y^T \]