From: Luca Heltai Date: Tue, 21 Nov 2017 11:34:55 +0000 (+0100) Subject: Added random_value and random_point to tests.h X-Git-Tag: v9.0.0-rc1~739^2~2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fb0025ff212cfce6168a0a1683bc4c1fb8dd9218;p=dealii.git Added random_value and random_point to tests.h --- diff --git a/doc/news/changes/minor/20171121LucaHeltai b/doc/news/changes/minor/20171121LucaHeltai new file mode 100644 index 0000000000..bdc219ea92 --- /dev/null +++ b/doc/news/changes/minor/20171121LucaHeltai @@ -0,0 +1,3 @@ +New: Added random_value() and random_point() in tests.h, to simplify and unify our way to generate random numbers and points. +
+(Luca Heltai, 2017/11/21) diff --git a/tests/arpack/step-36_parpack_mf_02.cc b/tests/arpack/step-36_parpack_mf_02.cc index dcc6582c56..5759d83082 100644 --- a/tests/arpack/step-36_parpack_mf_02.cc +++ b/tests/arpack/step-36_parpack_mf_02.cc @@ -145,7 +145,7 @@ void test () LinearAlgebra::distributed::Vector init_vector; mf_data->initialize_dof_vector(init_vector); for (auto it = init_vector.begin(); it != init_vector.end(); ++it) - *it = static_cast(Testing::rand())/static_cast(RAND_MAX); + *it = random_value(); constraints.set_zero(init_vector); eigensolver.set_initial_vector(init_vector); diff --git a/tests/arpack/step-36_parpack_mf_03.cc b/tests/arpack/step-36_parpack_mf_03.cc index 5e9b4ac935..a4e5cf0478 100644 --- a/tests/arpack/step-36_parpack_mf_03.cc +++ b/tests/arpack/step-36_parpack_mf_03.cc @@ -145,7 +145,7 @@ void test () LinearAlgebra::distributed::Vector init_vector; mf_data->initialize_dof_vector(init_vector); for (auto it = init_vector.begin(); it != init_vector.end(); ++it) - *it = static_cast(Testing::rand())/static_cast(RAND_MAX); + *it = random_value(); constraints.set_zero(init_vector); eigensolver.set_initial_vector(init_vector); diff --git a/tests/base/full_tensor_10.cc b/tests/base/full_tensor_10.cc index 878ea9f0e8..02fa86b467 100644 --- a/tests/base/full_tensor_10.cc +++ b/tests/base/full_tensor_10.cc @@ -29,7 +29,7 @@ void test () // as in symmetric_tensor_10 for (unsigned int i=0; i(); for (unsigned int i=0; i p; for (unsigned int d=0; d()) * (coordinates[d].back() - + coordinates[d][0]); double exact_value = 1; for (unsigned int d=0; d p; for (unsigned int d=0; d()) * (coordinates[d].back() - + coordinates[d][0]); double exact_value = 1; for (unsigned int d=0; d()*4-2.; } diff --git a/tests/base/polynomial_lagrange_ops.cc b/tests/base/polynomial_lagrange_ops.cc index f8808d1f3f..4c3a349359 100644 --- a/tests/base/polynomial_lagrange_ops.cc +++ b/tests/base/polynomial_lagrange_ops.cc @@ -32,8 +32,8 @@ void check_scale (const std::vector > &p) for (unsigned int i=0; i q = p[i]; - double x = (double)Testing::rand()/RAND_MAX; - double factor = 5.*(double)Testing::rand()/RAND_MAX; + double x = random_value(); + double factor = 5.*random_value(); q.scale (factor); double value1 = p[i].value (factor * x); double value2 = q .value (x); @@ -57,8 +57,8 @@ void check_shift (const std::vector > &p) for (unsigned int i=0; i q = p[i]; - double x = (double)Testing::rand()/RAND_MAX; - double a = 10.*(-1.+2.*(double)Testing::rand()/RAND_MAX); + double x = random_value(); + double a = 10.*(-1.+2.*random_value()); q.shift (a); double value1 = p[i].value (x+a); double value2 = q .value (x); @@ -78,8 +78,8 @@ void check_mult_scalar (const std::vector > &p) for (unsigned int i=0; i q = p[i]; - double x = (double)Testing::rand()/RAND_MAX; - double a = (double)Testing::rand()/RAND_MAX; + double x = random_value(); + double a = random_value(); q *= a; double value1 = p[i].value (x) * a; double value2 = q .value (x); @@ -102,7 +102,7 @@ void check_mult (const std::vector > &p) { Polynomial q = p[i]; q *= p[j]; - double x = (double)Testing::rand()/RAND_MAX; + double x = random_value(); double value1 = p[i].value (x) * p[j].value(x); double value2 = q .value (x); if (std::fabs(value1-value2) > std::max(1e-13,1e-13*std::fabs(value1))) @@ -134,7 +134,7 @@ void check_expand (const std::vector > &p) for (unsigned int i=0; i q = p[i]; - double x = (double)Testing::rand()/RAND_MAX; + double x = random_value(); q += zero; double value1 = p[i].value (x); double value2 = q .value (x); @@ -161,7 +161,7 @@ void check_mult_expand (const std::vector > &p) Polynomial q = p[i]; q += zero; q *= p[j]; - double x = (double)Testing::rand()/RAND_MAX; + double x = random_value(); double value1 = p[i].value (x) * p[j].value(x); double value2 = q .value (x); if (std::fabs(value1-value2) > std::max(1e-9,1e-9*std::fabs(value1))) diff --git a/tests/base/polynomial_lagrange_order.cc b/tests/base/polynomial_lagrange_order.cc index 4ae4fd8244..1ce08e86ee 100644 --- a/tests/base/polynomial_lagrange_order.cc +++ b/tests/base/polynomial_lagrange_order.cc @@ -63,7 +63,7 @@ void check_constant (const std::vector > &p) deallog << "Representation of one at random points"; for (unsigned int j=0; j<12; ++j) { - double x = (double)Testing::rand()/RAND_MAX; + double x = random_value(); double value = 0; for (unsigned int i=0; i > &p, Monomial zero (0,0); for (unsigned int j=0; j(); p[j].value (x, values); Polynomial q = p[j]; q += zero; diff --git a/tests/base/symmetric_tensor_19.cc b/tests/base/symmetric_tensor_19.cc index 21093e19c9..2e881f695e 100644 --- a/tests/base/symmetric_tensor_19.cc +++ b/tests/base/symmetric_tensor_19.cc @@ -107,7 +107,7 @@ void test () for (unsigned int j=0; j<3; ++j) for (unsigned int k=0; k<3; ++k) for (unsigned int l=0; l<3; ++l) - A[i][j][k][l] = 1.*Testing::rand()/RAND_MAX; + A[i][j][k][l] = random_value(); break; default: diff --git a/tests/base/utilities_pack_unpack_01.cc b/tests/base/utilities_pack_unpack_01.cc index 40ede8e996..e0943547e4 100644 --- a/tests/base/utilities_pack_unpack_01.cc +++ b/tests/base/utilities_pack_unpack_01.cc @@ -27,8 +27,7 @@ void test(const unsigned int &size) std::vector > points(size); for (auto &p : points) - for (unsigned int i=0; i(); auto buffer = Utilities::pack(points); diff --git a/tests/base/utilities_pack_unpack_02.cc b/tests/base/utilities_pack_unpack_02.cc index 194354ee55..11aff6845b 100644 --- a/tests/base/utilities_pack_unpack_02.cc +++ b/tests/base/utilities_pack_unpack_02.cc @@ -31,8 +31,7 @@ void test(const unsigned int &size) auto a_pair = std::make_pair(1, 3.14); for (auto &p : points) - for (unsigned int i=0; i(); auto a_tuple = std::make_tuple(a_pair, points); diff --git a/tests/base/vectorization_03.cc b/tests/base/vectorization_03.cc index 71b6f8fcae..7c2a0e8f4f 100644 --- a/tests/base/vectorization_03.cc +++ b/tests/base/vectorization_03.cc @@ -51,11 +51,11 @@ struct Evaluation void initialize(Evaluation &eval) { eval.is_cartesian = true; - eval.cartesian_weight = static_cast(rand())/RAND_MAX; + eval.cartesian_weight = random_value(); for (unsigned int i=0; i<4; ++i) eval.cartesian_weight = std::max(eval.cartesian_weight, eval.cartesian_weight * eval.cartesian_weight); eval.general_weight[0] = 0.2313342 * eval.cartesian_weight; - eval.jac_weight[0] = static_cast(rand())/RAND_MAX; + eval.jac_weight[0] = random_value(); } @@ -65,11 +65,11 @@ void test() initialize(current); initialize(old); VectorizedArray weight; - weight = static_cast(rand())/RAND_MAX; + weight = random_value(); VectorizedArray vec; for (unsigned int v=0; v::n_array_elements; ++v) - vec[v] = static_cast(rand())/RAND_MAX; + vec[v] = random_value(); current.values[0] = vec; old.values[0] = vec * 1.112 - std::max(2.*vec - 1., VectorizedArray()); diff --git a/tests/bits/chunk_sparse_matrix_15.cc b/tests/bits/chunk_sparse_matrix_15.cc index 126d5a7007..4c332f37ef 100644 --- a/tests/bits/chunk_sparse_matrix_15.cc +++ b/tests/bits/chunk_sparse_matrix_15.cc @@ -49,7 +49,7 @@ void test (const unsigned int chunk_size) // the iterator and compare it with the exact value Vector src(m.n()), dst(m.m()), dst_ref(m.m()); for (unsigned int i=0; i(); for (unsigned int i=0; i src(m.n()), dst(m.m()), dst_ref(m.m()); for (unsigned int i=0; i(); std::vector indices(sp.max_entries_per_row()); std::vector values(sp.max_entries_per_row()); for (unsigned int i=0; i::TestFunction (const unsigned int p_order) : for (unsigned int d = 0; d < dim; ++d) { for (unsigned int c = 0; c < p_order; ++c) - coeff[c] = (double) Testing::rand() / (double) RAND_MAX; + coeff[c] = random_value(); base.push_back (Polynomials::Polynomial (coeff)); } } @@ -134,7 +134,7 @@ void TestFEQConstraints::refine_grid_random () Vector estimated_error_per_cell (n_cells); for (unsigned int i = 0; i < n_cells; ++i) - estimated_error_per_cell(i) = (double) Testing::rand() / (double) RAND_MAX; + estimated_error_per_cell(i) = random_value(); GridRefinement::refine_and_coarsen_fixed_number (triangulation, estimated_error_per_cell, diff --git a/tests/bits/find_cell_13.cc b/tests/bits/find_cell_13.cc index 146976f23d..946eb9744f 100644 --- a/tests/bits/find_cell_13.cc +++ b/tests/bits/find_cell_13.cc @@ -37,8 +37,8 @@ void check (Triangulation<2> &tria) // generate some random points bounded by [0., 0.2)^2 in R^2 space // any point in this domain should be inside one of the cells - Point<2> p( static_cast(Testing::rand())/static_cast(RAND_MAX), - static_cast(Testing::rand())/static_cast(RAND_MAX)/8. ); + Point<2> p( random_value(), + random_value()/8. ); try { diff --git a/tests/bits/joa_1.cc b/tests/bits/joa_1.cc index d7df30f75f..52d17ea024 100644 --- a/tests/bits/joa_1.cc +++ b/tests/bits/joa_1.cc @@ -1068,7 +1068,7 @@ void LaplaceProblem::run () // points inside a radius of 0.9) for (int i=0; i<1000; i++) { - double r = sqrt((0.9*Testing::rand()/RAND_MAX)); + double r = sqrt(random_value(.9)); double phi = 2*3.14*(1.0*Testing::rand()/RAND_MAX); double x = r*cos(phi); double y = r*sin(phi); diff --git a/tests/bits/rt_2.cc b/tests/bits/rt_2.cc index 791863b606..3a19d7d22a 100644 --- a/tests/bits/rt_2.cc +++ b/tests/bits/rt_2.cc @@ -154,7 +154,7 @@ int main () // values between 0 and 1. Vector solution(dof_handler.n_dofs ()); for (unsigned int i = 0; i < dof_handler.n_dofs (); ++i) - solution(i) = (double) Testing::rand() / (double) RAND_MAX; + solution(i) = random_value(); // Now check if the function is // continuous in normal direction diff --git a/tests/fail/hp-step-15.cc b/tests/fail/hp-step-15.cc index 669b2ebdff..ba8508ceee 100644 --- a/tests/fail/hp-step-15.cc +++ b/tests/fail/hp-step-15.cc @@ -81,7 +81,7 @@ double InitializationValues::value (const Point<1> &p, const unsigned int) const { const double base = std::pow(p(0), 1./3.); - const double random = 2.*Testing::rand()/RAND_MAX-1; + const double random = random_value(-1., 1.); return std::max (base+.1*random, 0.); } diff --git a/tests/fail/step-15.cc b/tests/fail/step-15.cc index 1136e85740..e94207416f 100644 --- a/tests/fail/step-15.cc +++ b/tests/fail/step-15.cc @@ -79,7 +79,7 @@ double InitializationValues::value (const Point<1> &p, const unsigned int) const { const double base = std::pow(p(0), 1./3.); - const double random = 2.*Testing::rand()/RAND_MAX-1; + const double random = random_value(-1., 1.); return std::max (base+.1*random, 0.); } diff --git a/tests/fe/abf_03.cc b/tests/fe/abf_03.cc index a035c828be..c503926052 100644 --- a/tests/fe/abf_03.cc +++ b/tests/fe/abf_03.cc @@ -32,7 +32,7 @@ void test (const unsigned int degree) std::vector dof_values (fe.dofs_per_cell); for (unsigned int i=0; i(); const std::vector > &generalized_support_points = fe.get_generalized_support_points(); std::vector > real_values (generalized_support_points.size(), Vector(dim)); diff --git a/tests/fe/bdm_8.cc b/tests/fe/bdm_8.cc index 4c5d2d7d06..6d6e4c5cd7 100644 --- a/tests/fe/bdm_8.cc +++ b/tests/fe/bdm_8.cc @@ -81,7 +81,7 @@ test (const unsigned int degree) Vector tmp1(dofs_per_cell), tmp2(dofs_per_cell); for (unsigned int i=0; i(); deallog << "solving degree = " << degree << std::endl; check_solver_within_range( diff --git a/tests/fe/bdm_9.cc b/tests/fe/bdm_9.cc index ae2b962975..561db1660d 100644 --- a/tests/fe/bdm_9.cc +++ b/tests/fe/bdm_9.cc @@ -75,7 +75,7 @@ test (const unsigned int degree) Vector tmp1(dofs_per_cell), tmp2(dofs_per_cell); for (unsigned int i=0; i(); deallog << "solving degree = " << degree << std::endl; check_solver_within_range( diff --git a/tests/fe/fe_compute_point_locations_01.cc b/tests/fe/fe_compute_point_locations_01.cc index 4de0d5dfa0..70cae3d72b 100644 --- a/tests/fe/fe_compute_point_locations_01.cc +++ b/tests/fe/fe_compute_point_locations_01.cc @@ -55,12 +55,7 @@ void test_compute_pt_loc(unsigned int n_points) std::vector> points; for (size_t i=0; i p; - for (unsigned int d=0; d()); std::vector::active_cell_iterator> cells; std::vector > > qpoints; diff --git a/tests/fe/rt_8.cc b/tests/fe/rt_8.cc index 00ca6eb5aa..e6639c1963 100644 --- a/tests/fe/rt_8.cc +++ b/tests/fe/rt_8.cc @@ -84,7 +84,7 @@ test (const unsigned int degree) Vector tmp1(dofs_per_cell), tmp2(dofs_per_cell); for (unsigned int i=0; i(); cg.solve (mass_matrix, tmp2, tmp1, PreconditionIdentity()); deallog << "Degree=" << degree diff --git a/tests/fe/rt_9.cc b/tests/fe/rt_9.cc index c6e166db8e..ff28861cb7 100644 --- a/tests/fe/rt_9.cc +++ b/tests/fe/rt_9.cc @@ -75,7 +75,7 @@ test (const unsigned int degree) Vector tmp1(dofs_per_cell), tmp2(dofs_per_cell); for (unsigned int i=0; i(); cg.solve (mass_matrix, tmp2, tmp1, PreconditionIdentity()); deallog << "Degree=" << degree diff --git a/tests/fe/rt_normal_02.cc b/tests/fe/rt_normal_02.cc index 49a025f128..c2bda2e245 100644 --- a/tests/fe/rt_normal_02.cc +++ b/tests/fe/rt_normal_02.cc @@ -288,7 +288,7 @@ int main (int /*argc*/, char **/*argv*/) // Fill solution vector with random values between 0 and 1. for (unsigned int i = 0; i < dof_handler->n_dofs (); ++i) - solution(i) = (double) Testing::rand() / (double) RAND_MAX; + solution(i) = random_value(); // Now check if the function is continuous in normal // direction. diff --git a/tests/full_matrix/full_matrix_04.cc b/tests/full_matrix/full_matrix_04.cc index 852e8dfc23..e5cded4b15 100644 --- a/tests/full_matrix/full_matrix_04.cc +++ b/tests/full_matrix/full_matrix_04.cc @@ -45,16 +45,16 @@ void test (const unsigned int n, const unsigned int m) for (unsigned int i=0; i(); for (unsigned int j=0; j(); + D(j,i) = Dt(i,j) = random_value(); } } for (unsigned int i=0; i(); // Compare first Schur complement // with mmult. diff --git a/tests/full_matrix/full_matrix_09.cc b/tests/full_matrix/full_matrix_09.cc index 16abbee1eb..2375dec6ae 100644 --- a/tests/full_matrix/full_matrix_09.cc +++ b/tests/full_matrix/full_matrix_09.cc @@ -29,10 +29,10 @@ void test() FullMatrix A(2, 76), B(76, 3), C(2, 3), D(3, 2), E(2, 3); for (unsigned int i=0; i(); for (unsigned int i=0; i(); A.mmult(C, B); // C = A * B B.TmTmult(D, A); // D = B^T * A^T diff --git a/tests/full_matrix/full_matrix_10.cc b/tests/full_matrix/full_matrix_10.cc index 654b59dfae..3367196671 100644 --- a/tests/full_matrix/full_matrix_10.cc +++ b/tests/full_matrix/full_matrix_10.cc @@ -28,10 +28,10 @@ void test() FullMatrix A(2, 76), B(3, 76), C(2, 3), D(2, 3); for (unsigned int i=0; i(); for (unsigned int i=0; i(); A.mTmult(C, B); // C = A * B^T diff --git a/tests/full_matrix/full_matrix_11.cc b/tests/full_matrix/full_matrix_11.cc index cc19927d9a..b6c5e3bd4d 100644 --- a/tests/full_matrix/full_matrix_11.cc +++ b/tests/full_matrix/full_matrix_11.cc @@ -28,10 +28,10 @@ void test() FullMatrix A(76, 2), B(76, 3), C(2, 3), D(2, 3); for (unsigned int i=0; i(); for (unsigned int i=0; i(); A.Tmmult(C, B); // C = A^T * B diff --git a/tests/grid/compute_point_locations_01.cc b/tests/grid/compute_point_locations_01.cc index 334a19a2e7..ab0bca3fe8 100644 --- a/tests/grid/compute_point_locations_01.cc +++ b/tests/grid/compute_point_locations_01.cc @@ -56,12 +56,7 @@ void test_compute_pt_loc(unsigned int n_points) std::vector> points; for (size_t i=0; i p; - for (unsigned int d=0; d()); // Initializing the cache GridTools::Cache cache(tria); diff --git a/tests/grid/find_active_cell_around_point_01.cc b/tests/grid/find_active_cell_around_point_01.cc index 3690eece8c..920a8a8664 100644 --- a/tests/grid/find_active_cell_around_point_01.cc +++ b/tests/grid/find_active_cell_around_point_01.cc @@ -48,14 +48,7 @@ void test(unsigned int n_ref, unsigned int n_points) deallog << "Points in study: " << n_points << std::endl; for (size_t i=0; i p; - for (unsigned int d=0; d()); auto v_to_c = GridTools::vertex_to_cell_map (tria); auto v_to_c_d = GridTools::vertex_to_cell_centers_directions (tria, v_to_c); diff --git a/tests/grid/find_active_cell_around_point_02.cc b/tests/grid/find_active_cell_around_point_02.cc index cd371b229a..50a793ebfd 100644 --- a/tests/grid/find_active_cell_around_point_02.cc +++ b/tests/grid/find_active_cell_around_point_02.cc @@ -47,14 +47,7 @@ void test(unsigned int n_ref, unsigned int n_points) deallog << "Points in study: " << n_points << std::endl; for (size_t i=0; i p; - for (unsigned int d=0; d()); auto &mapping = StaticMappingQ1::mapping; diff --git a/tests/hp/hp_hanging_nodes_02.cc b/tests/hp/hp_hanging_nodes_02.cc index 99893fb6c3..c0859be9a9 100644 --- a/tests/hp/hp_hanging_nodes_02.cc +++ b/tests/hp/hp_hanging_nodes_02.cc @@ -89,7 +89,7 @@ void run (bool random_p, { for (; cell != endc; ++cell) { - cell->set_active_fe_index ((int)(4.0 * (double) Testing::rand() / (double) RAND_MAX)); + cell->set_active_fe_index ((int)(4.0 * random_value())); } } else diff --git a/tests/lac/constraints_local_to_global.cc b/tests/lac/constraints_local_to_global.cc index 7fa0be7919..7d5ab91edd 100644 --- a/tests/lac/constraints_local_to_global.cc +++ b/tests/lac/constraints_local_to_global.cc @@ -87,7 +87,7 @@ void test () if (counter % 42 == 0) local_mat(i,j) = 0; else - local_mat (i,j) = (double)Testing::rand() / RAND_MAX; + local_mat (i,j) = random_value(); cell->get_dof_indices (local_dof_indices); constraints.distribute_local_to_global (local_mat, local_dof_indices, sparse); diff --git a/tests/lac/constraints_local_to_global_chunk.cc b/tests/lac/constraints_local_to_global_chunk.cc index 30cfef7906..6828d8a9c8 100644 --- a/tests/lac/constraints_local_to_global_chunk.cc +++ b/tests/lac/constraints_local_to_global_chunk.cc @@ -91,7 +91,7 @@ void test (unsigned int chunk_size) if (counter % 42 == 0) local_mat(i,j) = 0; else - local_mat (i,j) = (double)Testing::rand() / RAND_MAX; + local_mat (i,j) = random_value(); cell->get_dof_indices (local_dof_indices); constraints.distribute_local_to_global (local_mat, local_dof_indices, sparse); diff --git a/tests/lac/gmres_reorthogonalize_01.cc b/tests/lac/gmres_reorthogonalize_01.cc index 0d54f59f5a..67fa9925ab 100644 --- a/tests/lac/gmres_reorthogonalize_01.cc +++ b/tests/lac/gmres_reorthogonalize_01.cc @@ -36,7 +36,7 @@ void test (unsigned int variant, unsigned int min_convergence_steps) FullMatrix matrix(n, n); for (unsigned int i=0; i(-.1, .1); // put diagonal entries of different strengths. these are very challenging // for GMRES and will usually take a lot of iterations until the Krylov diff --git a/tests/lac/gmres_reorthogonalize_03.cc b/tests/lac/gmres_reorthogonalize_03.cc index dc48dc6560..e7c5023fd8 100644 --- a/tests/lac/gmres_reorthogonalize_03.cc +++ b/tests/lac/gmres_reorthogonalize_03.cc @@ -34,7 +34,7 @@ void test (unsigned int variant) FullMatrix matrix(n, n); for (unsigned int i=0; i(-.1, .1); // put diagonal entries of different strengths. these are very challenging // for GMRES and will usually take a lot of iterations until the Krylov diff --git a/tests/lac/la_vector_accumulation_01.cc b/tests/lac/la_vector_accumulation_01.cc index 0555b257cc..4086779ca3 100644 --- a/tests/lac/la_vector_accumulation_01.cc +++ b/tests/lac/la_vector_accumulation_01.cc @@ -32,7 +32,7 @@ void check_norms () const unsigned int size = Testing::rand() % 100000; LinearAlgebra::Vector vec (size); for (unsigned int i=0; i(Testing::rand())/static_cast(RAND_MAX); + vec(i) = random_value(); const typename LinearAlgebra::ReadWriteVector::real_type norm = vec.l2_norm(); for (unsigned int i=0; i<30; ++i) AssertThrow (vec.l2_norm() == norm, ExcInternalError()); diff --git a/tests/lac/precondition_chebyshev_01.cc b/tests/lac/precondition_chebyshev_01.cc index ee6296c0cc..92a9d0d1aa 100644 --- a/tests/lac/precondition_chebyshev_01.cc +++ b/tests/lac/precondition_chebyshev_01.cc @@ -49,7 +49,7 @@ check() Vector in (size), out(size); for (unsigned int i=0; i(); PreconditionChebyshev > prec; PreconditionChebyshev >::AdditionalData diff --git a/tests/lac/precondition_chebyshev_02.cc b/tests/lac/precondition_chebyshev_02.cc index 84c2834bd3..c36822db04 100644 --- a/tests/lac/precondition_chebyshev_02.cc +++ b/tests/lac/precondition_chebyshev_02.cc @@ -71,7 +71,7 @@ check() Vector in (size), out(size); for (unsigned int i=0; i(); PreconditionChebyshev,Vector,DiagonalMatrixManual> prec; PreconditionChebyshev,Vector,DiagonalMatrixManual>::AdditionalData diff --git a/tests/lac/precondition_chebyshev_03.cc b/tests/lac/precondition_chebyshev_03.cc index 3b027ef076..1d7f2eb114 100644 --- a/tests/lac/precondition_chebyshev_03.cc +++ b/tests/lac/precondition_chebyshev_03.cc @@ -62,7 +62,7 @@ int main() for (unsigned int i=0; i<3; ++i) { for (unsigned int j=0; j(); A.vmult (tmp1, v); cheby_data.preconditioner->vmult (tmp2, tmp1); diff --git a/tests/lac/precondition_chebyshev_04.cc b/tests/lac/precondition_chebyshev_04.cc index 3a2f9c4423..c837373d62 100644 --- a/tests/lac/precondition_chebyshev_04.cc +++ b/tests/lac/precondition_chebyshev_04.cc @@ -71,7 +71,7 @@ check() Vector in (size), out(size), ref(size), zero(size); for (unsigned int i=0; i(); PreconditionChebyshev,Vector,DiagonalMatrixManual> prec; PreconditionChebyshev,Vector,DiagonalMatrixManual>::AdditionalData diff --git a/tests/lac/precondition_chebyshev_05.cc b/tests/lac/precondition_chebyshev_05.cc index ad85a96c31..e8c6387d0f 100644 --- a/tests/lac/precondition_chebyshev_05.cc +++ b/tests/lac/precondition_chebyshev_05.cc @@ -71,7 +71,7 @@ int main(int argc, char **argv) for (unsigned int i=0; i<3; ++i) { for (unsigned int j=0; j(); AA.vmult (tmp1, v); cheby_data.preconditioner->vmult (tmp2, tmp1); diff --git a/tests/lac/sparse_ilu.cc b/tests/lac/sparse_ilu.cc index 77c192efc9..4f417dcde0 100644 --- a/tests/lac/sparse_ilu.cc +++ b/tests/lac/sparse_ilu.cc @@ -97,7 +97,7 @@ int main() for (unsigned int i=0; i<3; ++i) { for (unsigned int j=0; j(); A.vmult (tmp1, v); ilu.vmult (tmp2, tmp1); diff --git a/tests/lac/sparse_ilu_t.cc b/tests/lac/sparse_ilu_t.cc index c6bac20186..282b1b3271 100644 --- a/tests/lac/sparse_ilu_t.cc +++ b/tests/lac/sparse_ilu_t.cc @@ -97,7 +97,7 @@ int main() for (unsigned int i=0; i<3; ++i) { for (unsigned int j=0; j(); A.Tvmult (tmp1, v); ilu.Tvmult (tmp2, tmp1); diff --git a/tests/lac/sparse_mic.cc b/tests/lac/sparse_mic.cc index 573193a705..ca850159b9 100644 --- a/tests/lac/sparse_mic.cc +++ b/tests/lac/sparse_mic.cc @@ -98,7 +98,7 @@ int main() for (unsigned int i=0; i<3; ++i) { for (unsigned int j=0; j(); A.vmult (tmp1, v); mic.vmult (tmp2, tmp1); diff --git a/tests/lac/utilities_01.cc b/tests/lac/utilities_01.cc index 8d07b7828c..d9b8f0e137 100644 --- a/tests/lac/utilities_01.cc +++ b/tests/lac/utilities_01.cc @@ -54,7 +54,7 @@ int main(int argc, char **argv) PETScWrappers::MPI::Vector y(MPI_COMM_WORLD, dim, dim); PETScWrappers::MPI::Vector x(MPI_COMM_WORLD, dim, dim); for (unsigned int j=0; j(Testing::rand())/static_cast(RAND_MAX); + v0[j] = random_value(); v0.compress(VectorOperation::insert); GrowingVectorMemory vector_memory; diff --git a/tests/lac/utilities_02.cc b/tests/lac/utilities_02.cc index 7d6cb59cd7..b89f6ed11f 100644 --- a/tests/lac/utilities_02.cc +++ b/tests/lac/utilities_02.cc @@ -153,7 +153,7 @@ void test () LinearAlgebra::distributed::Vector init_vector; mf_data->initialize_dof_vector(init_vector); for (auto it = init_vector.begin(); it != init_vector.end(); ++it) - *it = static_cast(Testing::rand())/static_cast(RAND_MAX); + *it = random_value(); constraints.set_zero(init_vector); @@ -197,7 +197,7 @@ void test () LinearAlgebra::distributed::Vector init_vector; mf_data->initialize_dof_vector(init_vector); for (auto it = init_vector.begin(); it != init_vector.end(); ++it) - *it = static_cast(Testing::rand())/static_cast(RAND_MAX); + *it = random_value(); constraints.set_zero(init_vector); eigensolver.set_initial_vector(init_vector); diff --git a/tests/lac/utilities_03.cc b/tests/lac/utilities_03.cc index 1e1621816d..0ceff63456 100644 --- a/tests/lac/utilities_03.cc +++ b/tests/lac/utilities_03.cc @@ -108,7 +108,7 @@ check(const int degree, const bool scale = false, const double a_L = -0.1, const n_in++; else n_out++; - x(i) = static_cast(Testing::rand())/static_cast(RAND_MAX); + x(i) = random_value(); } deallog << " Modes inside/outside: " << n_in << " " << n_out << std::endl; diff --git a/tests/lac/vector_accumulation_01.cc b/tests/lac/vector_accumulation_01.cc index 8fd5b3b45d..52ed0bd02e 100644 --- a/tests/lac/vector_accumulation_01.cc +++ b/tests/lac/vector_accumulation_01.cc @@ -32,7 +32,7 @@ void check_norms () const unsigned int size = Testing::rand() % 100000; Vector vec (size); for (unsigned int i=0; i(Testing::rand())/static_cast(RAND_MAX); + vec(i) = random_value(); const typename Vector::real_type norm = vec.l2_norm(); for (unsigned int i=0; i<30; ++i) AssertThrow (vec.l2_norm() == norm, ExcInternalError()); diff --git a/tests/lac/vector_accumulation_02.cc b/tests/lac/vector_accumulation_02.cc index 67be2f2a00..c842ccbb98 100644 --- a/tests/lac/vector_accumulation_02.cc +++ b/tests/lac/vector_accumulation_02.cc @@ -36,8 +36,8 @@ void check_norms () Vector larger1 (size+8), larger2(size+8), in1(size), in2(size); for (unsigned int i=0; i(Testing::rand())/static_cast(RAND_MAX); - in2(i) = static_cast(Testing::rand())/static_cast(RAND_MAX); + in1(i) = random_value(); + in2(i) = random_value(); } const number inner_product = in1 * in2; diff --git a/tests/lac/vector_operations_parallel_reduce_start_end.cc b/tests/lac/vector_operations_parallel_reduce_start_end.cc index b1bf28041e..f33026d459 100644 --- a/tests/lac/vector_operations_parallel_reduce_start_end.cc +++ b/tests/lac/vector_operations_parallel_reduce_start_end.cc @@ -37,7 +37,7 @@ void check () Utilities::System::posix_memalign ((void **)&val, 64, sizeof(Number)*size); for (unsigned int i = 0; i < size; ++i) - val[i] = (double)rand()/RAND_MAX; + val[i] = random_value(); internal::VectorOperations::MeanValue mean(val); diff --git a/tests/lapack/create_matrix.h b/tests/lapack/create_matrix.h index 4d97ffab24..7e4e2d4052 100644 --- a/tests/lapack/create_matrix.h +++ b/tests/lapack/create_matrix.h @@ -26,7 +26,7 @@ void create_spd (FullMatrix &A) for (unsigned int i = 0; i < size; ++i) for (unsigned int j = i; j < size; ++j) { - const double val = (double)Testing::rand()/RAND_MAX; + const double val = random_value(); Assert (val >= 0. && val <= 1., ExcInternalError()); if (i==j) @@ -48,5 +48,5 @@ void create_random (FullMatrix &A) { for (unsigned int i = 0; i < A.m(); ++i) for (unsigned int j = 0; j < A.n(); ++j) - A(i,j) = (double)Testing::rand()/RAND_MAX; + A(i,j) = random_value(); } diff --git a/tests/lapack/full_matrix_08.cc b/tests/lapack/full_matrix_08.cc index 39f81736b6..da560508c9 100644 --- a/tests/lapack/full_matrix_08.cc +++ b/tests/lapack/full_matrix_08.cc @@ -34,10 +34,10 @@ void test() LAPACKFullMatrix AL(m, k), BL(k, n), CL(m, n); for (unsigned int i=0; i(); for (unsigned int i=0; i(); A.mmult(C, B); AL.mmult(CL, BL); diff --git a/tests/lapack/full_matrix_09.cc b/tests/lapack/full_matrix_09.cc index 707c093b1a..b05c823ef6 100644 --- a/tests/lapack/full_matrix_09.cc +++ b/tests/lapack/full_matrix_09.cc @@ -34,10 +34,10 @@ void test() LAPACKFullMatrix AL(k,m), BL(k, n), CL(m, n); for (unsigned int i=0; i(); for (unsigned int i=0; i(); A.Tmmult(C, B); AL.Tmmult(CL, BL); diff --git a/tests/lapack/full_matrix_10.cc b/tests/lapack/full_matrix_10.cc index 6cfc73a1d0..8e15c54729 100644 --- a/tests/lapack/full_matrix_10.cc +++ b/tests/lapack/full_matrix_10.cc @@ -34,10 +34,10 @@ void test() LAPACKFullMatrix AL(m, k), BL(n, k), CL(m, n); for (unsigned int i=0; i(); for (unsigned int i=0; i(); A.mTmult(C, B); AL.mTmult(CL, BL); diff --git a/tests/lapack/full_matrix_11.cc b/tests/lapack/full_matrix_11.cc index 45cdd7861b..423c097f93 100644 --- a/tests/lapack/full_matrix_11.cc +++ b/tests/lapack/full_matrix_11.cc @@ -34,10 +34,10 @@ void test() LAPACKFullMatrix AL(k, m), BL(n, k), CL(m, n); for (unsigned int i=0; i(); for (unsigned int i=0; i(); A.TmTmult(C, B); AL.TmTmult(CL, BL); diff --git a/tests/lapack/full_matrix_12.cc b/tests/lapack/full_matrix_12.cc index 0d740cb4fe..a409cb2a46 100644 --- a/tests/lapack/full_matrix_12.cc +++ b/tests/lapack/full_matrix_12.cc @@ -30,12 +30,12 @@ void test() LAPACKFullMatrix A(n,n); for (unsigned int i=0; i(); A.compute_lu_factorization(); LAPACKFullMatrix rhs_orig(n, 3); for (unsigned int i=0; i<3; ++i) for (unsigned int j=0; j(-0.9923,1.3277); for (unsigned int transpose=0; transpose < 2; ++transpose) { diff --git a/tests/lapack/full_matrix_13.cc b/tests/lapack/full_matrix_13.cc index aa7196ba18..86a9aa8e7b 100644 --- a/tests/lapack/full_matrix_13.cc +++ b/tests/lapack/full_matrix_13.cc @@ -30,7 +30,7 @@ void test() LAPACKFullMatrix A(m,n); for (unsigned int i=0; i(); LAPACKFullMatrix A_check(A); diff --git a/tests/mappings/mapping_q_eulerian_09.cc b/tests/mappings/mapping_q_eulerian_09.cc index f2150e481a..a92580c7d4 100644 --- a/tests/mappings/mapping_q_eulerian_09.cc +++ b/tests/mappings/mapping_q_eulerian_09.cc @@ -143,7 +143,7 @@ void test () matrix_free->initialize_dof_vector(dst4); for (unsigned int i = 0; i < src.local_size(); ++i) - src.local_element(i) = (NumberType)Testing::rand()/RAND_MAX; + src.local_element(i) = random_value(); MatrixFreeOperators::MassOperator> mf_mass; MatrixFreeOperators::LaplaceOperator> mf_laplace; diff --git a/tests/matrix_free/copy.cc b/tests/matrix_free/copy.cc index 1f27795c1a..a5236b452c 100644 --- a/tests/matrix_free/copy.cc +++ b/tests/matrix_free/copy.cc @@ -95,7 +95,7 @@ void sub_test() { if (constraints.is_constrained(i)) continue; - const double entry = Testing::rand()/(double)RAND_MAX; + const double entry = random_value(); in_dist(i) = entry; } diff --git a/tests/matrix_free/copy_feevaluation.cc b/tests/matrix_free/copy_feevaluation.cc index 3e9aee67db..d839a22014 100644 --- a/tests/matrix_free/copy_feevaluation.cc +++ b/tests/matrix_free/copy_feevaluation.cc @@ -289,13 +289,13 @@ void test () for (unsigned int j=0; j(); system_rhs.block(0)(j) = val; } for (unsigned int j=0; j(); system_rhs.block(1)(j) = val; } diff --git a/tests/matrix_free/evaluate_1d_shape.cc b/tests/matrix_free/evaluate_1d_shape.cc index e670a81d1c..6305dd9177 100644 --- a/tests/matrix_free/evaluate_1d_shape.cc +++ b/tests/matrix_free/evaluate_1d_shape.cc @@ -34,7 +34,7 @@ void test() for (unsigned int i=0; i<(M+1)/2; ++i) for (unsigned int j=0; j(); if (type == 1) shape[(M-1-i)*N+N-1-j] = -shape[i*N+j]; else @@ -51,7 +51,7 @@ void test() double x[N], x_ref[N], y[M], y_ref[M]; for (unsigned int i=0; i(); // compute reference for (unsigned int i=0; i(); // compute reference for (unsigned int i=0; i(); if (type == 1) shape[M-1-i][N-1-j] = -shape[i][j]; else @@ -65,7 +65,7 @@ void test() double x[N], x_ref[N], y[M], y_ref[M]; for (unsigned int i=0; i(); // compute reference for (unsigned int i=0; i(); // compute reference for (unsigned int i=0; i &dof, { if (constraints.is_constrained(i)) continue; - const double entry = Testing::rand()/(double)RAND_MAX; + const double entry = random_value(); solution(i) = entry; } diff --git a/tests/matrix_free/get_functions_gl.cc b/tests/matrix_free/get_functions_gl.cc index 22223cbc1c..21f3f289a7 100644 --- a/tests/matrix_free/get_functions_gl.cc +++ b/tests/matrix_free/get_functions_gl.cc @@ -73,7 +73,7 @@ void test () { if (constraints.is_constrained(i)) continue; - const double entry = Testing::rand()/(double)RAND_MAX; + const double entry = random_value(); solution(i) = entry; } constraints.distribute(solution); diff --git a/tests/matrix_free/get_functions_mappingq.cc b/tests/matrix_free/get_functions_mappingq.cc index 71f9efd4e1..ba038c50a4 100644 --- a/tests/matrix_free/get_functions_mappingq.cc +++ b/tests/matrix_free/get_functions_mappingq.cc @@ -74,7 +74,7 @@ void test () { if (constraints.is_constrained(i)) continue; - const double entry = Testing::rand()/(double)RAND_MAX; + const double entry = random_value(); solution(i) = entry; } diff --git a/tests/matrix_free/get_functions_multife.cc b/tests/matrix_free/get_functions_multife.cc index c9df24a3b8..bd5f2e1740 100644 --- a/tests/matrix_free/get_functions_multife.cc +++ b/tests/matrix_free/get_functions_multife.cc @@ -242,7 +242,7 @@ void test () { if (constraints[no]->is_constrained(i)) continue; - const double entry = Testing::rand()/(double)RAND_MAX; + const double entry = random_value(); src[no](i) = entry; } diff --git a/tests/matrix_free/get_functions_multife2.cc b/tests/matrix_free/get_functions_multife2.cc index 81a42292e3..81a89ff218 100644 --- a/tests/matrix_free/get_functions_multife2.cc +++ b/tests/matrix_free/get_functions_multife2.cc @@ -293,7 +293,7 @@ void test () { if (constraints[no]->is_constrained(i)) continue; - const double entry = Testing::rand()/(double)RAND_MAX; + const double entry = random_value(); src[no](i) = entry; } diff --git a/tests/matrix_free/get_functions_notempl.cc b/tests/matrix_free/get_functions_notempl.cc index 418cd4a27e..f65ba7912b 100644 --- a/tests/matrix_free/get_functions_notempl.cc +++ b/tests/matrix_free/get_functions_notempl.cc @@ -96,7 +96,7 @@ void test () { if (constraints.is_constrained(i)) continue; - const double entry = Testing::rand()/(double)RAND_MAX; + const double entry = random_value(); solution(i) = entry; } constraints.distribute(solution); diff --git a/tests/matrix_free/get_functions_q_hierarchical.cc b/tests/matrix_free/get_functions_q_hierarchical.cc index e59ba7a938..1ba6030fc6 100644 --- a/tests/matrix_free/get_functions_q_hierarchical.cc +++ b/tests/matrix_free/get_functions_q_hierarchical.cc @@ -76,7 +76,7 @@ void test () { if (constraints.is_constrained(i)) continue; - const double entry = Testing::rand()/(double)RAND_MAX; + const double entry = random_value(); solution(i) = entry; } constraints.distribute(solution); diff --git a/tests/matrix_free/get_functions_rect.cc b/tests/matrix_free/get_functions_rect.cc index 6831c092a1..120a6fd93c 100644 --- a/tests/matrix_free/get_functions_rect.cc +++ b/tests/matrix_free/get_functions_rect.cc @@ -96,7 +96,7 @@ void test () { if (constraints.is_constrained(i)) continue; - const double entry = Testing::rand()/(double)RAND_MAX; + const double entry = random_value(); solution(i) = entry; } constraints.distribute(solution); diff --git a/tests/matrix_free/get_functions_variants.cc b/tests/matrix_free/get_functions_variants.cc index 0bd64e1bc0..34bfefc39f 100644 --- a/tests/matrix_free/get_functions_variants.cc +++ b/tests/matrix_free/get_functions_variants.cc @@ -166,7 +166,7 @@ void test () // create vector with random entries for (unsigned int i=0; i(); solution_dist(i) = entry; } diff --git a/tests/matrix_free/get_functions_variants_gl.cc b/tests/matrix_free/get_functions_variants_gl.cc index 0e57f229b1..538d509862 100644 --- a/tests/matrix_free/get_functions_variants_gl.cc +++ b/tests/matrix_free/get_functions_variants_gl.cc @@ -162,7 +162,7 @@ void test () // create vector with random entries for (unsigned int i=0; i(); solution_dist(i) = entry; } diff --git a/tests/matrix_free/get_values_plain.cc b/tests/matrix_free/get_values_plain.cc index 2ebdee7538..4bc20a84e0 100644 --- a/tests/matrix_free/get_values_plain.cc +++ b/tests/matrix_free/get_values_plain.cc @@ -116,7 +116,7 @@ void do_test (const DoFHandler &dof, { if (constraints.is_constrained(i)) continue; - const double entry = Testing::rand()/(double)RAND_MAX; + const double entry = random_value(); solution(i) = entry; } diff --git a/tests/matrix_free/integrate_functions.cc b/tests/matrix_free/integrate_functions.cc index 82d8577f58..05718b7b74 100644 --- a/tests/matrix_free/integrate_functions.cc +++ b/tests/matrix_free/integrate_functions.cc @@ -105,9 +105,9 @@ operator () (const MatrixFree &data, // and their gradients for (unsigned int q=0; q(); for (unsigned int d=0; d()); } fe_val.reinit (data.get_cell_iterator(cell,j)); data.get_cell_iterator(cell,j)->get_dof_indices(dof_indices); diff --git a/tests/matrix_free/integrate_functions_multife.cc b/tests/matrix_free/integrate_functions_multife.cc index a64f6c0f4b..8fd7083031 100644 --- a/tests/matrix_free/integrate_functions_multife.cc +++ b/tests/matrix_free/integrate_functions_multife.cc @@ -121,9 +121,9 @@ operator () (const MatrixFree &data, // and their gradients for (unsigned int q=0; q(); for (unsigned int d=0; d()); } fe_val0.reinit (data.get_cell_iterator(cell,j,0)); data.get_cell_iterator(cell,j,0)->get_dof_indices(dof_indices0); @@ -147,9 +147,9 @@ operator () (const MatrixFree &data, for (unsigned int q=0; q(); for (unsigned int d=0; d()); } for (unsigned int i=0; i &data, // and their gradients for (unsigned int q=0; q(); for (unsigned int d=0; d()); } fe_val0.reinit (data.get_cell_iterator(cell,j,0)); data.get_cell_iterator(cell,j,0)->get_dof_indices(dof_indices0); @@ -150,9 +150,9 @@ operator () (const MatrixFree &data, for (unsigned int q=0; q(); for (unsigned int d=0; d()); } for (unsigned int i=0; i &dof) for (unsigned int i=0; i(); in(i) = entry; } diff --git a/tests/matrix_free/inverse_mass_02.cc b/tests/matrix_free/inverse_mass_02.cc index 004f478e28..f4670e3c02 100644 --- a/tests/matrix_free/inverse_mass_02.cc +++ b/tests/matrix_free/inverse_mass_02.cc @@ -136,7 +136,7 @@ void do_test (const DoFHandler &dof) for (unsigned int i=0; i(); in(i) = entry; } diff --git a/tests/matrix_free/inverse_mass_03.cc b/tests/matrix_free/inverse_mass_03.cc index de61b80814..168a5486d9 100644 --- a/tests/matrix_free/inverse_mass_03.cc +++ b/tests/matrix_free/inverse_mass_03.cc @@ -150,7 +150,7 @@ void do_test (const DoFHandler &dof) for (unsigned int i=0; i(); in(i) = entry; } diff --git a/tests/matrix_free/laplace_operator_01.cc b/tests/matrix_free/laplace_operator_01.cc index 086b5443d9..83011e9490 100644 --- a/tests/matrix_free/laplace_operator_01.cc +++ b/tests/matrix_free/laplace_operator_01.cc @@ -120,7 +120,7 @@ void test () owned_set.nth_index_in_set (i); if (constraints.is_constrained(glob_index)) continue; - in.local_element(i) = (double)Testing::rand()/RAND_MAX; + in.local_element(i) = random_value(); } mf.vmult (out, in); diff --git a/tests/matrix_free/laplace_operator_02.cc b/tests/matrix_free/laplace_operator_02.cc index c3f54efcb5..549cbe2794 100644 --- a/tests/matrix_free/laplace_operator_02.cc +++ b/tests/matrix_free/laplace_operator_02.cc @@ -183,7 +183,7 @@ void test () owned_set.nth_index_in_set (i); if (constraints.is_constrained(glob_index)) continue; - in.local_element(i) = (double)Testing::rand()/RAND_MAX; + in.local_element(i) = random_value(); } mf.vmult (out, in); diff --git a/tests/matrix_free/mass_operator_01.cc b/tests/matrix_free/mass_operator_01.cc index 8c0599bd8d..3c6bb29992 100644 --- a/tests/matrix_free/mass_operator_01.cc +++ b/tests/matrix_free/mass_operator_01.cc @@ -128,7 +128,7 @@ void test () owned_set.nth_index_in_set (i); if (constraints.is_constrained(glob_index)) continue; - in.local_element(i) = (double)Testing::rand()/RAND_MAX; + in.local_element(i) = random_value(); } mf.vmult (out, in); diff --git a/tests/matrix_free/mass_operator_04.cc b/tests/matrix_free/mass_operator_04.cc index 114bd72880..c1c8f1554b 100644 --- a/tests/matrix_free/mass_operator_04.cc +++ b/tests/matrix_free/mass_operator_04.cc @@ -85,7 +85,7 @@ void test () mf_data_0->initialize_dof_vector (in); for (unsigned int i=0; i(); mf_c0.initialize_dof_vector(out); mf_c0.initialize_dof_vector(ref); diff --git a/tests/matrix_free/matrix_vector_10.cc b/tests/matrix_free/matrix_vector_10.cc index 704b236039..5316fe6faa 100644 --- a/tests/matrix_free/matrix_vector_10.cc +++ b/tests/matrix_free/matrix_vector_10.cc @@ -126,7 +126,7 @@ void test () owned_set.nth_index_in_set (i); if (constraints.is_constrained(glob_index)) continue; - in.local_element(i) = (double)Testing::rand()/RAND_MAX; + in.local_element(i) = random_value(); } mf.vmult (out, in); diff --git a/tests/matrix_free/matrix_vector_11.cc b/tests/matrix_free/matrix_vector_11.cc index 101a27d724..cfc22d0f6d 100644 --- a/tests/matrix_free/matrix_vector_11.cc +++ b/tests/matrix_free/matrix_vector_11.cc @@ -119,7 +119,7 @@ void test () owned_set.nth_index_in_set (i); if (constraints.is_constrained(glob_index)) continue; - in.local_element(i) = (double)Testing::rand()/RAND_MAX; + in.local_element(i) = random_value(); } mf.vmult (ref, in); diff --git a/tests/matrix_free/matrix_vector_12.cc b/tests/matrix_free/matrix_vector_12.cc index e168f499c8..d2f0638311 100644 --- a/tests/matrix_free/matrix_vector_12.cc +++ b/tests/matrix_free/matrix_vector_12.cc @@ -185,8 +185,8 @@ void test () owned_set.nth_index_in_set (i); if (constraints.is_constrained(glob_index)) continue; - in[0].local_element(i) = (double)Testing::rand()/RAND_MAX; - in[1].local_element(i) = (double)Testing::rand()/RAND_MAX; + in[0].local_element(i) = random_value(); + in[1].local_element(i) = random_value(); } mf.vmult (out, in); diff --git a/tests/matrix_free/matrix_vector_13.cc b/tests/matrix_free/matrix_vector_13.cc index 108e626e6a..c24a1944a4 100644 --- a/tests/matrix_free/matrix_vector_13.cc +++ b/tests/matrix_free/matrix_vector_13.cc @@ -188,8 +188,8 @@ void test () owned_set.nth_index_in_set (i); if (constraints.is_constrained(glob_index)) continue; - in.block(0).local_element(i) = (double)Testing::rand()/RAND_MAX; - in.block(1).local_element(i) = (double)Testing::rand()/RAND_MAX; + in.block(0).local_element(i) = random_value(); + in.block(1).local_element(i) = random_value(); } mf.vmult (out, in); diff --git a/tests/matrix_free/matrix_vector_15.cc b/tests/matrix_free/matrix_vector_15.cc index 3eeae85c25..126a1281b8 100644 --- a/tests/matrix_free/matrix_vector_15.cc +++ b/tests/matrix_free/matrix_vector_15.cc @@ -108,7 +108,7 @@ void do_test (const DoFHandler &dof, { if (constraints.is_constrained(i)) continue; - const double entry = Testing::rand()/(double)RAND_MAX; + const double entry = random_value(); in(i) = entry; in_dist(i) = entry; } diff --git a/tests/matrix_free/matrix_vector_16.cc b/tests/matrix_free/matrix_vector_16.cc index 1476128691..f4ebc1ac97 100644 --- a/tests/matrix_free/matrix_vector_16.cc +++ b/tests/matrix_free/matrix_vector_16.cc @@ -109,7 +109,7 @@ void do_test (const DoFHandler &dof, { if (constraints.is_constrained(i)) continue; - const double entry = Testing::rand()/(double)RAND_MAX; + const double entry = random_value(); in(i) = entry; in_dist(i) = entry; } diff --git a/tests/matrix_free/matrix_vector_18.cc b/tests/matrix_free/matrix_vector_18.cc index aff7123e99..6f97588832 100644 --- a/tests/matrix_free/matrix_vector_18.cc +++ b/tests/matrix_free/matrix_vector_18.cc @@ -133,7 +133,7 @@ void do_test (const DoFHandler &dof, { if (constraints.is_constrained(i)) continue; - const double entry = Testing::rand()/(double)RAND_MAX; + const double entry = random_value(); in(i) = entry; in_dist(i) = entry; } diff --git a/tests/matrix_free/matrix_vector_19.cc b/tests/matrix_free/matrix_vector_19.cc index bf72ae3e85..1100f153cb 100644 --- a/tests/matrix_free/matrix_vector_19.cc +++ b/tests/matrix_free/matrix_vector_19.cc @@ -116,7 +116,7 @@ void test () owned_set.nth_index_in_set (i); if (constraints.is_constrained(glob_index)) continue; - in.local_element(i) = (double)Testing::rand()/RAND_MAX; + in.local_element(i) = random_value(); } mf.vmult (out, in); diff --git a/tests/matrix_free/matrix_vector_20.cc b/tests/matrix_free/matrix_vector_20.cc index 7903107474..af9842b71f 100644 --- a/tests/matrix_free/matrix_vector_20.cc +++ b/tests/matrix_free/matrix_vector_20.cc @@ -189,8 +189,8 @@ void test () { if (constraints.is_constrained(dof.locally_owned_dofs().index_within_set(i))) continue; - in.block(0).local_element(i) = (double)Testing::rand()/RAND_MAX; - in.block(1).local_element(i) = (double)Testing::rand()/RAND_MAX; + in.block(0).local_element(i) = random_value(); + in.block(1).local_element(i) = random_value(); } mf.vmult (out, in); diff --git a/tests/matrix_free/matrix_vector_21.cc b/tests/matrix_free/matrix_vector_21.cc index 8d95f1fc44..7a7a53b247 100644 --- a/tests/matrix_free/matrix_vector_21.cc +++ b/tests/matrix_free/matrix_vector_21.cc @@ -180,8 +180,8 @@ void test () { if (constraints.is_constrained(dof.locally_owned_dofs().index_within_set(i))) continue; - in.block(0).local_element(i) = (double)Testing::rand()/RAND_MAX; - in.block(1).local_element(i) = (double)Testing::rand()/RAND_MAX; + in.block(0).local_element(i) = random_value(); + in.block(1).local_element(i) = random_value(); } mf.vmult (out, in); diff --git a/tests/matrix_free/matrix_vector_22.cc b/tests/matrix_free/matrix_vector_22.cc index d525616d03..f107b8cb61 100644 --- a/tests/matrix_free/matrix_vector_22.cc +++ b/tests/matrix_free/matrix_vector_22.cc @@ -186,8 +186,8 @@ void test () owned_set.nth_index_in_set (i); if (constraints.is_constrained(glob_index)) continue; - in[0].local_element(i) = (double)Testing::rand()/RAND_MAX; - in[1].local_element(i) = (double)Testing::rand()/RAND_MAX; + in[0].local_element(i) = random_value(); + in[1].local_element(i) = random_value(); } std::vector *> in_ptr(2), out_ptr(2); diff --git a/tests/matrix_free/matrix_vector_23.cc b/tests/matrix_free/matrix_vector_23.cc index 80cb8d9455..d02618e678 100644 --- a/tests/matrix_free/matrix_vector_23.cc +++ b/tests/matrix_free/matrix_vector_23.cc @@ -196,9 +196,9 @@ void test () owned_set.nth_index_in_set (i); if (constraints.is_constrained(glob_index)) continue; - in[0].local_element(i) = (double)Testing::rand()/RAND_MAX; - in[1].local_element(i) = (double)Testing::rand()/RAND_MAX; - in[2].local_element(i) = (double)Testing::rand()/RAND_MAX; + in[0].local_element(i) = random_value(); + in[1].local_element(i) = random_value(); + in[2].local_element(i) = random_value(); } std::vector *> in_ptr(3), out_ptr(3); diff --git a/tests/matrix_free/matrix_vector_common.h b/tests/matrix_free/matrix_vector_common.h index aa4fe53673..c20e8ca8cc 100644 --- a/tests/matrix_free/matrix_vector_common.h +++ b/tests/matrix_free/matrix_vector_common.h @@ -92,7 +92,7 @@ void do_test (const DoFHandler &dof, { if (constraints.is_constrained(i)) continue; - const double entry = Testing::rand()/(double)RAND_MAX; + const double entry = random_value(); in(i) = entry; in_dist(i) = entry; } diff --git a/tests/matrix_free/matrix_vector_curl.cc b/tests/matrix_free/matrix_vector_curl.cc index e6ce1ea75a..21e59cccf5 100644 --- a/tests/matrix_free/matrix_vector_curl.cc +++ b/tests/matrix_free/matrix_vector_curl.cc @@ -243,7 +243,7 @@ void test () for (unsigned int i=0; i(); system_rhs.block(i)(j) = val; } constraints.condense(system_rhs); diff --git a/tests/matrix_free/matrix_vector_div.cc b/tests/matrix_free/matrix_vector_div.cc index f04e5756c7..71f5877851 100644 --- a/tests/matrix_free/matrix_vector_div.cc +++ b/tests/matrix_free/matrix_vector_div.cc @@ -240,7 +240,7 @@ void test () for (unsigned int i=0; i(); system_rhs.block(i)(j) = val; } constraints.condense(system_rhs); diff --git a/tests/matrix_free/matrix_vector_hp.cc b/tests/matrix_free/matrix_vector_hp.cc index 2ef2865924..c25fb5d3bd 100644 --- a/tests/matrix_free/matrix_vector_hp.cc +++ b/tests/matrix_free/matrix_vector_hp.cc @@ -228,7 +228,7 @@ void test () for (unsigned int i=0; i(); } // now perform matrix-vector product and check diff --git a/tests/matrix_free/matrix_vector_large_degree_02.cc b/tests/matrix_free/matrix_vector_large_degree_02.cc index ccd4f65d7d..f9fceeee1a 100644 --- a/tests/matrix_free/matrix_vector_large_degree_02.cc +++ b/tests/matrix_free/matrix_vector_large_degree_02.cc @@ -98,7 +98,7 @@ void test () { if (constraints.is_constrained(i)) continue; - in(i) = (double)Testing::rand()/RAND_MAX; + in(i) = random_value(); } mf.vmult (out, in); diff --git a/tests/matrix_free/matrix_vector_mg.cc b/tests/matrix_free/matrix_vector_mg.cc index 77756ec28e..a13a437d93 100644 --- a/tests/matrix_free/matrix_vector_mg.cc +++ b/tests/matrix_free/matrix_vector_mg.cc @@ -184,7 +184,7 @@ void test () for (unsigned int i=0; i(); } // now perform matrix-vector product and check @@ -205,7 +205,7 @@ void test () for (unsigned int i=0; i(); } // now perform matrix-vector product and check diff --git a/tests/matrix_free/matrix_vector_stokes.cc b/tests/matrix_free/matrix_vector_stokes.cc index cee0c03cf5..06a8751060 100644 --- a/tests/matrix_free/matrix_vector_stokes.cc +++ b/tests/matrix_free/matrix_vector_stokes.cc @@ -264,7 +264,7 @@ void test () for (unsigned int i=0; i(); system_rhs.block(i)(j) = val; vec1[i](j) = val; } diff --git a/tests/matrix_free/matrix_vector_stokes_base.cc b/tests/matrix_free/matrix_vector_stokes_base.cc index e1d5cd3972..199d05766f 100644 --- a/tests/matrix_free/matrix_vector_stokes_base.cc +++ b/tests/matrix_free/matrix_vector_stokes_base.cc @@ -230,14 +230,14 @@ test() for (unsigned int j=0; j(); system_rhs.block(0)(j) = val; mf_system_rhs.block(0)(j) = val; } for (unsigned int j=0; j(); system_rhs.block(1)(j) = val; mf_system_rhs.block(1)(j) = val; } diff --git a/tests/matrix_free/matrix_vector_stokes_noflux.cc b/tests/matrix_free/matrix_vector_stokes_noflux.cc index 6dc7c0c02c..3ec3d4985a 100644 --- a/tests/matrix_free/matrix_vector_stokes_noflux.cc +++ b/tests/matrix_free/matrix_vector_stokes_noflux.cc @@ -286,13 +286,13 @@ void test () for (unsigned int j=0; j(); system_rhs.block(0)(j) = val; } for (unsigned int j=0; j(); system_rhs.block(1)(j) = val; } diff --git a/tests/matrix_free/matrix_vector_stokes_notempl.cc b/tests/matrix_free/matrix_vector_stokes_notempl.cc index 64f6ec2ada..d89320ad63 100644 --- a/tests/matrix_free/matrix_vector_stokes_notempl.cc +++ b/tests/matrix_free/matrix_vector_stokes_notempl.cc @@ -283,13 +283,13 @@ void test (const unsigned int fe_degree) for (unsigned int j=0; j(); system_rhs.block(0)(j) = val; } for (unsigned int j=0; j(); system_rhs.block(1)(j) = val; } diff --git a/tests/matrix_free/matrix_vector_stokes_qdg0.cc b/tests/matrix_free/matrix_vector_stokes_qdg0.cc index b52dac318c..71b34343c6 100644 --- a/tests/matrix_free/matrix_vector_stokes_qdg0.cc +++ b/tests/matrix_free/matrix_vector_stokes_qdg0.cc @@ -266,7 +266,7 @@ void test () for (unsigned int i=0; i(); system_rhs.block(i)(j) = val; vec1[i](j) = val; } diff --git a/tests/matrix_free/matrix_vector_stokes_qdg0b.cc b/tests/matrix_free/matrix_vector_stokes_qdg0b.cc index c84868de40..6b571ca004 100644 --- a/tests/matrix_free/matrix_vector_stokes_qdg0b.cc +++ b/tests/matrix_free/matrix_vector_stokes_qdg0b.cc @@ -267,7 +267,7 @@ void test (const unsigned int fe_degree) for (unsigned int i=0; i(); system_rhs.block(i)(j) = val; vec1[i](j) = val; } diff --git a/tests/matrix_free/no_index_initialize.cc b/tests/matrix_free/no_index_initialize.cc index 2f0a2c912e..b90463651d 100644 --- a/tests/matrix_free/no_index_initialize.cc +++ b/tests/matrix_free/no_index_initialize.cc @@ -123,7 +123,7 @@ void do_test (const DoFHandler &dof, { if (constraints.is_constrained(i)) continue; - const double entry = Testing::rand()/(double)RAND_MAX; + const double entry = random_value(); solution(i) = entry; } diff --git a/tests/matrix_free/thread_correctness.cc b/tests/matrix_free/thread_correctness.cc index 02b1544290..0987e5a413 100644 --- a/tests/matrix_free/thread_correctness.cc +++ b/tests/matrix_free/thread_correctness.cc @@ -109,7 +109,7 @@ void sub_test() { if (constraints.is_constrained(i)) continue; - const double entry = Testing::rand()/(double)RAND_MAX; + const double entry = random_value(); in_dist(i) = entry; } diff --git a/tests/matrix_free/thread_correctness_hp.cc b/tests/matrix_free/thread_correctness_hp.cc index 41a1a1412c..fdaa5548a5 100644 --- a/tests/matrix_free/thread_correctness_hp.cc +++ b/tests/matrix_free/thread_correctness_hp.cc @@ -183,7 +183,7 @@ void do_test (const unsigned int parallel_option) for (unsigned int i=0; i(); } // now perform 30 matrix-vector products in diff --git a/tests/matrix_free/update_mapping_only.cc b/tests/matrix_free/update_mapping_only.cc index aae52cc47c..ac4afa1852 100644 --- a/tests/matrix_free/update_mapping_only.cc +++ b/tests/matrix_free/update_mapping_only.cc @@ -57,7 +57,7 @@ void test () { if (constraints.is_constrained(i)) continue; - const double entry = Testing::rand()/(double)RAND_MAX; + const double entry = random_value(); solution(i) = entry; } diff --git a/tests/mpi/parallel_block_vector_05.cc b/tests/mpi/parallel_block_vector_05.cc index 4078094d9a..94f25eaa3a 100644 --- a/tests/mpi/parallel_block_vector_05.cc +++ b/tests/mpi/parallel_block_vector_05.cc @@ -116,7 +116,7 @@ void test (const unsigned int n_blocks = 5) owned_set.nth_index_in_set (i); if (constraints.is_constrained(glob_index)) continue; - right.block(b).local_element(i) = (double)Testing::rand()/RAND_MAX; + right.block(b).local_element(i) = random_value(); } mf.vmult (left.block(b), right.block(b)); @@ -153,7 +153,7 @@ void test (const unsigned int n_blocks = 5) owned_set.nth_index_in_set (i); if (constraints.is_constrained(glob_index)) continue; - left2.block(b).local_element(i) = (double)Testing::rand()/RAND_MAX; + left2.block(b).local_element(i) = random_value(); } } diff --git a/tests/mpi/parallel_block_vector_06.cc b/tests/mpi/parallel_block_vector_06.cc index b8d77da3e7..504182ac57 100644 --- a/tests/mpi/parallel_block_vector_06.cc +++ b/tests/mpi/parallel_block_vector_06.cc @@ -119,7 +119,7 @@ void test (const unsigned int n_blocks = 5) owned_set.nth_index_in_set (i); if (constraints.is_constrained(glob_index)) continue; - right.block(b).local_element(i) = (double)Testing::rand()/RAND_MAX; + right.block(b).local_element(i) = random_value(); } mf.vmult (left.block(b), right.block(b)); @@ -160,7 +160,7 @@ void test (const unsigned int n_blocks = 5) owned_set.nth_index_in_set (i); if (constraints.is_constrained(glob_index)) continue; - left2.block(b).local_element(i) = (double)Testing::rand()/RAND_MAX; + left2.block(b).local_element(i) = random_value(); } } diff --git a/tests/mpi/trilinos_matvec_01.cc b/tests/mpi/trilinos_matvec_01.cc index f63177bc9c..02a1b33578 100644 --- a/tests/mpi/trilinos_matvec_01.cc +++ b/tests/mpi/trilinos_matvec_01.cc @@ -98,7 +98,7 @@ void test () for (unsigned int i=0; i(); x(global_index) = dx(global_index); } dy = 1.; diff --git a/tests/mpi/trilinos_matvec_02.cc b/tests/mpi/trilinos_matvec_02.cc index 48f5c0e0aa..ff965a3f60 100644 --- a/tests/mpi/trilinos_matvec_02.cc +++ b/tests/mpi/trilinos_matvec_02.cc @@ -98,7 +98,7 @@ void test () for (unsigned int i=0; i(); y(global_index) = dy(global_index); } dx = 1.; diff --git a/tests/mpi/trilinos_matvec_03.cc b/tests/mpi/trilinos_matvec_03.cc index 45d2e59e9a..91ed15d1ac 100644 --- a/tests/mpi/trilinos_matvec_03.cc +++ b/tests/mpi/trilinos_matvec_03.cc @@ -92,7 +92,7 @@ void test () for (unsigned int i=0; i(); x(global_index) = dx(global_index); } dy = 1.; diff --git a/tests/multigrid/transfer_05.cc b/tests/multigrid/transfer_05.cc index 8a927f7b0f..d9aed66f5f 100644 --- a/tests/multigrid/transfer_05.cc +++ b/tests/multigrid/transfer_05.cc @@ -129,7 +129,7 @@ void check(const unsigned int fe_degree) // set values: for (unsigned int b = 0; b < nb; ++b) for (unsigned int i=0; i(); lbv[l].compress(VectorOperation::insert); } @@ -152,7 +152,7 @@ void check(const unsigned int fe_degree) MGLevelObject> lbv2(0, tr.n_global_levels()-1); for (unsigned int b=0; b < nb; ++b) for (unsigned int i = 0; i < bv.block(b).local_size(); ++i) - bv.block(b).local_element(i) = (double)Testing::rand()/RAND_MAX; + bv.block(b).local_element(i) = random_value(); transfer.copy_to_mg(mgdof, lbv2, bv); // Also check that the block vector has its (global) size set on each level: diff --git a/tests/multigrid/transfer_06.cc b/tests/multigrid/transfer_06.cc index 751b5b0f15..d23ed92a4d 100644 --- a/tests/multigrid/transfer_06.cc +++ b/tests/multigrid/transfer_06.cc @@ -141,7 +141,7 @@ void check(const unsigned int fe_degree) // set values: for (unsigned int b = 0; b < nb; ++b) for (unsigned int i=0; i(); lbv[l].compress(VectorOperation::insert); } @@ -169,7 +169,7 @@ void check(const unsigned int fe_degree) MGLevelObject> lbv2(0, tr.n_global_levels()-1); for (unsigned int b=0; b < nb; ++b) for (unsigned int i = 0; i < bv.block(b).local_size(); ++i) - bv.block(b).local_element(i) = (double)Testing::rand()/RAND_MAX; + bv.block(b).local_element(i) = random_value(); transfer.copy_to_mg(mgdof_ptr, lbv2, bv); // Also check that the block vector has its (global) size set on each level: diff --git a/tests/multigrid/transfer_matrix_free_01.cc b/tests/multigrid/transfer_matrix_free_01.cc index 738cfb5c91..c5c95590aa 100644 --- a/tests/multigrid/transfer_matrix_free_01.cc +++ b/tests/multigrid/transfer_matrix_free_01.cc @@ -83,7 +83,7 @@ void check(const unsigned int fe_degree) v2.reinit(mgdof.locally_owned_mg_dofs(level), MPI_COMM_WORLD); v3.reinit(mgdof.locally_owned_mg_dofs(level), MPI_COMM_WORLD); for (unsigned int i=0; i(); v1_cpy = v1; transfer.prolongate(level, v2, v1); transfer_ref.prolongate(level, v3, v1_cpy); @@ -101,7 +101,7 @@ void check(const unsigned int fe_degree) v2.reinit(mgdof.locally_owned_mg_dofs(level-1), MPI_COMM_WORLD); v3.reinit(mgdof.locally_owned_mg_dofs(level-1), MPI_COMM_WORLD); for (unsigned int i=0; i(); v1_cpy = v1; transfer.restrict_and_add(level, v2, v1); transfer_ref.restrict_and_add(level, v3, v1_cpy); diff --git a/tests/multigrid/transfer_matrix_free_02.cc b/tests/multigrid/transfer_matrix_free_02.cc index afdf4066e2..b445e4e1fd 100644 --- a/tests/multigrid/transfer_matrix_free_02.cc +++ b/tests/multigrid/transfer_matrix_free_02.cc @@ -103,7 +103,7 @@ void check(const unsigned int fe_degree) v2.reinit(mgdof.locally_owned_mg_dofs(level), MPI_COMM_WORLD); v3.reinit(mgdof.locally_owned_mg_dofs(level), MPI_COMM_WORLD); for (unsigned int i=0; i(); v1_cpy = v1; transfer.prolongate(level, v2, v1); transfer_ref.prolongate(level, v3, v1_cpy); @@ -121,7 +121,7 @@ void check(const unsigned int fe_degree) v2.reinit(mgdof.locally_owned_mg_dofs(level-1), MPI_COMM_WORLD); v3.reinit(mgdof.locally_owned_mg_dofs(level-1), MPI_COMM_WORLD); for (unsigned int i=0; i(); v1_cpy = v1; transfer.restrict_and_add(level, v2, v1); transfer_ref.restrict_and_add(level, v3, v1_cpy); diff --git a/tests/multigrid/transfer_matrix_free_02_block.cc b/tests/multigrid/transfer_matrix_free_02_block.cc index 1b3915c4c7..3139a60b15 100644 --- a/tests/multigrid/transfer_matrix_free_02_block.cc +++ b/tests/multigrid/transfer_matrix_free_02_block.cc @@ -108,7 +108,7 @@ void check(const unsigned int fe_degree) v3.block(b).reinit(mgdof.locally_owned_mg_dofs(level), MPI_COMM_WORLD); for (unsigned int i=0; i(); transfer_ref.prolongate(level, v2.block(b), v1.block(b)); } @@ -129,7 +129,7 @@ void check(const unsigned int fe_degree) v3.block(b).reinit(mgdof.locally_owned_mg_dofs(level-1), MPI_COMM_WORLD); for (unsigned int i=0; i(); transfer_ref.restrict_and_add(level, v2.block(b), v1.block(b)); } diff --git a/tests/multigrid/transfer_matrix_free_02_block_02.cc b/tests/multigrid/transfer_matrix_free_02_block_02.cc index 6ab03ee1fb..ca12dea580 100644 --- a/tests/multigrid/transfer_matrix_free_02_block_02.cc +++ b/tests/multigrid/transfer_matrix_free_02_block_02.cc @@ -123,7 +123,7 @@ void check(const unsigned int fe_degree) v3.block(b).reinit(mgdof_ptr[b]->locally_owned_mg_dofs(level), MPI_COMM_WORLD); for (unsigned int i=0; i(); transfer_ref[b].prolongate(level, v2.block(b), v1.block(b)); } @@ -144,7 +144,7 @@ void check(const unsigned int fe_degree) v3.block(b).reinit(mgdof_ptr[b]->locally_owned_mg_dofs(level-1), MPI_COMM_WORLD); for (unsigned int i=0; i(); transfer_ref[b].restrict_and_add(level, v2.block(b), v1.block(b)); } diff --git a/tests/multigrid/transfer_matrix_free_03.cc b/tests/multigrid/transfer_matrix_free_03.cc index fd70f7b20f..9e6ee57b64 100644 --- a/tests/multigrid/transfer_matrix_free_03.cc +++ b/tests/multigrid/transfer_matrix_free_03.cc @@ -80,7 +80,7 @@ void check(const unsigned int fe_degree) v2.reinit(mgdof.locally_owned_mg_dofs(level), MPI_COMM_WORLD); v3.reinit(mgdof.locally_owned_mg_dofs(level), MPI_COMM_WORLD); for (unsigned int i=0; i(); v1_cpy = v1; transfer.prolongate(level, v2, v1); transfer_ref.prolongate(level, v3, v1_cpy); @@ -98,7 +98,7 @@ void check(const unsigned int fe_degree) v2.reinit(mgdof.locally_owned_mg_dofs(level-1), MPI_COMM_WORLD); v3.reinit(mgdof.locally_owned_mg_dofs(level-1), MPI_COMM_WORLD); for (unsigned int i=0; i(); v1_cpy = v1; transfer.restrict_and_add(level, v2, v1); transfer_ref.restrict_and_add(level, v3, v1_cpy); diff --git a/tests/multigrid/transfer_matrix_free_04.cc b/tests/multigrid/transfer_matrix_free_04.cc index 27114ecfd6..fc5ad9be02 100644 --- a/tests/multigrid/transfer_matrix_free_04.cc +++ b/tests/multigrid/transfer_matrix_free_04.cc @@ -79,7 +79,7 @@ void check(const unsigned int fe_degree) v2.reinit(mgdof.locally_owned_mg_dofs(level), MPI_COMM_WORLD); v3.reinit(mgdof.locally_owned_mg_dofs(level), MPI_COMM_WORLD); for (unsigned int i=0; i(); v1_cpy = v1; transfer.prolongate(level, v2, v1); transfer_ref.prolongate(level, v3, v1_cpy); @@ -98,7 +98,7 @@ void check(const unsigned int fe_degree) v2.reinit(mgdof.locally_owned_mg_dofs(level-1), MPI_COMM_WORLD); v3.reinit(mgdof.locally_owned_mg_dofs(level-1), MPI_COMM_WORLD); for (unsigned int i=0; i(); v1_cpy = v1; transfer.restrict_and_add(level, v2, v1); transfer_ref.restrict_and_add(level, v3, v1_cpy); diff --git a/tests/multigrid/transfer_matrix_free_05.cc b/tests/multigrid/transfer_matrix_free_05.cc index cb2cd01a00..ba75a42778 100644 --- a/tests/multigrid/transfer_matrix_free_05.cc +++ b/tests/multigrid/transfer_matrix_free_05.cc @@ -98,7 +98,7 @@ void check(const unsigned int fe_degree) v2.reinit(mgdof.locally_owned_mg_dofs(level), MPI_COMM_WORLD); v3.reinit(mgdof.locally_owned_mg_dofs(level), MPI_COMM_WORLD); for (unsigned int i=0; i(); v1_cpy = v1; transfer.prolongate(level, v2, v1); transfer_ref.prolongate(level, v3, v1_cpy); @@ -117,7 +117,7 @@ void check(const unsigned int fe_degree) v2.reinit(mgdof.locally_owned_mg_dofs(level-1), MPI_COMM_WORLD); v3.reinit(mgdof.locally_owned_mg_dofs(level-1), MPI_COMM_WORLD); for (unsigned int i=0; i(); v1_cpy = v1; transfer.restrict_and_add(level, v2, v1); transfer_ref.restrict_and_add(level, v3, v1_cpy); diff --git a/tests/multigrid/transfer_matrix_free_06.cc b/tests/multigrid/transfer_matrix_free_06.cc index db0bb70257..78260b95eb 100644 --- a/tests/multigrid/transfer_matrix_free_06.cc +++ b/tests/multigrid/transfer_matrix_free_06.cc @@ -105,7 +105,7 @@ void check(const unsigned int fe_degree) v2.reinit(mgdof.locally_owned_mg_dofs(level), MPI_COMM_WORLD); v3.reinit(mgdof.locally_owned_mg_dofs(level), MPI_COMM_WORLD); for (unsigned int i=0; i(); v1_cpy = v1; transfer.prolongate(level, v2, v1); transfer_ref.prolongate(level, v3, v1_cpy); @@ -123,7 +123,7 @@ void check(const unsigned int fe_degree) v2.reinit(mgdof.locally_owned_mg_dofs(level-1), MPI_COMM_WORLD); v3.reinit(mgdof.locally_owned_mg_dofs(level-1), MPI_COMM_WORLD); for (unsigned int i=0; i(); v1_cpy = v1; transfer.restrict_and_add(level, v2, v1); transfer_ref.restrict_and_add(level, v3, v1_cpy); diff --git a/tests/multigrid/transfer_matrix_free_07.cc b/tests/multigrid/transfer_matrix_free_07.cc index fe4752e8ed..ef88816d5b 100644 --- a/tests/multigrid/transfer_matrix_free_07.cc +++ b/tests/multigrid/transfer_matrix_free_07.cc @@ -96,7 +96,7 @@ void check(const unsigned int fe_degree) v2.reinit(mgdof.locally_owned_mg_dofs(level), MPI_COMM_WORLD); v3.reinit(mgdof.locally_owned_mg_dofs(level), MPI_COMM_WORLD); for (unsigned int i=0; i(); v1_cpy = v1; transfer.prolongate(level, v2, v1); transfer_ref.prolongate(level, v3, v1_cpy); @@ -114,7 +114,7 @@ void check(const unsigned int fe_degree) v2.reinit(mgdof.locally_owned_mg_dofs(level-1), MPI_COMM_WORLD); v3.reinit(mgdof.locally_owned_mg_dofs(level-1), MPI_COMM_WORLD); for (unsigned int i=0; i(); v1_cpy = v1; transfer.restrict_and_add(level, v2, v1); transfer_ref.restrict_and_add(level, v3, v1_cpy); diff --git a/tests/multigrid/transfer_matrix_free_11.cc b/tests/multigrid/transfer_matrix_free_11.cc index ea4a1d831b..85a6c7f7e0 100644 --- a/tests/multigrid/transfer_matrix_free_11.cc +++ b/tests/multigrid/transfer_matrix_free_11.cc @@ -76,7 +76,7 @@ void check(const unsigned int fe_degree) v2.reinit(mgdof.locally_owned_mg_dofs(level), MPI_COMM_WORLD); v3.reinit(mgdof.locally_owned_mg_dofs(level), MPI_COMM_WORLD); for (unsigned int i=0; i(); v1_cpy = v1; transfer.prolongate(level, v2, v1); transfer_ref.prolongate(level, v3, v1_cpy); @@ -102,7 +102,7 @@ void check(const unsigned int fe_degree) v2.reinit(mgdof.locally_owned_mg_dofs(level-1), MPI_COMM_WORLD); v3.reinit(mgdof.locally_owned_mg_dofs(level-1), MPI_COMM_WORLD); for (unsigned int i=0; i(); v1_cpy = v1; transfer.restrict_and_add(level, v2, v1); transfer_ref.restrict_and_add(level, v3, v1_cpy); diff --git a/tests/slepc/solve_01.cc b/tests/slepc/solve_01.cc index 070164ae66..b51e25a0a4 100644 --- a/tests/slepc/solve_01.cc +++ b/tests/slepc/solve_01.cc @@ -48,7 +48,7 @@ check_solve( SolverType &solver, // to avoid dependency on SLEPc random numbers: for (unsigned int i = 0; i < u.size(); i++) for (unsigned int j=0; j(Testing::rand())/static_cast(RAND_MAX); + u[i][j] = random_value(); for (auto &vector : u) vector.compress(VectorOperation::insert); diff --git a/tests/slepc/solve_04.cc b/tests/slepc/solve_04.cc index 0618d2ef8e..751acdab57 100644 --- a/tests/slepc/solve_04.cc +++ b/tests/slepc/solve_04.cc @@ -49,7 +49,7 @@ check_solve( SolverType &solver, // to avoid dependency on random numbers: for (unsigned int i = 0; i < u.size(); i++) for (unsigned int j=0; j(Testing::rand())/static_cast(RAND_MAX); + u[i][j] = random_value(); for (auto &vector : u) vector.compress(VectorOperation::insert); diff --git a/tests/slepc/step-36_parallel.cc b/tests/slepc/step-36_parallel.cc index ec31dabbdf..b85aadc868 100644 --- a/tests/slepc/step-36_parallel.cc +++ b/tests/slepc/step-36_parallel.cc @@ -145,7 +145,7 @@ void test (std::string solver_name, { eigenfunctions[i].reinit (locally_owned_dofs, mpi_communicator);//without ghost dofs for (unsigned int j=0; j(Testing::rand())/static_cast(RAND_MAX); + eigenfunctions[i][locally_owned_dofs.nth_index_in_set(j)] = random_value(); eigenfunctions[i].compress(dealii::VectorOperation::insert); } diff --git a/tests/slepc/step-36_parallel_02.cc b/tests/slepc/step-36_parallel_02.cc index d7d05f50fd..d1d6b7dff1 100644 --- a/tests/slepc/step-36_parallel_02.cc +++ b/tests/slepc/step-36_parallel_02.cc @@ -145,7 +145,7 @@ void test (std::string solver_name, { eigenfunctions[i].reinit (locally_owned_dofs, mpi_communicator);//without ghost dofs for (unsigned int j=0; j(Testing::rand())/static_cast(RAND_MAX); + eigenfunctions[i][locally_owned_dofs.nth_index_in_set(j)] = random_value(); eigenfunctions[i].compress(dealii::VectorOperation::insert); } diff --git a/tests/slepc/step-36_parallel_03.cc b/tests/slepc/step-36_parallel_03.cc index a5fb1a22af..0a6ccaeb25 100644 --- a/tests/slepc/step-36_parallel_03.cc +++ b/tests/slepc/step-36_parallel_03.cc @@ -145,7 +145,7 @@ void test (std::string solver_name, { eigenfunctions[i].reinit (locally_owned_dofs, mpi_communicator);//without ghost dofs for (unsigned int j=0; j(Testing::rand())/static_cast(RAND_MAX); + eigenfunctions[i][locally_owned_dofs.nth_index_in_set(j)] = random_value(); eigenfunctions[i].compress(dealii::VectorOperation::insert); } diff --git a/tests/tests.h b/tests/tests.h index 304e74a653..2301fe6ab1 100644 --- a/tests/tests.h +++ b/tests/tests.h @@ -26,6 +26,8 @@ #include #include #include +#include +#include #include #include #include @@ -187,6 +189,40 @@ namespace Testing +// Get a uniformly distributed random value between min and max +template +T random_value(const T &min, const T &max) +{ + return min+(max-min)*(Testing::rand()/static_cast(RAND_MAX)); +} + + + +// Same as above, but allows one to leave 0 as a default minimum value, +// and specify only the maximum +template +T random_value(const T &max=1) +{ + return random_value(static_cast(0), max); +} + + + +// Construct a uniformly distributed random point, with each coordinate +// between min and max +template +inline Point random_point(const double &min=0.0, + const double &max=1.0) +{ + Assert(max >= min, ExcMessage("Make sure max>=min")); + Point p; + for (unsigned int i=0; i