mirror of
https://github.com/OPM/opm-upscaling.git
synced 2025-02-25 18:45:23 -06:00
Merge pull request #296 from akva2/use_std_random
changed: use std::random instead of boost::random
This commit is contained in:
commit
7074099338
@ -48,10 +48,7 @@
|
||||
|
||||
#include <sys/utsname.h>
|
||||
|
||||
#include <boost/random/mersenne_twister.hpp>
|
||||
#include <boost/random/uniform_int.hpp>
|
||||
#include <boost/random/uniform_real.hpp>
|
||||
#include <boost/random/variate_generator.hpp>
|
||||
#include <random>
|
||||
|
||||
int main(int argc, char** argv)
|
||||
try
|
||||
@ -88,7 +85,7 @@ try
|
||||
bool upscale = param.getDefault("upscale", true);
|
||||
std::string bc = param.getDefault<std::string>("bc", "fixed");
|
||||
bool resettoorigin = param.getDefault("resettoorigin", true);
|
||||
boost::mt19937::result_type userseed = param.getDefault("seed", 0);
|
||||
std::mt19937::result_type userseed = param.getDefault("seed", 0);
|
||||
bool use_random = param.getDefault("use_random", true);
|
||||
|
||||
int outputprecision = param.getDefault("outputprecision", 8);
|
||||
@ -234,12 +231,11 @@ try
|
||||
jmin, jlen, jmax,
|
||||
zmin, zlen, zmax);
|
||||
|
||||
// Random number generator from boost.
|
||||
boost::mt19937 gen;
|
||||
std::mt19937 gen;
|
||||
|
||||
// Seed the random number generators with the current time, unless specified on command line
|
||||
// Warning: Current code does not allow 0 for the seed!!
|
||||
boost::mt19937::result_type autoseed = time(NULL);
|
||||
std::mt19937::result_type autoseed = time(NULL);
|
||||
if (userseed == 0) {
|
||||
gen.seed(autoseed);
|
||||
}
|
||||
@ -273,12 +269,12 @@ try
|
||||
}
|
||||
|
||||
// Note that end is included in interval for uniform_int.
|
||||
boost::uniform_int<> disti(imin, imax - ilen);
|
||||
boost::uniform_int<> distj(jmin, jmax - jlen);
|
||||
boost::uniform_real<> distz(zmin, std::max(zmax - zlen, zmin+1e-6));
|
||||
boost::variate_generator<boost::mt19937&, boost::uniform_int<> > ri(gen, disti);
|
||||
boost::variate_generator<boost::mt19937&, boost::uniform_int<> > rj(gen, distj);
|
||||
boost::variate_generator<boost::mt19937&, boost::uniform_real<> > rz(gen, distz);
|
||||
std::uniform_int_distribution<> disti(imin, imax - ilen);
|
||||
std::uniform_int_distribution<> distj(jmin, jmax - jlen);
|
||||
std::uniform_real_distribution<> distz(zmin, std::max(zmax - zlen, zmin+1e-6));
|
||||
auto ri = [&disti, &gen] { return disti(gen); };
|
||||
auto rj = [&distj, &gen] { return distj(gen); };
|
||||
auto rz = [&distz, &gen] { return distz(gen); };
|
||||
|
||||
// Storage for results
|
||||
std::vector<double> porosities;
|
||||
|
@ -45,10 +45,7 @@
|
||||
|
||||
#include <sys/utsname.h>
|
||||
|
||||
#include <boost/random/mersenne_twister.hpp>
|
||||
#include <boost/random/uniform_int.hpp>
|
||||
#include <boost/random/uniform_real.hpp>
|
||||
#include <boost/random/variate_generator.hpp>
|
||||
#include <random>
|
||||
|
||||
/**
|
||||
This program is a variant of cpchop. Instead of subsampling randomly,
|
||||
@ -93,7 +90,7 @@ try
|
||||
double zlen = param.getDefault("zlen", zresolution);
|
||||
bool upscale = param.getDefault("upscale", true);
|
||||
bool resettoorigin = param.getDefault("resettoorigin", true);
|
||||
boost::mt19937::result_type userseed = param.getDefault("seed", 0);
|
||||
std::mt19937::result_type userseed = param.getDefault("seed", 0);
|
||||
|
||||
int outputprecision = param.getDefault("outputprecision", 8);
|
||||
std::string filebase = param.getDefault<std::string>("filebase", "");
|
||||
@ -122,8 +119,7 @@ try
|
||||
jmin, jlen, jmax,
|
||||
zmin, zlen, zmax);
|
||||
|
||||
// Random number generator from boost.
|
||||
boost::mt19937 gen;
|
||||
std::mt19937 gen;
|
||||
|
||||
// Seed the random number generators with the current time, unless specified on command line
|
||||
// Warning: Current code does not allow 0 for the seed!!
|
||||
@ -136,10 +132,10 @@ try
|
||||
|
||||
|
||||
// Note that end is included in interval for uniform_int.
|
||||
boost::uniform_int<> disti(imin, imax - ilen);
|
||||
boost::uniform_int<> distj(jmin, jmax - jlen);
|
||||
boost::variate_generator<boost::mt19937&, boost::uniform_int<> > ri(gen, disti);
|
||||
boost::variate_generator<boost::mt19937&, boost::uniform_int<> > rj(gen, distj);
|
||||
std::uniform_int_distribution<> disti(imin, imax - ilen);
|
||||
std::uniform_int_distribution<> distj(jmin, jmax - jlen);
|
||||
auto ri = [&disti, &gen] { return disti(gen); };
|
||||
auto rj = [&distj, &gen] { return distj(gen); };
|
||||
|
||||
// Storage for results
|
||||
std::vector<double> zstarts;
|
||||
|
@ -56,10 +56,7 @@
|
||||
|
||||
#include <sys/utsname.h>
|
||||
|
||||
#include <boost/random/mersenne_twister.hpp>
|
||||
#include <boost/random/uniform_int.hpp>
|
||||
#include <boost/random/uniform_real.hpp>
|
||||
#include <boost/random/variate_generator.hpp>
|
||||
#include <random>
|
||||
|
||||
int main(int argc, char** argv)
|
||||
try
|
||||
@ -84,7 +81,7 @@ try
|
||||
int ilen = param.getDefault("ilen", 0);
|
||||
int jlen = param.getDefault("jlen", 0);
|
||||
double zlen = param.getDefault("zlen", 0.0);
|
||||
boost::mt19937::result_type userseed = param.getDefault("seed", 0);
|
||||
std::mt19937::result_type userseed = param.getDefault("seed", 0);
|
||||
|
||||
int outputprecision = param.getDefault("outputprecision", 8);
|
||||
std::string resultfile = param.getDefault<std::string>("resultfile", "");
|
||||
@ -145,8 +142,7 @@ try
|
||||
jmin, jlen, jmax,
|
||||
zmin, zlen, zmax);
|
||||
|
||||
// Random number generator from boost.
|
||||
boost::mt19937 gen;
|
||||
std::mt19937 gen;
|
||||
|
||||
// Seed the random number generators with the current time, unless specified on command line
|
||||
// Warning: Current code does not allow 0 for the seed!!
|
||||
@ -159,12 +155,12 @@ try
|
||||
|
||||
|
||||
// Note that end is included in interval for uniform_int.
|
||||
boost::uniform_int<> disti(imin, imax - ilen);
|
||||
boost::uniform_int<> distj(jmin, jmax - jlen);
|
||||
boost::uniform_real<> distz(zmin, std::max(zmax - zlen, zmin));
|
||||
boost::variate_generator<boost::mt19937&, boost::uniform_int<> > ri(gen, disti);
|
||||
boost::variate_generator<boost::mt19937&, boost::uniform_int<> > rj(gen, distj);
|
||||
boost::variate_generator<boost::mt19937&, boost::uniform_real<> > rz(gen, distz);
|
||||
std::uniform_int_distribution<> disti(imin, imax - ilen);
|
||||
std::uniform_int_distribution<> distj(jmin, jmax - jlen);
|
||||
std::uniform_real_distribution<> distz(zmin, std::max(zmax - zlen, zmin));
|
||||
auto ri = [&disti, &gen] { return disti(gen); };
|
||||
auto rj = [&distj, &gen] { return distj(gen); };
|
||||
auto rz = [&distz, &gen] { return distz(gen); };
|
||||
|
||||
// Storage for results
|
||||
std::vector<double> distances;
|
||||
|
Loading…
Reference in New Issue
Block a user