This is a read only copy of the old FEniCS QA forum. Please visit the new QA forum to ask questions

PETSc error code is: 62 (Invalid argument).

+1 vote

What's the meaning of the error code?

My source code is below:

mesh = UnitCubeMesh(10, 10, 10)

DG = FiniteElement('DG', mesh.ufl_cell(), 0)
Nedelec = FiniteElement('N1curl', mesh.ufl_cell(), 1)
element = MixedElement([DG, Nedelec])
V = FunctionSpace(mesh, element)

V_RT = FunctionSpace(mesh, 'RT', 1)

bc1 = DirichletBC(V_RT, Constant([0.0, 0.0, 0.0]), DomainBoundary())
bc2 = DirichletBC(V.sub(0), Constant(0.0), DomainBoundary())
bc3 = DirichletBC(V.sub(1), Constant([0.0, 0.0, 0.0]), DomainBoundary())

u = TrialFunction(V_RT)
q, eta = TestFunctions(V)

a = div(u)*q*dx + inner(u, curl(eta))*dx
L = phi*q*dx
dummy = q*dx

A, _ = assemble_system(a, dummy, [bc1, bc2, bc3])
_, b = assemble_system(a, L, [bc1, bc2])

u = Function(V_RT) 
solve(A, u.vector(), b)
asked Jul 3, 2017 by fanronghong FEniCS User (1,680 points)

Hi, print A.size(0), A.size(1) shows you that you have a rectangular system while solve assumes square systems.

Thank you for your answer very much !!!

Actually I know the system is rectangular, because of the different trial and test function space. So what is the common method to solve this rectangular system ? I think the different-trial-test-functionspace problem is very common .

Besides, the solution of the problem exists only one because of theory .

Isn't there a variational problem which leads to square system, similar to here? If you want to stick with your current system you could perhaps solve it with CGN. The method is implemented in cbc.block.

So I read some demos. And I correct my source code like below.
But I get error:
*** Error: Unable to apply boundary condition.
*** Reason: Matrix dimension (384 rows) does not match b vector dimension (864) for application of boundary conditions.

I do't know where I'm wrong.
Please help me, I'm desperately want to solve the problem.Thanks in advance!!!

mesh = UnitCubeMesh(4,4,4)

RT = FunctionSpace(mesh, 'RT', 1)
DG = FunctionSpace(mesh, 'DG', 0)
Nedelec = FunctionSpace(mesh, 'N1curl', 1)

u = TrialFunction(RT)
q = TestFunction(DG)
eta = TestFunction(Nedelec)

a11 = div(u)*q*dx
a21 = inner(u, curl(eta))*dx
L1 = phi*q*dx

#A11 = assemble(a11)
#A21 = assemble(a21)
#b1 = assemble(L1)
#AA = block_mat([[A11], [A21]])
#bb = block_vec([b1, 0])

AA = block_assemble([[a11], [a21]])
bb = block_assemble([L1, 0])

bc_RT = DirichletBC(RT, Constant([0.0, 0.0, 0.0]), DomainBoundary())
bcs = [bc_RT, bc_RT]
block_bc(bcs, True).apply(AA).apply(bb)

#BB = AMG(AA)
#AAinv = ConjGrad(AA, precond=BB)
AAinv = ConjGrad(AA.T * AA) * AA.T
x = AAinv * bb

u = Function(RT)
u.vector()[:] = x[:]
plot(u)

Maybe I know where I'm wrong.

Forming the block matrix is OK, but how to apply boundary condition for different trial and test function space?

...