From: Wolfgang Bangerth Date: Mon, 10 Jul 2017 14:07:05 +0000 (-0600) Subject: Add tests. X-Git-Tag: v9.0.0-rc1~1434^2~1 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=36e7f90f756e8b0d3f87efde9f2484b285cfd6a5;p=dealii.git Add tests. --- diff --git a/tests/dofs/n_boundary_dofs_02.cc b/tests/dofs/n_boundary_dofs_02.cc new file mode 100644 index 0000000000..74c15abaa0 --- /dev/null +++ b/tests/dofs/n_boundary_dofs_02.cc @@ -0,0 +1,80 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2008 - 2015 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. +// +// --------------------------------------------------------------------- + + + +// test that DoFHandler::n_boundary_dofs() yields the correct +// results in 1d, even if there are more than two boundary vertices + + +#include "../tests.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + + +template +void test() +{ + // create a triangulation that spans the disjoint interval [0,1] \union [2,3] + Triangulation<1,spacedim> triangulation_1; + GridGenerator::hyper_cube(triangulation_1, 0, 1); + + Triangulation<1,spacedim> triangulation_2; + GridGenerator::hyper_cube(triangulation_2, 2, 3); + + Triangulation<1,spacedim> triangulation; + GridGenerator::merge_triangulations(triangulation_1, + triangulation_2, + triangulation); + + + FESystem<1,spacedim> fe(FE_Q<1,spacedim>(1),1, + FE_DGQ<1,spacedim>(1), 1); + + DoFHandler<1,spacedim> dof_handler (triangulation); + + dof_handler.distribute_dofs (fe); + + const unsigned int N = dof_handler.n_boundary_dofs(); + deallog << N << std::endl; +} + + +int main() +{ + initlog(); + deallog.threshold_double(1.e-10); + + deallog.push("2d"); + test<2>(); + deallog.pop(); + + deallog.push("3d"); + test<3>(); + deallog.pop(); +} diff --git a/tests/dofs/n_boundary_dofs_02.output b/tests/dofs/n_boundary_dofs_02.output new file mode 100644 index 0000000000..c94fad75fe --- /dev/null +++ b/tests/dofs/n_boundary_dofs_02.output @@ -0,0 +1,3 @@ + +DEAL:2d::4 +DEAL:3d::4 diff --git a/tests/dofs/n_boundary_dofs_03.cc b/tests/dofs/n_boundary_dofs_03.cc new file mode 100644 index 0000000000..b3f7de85d6 --- /dev/null +++ b/tests/dofs/n_boundary_dofs_03.cc @@ -0,0 +1,96 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2008 - 2015 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. +// +// --------------------------------------------------------------------- + + + +// test that DoFHandler::n_boundary_dofs() yields the correct +// results in 1d, even if there are more than two boundary vertices +// +// same as the _02 test, but using the variant of the function that +// takes a std::set as argument + + +#include "../tests.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + + +template +void test() +{ + // create a triangulation that spans the disjoint interval [0,1] \union [2,3] + Triangulation<1,spacedim> triangulation_1; + GridGenerator::hyper_cube(triangulation_1, 0, 1); + + Triangulation<1,spacedim> triangulation_2; + GridGenerator::hyper_cube(triangulation_2, 2, 3); + + Triangulation<1,spacedim> triangulation; + GridGenerator::merge_triangulations(triangulation_1, + triangulation_2, + triangulation); + + // assign boundary ids + triangulation.begin()->face(0)->set_boundary_id(12); + triangulation.begin()->face(1)->set_boundary_id(13); + (++triangulation.begin())->face(0)->set_boundary_id(14); + (++triangulation.begin())->face(1)->set_boundary_id(15); + + + FESystem<1,spacedim> fe(FE_Q<1,spacedim>(1),1, + FE_DGQ<1,spacedim>(1), 1); + + DoFHandler<1,spacedim> dof_handler (triangulation); + + dof_handler.distribute_dofs (fe); + + for (types::boundary_id b : + { + 12, 13, 14, 15 + } ) + { + const unsigned int N = dof_handler.n_boundary_dofs(std::set {b}); + deallog << (int)b << ' ' << N << std::endl; + } +} + + + +int main() +{ + initlog(); + deallog.threshold_double(1.e-10); + + deallog.push("2d"); + test<2>(); + deallog.pop(); + + deallog.push("3d"); + test<3>(); + deallog.pop(); +} diff --git a/tests/dofs/n_boundary_dofs_03.output b/tests/dofs/n_boundary_dofs_03.output new file mode 100644 index 0000000000..b7ee62ad04 --- /dev/null +++ b/tests/dofs/n_boundary_dofs_03.output @@ -0,0 +1,9 @@ + +DEAL:2d::12 1 +DEAL:2d::13 1 +DEAL:2d::14 1 +DEAL:2d::15 1 +DEAL:3d::12 1 +DEAL:3d::13 1 +DEAL:3d::14 1 +DEAL:3d::15 1 diff --git a/tests/hp/n_boundary_dofs_02.cc b/tests/hp/n_boundary_dofs_02.cc new file mode 100644 index 0000000000..260cb8e605 --- /dev/null +++ b/tests/hp/n_boundary_dofs_02.cc @@ -0,0 +1,89 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2008 - 2015 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. +// +// --------------------------------------------------------------------- + + + +// test that hp::DoFHandler::n_boundary_dofs() yields the correct +// results in 1d, even if there are more than two boundary vertices + + +#include "../tests.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + + +template +void test() +{ + // create a triangulation that spans the disjoint interval [0,1] \union [2,3] + Triangulation<1,spacedim> triangulation_1; + GridGenerator::hyper_cube(triangulation_1, 0, 1); + + Triangulation<1,spacedim> triangulation_2; + GridGenerator::hyper_cube(triangulation_2, 2, 3); + + Triangulation<1,spacedim> triangulation; + GridGenerator::merge_triangulations(triangulation_1, + triangulation_2, + triangulation); + + + hp::FECollection<1,spacedim> fe; + fe.push_back (FESystem<1,spacedim>(FE_Q<1,spacedim>(1),1, + FE_DGQ<1,spacedim>(1), 1)); + fe.push_back (FESystem<1,spacedim>(FE_Q<1,spacedim>(2),2)); + + hp::DoFHandler<1,spacedim> dof_handler (triangulation); + + unsigned int index=0; + for (typename hp::DoFHandler<1,spacedim>::active_cell_iterator + cell = dof_handler.begin_active(); + cell != dof_handler.end(); ++cell, ++index) + cell->set_active_fe_index (index); + + dof_handler.distribute_dofs (fe); + + const unsigned int N = dof_handler.n_boundary_dofs(); + deallog << N << std::endl; +} + + +int main() +{ + initlog(); + deallog.threshold_double(1.e-10); + + deallog.push("2d"); + test<2>(); + deallog.pop(); + + deallog.push("3d"); + test<3>(); + deallog.pop(); +} diff --git a/tests/hp/n_boundary_dofs_02.output b/tests/hp/n_boundary_dofs_02.output new file mode 100644 index 0000000000..77af50e278 --- /dev/null +++ b/tests/hp/n_boundary_dofs_02.output @@ -0,0 +1,3 @@ + +DEAL:2d::6 +DEAL:3d::6 diff --git a/tests/hp/n_boundary_dofs_03.cc b/tests/hp/n_boundary_dofs_03.cc new file mode 100644 index 0000000000..48cc40fea9 --- /dev/null +++ b/tests/hp/n_boundary_dofs_03.cc @@ -0,0 +1,105 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2008 - 2015 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. +// +// --------------------------------------------------------------------- + + + +// test that hp::DoFHandler::n_boundary_dofs() yields the correct +// results in 1d, even if there are more than two boundary vertices +// +// same as the _02 test, but using the variant of the function that +// takes a std::set as argument + + +#include "../tests.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + + +template +void test() +{ + // create a triangulation that spans the disjoint interval [0,1] \union [2,3] + Triangulation<1,spacedim> triangulation_1; + GridGenerator::hyper_cube(triangulation_1, 0, 1); + + Triangulation<1,spacedim> triangulation_2; + GridGenerator::hyper_cube(triangulation_2, 2, 3); + + Triangulation<1,spacedim> triangulation; + GridGenerator::merge_triangulations(triangulation_1, + triangulation_2, + triangulation); + + // assign boundary ids + triangulation.begin()->face(0)->set_boundary_id(12); + triangulation.begin()->face(1)->set_boundary_id(13); + (++triangulation.begin())->face(0)->set_boundary_id(14); + (++triangulation.begin())->face(1)->set_boundary_id(15); + + + hp::FECollection<1,spacedim> fe; + fe.push_back (FESystem<1,spacedim>(FE_Q<1,spacedim>(1),1, + FE_DGQ<1,spacedim>(1), 1)); + fe.push_back (FESystem<1,spacedim>(FE_Q<1,spacedim>(2),2)); + + hp::DoFHandler<1,spacedim> dof_handler (triangulation); + + unsigned int index=0; + for (typename hp::DoFHandler<1,spacedim>::active_cell_iterator + cell = dof_handler.begin_active(); + cell != dof_handler.end(); ++cell, ++index) + cell->set_active_fe_index (index); + + dof_handler.distribute_dofs (fe); + + for (types::boundary_id b : + { + 12, 13, 14, 15 + } ) + { + const unsigned int N = dof_handler.n_boundary_dofs(std::set {b}); + deallog << (int)b << ' ' << N << std::endl; + } +} + + + +int main() +{ + initlog(); + deallog.threshold_double(1.e-10); + + deallog.push("2d"); + test<2>(); + deallog.pop(); + + deallog.push("3d"); + test<3>(); + deallog.pop(); +} diff --git a/tests/hp/n_boundary_dofs_03.output b/tests/hp/n_boundary_dofs_03.output new file mode 100644 index 0000000000..8f217a2ea8 --- /dev/null +++ b/tests/hp/n_boundary_dofs_03.output @@ -0,0 +1,9 @@ + +DEAL:2d::12 1 +DEAL:2d::13 1 +DEAL:2d::14 2 +DEAL:2d::15 2 +DEAL:3d::12 1 +DEAL:3d::13 1 +DEAL:3d::14 2 +DEAL:3d::15 2