Changeset 3518 in Sophya for trunk/Cosmo
- Timestamp:
- Sep 11, 2008, 12:37:39 PM (17 years ago)
- Location:
- trunk/Cosmo/SimLSS
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Cosmo/SimLSS/Makefile
r3501 r3518 12 12 MYEXTINC = ${EXTLIBDIR}/Include 13 13 #MYLIB = $(SOPHYAEXTSLBLIST) -L$(LIB) -lcmvsimbao -lfftw3 -lm 14 MYLIB = $(SOPHYAEXTSLBLIST) -L$(LIB) -lcmvsimbao -lfftw3_threads -lfftw3 -lm14 MYLIB = $(SOPHYAEXTSLBLIST) -L$(LIB) -lcmvsimbao -lfftw3_threads -lfftw3f_threads -lfftw3 -lfftw3f -lm 15 15 16 16 #-------------------------------------------------------------------------- -
trunk/Cosmo/SimLSS/cmvobserv3d.cc
r3516 r3518 379 379 fluct3d.SetGrowthFactor(growth); 380 380 fluct3d.LosComRedshift(0.001,-1); 381 TArray< complex< r_8> >& pkgen = fluct3d.GetComplexArray();382 TArray< r_8>& rgen = fluct3d.GetRealArray();381 TArray< complex<GEN3D_TYPE> >& pkgen = fluct3d.GetComplexArray(); 382 TArray<GEN3D_TYPE>& rgen = fluct3d.GetRealArray(); 383 383 cout<<endl; fluct3d.Print(); 384 384 cout<<"\nMean number of galaxies per pixel = "<<ngal_by_mpc3*fluct3d.GetDVol()<<endl; -
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_; -
trunk/Cosmo/SimLSS/genefluct3d.h
r3358 r3518 18 18 #include "pkspectrum.h" 19 19 20 #define WITH_FFTW_THREAD 21 //#define GEN3D_FLOAT 22 23 #if defined(GEN3D_FLOAT) 24 #define GEN3D_TYPE r_4 25 #define GEN3D_FFTW_PLAN fftwf_plan 26 #define GEN3D_FFTW_COMPLEX fftwf_complex 27 #else 28 #define GEN3D_TYPE r_8 29 #define GEN3D_FFTW_PLAN fftw_plan 30 #define GEN3D_FFTW_COMPLEX fftw_complex 31 #endif 20 32 21 33 namespace SOPHYA { … … 41 53 long LosComRedshift(double zinc=0.001,long npoints=-1); 42 54 43 TArray< complex< r_8> >& GetComplexArray(void) {return T_;}44 fftw_complex* GetComplexPointer(void) {return fdata_;}45 TArray< r_8>& GetRealArray(void) {return R_;}46 r_8* GetRealPointer(void) {return data_;}55 TArray< complex<GEN3D_TYPE> >& GetComplexArray(void) {return T_;} 56 GEN3D_FFTW_COMPLEX * GetComplexPointer(void) {return fdata_;} 57 TArray<GEN3D_TYPE>& GetRealArray(void) {return R_;} 58 GEN3D_TYPE* GetRealPointer(void) {return data_;} 47 59 48 60 // Pour adressage data_[ip] … … 157 169 158 170 // la gestion de la FFT 159 bool is_set_fft w_plan;160 fftw_planpf_,pb_;171 bool is_set_fft_plan; 172 GEN3D_FFTW_PLAN pf_,pb_; 161 173 unsigned short nthread_; 162 174 int lp_; … … 164 176 // le stockage du Cube de donnees et les pointeurs 165 177 bool array_allocated_; // true if array has been allocated 166 TArray< complex< r_8> > T_;167 fftw_complex*fdata_;168 TArray< r_8> R_;169 double*data_;178 TArray< complex<GEN3D_TYPE> > T_; 179 GEN3D_FFTW_COMPLEX *fdata_; 180 TArray<GEN3D_TYPE> R_; 181 GEN3D_TYPE *data_; 170 182 171 183 // l'observateur
Note:
See TracChangeset
for help on using the changeset viewer.