mirror of
https://github.com/cosmo-sims/MUSIC.git
synced 2024-09-08 04:23:44 +02:00
added back (and exposed) N-GenIC topgrid generator
This commit is contained in:
parent
bfbb00ae71
commit
c18cb64055
3 changed files with 27 additions and 22 deletions
|
@ -145,6 +145,7 @@ void RNG_music::parse_random_parameters(void)
|
|||
void RNG_music::compute_random_numbers(void)
|
||||
{
|
||||
bool rndsign = pcf_->get_value_safe<bool>("random", "grafic_sign", false);
|
||||
bool bUseNGenIC = pcf_->get_value_safe<bool>("random","coarse_ngenic",false);
|
||||
|
||||
std::vector<rng *> randc(std::max(levelmax_, levelmin_seed_) + 1, (rng *)NULL);
|
||||
|
||||
|
@ -156,7 +157,8 @@ void RNG_music::compute_random_numbers(void)
|
|||
if (rngfnames_[levelmin_seed_].size() > 0)
|
||||
randc[levelmin_seed_] = new rng(1 << levelmin_seed_, rngfnames_[levelmin_seed_], rndsign);
|
||||
else
|
||||
randc[levelmin_seed_] = new rng(1 << levelmin_seed_, ran_cube_size_, rngseeds_[levelmin_seed_]);
|
||||
randc[levelmin_seed_] = new rng(1 << levelmin_seed_, ran_cube_size_, rngseeds_[levelmin_seed_],
|
||||
bUseNGenIC, true);
|
||||
|
||||
for (int i = levelmin_seed_ + 1; i <= levelmin_; ++i)
|
||||
{
|
||||
|
@ -178,7 +180,7 @@ void RNG_music::compute_random_numbers(void)
|
|||
randc[levelmin_seed_] = new rng(1 << levelmin_seed_, rngfnames_[levelmin_seed_], rndsign);
|
||||
else
|
||||
randc[levelmin_seed_] =
|
||||
new rng(1 << levelmin_seed_, ran_cube_size_, rngseeds_[levelmin_seed_]); //, x0, lx );
|
||||
new rng(1 << levelmin_seed_, ran_cube_size_, rngseeds_[levelmin_seed_], bUseNGenIC, true); //, x0, lx );
|
||||
|
||||
for (int ilevel = levelmin_seed_ - 1; ilevel >= (int)levelmin_; --ilevel)
|
||||
{
|
||||
|
@ -205,7 +207,7 @@ void RNG_music::compute_random_numbers(void)
|
|||
if (rngfnames_[levelmin_].size() > 0)
|
||||
randc[levelmin_] = new rng(1 << levelmin_, rngfnames_[levelmin_], rndsign);
|
||||
else
|
||||
randc[levelmin_] = new rng(1 << levelmin_, ran_cube_size_, rngseeds_[levelmin_]);
|
||||
randc[levelmin_] = new rng(1 << levelmin_, ran_cube_size_, rngseeds_[levelmin_], bUseNGenIC, true);
|
||||
}
|
||||
|
||||
store_rnd(levelmin_, randc[levelmin_]);
|
||||
|
|
|
@ -11,10 +11,13 @@
|
|||
|
||||
|
||||
template <typename T>
|
||||
void rapid_proto_ngenic_rng(size_t res, long baseseed, music_wnoise_generator<T> &R)
|
||||
{
|
||||
music::ulog.Print("Invoking the N-GenIC random number generator");
|
||||
void music_wnoise_generator<T>:: gen_topgrid_NGenIC(size_t res, long baseseed) {
|
||||
music::ulog.Print(
|
||||
"Generating large-scale random numbers using N-GenIC RNG with seed %ld",
|
||||
baseseed);
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// execute N-GenIC rando number generator
|
||||
unsigned *seedtable = new unsigned[res * res];
|
||||
|
||||
gsl_rng *random_generator = gsl_rng_alloc(gsl_rng_ranlxd1);
|
||||
|
@ -138,7 +141,7 @@ void rapid_proto_ngenic_rng(size_t res, long baseseed, music_wnoise_generator<T>
|
|||
for (int i = 0; i < (int)res; ++i)
|
||||
for (size_t j = 0; j < res; ++j)
|
||||
for (size_t k = 0; k < res; ++k)
|
||||
R(i, j, k) = rnoise[((size_t)i * res + j) * res + k];
|
||||
(*this)(i, j, k) = rnoise[((size_t)i * res + j) * res + k];
|
||||
|
||||
delete[] rnoise;
|
||||
}
|
||||
|
@ -154,7 +157,8 @@ music_wnoise_generator<T>::music_wnoise_generator(unsigned res, unsigned cubesiz
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
music_wnoise_generator<T>::music_wnoise_generator(unsigned res, unsigned cubesize, long baseseed, bool zeromean)
|
||||
music_wnoise_generator<T>::music_wnoise_generator( unsigned res, unsigned cubesize, long baseseed,
|
||||
bool bUseNGenIC, bool zeromean )
|
||||
: res_(res), cubesize_(cubesize), ncubes_(1), baseseed_(baseseed)
|
||||
{
|
||||
music::ilog.Print("Generating random numbers (2) with seed %ld", baseseed);
|
||||
|
@ -162,23 +166,19 @@ music_wnoise_generator<T>::music_wnoise_generator(unsigned res, unsigned cubesiz
|
|||
double mean = 0.0;
|
||||
size_t res_l = res;
|
||||
|
||||
bool musicnoise = true;
|
||||
if (!musicnoise)
|
||||
cubesize_ = res_;
|
||||
|
||||
if (!musicnoise)
|
||||
music::elog.Print("This currently breaks compatibility. Need to disable by hand! Make sure to not check into repo");
|
||||
if( bUseNGenIC ){
|
||||
cubesize_ = res;
|
||||
ncubes_ = 1;
|
||||
}
|
||||
|
||||
initialize();
|
||||
|
||||
if (musicnoise)
|
||||
if( !bUseNGenIC ){
|
||||
mean = fill_all();
|
||||
else
|
||||
{
|
||||
rnums_.push_back(new Meshvar<T>(res, 0, 0, 0));
|
||||
cubemap_[0] = 0; // create dummy map index
|
||||
register_cube(0, 0, 0);
|
||||
rapid_proto_ngenic_rng( res_, baseseed_, *this );
|
||||
}else{
|
||||
mean = 0.0;
|
||||
gen_topgrid_NGenIC( res_, baseseed_ );
|
||||
zeromean = false;
|
||||
}
|
||||
|
||||
if (zeromean)
|
||||
|
|
|
@ -39,6 +39,9 @@ protected:
|
|||
//! subtract a constant from an entire cube
|
||||
void subtract_from_cube(int i, int j, int k, double val);
|
||||
|
||||
//! usees the N-GenIC random number generator to set up the top grid
|
||||
void gen_topgrid_NGenIC( size_t res, long baseseed );
|
||||
|
||||
//! copy random numbers from a cube to a full grid array
|
||||
template <class C>
|
||||
void copy_cube(int i, int j, int k, C &dat)
|
||||
|
@ -127,7 +130,7 @@ public:
|
|||
music_wnoise_generator(music_wnoise_generator<T> &rc, unsigned cubesize, long baseseed, int *x0_ = NULL, int *lx_ = NULL, bool zeromean = true);
|
||||
|
||||
//! constructor
|
||||
music_wnoise_generator(unsigned res, unsigned cubesize, long baseseed, bool zeromean = true);
|
||||
music_wnoise_generator(unsigned res, unsigned cubesize, long baseseed, bool bUseNGenIC, bool zeromean = true );
|
||||
|
||||
//! constructor to read white noise from file
|
||||
music_wnoise_generator(unsigned res, std::string randfname, bool rndsign);
|
||||
|
|
Loading…
Reference in a new issue