]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Write complex periodicity_factor test
authorDaniel Garcia-Sanchez <daniel.garcia-sanchez@insp.upmc.fr>
Fri, 1 Nov 2019 13:59:41 +0000 (14:59 +0100)
committerDaniel Garcia-Sanchez <daniel.garcia-sanchez@insp.upmc.fr>
Fri, 1 Nov 2019 13:59:41 +0000 (14:59 +0100)
tests/bits/periodicity_09.cc [new file with mode: 0644]
tests/bits/periodicity_09.output [new file with mode: 0644]

diff --git a/tests/bits/periodicity_09.cc b/tests/bits/periodicity_09.cc
new file mode 100644 (file)
index 0000000..82baa4c
--- /dev/null
@@ -0,0 +1,94 @@
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2002 - 2018 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 periodic boundary conditions with a complex periodicity_factor for a
+// simple enough case where we know the exact set of constraints
+//
+// this test simply uses two hypercubes, refines one of them and matches the
+// faces at the far ends
+//
+// This test is based on bits/periodicity_02
+
+#include <deal.II/dofs/dof_accessor.h>
+#include <deal.II/dofs/dof_handler.h>
+#include <deal.II/dofs/dof_tools.h>
+
+#include <deal.II/fe/fe_q.h>
+
+#include <deal.II/grid/grid_generator.h>
+#include <deal.II/grid/tria.h>
+#include <deal.II/grid/tria_accessor.h>
+#include <deal.II/grid/tria_iterator.h>
+
+#include "../tests.h"
+
+
+
+template <int dim>
+void
+test()
+{
+  deallog << dim << "D" << std::endl;
+
+  // create a 2x1 (or 2x1x1) mesh and refine the leftmost cell
+  Triangulation<dim>        triangulation;
+  std::vector<unsigned int> repetitions(dim, 1);
+  repetitions[0] = 2;
+  GridGenerator::subdivided_hyper_rectangle(triangulation,
+                                            repetitions,
+                                            Point<dim>(),
+                                            (dim == 2 ? Point<dim>(2, 1) :
+                                                        Point<dim>(2, 1, 1)));
+  triangulation.begin_active()->set_refine_flag();
+  triangulation.execute_coarsening_and_refinement();
+
+  FE_Q<dim>       fe(1);
+  DoFHandler<dim> dof_handler(triangulation);
+  dof_handler.distribute_dofs(fe);
+
+
+  AffineConstraints<std::complex<double>> cm;
+  const std::complex<double>              periodicity_factor =
+    std::exp(-std::complex<double>(0, 1) * 0.4);
+
+  deallog << dim << " 1/periodicity_factor: " << 1. / periodicity_factor
+          << std::endl;
+
+  DoFTools::make_periodicity_constraints(dof_handler.begin(0)->face(0),
+                                         (++dof_handler.begin(0))->face(1),
+                                         cm,
+                                         ComponentMask(),
+                                         true,
+                                         false,
+                                         false,
+                                         FullMatrix<double>(),
+                                         std::vector<unsigned int>(),
+                                         periodicity_factor);
+  cm.print(deallog.get_file_stream());
+}
+
+
+
+int
+main()
+{
+  initlog();
+
+  test<2>();
+  test<3>();
+  return 0;
+}
diff --git a/tests/bits/periodicity_09.output b/tests/bits/periodicity_09.output
new file mode 100644 (file)
index 0000000..249e451
--- /dev/null
@@ -0,0 +1,25 @@
+
+DEAL::2D
+DEAL::2 1/periodicity_factor: (0.921061,0.389418)
+    4 1:  (0.921061,0.389418)
+    6 1:  (0.500000,0.00000)
+    6 3:  (0.500000,0.00000)
+    9 3:  (0.921061,0.389418)
+DEAL::3D
+DEAL::3 1/periodicity_factor: (0.921061,0.389418)
+    8 1:  (0.921061,0.389418)
+    10 1:  (0.500000,0.00000)
+    10 3:  (0.500000,0.00000)
+    12 1:  (0.500000,0.00000)
+    12 5:  (0.500000,0.00000)
+    14 1:  (0.250000,0.00000)
+    14 3:  (0.250000,0.00000)
+    14 5:  (0.250000,0.00000)
+    14 7:  (0.250000,0.00000)
+    19 3:  (0.921061,0.389418)
+    21 3:  (0.500000,0.00000)
+    21 7:  (0.500000,0.00000)
+    24 5:  (0.921061,0.389418)
+    26 5:  (0.500000,0.00000)
+    26 7:  (0.500000,0.00000)
+    29 7:  (0.921061,0.389418)

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.