def sparsifyElementMatrix(K,numbering1,numbering2=None):
    """Convert the element stiffness matrix into COO format for assembling."""
    if numbering2 is None: numbering2=numbering1

    IArray=[]
    JArray=[]
    VArray=[]

    for i in range(2*len(numbering1)):
        for j in range(2*len(numbering2)):
            IArray.append(2*numbering1[i//2]+i%2)
            JArray.append(2*numbering2[j//2]+j%2)
            VArray.append(K[i,j])
    
    return IArray,JArray,VArray