This is a read only copy of the old FEniCS QA forum. Please visit the new QA forum to ask questions

use of `errornorm` function

0 votes

Hi,

I am trying to evaluate the relative error of a computation depending on mesh refinement, so I have two fields u0 and u0_ref, computed on two different meshes (mesh and mesh_ref), with first order Lagrange elements in both computations. It is not clear for me whether there is any difference between using :

V = VectorFunctionSpace(mesh, "Lagrange", 1)
u0_int = interpolate(u0_ref,V)
u0_err = u0 - u0_int
u0_err2 = assemble(inner(u0_err,u0_err)*dx)**0.5

or FEniCS' function :

u0_r = errornorm(u0,u0_ref,mesh = mesh)

I was looking for the source code for error norm but I haven't found it (yet...)

Many thanks in advance !!

asked Mar 9, 2015 by Claire L FEniCS User (2,120 points)

2 Answers

+1 vote
 
Best answer

errornorm is a pure python-implementation. From IPython you can access the source code through errornorm??

answered Mar 9, 2015 by Øyvind Evju FEniCS Expert (17,700 points)
selected Mar 9, 2015 by Claire L

No... But Iit is true that I can get a description through :

from dolfin import *
help (errornorm)

I would like to have more details on errornorm function though.

Not help(errornorm), but errornorm??

Actually, it works exactly as Øyvind wrote: in IPython, you can call

from dolfin import *
errornorm??

and it tells you the location as well as the source code of the file!

Yes it works, I will have a look through it, thanks !

0 votes

There is a detailed discussion of the merits of using errornorm in the Fenics Tutorial. It is demonstrated there that using your approach, in some cases one even gets wrong convergence rates for the error.

To find the source code, I just proceeded as follows:
-) Go to the online Programmer's Reference for Dolfin (Python)
-) Using your Browser (e.g. Ctrl+F), find "errornorm"
-) It tells you that errornorm is located in dolfin.fem.norms
-) Accordingly, on your computer, there should be some file */dolfin/fem/norms.py
(e.g. if you downloaded and unzipped the source code from bitbucket, you have it in Downloads/dolfin-1.5.0/site-packages/dolfin/fem/norms.py)
-) Indeed, in this file we have the function errornorm!

answered Mar 9, 2015 by Gregor Mitscha-Baude FEniCS User (2,280 points)
...