From fbc4b3845b71ba540a0f1286c077e318239e4bd2 Mon Sep 17 00:00:00 2001 From: "Dennis.Glaeser" <dennis.glaeser@iws.uni-stuttgart.de> Date: Mon, 17 Jun 2019 14:45:59 +0200 Subject: [PATCH] [test][l2norm] test grid function integration --- test/common/functions/test_function_l2norm.cc | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/test/common/functions/test_function_l2norm.cc b/test/common/functions/test_function_l2norm.cc index 25ce705c41..0133463e1b 100644 --- a/test/common/functions/test_function_l2norm.cc +++ b/test/common/functions/test_function_l2norm.cc @@ -52,7 +52,21 @@ int main (int argc, char *argv[]) try // a quadratic function on the grid auto f = [&] (const auto& pos) -> R { return {pos.two_norm2(), pos[0]*pos[0]*pos[1]}; }; - // make bases + // test Dumux::integrateGridFunction with unit function + auto basisUnit = makeBasis(gvFine, lagrange<1>()); + + using RUnit = Dune::FieldVector<double, 1>; + Dune::BlockVector< RUnit > solUnit; + interpolate(basisUnit, solUnit, [&] (const auto& pos) { return 1.0; }); + + auto gfUnit = makeDiscreteGlobalBasisFunction<RUnit>(basisUnit, solUnit); + auto integral = Dumux::integrateGridFunction(gvFine, gfUnit, 1); + + using std::abs; + if ( abs(integral - 1.0) > 1e-13) + DUNE_THROW(Dune::MathError, "Integral of grid function is not 1 (error = " << abs(integral - 1.0) << ")"); + + // test Dumux::integrateL2Error SolutionVector solCoarse, solFine; interpolate(makeBasis(gvCoarse, power<2>(lagrange<2>())), solCoarse, f); interpolate(makeBasis(gvFine, power<2>(lagrange<2>())), solFine, f); -- GitLab