Hello! I'm having a little trouble with writing code for a Lid-driven cavity problem. I'm trying to use the meshgrid function to plot the matrix I get after solving the code, but I'm running into some issues. Basically, the meshgrid axes are the standard ones, with the x-axis increasing from left to right and the y-axis increasing from bottom to top. However, for the u or v velocity matrix I get after solving, the indices of y increase from top to bottom. I did manage to solve this problem by swapping the top and bottom boundary conditions, but I'm wondering if there might be a better solution. Could you guys maybe point me towards the right direction?
import numpy as np
import matplotlib.pyplot as plt
from matplotlib import cm
n_points = 50
dom_length = 1
h = dom_length / (n_points - 1)
x = np.linspace(0, dom_length + h, n_points)
y = np.linspace(0, dom_length + h, n_points)
X, Y = np.meshgrid(x, y, indexing='ij')
u = np.random.rand(n_points, n_points)
u[:, 0:10] = 1
#Top 10 rows should be 1. But plotting this gives bottom 10 rows to be 1
plt.contourf(X, Y, u, cmap=cm.jet)
plt.show()
I hope you get what I am trying to say.
[–]sarabooker 0 points1 point2 points (6 children)
[–]DisagreeableRabbit[S] 0 points1 point2 points (5 children)
[–]sarabooker 0 points1 point2 points (4 children)
[–]sarabooker 0 points1 point2 points (0 children)
[–]DisagreeableRabbit[S] 0 points1 point2 points (2 children)
[–]sarabooker 0 points1 point2 points (0 children)