From: Peter Munch Date: Fri, 24 Nov 2023 19:52:44 +0000 (+0100) Subject: MGTransferMatrixFree: assert that only homogeneous or identity constraints are used X-Git-Tag: relicensing~283^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=284b3c6bb320101090965a15d447d07bbfa278b0;p=dealii.git MGTransferMatrixFree: assert that only homogeneous or identity constraints are used --- diff --git a/include/deal.II/multigrid/mg_transfer_global_coarsening.templates.h b/include/deal.II/multigrid/mg_transfer_global_coarsening.templates.h index 3011e8ce1f..aa97154a47 100644 --- a/include/deal.II/multigrid/mg_transfer_global_coarsening.templates.h +++ b/include/deal.II/multigrid/mg_transfer_global_coarsening.templates.h @@ -1774,6 +1774,9 @@ namespace internal (mg_level_coarse + 1 == mg_level_fine), ExcNotImplemented()); + AssertDimension(constraints_fine.n_inhomogeneities(), 0); + AssertDimension(constraints_coarse.n_inhomogeneities(), 0); + transfer.dof_handler_fine = &dof_handler_fine; transfer.mg_level_fine = mg_level_fine; @@ -2317,6 +2320,9 @@ namespace internal "(numbers::invalid_unsigned_int) or on refinement levels without " "hanging nodes.")); + AssertDimension(constraints_fine.n_inhomogeneities(), 0); + AssertDimension(constraints_coarse.n_inhomogeneities(), 0); + transfer.dof_handler_fine = &dof_handler_fine; transfer.mg_level_fine = mg_level_fine; diff --git a/source/multigrid/mg_transfer_internal.cc b/source/multigrid/mg_transfer_internal.cc index 2bbafff463..584e4846e1 100644 --- a/source/multigrid/mg_transfer_internal.cc +++ b/source/multigrid/mg_transfer_internal.cc @@ -637,6 +637,39 @@ namespace internal dirichlet_indices.clear(); weights_on_refined.clear(); +#ifdef DEBUG + if (mg_constrained_dofs) + { + const unsigned int n_levels = + dof_handler.get_triangulation().n_global_levels(); + + for (unsigned int l = 0; l < n_levels; ++l) + { + const auto &constraints = + mg_constrained_dofs->get_user_constraint_matrix(l); + + // no inhomogeneities are supported + AssertDimension(constraints.n_inhomogeneities(), 0); + + for (const auto dof : constraints.get_local_lines()) + { + const auto *entries_ptr = + constraints.get_constraint_entries(dof); + + if (entries_ptr == nullptr) + continue; + + // only homogeneous or identity constraints are supported + Assert((entries_ptr->size() == 0) || + ((entries_ptr->size() == 1) && + (std::abs((*entries_ptr)[0].second - 1.) < + 100 * std::numeric_limits::epsilon())), + ExcNotImplemented()); + } + } + } +#endif + // we collect all child DoFs of a mother cell together. For faster // tensorized operations, we align the degrees of freedom // lexicographically. We distinguish FE_Q elements and FE_DGQ elements diff --git a/tests/multigrid/transfer_matrix_free_13.cc b/tests/multigrid/transfer_matrix_free_13.cc index 197fa2106b..ac1955f026 100644 --- a/tests/multigrid/transfer_matrix_free_13.cc +++ b/tests/multigrid/transfer_matrix_free_13.cc @@ -41,7 +41,7 @@ check() tr.refine_global(1); - FE_Q fe = FE_Q(1); + FE_Q fe(1); DoFHandler mgdof(tr); mgdof.distribute_dofs(fe); @@ -63,7 +63,6 @@ check() if (user_constraints.can_store_line(face_dofs[i])) { user_constraints.constrain_dof_to_zero(face_dofs[i]); - user_constraints.set_inhomogeneity(face_dofs[i], 5.0); } } user_constraints.close(); @@ -74,6 +73,7 @@ check() deallog << "SRC Vector" << std::endl; LinearAlgebra::distributed::Vector src_level_0(mgdof.n_dofs(0)); + src_level_0 = 1.0; for (unsigned int i = 0; i < mgdof.n_dofs(0); ++i) deallog << src_level_0(i) << ' '; deallog << std::endl << std::endl; diff --git a/tests/multigrid/transfer_matrix_free_13.output b/tests/multigrid/transfer_matrix_free_13.output index 91b1651826..cdb7ec1e21 100644 --- a/tests/multigrid/transfer_matrix_free_13.output +++ b/tests/multigrid/transfer_matrix_free_13.output @@ -1,13 +1,13 @@ DEAL::SRC Vector -DEAL::0.00000 0.00000 0.00000 0.00000 +DEAL::1.00000 1.00000 1.00000 1.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::0.00000 0.500000 0.00000 0.500000 1.00000 1.00000 0.00000 0.500000 1.00000 DEAL:: DEAL::SRC Vector -DEAL::0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 +DEAL::1.00000 1.00000 1.00000 1.00000 1.00000 1.00000 1.00000 1.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::0.00000 0.500000 0.00000 0.500000 0.00000 0.500000 0.00000 0.500000 1.00000 1.00000 1.00000 1.00000 0.00000 0.500000 0.00000 0.500000 1.00000 1.00000 0.00000 0.500000 0.00000 0.500000 1.00000 1.00000 0.00000 0.500000 1.00000 DEAL::