From: Timo Heister
Date: Thu, 9 Jul 2015 15:54:20 +0000 (-0400)
Subject: switch GridTools::distort_random to boost::random
X-Git-Tag: v8.3.0-rc1~42^2
X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8029c23cf7a4572272cccd00384c59021844abcb;p=dealii.git
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).
---
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.
+
+ - Changed: GridTools::distort_random is now deterministic (gives the same
+ distorted mesh when called with the same input Triangulation).
+
+ (Timo Heister, 2015/07/09)
+
+
- 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