aboutsummaryrefslogtreecommitdiff
path: root/src/Schwarzschild.c
blob: d459542c066abe81f506033e283567980475d3ae (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
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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
 /*@@
   @file      Schwarzschild.c
   @date      Sun Oct 17 10:35:41 1999
   @author    Tom Goodale
   @desc
              C version of Scwhwarzschild lapse routine
   @enddesc
   @version   $Id$
 @@*/

#include <string.h>

#include "cctk.h"
#include "cctk_Arguments.h"
#include "cctk_Parameters.h"

#include "IDAnalyticBH.h"

static const char *rcsid = "$Header$";
CCTK_FILEVERSION(CactusEinstein_IDAnalyticBH_Schwarzschild_c)


void Schwarzschild(CCTK_ARGUMENTS)
{
  DECLARE_CCTK_ARGUMENTS
  DECLARE_CCTK_PARAMETERS

  const CCTK_REAL zero = 0.0, one = 1.0, two = 2.0, three = 3.0;
  CCTK_REAL tmp, r_squared, r_cubed;
  int make_conformal_derivs = 0;
  int i, npoints;

  CCTK_VInfo(CCTK_THORNSTRING,
             "setting up Schwarzschild initial");

  /* Check if we should create and store conformal factor stuff */
  if(CCTK_EQUALS(metric_type, "static conformal"))
  {
    if      (CCTK_EQUALS(conformal_storage,"factor"))
    {
      *conformal_state = 1;
      make_conformal_derivs = 0;
    }
    else if (CCTK_EQUALS(conformal_storage,"factor+derivs"))
    {
      *conformal_state = 2;
      make_conformal_derivs = 1;
    }
    else if (CCTK_EQUALS(conformal_storage,"factor+derivs+2nd derivs"))
    {
      *conformal_state = 3;
      make_conformal_derivs = 1;
    }
    else
    {
      CCTK_VWarn(0, __LINE__, __FILE__, CCTK_THORNSTRING,
"Schwarzschild(): impossible value for conformal_storage=\"%s\"!",
		 conformal_storage);				/*NOTREACHED*/
    }
  }      


  npoints = cctk_lsh[0] * cctk_lsh[1] * cctk_lsh[2];

  if(CCTK_EQUALS(metric_type, "static conformal"))
  {
    for (i = 0; i < npoints; i++)
    {
      /*        Compute conformal factor */
      psi[i] = ( one + mass/two/r[i]);

      if(make_conformal_derivs)
      {
        /*        derivatives of psi / psi */
        r_squared = r[i]*r[i];
        r_cubed   = r[i]*r_squared;
        tmp = mass/two/r_cubed/psi[i];


        psix[i] = -x[i]*tmp;
        psiy[i] = -y[i]*tmp;
        psiz[i] = -z[i]*tmp;

        if(*conformal_state > 2)
        {
          tmp = mass/two/(r_squared*r_cubed)/psi[i];
          psixy[i] = three*x[i]*y[i]*tmp;
          psixz[i] = three*x[i]*z[i]*tmp;
          psiyz[i] = three*y[i]*z[i]*tmp;
      
          psixx[i]  = (three*x[i]*x[i] - r_squared)*tmp;
          psiyy[i]  = (three*y[i]*y[i] - r_squared)*tmp;
          psizz[i]  = (three*z[i]*z[i] - r_squared)*tmp;
        }
      }
      gxx[i] = one;
      gyy[i] = one;
      gzz[i] = one;
      gxy[i] = zero;
      gxz[i] = zero;
      gyz[i] = zero;
    }
  }
  else
  {
    for (i = 0; i < npoints; i++)
    {
      tmp = one + mass/two/r[i];
      gxx[i] = tmp*tmp*tmp*tmp;
      gyy[i] = gxx[i];
      gzz[i] = gxx[i];
      gxy[i] = zero;
      gxz[i] = zero;
      gyz[i] = zero;
    }
  }
  
  /*     If the initial lapse is not one ... */
  if (CCTK_Equals(initial_lapse,"schwarz"))
  {
    CCTK_INFO("Initialise with Schwarzschild lapse");

    for (i = 0; i < npoints; i++)
    {
      alp[i] = (2.*r[i] - mass)/(2.*r[i]+mass);
    }
  }

  /*     time symmetric initial slice */
  IDAnalyticBH_zero_CCTK_REAL_array(npoints, kxx);
  IDAnalyticBH_zero_CCTK_REAL_array(npoints, kxy);
  IDAnalyticBH_zero_CCTK_REAL_array(npoints, kxz);
  IDAnalyticBH_zero_CCTK_REAL_array(npoints, kyy);
  IDAnalyticBH_zero_CCTK_REAL_array(npoints, kyz);
  IDAnalyticBH_zero_CCTK_REAL_array(npoints, kzz);
}