What can I do to calculate the L2 norm between the exact solution and my numerical solution?

An example is given at the end of this tutorial.

I think you need something like sum(abs2(T - uₕ) * dΩ), though in the tutorial it first projects the analytical solution into the FEM basis. In general, if you want to compose an arbitrary function f with a cell field u, you need to use f ∘ u, e.g. (x -> x^2) ∘ uₕ. But a specialized CellField method is already defined for abs2.

1 Like