]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Added test for identity constraints in h-adapted grids. 15268/head
authorMarc Fehling <mafehling.git@gmail.com>
Wed, 24 May 2023 23:02:49 +0000 (17:02 -0600)
committerMarc Fehling <mafehling.git@gmail.com>
Wed, 24 May 2023 23:05:45 +0000 (17:05 -0600)
tests/lac/identity_constraints_01.cc [new file with mode: 0644]
tests/lac/identity_constraints_01.output [new file with mode: 0644]

diff --git a/tests/lac/identity_constraints_01.cc b/tests/lac/identity_constraints_01.cc
new file mode 100644 (file)
index 0000000..a607570
--- /dev/null
@@ -0,0 +1,88 @@
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2023 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.md at
+// the top level directory of deal.II.
+//
+// ---------------------------------------------------------------------
+
+
+// Check for identity constraints using different finite elements
+// in h-refined grids with hanging nodes.
+//   +---+---+-------+
+//   |   |   |       |
+//   +---+---+       |
+//   |   |   |       |
+//   +---+---+-------+
+
+
+#include <deal.II/dofs/dof_handler.h>
+#include <deal.II/dofs/dof_tools.h>
+
+#include <deal.II/fe/fe_q.h>
+#include <deal.II/fe/fe_system.h>
+
+#include <deal.II/grid/tria.h>
+
+#include <deal.II/lac/affine_constraints.h>
+
+#include "../tests.h"
+
+#include "../test_grids.h"
+
+
+template <int dim>
+void
+test(const FiniteElement<dim> &fe)
+{
+  Triangulation<dim> tria;
+  TestGrids::hyper_line(tria, 2);
+  tria.begin_active()->set_refine_flag();
+  tria.execute_coarsening_and_refinement();
+
+  DoFHandler<dim> dofh(tria);
+  dofh.distribute_dofs(fe);
+
+  AffineConstraints<double> constraints;
+  DoFTools::make_hanging_node_constraints(dofh, constraints);
+  constraints.close();
+
+  deallog << fe.get_name() << ":";
+  // print dof identities
+  for (const auto &line : constraints.get_lines())
+    if ((line.entries.size() == 1) && (line.entries[0].second == 1.))
+      deallog << " " << line.index << "=" << line.entries[0].first;
+  deallog << std::endl;
+
+#if false
+  constraints.print(deallog.get_file_stream());
+#endif
+}
+
+
+int
+main()
+{
+  initlog();
+
+  {
+    constexpr int dim = 2;
+
+    for (unsigned int degree = 1; degree <= 9; ++degree)
+      test<dim>(FE_Q<dim>(degree));
+  }
+
+  {
+    constexpr int dim = 3;
+
+    for (unsigned int degree = 1; degree <= 9; ++degree)
+      test<dim>(FE_Q<dim>(degree));
+  }
+}
diff --git a/tests/lac/identity_constraints_01.output b/tests/lac/identity_constraints_01.output
new file mode 100644 (file)
index 0000000..b6a54b8
--- /dev/null
@@ -0,0 +1,19 @@
+
+DEAL::FE_Q<2>(1):
+DEAL::FE_Q<2>(2): 18=4
+DEAL::FE_Q<2>(3):
+DEAL::FE_Q<2>(4): 50=5
+DEAL::FE_Q<2>(5):
+DEAL::FE_Q<2>(6): 98=6
+DEAL::FE_Q<2>(7):
+DEAL::FE_Q<2>(8): 162=7
+DEAL::FE_Q<2>(9):
+DEAL::FE_Q<3>(1):
+DEAL::FE_Q<3>(2): 54=8 55=16 56=20 89=18 118=12
+DEAL::FE_Q<3>(3):
+DEAL::FE_Q<3>(4): 250=9 251=33 252=48 449=39 628=21
+DEAL::FE_Q<3>(5):
+DEAL::FE_Q<3>(6): 686=10 687=50 688=80 1273=60 1818=30
+DEAL::FE_Q<3>(7):
+DEAL::FE_Q<3>(8): 1458=11 1459=67 1460=116 2753=81 3976=39
+DEAL::FE_Q<3>(9):

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.