**from** fenics **import** *

**import** numpy **as** np

# Create mesh and function space

mesh = UnitSquareMesh(96,96)

cell = triangle

U = FiniteElement(“BDM”, cell, 1)

V = VectorElement(‘DG’, cell, 0)

Mixed_element = MixedElement([U,V])

W = FunctionSpace(mesh, Mixed_element)

dim1 = W.sub(0).dim()

nt = mesh.num_cells() # number of elements(triangles)

print(“dimU=”,dim1)

print(“dimV=”,2*nt)

# Trial and test functions

(u,v) = TrialFunctions(W)

(u1, v1) = TestFunctions(W)

A = PETScMatrix()

dx = Measure(‘dx’, domain=mesh)

assemble(dot(u,v1)*dx, tensor=A)

A1 = np.array(A.array())

A2 = np.zeros([dim1,2*nt])

**for** cell **in** cells(mesh):

t_n = cell.index() # triangle number

element_edges = cell.entities(1)

dof_u = W.sub(0).dofmap().cell_dofs(t_n)

dof_v = W.sub(1).dofmap().cell_dofs(t_n)

**for** i **in** range(3):

**for** j **in** range(2):

A2[2 * element_edges[i], 2 * t_n + j] = A1[dof_v[j], dof_u[2 * i]]

A2[2 * element_edges[i] + 1, 2 * t_n + j] = A1[dof_v[j], dof_u[2 * i + 1]]

I have provided a snippet of my code. I need the matrix A2 for updating some entries for the next iteration for higher discretization like 96-96,128-128 etc. But i am getting the error

zsh: killed.

This might be due to storing large size matrix A1. Is there any alternative to this ?

It will be really helpful for me.