aboutsummaryrefslogtreecommitdiff
path: root/src/InitialData.cc
blob: c8d790d78521e4b51b68c6a0d1b74fe4e89aae26 (plain)
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
 /*@@
   @file      InitialData.cc
   @date      
   @author    Werner Benger   
   @desc 
              Initial data for the 3D Wave Equation
	      Derived from Tom Goodale
   @enddesc 
 @@*/

#include "cctk.h" 
#include "cctk_Flesh.h"
#include "cctk_parameters.h"
#include "cctk_Groups.h"
#include "cctk_arguments.h"
#include "cctk_Comm.h"

#include "CactusBase/CartGrid3D/src/Symmetry.h"

#include <math.h>

inline double sqr(double val)
{
	return val*val;
}


 /*@@
   @routine    IDScalarWave_InitialData
   @date       
   @author     Tom Goodale
   @desc 
               Set up initial data for the wave equation
   @enddesc 
   @calls      
   @calledby   
   @history 
 
   @endhistory 

@@*/

extern "C" void IDScalarWaveCXX_InitialData(CCTK_CARGUMENTS)
{
      	DECLARE_CCTK_CARGUMENTS
      	DECLARE_CCTK_PARAMETERS

	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);

	double	X = x[index], Y = y[index], Z = z[index];
	double	R = sqrt(X*X + Y*Y + Z*Z);

		phi_old[index] = phi[index] = 
				 amplitude*exp( - sqr( (R - radius) / sigma ) );
	} 

	  //
	  //    Apply symmetry boundary conditions 
	  // 
	ApplySymmetry(cctkGH,"wavetoy::scalarevolve"); 

	  // 
	  //	Synchronise 
	  // 
	CCTK_SyncGroup(cctkGH,"wavetoy::scalarevolve"); 

	return;
}