]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Clone policy in Triangulation 12279/head
authorPeter Munch <peterrmuench@gmail.com>
Sat, 22 May 2021 07:02:24 +0000 (09:02 +0200)
committerPeter Munch <peterrmuench@gmail.com>
Sat, 22 May 2021 07:05:57 +0000 (09:05 +0200)
source/grid/tria.cc
tests/grid/copy.cc [new file with mode: 0644]
tests/grid/copy.output [new file with mode: 0644]

index 244459f03fba602c25c1d9b4284c606c83a850c7..96efb3aa0557d3d98821720084515a45090441bc 100644 (file)
@@ -10039,6 +10039,9 @@ Triangulation<dim, spacedim>::Triangulation(
   , vertex_to_manifold_id_map_1d(std::move(tria.vertex_to_manifold_id_map_1d))
 {
   tria.number_cache = internal::TriangulationImplementation::NumberCache<dim>();
+
+  if (tria.policy)
+    this->policy = tria.policy->clone();
 }
 
 
@@ -10065,6 +10068,9 @@ operator=(Triangulation<dim, spacedim> &&tria) noexcept
 
   tria.number_cache = internal::TriangulationImplementation::NumberCache<dim>();
 
+  if (tria.policy)
+    this->policy = tria.policy->clone();
+
   return *this;
 }
 
diff --git a/tests/grid/copy.cc b/tests/grid/copy.cc
new file mode 100644 (file)
index 0000000..700e5c4
--- /dev/null
@@ -0,0 +1,45 @@
+// ---------------------------------------------------------------------
+//
+// 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.
+//
+// ---------------------------------------------------------------------
+
+#include <deal.II/grid/grid_generator.h>
+#include <deal.II/grid/tria.h>
+
+#include "../tests.h"
+
+// Test Triangulation<dim, spacedim>::operator=(Triangulation<dim, spacedim>
+// &&tria)
+
+dealii::Triangulation<2>
+createDummyTria()
+{
+  dealii::Triangulation<2, 2> patch;
+  dealii::GridGenerator::hyper_cube<2>(patch);
+  dealii::Triangulation<2> tria;
+  tria.copy_triangulation(patch); // here the policies are copied (just a check)
+  return patch;                   // patch has the policies
+}
+
+int
+main()
+{
+  initlog();
+
+  dealii::Triangulation<2> tria;
+  tria.copy_triangulation(createDummyTria());
+
+  tria.refine_global();
+
+  deallog << "OK" << std::endl;
+}
diff --git a/tests/grid/copy.output b/tests/grid/copy.output
new file mode 100644 (file)
index 0000000..0fd8fc1
--- /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.