Changeset 3154 in Sophya for trunk/Cosmo/SimLSS/genefluct3d.cc


Ignore:
Timestamp:
Jan 19, 2007, 5:19:49 PM (19 years ago)
Author:
cmv
Message:

modifs d'options de cmvobserv3d.cc
creation de init_fftw() et deplacement a l'initialisation
creation de SetObservator pour positionner l'observateur + ecriture FITS et PPF

(mais le codage des distance/redshift reste a coder)

cmv 19/01/2007

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Cosmo/SimLSS/genefluct3d.cc

    r3150 r3154  
    3232//-------------------------------------------------------
    3333GeneFluct3D::GeneFluct3D(TArray< complex<r_8 > >& T)
    34   : T_(T) , array_allocated_(false) , lp_(0)
     34  : T_(T) , Nx_(0) , Ny_(0) , Nz_(0) , array_allocated_(false) , lp_(0)
     35  , redshref_(-999.) , kredshref_(-999.)
    3536{
    3637 SetNThread();
     
    5253  setalloc();
    5354  setpointers(false);
     55  init_fftw();
     56}
     57
     58void GeneFluct3D::SetObservator(double redshref,double kredshref)
     59// L'observateur est au redshift z=0
     60//               est situe sur la "perpendiculaire" a la face x,y
     61//                         issue du centre de cette face
     62// Il faut positionner le cube sur l'axe des z cad des redshifts:
     63//     redshref  = redshift de reference
     64//                 Si redshref<0 alors redshref=0
     65//     kredshref = indice (en double) correspondant a ce redshift
     66//                 Si kredshref<0 alors kredshref=0
     67{
     68 if(redshref<0.) redshref = 0.;
     69 if(kredshref<0.) kredshref = 0.;
     70 redshref_ = redshref;
     71 kredshref_ = kredshref;
    5472}
    5573
     
    126144}
    127145
     146void GeneFluct3D::init_fftw(void)
     147{
     148 // --- Initialisation de fftw3 (attention data est sur-ecrit a l'init)
     149 if(lp_>1) PrtTim("--- GeneFluct3D::init_fftw: before fftw_plan ---");
     150#ifdef FFTW_THREAD
     151 if(nthread_>0) {
     152   cout<<"Computing with "<<nthread_<<" threads"<<endl;
     153   fftw_init_threads();
     154   fftw_plan_with_nthreads(nthread_);
     155 }
     156#endif
     157 pf_ = fftw_plan_dft_r2c_3d(Nx_,Ny_,Nz_,data_,fdata_,FFTW_ESTIMATE);
     158 pb_ = fftw_plan_dft_c2r_3d(Nx_,Ny_,Nz_,fdata_,data_,FFTW_ESTIMATE);
     159 if(lp_>1) PrtTim("--- GeneFluct3D::init_fftw: after fftw_plan ---");
     160}
     161
    128162
    129163//-------------------------------------------------------
     
    142176   fwrt.WriteKey("DKY",Dky_," Mpc^-1");
    143177   fwrt.WriteKey("DKZ",Dkz_," Mpc^-1");
     178   fwrt.WriteKey("ZREF",redshref_," reference redshift");
     179   fwrt.WriteKey("KZREF",kredshref_," reference redshift on z axe");
    144180   fwrt.Write(R_);
    145181 } catch (PThrowable & exc) {
     
    165201   double dy = fimg.ReadKey("DY");
    166202   double dz = fimg.ReadKey("DZ");
     203   double zref = fimg.ReadKey("ZREF");
     204   double kzref = fimg.ReadKey("KZREF");
    167205   setsize(nx,ny,nz,dx,dy,dz);
    168206   setpointers(true);
     207   init_fftw();
     208   SetObservator(zref,kzref);
    169209 } catch (PThrowable & exc) {
    170210   cout<<"Exception : "<<(string)typeid(exc).name()
     
    188228   R_.Info()["DY"] = (r_8)Dy_;
    189229   R_.Info()["DZ"] = (r_8)Dz_;
     230   R_.Info()["ZREF"] = (r_8)redshref_;
     231   R_.Info()["KZREF"] = (r_8)kredshref_;
    190232   POutPersist pos(cfname.c_str());
    191233   if(write_real) pos << PPFNameTag("rgen")  << R_;
     
    217259     pis >> PPFNameTag("rgen")  >> R_;
    218260   }
     261   setpointers(from_real);  // a mettre ici pour relire les DVInfo
    219262   int_8 nx = R_.Info()["NX"];
    220263   int_8 ny = R_.Info()["NY"];
     
    223266   r_8 dy = R_.Info()["DY"];
    224267   r_8 dz = R_.Info()["DZ"];
     268   r_8 zref = R_.Info()["ZREF"];
     269   r_8 kzref = R_.Info()["KZREF"];
    225270   setsize(nx,ny,nz,dx,dy,dz);
    226    setpointers(from_real);
     271   init_fftw();
     272   SetObservator(zref,kzref);
    227273 } catch (PThrowable & exc) {
    228274   cout<<"Exception : "<<(string)typeid(exc).name()
     
    250296     <<", Kmax="<<GetKmax()<<" Mpc^-1"<<endl;
    251297 cout<<"          (2Pi/k: "<<2.*M_PI/Knyqx_<<" "<<2.*M_PI/Knyqy_<<" "<<2.*M_PI/Knyqz_<<" Mpc)"<<endl;
     298 cout<<"Redshift "<<redshref_<<" for z axe at k="<<kredshref_<<endl;
    252299}
    253300
     
    257304//    (attention on fait une fft pour realiser le spectre)
    258305{
    259  // --- Initialisation de fftw3 (attention data est sur-ecrit a l'init)
    260  if(lp_>1) PrtTim("--- ComputeFourier0: before fftw_plan ---");
    261 #ifdef FFTW_THREAD
    262  if(nthread_>0) {
    263    cout<<"Computing with "<<nthread_<<" threads"<<endl;
    264    fftw_init_threads();
    265    fftw_plan_with_nthreads(nthread_);
    266  }
    267 #endif
    268  pf_ = fftw_plan_dft_r2c_3d(Nx_,Ny_,Nz_,data_,fdata_,FFTW_ESTIMATE);
    269  pb_ = fftw_plan_dft_c2r_3d(Nx_,Ny_,Nz_,fdata_,data_,FFTW_ESTIMATE);
    270  if(lp_>1) PrtTim("--- ComputeFourier0: after fftw_plan ---");
    271306
    272307 // --- realisation d'un tableau de tirage gaussiens
     
    326361//                                          sum(fb(x_i)^2) = S*N^2
    327362{
    328  // --- Initialisation de fftw3 (attention data est sur-ecrit a l'init)
    329  if(lp_>1) PrtTim("--- ComputeFourier: before fftw_plan ---");
    330 #ifdef FFTW_THREAD
    331  if(nthread_>0) {
    332    cout<<"Computing with "<<nthread_<<" threads"<<endl;
    333    fftw_init_threads();
    334    fftw_plan_with_nthreads(nthread_);
    335  }
    336 #endif
    337  pf_ = fftw_plan_dft_r2c_3d(Nx_,Ny_,Nz_,data_,fdata_,FFTW_ESTIMATE);
    338  pb_ = fftw_plan_dft_c2r_3d(Nx_,Ny_,Nz_,fdata_,data_,FFTW_ESTIMATE);
    339  //fftw_print_plan(pb_); cout<<endl;
    340  if(lp_>1) PrtTim("--- ComputeFourier: after fftw_plan ---");
    341 
    342363 // --- RaZ du tableau
    343364 T_ = complex<r_8>(0.);
Note: See TracChangeset for help on using the changeset viewer.