dolfin team mailing list archive
-
dolfin team
-
Mailing list archive
-
Message #23594
[Question #159694]: Nonlinear 1-d convection diffusion
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
--
You received this question notification because you are a member of
DOLFIN Team, which is an answer contact for DOLFIN.
Follow ups