7#include "../../FTensor.hpp"
9void initial(
double P1[],
double P2[],
double P3[],
double c[],
const int N)
12 int cc = 7.0 *
N / 8.0 - 1;
13 float s2 = 64.0 * 9.0 / pow(
N / 2.0, 2.0);
15 for(
int i = 0;
i <
N; ++
i)
16 for(
int j = 0;
j <
N; ++
j)
20 P2[
i +
N *
j] = exp(-(pow(
i - cr, 2.0) + pow(
j - cc, 2.0)) * s2);
24 const int blockLeft = 0;
25 const int blockRight = 2 *
N / 5.0;
26 const int blockTop =
N / 3.0;
27 const int blockBottom = 2 *
N / 3.0;
29 for(
int i = blockTop;
i < blockBottom; ++
i)
30 for(
int j = blockLeft;
j < blockRight; ++
j)
33 int channelLeft = 4 *
N / 5.0;
35 int channel1Height = 3 *
N / 8.0;
36 int channel2Height = 5 *
N / 8.0;
37 for(
int i = channelLeft;
i < channelRight; ++
i)
38 for(
int j = channel1Height;
j < channel2Height; ++
j)
42void FTen(
double P1_[],
double P2_[],
double P3_[],
double c_[],
const int N)
50 for(
int j = 0;
j <
N; ++
j)
51 for(
int i = 0;
i <
N; ++
i)
53 if(
i != 0 &&
i !=
N - 1 &&
j != 0 &&
j !=
N - 1)
58 * (dd(P2,
l,
m, d_ijk, d_xyz)(0, 0)
59 + dd(P2,
l,
m, d_ijk, d_xyz)(1, 1));
69void simple(
double P1[],
double P2[],
double P3[],
double c[],
const int N)
71 for(
int j = 1;
j <
N - 1; ++
j)
72 for(
int i = 1;
i <
N - 1; ++
i)
75 P3[
i +
N *
j] = (2 - 4 *
c[
i +
N *
j]) * P2[
i +
N *
j] - P1[
i +
N *
j]
77 * (P2[
i - 1 +
N *
j] + P2[
i + 1 +
N *
j]
78 + P2[
i +
N * (
j - 1)] + P2[
i +
N * (
j + 1)]);
83int main(
int argc,
char *argv[])
85 const int N = atoi(argv[1]);
87 vector<double> P1(
N *
N), P2(
N *
N), P3(
N *
N),
c(
N *
N);
89 initial(&
c[0], &P1[0], &P2[0], &P3[0],
N);
91 const int niters = atoi(argv[2]);
93 for(
int i = 0;
i < niters; ++
i)
98 FTen(&P1[0], &P2[0], &P3[0], &
c[0],
N);
99 FTen(&P2[0], &P3[0], &P1[0], &
c[0],
N);
100 FTen(&P3[0], &P1[0], &P2[0], &
c[0],
N);
void initial(double P1[], double P2[], double P3[], double c[], const int N)
void FTen(double P1_[], double P2_[], double P3_[], double c_[], const int N)
void simple(double P1[], double P2[], double P3[], double c[], const int N)
FTensor::Index< 'i', SPACE_DIM > i
const double c
speed of light (cm/ns)
FTensor::Index< 'l', 3 > l
FTensor::Index< 'j', 3 > j
FTensor::Index< 'm', 3 > m