11#include " fft.h"
2- #include " ../module_base/tool_quit.h"
32namespace ModulePW
43{
54
@@ -136,7 +135,7 @@ void FFT :: initplan()
136135 // 2 D
137136 // ---------------------------------------------------------
138137
139- int nrank[2 ] = {this ->nx ,this ->bigny };
138+ // int nrank[2] = {this->nx,this->bigny};
140139 int *embed = NULL ;
141140 if (this ->gamma_only )
142141 {
@@ -301,80 +300,78 @@ void FFT:: cleanFFT()
301300 return ;
302301}
303302
304- void FFT::executefftw (std::string instr )
303+ void FFT::fftzfor (std::complex < double >* & in, std:: complex < double >* & out )
305304{
306- if (instr == " 1for" )
307- {
308- // for(int i = 0 ; i < this->ns ; ++i)
309- // {
310- // fftw_execute_dft(this->planzfor,(fftw_complex *)&c_gspace[i*nz],(fftw_complex *)&c_gspace[i*nz]);
311- // }
312- fftw_execute_dft (this ->planzfor ,(fftw_complex *)c_gspace,(fftw_complex *)c_gspace);
313- // fftw_execute(this->planzfor);
314- }
315- else if (instr == " 1bac" )
316- {
317- // for(int i = 0 ; i < this->ns ; ++i)
318- // {
319- // fftw_execute_dft(this->planzbac,(fftw_complex *)&c_gspace[i*nz],(fftw_complex *)&c_gspace[i*nz]);
320- // }
321- fftw_execute_dft (this ->planzbac ,(fftw_complex *)c_gspace,(fftw_complex *)c_gspace);
322- // fftw_execute(this->planzbac);
323- }
324- else if (instr == " 2for" )
305+ // for(int i = 0 ; i < this->ns ; ++i)
306+ // {
307+ // fftw_execute_dft(this->planzfor,(fftw_complex *)&in[i*nz],(fftw_complex *)&out[i*nz]);
308+ // }
309+ fftw_execute_dft (this ->planzfor ,(fftw_complex *)in,(fftw_complex *)out);
310+ return ;
311+ }
312+
313+ void FFT::fftzbac (std::complex <double >* & in, std::complex <double >* & out)
314+ {
315+ // for(int i = 0 ; i < this->ns ; ++i)
316+ // {
317+ // fftw_execute_dft(this->planzbac,(fftw_complex *)&c_gspace[i*nz],(fftw_complex *)&c_gspace[i*nz]);
318+ // }
319+ fftw_execute_dft (this ->planzbac ,(fftw_complex *)in, (fftw_complex *)out);
320+ return ;
321+ }
322+
323+ void FFT::fftxyfor (std::complex <double >* & in, std::complex <double >* & out)
324+ {
325+ int npy = this ->nplane * this -> ny;
326+ fftw_execute_dft ( this ->planxfor , (fftw_complex *)in, (fftw_complex *)out);
327+ for (int i=0 ; i<this ->nx ;++i)
325328 {
326- int npy = this ->nplane * this -> ny;
327- fftw_execute_dft ( this ->planxfor , (fftw_complex *)c_rspace, (fftw_complex *)c_rspace);
328- for (int i=0 ; i<this ->nx ;++i)
329- {
330- fftw_execute_dft ( this ->planyfor , (fftw_complex*)&c_rspace[i*npy], (fftw_complex*)&c_rspace[i*npy] );
331- }
332- // fftw_execute(this->plan2for);
329+ fftw_execute_dft ( this ->planyfor , (fftw_complex*)&in[i*npy], (fftw_complex*)&out[i*npy] );
333330 }
334- else if (instr == " 2bac" )
335- {
336- // fftw_execute(this->plan2bac);
337- int npy = this ->nplane * this -> ny;
338-
339- for (int i=0 ; i<this ->nx ;++i)
340- {
341- fftw_execute_dft ( this ->planybac , (fftw_complex*)&c_rspace[i*npy], (fftw_complex*)&c_rspace[i*npy] );
342- }
343- fftw_execute_dft ( this ->planxbac , (fftw_complex *)c_rspace, (fftw_complex *)c_rspace);
331+ return ;
332+ }
333+
334+ void FFT::fftxybac (std::complex <double >* & in, std::complex <double >* & out)
335+ {
336+ int npy = this ->nplane * this -> ny;
344337
345- }
346- else if (instr == " 2r2c" )
338+ for (int i=0 ; i<this ->nx ;++i)
347339 {
348- // fftw_execute(this->plan2r2c);
349- // int npy = this->nplane * this-> ny;
350- int bignpy = this ->nplane * this -> bigny;
351- // int padnpy = this->nplane * this-> ny * 2;
352- for (int i=0 ; i<this ->nx ;++i)
353- {
354- fftw_execute_dft_r2c ( this ->planyr2c , &r_rspace[i*bignpy], (fftw_complex*)&c_rspace[i*bignpy] );
355- // fftw_execute_dft_r2c( this->planyfor, &r_rspace[4*i*padnpy], (fftw_complex*)&c_rspace[i*padnpy] );
356- }
357- fftw_execute_dft ( this ->planxfor , (fftw_complex *)c_rspace, (fftw_complex *)c_rspace);
340+ fftw_execute_dft ( this ->planybac , (fftw_complex*)&in[i*npy], (fftw_complex*)&out[i*npy] );
358341 }
359- else if (instr == " 2c2r" )
342+ fftw_execute_dft ( this ->planxbac , (fftw_complex *)in, (fftw_complex *)out);
343+ return ;
344+ }
345+
346+ void FFT::fftxyr2c (double * &in, std::complex <double >* & out)
347+ {
348+ // int npy = this->nplane * this-> ny;
349+ int bignpy = this ->nplane * this -> bigny;
350+ // int padnpy = this->nplane * this-> ny * 2;
351+ for (int i=0 ; i<this ->nx ;++i)
360352 {
361- // fftw_execute(this->plan2c2r);
362- // int npy = this->nplane * this-> ny;
363- int bignpy = this ->nplane * this -> bigny;
364- // int padnpy = this->nplane * this-> ny * 2;
365- fftw_execute_dft ( this ->planxbac , (fftw_complex *)c_rspace, (fftw_complex *)c_rspace);
366- for (int i=0 ; i<this ->nx ;++i)
367- {
368- fftw_execute_dft_c2r ( this ->planyc2r , (fftw_complex*)&c_rspace[i*bignpy], &r_rspace[i*bignpy] );
369- // fftw_execute_dft_c2r( this->planybac, (fftw_complex*)&c_rspace[i*padnpy], &r_rspace[4*i*padnpy] );
370- }
353+ fftw_execute_dft_r2c ( this ->planyr2c , &in[i*bignpy], (fftw_complex*)&out[i*bignpy] );
354+ // fftw_execute_dft_r2c( this->planyfor, &r_rspace[4*i*padnpy], (fftw_complex*)&c_rspace[i*padnpy] );
371355 }
372- else
356+ fftw_execute_dft ( this ->planxfor , (fftw_complex *)out, (fftw_complex *)out);
357+ return ;
358+ }
359+
360+ void FFT::fftxyc2r (std::complex <double >* & in, double * & out)
361+ {
362+ // int npy = this->nplane * this-> ny;
363+ int bignpy = this ->nplane * this -> bigny;
364+ // int padnpy = this->nplane * this-> ny * 2;
365+ fftw_execute_dft ( this ->planxbac , (fftw_complex *)in, (fftw_complex *)in);
366+ for (int i=0 ; i<this ->nx ;++i)
373367 {
374- ModuleBase::WARNING_QUIT (" FFT" , " Wrong input for excutefftw" );
368+ fftw_execute_dft_c2r ( this ->planyc2r , (fftw_complex*)&in[i*bignpy], &out[i*bignpy] );
369+ // fftw_execute_dft_c2r( this->planybac, (fftw_complex*)&c_rspace[i*padnpy], &r_rspace[4*i*padnpy] );
375370 }
371+ return ;
376372}
377373
374+
378375#ifdef __MIX_PRECISION
379376void executefftwf (std::string instr)
380377{
@@ -390,10 +387,6 @@ void executefftwf(std::string instr)
390387 fftwf_execute (this ->planf2r2c );
391388 else if (instr == " 2c2r" )
392389 fftwf_execute (this ->planf2c2r );
393- else
394- {
395- ModuleBase::WARNING_QUIT (" FFT" , " Wrong input for excutefftwf" );
396- }
397390}
398391#endif
399392}
0 commit comments