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
|
static const int nx = 16;
static const int ny = 16;
static const int nz = 16;
double Lx = 128;
double Ly = 128;
double LZ = 128;
double dx = Lx / nx;
double dy = Ly / ny;
double dz = Lz / nz;
double A = (2 * EIGEN_PI)/Lx;
double A1 = (2 * EIGEN_PI)/ Ly;
Eigen::Tensor<double, 3> eXX(nx,ny,nz);
eXX.setZero();
Eigen::Tensor<double, 3> eYY(nx,ny,nz);
eYY.setZero();
Eigen::Tensor<double, 3> eZZ(nx,ny,nz);
eZZ.setZero();
for(int i = 0; i< nx; i++){
for(int j = 0; j< ny; j++){
for(int k = 0; k< nz; k++){
eXX(k,i,j) = i*dx;
eYY(j,i,k) = j*dy;//eYY(k,i,j) = j*dy;
eZZ(j,i,k) = k*dz; //eZZ(k,i,j) = k*dz;
}
}
}
Eigen::Tensor<double, 3> uFun(nx,ny,nz);
uFun.setZero();
for(int i = 0; i< nx; i++){
for(int j = 0; j< ny; j++){
for(int k = 0; k< nz; k++){
uFun(k,i,j) = sin(3. * A * eZZ(k,i,j)) * sin(A * eXX(k,i,j)) * cos(A1 * eYY(k,i,j));
}
}
}
std::ofstream file("test.txt");
if (file.is_open())
{
file << uFun << '\n';
}
| |