Changeset 3518 in Sophya for trunk/Cosmo/SimLSS/genefluct3d.cc
- Timestamp:
- Sep 11, 2008, 12:37:39 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Cosmo/SimLSS/genefluct3d.cc
r3516 r3518 24 24 #include "genefluct3d.h" 25 25 26 #define WITH_FFTW_THREAD 26 #if defined(GEN3D_FLOAT) 27 #define GEN3D_FFTW_INIT_THREADS fftwf_init_threads 28 #define GEN3D_FFTW_CLEANUP_THREADS fftwf_cleanup_threads 29 #define GEN3D_FFTW_PLAN_WITH_NTHREADS fftwf_plan_with_nthreads 30 #define GEN3D_FFTW_PLAN_DFT_R2C_3D fftwf_plan_dft_r2c_3d 31 #define GEN3D_FFTW_PLAN_DFT_C2R_3D fftwf_plan_dft_c2r_3d 32 #define GEN3D_FFTW_DESTROY_PLAN fftwf_destroy_plan 33 #define GEN3D_FFTW_EXECUTE fftwf_execute 34 #else 35 #define GEN3D_FFTW_INIT_THREADS fftw_init_threads 36 #define GEN3D_FFTW_CLEANUP_THREADS fftw_cleanup_threads 37 #define GEN3D_FFTW_PLAN_WITH_NTHREADS fftw_plan_with_nthreads 38 #define GEN3D_FFTW_PLAN_DFT_R2C_3D fftw_plan_dft_r2c_3d 39 #define GEN3D_FFTW_PLAN_DFT_C2R_3D fftw_plan_dft_c2r_3d 40 #define GEN3D_FFTW_DESTROY_PLAN fftw_destroy_plan 41 #define GEN3D_FFTW_EXECUTE fftw_execute 42 #endif 27 43 28 44 #define MODULE2(_x_) ((double)((_x_).real()*(_x_).real() + (_x_).imag()*(_x_).imag())) … … 64 80 { 65 81 Nx_ = Ny_ = Nz_ = 0; 66 is_set_fft w_plan = false;82 is_set_fft_plan = false; 67 83 nthread_ = 0; 68 84 lp_ = 0; … … 134 150 T_.ReSize(3,SzK_); 135 151 array_allocated_ = true; 136 if(lp_>1) cout<<" allocating: "<<T_.Size()*sizeof(complex< r_8>)/1.e6<<" Mo"<<endl;152 if(lp_>1) cout<<" allocating: "<<T_.Size()*sizeof(complex<GEN3D_TYPE>)/1.e6<<" Mo"<<endl; 137 153 } catch (...) { 138 154 cout<<"GeneFluct3D::setalloc_Error: Problem allocating T_"<<endl; … … 147 163 else R_ = ArrCastC2R(T_); 148 164 // On remplit les pointeurs 149 fdata_ = ( fftw_complex*) (&T_(0,0,0));150 data_ = ( double*) (&R_(0,0,0));165 fdata_ = (GEN3D_FFTW_COMPLEX *) (&T_(0,0,0)); 166 data_ = (GEN3D_TYPE *) (&R_(0,0,0)); 151 167 } 152 168 153 169 void GeneFluct3D::init_fftw(void) 154 170 { 155 if( is_set_fft w_plan ) delete_fftw();171 if( is_set_fft_plan ) delete_fftw(); 156 172 157 173 // --- Initialisation de fftw3 (attention data est sur-ecrit a l'init) … … 160 176 if(nthread_>0) { 161 177 cout<<"...Computing with "<<nthread_<<" threads"<<endl; 162 fftw_init_threads();163 fftw_plan_with_nthreads(nthread_);178 GEN3D_FFTW_INIT_THREADS(); 179 GEN3D_FFTW_PLAN_WITH_NTHREADS(nthread_); 164 180 } 165 181 #endif 166 182 if(lp_>1) cout<<"...forward plan"<<endl; 167 pf_ = fftw_plan_dft_r2c_3d(Nx_,Ny_,Nz_,data_,fdata_,FFTW_ESTIMATE);183 pf_ = GEN3D_FFTW_PLAN_DFT_R2C_3D(Nx_,Ny_,Nz_,data_,fdata_,FFTW_ESTIMATE); 168 184 if(lp_>1) cout<<"...backward plan"<<endl; 169 pb_ = fftw_plan_dft_c2r_3d(Nx_,Ny_,Nz_,fdata_,data_,FFTW_ESTIMATE);170 is_set_fft w_plan = true;185 pb_ = GEN3D_FFTW_PLAN_DFT_C2R_3D(Nx_,Ny_,Nz_,fdata_,data_,FFTW_ESTIMATE); 186 is_set_fft_plan = true; 171 187 } 172 188 173 189 void GeneFluct3D::delete_fftw(void) 174 190 { 175 if( !is_set_fft w_plan ) return;176 fftw_destroy_plan(pf_);177 fftw_destroy_plan(pb_);191 if( !is_set_fft_plan ) return; 192 GEN3D_FFTW_DESTROY_PLAN(pf_); 193 GEN3D_FFTW_DESTROY_PLAN(pb_); 178 194 #ifdef WITH_FFTW_THREAD 179 if(nthread_>0) fftw_cleanup_threads();195 if(nthread_>0) GEN3D_FFTW_CLEANUP_THREADS(); 180 196 #endif 181 is_set_fft w_plan = false;197 is_set_fft_plan = false; 182 198 } 183 199 … … 566 582 // --- realisation d'un tableau de tirage gaussiens 567 583 if(lp_>0) cout<<"...before fft real ---"<<endl; 568 fftw_execute(pf_);584 GEN3D_FFTW_EXECUTE(pf_); 569 585 570 586 // --- On remplit avec une realisation 571 587 if(lp_>0) cout<<"...before Fourier realization filling"<<endl; 572 T_(0,0,0) = complex< r_8>(0.); // on coupe le continue et on l'initialise588 T_(0,0,0) = complex<GEN3D_TYPE>(0.); // on coupe le continue et on l'initialise 573 589 long lmod = Nx_/10; if(lmod<1) lmod=1; 574 590 for(long i=0;i<Nx_;i++) { … … 609 625 { 610 626 // --- RaZ du tableau 611 T_ = complex< r_8>(0.);627 T_ = complex<GEN3D_TYPE>(0.); 612 628 613 629 // --- On remplit avec une realisation … … 830 846 831 847 // On fait la FFT 832 fftw_execute(pb_);848 GEN3D_FFTW_EXECUTE(pb_); 833 849 } 834 850 … … 840 856 841 857 // On fait la FFT 842 fftw_execute(pf_);858 GEN3D_FFTW_EXECUTE(pf_); 843 859 // On corrige du pb de la normalisation de FFTW3 844 860 double v = (double)NRtot_;
Note:
See TracChangeset
for help on using the changeset viewer.