mirror of
https://github.com/cosmo-sims/monofonIC.git
synced 2024-09-19 17:03:45 +02:00
optimised memory usage, wnoise is generated before anything else is allocated
This commit is contained in:
parent
edcfbbab58
commit
bf81d6e474
1 changed files with 14 additions and 13 deletions
|
@ -187,6 +187,19 @@ int run( config_file& the_config )
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
// Create arrays
|
// Create arrays
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
|
|
||||||
|
// white noise field
|
||||||
|
Grid_FFT<real_t> wnoise({ngrid, ngrid, ngrid}, {boxlen, boxlen, boxlen});
|
||||||
|
|
||||||
|
//... Fill the wnoise grid with a Gaussian white noise field, we do this first since the RNG might need extra memory
|
||||||
|
music::ilog << "-------------------------------------------------------------------------------" << std::endl;
|
||||||
|
music::ilog << "Generating white noise field...." << std::endl;
|
||||||
|
|
||||||
|
the_random_number_generator->Fill_Grid(wnoise);
|
||||||
|
|
||||||
|
wnoise.FourierTransformForward();
|
||||||
|
|
||||||
|
//... Next, declare LPT related arrays, allocated only as needed by order
|
||||||
Grid_FFT<real_t> phi({ngrid, ngrid, ngrid}, {boxlen, boxlen, boxlen});
|
Grid_FFT<real_t> phi({ngrid, ngrid, ngrid}, {boxlen, boxlen, boxlen});
|
||||||
Grid_FFT<real_t> phi2({ngrid, ngrid, ngrid}, {boxlen, boxlen, boxlen}, false); // do not allocate these unless needed
|
Grid_FFT<real_t> phi2({ngrid, ngrid, ngrid}, {boxlen, boxlen, boxlen}, false); // do not allocate these unless needed
|
||||||
Grid_FFT<real_t> phi3({ngrid, ngrid, ngrid}, {boxlen, boxlen, boxlen}, false); // ..
|
Grid_FFT<real_t> phi3({ngrid, ngrid, ngrid}, {boxlen, boxlen, boxlen}, false); // ..
|
||||||
|
@ -197,24 +210,12 @@ int run( config_file& the_config )
|
||||||
//... array [.] access to components of A3:
|
//... array [.] access to components of A3:
|
||||||
std::array<Grid_FFT<real_t> *, 3> A3({&A3x, &A3y, &A3z});
|
std::array<Grid_FFT<real_t> *, 3> A3({&A3x, &A3y, &A3z});
|
||||||
|
|
||||||
// white noise field
|
|
||||||
Grid_FFT<real_t> wnoise({ngrid, ngrid, ngrid}, {boxlen, boxlen, boxlen});
|
|
||||||
|
|
||||||
// temporary storage of additional data
|
// temporary storage of additional data
|
||||||
Grid_FFT<real_t> tmp({ngrid, ngrid, ngrid}, {boxlen, boxlen, boxlen});
|
Grid_FFT<real_t> tmp({ngrid, ngrid, ngrid}, {boxlen, boxlen, boxlen});
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
|
||||||
// Fill the grid with a Gaussian white noise field
|
|
||||||
//--------------------------------------------------------------------
|
|
||||||
music::ilog << "-------------------------------------------------------------------------------" << std::endl;
|
|
||||||
music::ilog << "Generating white noise field...." << std::endl;
|
|
||||||
|
|
||||||
the_random_number_generator->Fill_Grid(wnoise);
|
|
||||||
|
|
||||||
wnoise.FourierTransformForward();
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
// Use externally specified large scale modes from constraints in case
|
// Use externally specified large scale modes from constraints in case
|
||||||
|
// TODO: move to separate routine
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
if( bAddConstrainedModes ){
|
if( bAddConstrainedModes ){
|
||||||
Grid_FFT<real_t,false> cwnoise({8,8,8}, {boxlen,boxlen,boxlen});
|
Grid_FFT<real_t,false> cwnoise({8,8,8}, {boxlen,boxlen,boxlen});
|
||||||
|
|
Loading…
Reference in a new issue