Dear Will,

Make a Function for outputting; e.g.

energy_fn = Function(R)  [if you want to output in the function space R]

Then do

energy_fn.interpolate(dot(u, u) + rho*rho)  [for interpolation]

or

energy_fn.project(dot(u, u) + rho*rho)  [for L^2 projection]

followed by

localenergyfile.write(energy_fn, time=t)

Apologies for any typos in the above.

Thanks,
Andrew

On 3 May 2016 at 14:00, William Booker <scwb@leeds.ac.uk> wrote:

Dear Firedrakers,


For the model,

https://github.com/booker213/compressible_acoustic/blob/master/Firedrake/1D/compressible_acoustic.py

I'm interested in finding out how the energy in my system is distributed at the end of my model.

My naive approach, below, was to try and create a function, so I could visualise it.



localenergyfile = File('./Results/local_energy.pvd')
E_local = Function(R, name="Local Energy")
E_local = 0.5*(inner(u,u) + rho**2
localenergyfile.write(E_local , time =t)


But this does not work. How would I go about implementing this?

Regards,

Will