Esempio n. 1
0
def MatrixS3D(Coords, n, Coefficients, el_type, Upwinded):
    E = Element(el_type)
    Se = np.zeros((len(Coords), len(Coords)))
    x_ip = [-np.sqrt(3) / 3, np.sqrt(3) / 3]
    weights = [1, 1]
    x_0 = Coefficients[6]
    r_c = Coefficients[4]
    for i in range(len(x_ip)):
        for j in range(len(x_ip)):
            for k in range(len(x_ip)):
                N = E.N(x_ip[i], x_ip[j], x_ip[k])
                N_T = N.transpose()
                B, Jdet, G, J_inv = E.G_ext(x_ip[i], x_ip[j], x_ip[k], Coords)
                B_T = B.transpose()
                x_coord = np.array([Coords[:, 0]]) @ N_T
                y_coord = np.array([Coords[:, 1]]) @ N_T
                z_coord = np.array([Coords[:, 2]]) @ N_T
                sigma = Coefficients[3](x_coord, y_coord, z_coord, r_c, x_0)
                Se += -N_T * (
                    sigma) * N * Jdet * weights[i] * weights[j] * weights[k]
                if Upwinded == True:
                    delta = CalcDelta3D(Coefficients,
                                        [x_coord, y_coord, z_coord], n)
                    Se += -delta * np.dot(
                        B_T, n.transpose()
                    ) * sigma * N * Jdet * weights[i] * weights[j] * weights[k]
    return Se
Esempio n. 2
0
def MatrixT2D(Coords, n, Coefficients, el_type, Upwinded):
    E = Element(el_type)
    Te = np.zeros((len(Coords), len(Coords)))
    x_ip = [-np.sqrt(3) / 3, np.sqrt(3) / 3]
    weights = [1, 1]
    for i in range(len(x_ip)):
        for j in range(len(x_ip)):
            N = E.N(x_ip[i], x_ip[j], 0)
            N_T = N.transpose()
            B, Jdet, G, J_inv = E.G_ext(x_ip[i], x_ip[j], 0, Coords)
            B_T = B.transpose()
            Te += N_T * np.dot(n, B) * Jdet * weights[i] * weights[j]
            if Upwinded == True:
                x_coord = np.array([Coords[:, 0]]) @ N.transpose()
                y_coord = np.array([Coords[:, 1]]) @ N.transpose()
                delta = CalcDelta2D(Coefficients, [x_coord, y_coord], n)
                Te += delta * np.dot(B_T, n.transpose()) * np.dot(
                    n, B) * Jdet * weights[i] * weights[j]
    return Te
Esempio n. 3
0
def MatrixK2D(Coords, n, Coefficients, el_type, Upwinded):
    E = Element(el_type)
    Ke = np.zeros((len(Coords), len(Coords)))
    x_ip = [-np.sqrt(3) / 3, np.sqrt(3) / 3]
    weights = [1, 1]
    for i in range(len(x_ip)):
        for j in range(len(x_ip)):
            N = E.N(x_ip[i], x_ip[j], 0)
            N_T = N.transpose()
            B, Jdet, G, J_inv = E.G_ext(x_ip[i], x_ip[j], 0, Coords)
            B_T = B.transpose()
            x_coord = np.array([Coords[:, 0]]) @ N_T
            y_coord = np.array([Coords[:, 1]]) @ N_T
            kappa_and_sigma = (Coefficients[0](x_coord, y_coord) +
                               Coefficients[3](x_coord, y_coord))
            Ke += N_T * (kappa_and_sigma) * N * Jdet * weights[i] * weights[j]
            if Upwinded == True:
                delta = CalcDelta2D(Coefficients, [x_coord, y_coord], n)
                Ke += delta * np.dot(B_T, n.transpose(
                )) * kappa_and_sigma * N * Jdet * weights[i] * weights[j]
    return Ke