1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
|
#define _USE_MATH_DEFINES
#include <cmath>
#include<math.h>
#include<stdio.h>
#include "fftw3.h"
#include <cstring>
#include <sstream>
#include <string>
#include <sys/resource.h>
#include <iostream>
#include <vector>
#include <fstream>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <Eigen/Dense>
#include <unsupported/Eigen/FFT>
#include <Eigen/SparseCore>
#include <Eigen/Sparse>
using namespace std;
using namespace Eigen;
int main(){
static const int nx = 10;
static const int ny = 10;
static const int nyk = ny/2 + 1;
static const int ncomp = 2;
double Lx = 2*EIGEN_PI;
double A = (2 * EIGEN_PI)/Lx;
Matrix <double, ny+1, nx> eYY;
eYY.setZero();
Matrix <double, ny+1, nx> eXX;
eXX.setZero();
Eigen::Matrix< double, (ny+1), (ny)> u;
u.setZero();
for(int i = 0; i< nx; i++){
for(int j = 0; j< ny+1; j++){
eXX(j + (ny+1)*i) = (i)*2*EIGEN_PI/nx;
eYY(j + (ny+1)*i) = -1. * cos(((j) * EIGEN_PI )/ny);
u(j + (ny+1)*i) = pow((eYY(j + (ny+1)*i)-0.5),2) * sin(A * eXX(j + (ny+1)*i)); //test function:u
}
}
fftw_complex *uhk;
uhk = (fftw_complex*) fftw_malloc(((ny*(ny+1)))* sizeof(fftw_complex));
memset(uhk, 42, ((ny*(ny+1)))* sizeof(fftw_complex));
Eigen::MatrixXcd uh;
uh.setZero((ny+1), (ny));
fftw_complex *uhkOut;
uhkOut = (fftw_complex*) fftw_malloc(((ny*(ny+1)))* sizeof(fftw_complex));
memset(uhkOut, 42, ((ny*(ny+1)))* sizeof(fftw_complex));
fftw_plan r2c;
r2c = fftw_plan_dft_r2c_2d(ny, (ny+1), &uhk[0], &uhkOut[0], FFTW_ESTIMATE);
fftw_execute(r2c);
fftw_destroy_plan(r2c);
fftw_cleanup();
}
|