argiope/mesh.py
def _make_conn(shape):
    """
    Connectivity builder using Numba for speed boost.
    """
    shape = np.array(shape)
    Ne = shape.prod()
    if len(shape) == 2:
        nx, ny = np.array(shape) +1 
        conn = np.zeros((Ne, 4), dtype = np.int32)
        counter = 0
        pattern = np.array([0,1,1+nx,nx])
        for j in range(shape[1]):
            for i in range(shape[0]):
                conn[counter] = pattern + 1 + i + j*nx
                counter += 1
        
    if len(shape) == 3:
        nx, ny, nz  = np.array(shape) +1 
        conn = np.zeros((Ne, 8), dtype = np.int32)
        counter = 0
        pattern = np.array([0,1,1+nx,nx,nx*ny,1+nx*ny,1+(nx+1)*ny,(nx+1)*ny])
        for k in range(shape[2]):
            for j in range(shape[1]):
                for i in range(shape[0]):
                    conn[counter] = pattern + 1 + i + j*nx+ k*nx*ny
                    counter += 1
    return conn
def _make_conn(shape):
    """
    Connectivity builder using Numba for speed boost.
    """
    shape = np.array(shape)
    Ne = shape.prod()
    if len(shape) == 2:
        nx, ny = np.array(shape) +1 
        conn = np.zeros((Ne, 4), dtype = np.int32)
        counter = 0
        pattern = np.array([0,1,1+nx,nx])
        for j in range(shape[1]):
            for i in range(shape[0]):
                conn[counter] = pattern + 1 + i + j*nx
                counter += 1
        
    if len(shape) == 3:
        nx, ny, nz  = np.array(shape) +1 
        conn = np.zeros((Ne, 8), dtype = np.int32)
        counter = 0
        pattern = np.array([0,1,1+nx,nx,nx*ny,1+nx*ny,1+(nx+1)*ny,(nx+1)*ny])
        for k in range(shape[2]):
            for j in range(shape[1]):
                for i in range(shape[0]):
                    conn[counter] = pattern + 1 + i + j*nx+ k*nx*ny
                    counter += 1
    return conn
Connectivity builder using Numba for speed boost.