My code is as follows: I am getting the error:
ypeError: setitem(): incompatible function arguments. The following argument types are supported:
1. (self: dolfin.cpp.la.BlockMatrix, arg0: tuple, arg1: dolfin.cpp.la.GenericMatrix) -> None
Invoked with: <dolfin.cpp.la.BlockMatrix object at 0x7f8658e08a78>, (0, 2), array([[0., 0., 0., …, 0., 0., 0.],
[0., 0., 0., …, 0., 0., 0.],
[0., 0., 0., …, 0., 0., 0.],
…,
[0., 0., 0., …, 0., 0., 0.],
[0., 0., 0., …, 0., 0., 0.],
[0., 0., 0., …, 0., 0., 0.]])
mesh = UnitSquareMesh(10,10)
RT1 = FiniteElement("RT", mesh.ufl_cell(), 1)
V1 = FunctionSpace(mesh, "RT", 1)
CG1 = FiniteElement("CG", mesh.ufl_cell(), 1)
mixed_A = MixedElement([RT1, CG1, RT1])
mixed_B = MixedElement([RT1, CG1])
W_A = FunctionSpace(mesh, mixed_A)
W_B = FunctionSpace(mesh, mixed_B)
(vpsi, vphi, vbigphi) = TestFunctions(W_A)
(vq, vu ) = TestFunctions(W_B)
trials_1A = TrialFunction(W_A)
trials_1B = TrialFunction(W_B)
Sol_A, Sol0_A = Function(W_A) , Function(W_A)
Sol_B, Sol0_B = Function(W_B) , Function(W_B)
(psi, phi, bigphi) = split(Sol_A)
(q, u) = split(Sol_B)
(psi0, phi0, bigphi0) = split(Sol0_A)
(q0, u0) = split(Sol0_B)
(psi_1, phi_1, bigphi_1) = split(trials_1A)
(q_1, u_1) = split(trials_1B)
def sigma(u):
return u**2
def beta_new(u):
return (1/(u**2))
uinitial = Expression("exp(x[1] + x[0] - t)", t = 0, degree = 2)
u0 = interpolate(uinitial, W_B.sub(1).collapse())
t = 0
dt = 0.1
T = 1
t = dt
A11 = assemble(inner(psi_1, vbigphi)*dx)
A23 = assemble(inner(bigphi_1, vpsi)*dx)
A33 = assemble(div(bigphi_1)*vphi*dx)
A12 = assemble(div(vbigphi)*phi_1*dx)
A_21_mat = - inner(sigma(u0)*psi_1, vpsi)*dx
nn = FacetNormal(mesh)
nrelems = mesh.num_cells()
nrsides = mesh.num_edges()
pp = Expression(" sin(x[1] + x[0] - t )", degree = 2, t = 0)
f1 = Expression(" (- 3*exp(x[0] - t + x[1]) + 1)", degree = 3, t=0)
f2 = Expression("2*sin(t + x[0] + x[1])", degree = 2, t=0 )
LHS1_mat = BlockMatrix(3,3)
while t <= T :
A21 = assemble(A_21_mat)
f2.t = t
b1_3 = assemble(inner(f2, vphi)*dx)
pp.t = t
b1_1 = assemble(-pp*dot(nn, vbigphi)*ds)
A13 = np.zeros((nrsides,nrsides))
A22 = np.zeros((nrsides, nrelems))
A31 = np.zeros((nrelems,nrsides))
A32 = np.zeros((nrelems, nrelems))
LHS1_mat[0,0] = A11
LHS1_mat[0,1] = A12
LHS1_mat[0,2] = A13 ##### Error here
LHS1_mat[1,0] = A21
LHS1_mat[1,1] = A22
LHS1_mat[1,2] = A23
LHS1_mat[2,0] = A31
LHS1_mat[2,1] = A32
LHS1_mat[2,2] = A33
LHS1_mat = np.block([[A11, A12, A13], [A21, A22, A23], [A31, A32, A33]])