Expecting second argument to be a Function
I came upon this strange error message while running the following code (the error message has been included at the end) :
from dolfin import *
N = 100
alpha = 0.1
mesh = UnitInterval(N)
V = FunctionSpace(
def left(x,
return on_boundary & near(x[0],0)
def right(x,
return on_boundary & near(x[0],1)
# The boundary conditions
bc_left = DirichletBC(
bc_right = DirichletBC(
bcs = [bc_left,bc_right]
# The variational formulation
u = TrialFunction(V)
v = TestFunction(V)
a = (-u.dx(0)*v + alpha*u.
L = Constant(0)*v*dx
# Solve the variational problem
solve(a == L,u,bcs)
#u_ = Function(V)
#solve(a==L,u_,bcs)
The commented code works well. However when I try to solve the variational problem and store the solution in u, which is the trial function, I produce the error message :
>> python convection_
Traceback (most recent call last):
File "convection_
solve(a == L,u,bcs)
File "/usr/lib/
_solve_
File "/usr/lib/
= _extract_
File "/usr/lib/
u = _extract_u(args[1])
File "/usr/lib/
"Expecting second argument to be a Function")
File "/usr/lib/
return _cpp.dolfin_
RuntimeError:
*** -------
*** DOLFIN encountered an error. If you are not able to resolve this issue
*** using the information listed below, you can ask for help at
***
*** https:/
***
*** Remember to include the error message listed below and, if possible,
*** include a *minimal* running example to reproduce the error.
***
*** -------
*** Error: Unable to solve variational problem.
*** Reason: Expecting second argument to be a Function.
*** Where: This error was encountered inside solving.py.
*** -------
Why does this happen ? I have solved plenty of problems using the trialfunction as an argument in different solvers to store the solution inside.
Question information
- Language:
- English Edit question
- Status:
- Answered
- For:
- DOLFIN Edit question
- Assignee:
- No assignee Edit question
- Last query:
- Last reply:
Can you help with this problem?
Provide an answer of your own, or ask imranal for more information if necessary.