]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Bugfix: Clear DoFHandler in Triangulation create signal. 11627/head
authorMarc Fehling <mafehling.git@gmail.com>
Tue, 26 Jan 2021 02:00:40 +0000 (19:00 -0700)
committerMarc Fehling <marc.fehling@gmx.net>
Thu, 28 Jan 2021 21:14:14 +0000 (14:14 -0700)
include/deal.II/grid/grid_generator.h
include/deal.II/grid/tria.h
source/dofs/dof_handler.cc
tests/hp/crash_22.cc [new file with mode: 0644]
tests/hp/crash_22.output [new file with mode: 0644]

index d17c7e5d02366cdf055361b58e6efc264875638c..6dfaee23c63859d3fb2e59a6a9270c6562b356f9 100644 (file)
@@ -1522,6 +1522,7 @@ namespace GridGenerator
    * Given the two triangulations specified as the first two arguments, create
    * the triangulation that contains the cells of both triangulation and store
    * it in the third parameter. Previous content of @p result will be deleted.
+   * One of the two input triangulations can also be the @p result triangulation.
    *
    * This function is most often used to compose meshes for more complicated
    * geometries if the geometry can be composed of simpler parts for which
index 058550145ce2f4e898860f39bcf2cec45fb4c95a..55b0e7e5b0a4f5c528214d68d92ae6ede24494e0 100644 (file)
@@ -1830,7 +1830,9 @@ public:
    * @note This function is used in step-14 and step-19.
    *
    * @note This function triggers the "create" signal after doing its work. See
-   * the section on signals in the general documentation of this class.
+   * the section on signals in the general documentation of this class. For
+   * example as a consequence of this, all DoFHandler objects connected to
+   * this triangulation will be reinitialized via DoFHandler::reinit().
    *
    * @note The check for distorted cells is only done if dim==spacedim, as
    * otherwise cells can legitimately be twisted if the manifold they describe
index d0b2a6661b841d3e869ab8ee0fc716d9305bbf21..d88ce7c1356bc2947a164222c28e0983379c0936 100644 (file)
@@ -3043,7 +3043,7 @@ DoFHandler<dim, spacedim>::connect_to_triangulation_signals()
 {
   // connect functions to signals of the underlying triangulation
   this->tria_listeners.push_back(this->tria->signals.create.connect(
-    [this]() { this->create_active_fe_table(); }));
+    [this]() { this->reinit(*(this->tria)); }));
 
   // attach corresponding callback functions dealing with the transfer of
   // active FE indices depending on the type of triangulation
diff --git a/tests/hp/crash_22.cc b/tests/hp/crash_22.cc
new file mode 100644 (file)
index 0000000..b396697
--- /dev/null
@@ -0,0 +1,68 @@
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2021 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.
+//
+// ---------------------------------------------------------------------
+
+
+
+// Consider a Triangulation with a connected DoFHandler.
+// When Triangulation::create_triangulation() gets called (e.g. in
+// GridGenerator::merge_triangulations()) the corresponding create signal
+// gets triggered.
+// At some point, we forgot to reset the DoFHandler at this stage.
+
+
+#include <deal.II/dofs/dof_handler.h>
+
+#include <deal.II/grid/grid_generator.h>
+#include <deal.II/grid/tria.h>
+
+#include "../tests.h"
+
+
+template <int dim>
+void
+test()
+{
+  Triangulation<dim> triangulation;
+  DoFHandler<dim>    dof_handler(triangulation);
+
+  /*Make a square*/
+  Point<dim> point_1, point_2;
+  point_1(0) = 0;
+  point_1(1) = 0;
+  point_2(0) = 1;
+  point_2(1) = 1;
+  GridGenerator::hyper_rectangle(triangulation, point_1, point_2);
+
+  Triangulation<dim> triangulation_temp;
+  point_1(0) = 1;
+  point_2(0) = 2;
+  GridGenerator::hyper_rectangle(triangulation_temp, point_1, point_2);
+  /*glue squares together*/
+  GridGenerator::merge_triangulations(triangulation_temp,
+                                      triangulation,
+                                      triangulation);
+
+  deallog << "OK" << std::endl;
+}
+
+int
+main()
+{
+  initlog();
+
+  deallog.push("2d");
+  test<2>();
+  deallog.pop();
+}
diff --git a/tests/hp/crash_22.output b/tests/hp/crash_22.output
new file mode 100644 (file)
index 0000000..f445833
--- /dev/null
@@ -0,0 +1,2 @@
+
+DEAL:2d::OK

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.