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

Norms over edges

0 votes

Hi everyone,
I am trying to compute norms over edges with bad results.
I need to calculate the $L^2(\partial K)$-norm of a variable already computed (also the $L^\infty$) - K is the single element.
I do not need to make any differences between internal or external edges.
I have tried something like this, but nothing satisfactory happens:

DG = FunctionSpace(mesh, 'DG', 0)
store = Function(DG)
R = #myexpression
store.vector()[:] = assemble(R*w('+')*dS + R*w*ds).array()    #or w('-') or avg(w)?

Can someone help me? What about the $L^\infty$ norm?
Thanks

asked Mar 3, 2015 by nicholas_ FEniCS Novice (310 points)

1 Answer

0 votes

In principle, your approach should work, I have used it with success to compute residual errors over edges. w should be defined as a TestFunction, and I would put "2*avg(w)" in the assembly statement, since as I understand it you want to count every inner edge twice. Also, your last line seems a little suspect to me. You may assemble into your DG function by using

assemble(..., tensor=store.vector())

This example code works for me:

from dolfin import *

mesh = UnitSquareMesh(2,2)
DG = FunctionSpace(mesh, 'DG', 0)
store = Function(DG)
w = TestFunction(DG)

R = Constant(1.0)
assemble(2*R*avg(w)*dS + R*w*ds,store.vector())

plot(store,interactive=True)

To compute the (global) L^{\infty} norm of a Function, you may use

norm(function, 'linf')

If it is not a Function but some ufl Expression, you can interpolate it to a function first.
A question back to you: How do you write LaTeX??

EDIT: I just noticed that my usage of the norm function was wrong, it should rather be

norm(function.vector(), 'linf')
answered Mar 10, 2015 by Gregor Mitscha-Baude FEniCS User (2,280 points)
edited Mar 13, 2015 by Gregor Mitscha-Baude
...