From: Peter Munch Date: Sat, 22 May 2021 07:02:24 +0000 (+0200) Subject: Clone policy in Triangulation X-Git-Tag: v9.3.0-rc1~13^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F12279%2Fhead;p=dealii.git Clone policy in Triangulation --- 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