Re: [firedrake] Poisson equation; homogeneous vs nonhomogeneous
[re-adding firedrake to CC]
On 17 Apr 2018, at 20:56, Eric M <eric.malitz@gmail.com> wrote:
Thanks for the tips. For a scalar function I think I wrote diff=u-g; max(abs(diff.dat.data)) for instance. Can this be done for sigmak-sigma? I tried to do it with the components individually and it didn’t work.
You should be able to do: diff = assemble(sigmak - sigma) and then diff.dat.data should give you the point wise difference. What doesn't work?
On Apr 17, 2018, at 8:14 AM, Lawrence Mitchell <lawrence.mitchell@imperial.ac.uk> wrote:
Hi Eric,
On 17/04/18 04:14, Eric M wrote: Sorry, hit send too soon;
I am coding a mixed problem where the unknowns are the scalar function u and a Hessian D^2u.
Among the things I specify are the function spaces:
V = FunctionSpace(mesh, "Lagrange", 2) Sigma = TensorFunctionSpace(mesh, "Lagrange", 2) VS = V * Sigma
I specify some exact solutions:
u = Expression("exp((x[0]*x[0] + x[1]*x[1])/2)") u = Function(V).interpolate(u) sigma00expr= Expression(' (1+x[0]*x[0])*exp((x[0]*x[0]+x[1]*x[1])/2) ' ,degree=5) sigma01expr= Expression('x[0]*x[1]*exp((x[0]*x[0]+x[1]*x[1])/2) ' ,degree=5) sigma10expr= Expression(' x[0]*x[1]*exp((x[0]*x[0]+x[1]*x[1])/2) ' ,degree=5) sigma11expr= Expression(' (1+x[1]*x[1])*exp((x[0]*x[0]+x[1]*x[1])/2) ' ,degree=5)
So I would write these using UFL expressions, and then glue them together into a tensor:
x, y = SpatialCoordinate(mesh)
sigma00 = (1 + x**2)*exp((x**2 + y**2)/2) sigma01 = ...
etc...
Then you can write:
sigma = as_tensor([[sigma00, sigma01], [sigma10, sigma11]])
...
And solve it:
solve(a == L, us, bcs=bcs, solver_parameters=sp_it) uk, sigmak = us.split()
Now I analyze uk in L2, H1, etc. error norms. But I can't figure out how to analyze sigmak, that is, extract the components to put in error norms. but this doesn't work here.
Now you can write:
diff = sigmak - sigma
and then L2norm = norm(diff, norm_type="L2")
Even then, once I extract, say, sigmak00, how do I do for example: L2 norm of sigmak - sigma and L^infinity norm of sigmak - sigma ?
There's no builtin functionality for computing Linf norms, because they are tricky!
Hope this helps.
Lawrence
participants (1)
- 
                
                Lawrence Mitchell