Nonlinear 1-d convection diffusion

Asked by Praveen C

Hello
This is my first attempt at dolfin. I am solving a 1-d convection-diffusion equation

(u^2/2)_x - u_xx = f
u(0) = u(1) = 0

So I do the following

# Create mesh and function space
mesh = UnitInterval(50)
V = FunctionSpace(mesh, "CG", 1)

# Sub domain for Dirichlet boundary condition
def DirichletBoundary(x):
     return x[0] < DOLFIN_EPS or x[0] > 1.0 - DOLFIN_EPS

# Define variational problem
u = Function(V)
f = Expression("10.0*x[0]*(1.0-x[0])*sin(x[0])")

du = TrialFunction(V)
v = TestFunction(V)

F = (-0.5*u**2*grad(v) + dot(grad(u), grad(v)))*dx - f*v*dx
dF= derivative(F, u, du)

# Define boundary condition
u0 = Constant(0.0)
bc = DirichletBC(V, u0, DirichletBoundary)

problem = VariationalProblem(F, dF, bc)
u = problem.solve()

But this gives me following error

RuntimeError: *** Error: Unable to extract trial space for solution of variational problem, is 'a' bilinear?

Can you help me with this please ?

Thanks
praveen

Question information

Language:
English Edit question
Status:
Solved
For:
DOLFIN Edit question
Assignee:
No assignee Edit question
Solved by:
Praveen C
Solved:
Last query:
Last reply:
Revision history for this message
Praveen C (cpraveen) said :
#1

I found the mistake. It should be

problem.solve(u)

Revision history for this message
Johan Hake (johan-hake) said :
#2

What version of DOLFIN do you use. Just run

  dolfin-version

from the command prompt. The itnerface of VariationalProblem has changed
recently and it seams as you might have an older version.

Johan

On Monday May 30 2011 21:05:47 Praveen C wrote:
> New question #159694 on DOLFIN:
> https://answers.launchpad.net/dolfin/+question/159694
>
> Hello
> This is my first attempt at dolfin. I am solving a 1-d convection-diffusion
> equation
>
> (u^2/2)_x - u_xx = f
> u(0) = u(1) = 0
>
> So I do the following
>
>
> # Create mesh and function space
> mesh = UnitInterval(50)
> V = FunctionSpace(mesh, "CG", 1)
>
> # Sub domain for Dirichlet boundary condition
> def DirichletBoundary(x):
> return x[0] < DOLFIN_EPS or x[0] > 1.0 - DOLFIN_EPS
>
> # Define variational problem
> u = Function(V)
> f = Expression("10.0*x[0]*(1.0-x[0])*sin(x[0])")
>
> du = TrialFunction(V)
> v = TestFunction(V)
>
> F = (-0.5*u**2*grad(v) + dot(grad(u), grad(v)))*dx - f*v*dx
> dF= derivative(F, u, du)
>
> # Define boundary condition
> u0 = Constant(0.0)
> bc = DirichletBC(V, u0, DirichletBoundary)
>
> problem = VariationalProblem(F, dF, bc)
> u = problem.solve()
>
> But this gives me following error
>
> RuntimeError: *** Error: Unable to extract trial space for solution of
> variational problem, is 'a' bilinear?
>
> Can you help me with this please ?
>
> Thanks
> praveen

Revision history for this message
Praveen C (cpraveen) said :
#3

I use the Mac binary available on fenics website. It says version is 0.9.11

Revision history for this message
Johan Hake (johan-hake) said :
#4

On Monday May 30 2011 22:20:56 Praveen C wrote:
> Question #159694 on DOLFIN changed:
> https://answers.launchpad.net/dolfin/+question/159694
>
> Praveen C posted a new comment:
> I use the Mac binary available on fenics website. It says version is
> 0.9.11

Then you have a recent enough version

Johan