how to compute W_{1,\infty} semi-norm

Asked by Huadong GAO

    I do not know how to compute the W_{1,\infty} semi-norm a finite solution with FEniCS.
For example I solve a standard elliptic equation as below, and I get
the solution u, now I want to compute L-inf norm of du/dx and du/dy.

    I cannot make sure I am correct, any help is great apprieciated.

#-----------------------------
from dolfin import *

mesh = UnitSquareMesh(100, 100)
V = FunctionSpace(mesh, "CG", 1)

def boundary(x):
    return x[0] < DOLFIN_EPS or x[0] > 1.0 - DOLFIN_EPS

u0 = Constant(0.0)
bc = DirichletBC(V, u0, boundary)

u = TrialFunction(V)
v = TestFunction(V)
f = Expression("10*exp(-(pow(x[0] - 0.5, 2) + pow(x[1] - 0.5, 2)) / 0.02)")
g = Expression("sin(5*x[0])")
a = inner(grad(u), grad(v))*dx
L = f*v*dx + g*v*ds

u = Function(V)
solve(a == L, u, bc)

#-----------------------------------
# compute the W_{1,\infty} semi-norm
#-----------------------------------
A = project(grad(u),VectorFunctionSpace(mesh, "CG", 1))
ux , uy = A.split(deepcopy=True)
tempx = norm(ux.vector(),'linf',mesh)
tempy = norm(uy.vector(),'linf',mesh)
linf = max(tempx,tempy)
print linf
#-----------------------------------

Question information

Language:
English Edit question
Status:
Solved
For:
DOLFIN Edit question
Assignee:
No assignee Edit question
Solved by:
Jan Blechta
Solved:
Last query:
Last reply:
Revision history for this message
Best Jan Blechta (blechta) said :
#1

Gradient of CG1 function is DG0 vector function. Also you don't need to deepcopy components.

u = Function(FunctionSpace(mesh, "CG", 1))
A = project(grad(u), VectorFunctionSpace(mesh, "DG", 0))
linf = norm(A.vector(), 'linf')

Revision history for this message
Huadong GAO (mathsgao) said :
#2

Thanks Jan Blechta, that solved my question.