File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11#include " mockgrid.h"
2- #include < random>
3- #include < stdlib.h>
4- #include < algorithm>
52void create_grid (gmgpolar& test_p)
63{
74 std::default_random_engine gen (time (0 ));
85 std::uniform_real_distribution<double > dis (gyro::dcntl[Param::R0], gyro::dcntl[Param::R]);
6+ std::uniform_real_distribution<double > theta_distribution (0 , 2 * PI);
97 level* new_level = new level (0 );
108 new_level->nr = pow (2 , gyro::icntl[Param::nr_exp]);
119 new_level->r = std::vector<double >(new_level->nr + 1 );
@@ -26,8 +24,17 @@ void create_grid(gmgpolar& test_p)
2624
2725 new_level->theta = std::vector<double >(new_level->ntheta );
2826
29- for (int i = 0 ; i < new_level->ntheta ; i++) {
30- new_level->theta [i] = 2 . * PI * static_cast <double >(i) / ntmp; // uniform in theta
27+ std::vector<double > randst (ntmp - 1 );
28+ for (int k = 0 ; k < ntmp - 1 ; ++k) {
29+ randst[k] = theta_distribution (gen);
30+ }
31+ std::sort (randst.begin (), randst.end ());
32+ new_level->theta [0 ] = 0 ;
33+ for (int i = 1 ; i < ntmp; i++) {
34+ new_level->theta [i] = randst[i - 1 ];
35+ }
36+ if (!gyro::icntl[Param::periodic]) {
37+ new_level->theta [ntmp] = 2 * PI;
3138 }
3239
3340 new_level->ntheta_int = gyro::icntl[Param::periodic] ? new_level->ntheta : new_level->ntheta - 1 ;
Original file line number Diff line number Diff line change 11#include "gmgpolar.h"
2+ #include <random>
3+ #include <stdlib.h>
4+ #include <algorithm>
25
36#ifndef MOCKGRID_H
4- #define MOCKGRID_H
7+ #define MOCKGRID_H
58
69void create_grid (gmgpolar & test_p );
710
You can’t perform that action at this time.
0 commit comments