Inspecting values of potential function
Dear Firedrakers, I define a potential function on a DG function space (see attached file). Now I would like to inspect the values on my mesh. But when I do a print assemble(psiw).vector().array() I get an error (see below). In contrast evaluating the integral over the facets print assemble(psiw*dS_h) works just fine. How can I inspect the values of the potential function on every grid cell? Thank you! Henrik Error: ValueError: Expression has incompatible function spaces <firedrake.functionspace.FunctionSpace object at 0x7f3c67723390> and <firedrake.functionspace.MixedFunctionSpace object at 0x7f3c67723a50> -- Dipl.-Math. Henrik Büsing Institute for Applied Geophysics and Geothermal Energy E.ON Energy Research Center RWTH Aachen University ------------------------------------------------------ Mathieustr. 10 | Tel +49 (0)241 80 49907 52074 Aachen, Germany | Fax +49 (0)241 80 49889 ------------------------------------------------------ http://www.eonerc.rwth-aachen.de/GGE hbuesing@eonerc.rwth-aachen.de ------------------------------------------------------
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Dear Henrik, On 29/09/15 13:12, Buesing, Henrik wrote:
Dear Firedrakers,
I define a potential function on a DG function space (see attached file). Now I would like to inspect the values on my mesh.
But when I do a
print assemble(psiw).vector().array()
Assembly of an expression like this does a pointwise computation. If I look at the expression for psiw I see that it is: gradpw = (pw('+') - pw('-'))/Delta_h_facet # Define constants rhow = 1000.0 rhon = 200.0 grav = 9.81 # Potential for upwinding diffz = jump(z_func)/Delta_h_facet psiw = gradpw + rhow*grav*diffz This clearly can't be evaluated pointwise in each cell (since it computes jumps over facets). The normal thing to do is to do this weakly. This might be right: u = TrialFunction(W) v = TestFunction(W) pot = Function(W) solve(dot(u, v)*dx == psiw*v[0]('+')*dS_h, pot) print pot.vector().array()
I get an error (see below). In contrast evaluating the integral over the facets
print assemble(psiw*dS_h)
This is fine, because it does the integral to compute a value. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQEcBAEBAgAGBQJWCocpAAoJECOc1kQ8PEYvaH4H/jfn6A7ScJtcd0OWw9IqR+Yy 7VykfJx7Jmb/WUIdEqxS7YUDJPBQnj83Nhj3PYJh3Yscj1qYl0k+1wM5Q1K1CPBI 7XhwNLGPXRbx9gHUVXVZQV7NEnMRngEDLcNJhm2HpBsaKzRhKYu1xughLCf0VG9T MLbgHUgYFJPju4VoJOaUU3UlcPCGot2xESJHv//DDbyotGdGkxK5/9mgNWg1OUw9 366fAnYvNZoXho2IEIfkUKtAFtK/RY2GW5bGCTjlAwIvdYSpz7MnT951q2tjaUjJ tMMEBwhvlUZKyjocBeo/vlcJIEdBlgAk9Qd48NtFeNsZRdAHLPYkH/Xh/8ZOd/Q= =LXZW -----END PGP SIGNATURE-----
-----Ursprüngliche Nachricht----- Von: firedrake-bounces@imperial.ac.uk [mailto:firedrake- bounces@imperial.ac.uk] Im Auftrag von Lawrence Mitchell Gesendet: 29 September 2015 14:42 An: firedrake@imperial.ac.uk Betreff: Re: [firedrake] Inspecting values of potential function
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
Dear Henrik,
On 29/09/15 13:12, Buesing, Henrik wrote:
Dear Firedrakers,
I define a potential function on a DG function space (see attached file). Now I would like to inspect the values on my mesh.
But when I do a
print assemble(psiw).vector().array()
Assembly of an expression like this does a pointwise computation. If I look at the expression for psiw I see that it is:
gradpw = (pw('+') - pw('-'))/Delta_h_facet
# Define constants rhow = 1000.0 rhon = 200.0 grav = 9.81
# Potential for upwinding diffz = jump(z_func)/Delta_h_facet psiw = gradpw + rhow*grav*diffz
This clearly can't be evaluated pointwise in each cell (since it computes jumps over facets). The normal thing to do is to do this weakly. This might be right:
u = TrialFunction(W) v = TestFunction(W) pot = Function(W)
solve(dot(u, v)*dx == psiw*v[0]('+')*dS_h, pot)
print pot.vector().array() [Buesing, Henrik]
solve(dot(u, v)*dx == psiw*jump(v[0])*dS_h, pot) does what I want. Thank you very much! Henrik
I get an error (see below). In contrast evaluating the integral over the facets
print assemble(psiw*dS_h)
This is fine, because it does the integral to compute a value.
-----BEGIN PGP SIGNATURE----- Version: GnuPG v1
iQEcBAEBAgAGBQJWCocpAAoJECOc1kQ8PEYvaH4H/jfn6A7ScJtcd0OWw9IqR+Yy 7VykfJx7Jmb/WUIdEqxS7YUDJPBQnj83Nhj3PYJh3Yscj1qYl0k+1wM5Q1K1CPBI 7XhwNLGPXRbx9gHUVXVZQV7NEnMRngEDLcNJhm2HpBsaKzRhKYu1xughLCf0VG9T MLbgHUgYFJPju4VoJOaUU3UlcPCGot2xESJHv//DDbyotGdGkxK5/9mgNWg1OUw9 366fAnYvNZoXho2IEIfkUKtAFtK/RY2GW5bGCTjlAwIvdYSpz7MnT951q2tjaUjJ tMMEBwhvlUZKyjocBeo/vlcJIEdBlgAk9Qd48NtFeNsZRdAHLPYkH/Xh/8ZOd/Q= =LXZW -----END PGP SIGNATURE-----
_______________________________________________ firedrake mailing list firedrake@imperial.ac.uk<mailto:firedrake@imperial.ac.uk> https://mailman.ic.ac.uk/mailman/listinfo/firedrake
participants (2)
- 
                
                Buesing, Henrik
- 
                
                Lawrence Mitchell