# norm(): expected a GenericVector or GenericFunction

I'd like to compute the discretization error of a PDE in the L2 and LInf norm.

To this end, I stitched together a PDE of which I know the exact solution exact_sol (given as an Expression) and calculate the numerical solution numerical_sol. Then

norm(exact_sol - numerical_sol, norm_type='L2', mesh=mesh)

fails with the error message

=============== *snip* ===============

Traceback (most recent call last):

File "singular-

_main()

File "singular-

with_erf()

File "singular-

norm_error_l2 = norm(error, norm_type='L2', mesh=mesh)

File "/home/

raise TypeError, "expected a GenericVector or GenericFunction"

TypeError: expected a GenericVector or GenericFunction

=============== *snap* ===============

I *can* compute

norm(exact_sol, norm_type='L2', mesh=mesh)

norm(

without problems.

What am I missing here?

Also: What does

norm(exact_sol, norm_type='L2', mesh=mesh)

do? Does it actually do symbolic integration of the expression exact_sol over the mesh, is it silently projected to a more generic function space, or are some quadrature rules applied?

## Question information

- Language:
- English Edit question

- Status:
- Answered

- For:
- DOLFIN Edit question

- Assignee:
- No assignee Edit question

- Last query:

- Last reply:

Does it work with errornorm instead of norm?

Best regards

Mikael

Den Dec 14, 2012 kl. 12:31 PM skrev Nico Schlömer:

> New question #216785 on DOLFIN:

> https:/

>

> I'd like to compute the discretization error of a PDE in the L2 and LInf norm.

> To this end, I stitched together a PDE of which I know the exact solution exact_sol (given as an Expression) and calculate the numerical solution numerical_sol. Then

>

> norm(exact_sol - numerical_sol, norm_type='L2', mesh=mesh)

>

> fails with the error message

>

> =============== *snip* ===============

> Traceback (most recent call last):

> File "singular-

> _main()

> File "singular-

> with_erf()

> File "singular-

> norm_error_l2 = norm(error, norm_type='L2', mesh=mesh)

> File "/home/

> raise TypeError, "expected a GenericVector or GenericFunction"

> TypeError: expected a GenericVector or GenericFunction

> =============== *snap* ===============

>

> I *can* compute

>

> norm(exact_sol, norm_type='L2', mesh=mesh)

> norm(numerical_sol, norm_type='L2', mesh=mesh)

>

> without problems.

> What am I missing here?

>

> Also: What does

> norm(exact_sol, norm_type='L2', mesh=mesh)

> do? Does it actually do symbolic integration of the expression exact_sol over the mesh, is it silently projected to a more generic function space, or are some quadrature rules applied?

>

> --

> You received this question notification because you are a member of

> DOLFIN Team, which is an answer contact for DOLFIN.

## Can you help with this problem?

Provide an answer of your own, or ask Nico Schlömer for more information if necessary.