Changeset 3154 in Sophya for trunk/Cosmo/SimLSS/genefluct3d.cc
- Timestamp:
- Jan 19, 2007, 5:19:49 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Cosmo/SimLSS/genefluct3d.cc
r3150 r3154 32 32 //------------------------------------------------------- 33 33 GeneFluct3D::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.) 35 36 { 36 37 SetNThread(); … … 52 53 setalloc(); 53 54 setpointers(false); 55 init_fftw(); 56 } 57 58 void 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; 54 72 } 55 73 … … 126 144 } 127 145 146 void 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 128 162 129 163 //------------------------------------------------------- … … 142 176 fwrt.WriteKey("DKY",Dky_," Mpc^-1"); 143 177 fwrt.WriteKey("DKZ",Dkz_," Mpc^-1"); 178 fwrt.WriteKey("ZREF",redshref_," reference redshift"); 179 fwrt.WriteKey("KZREF",kredshref_," reference redshift on z axe"); 144 180 fwrt.Write(R_); 145 181 } catch (PThrowable & exc) { … … 165 201 double dy = fimg.ReadKey("DY"); 166 202 double dz = fimg.ReadKey("DZ"); 203 double zref = fimg.ReadKey("ZREF"); 204 double kzref = fimg.ReadKey("KZREF"); 167 205 setsize(nx,ny,nz,dx,dy,dz); 168 206 setpointers(true); 207 init_fftw(); 208 SetObservator(zref,kzref); 169 209 } catch (PThrowable & exc) { 170 210 cout<<"Exception : "<<(string)typeid(exc).name() … … 188 228 R_.Info()["DY"] = (r_8)Dy_; 189 229 R_.Info()["DZ"] = (r_8)Dz_; 230 R_.Info()["ZREF"] = (r_8)redshref_; 231 R_.Info()["KZREF"] = (r_8)kredshref_; 190 232 POutPersist pos(cfname.c_str()); 191 233 if(write_real) pos << PPFNameTag("rgen") << R_; … … 217 259 pis >> PPFNameTag("rgen") >> R_; 218 260 } 261 setpointers(from_real); // a mettre ici pour relire les DVInfo 219 262 int_8 nx = R_.Info()["NX"]; 220 263 int_8 ny = R_.Info()["NY"]; … … 223 266 r_8 dy = R_.Info()["DY"]; 224 267 r_8 dz = R_.Info()["DZ"]; 268 r_8 zref = R_.Info()["ZREF"]; 269 r_8 kzref = R_.Info()["KZREF"]; 225 270 setsize(nx,ny,nz,dx,dy,dz); 226 setpointers(from_real); 271 init_fftw(); 272 SetObservator(zref,kzref); 227 273 } catch (PThrowable & exc) { 228 274 cout<<"Exception : "<<(string)typeid(exc).name() … … 250 296 <<", Kmax="<<GetKmax()<<" Mpc^-1"<<endl; 251 297 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; 252 299 } 253 300 … … 257 304 // (attention on fait une fft pour realiser le spectre) 258 305 { 259 // --- Initialisation de fftw3 (attention data est sur-ecrit a l'init)260 if(lp_>1) PrtTim("--- ComputeFourier0: before fftw_plan ---");261 #ifdef FFTW_THREAD262 if(nthread_>0) {263 cout<<"Computing with "<<nthread_<<" threads"<<endl;264 fftw_init_threads();265 fftw_plan_with_nthreads(nthread_);266 }267 #endif268 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 ---");271 306 272 307 // --- realisation d'un tableau de tirage gaussiens … … 326 361 // sum(fb(x_i)^2) = S*N^2 327 362 { 328 // --- Initialisation de fftw3 (attention data est sur-ecrit a l'init)329 if(lp_>1) PrtTim("--- ComputeFourier: before fftw_plan ---");330 #ifdef FFTW_THREAD331 if(nthread_>0) {332 cout<<"Computing with "<<nthread_<<" threads"<<endl;333 fftw_init_threads();334 fftw_plan_with_nthreads(nthread_);335 }336 #endif337 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 342 363 // --- RaZ du tableau 343 364 T_ = complex<r_8>(0.);
Note:
See TracChangeset
for help on using the changeset viewer.