@numba.jit<EOL>def _make_conn(shape):
shape = np.array(shape)<EOL>Ne = shape.prod()<EOL>if len(shape) == <NUM_LIT:2>:<EOL><INDENT>nx, ny = np.array(shape) +<NUM_LIT:1> <EOL>conn = np.zeros((Ne, <NUM_LIT:4>), dtype = np.int32)<EOL>counter = <NUM_LIT:0><EOL>pattern = np.array([<NUM_LIT:0>,<NUM_LIT:1>,<NUM_LIT:1>+nx,nx])<EOL>for j in range(shape[<NUM_LIT:1>]):<EOL><INDENT>for i in range(shape[<NUM_LIT:0>]):<EOL><INDENT>conn[counter] = pattern + <NUM_LIT:1> + i + j*nx<EOL>counter += <NUM_LIT:1><EOL><DEDENT><DEDENT><DEDENT>if len(shape) == <NUM_LIT:3>:<EOL><INDENT>nx, ny, nz  = np.array(shape) +<NUM_LIT:1> <EOL>conn = np.zeros((Ne, <NUM_LIT:8>), dtype = np.int32)<EOL>counter = <NUM_LIT:0><EOL>pattern = np.array([<NUM_LIT:0>,<NUM_LIT:1>,<NUM_LIT:1>+nx,nx,nx*ny,<NUM_LIT:1>+nx*ny,<NUM_LIT:1>+(nx+<NUM_LIT:1>)*ny,(nx+<NUM_LIT:1>)*ny])<EOL>for k in range(shape[<NUM_LIT:2>]):<EOL><INDENT>for j in range(shape[<NUM_LIT:1>]):<EOL><INDENT>for i in range(shape[<NUM_LIT:0>]):<EOL><INDENT>conn[counter] = pattern + <NUM_LIT:1> + i + j*nx+ k*nx*ny<EOL>counter += <NUM_LIT:1><EOL><DEDENT><DEDENT><DEDENT><DEDENT>return conn<EOL>
Connectivity builder using Numba for speed boost.