From 40042d125593ff9c27833634a878b7f48e08e93d Mon Sep 17 00:00:00 2001 From: Martin Kronbichler Date: Sat, 13 Jul 2019 16:29:26 +0200 Subject: [PATCH] Add test for 1D mass matrix --- tests/base/polynomial_hermite_like_mass_1d.cc | 53 ++++++++++++ .../polynomial_hermite_like_mass_1d.output | 86 +++++++++++++++++++ 2 files changed, 139 insertions(+) create mode 100644 tests/base/polynomial_hermite_like_mass_1d.cc create mode 100644 tests/base/polynomial_hermite_like_mass_1d.output diff --git a/tests/base/polynomial_hermite_like_mass_1d.cc b/tests/base/polynomial_hermite_like_mass_1d.cc new file mode 100644 index 0000000000..ce90b4639f --- /dev/null +++ b/tests/base/polynomial_hermite_like_mass_1d.cc @@ -0,0 +1,53 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2019 by the deal.II authors +// +// This file is part of the deal.II library. +// +// The deal.II library is free software; you can use it, redistribute +// it, and/or modify it under the terms of the GNU Lesser General +// Public License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// The full text of the license can be found in the file LICENSE.md at +// the top level directory of deal.II. +// +// --------------------------------------------------------------------- + + +// Check the mass matrix of the HermiteLikeInterpolation + +#include +#include + +#include + +#include "../tests.h" + + +int +main() +{ + initlog(); + + for (unsigned int degree = 1; degree < 11; ++degree) + { + auto poly = + Polynomials::HermiteLikeInterpolation::generate_complete_basis(degree); + QGauss<1> quad(degree + 1); + FullMatrix mat(degree + 1, degree + 1); + for (unsigned int i = 0; i < degree + 1; ++i) + for (unsigned int j = 0; j < degree + 1; ++j) + { + double sum = 0; + for (unsigned int q = 0; q < quad.size(); ++q) + sum += poly[i].value(quad.point(q)[0]) * + poly[j].value(quad.point(q)[0]) * quad.weight(q); + if (std::abs(sum) > 1e-15) + mat(i, j) = sum; + } + + deallog << "Mass matrix degree " << degree << std::endl; + mat.print_formatted(deallog.get_file_stream()); + deallog << std::endl; + } +} diff --git a/tests/base/polynomial_hermite_like_mass_1d.output b/tests/base/polynomial_hermite_like_mass_1d.output new file mode 100644 index 0000000000..2c5c01c7e9 --- /dev/null +++ b/tests/base/polynomial_hermite_like_mass_1d.output @@ -0,0 +1,86 @@ + +DEAL::Mass matrix degree 1 +3.333e-01 1.667e-01 +1.667e-01 3.333e-01 +DEAL:: +DEAL::Mass matrix degree 2 +2.000e-01 1.000e-01 3.333e-02 +1.000e-01 1.333e-01 1.000e-01 +3.333e-02 1.000e-01 2.000e-01 +DEAL:: +DEAL::Mass matrix degree 3 +8.333e-02 -4.583e-02 4.167e-03 + 2.881e-01 2.161e-01 -4.583e-02 +-4.583e-02 2.161e-01 2.881e-01 +4.167e-03 -4.583e-02 8.333e-02 +DEAL:: +DEAL::Mass matrix degree 4 +4.762e-02 2.381e-02 -4.762e-03 + 1.587e-01 6.349e-02 -7.937e-02 2.381e-02 + 6.349e-02 4.063e-01 6.349e-02 +2.381e-02 -7.937e-02 6.349e-02 1.587e-01 +-4.762e-03 2.381e-02 4.762e-02 +DEAL:: +DEAL::Mass matrix degree 5 +3.130e-02 -1.780e-03 3.316e-03 -1.271e-02 3.206e-03 + 1.054e-01 5.107e-02 -2.741e-02 3.764e-02 -1.271e-02 +-1.780e-03 5.107e-02 2.975e-01 -2.741e-02 3.316e-03 +3.316e-03 -2.741e-02 2.975e-01 5.107e-02 -1.780e-03 +-1.271e-02 3.764e-02 -2.741e-02 5.107e-02 1.054e-01 +3.206e-03 -1.271e-02 3.316e-03 -1.780e-03 3.130e-02 +DEAL:: +DEAL::Mass matrix degree 6 +2.233e-02 -2.223e-03 3.502e-03 -2.426e-03 7.296e-03 -2.051e-03 + 7.610e-02 4.074e-02 -2.505e-02 1.430e-02 -2.038e-02 7.296e-03 +-2.223e-03 4.074e-02 2.286e-01 1.430e-02 -2.426e-03 +3.502e-03 -2.505e-02 2.463e-01 -2.505e-02 3.502e-03 +-2.426e-03 1.430e-02 2.286e-01 4.074e-02 -2.223e-03 +7.296e-03 -2.038e-02 1.430e-02 -2.505e-02 4.074e-02 7.610e-02 +-2.051e-03 7.296e-03 -2.426e-03 3.502e-03 -2.223e-03 2.233e-02 +DEAL:: +DEAL::Mass matrix degree 7 +1.681e-02 -2.199e-03 3.288e-03 -2.586e-03 1.620e-03 -4.462e-03 1.334e-03 + 5.785e-02 3.289e-02 -2.172e-02 1.425e-02 -8.289e-03 1.205e-02 -4.462e-03 +-2.199e-03 3.289e-02 1.809e-01 -8.289e-03 1.620e-03 +3.288e-03 -2.172e-02 2.054e-01 1.425e-02 -2.586e-03 +-2.586e-03 1.425e-02 2.054e-01 -2.172e-02 3.288e-03 +1.620e-03 -8.289e-03 1.809e-01 3.289e-02 -2.199e-03 +-4.462e-03 1.205e-02 -8.289e-03 1.425e-02 -2.172e-02 3.289e-02 5.785e-02 +1.334e-03 -4.462e-03 1.620e-03 -2.586e-03 3.288e-03 -2.199e-03 1.681e-02 +DEAL:: +DEAL::Mass matrix degree 8 +1.315e-02 -2.024e-03 2.960e-03 -2.486e-03 1.791e-03 -1.090e-03 2.875e-03 -8.936e-04 + 4.559e-02 2.697e-02 -1.860e-02 1.314e-02 -8.805e-03 5.163e-03 -7.598e-03 2.875e-03 +-2.024e-03 2.697e-02 1.466e-01 5.163e-03 -1.090e-03 +2.960e-03 -1.860e-02 1.724e-01 -8.805e-03 1.791e-03 +-2.486e-03 1.314e-02 1.819e-01 1.314e-02 -2.486e-03 +1.791e-03 -8.805e-03 1.724e-01 -1.860e-02 2.960e-03 +-1.090e-03 5.163e-03 1.466e-01 2.697e-02 -2.024e-03 +2.875e-03 -7.598e-03 5.163e-03 -8.805e-03 1.314e-02 -1.860e-02 2.697e-02 4.559e-02 +-8.936e-04 2.875e-03 -1.090e-03 1.791e-03 -2.486e-03 2.960e-03 -2.024e-03 1.315e-02 +DEAL:: +DEAL::Mass matrix degree 9 +1.059e-02 -1.814e-03 2.622e-03 -2.294e-03 1.781e-03 -1.249e-03 7.511e-04 -1.933e-03 6.168e-04 + 3.691e-02 2.245e-02 -1.594e-02 1.179e-02 -8.523e-03 5.763e-03 -3.393e-03 5.033e-03 -1.933e-03 +-1.814e-03 2.245e-02 1.211e-01 -3.393e-03 7.511e-04 +2.622e-03 -1.594e-02 1.460e-01 5.763e-03 -1.249e-03 +-2.294e-03 1.179e-02 1.598e-01 -8.523e-03 1.781e-03 +1.781e-03 -8.523e-03 1.598e-01 1.179e-02 -2.294e-03 +-1.249e-03 5.763e-03 1.460e-01 -1.594e-02 2.622e-03 +7.511e-04 -3.393e-03 1.211e-01 2.245e-02 -1.814e-03 +-1.933e-03 5.033e-03 -3.393e-03 5.763e-03 -8.523e-03 1.179e-02 -1.594e-02 2.245e-02 3.691e-02 +6.168e-04 -1.933e-03 7.511e-04 -1.249e-03 1.781e-03 -2.294e-03 2.622e-03 -1.814e-03 1.059e-02 +DEAL:: +DEAL::Mass matrix degree 10 +8.720e-03 -1.611e-03 2.313e-03 -2.080e-03 1.691e-03 -1.281e-03 8.892e-04 -5.315e-04 1.346e-03 -4.378e-04 + 3.052e-02 1.894e-02 -1.373e-02 1.048e-02 -7.942e-03 5.800e-03 -3.941e-03 2.325e-03 -3.469e-03 1.346e-03 +-1.611e-03 1.894e-02 1.016e-01 2.325e-03 -5.315e-04 +2.313e-03 -1.373e-02 1.248e-01 -3.941e-03 8.892e-04 +-2.080e-03 1.048e-02 1.402e-01 5.800e-03 -1.281e-03 +1.691e-03 -7.942e-03 1.455e-01 -7.942e-03 1.691e-03 +-1.281e-03 5.800e-03 1.402e-01 1.048e-02 -2.080e-03 +8.892e-04 -3.941e-03 1.248e-01 -1.373e-02 2.313e-03 +-5.315e-04 2.325e-03 1.016e-01 1.894e-02 -1.611e-03 +1.346e-03 -3.469e-03 2.325e-03 -3.941e-03 5.800e-03 -7.942e-03 1.048e-02 -1.373e-02 1.894e-02 3.052e-02 +-4.378e-04 1.346e-03 -5.315e-04 8.892e-04 -1.281e-03 1.691e-03 -2.080e-03 2.313e-03 -1.611e-03 8.720e-03 +DEAL:: -- 2.39.5