From ecc9bf0216a9981849e20af5f2a964004da51fcd Mon Sep 17 00:00:00 2001 From: tcclevenger Date: Mon, 8 Jun 2020 14:28:17 -0400 Subject: [PATCH] add test --- doc/news/changes/minor/20200605Roth | 3 +- tests/multigrid/transfer_matrix_free_13.cc | 23 +++-- .../multigrid/transfer_matrix_free_13.output | 6 ++ tests/multigrid/transfer_prebuilt_05.cc | 98 +++++++++++++++++++ tests/multigrid/transfer_prebuilt_05.output | 13 +++ 5 files changed, 132 insertions(+), 11 deletions(-) create mode 100644 tests/multigrid/transfer_prebuilt_05.cc create mode 100644 tests/multigrid/transfer_prebuilt_05.output diff --git a/doc/news/changes/minor/20200605Roth b/doc/news/changes/minor/20200605Roth index c5086e6e8f..eb48afd0e3 100644 --- a/doc/news/changes/minor/20200605Roth +++ b/doc/news/changes/minor/20200605Roth @@ -1,4 +1,5 @@ New: Applying user constraints before prolongation in MGTransferPrebuilt.
-(Julian Roth, 2020/06/05) +(Julian Roth and Conrad Clevenger, 2020/06/05) + diff --git a/tests/multigrid/transfer_matrix_free_13.cc b/tests/multigrid/transfer_matrix_free_13.cc index c3954e918d..f677a4e5f3 100644 --- a/tests/multigrid/transfer_matrix_free_13.cc +++ b/tests/multigrid/transfer_matrix_free_13.cc @@ -69,20 +69,23 @@ check() user_constraints.close(); mg_constrained_dofs.add_user_constraints(0, user_constraints); - // build matrix-free transfer - MGTransferMatrixFree transfer(mg_constrained_dofs); - transfer.build(mgdof); + MGTransferMatrixFree transfer_mf(mg_constrained_dofs); + transfer_mf.build(mgdof); + deallog << "SRC Vector" << std::endl; LinearAlgebra::distributed::Vector src_level_0(mgdof.n_dofs(0)); for (unsigned int i = 0; i < mgdof.n_dofs(0); ++i) deallog << src_level_0(i) << " "; - deallog << std::endl; - - LinearAlgebra::distributed::Vector dst_level_1(mgdof.n_dofs(1)); - transfer.prolongate(1, dst_level_1, src_level_0); - for (unsigned int i = 0; i < mgdof.n_dofs(1); ++i) - deallog << dst_level_1(i) << " "; - deallog << std::endl; + deallog << std::endl << std::endl; + + { + LinearAlgebra::distributed::Vector dst_level_1(mgdof.n_dofs(1)); + transfer_mf.prolongate(1, dst_level_1, src_level_0); + deallog << "DST Vector" << std::endl; + for (unsigned int i = 0; i < mgdof.n_dofs(1); ++i) + deallog << dst_level_1(i) << " "; + deallog << std::endl; + } } diff --git a/tests/multigrid/transfer_matrix_free_13.output b/tests/multigrid/transfer_matrix_free_13.output index f51ed58732..91b1651826 100644 --- a/tests/multigrid/transfer_matrix_free_13.output +++ b/tests/multigrid/transfer_matrix_free_13.output @@ -1,7 +1,13 @@ +DEAL::SRC Vector DEAL::0.00000 0.00000 0.00000 0.00000 +DEAL:: +DEAL::DST Vector DEAL::5.00000 2.50000 5.00000 2.50000 0.00000 0.00000 5.00000 2.50000 0.00000 DEAL:: +DEAL::SRC Vector DEAL::0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 +DEAL:: +DEAL::DST Vector DEAL::5.00000 2.50000 5.00000 2.50000 5.00000 2.50000 5.00000 2.50000 0.00000 0.00000 0.00000 0.00000 5.00000 2.50000 5.00000 2.50000 0.00000 0.00000 5.00000 2.50000 5.00000 2.50000 0.00000 0.00000 5.00000 2.50000 0.00000 DEAL:: diff --git a/tests/multigrid/transfer_prebuilt_05.cc b/tests/multigrid/transfer_prebuilt_05.cc new file mode 100644 index 0000000000..119091f247 --- /dev/null +++ b/tests/multigrid/transfer_prebuilt_05.cc @@ -0,0 +1,98 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2016 - 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 MGTransferPrebuilt with custom user constraints + +#include + +#include + +#include + +#include + +#include "../tests.h" + +template +void +check() +{ + Triangulation tr(Triangulation::limit_level_difference_at_vertices); + GridGenerator::hyper_cube(tr, 0, 1, false); + + typename Triangulation::active_cell_iterator cell = tr.begin_active(); + cell->face(0)->set_all_boundary_ids(1); + + tr.refine_global(1); + + FE_Q fe = FE_Q(1); + + DoFHandler mgdof(tr); + mgdof.distribute_dofs(fe); + mgdof.distribute_mg_dofs(); + + MGConstrainedDoFs mg_constrained_dofs; + mg_constrained_dofs.initialize(mgdof); + + IndexSet relevant_dofs; + DoFTools::extract_locally_relevant_level_dofs(mgdof, 0, relevant_dofs); + AffineConstraints user_constraints; + user_constraints.reinit(relevant_dofs); + + typename DoFHandler::level_face_iterator face0 = mgdof.begin(0)->face(0); + std::vector face_dofs(fe.dofs_per_face); + face0->get_mg_dof_indices(0, face_dofs); + for (unsigned int i = 0; i < face_dofs.size(); ++i) + { + if (user_constraints.can_store_line(face_dofs[i])) + { + user_constraints.add_line(face_dofs[i]); + user_constraints.set_inhomogeneity(face_dofs[i], 5.0); + } + } + user_constraints.close(); + mg_constrained_dofs.add_user_constraints(0, user_constraints); + + MGTransferPrebuilt> transfer_pb(mg_constrained_dofs); + transfer_pb.build(mgdof); + + deallog << "SRC Vector" << std::endl; + Vector src_level_0(mgdof.n_dofs(0)); + for (unsigned int i = 0; i < mgdof.n_dofs(0); ++i) + deallog << src_level_0(i) << " "; + deallog << std::endl << std::endl; + + { + Vector dst_level_1(mgdof.n_dofs(1)); + transfer_pb.prolongate(1, dst_level_1, src_level_0); + deallog << "DST Vector" << std::endl; + for (unsigned int i = 0; i < mgdof.n_dofs(1); ++i) + deallog << dst_level_1(i) << " "; + deallog << std::endl; + } +} + + +int +main() +{ + initlog(); + + check<2>(); + deallog << std::endl; + check<3>(); + deallog << std::endl; +} diff --git a/tests/multigrid/transfer_prebuilt_05.output b/tests/multigrid/transfer_prebuilt_05.output new file mode 100644 index 0000000000..91b1651826 --- /dev/null +++ b/tests/multigrid/transfer_prebuilt_05.output @@ -0,0 +1,13 @@ + +DEAL::SRC Vector +DEAL::0.00000 0.00000 0.00000 0.00000 +DEAL:: +DEAL::DST Vector +DEAL::5.00000 2.50000 5.00000 2.50000 0.00000 0.00000 5.00000 2.50000 0.00000 +DEAL:: +DEAL::SRC Vector +DEAL::0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 +DEAL:: +DEAL::DST Vector +DEAL::5.00000 2.50000 5.00000 2.50000 5.00000 2.50000 5.00000 2.50000 0.00000 0.00000 0.00000 0.00000 5.00000 2.50000 5.00000 2.50000 0.00000 0.00000 5.00000 2.50000 5.00000 2.50000 0.00000 0.00000 5.00000 2.50000 0.00000 +DEAL:: -- 2.39.5