norm(): expected a GenericVector or GenericFunction

Asked by Nico Schlömer on 2012-12-14

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-perturbation1d.py", line 192, in <module>
    _main()
  File "singular-perturbation1d.py", line 9, in _main
    with_erf()
  File "singular-perturbation1d.py", line 106, in with_erf
    norm_error_l2 = norm(error, norm_type='L2', mesh=mesh)
  File "/home/nschloe/Work/FEniCS/lib/python2.7/site-packages/dolfin/fem/norms.py", line 98, in norm
    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?

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://answers.launchpad.net/dolfin/+question/216785
>
> 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-perturbation1d.py", line 192, in <module>
> _main()
> File "singular-perturbation1d.py", line 9, in _main
> with_erf()
> File "singular-perturbation1d.py", line 106, in with_erf
> norm_error_l2 = norm(error, norm_type='L2', mesh=mesh)
> File "/home/nschloe/Work/FEniCS/lib/python2.7/site-packages/dolfin/fem/norms.py", line 98, in norm
> 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.

To post a message you must log in.