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

dirichlet bc in nonlinear problem

0 votes

Hi,
I am trying to solve a nonlinear problem by imposing dirichlet boundary conditions. I got the error:

"Vector dimension (4 rows) does not match vector dimension (2) for application of boundary conditions."

Here you can find some important part of my code:

mesh = IntervalMesh(1,0,10)
A = FunctionSpace(mesh, "CG", 1)
Q = FunctionSpace(mesh, "CG", 1)
W = MixedFunctionSpace([A, Q])

def left (x, on_boundary):
tol = 1e-14
return on_boundary and abs(x [0]) < tol

bc_1 = DirichletBC(W.sub(1), Constant((100.0)), left)
bcs = [bc_1]

...
w = Function(W)
(a, q) = (w[0], w[1])
v = TestFunction(A)
F_nonlinear_1 = inner(grad(v)[0], q)dx
F_nonlinear_2 = inner (q, v)
ds
F = F_nonlinear_1 + F_nonlinear_2
J = derivative(F, w)
...

problem = NonlinearVariationalProblem(F, w, bcs, J)
solver = NonlinearVariationalSolver(problem)

solver.solve()

asked Jan 24, 2017 by Abi FEniCS Novice (270 points)
edited Jan 25, 2017 by Abi

1 Answer

+1 vote

The test function v must live in the same mixed space that a and q (side note: the problem posted here isn't really nonlinear).

answered Jan 25, 2017 by hernan_mella FEniCS Expert (19,460 points)
...