16#include <forcage_spectral.h>
38double my_function_d_2(
const int i,
const int j,
const int k)
48 const ptrdiff_t L = 7, M = 8, N = 9;
52 ptrdiff_t alloc_local, local_n0, local_0_start;
58 alloc_local = fftw_mpi_local_size_3d(L, M, N/2+1, MPI_COMM_WORLD,
59 &local_n0, &local_0_start);
60 rin = fftw_alloc_real(2 * alloc_local);
62 c_out = fftw_alloc_complex(alloc_local);
67 plan = fftw_mpi_plan_dft_r2c_3d(L, M, N, rin, c_out, MPI_COMM_WORLD,
77 for (i = 0; i < local_n0; ++i)
80 for (j = 0; j < M; ++j)
83 for (k = 0; k < N; ++k)
88 rin[(i*M + j) * (2*(N/2+1)) + k]= my_function_d_2((
int)local_0_start+i, j, k);
99 fftw_destroy_plan(plan);
103 const double kmin,
const double kmax)
110static int myPow(
int x,
unsigned int p)
112 if (p == 0)
return 1;
113 if (p == 1)
return x;
115 int tmp = myPow(x, p/2);
116 if (p%2 == 0)
return tmp * tmp;
117 else return x * tmp * tmp;
123 nk_tot = myPow(nk,3)-1;
124 kx.resize_array(nk_tot);
125 ky.resize_array(nk_tot);
126 kz.resize_array(nk_tot);
133 ind = i*nk*nk+j*nk+k;
134 kx[ind] = k_min + i*(k_max/nk);
135 ky[ind] = k_min + j*(k_max/nk);
136 kz[ind] = k_min + k*(k_max/nk);
144 const double pi(3.14159265358979);
146 nk_tot = myPow(nk,3)-1;
147 fx.resize_array(nk_tot);
148 fy.resize_array(nk_tot);
149 fz.resize_array(nk_tot);
156 ind = i*nk*nk+j*nk+k;
157 fx[ind] = cos(2*pi*kx[ind]);
158 fy[ind] = cos(2*pi*ky[ind]);
159 fz[ind] = cos(2*pi*kz[ind]);
169void Create_file(std::string
const& fichname, std::string
const& name)
172 std::ofstream myFlux(fichname.c_str());
175 myFlux <<
"----------- " << name <<
" --------" << endl;
179void Add_in_file(std::string
const& fichname, std::string
const& information)
182 std::ofstream myFlux(fichname.c_str(), ios::app);
185 myFlux << information << endl;
188void Add_in_file(std::string
const& fichname,
int const information)
191 std::ofstream myFlux(fichname.c_str(), ios::app);
194 myFlux << information << endl;
197void Add_in_file(std::string
const& fichname, std::string
const& info,
int const information)
200 std::ofstream myFlux(fichname.c_str(), ios::app);
203 myFlux << info <<
" : "<<information << endl;
211std::string fftw_org_unidentified_function()
213 const ptrdiff_t N0 = 2, N1 = 5;
216 ptrdiff_t alloc_local, local_n0, local_0_start;
229 alloc_local = fftw_mpi_local_size_2d(N0, N1, MPI_COMM_WORLD,
230 &local_n0, &local_0_start);
231 data = fftw_alloc_complex(alloc_local);
234 plan = fftw_mpi_plan_dft_2d(N0, N1, data, data, MPI_COMM_WORLD,
235 FFTW_FORWARD, FFTW_ESTIMATE);
249 fftw_destroy_plan(plan);
251 std::string msg(
"MPI unditentified");
255double my_function_d(
const int i,
const int j)
261std::string fftw_org_real_data_MPI_transform()
263 const ptrdiff_t L = 6, M = 9;
266 ptrdiff_t alloc_local, local_n0, local_0_start;
271 alloc_local = fftw_mpi_local_size_2d(L, M, MPI_COMM_WORLD,
272 &local_n0, &local_0_start);
273 data = fftw_alloc_real(alloc_local);
276 plan = fftw_mpi_plan_r2r_2d(L, M, data, data, MPI_COMM_WORLD,
277 FFTW_REDFT10, FFTW_RODFT10, FFTW_MEASURE);
280 for (i = 0; i < local_n0; ++i)
281 for (j = 0; j < M; ++j)
282 data[i*M + j] = my_function_d((
int)local_0_start + i, j);
287 fftw_destroy_plan(plan);
289 std::string msg(
"MPI r2r_2d");
Class defining operators and methods for all reading operation in an input flow (file,...
classe Objet_U Cette classe est la classe de base des Objets de TRUST
virtual Entree & readOn(Entree &)
Lecture d'un Objet_U sur un flot d'entree Methode a surcharger.
virtual Sortie & printOn(Sortie &) const
Ecriture de l'objet sur un flot de sortie Methode a surcharger.
Classe de base des flux de sortie.
void fftw_org_multi_D_MPI_DFT_real_data()
void set_spectral_domain()
void set_nk_kmin_kmax(const int number_k, const double kmin, const double kmax)