EDIT: THE ORIGINAL POST DID NOT MAKE MUCH SENSE, SO I ADJUSTED ITOk, so I have thought about it, googled it and put some more thought into it. This presentation by the Imperial College in London has a nice example in it, on page 8, Burgers Equations. The first part of their code reads like this:from dolfin import*n = 30mesh = UnitInterval(n)V = FunctionSpace(mesh, CG,2)ic = project(Expression(sin(2*pi*x[0])), V)u = Function(ic)u_next = Function(V)v= TestFunction(V)nu = Constant(0.0001)timestep = Constant(1.0/n)F1 = ((u_next - u)/timestep*v)*dxF2 = (u_next*grad(u_next)*v)*dxF3 = (nu*grad(v)*grad(u_next))*dxOn my system this code fails, giving shape mismatch errors for the sums F2 and F3. I don't understand why.
Simple FEniCS problem shape mismatch
fenics;solver
So the problem is that FEniCS doesn't recognize that in 1D, u and grad(u) have the same shape. (You could file an issue about this on the Dolfin issue tracker.)If you replace grad by div, your code works. (The general form of the inviscid Burgers equation is $\mathop{\mathrm{div}}(u^2) = f$.)