From 4f95b5131cdd6de64000bd9343ce75e061ea94f6 Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Tue, 19 Sep 2023 09:24:40 -0600 Subject: [PATCH] Fix tests. --- tests/gla/block_vec_02.cc | 3 +- tests/gla/vec_03.cc | 3 +- tests/hp/field_transfer_05.cc | 4 ++- tests/lac/linear_operator_12.cc | 2 ++ tests/lac/linear_operator_12a.cc | 2 ++ tests/mpi/fe_tools_extrapolate_common.h | 29 +++++++++++-------- tests/mpi/hp_integrate_difference.cc | 7 +++-- tests/mpi/interpolate_04.cc | 12 ++++---- tests/mpi/multigrid_adaptive.cc | 2 ++ tests/mpi/multigrid_uniform.cc | 2 ++ tests/mpi/step-37.cc | 3 ++ .../mg_data_out_05.cc | 3 +- .../mg_transfer_p_01.cc | 10 +++++-- .../mg_transfer_p_02.cc | 10 +++++-- .../mg_transfer_p_03.cc | 10 +++++-- .../mg_transfer_p_04.cc | 10 +++++-- .../mg_transfer_p_05.cc | 8 +++-- .../mg_transfer_p_06.cc | 8 +++-- .../mg_transfer_util.h | 8 +++-- tests/multigrid/mg_data_out_05.cc | 3 +- .../vector_tools_evaluate_at_points_02.cc | 4 ++- tests/simplex/step-67.cc | 12 ++++++-- tests/trilinos/direct_solver_3.cc | 2 ++ 23 files changed, 114 insertions(+), 43 deletions(-) diff --git a/tests/gla/block_vec_02.cc b/tests/gla/block_vec_02.cc index ad7bf809a9..4946b78f86 100644 --- a/tests/gla/block_vec_02.cc +++ b/tests/gla/block_vec_02.cc @@ -77,7 +77,8 @@ test() using scalar_type = typename LA::MPI::BlockVector::value_type; - AffineConstraints cm; + AffineConstraints cm(complete_index_set(v.size()), + complete_index_set(v.size())); cm.add_line(0); cm.add_entry(0, 1, 3.0); cm.close(); diff --git a/tests/gla/vec_03.cc b/tests/gla/vec_03.cc index e53a527341..a78b4ff655 100644 --- a/tests/gla/vec_03.cc +++ b/tests/gla/vec_03.cc @@ -80,7 +80,8 @@ test() ExcInternalError()); using scalar_type = typename LA::MPI::BlockVector::value_type; - AffineConstraints cm; + AffineConstraints cm(local_active, + complete_index_set(local_active.size())); cm.add_line(1); cm.add_entry(1, 2, 3.0); cm.close(); diff --git a/tests/hp/field_transfer_05.cc b/tests/hp/field_transfer_05.cc index 443bdc91e1..aef839c65a 100644 --- a/tests/hp/field_transfer_05.cc +++ b/tests/hp/field_transfer_05.cc @@ -148,7 +148,9 @@ main(int argc, char *argv[]) LinearAlgebra::distributed::Vector new_solution( dof_handler.locally_owned_dofs(), locally_relevant_dofs, MPI_COMM_WORLD); - AffineConstraints affine_constraints; + AffineConstraints affine_constraints( + dof_handler.locally_owned_dofs(), + DoFTools::extract_locally_relevant_dofs(dof_handler)); DoFTools::make_hanging_node_constraints(dof_handler, affine_constraints); affine_constraints.close(); diff --git a/tests/lac/linear_operator_12.cc b/tests/lac/linear_operator_12.cc index fa98e6afc8..cb2e34c7a0 100644 --- a/tests/lac/linear_operator_12.cc +++ b/tests/lac/linear_operator_12.cc @@ -186,6 +186,8 @@ Step4::setup_system() dof_handler.distribute_dofs(fe); constraints.clear(); + constraints.reinit(dof_handler.locally_owned_dofs(), + DoFTools::extract_locally_relevant_dofs(dof_handler)); std::map boundary_values; VectorTools::interpolate_boundary_values(dof_handler, 0, diff --git a/tests/lac/linear_operator_12a.cc b/tests/lac/linear_operator_12a.cc index 46eee505f0..c48a9f7587 100644 --- a/tests/lac/linear_operator_12a.cc +++ b/tests/lac/linear_operator_12a.cc @@ -187,6 +187,8 @@ Step4::setup_system() dof_handler.distribute_dofs(fe); constraints.clear(); + constraints.reinit(dof_handler.locally_owned_dofs(), + DoFTools::extract_locally_relevant_dofs(dof_handler)); std::map boundary_values; VectorTools::interpolate_boundary_values(dof_handler, 0, diff --git a/tests/mpi/fe_tools_extrapolate_common.h b/tests/mpi/fe_tools_extrapolate_common.h index 5ebf2d1d59..31ca05ac62 100644 --- a/tests/mpi/fe_tools_extrapolate_common.h +++ b/tests/mpi/fe_tools_extrapolate_common.h @@ -193,12 +193,6 @@ check_this(const FiniteElement &fe1, const FiniteElement &fe2) std::unique_ptr> dof1(make_dof_handler(*tria, fe1)); std::unique_ptr> dof2(make_dof_handler(*tria, fe2)); - AffineConstraints cm1; - DoFTools::make_hanging_node_constraints(*dof1, cm1); - cm1.close(); - AffineConstraints cm2; - DoFTools::make_hanging_node_constraints(*dof2, cm2); - cm2.close(); const IndexSet &locally_owned_dofs1 = dof1->locally_owned_dofs(); const IndexSet locally_relevant_dofs1 = @@ -207,6 +201,16 @@ check_this(const FiniteElement &fe1, const FiniteElement &fe2) const IndexSet locally_relevant_dofs2 = DoFTools::extract_locally_relevant_dofs(*dof2); + AffineConstraints cm1(locally_owned_dofs1, + locally_relevant_dofs1); + DoFTools::make_hanging_node_constraints(*dof1, cm1); + cm1.close(); + AffineConstraints cm2(locally_owned_dofs2, + locally_relevant_dofs2); + DoFTools::make_hanging_node_constraints(*dof2, cm2); + cm2.close(); + + VectorType in_ghosted = build_ghosted(locally_owned_dofs1, locally_relevant_dofs1); VectorType in_distributed = @@ -324,12 +328,6 @@ check_this_dealii(const FiniteElement &fe1, const FiniteElement &fe2) std::unique_ptr> dof1(make_dof_handler(*tria, fe1)); std::unique_ptr> dof2(make_dof_handler(*tria, fe2)); - AffineConstraints cm1; - DoFTools::make_hanging_node_constraints(*dof1, cm1); - cm1.close(); - AffineConstraints cm2; - DoFTools::make_hanging_node_constraints(*dof2, cm2); - cm2.close(); const IndexSet &locally_owned_dofs1 = dof1->locally_owned_dofs(); const IndexSet locally_relevant_dofs1 = @@ -338,6 +336,13 @@ check_this_dealii(const FiniteElement &fe1, const FiniteElement &fe2) const IndexSet locally_relevant_dofs2 = DoFTools::extract_locally_relevant_dofs(*dof2); + AffineConstraints cm1(locally_owned_dofs1, locally_relevant_dofs1); + DoFTools::make_hanging_node_constraints(*dof1, cm1); + cm1.close(); + AffineConstraints cm2(locally_owned_dofs2, locally_relevant_dofs2); + DoFTools::make_hanging_node_constraints(*dof2, cm2); + cm2.close(); + VectorType in_ghosted = build_ghosted(locally_owned_dofs1, locally_relevant_dofs1); VectorType out_ghosted = diff --git a/tests/mpi/hp_integrate_difference.cc b/tests/mpi/hp_integrate_difference.cc index 0ae78048f2..73de23c74a 100644 --- a/tests/mpi/hp_integrate_difference.cc +++ b/tests/mpi/hp_integrate_difference.cc @@ -156,15 +156,16 @@ test() VectorTools::interpolate(dof_handler, CheckFunction(), interpolated); // then also apply constraints - AffineConstraints hanging_node_constraints; + const IndexSet relevant_set = + DoFTools::extract_locally_relevant_dofs(dof_handler); + AffineConstraints hanging_node_constraints( + dof_handler.locally_owned_dofs(), relevant_set); DoFTools::make_hanging_node_constraints(dof_handler, hanging_node_constraints); hanging_node_constraints.close(); hanging_node_constraints.distribute(interpolated); // extract a vector that has ghost elements - const IndexSet relevant_set = - DoFTools::extract_locally_relevant_dofs(dof_handler); TrilinosWrappers::MPI::Vector x_rel(relevant_set, MPI_COMM_WORLD); x_rel = interpolated; diff --git a/tests/mpi/interpolate_04.cc b/tests/mpi/interpolate_04.cc index abb249c517..049fe7230d 100644 --- a/tests/mpi/interpolate_04.cc +++ b/tests/mpi/interpolate_04.cc @@ -60,11 +60,6 @@ test() dofh1.distribute_dofs(fe); dofh2.distribute_dofs(fe); - AffineConstraints cm1; - cm1.close(); - AffineConstraints cm2; - cm2.close(); - const IndexSet &dof1_locally_owned_dofs = dofh1.locally_owned_dofs(); const IndexSet &dof2_locally_owned_dofs = dofh2.locally_owned_dofs(); const IndexSet dof1_locally_relevant_dofs = @@ -72,6 +67,13 @@ test() const IndexSet dof2_locally_relevant_dofs = DoFTools::extract_locally_relevant_dofs(dofh2); + AffineConstraints cm1(dof1_locally_owned_dofs, + dof1_locally_relevant_dofs); + cm1.close(); + AffineConstraints cm2(dof2_locally_owned_dofs, + dof2_locally_relevant_dofs); + cm2.close(); + PETScWrappers::MPI::Vector u1(dof1_locally_owned_dofs, dof1_locally_relevant_dofs, diff --git a/tests/mpi/multigrid_adaptive.cc b/tests/mpi/multigrid_adaptive.cc index 091ff45261..03cb4c2eb1 100644 --- a/tests/mpi/multigrid_adaptive.cc +++ b/tests/mpi/multigrid_adaptive.cc @@ -189,6 +189,8 @@ namespace Step50 system_rhs.reinit(mg_dof_handler.locally_owned_dofs(), MPI_COMM_WORLD); constraints.clear(); + constraints.reinit(mg_dof_handler.locally_owned_dofs(), + DoFTools::extract_locally_relevant_dofs(mg_dof_handler)); DoFTools::make_hanging_node_constraints(mg_dof_handler, constraints); std::map *> dirichlet_boundary; diff --git a/tests/mpi/multigrid_uniform.cc b/tests/mpi/multigrid_uniform.cc index 9d802ac204..bdbc527315 100644 --- a/tests/mpi/multigrid_uniform.cc +++ b/tests/mpi/multigrid_uniform.cc @@ -189,6 +189,8 @@ namespace Step50 system_rhs.reinit(mg_dof_handler.locally_owned_dofs(), MPI_COMM_WORLD); constraints.clear(); + constraints.reinit(mg_dof_handler.locally_owned_dofs(), + DoFTools::extract_locally_relevant_dofs(mg_dof_handler)); DoFTools::make_hanging_node_constraints(mg_dof_handler, constraints); std::map *> dirichlet_boundary; diff --git a/tests/mpi/step-37.cc b/tests/mpi/step-37.cc index 030bd04d75..fb03d8bfb6 100644 --- a/tests/mpi/step-37.cc +++ b/tests/mpi/step-37.cc @@ -195,6 +195,9 @@ namespace Step37 // Apply hanging node constraints on that vector constraints_euler.clear(); + constraints_euler.reinit(dof_euler.locally_owned_dofs(), + DoFTools::extract_locally_relevant_dofs( + dof_euler)); DoFTools::make_hanging_node_constraints(dof_euler, constraints_euler); constraints_euler.close(); constraints_euler.distribute(euler_positions); diff --git a/tests/multigrid-global-coarsening/mg_data_out_05.cc b/tests/multigrid-global-coarsening/mg_data_out_05.cc index d9c069f22e..1d096d08b2 100644 --- a/tests/multigrid-global-coarsening/mg_data_out_05.cc +++ b/tests/multigrid-global-coarsening/mg_data_out_05.cc @@ -73,7 +73,8 @@ do_test() FunctionParser function(dim == 2 ? "y;-x;x*x+y*y" : "y;-x;0;x*x+y*y+z*z"); - AffineConstraints constraints; + AffineConstraints constraints(dof_handler.locally_owned_dofs(), + locally_relevant_dofs); DoFTools::make_hanging_node_constraints(dof_handler, constraints); constraints.close(); VectorTools::project( diff --git a/tests/multigrid-global-coarsening/mg_transfer_p_01.cc b/tests/multigrid-global-coarsening/mg_transfer_p_01.cc index 39000e83f2..11b68190a6 100644 --- a/tests/multigrid-global-coarsening/mg_transfer_p_01.cc +++ b/tests/multigrid-global-coarsening/mg_transfer_p_01.cc @@ -81,12 +81,18 @@ do_test(const FiniteElement &fe_fine, const FiniteElement &fe_coarse) DoFHandler dof_handler_coarse(tria); dof_handler_coarse.distribute_dofs(fe_coarse); - AffineConstraints constraint_coarse; + AffineConstraints constraint_coarse( + dof_handler_coarse.locally_owned_dofs(), + DoFTools::extract_locally_relevant_dofs(dof_handler_coarse)); + + AffineConstraints constraint_fine( + dof_handler_fine.locally_owned_dofs(), + DoFTools::extract_locally_relevant_dofs(dof_handler_fine)); + DoFTools::make_hanging_node_constraints(dof_handler_coarse, constraint_coarse); constraint_coarse.close(); - AffineConstraints constraint_fine; DoFTools::make_hanging_node_constraints(dof_handler_fine, constraint_fine); constraint_fine.close(); diff --git a/tests/multigrid-global-coarsening/mg_transfer_p_02.cc b/tests/multigrid-global-coarsening/mg_transfer_p_02.cc index c97c811510..297c4ae964 100644 --- a/tests/multigrid-global-coarsening/mg_transfer_p_02.cc +++ b/tests/multigrid-global-coarsening/mg_transfer_p_02.cc @@ -126,12 +126,18 @@ do_test() dof_handler_fine.distribute_dofs(fe_collection); dof_handler_coarse.distribute_dofs(fe_collection); - AffineConstraints constraint_coarse; + AffineConstraints constraint_coarse( + dof_handler_coarse.locally_owned_dofs(), + DoFTools::extract_locally_relevant_dofs(dof_handler_coarse)); + + AffineConstraints constraint_fine( + dof_handler_fine.locally_owned_dofs(), + DoFTools::extract_locally_relevant_dofs(dof_handler_fine)); + DoFTools::make_hanging_node_constraints(dof_handler_coarse, constraint_coarse); constraint_coarse.close(); - AffineConstraints constraint_fine; DoFTools::make_hanging_node_constraints(dof_handler_fine, constraint_fine); constraint_fine.close(); diff --git a/tests/multigrid-global-coarsening/mg_transfer_p_03.cc b/tests/multigrid-global-coarsening/mg_transfer_p_03.cc index 68deebebb7..73ae1ceaa2 100644 --- a/tests/multigrid-global-coarsening/mg_transfer_p_03.cc +++ b/tests/multigrid-global-coarsening/mg_transfer_p_03.cc @@ -68,12 +68,18 @@ do_test(const FiniteElement &fe_fine, const FiniteElement &fe_coarse) DoFHandler dof_handler_coarse(tria); dof_handler_coarse.distribute_dofs(FESystem(fe_coarse, dim)); - AffineConstraints constraint_coarse; + AffineConstraints constraint_coarse( + dof_handler_coarse.locally_owned_dofs(), + DoFTools::extract_locally_relevant_dofs(dof_handler_coarse)); + + AffineConstraints constraint_fine( + dof_handler_fine.locally_owned_dofs(), + DoFTools::extract_locally_relevant_dofs(dof_handler_fine)); + DoFTools::make_hanging_node_constraints(dof_handler_coarse, constraint_coarse); constraint_coarse.close(); - AffineConstraints constraint_fine; DoFTools::make_hanging_node_constraints(dof_handler_fine, constraint_fine); constraint_fine.close(); diff --git a/tests/multigrid-global-coarsening/mg_transfer_p_04.cc b/tests/multigrid-global-coarsening/mg_transfer_p_04.cc index 6d83e2b905..ad3ef0182d 100644 --- a/tests/multigrid-global-coarsening/mg_transfer_p_04.cc +++ b/tests/multigrid-global-coarsening/mg_transfer_p_04.cc @@ -111,12 +111,18 @@ do_test(const FiniteElement &fe_fine, const FiniteElement &fe_coarse) DoFHandler dof_handler_coarse(tria_coarse); dof_handler_coarse.distribute_dofs(fe_coarse); - AffineConstraints constraint_coarse; + AffineConstraints constraint_coarse( + dof_handler_coarse.locally_owned_dofs(), + DoFTools::extract_locally_relevant_dofs(dof_handler_coarse)); + + AffineConstraints constraint_fine( + dof_handler_fine.locally_owned_dofs(), + DoFTools::extract_locally_relevant_dofs(dof_handler_fine)); + DoFTools::make_hanging_node_constraints(dof_handler_coarse, constraint_coarse); constraint_coarse.close(); - AffineConstraints constraint_fine; DoFTools::make_hanging_node_constraints(dof_handler_fine, constraint_fine); constraint_fine.close(); diff --git a/tests/multigrid-global-coarsening/mg_transfer_p_05.cc b/tests/multigrid-global-coarsening/mg_transfer_p_05.cc index 838e595c9a..b85f8237b9 100644 --- a/tests/multigrid-global-coarsening/mg_transfer_p_05.cc +++ b/tests/multigrid-global-coarsening/mg_transfer_p_05.cc @@ -81,10 +81,14 @@ do_test(const FiniteElement &fe_fine, const FiniteElement &fe_coarse) dof_handler_coarse.distribute_dofs(fe_coarse); dof_handler_coarse.distribute_mg_dofs(); - AffineConstraints constraint_coarse; + AffineConstraints constraint_coarse( + dof_handler_coarse.locally_owned_dofs(), + DoFTools::extract_locally_relevant_dofs(dof_handler_coarse)); constraint_coarse.close(); - AffineConstraints constraint_fine; + AffineConstraints constraint_fine( + dof_handler_fine.locally_owned_dofs(), + DoFTools::extract_locally_relevant_dofs(dof_handler_fine)); constraint_fine.close(); // setup transfer operator diff --git a/tests/multigrid-global-coarsening/mg_transfer_p_06.cc b/tests/multigrid-global-coarsening/mg_transfer_p_06.cc index 97e1affdcb..a636a89627 100644 --- a/tests/multigrid-global-coarsening/mg_transfer_p_06.cc +++ b/tests/multigrid-global-coarsening/mg_transfer_p_06.cc @@ -85,10 +85,14 @@ do_test(const FiniteElement &fe_fine, const FiniteElement &fe_coarse) DoFHandler dof_handler_coarse(tria); dof_handler_coarse.distribute_dofs(fe_coarse); - AffineConstraints constraint_coarse; + AffineConstraints constraint_coarse( + dof_handler_coarse.locally_owned_dofs(), + DoFTools::extract_locally_relevant_dofs(dof_handler_coarse)); constraint_coarse.close(); - AffineConstraints constraint_fine; + AffineConstraints constraint_fine( + dof_handler_fine.locally_owned_dofs(), + DoFTools::extract_locally_relevant_dofs(dof_handler_fine)); constraint_fine.close(); // setup transfer operator diff --git a/tests/multigrid-global-coarsening/mg_transfer_util.h b/tests/multigrid-global-coarsening/mg_transfer_util.h index fdf916d9ee..197e065c19 100644 --- a/tests/multigrid-global-coarsening/mg_transfer_util.h +++ b/tests/multigrid-global-coarsening/mg_transfer_util.h @@ -76,7 +76,9 @@ test_transfer_operator( const unsigned int mg_level_fine = numbers::invalid_unsigned_int, const unsigned int mg_level_coarse = numbers::invalid_unsigned_int) { - AffineConstraints constraint_fine; + AffineConstraints constraint_fine( + dof_handler_fine.locally_owned_dofs(), + DoFTools::extract_locally_relevant_dofs(dof_handler_fine)); DoFTools::make_hanging_node_constraints(dof_handler_fine, constraint_fine); constraint_fine.close(); @@ -186,7 +188,9 @@ test_non_nested_transfer( const unsigned int mg_level_fine = numbers::invalid_unsigned_int, const unsigned int mg_level_coarse = numbers::invalid_unsigned_int) { - AffineConstraints constraint_fine; + AffineConstraints constraint_fine( + dof_handler_fine.locally_owned_dofs(), + DoFTools::extract_locally_relevant_dofs(dof_handler_fine)); DoFTools::make_hanging_node_constraints(dof_handler_fine, constraint_fine); constraint_fine.close(); diff --git a/tests/multigrid/mg_data_out_05.cc b/tests/multigrid/mg_data_out_05.cc index 785c553df6..88ce39e26d 100644 --- a/tests/multigrid/mg_data_out_05.cc +++ b/tests/multigrid/mg_data_out_05.cc @@ -73,7 +73,8 @@ do_test() FunctionParser function(dim == 2 ? "y;-x;x*x+y*y" : "y;-x;0;x*x+y*y+z*z"); - AffineConstraints constraints; + AffineConstraints constraints(dof_handler.locally_owned_dofs(), + locally_relevant_dofs); DoFTools::make_hanging_node_constraints(dof_handler, constraints); constraints.close(); VectorTools::project( diff --git a/tests/remote_point_evaluation/vector_tools_evaluate_at_points_02.cc b/tests/remote_point_evaluation/vector_tools_evaluate_at_points_02.cc index f2f9bb76e3..2328401dd4 100644 --- a/tests/remote_point_evaluation/vector_tools_evaluate_at_points_02.cc +++ b/tests/remote_point_evaluation/vector_tools_evaluate_at_points_02.cc @@ -137,7 +137,9 @@ public: const LinearAlgebra::distributed::Vector &solution_other, const Mapping &mapping_other) { - AffineConstraints constraints; + AffineConstraints constraints( + dof_handler.locally_owned_dofs(), + DoFTools::extract_locally_relevant_dofs(dof_handler)); { std::map> support_points; diff --git a/tests/simplex/step-67.cc b/tests/simplex/step-67.cc index f152a3d5e0..75be730e4c 100644 --- a/tests/simplex/step-67.cc +++ b/tests/simplex/step-67.cc @@ -864,7 +864,9 @@ namespace Euler_DG const DoFHandler &dof_handler) { const std::vector *> dof_handlers = {&dof_handler}; - const AffineConstraints dummy; + const AffineConstraints dummy( + dof_handler.locally_owned_dofs(), + DoFTools::extract_locally_relevant_dofs(dof_handler)); const std::vector *> constraints = {&dummy}; #ifdef HEX const std::vector> quadratures = {QGauss<1>(n_q_points_1d), @@ -2320,7 +2322,9 @@ namespace Euler_DG euler_operator.project(ExactSolution(time), reference); #else - AffineConstraints dummy; + AffineConstraints dummy( + dof_handler.locally_owned_dofs(), + DoFTools::extract_locally_relevant_dofs(dof_handler)); dummy.close(); VectorTools::project(mapping, dof_handler, @@ -2414,7 +2418,9 @@ namespace Euler_DG #ifdef HEX euler_operator.project(ExactSolution(time), solution); #else - AffineConstraints dummy; + AffineConstraints dummy(dof_handler.locally_owned_dofs(), + DoFTools::extract_locally_relevant_dofs( + dof_handler)); dummy.close(); VectorTools::project(mapping, dof_handler, diff --git a/tests/trilinos/direct_solver_3.cc b/tests/trilinos/direct_solver_3.cc index 1b1b3158ed..827058290f 100644 --- a/tests/trilinos/direct_solver_3.cc +++ b/tests/trilinos/direct_solver_3.cc @@ -147,6 +147,8 @@ Step4::setup_system() dof_handler.distribute_dofs(fe); constraints.clear(); + constraints.reinit(dof_handler.locally_owned_dofs(), + DoFTools::extract_locally_relevant_dofs(dof_handler)); std::map boundary_values; VectorTools::interpolate_boundary_values(dof_handler, 0, -- 2.39.5