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

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