25#ifndef DUMUX_TEST_L2_NORM_HH
26#define DUMUX_TEST_L2_NORM_HH
30#include <dune/geometry/quadraturerules.hh>
41 template<
class Problem,
class Solution>
48 const auto& gg = problem.gridGeometry();
49 for (
const auto& element : elements(gg.gridView()))
51 const auto geometry = element.geometry();
52 const auto center = geometry.center();
56 static const bool excludeInnerBulk = getParam<bool>(
"Problem.NormExcludeInnerBulk");
57 static const Scalar radius = getParam<Scalar>(
"SpatialParams.Radius") + 0.01;
58 using GridView = std::decay_t<
decltype(gg.gridView())>;
59 if (
int(GridView::dimension) == 3 && excludeInnerBulk && std::sqrt(center[0]*center[0] + center[1]*center[1]) < radius)
62 const auto& quad = Dune::QuadratureRules<Scalar, GridView::dimension>::rule(geometry.type(), order);
65 const auto globalPos = geometry.global(qp.position());
66 const Scalar pe = problem.exactSolution(globalPos);
67 const Scalar p =
evalSolution(element, geometry, gg, elemSol, globalPos)[0];
68 norm += (p - pe)*(p - pe)*qp.weight()*geometry.integrationElement(qp.position());
72 return std::sqrt(norm);
75 template<
class Problem>
82 const auto& gg = problem.gridGeometry();
83 for (
const auto& element : elements(gg.gridView()))
85 const auto geometry = element.geometry();
86 const auto center = geometry.center();
89 static const bool excludeInnerBulk = getParam<bool>(
"Problem.NormExcludeInnerBulk");
90 static const Scalar radius = getParam<Scalar>(
"SpatialParams.Radius") + 0.01;
91 using GridView = std::decay_t<
decltype(gg.gridView())>;
92 if (
int(GridView::dimension) == 3 && excludeInnerBulk && std::sqrt(center[0]*center[0] + center[1]*center[1]) < radius)
95 const auto& quad = Dune::QuadratureRules<Scalar, GridView::dimension>::rule(geometry.type(), order);
98 const auto globalPos = geometry.global(qp.position());
99 const Scalar pe = problem.exactSolution(globalPos);
100 norm += pe*pe*qp.weight()*geometry.integrationElement(qp.position());
104 return std::sqrt(norm);
The infrastructure to retrieve run-time parameters from Dune::ParameterTrees.
Element solution classes and factory functions.
free functions for the evaluation of primary variables inside elements.
PrimaryVariables evalSolution(const Element &element, const typename Element::Geometry &geometry, const typename FVElementGeometry::GridGeometry &gridGeometry, const BoxElementSolution< FVElementGeometry, PrimaryVariables > &elemSol, const typename Element::Geometry::GlobalCoordinate &globalPos, bool ignoreState=false)
Interpolates a given box element solution at a given global position. Uses the finite element cache o...
Definition: evalsolution.hh:95
auto elementSolution(const Element &element, const SolutionVector &sol, const GridGeometry &gg) -> std::enable_if_t< GridGeometry::discMethod==DiscretizationMethod::box, BoxElementSolution< typename GridGeometry::LocalView, std::decay_t< decltype(std::declval< SolutionVector >()[0])> > >
Make an element solution for box schemes.
Definition: box/elementsolution.hh:115
make the local view function available whenever we use the grid geometry
Definition: adapt.hh:29
static Scalar computeErrorNorm(const Problem &problem, const Solution &sol, int order)
Calculate the L2-Norm of the solution and hmax of the grid.
Definition: l2norm.hh:42
static Scalar computeNormalization(const Problem &problem, int order)
Definition: l2norm.hh:76