From 8029c23cf7a4572272cccd00384c59021844abcb Mon Sep 17 00:00:00 2001 From: Timo Heister Date: Thu, 9 Jul 2015 11:54:20 -0400 Subject: [PATCH] switch GridTools::distort_random to boost::random Use boost::random instead of std::rand(). This makes calls to the function deterministic (distortion will always be the same for the same mesh) and hopefully makes the testsuite more robust (differences in rand() on MAC OS). --- doc/news/changes.h | 7 + source/grid/grid_tools.cc | 18 +- tests/bits/rt_2.output | 2592 +++++++------- tests/deal.II/distort_random.output | 3676 ++++++++++---------- tests/deal.II/nedelec_non_rect_2d.output | 6 +- tests/deal.II/nedelec_non_rect_face.output | 18 +- tests/fe/rt_normal_02.output | 2264 ++++++------ 7 files changed, 4294 insertions(+), 4287 deletions(-) diff --git a/doc/news/changes.h b/doc/news/changes.h index c3c3dc557d..b6b33f8c40 100644 --- a/doc/news/changes.h +++ b/doc/news/changes.h @@ -38,6 +38,13 @@ inconvenience this causes.

    + +
  1. Changed: GridTools::distort_random is now deterministic (gives the same + distorted mesh when called with the same input Triangulation). +
    + (Timo Heister, 2015/07/09) +
  2. +
  3. Changed: MatrixCreator::create_mass_matrix() took matrix and vector objects where the scalar type of the matrix was a template argument but the scalar type of the vector was always double. This diff --git a/source/grid/grid_tools.cc b/source/grid/grid_tools.cc index 56568a97e0..b157fcae93 100644 --- a/source/grid/grid_tools.cc +++ b/source/grid/grid_tools.cc @@ -856,19 +856,19 @@ namespace GridTools } } + // create a random number generator for the interval [-1,1]. we use + // this to make sure the distribution we get is repeatable, i.e., + // if you call the function twice on the same mesh, then you will + // get the same mesh. this would not be the case if you used + // the rand() function, which carries around some internal state + boost::random::mt19937 rng; + boost::random::uniform_real_distribution<> uniform_distribution(-1,1); + // If the triangulation is distributed, we need to // exchange the moved vertices across mpi processes if (parallel::distributed::Triangulation< dim, spacedim > *distributed_triangulation = dynamic_cast*> (&triangulation)) { - // create a random number generator for the interval [-1,1]. we use - // this to make sure the distribution we get is repeatable, i.e., - // if you call the function twice on the same mesh, then you will - // get the same mesh. this would not be the case if you used - // the rand() function, which carries around some internal state - boost::random::mt19937 rng; - boost::random::uniform_real_distribution<> uniform_distribution(-1,1); - const std::vector locally_owned_vertices = get_locally_owned_vertices(triangulation); std::vector vertex_moved (triangulation.n_vertices(), false); @@ -935,7 +935,7 @@ namespace GridTools // compute a random shift vector Point shift_vector; for (unsigned int d=0; d