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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
|
/*@@
@file InitialData.cc
@date
@author Werner Benger
@desc
Initial data for the 3D Wave Equation
Derived from Tom Goodale
@enddesc
@@*/
#include <math.h>
#include "cctk.h"
#include "cctk_Parameters.h"
#include "cctk_Arguments.h"
static char *rcsid = "$Header$";
inline CCTK_REAL sqr(CCTK_REAL val)
{
return val*val;
}
/*@@
@routine IDScalarWave_InitialData
@date
@author Tom Goodale
@desc
Set up initial data for the wave equation
@enddesc
@calls
@calledby
@history
@hdate Mon Oct 11 11:48:03 1999 @hauthor Werner Benger
@hdesc Converted to C++
@hdate Mon Oct 11 11:48:20 1999 @hauthor Tom Goodale
@hdesc Added the rest of the initial data.
@endhistory
@@*/
extern "C" void IDScalarWaveCXX_InitialData(CCTK_ARGUMENTS)
{
DECLARE_CCTK_ARGUMENTS
DECLARE_CCTK_PARAMETERS
CCTK_REAL dt = CCTK_DELTA_TIME;
if(CCTK_Equals(initial_data, "plane"))
{
CCTK_REAL omega = sqrt(sqr(kx)+sqr(ky)+sqr(kz));
for(int k=0; k<cctk_lsh[2]; k++)
{
for(int j=0; j<cctk_lsh[1]; j++)
{
for(int i=0; i<cctk_lsh[0]; i++)
{
int index = CCTK_GFINDEX3D(cctkGH,i,j,k);
phi[index] = amplitude*cos(kx*x[index]+ky*y[index]+kz*z[index]+omega*cctk_time);
phi_old[index] = amplitude*cos(kx*x[index]+ky*y[index]+kz*z[index]+omega*(cctk_time-dt));
}
}
}
}
else if(CCTK_Equals(initial_data, "gaussian"))
{
for(int k=0; k<cctk_lsh[2]; k++)
{
for(int j=0; j<cctk_lsh[1]; j++)
{
for(int i=0; i<cctk_lsh[0]; i++)
{
int index = CCTK_GFINDEX3D(cctkGH,i,j,k);
CCTK_REAL X = x[index], Y = y[index], Z = z[index];
CCTK_REAL R = sqrt(X*X + Y*Y + Z*Z);
phi[index] = amplitude*exp( - sqr( (R - radius) / sigma ) );
phi_old[index] = amplitude*exp( - sqr( (R - radius - dt) / sigma ) );
}
}
}
}
else if(CCTK_Equals(initial_data, "box"))
{
CCTK_REAL pi = 4.0*atan(1.0);
CCTK_REAL omega = sqrt(sqr(kx)+sqr(ky)+sqr(kz));
for(int k=0; k<cctk_lsh[2]; k++)
{
for(int j=0; j<cctk_lsh[1]; j++)
{
for(int i=0; i<cctk_lsh[0]; i++)
{
int index = CCTK_GFINDEX3D(cctkGH,i,j,k);
phi[index] = amplitude*sin(kx*(x[index]-0.5)*pi)*
sin(ky*(y[index]-0.5)*pi)*
sin(kz*(z[index]-0.5)*pi)*
cos(omega*cctk_time*pi);
phi_old[index] = amplitude*sin(kx*(x[index]-0.5)*pi)*
sin(ky*(y[index]-0.5)*pi)*
sin(kz*(z[index]-0.5)*pi)*
cos(omega*(cctk_time-dt)*pi);
}
}
}
}
return;
}
|