Unable to extract all indices

Asked by Yapi Donatien Achou

Hi, I am new to Fenics, and I am trying to solve a linear convection-diffusion equation, read
alpha*du/dt +beta*inner(w,grad(u))= grad(K*grad(u)). w is the velocity vector, alpha, beta are constants. My entire code read:

# implementation of the constant coefficient convection-diffusion equation
from dolfin import *

# Create mesh and define function space
mesh=UnitSquare(10,10)
V=FunctionSpace(mesh, "Lagrange", 1)

#Define boundary condition
u0 = Expression("20+t", t=0)

#Define the Dirichlet boundary condition
def boundary(x, on_boundary):
    return on_boundary

bc = DirichletBC(V, u0, boundary)

u_1 = interpolate(u0, V) #u_1 is the value of u at time step k-1

# Time step and some problem parameters
dt=0.3
K=1
alpha=1
#beta=1
w = as_vector([1.0, 1.0])

u= TrialFunction(V)

v=TestFunction(V)
f = Expression("0.0")
a=alpha*u*v*dx+inner(w, grad(u))*dx+dt*K*inner(grad(u), grad(v))*dx
L=alpha*u_1*v*dx + f*v*dx

A=assemble(a)
u=Function(V)
T=10 # total simulation time
t=dt

while t <= T:
    b = assemble(L)
    u0.t = t
   # bc.apply(A,b)
    solve(A, u.vector(), b)

    t += dt
    u_1.assign(u)

plot(u)
plot(mesh)
interactive()

I am getting the following error: Unable to extract all indices. Can some one help. Thank you.

Question information

Language:
English Edit question
Status:
Solved
For:
DOLFIN Edit question
Assignee:
No assignee Edit question
Solved by:
Hans Petter Langtangen
Solved:
Last query:
Last reply:
Revision history for this message
Best Hans Petter Langtangen (hpl) said :
#1

You need the test function v in the second term in a, see http://fenicsproject.org/documentation/tutorial/misc.html#problems-in-the-solve-step

Hans Petter

Revision history for this message
Yapi Donatien Achou (ruben123x) said :
#2

Thank you Hans Petter. This has solved the problem.

Revision history for this message
Leonardo Andrés Jofré Flor (ljofre2146) said :
#3

what is the solution for this?