def getWave2DUpwindMatrix(N, dx): Dx = get2DUpwindMatrix(N, dx) Zero = np.zeros((N[0] * N[1], N[0] * N[1])) M1 = sp.hstack((Dx, Zero, Zero), format="csr") M2 = sp.hstack((Zero, Dx, Zero), format="csr") M3 = sp.hstack((Zero, Zero, Dx), format="csr") M = sp.vstack((M1, M2, M3), format="csr") return sp.csc_matrix(M)
def getWave2DUpwindMatrix(N, dx): Dx = get2DUpwindMatrix(N, dx) Zero = np.zeros((N[0]*N[1],N[0]*N[1])) M1 = sp.hstack((Dx , Zero, Zero), format="csr") M2 = sp.hstack((Zero, Dx, Zero), format="csr") M3 = sp.hstack((Zero, Zero, Dx), format="csr") M = sp.vstack((M1,M2,M3), format="csr") return sp.csc_matrix(M)
def getBoussinesq2DUpwindMatrix(N, dx, u_adv, order): Dx = get2DUpwindMatrix(N, dx) # Note: In the equations it is u_t + u_adv* D_x u = ... so in order to comply with the form u_t = M u, # add a minus sign in front of u_adv Zero = np.zeros((N[0]*N[1], N[0]*N[1])) M1 = sp.hstack((-u_adv*Dx, Zero, Zero, Zero), format="csr") M2 = sp.hstack(( Zero, -u_adv*Dx, Zero, Zero), format="csr") M3 = sp.hstack(( Zero, Zero, -u_adv*Dx, Zero), format="csr") M4 = sp.hstack(( Zero, Zero, Zero, -u_adv*Dx), format="csr") M = sp.vstack((M1,M2,M3,M4), format="csr") return sp.csc_matrix(M)