Behavior of the norm function

Hello

I’m trying to understand the behavior of the norm function in dolfin.

Given a mixed vector function space, I compute a vector function, say U.

If I want to find its norm, what is the difference between norm(U) and norm(U.vector())? Both give me different results and I’m trying to understand why.

Thank you!

It sounds like you may be confusing two different notions of “vector” here. The functions in a VectorFunctionSpace are vector-valued, in the sense that they evaluate to a vector at each point in the domain. However, functions in finite element function spaces can be represented as vectors of coefficients scaling each basis function (e.g., a list of nodal values in a Lagrange finite element space). U.vector() refers to the latter notion of “vector”.

The function norm is overloaded to have different behaviors when given a function or a vector as its argument. If the norm of a Function is computed, it returns some Sobolev norm, defaulting to L^2, but optionally specified by a second string argument, as illustrated below:

from dolfin import *
mesh = UnitIntervalMesh(10)
V = VectorFunctionSpace(mesh,"CG",1,dim=2)
x = SpatialCoordinate(mesh)
u = project(as_vector((sin(pi*x[0]),cos(pi*x[0]))),V)
print(norm(u))
print(sqrt(assemble(inner(u,u)*dx)))
print(norm(u,"H1"))
print(sqrt(assemble((inner(u,u) + inner(grad(u),grad(u)))*dx)))

If a vector is passed, norm computes some algebraic norm of the vector, defaulting, if I recall, to the Euclidean (or \ell^2) norm, i.e., the square root of the sum of the squares of the components.

1 Like

Thanks for your reply!

I understand what you said but I guess its still a bit hazy for me. Say, I have a function in a VectorFunctionSpace, which as you said would be vector-valued at each point. Let’s say this function is a velocity vector, U.

Suppose I want to normalize the velocity vector by its own norm, am I right in thinking that I will need to use “norm(U.vector())” as the dividing factor ?

I’m asking because the norm of a vector field could have multiple definitions (even the L2 norm) based on local L2 norms, Frobenius norms etc.

You must distinguish between the local norm of your physical vectorial field and its global norm when considering it as a vector of degrees of freedom. I think you are referring to the former so U_normalized = U/sqrt(dot(U, U)) is a normalized vectorial field.
The Froebenius norm is a norm on matrices, I don’t see how the L2 norm can have different definitions…

Gotcha, that makes sense. Thanks!