#include <cmath>
#include <cstdlib>
#include <iostream>
#include <vector>
#include "../../FTensor.hpp"
Go to the source code of this file.
|
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) |
|
int | main (int argc, char *argv[]) |
|
◆ FTen()
Definition at line 42 of file acoustic.cpp.
43{
45
50 for(
int j = 0;
j <
N; ++
j)
51 for(
int i = 0;
i <
N; ++
i)
52 {
53 if(
i != 0 &&
i !=
N - 1 &&
j != 0 &&
j !=
N - 1)
54 {
55
56 P3 = 2 * P2 - P1
58 * (
dd(P2,
l,
m, d_ijk, d_xyz)(0, 0)
59 +
dd(P2,
l,
m, d_ijk, d_xyz)(1, 1));
60 }
61 ++P1;
62 ++P2;
63 ++P3;
65 }
66
67}
FTensor::Index< 'm', SPACE_DIM > m
FTensor::Index< 'i', SPACE_DIM > i
const double c
speed of light (cm/ns)
FTensor::Index< 'l', 3 > l
FTensor::Index< 'j', 3 > j
const Tensor2_symmetric_Expr< const ddTensor0< T, Dim, i, j >, typename promote< T, double >::V, Dim, i, j > dd(const Tensor0< T * > &a, const Index< i, Dim > index1, const Index< j, Dim > index2, const Tensor1< int, Dim > &d_ijk, const Tensor1< double, Dim > &d_xyz)
◆ initial()
Definition at line 9 of file acoustic.cpp.
10{
12 int cc = 7.0 *
N / 8.0 - 1;
13 float s2 = 64.0 * 9.0 / pow(
N / 2.0, 2.0);
14
15 for(
int i = 0;
i <
N; ++
i)
16 for(
int j = 0;
j <
N; ++
j)
17 {
20 P2[
i +
N *
j] = exp(-(pow(
i - cr, 2.0) + pow(
j - cc, 2.0)) * s2);
22 }
23
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;
28
29 for(
int i = blockTop;
i < blockBottom; ++
i)
30 for(
int j = blockLeft;
j < blockRight; ++
j)
32
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)
40}
◆ main()
int main |
( |
int |
argc, |
|
|
char * |
argv[] |
|
) |
| |
Definition at line 83 of file acoustic.cpp.
84{
85 const int N = atoi(argv[1]);
86
87 vector<double> P1(
N *
N), P2(
N *
N), P3(
N *
N),
c(
N *
N);
88
89 initial(&
c[0], &P1[0], &P2[0], &P3[0],
N);
90
91 const int niters = atoi(argv[2]);
92
93 for(
int i = 0;
i < niters; ++
i)
94 {
95
96
97
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);
101 }
102}
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)
◆ simple()
Definition at line 69 of file acoustic.cpp.
70{
71 for(
int j = 1;
j <
N - 1; ++
j)
72 for(
int i = 1;
i <
N - 1; ++
i)
73 {
74
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)]);
79 }
80
81}