From c9b2616bf3db0540f5b6c27a53e5bda45fa04b2c Mon Sep 17 00:00:00 2001 From: David Wells Date: Sat, 12 Mar 2022 20:16:25 -0500 Subject: [PATCH] Add another test. --- tests/dofs/nodal_renumbering_01.cc | 113 +++++++++++++++++- ...mbering_01.mpirun=2.with_p4est=true.output | 52 +++++--- ...mbering_01.mpirun=3.with_p4est=true.output | 78 ++++++++---- ...odal_renumbering_01.with_p4est=true.output | 26 ++-- 4 files changed, 218 insertions(+), 51 deletions(-) diff --git a/tests/dofs/nodal_renumbering_01.cc b/tests/dofs/nodal_renumbering_01.cc index 4c767bfbd0..368c798773 100644 --- a/tests/dofs/nodal_renumbering_01.cc +++ b/tests/dofs/nodal_renumbering_01.cc @@ -21,6 +21,9 @@ #include #include +#include +#include +#include #include #include #include @@ -77,7 +80,7 @@ test(DoFHandler<2> &dof_handler, const hp::MappingCollection<2> &mappings) const MPI_Comm comm = dof_handler.get_communicator(); const IndexSet &local_dofs = dof_handler.locally_owned_dofs(); - deallog << "locally owned dofs =\n"; + deallog << "new case with locally owned dofs = "; local_dofs.print(deallog); deallog << std::endl; const IndexSet relevant_dofs = @@ -104,8 +107,7 @@ test(DoFHandler<2> &dof_handler, const hp::MappingCollection<2> &mappings) position); Test test(n_components); - if (n_components == 2) - VectorTools::interpolate(mappings, dof_handler, test, solution1); + VectorTools::interpolate(mappings, dof_handler, test, solution1); // Verify that we get the same results when we interpolate either manually // or by reading off position data and evaluating the interpolated @@ -174,6 +176,51 @@ main(int argc, char **argv) test(dof_handler, mappings); } + // Try discontinuous elements + { + parallel::shared::Triangulation<2> tria( + comm, + dealii::Triangulation<2>::none, + true, + parallel::shared::Triangulation<2>::partition_zorder); + GridGenerator::hyper_ball(tria); + + hp::FECollection<2> fe(FESystem<2>(FE_DGQ<2>(4), 2)); + hp::MappingCollection<2> mappings(MappingQ<2>(1)); + DoFHandler<2> dof_handler(tria); + for (const auto &cell : dof_handler.active_cell_iterators()) + if (cell->is_locally_owned()) + cell->set_active_fe_index(0); + dof_handler.distribute_dofs(fe); + + test(dof_handler, mappings); + } + + // Test with p::d::T, hp-FE, multiple components + { + parallel::distributed::Triangulation<2> tria(comm); + GridGenerator::hyper_ball(tria); + tria.refine_global(3); + for (const auto &cell : tria.active_cell_iterators()) + if (cell->is_locally_owned() && std::abs(cell->center()[0]) < 0.1) + cell->set_refine_flag(); + tria.execute_coarsening_and_refinement(); + + hp::FECollection<2> fe(FESystem<2>(FE_Q<2>(2), 2), + FESystem<2>(FE_Q<2>(4), 2), + FESystem<2>(FE_Nothing<2>(), 2)); + hp::MappingCollection<2> mappings(MappingQ<2>(1), + MappingQ<2>(1), + MappingQ<2>(1)); + DoFHandler<2> dof_handler(tria); + for (const auto &cell : dof_handler.active_cell_iterators()) + if (cell->is_locally_owned()) + cell->set_active_fe_index(cell->index() % 3); + dof_handler.distribute_dofs(fe); + + test(dof_handler, mappings); + } + // Test with a scalar FE { parallel::shared::Triangulation<2> tria( @@ -238,4 +285,64 @@ main(int argc, char **argv) test(dof_handler, mappings); } + + // Make sure that we fail correctly when we do weird things + deal_II_exceptions::disable_abort_on_exception(); + { + try + { + parallel::distributed::Triangulation<2> tria(comm); + GridGenerator::hyper_cube(tria); + tria.refine_global(3); + + FESystem<2> fe(FE_NedelecSZ<2>(0), 1, FE_Q<2>(1), 2); + DoFHandler<2> dof_handler(tria); + dof_handler.distribute_dofs(fe); + hp::MappingCollection<2> mappings(MappingQ<2>(1)); + for (const auto &cell : dof_handler.active_cell_iterators()) + cell->set_active_fe_index(0); + + test(dof_handler, mappings); + } + catch (const ExceptionBase &exc) + { + // The third line contains line numbers so skip it + const std::vector lines = + Utilities::split_string_list(exc.what(), "\n"); + deallog + << "FE_NedelecSZ nodal renumbering failed successfully with message:" + << std::endl; + for (std::size_t i = 3; i < 6; ++i) + deallog << lines[i] << std::endl; + } + } + + { + try + { + parallel::distributed::Triangulation<2> tria(comm); + GridGenerator::hyper_cube(tria); + tria.refine_global(3); + + FE_NedelecSZ<2> fe(0); + DoFHandler<2> dof_handler(tria); + dof_handler.distribute_dofs(fe); + hp::MappingCollection<2> mappings(MappingQ<2>(1)); + for (const auto &cell : dof_handler.active_cell_iterators()) + cell->set_active_fe_index(0); + + test(dof_handler, mappings); + } + catch (const ExceptionBase &exc) + { + // The third line contains line numbers so skip it + const std::vector lines = + Utilities::split_string_list(exc.what(), "\n"); + deallog + << "FE_NedelecSZ nodal renumbering failed successfully with message:" + << std::endl; + for (std::size_t i = 3; i < 6; ++i) + deallog << lines[i] << std::endl; + } + } } diff --git a/tests/dofs/nodal_renumbering_01.mpirun=2.with_p4est=true.output b/tests/dofs/nodal_renumbering_01.mpirun=2.with_p4est=true.output index 7dadd62145..f941368ee7 100644 --- a/tests/dofs/nodal_renumbering_01.mpirun=2.with_p4est=true.output +++ b/tests/dofs/nodal_renumbering_01.mpirun=2.with_p4est=true.output @@ -1,31 +1,51 @@ -DEAL:0::locally owned dofs = -{[0,7]} +DEAL:0::new case with locally owned dofs = {[0,7]} DEAL:0:: DEAL:0::difference norm = 0.00000 -DEAL:0::locally owned dofs = -{[0,3]} +DEAL:0::new case with locally owned dofs = {[0,99]} DEAL:0:: -DEAL:0::locally owned dofs = -{[0,230]} +DEAL:0::difference norm = 0.00000 +DEAL:0::new case with locally owned dofs = {[0,4033]} +DEAL:0:: +DEAL:0::difference norm = 1.59444e-15 +DEAL:0::new case with locally owned dofs = {[0,3]} +DEAL:0:: +DEAL:0::new case with locally owned dofs = {[0,230]} DEAL:0:: -DEAL:0::locally owned dofs = -{[0,1721]} +DEAL:0::new case with locally owned dofs = {[0,1721]} DEAL:0:: DEAL:0::difference norm = 0.00000 +DEAL:0::FE_NedelecSZ nodal renumbering failed successfully with message: +DEAL:0::void dealii::DoFRenumbering::compute_support_point_wise(std::vector&, const dealii::DoFHandler&) [with int dim = 2; int spacedim = 2] +DEAL:0::The violated condition was: +DEAL:0::dofs_per_component[0] == dpc +DEAL:0::FE_NedelecSZ nodal renumbering failed successfully with message: +DEAL:0::void dealii::DoFRenumbering::compute_support_point_wise(std::vector&, const dealii::DoFHandler&) [with int dim = 2; int spacedim = 2] +DEAL:0::The violated condition was: +DEAL:0::dofs_per_component[0] == dpc -DEAL:1::locally owned dofs = -{[8,9]} +DEAL:1::new case with locally owned dofs = {[8,9]} DEAL:1:: DEAL:1::difference norm = 0.00000 -DEAL:1::locally owned dofs = -{4} +DEAL:1::new case with locally owned dofs = {[100,249]} +DEAL:1:: +DEAL:1::difference norm = 0.00000 +DEAL:1::new case with locally owned dofs = {[4034,7965]} +DEAL:1:: +DEAL:1::difference norm = 1.59444e-15 +DEAL:1::new case with locally owned dofs = {4} DEAL:1:: -DEAL:1::locally owned dofs = -{[231,440]} +DEAL:1::new case with locally owned dofs = {[231,440]} DEAL:1:: -DEAL:1::locally owned dofs = -{[1722,3361]} +DEAL:1::new case with locally owned dofs = {[1722,3361]} DEAL:1:: DEAL:1::difference norm = 0.00000 +DEAL:1::FE_NedelecSZ nodal renumbering failed successfully with message: +DEAL:1::void dealii::DoFRenumbering::compute_support_point_wise(std::vector&, const dealii::DoFHandler&) [with int dim = 2; int spacedim = 2] +DEAL:1::The violated condition was: +DEAL:1::dofs_per_component[0] == dpc +DEAL:1::FE_NedelecSZ nodal renumbering failed successfully with message: +DEAL:1::void dealii::DoFRenumbering::compute_support_point_wise(std::vector&, const dealii::DoFHandler&) [with int dim = 2; int spacedim = 2] +DEAL:1::The violated condition was: +DEAL:1::dofs_per_component[0] == dpc diff --git a/tests/dofs/nodal_renumbering_01.mpirun=3.with_p4est=true.output b/tests/dofs/nodal_renumbering_01.mpirun=3.with_p4est=true.output index bd56e24115..427c6c29b2 100644 --- a/tests/dofs/nodal_renumbering_01.mpirun=3.with_p4est=true.output +++ b/tests/dofs/nodal_renumbering_01.mpirun=3.with_p4est=true.output @@ -1,47 +1,77 @@ -DEAL:0::locally owned dofs = -{} +DEAL:0::new case with locally owned dofs = {} DEAL:0:: DEAL:0::difference norm = 0.00000 -DEAL:0::locally owned dofs = -{} +DEAL:0::new case with locally owned dofs = {[0,49]} DEAL:0:: -DEAL:0::locally owned dofs = -{[0,120]} +DEAL:0::difference norm = 0.00000 +DEAL:0::new case with locally owned dofs = {[0,2731]} +DEAL:0:: +DEAL:0::difference norm = 1.67272e-15 +DEAL:0::new case with locally owned dofs = {} +DEAL:0:: +DEAL:0::new case with locally owned dofs = {[0,120]} DEAL:0:: -DEAL:0::locally owned dofs = -{[0,1101]} +DEAL:0::new case with locally owned dofs = {[0,1101]} DEAL:0:: DEAL:0::difference norm = 0.00000 +DEAL:0::FE_NedelecSZ nodal renumbering failed successfully with message: +DEAL:0::void dealii::DoFRenumbering::compute_support_point_wise(std::vector&, const dealii::DoFHandler&) [with int dim = 2; int spacedim = 2] +DEAL:0::The violated condition was: +DEAL:0::dofs_per_component[0] == dpc +DEAL:0::FE_NedelecSZ nodal renumbering failed successfully with message: +DEAL:0::void dealii::DoFRenumbering::compute_support_point_wise(std::vector&, const dealii::DoFHandler&) [with int dim = 2; int spacedim = 2] +DEAL:0::The violated condition was: +DEAL:0::dofs_per_component[0] == dpc -DEAL:1::locally owned dofs = -{[0,7]} +DEAL:1::new case with locally owned dofs = {[0,7]} +DEAL:1:: +DEAL:1::difference norm = 0.00000 +DEAL:1::new case with locally owned dofs = {[50,149]} DEAL:1:: DEAL:1::difference norm = 0.00000 -DEAL:1::locally owned dofs = -{[0,3]} +DEAL:1::new case with locally owned dofs = {[2732,5305]} DEAL:1:: -DEAL:1::locally owned dofs = -{[121,340]} +DEAL:1::difference norm = 1.67272e-15 +DEAL:1::new case with locally owned dofs = {[0,3]} DEAL:1:: -DEAL:1::locally owned dofs = -{[1102,2361]} +DEAL:1::new case with locally owned dofs = {[121,340]} +DEAL:1:: +DEAL:1::new case with locally owned dofs = {[1102,2361]} DEAL:1:: DEAL:1::difference norm = 0.00000 +DEAL:1::FE_NedelecSZ nodal renumbering failed successfully with message: +DEAL:1::void dealii::DoFRenumbering::compute_support_point_wise(std::vector&, const dealii::DoFHandler&) [with int dim = 2; int spacedim = 2] +DEAL:1::The violated condition was: +DEAL:1::dofs_per_component[0] == dpc +DEAL:1::FE_NedelecSZ nodal renumbering failed successfully with message: +DEAL:1::void dealii::DoFRenumbering::compute_support_point_wise(std::vector&, const dealii::DoFHandler&) [with int dim = 2; int spacedim = 2] +DEAL:1::The violated condition was: +DEAL:1::dofs_per_component[0] == dpc -DEAL:2::locally owned dofs = -{[8,9]} +DEAL:2::new case with locally owned dofs = {[8,9]} +DEAL:2:: +DEAL:2::difference norm = 0.00000 +DEAL:2::new case with locally owned dofs = {[150,249]} DEAL:2:: DEAL:2::difference norm = 0.00000 -DEAL:2::locally owned dofs = -{4} +DEAL:2::new case with locally owned dofs = {[5306,7935]} +DEAL:2:: +DEAL:2::difference norm = 1.67272e-15 +DEAL:2::new case with locally owned dofs = {4} DEAL:2:: -DEAL:2::locally owned dofs = -{[341,440]} +DEAL:2::new case with locally owned dofs = {[341,440]} DEAL:2:: -DEAL:2::locally owned dofs = -{[2362,3361]} +DEAL:2::new case with locally owned dofs = {[2362,3361]} DEAL:2:: DEAL:2::difference norm = 0.00000 +DEAL:2::FE_NedelecSZ nodal renumbering failed successfully with message: +DEAL:2::void dealii::DoFRenumbering::compute_support_point_wise(std::vector&, const dealii::DoFHandler&) [with int dim = 2; int spacedim = 2] +DEAL:2::The violated condition was: +DEAL:2::dofs_per_component[0] == dpc +DEAL:2::FE_NedelecSZ nodal renumbering failed successfully with message: +DEAL:2::void dealii::DoFRenumbering::compute_support_point_wise(std::vector&, const dealii::DoFHandler&) [with int dim = 2; int spacedim = 2] +DEAL:2::The violated condition was: +DEAL:2::dofs_per_component[0] == dpc diff --git a/tests/dofs/nodal_renumbering_01.with_p4est=true.output b/tests/dofs/nodal_renumbering_01.with_p4est=true.output index 3826b2a5bd..8d20583e59 100644 --- a/tests/dofs/nodal_renumbering_01.with_p4est=true.output +++ b/tests/dofs/nodal_renumbering_01.with_p4est=true.output @@ -1,15 +1,25 @@ -DEAL:0::locally owned dofs = -{[0,9]} +DEAL:0::new case with locally owned dofs = {[0,9]} DEAL:0:: DEAL:0::difference norm = 0.00000 -DEAL:0::locally owned dofs = -{[0,4]} +DEAL:0::new case with locally owned dofs = {[0,249]} DEAL:0:: -DEAL:0::locally owned dofs = -{[0,440]} +DEAL:0::difference norm = 0.00000 +DEAL:0::new case with locally owned dofs = {[0,7941]} +DEAL:0:: +DEAL:0::difference norm = 1.62791e-15 +DEAL:0::new case with locally owned dofs = {[0,4]} +DEAL:0:: +DEAL:0::new case with locally owned dofs = {[0,440]} DEAL:0:: -DEAL:0::locally owned dofs = -{[0,3361]} +DEAL:0::new case with locally owned dofs = {[0,3361]} DEAL:0:: DEAL:0::difference norm = 0.00000 +DEAL:0::FE_NedelecSZ nodal renumbering failed successfully with message: +DEAL:0::void dealii::DoFRenumbering::compute_support_point_wise(std::vector&, const dealii::DoFHandler&) [with int dim = 2; int spacedim = 2] +DEAL:0::The violated condition was: +DEAL:0::dofs_per_component[0] == dpc +DEAL:0::FE_NedelecSZ nodal renumbering failed successfully with message: +DEAL:0::void dealii::DoFRenumbering::compute_support_point_wise(std::vector&, const dealii::DoFHandler&) [with int dim = 2; int spacedim = 2] +DEAL:0::The violated condition was: +DEAL:0::dofs_per_component[0] == dpc -- 2.39.5