From ee41be3b092cd9d83b4595373f7b6b9a1b9df239 Mon Sep 17 00:00:00 2001 From: Tobias Leibner <tobias.leibner@googlemail.com> Date: Thu, 18 Jul 2019 08:56:27 +0200 Subject: [PATCH] [momentmodels] some fixes, new tests --- ...bolic__momentmodels__entropic_coords_mn.cc | 2 - ...omentmodels__mn_1dhatfunctions_analytic.cc | 30 ++++++++++++++ ...bolic__momentmodels__mn_nochangeofbasis.cc | 39 +++++++++++++++++++ dune/gdt/test/mn-discretization.hh | 8 ++-- .../entropyflux_implementations.hh | 4 +- 5 files changed, 75 insertions(+), 8 deletions(-) create mode 100644 dune/gdt/test/hyperbolic__momentmodels__mn_1dhatfunctions_analytic.cc create mode 100644 dune/gdt/test/hyperbolic__momentmodels__mn_nochangeofbasis.cc diff --git a/dune/gdt/test/hyperbolic__momentmodels__entropic_coords_mn.cc b/dune/gdt/test/hyperbolic__momentmodels__entropic_coords_mn.cc index 217629bbe..4975efe32 100644 --- a/dune/gdt/test/hyperbolic__momentmodels__entropic_coords_mn.cc +++ b/dune/gdt/test/hyperbolic__momentmodels__entropic_coords_mn.cc @@ -8,8 +8,6 @@ // This one has to come first (includes the config.h)! #include <dune/xt/common/test/main.hxx> -#define USE_LP_POSITIVITY_LIMITER 1 - #include <dune/gdt/test/momentmodels/kinetictransport/testcases.hh> #include <dune/gdt/test/entropic-coords-mn-discretization.hh> diff --git a/dune/gdt/test/hyperbolic__momentmodels__mn_1dhatfunctions_analytic.cc b/dune/gdt/test/hyperbolic__momentmodels__mn_1dhatfunctions_analytic.cc new file mode 100644 index 000000000..b5b07189b --- /dev/null +++ b/dune/gdt/test/hyperbolic__momentmodels__mn_1dhatfunctions_analytic.cc @@ -0,0 +1,30 @@ +// This file is part of the dune-gdt project: +// https://github.com/dune-community/dune-gdt +// Copyright 2010-2016 dune-gdt developers and contributors. All rights reserved. +// License: BSD 2-Clause License (http://opensource.org/licenses/BSD-2-Clause) +// Authors: +// Tobias Leibner (2016) + +#define ENTROPY_FLUX_1D_HATFUNCTIONS_USE_ANALYTICAL_INTEGRALS 1 + +// This one has to come first (includes the config.h)! +#include <dune/xt/common/test/main.hxx> + +#include <dune/gdt/test/momentmodels/kinetictransport/testcases.hh> +#include <dune/gdt/test/mn-discretization.hh> + +using Yasp1 = Dune::YaspGrid<1, Dune::EquidistantOffsetCoordinates<double, 1>>; +using Yasp2 = Dune::YaspGrid<2, Dune::EquidistantOffsetCoordinates<double, 2>>; +using Yasp3 = Dune::YaspGrid<3, Dune::EquidistantOffsetCoordinates<double, 3>>; + +using YaspGridTestCases1dHatAnalytic = testing::Types< + Dune::GDT::SourceBeamMnTestCase<Yasp1, Dune::GDT::HatFunctionMomentBasis<double, 1, double, 8, 1, 1>, false>, + Dune::GDT::PlaneSourceMnTestCase<Yasp1, Dune::GDT::HatFunctionMomentBasis<double, 1, double, 8, 1, 1>, false>, + Dune::GDT::SourceBeamMnTestCase<Yasp1, Dune::GDT::HatFunctionMomentBasis<double, 1, double, 8, 1, 1>, true>, + Dune::GDT::PlaneSourceMnTestCase<Yasp1, Dune::GDT::HatFunctionMomentBasis<double, 1, double, 8, 1, 1>, true>>; + +TYPED_TEST_CASE(HyperbolicMnTest, YaspGridTestCases1dHatAnalytic); +TYPED_TEST(HyperbolicMnTest, check) +{ + this->run(1e-3); +} diff --git a/dune/gdt/test/hyperbolic__momentmodels__mn_nochangeofbasis.cc b/dune/gdt/test/hyperbolic__momentmodels__mn_nochangeofbasis.cc new file mode 100644 index 000000000..1e6fde3b7 --- /dev/null +++ b/dune/gdt/test/hyperbolic__momentmodels__mn_nochangeofbasis.cc @@ -0,0 +1,39 @@ +// This file is part of the dune-gdt project: +// https://github.com/dune-community/dune-gdt +// Copyright 2010-2016 dune-gdt developers and contributors. All rights reserved. +// License: BSD 2-Clause License (http://opensource.org/licenses/BSD-2-Clause) +// Authors: +// Tobias Leibner (2016) + +#define ENTROPY_FLUX_UNSPECIALIZED_USE_ADAPTIVE_CHANGE_OF_BASIS 0 + +// This one has to come first (includes the config.h)! +#include <dune/xt/common/test/main.hxx> + +#include <dune/gdt/test/momentmodels/kinetictransport/testcases.hh> +#include <dune/gdt/test/mn-discretization.hh> + +using Yasp1 = Dune::YaspGrid<1, Dune::EquidistantOffsetCoordinates<double, 1>>; +using Yasp3 = Dune::YaspGrid<3, Dune::EquidistantOffsetCoordinates<double, 3>>; + +using YaspGridTestCasesNoBasisChange = testing::Types< +#if HAVE_CLP + Dune::GDT::SourceBeamMnTestCase<Yasp1, Dune::GDT::LegendreMomentBasis<double, double, 7>, false>, + Dune::GDT::SourceBeamMnTestCase<Yasp1, Dune::GDT::LegendreMomentBasis<double, double, 7>, true>, +#endif + Dune::GDT::SourceBeamMnTestCase<Yasp1, Dune::GDT::HatFunctionMomentBasis<double, 1, double, 8, 1, 1>, false>, + Dune::GDT::SourceBeamMnTestCase<Yasp1, Dune::GDT::HatFunctionMomentBasis<double, 1, double, 8, 1, 1>, true> +#if !DXT_DISABLE_LARGE_TESTS + , +# if HAVE_CLP + Dune::GDT::PointSourceMnTestCase<Yasp3, Dune::GDT::RealSphericalHarmonicsMomentBasis<double, double, 2, 3>, false>, +# endif + Dune::GDT::PointSourceMnTestCase<Yasp3, Dune::GDT::HatFunctionMomentBasis<double, 3, double, 0, 1, 3>, false> +#endif + >; + +TYPED_TEST_CASE(HyperbolicMnTest, YaspGridTestCasesNoBasisChange); +TYPED_TEST(HyperbolicMnTest, check) +{ + this->run(); +} diff --git a/dune/gdt/test/mn-discretization.hh b/dune/gdt/test/mn-discretization.hh index 5df56da73..96f8a8511 100644 --- a/dune/gdt/test/mn-discretization.hh +++ b/dune/gdt/test/mn-discretization.hh @@ -239,7 +239,7 @@ struct HyperbolicMnTest : public HyperbolicMnDiscretization<TestCaseType> , public ::testing::Test { - void run() + void run(const double tol = TestCaseType::ExpectedResultsType::tol) { auto norms = HyperbolicMnDiscretization<TestCaseType>::run( 1, @@ -256,9 +256,9 @@ struct HyperbolicMnTest const double l2norm = norms[1]; const double linfnorm = norms[2]; using ResultsType = typename TestCaseType::ExpectedResultsType; - EXPECT_NEAR(ResultsType::l1norm, l1norm, ResultsType::l1norm * ResultsType::tol); - EXPECT_NEAR(ResultsType::l2norm, l2norm, ResultsType::l2norm * ResultsType::tol); - EXPECT_NEAR(ResultsType::linfnorm, linfnorm, ResultsType::linfnorm * ResultsType::tol); + EXPECT_NEAR(ResultsType::l1norm, l1norm, ResultsType::l1norm * tol); + EXPECT_NEAR(ResultsType::l2norm, l2norm, ResultsType::l2norm * tol); + EXPECT_NEAR(ResultsType::linfnorm, linfnorm, ResultsType::linfnorm * tol); } }; diff --git a/dune/gdt/test/momentmodels/entropyflux_implementations.hh b/dune/gdt/test/momentmodels/entropyflux_implementations.hh index 9fe26b7a0..eeaac7a58 100644 --- a/dune/gdt/test/momentmodels/entropyflux_implementations.hh +++ b/dune/gdt/test/momentmodels/entropyflux_implementations.hh @@ -1265,7 +1265,7 @@ public: // if rescale is true, working storage already contains the eta_ast_prime evaluations due to the call to // calculate_u above if (!rescale) - evaluate_eta_ast_prime(eta_ast_prime_vals); + evaluate_eta_ast_prime(alpha_prime, M_, eta_ast_prime_vals); if (first_error_cond < tau_prime && 1 - epsilon_gamma_ < second_error_cond && (entropy == EntropyType::MaxwellBoltzmann || all_positive(eta_ast_prime_vals)) && (disable_realizability_check_ @@ -4124,7 +4124,7 @@ public: // if rescale is true, working storage already contains the eta_ast_prime evaluations due to the call to // calculate_u above if (!rescale) - evaluate_eta_ast_prime(eta_ast_prime_vals); + evaluate_eta_ast_prime(alpha_prime, eta_ast_prime_vals); // checking realizability is cheap so we do not need the second stopping criterion if (g_k.two_norm() < tau_prime && is_realizable(u_eps_diff) && (entropy == EntropyType::MaxwellBoltzmann || all_positive(eta_ast_prime_vals))) { -- GitLab