Re: [firedrake] Poisson equation; homogeneous vs nonhomogeneous
[Re-adding firedrake@imperial.ac.uk]
On 23 Apr 2018, at 08:39, Eric M <eric.malitz@gmail.com> wrote:
But I have a new question, unfortunately: I have a solution u, and I want to take a derivative for use in a W^{1,\infty} norm for example. It doesn't allow for example u.dx(0).dat.data, or grad(u)[0].dat.data.
Aha, there is a confusion here between what is a coefficient in some finite element space, and what is a symbolic expression. You start with u, which is a Function in some finite element space. Now grad(u)[0], or u.dx(0) (these actually produce the same thing) are symbolic expressions. If you want to look at the values, you first need to interpolate (or project) the expression into a suitable finite element space: e.g, if u is in FunctionSpace(mesh, "CG", 2) Then perhaps: VGrad = FunctionSpace(mesh, "DG", 1) gradu = project(grad(u), VGrad) gradu.dat.data[:] ...
Wanted to let you know I figured out the max norm thing (the structures were different sizes and had to play around with the notation a bit). And thanks for your help with the multi-grid.
On Fri, Apr 20, 2018 at 1:07 PM, Eric M <eric.malitz@gmail.com> wrote: Lawrence,
For the attempt to take to an L^{\inf} norm, here are the relevant code snippets:
V = FunctionSpace(mesh, "Lagrange", 2) Sigma = TensorFunctionSpace(mesh, "Lagrange", 2) VS = V * Sigma
sigma00=Function(V) sigma00.interpolate((1+x**2)*exp((x**2+y**2)/2)) sigma01=Function(V) sigma01.interpolate(x*y*exp((x**2+y**2)/2)) sigma10=Function(V) sigma10.interpolate(x*y*exp((x**2+y**2)/2)) sigma11=Function(V) sigma11.interpolate((1+y**2)*exp((x**2+y**2)/2))
sigma_exact=as_tensor([[sigma00,sigma01],[sigma10,sigma11]])
(then solve a mixed problem for solution us)
uk, sigmak = us.split() diff=assemble(sigma_exact-sigmak)
Aha, so you could have done one of two things: Either: sigma_exact = interpolate(sigma_exact, Sigma) diff = assemble(sigma_exact - sigma) Or you could have done: diff = interpolate(sigma_exact - sigmak, V) This does interpolation of expressions at the nodes of V. Whereas the `assemble(sigma_exact - sigmak)` attempts to point wise evaluate the given expression (and only works if all the terms in the expression are Functions in the same function space). Cheers, Lawrence
participants (1)
-
Lawrence Mitchell