def find_physical_coordinates(self, N): self.N = N self.Nq = N + 1 if self.get_ndim() == 3: self.Nfp = (N + 1) * (N + 1) self.Np = (N + 1) * (N + 1) * (N + 1) else: self.Nfp = N + 1 self.Np = (N + 1) * (N + 1) z_1, jnk = gauss_lobatto(1) z_N, jnk = gauss_lobatto(N) J = lagrange(z_N, z_1) self.xe = [] self.ye = [] self.ze = [] if self.ndim == 3: for e in range(self.get_num_elems()): x = self.x[e, :] y = self.y[e, :] z = self.z[e, :] xx = np.array([x[0], x[1], x[3], x[2], x[4], x[5], x[7], x[6]]) yy = np.array([y[0], y[1], y[3], y[2], y[4], y[5], y[7], y[6]]) zz = np.array([z[0], z[1], z[3], z[2], z[4], z[5], z[7], z[6]]) xe = kron(J, J, J, xx) ye = kron(J, J, J, yy) ze = kron(J, J, J, zz) self.xe.append(xe) self.ye.append(ye) self.ze.append(ze) else: for e in range(self.get_num_elems()): x = self.x[e, :] y = self.y[e, :] z = self.z[e, :] xx = np.array([x[0], x[1], x[3], x[2]]) yy = np.array([y[0], y[1], y[3], y[2]]) zz = np.arraz([z[0], z[1], z[3], z[2]]) xe = kron(J, J, J, xx) ye = kron(J, J, J, yy) ze = kron(J, J, J, zz) self.xe.append(xe) self.ye.append(ye) self.ze.append(ze) self.xe = np.array(self.xe) self.ye = np.array(self.ye) self.ze = np.array(self.ze)
def reference_mass_matrix_2d(p): z, w = gauss_lobatto(p) n = p + 1 B = np.zeros((n * n, ), dtype=np.float64) for k in range(n): for j in range(n): B[j * n + k] = w[j] * w[k] return B
def box(x, y, z, M): N = 1 n = N + 1 nn = n * n m = M + 1 mm = m * m zn, wn = gauss_lobatto(N) zm, wm = gauss_lobatto(M) J = lagrange(zm, zn) x = x.reshape((nn, n)) y = y.reshape((nn, n)) z = z.reshape((nn, n)) Jx = np.dot(x, J.T) Jy = np.dot(y, J.T) Jz = np.dot(z, J.T) x = Jx.reshape((n, n, m)) y = Jy.reshape((n, n, m)) z = Jz.reshape((n, n, m)) Jx = np.zeros((n, m, m)) Jy = np.zeros((n, m, m)) Jz = np.zeros((n, m, m)) for i in range(n): Jx[i, :, :] = np.dot(J, x[i, :, :]) Jy[i, :, :] = np.dot(J, y[i, :, :]) Jz[i, :, :] = np.dot(J, z[i, :, :]) x = Jx.reshape((n, mm)) y = Jy.reshape((n, mm)) z = Jz.reshape((n, mm)) Jx = np.dot(J, x) Jy = np.dot(J, y) Jz = np.dot(J, z) x = Jx.reshape((m, m, m)) y = Jy.reshape((m, m, m)) z = Jz.reshape((m, m, m)) return x, y, z
def box_2d(x, y, M): N = 1 n = N + 1 m = M + 1 zn, wn = gauss_lobatto(N) zm, wm = gauss_lobatto(M) J = lagrange(zm, zn) x = x.reshape((n, n)) y = y.reshape((n, n)) Jx = np.dot(x, J.T) Jy = np.dot(y, J.T) x = Jx.reshape((n, m)) y = Jy.reshape((n, m)) Jx = np.dot(J, x) Jy = np.dot(J, y) x = Jx.reshape((m, m)) y = Jy.reshape((m, m)) return x, y
def reference_derivative_matrix(p): z, w = gauss_lobatto(p) D = lagrange_derivative_matrix(z) return D
def trapezoid(M): N = 1 zn, wn = gauss_lobatto(N) zm, wm = gauss_lobatto(M) J = lagrange(zm, zn) x = np.array([ -0.5, 0.5, -1.0 / sqrt(2.0), 1.0 / sqrt(2.0), -0.5, 0.5, -1.0 / sqrt(2.0), 1.0 / sqrt(2.0), ]) y = np.array([ 0.5, 0.5, 1.0 / sqrt(2.0), 1.0 / sqrt(2.0), 0.5, 0.5, 1.0 / sqrt(2.0), 1.0 / sqrt(2.0), ]) z = np.array([0.0, 0.0, 0.0, 0.0, 0.1, 0.1, 0.1, 0.1]) n = N + 1 nn = n * n m = M + 1 mm = m * m x = x.reshape((nn, n)) y = y.reshape((nn, n)) z = z.reshape((nn, n)) Jx = np.dot(x, J.T) Jy = np.dot(y, J.T) Jz = np.dot(z, J.T) Jx = Jx.reshape((n, n, m)) Jy = Jy.reshape((n, n, m)) Jz = Jz.reshape((n, n, m)) JJx = np.zeros((n, m, m)) JJy = np.zeros((n, m, m)) JJz = np.zeros((n, m, m)) for i in range(n): JJx[i, :, :] = np.dot(J, Jx[i, :, :]) JJy[i, :, :] = np.dot(J, Jy[i, :, :]) JJz[i, :, :] = np.dot(J, Jz[i, :, :]) X = JJx Y = JJy Z = JJz for j in range(n): for i in range(m): Y[j, i, :] = Y[j, i, :] + (Y[j, i, :] - Y[j, 0, :]) * ( X[j, i, 0] * X[j, i, 0] - np.multiply(X[j, i, :], X[j, i, :])) Jx = JJx.reshape((n, mm)) Jy = JJy.reshape((n, mm)) Jz = JJz.reshape((n, mm)) X = np.dot(J, Jx) Y = np.dot(J, Jy) Z = np.dot(J, Jz) X = X.reshape((m, m, m)) Y = Y.reshape((m, m, m)) Z = Z.reshape((m, m, m)) return X, Y, Z
def reference_mass_matrix_1d(p): z, w = gauss_lobatto(p) return np.diag(w)