From: Martin Kronbichler Date: Fri, 17 Feb 2017 10:25:47 +0000 (+0100) Subject: Add test for mg transfer X-Git-Tag: v8.5.0-rc1~106^2~1 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=668018d3edd724266c796ad2d7ab183dac270b48;p=dealii.git Add test for mg transfer --- diff --git a/tests/multigrid/transfer_matrix_free_08.cc b/tests/multigrid/transfer_matrix_free_08.cc new file mode 100644 index 0000000000..f579803a63 --- /dev/null +++ b/tests/multigrid/transfer_matrix_free_08.cc @@ -0,0 +1,115 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2016 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 at +// the top level of the deal.II distribution. +// +// --------------------------------------------------------------------- + + +// Check MGTransferMatrixFree for high polynomial degrees beyond 10 by +// checking a linear function that gets prolongated between the mesh +// levels. Since the function is linear, it should be exactly represented on +// the finest level. Then also look into the result of restriction + +#include "../tests.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +template +void check(const FiniteElement &fe) +{ + deallog.threshold_double(std::max(1e2*(double)std::numeric_limits::epsilon(), + 1e-11)); + deallog << "FE: " << fe.get_name() << std::endl; + + // run a few different sizes... + + Triangulation tr(Triangulation::limit_level_difference_at_vertices); + GridGenerator::hyper_cube(tr); + tr.refine_global(2); + + Triangulation trcoarse(Triangulation::limit_level_difference_at_vertices); + GridGenerator::hyper_cube(trcoarse); + DoFHandler dofcoarse(trcoarse); + dofcoarse.distribute_dofs(fe); + Tensor<1,dim> exponents_monomial; + for (unsigned int d=0; d vrefcoarse; + vrefcoarse.reinit(dofcoarse.n_dofs()); + VectorTools::interpolate(dofcoarse, Functions::Monomial(exponents_monomial), vrefcoarse); + + deallog << "no. cells: " << tr.n_global_active_cells() << std::endl; + + DoFHandler mgdof(tr); + mgdof.distribute_dofs(fe); + mgdof.distribute_mg_dofs(fe); + + // build matrix-free transfer + MGTransferMatrixFree transfer; + transfer.build(mgdof); + + LinearAlgebra::distributed::Vector vrefdouble; + LinearAlgebra::distributed::Vector vref; + AssertDimension(mgdof.n_dofs(tr.n_global_levels()-1), mgdof.n_dofs()); + vrefdouble.reinit(mgdof.n_dofs()); + VectorTools::interpolate(mgdof, Functions::Monomial(exponents_monomial), vrefdouble); + + vref.reinit(mgdof.n_dofs()); + vref = vrefdouble; + std::vector > vec(tr.n_global_levels()); + for (unsigned int level=0; level 0 ; --level) + transfer.restrict_and_add(level, vec[level-1], vec[level]); + deallog << "Norm after restriction: " << vec[0].l2_norm() << std::endl; +} + + +int main(int argc, char **argv) +{ + // no threading in this test... + Utilities::MPI::MPI_InitFinalize mpi(argc, argv, 1); + mpi_initlog(); + + check<2,double>(FE_DGQ<2>(3)); + check<2,double>(FE_DGQ<2>(8)); + check<2,double>(FE_DGQ<2>(16)); + check<2,double>(FE_Q<2>(16)); + check<3,double>(FE_DGQ<3>(11)); + check<2,float> (FE_DGQ<2>(3)); + check<2,float> (FE_DGQ<2>(8)); + check<2,float> (FE_DGQ<2>(16)); + check<2,float> (FE_Q<2>(16)); + check<3,float> (FE_DGQ<3>(11)); +} diff --git a/tests/multigrid/transfer_matrix_free_08.output b/tests/multigrid/transfer_matrix_free_08.output new file mode 100644 index 0000000000..bfb4799c28 --- /dev/null +++ b/tests/multigrid/transfer_matrix_free_08.output @@ -0,0 +1,41 @@ + +DEAL::FE: FE_DGQ<2>(3) +DEAL::no. cells: 16 +DEAL::Error after prolongation: 0 +DEAL::Norm after restriction: 34.1210 +DEAL::FE: FE_DGQ<2>(8) +DEAL::no. cells: 16 +DEAL::Error after prolongation: 0 +DEAL::Norm after restriction: 71.6678 +DEAL::FE: FE_DGQ<2>(16) +DEAL::no. cells: 16 +DEAL::Error after prolongation: 0 +DEAL::Norm after restriction: 151.607 +DEAL::FE: FE_Q<2>(16) +DEAL::no. cells: 16 +DEAL::Error after prolongation: 0 +DEAL::Norm after restriction: 133.734 +DEAL::FE: FE_DGQ<3>(11) +DEAL::no. cells: 64 +DEAL::Error after prolongation: 0 +DEAL::Norm after restriction: 774.120 +DEAL::FE: FE_DGQ<2>(3) +DEAL::no. cells: 16 +DEAL::Error after prolongation: 0 +DEAL::Norm after restriction: 34.1210 +DEAL::FE: FE_DGQ<2>(8) +DEAL::no. cells: 16 +DEAL::Error after prolongation: 0 +DEAL::Norm after restriction: 71.6678 +DEAL::FE: FE_DGQ<2>(16) +DEAL::no. cells: 16 +DEAL::Error after prolongation: 0 +DEAL::Norm after restriction: 151.607 +DEAL::FE: FE_Q<2>(16) +DEAL::no. cells: 16 +DEAL::Error after prolongation: 0 +DEAL::Norm after restriction: 133.734 +DEAL::FE: FE_DGQ<3>(11) +DEAL::no. cells: 64 +DEAL::Error after prolongation: 0 +DEAL::Norm after restriction: 774.120