From 20129485f1286484c5cfc4aaf9639072607d2325 Mon Sep 17 00:00:00 2001 From: Peter Munch Date: Sat, 22 May 2021 09:02:24 +0200 Subject: [PATCH] Clone policy in Triangulation --- source/grid/tria.cc | 6 ++++++ tests/grid/copy.cc | 45 ++++++++++++++++++++++++++++++++++++++++++ tests/grid/copy.output | 2 ++ 3 files changed, 53 insertions(+) create mode 100644 tests/grid/copy.cc create mode 100644 tests/grid/copy.output diff --git a/source/grid/tria.cc b/source/grid/tria.cc index 244459f03f..96efb3aa05 100644 --- a/source/grid/tria.cc +++ b/source/grid/tria.cc @@ -10039,6 +10039,9 @@ Triangulation::Triangulation( , vertex_to_manifold_id_map_1d(std::move(tria.vertex_to_manifold_id_map_1d)) { tria.number_cache = internal::TriangulationImplementation::NumberCache(); + + if (tria.policy) + this->policy = tria.policy->clone(); } @@ -10065,6 +10068,9 @@ operator=(Triangulation &&tria) noexcept tria.number_cache = internal::TriangulationImplementation::NumberCache(); + 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 index 0000000000..700e5c4eb3 --- /dev/null +++ b/tests/grid/copy.cc @@ -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 +#include + +#include "../tests.h" + +// Test Triangulation::operator=(Triangulation +// &&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 index 0000000000..0fd8fc12f0 --- /dev/null +++ b/tests/grid/copy.output @@ -0,0 +1,2 @@ + +DEAL::OK -- 2.39.5