aboutsummaryrefslogtreecommitdiff
path: root/src/gr/misc-gr.cc
blob: b17a7e9f8e657a4fcf3f6c39e2b24f9b785133a4 (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
137
138
139
140
141
142
143
144
145
146
147
// misc-gr.cc -- misc support routines
// $Header$
//
// decode_geometry_method - decode the geometry_method parameter
#ifdef NOT_USED
// geomery_method_is_interp - does  enum geometry_method  specify interpolation?
#endif
// decode_geometry_method - decode the geometry_method parameter
// expansion_status_string - string describing expansion_status
//

#include <stdio.h>
#include <assert.h>
#include <math.h>
#include <string.h>

#include "util_Table.h"
#include "cctk.h"
#include "cctk_Arguments.h"

#include "config.h"
#include "stdc.h"
#include "../jtutil/util.hh"
#include "../jtutil/array.hh"
#include "../jtutil/cpm_map.hh"
#include "../jtutil/linear_map.hh"

#include "../patch/coords.hh"
#include "../patch/grid.hh"
#include "../patch/fd_grid.hh"
#include "../patch/patch.hh"
#include "../patch/patch_edge.hh"
#include "../patch/patch_interp.hh"
#include "../patch/ghost_zone.hh"
#include "../patch/patch_system.hh"

#include "../elliptic/Jacobian.hh"

#include "gfns.hh"
#include "gr.hh"

//******************************************************************************

//
// This function decodes the  geometry_method  parameter (string) into
// an internal enum for future use.
//
enum geometry_method
  decode_geometry_method(const char geometry_method_string[])
{
if	(STRING_EQUAL(geometry_method_string,
		      "globally interpolate from Cactus grid"))
   then return geometry__global_interp_from_Cactus_grid;
else if (STRING_EQUAL(geometry_method_string,
		      "locally interpolate from Cactus grid"))
   then return geometry__local_interp_from_Cactus_grid;
else if (STRING_EQUAL(geometry_method_string,
		      "Schwarzschild/EF"))
   then return geometry__Schwarzschild_EF;
else	CCTK_VWarn(FATAL_ERROR, __LINE__, __FILE__, CCTK_THORNSTRING,
"decode_geometry_method(): unknown geometry_method_string=\"%s\"!",
		   geometry_method_string);			/*NOTREACHED*/
}

//******************************************************************************

#ifdef NOT_USED
//
// This function determines whether or not an  enum geometry_method
// value specifies an interpolation.
//
bool geometry_method_is_interp(enum geometry_method geometry_method)
{
switch	(geometry_method)
	{
case geometry__global_interp_from_Cactus_grid:
case geometry__local_interp_from_Cactus_grid:
	return true;
case geometry__Schwarzschild_EF:
	return false;
default:
	CCTK_VWarn(FATAL_ERROR, __LINE__, __FILE__, CCTK_THORNSTRING,
"geometry_method_is_interp(): unknown geometry_method=(int)%d!",
		   geometry_method);				/*NOTREACHED*/
	}
}
#endif

//******************************************************************************

//
// This function decodes the  Jacobian_compute_method  parameter (string) into
// an internal enum for future use.
//
enum Jacobian_compute_method
  decode_Jacobian_compute_method(const char Jacobian_compute_method_string[])
{
if	(STRING_EQUAL(Jacobian_compute_method_string,
		      "numerical perturbation"))
   then return Jacobian__numerical_perturbation;
else if (STRING_EQUAL(Jacobian_compute_method_string,
		      "symbolic differentiation with finite diff d/dr"))
   then return Jacobian__symbolic_diff_with_FD_dr;
else if (STRING_EQUAL(Jacobian_compute_method_string,
		      "symbolic differentiation"))
   then return Jacobian__symbolic_diff;
else	CCTK_VWarn(FATAL_ERROR, __LINE__, __FILE__, CCTK_THORNSTRING,
"\n"
"   decode_Jacobian_compute_method():\n"
"        unknown Jacobian_compute_method_string=\"%s\"!",
		   Jacobian_compute_method_string);		/*NOTREACHED*/
}

//******************************************************************************

//
// This function returns (a pointer to) a C-style string describing
// an  expansion_status  value.
//
const char* expansion_status_string(enum expansion_status status)
{
switch	(status)
	{
case expansion_success:
	return "success";
	break;
case expansion_failure__surface_nonfinite:
	return "infinity/NaN in surface shape!";
	break;
case expansion_failure__surface_outside_grid:
	return "surface outside grid";
	break;
case expansion_failure__surface_in_excised_region:
	return "surface in excised region";
	break;
case expansion_failure__geometry_nonfinite:
	return "infinity/NaN in 3-geometry!";
	break;
case expansion_failure__gij_not_positive_definite:
	return "g_ij not positive definite!";
	break;
default:
	CCTK_VWarn(FATAL_ERROR, __LINE__, __FILE__, CCTK_THORNSTRING,
		   "expansion_status_string(): unknown status=(int)%d!",
		   status);					/*NOTREACHED*/
	}
}