David,

So if D.assign(assemble(div(q) * e * dx)/assemble(e * dx)) returns cell-wise div(q), what's the denominator "/assemble(e * dx)" for?

Thanks,
Justin

On Thursday, November 12, 2015, David Ham <David.Ham@imperial.ac.uk> wrote:
If you're worried about performance, then you can notice that the LHS matrix is diagonal (because D is in DG0) so you can avoid matrix assembly and solve with:

D.assign(assemble(div(q) * e * dx)/assemble(e * dx))

(ie just divide by the diagonal entries of the matrix).

On Thu, 12 Nov 2015 at 11:08 David Ham <David.Ham@imperial.ac.uk> wrote:
Basically:

d = TrialFunction(D.function_space())
e = TestFunction(D.function_space())

solve(d * e * dx == div(q) * e * dx, D)

One might have to think a little about what value this gives at the boundary, but I think it's OK.

On Thu, 12 Nov 2015 at 11:00 Justin Chang <jychang48@gmail.com> wrote:
Hi all,

Perhaps this may be a simple question, but say I have this bilinear and linear form:

a = grad(u)*D*grad(v)*dx
L = F*v*dx

where u,v is trial/test function on CG1 space, and D and F are coefficients that live in DG0 space.

Say I have a velocity vector function q (CG1) on the same mesh and want D to be the element-wise divergence of said velocity.

How would I formulate D in Firedrake? 

Thanks,
Justin