]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Add tests.
authorWolfgang Bangerth <bangerth@colostate.edu>
Mon, 10 Jul 2017 14:07:05 +0000 (08:07 -0600)
committerWolfgang Bangerth <bangerth@colostate.edu>
Mon, 10 Jul 2017 14:07:05 +0000 (08:07 -0600)
tests/dofs/n_boundary_dofs_02.cc [new file with mode: 0644]
tests/dofs/n_boundary_dofs_02.output [new file with mode: 0644]
tests/dofs/n_boundary_dofs_03.cc [new file with mode: 0644]
tests/dofs/n_boundary_dofs_03.output [new file with mode: 0644]
tests/hp/n_boundary_dofs_02.cc [new file with mode: 0644]
tests/hp/n_boundary_dofs_02.output [new file with mode: 0644]
tests/hp/n_boundary_dofs_03.cc [new file with mode: 0644]
tests/hp/n_boundary_dofs_03.output [new file with mode: 0644]

diff --git a/tests/dofs/n_boundary_dofs_02.cc b/tests/dofs/n_boundary_dofs_02.cc
new file mode 100644 (file)
index 0000000..74c15ab
--- /dev/null
@@ -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 <deal.II/base/logstream.h>
+#include <deal.II/base/tensor.h>
+#include <deal.II/grid/tria.h>
+#include <deal.II/grid/tria_accessor.h>
+#include <deal.II/grid/tria_iterator.h>
+#include <deal.II/grid/grid_generator.h>
+#include <deal.II/grid/intergrid_map.h>
+#include <deal.II/base/utilities.h>
+#include <deal.II/dofs/dof_handler.h>
+#include <deal.II/fe/fe_system.h>
+#include <deal.II/fe/fe_q.h>
+#include <deal.II/fe/fe_dgq.h>
+
+#include <fstream>
+#include <cstdlib>
+
+
+template <int spacedim>
+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 (file)
index 0000000..c94fad7
--- /dev/null
@@ -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 (file)
index 0000000..b3f7de8
--- /dev/null
@@ -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 <deal.II/base/logstream.h>
+#include <deal.II/base/tensor.h>
+#include <deal.II/grid/tria.h>
+#include <deal.II/grid/tria_accessor.h>
+#include <deal.II/grid/tria_iterator.h>
+#include <deal.II/grid/grid_generator.h>
+#include <deal.II/grid/intergrid_map.h>
+#include <deal.II/base/utilities.h>
+#include <deal.II/dofs/dof_handler.h>
+#include <deal.II/fe/fe_system.h>
+#include <deal.II/fe/fe_q.h>
+#include <deal.II/fe/fe_dgq.h>
+
+#include <fstream>
+#include <cstdlib>
+
+
+template <int spacedim>
+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<types::boundary_id> {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 (file)
index 0000000..b7ee62a
--- /dev/null
@@ -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 (file)
index 0000000..260cb8e
--- /dev/null
@@ -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 <deal.II/base/logstream.h>
+#include <deal.II/base/tensor.h>
+#include <deal.II/grid/tria.h>
+#include <deal.II/grid/tria_accessor.h>
+#include <deal.II/grid/tria_iterator.h>
+#include <deal.II/grid/grid_generator.h>
+#include <deal.II/grid/intergrid_map.h>
+#include <deal.II/base/utilities.h>
+#include <deal.II/hp/dof_handler.h>
+#include <deal.II/fe/fe_system.h>
+#include <deal.II/fe/fe_q.h>
+#include <deal.II/fe/fe_dgq.h>
+#include <deal.II/hp/fe_collection.h>
+
+#include <fstream>
+#include <cstdlib>
+
+
+template <int spacedim>
+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 (file)
index 0000000..77af50e
--- /dev/null
@@ -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 (file)
index 0000000..48cc40f
--- /dev/null
@@ -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 <deal.II/base/logstream.h>
+#include <deal.II/base/tensor.h>
+#include <deal.II/grid/tria.h>
+#include <deal.II/grid/tria_accessor.h>
+#include <deal.II/grid/tria_iterator.h>
+#include <deal.II/grid/grid_generator.h>
+#include <deal.II/grid/intergrid_map.h>
+#include <deal.II/base/utilities.h>
+#include <deal.II/hp/dof_handler.h>
+#include <deal.II/fe/fe_system.h>
+#include <deal.II/fe/fe_q.h>
+#include <deal.II/fe/fe_dgq.h>
+#include <deal.II/hp/fe_collection.h>
+
+#include <fstream>
+#include <cstdlib>
+
+
+template <int spacedim>
+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<types::boundary_id> {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 (file)
index 0000000..8f217a2
--- /dev/null
@@ -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

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.