]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Fix bug in distribute_dofs 11486/head
authorCe Qin <qince168@gmail.com>
Wed, 6 Jan 2021 12:09:15 +0000 (20:09 +0800)
committerCe Qin <qince168@gmail.com>
Thu, 7 Jan 2021 07:03:16 +0000 (15:03 +0800)
source/dofs/dof_handler.cc
tests/dofs/distribute_dofs_01.cc [new file with mode: 0644]
tests/dofs/distribute_dofs_01.debug.output [new file with mode: 0644]

index f6becc13227b3ca69289743e7b76d3ef48fecd24..d0b2a6661b841d3e869ab8ee0fc716d9305bbf21 100644 (file)
@@ -2056,6 +2056,9 @@ DoFHandler<dim, spacedim>::reinit(const Triangulation<dim, spacedim> &tria)
   DoFHandler<dim, spacedim>::clear();
   this->policy.reset();
 
+  // reset the finite element collection
+  this->fe_collection = hp::FECollection<dim, spacedim>();
+
   //
   // call constructor
   //
diff --git a/tests/dofs/distribute_dofs_01.cc b/tests/dofs/distribute_dofs_01.cc
new file mode 100644 (file)
index 0000000..337a9a6
--- /dev/null
@@ -0,0 +1,58 @@
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2010 - 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.
+//
+// ---------------------------------------------------------------------
+
+#include <deal.II/dofs/dof_handler.h>
+
+#include <deal.II/fe/fe_nedelec.h>
+
+#include <deal.II/grid/grid_generator.h>
+#include <deal.II/grid/tria.h>
+
+#include "../tests.h"
+
+// Check DoFHandler::distribute_dofs with multiple calls to reinit
+
+void
+test()
+{
+  dealii::Triangulation<3> tria;
+  dealii::GridGenerator::hyper_cube(tria, -1, 1);
+
+  dealii::FE_Nedelec<3> fe_nedelec(0);
+
+  dealii::DoFHandler<3> dh_nedelec;
+
+  dh_nedelec.reinit(tria);
+  dh_nedelec.distribute_dofs(fe_nedelec);
+
+  dh_nedelec.reinit(tria);
+  dh_nedelec.distribute_dofs(fe_nedelec);
+
+  for (const auto &cell : dh_nedelec.active_cell_iterators())
+    for (unsigned int i = 0; i < dealii::GeometryInfo<3>::lines_per_cell; ++i)
+      cell->line(i)->dof_index(0);
+
+  deallog << "ok" << std::endl;
+}
+
+int
+main()
+{
+  initlog();
+
+  test();
+
+  return 0;
+}
diff --git a/tests/dofs/distribute_dofs_01.debug.output b/tests/dofs/distribute_dofs_01.debug.output
new file mode 100644 (file)
index 0000000..0de3521
--- /dev/null
@@ -0,0 +1,2 @@
+
+DEAL::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.