(vertices, lame, mu)
return K
Local stiffness matrix for P1 elements in 3d.
Local stiffness matrix for P1 elements in 3d.
Local stiffness matrix for P1 elements in 3d .
def p13d_local(vertices, lame, mu):
    """Local stiffness matrix for P1 elements in 3d."""
    assert vertices.shape == (4, 3)

    A = np.vstack((np.ones((1, 4)), vertices.T))
    PhiGrad = sla.inv(A)[:, 1:]  # gradients of basis functions

    R = np.zeros((6, 12))
    R[[0, 3, 4], 0::3] = PhiGrad.T
    R[[3, 1, 5], 1::3] = PhiGrad.T
    R[[4, 5, 2], 2::3] = PhiGrad.T

    C = np.zeros((6, 6))
    C[0:3, 0:3] = lame + 2*mu*np.eye(3)
    C[3:6, 3:6] = mu*np.eye(3)

    K = sla.det(A)/6*np.dot(np.dot(R.T, C), R)
    return K
def p13d_local ( vertices , lame , mu ) : assert vertices . shape == ( 4 , 3 ) A = np . vstack ( ( np . ones ( ( 1 , 4 ) ) , vertices . T ) ) PhiGrad = sla . inv ( A ) [ : , 1 : ] # gradients of basis functions R = np . zeros ( ( 6 , 12 ) ) R [ [ 0 , 3 , 4 ] , 0 : : 3 ] = PhiGrad . T R [ [ 3 , 1 , 5 ] , 1 : : 3 ] = PhiGrad . T R [ [ 4 , 5 , 2 ] , 2 : : 3 ] = PhiGrad . T C = np . zeros ( ( 6 , 6 ) ) C [ 0 : 3 , 0 : 3 ] = lame + 2 * mu * np . eye ( 3 ) C [ 3 : 6 , 3 : 6 ] = mu * np . eye ( 3 ) K = sla . det ( A ) / 6 * np . dot ( np . dot ( R . T , C ) , R ) return K