aboutsummaryrefslogtreecommitdiff
path: root/src/gr/horizon_function.cc
blob: 82f5f319550af26544f26bb29d6b4ac42f4a7199 (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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
// horizon_function.cc -- evaluate LHS function H(h)
// $Id$
//
// <<<prototypes for functions local to this file>>>
// horizon_function - top-level driver
/// setup_xyz_posns - setup global xyz posns of grid points
/// interpolate_geometry - interpolate $g_{ij}$, $K_{ij}$ from Cactus 3-D grid
/// compute_H - compute H(h) given earlier setup
//

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

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

#include "stdc.h"
#include "config.hh"
#include "../jtutil/util.hh"
#include "../jtutil/array.hh"
#include "../jtutil/cpm_map.hh"
#include "../jtutil/linear_map.hh"
using jtutil::error_exit;

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

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

#include "gfn.hh"
#include "AHFinderDirect.hh"

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

//
// ***** prototypes for functions local to this file *****
//

namespace {
void setup_xyz_posns(patch_system& ps);
void interpolate_geometry(patch_system& ps,
			  const struct cactus_grid_info& cgi,
			  const struct geometry_interpolator_info& ii);
void compute_H(patch_system& ps, bool Jacobian_flag);
	  }

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

//
// This function computes the LHS function H(h), and optionally also
// its Jacobian coefficients (from which the Jacobian matrix may be
// computed later).
//
// Inputs (angular gridfns, on ghosted grid):
// ... defined on ghosted grid
// ... only values on nominal grid are actually used as input
//	h				# shape of trial surface
//
// Inputs (Cactus 3-D gridfns):
//	gxx,gxy,gxz,gyy,gyz,gzz		# 3-metric $g_{ij}$
//	kxx,kxy,kxz,kyy,kyz,kzz		# extrinsic curvature $K_{ij}$
//
// Outputs (temporaries computed at each grid point)
//	## computed by hand-written code
//	xx,yy,zz			# xyz positions of grid points
//	X_ud_*, X_udd_*			# xyz derivative coefficients
//	## computed by Maple-generated code
//	g_uu_{11,12,13,22,23,33}	# $g^{ij}$
//	K				# $K$
//	K_dd_{11,12,13,22,23,33}	# $K^{ij}$
//	partial_d_ln_sqrt_g_d		# $\partial_i \ln \sqrt{g}$
//	partial_d_g_uu_{1,2,3}{11,12,13,22,23,33}	# $\partial_k g^{ij}$
//
// Outputs (angular gridfns, all on the nominal grid):
//	## interpolated from 3-D Cactus grid
//	g_dd_{11,12,13,22,23,33}			# $g_{ij}$
//	K_dd_{11,12,13,22,23,33}			# $K_{ij}$
//	partial_d_g_dd_{1,2,3}{11,12,13,22,23,33}	# $\partial_k g_{ij}$
//	H				# $H = H(h)$
//
// Arguments:
// Jacobian_flag = true to compute the Jacobian coefficients,
//		   false to skip this.
//
void horizon_function(patch_system& ps,
		      const struct cactus_grid_info& cgi,
		      const struct geometry_interpolator_info& ii,
		      bool Jacobian_flag)
{
CCTK_VInfo(CCTK_THORNSTRING, "   horizon function");

// fill in values of all ghosted gridfns in ghost zones
ps.synchronize();

// set up xyz positions of grid points
setup_xyz_posns(ps);

// interpolate $g_{ij}$, $K_{ij}$ --> $g_{ij}$, $K_{ij}$, $\partial_k g_{ij}$
interpolate_geometry(ps, cgi, ii);

// compute remaining gridfns --> $H$ and optionally Jacobian coefficients
// by algebraic ops and angular finite differencing
compute_H(ps, Jacobian_flag);
}

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

//
// This function sets up the global xyz positions of the grid points
// in the gridfns global_[xyz].  These will be used by interplate_geometry().
//
namespace {
void setup_xyz_posns(patch_system& ps)
{
CCTK_VInfo(CCTK_THORNSTRING, "      xyz positions and derivative coefficients");

	for (int pn = 0 ; pn < ps.N_patches() ; ++pn)
	{
	patch& p = ps.ith_patch(pn);

		for (int irho = p.min_irho() ; irho <= p.max_irho() ; ++irho)
		{
		for (int isigma = p.min_isigma() ;
		     isigma <= p.max_isigma() ;
		     ++isigma)
		{
		const fp r = p.ghosted_gridfn(ghosted_gfns::gfn__h,
					      irho,isigma);
		const fp rho = p.rho_of_irho(irho);
		const fp sigma = p.sigma_of_isigma(isigma);
		fp local_x, local_y, local_z;
		p.xyz_of_r_rho_sigma(r,rho,sigma, local_x,local_y,local_z);
		const fp global_x = ps.global_x_of_local_x(local_x);
		const fp global_y = ps.global_y_of_local_y(local_y);
		const fp global_z = ps.global_z_of_local_z(local_z);

		p.gridfn(nominal_gfns::gfn__global_x, irho,isigma) = global_x;
		p.gridfn(nominal_gfns::gfn__global_y, irho,isigma) = global_y;
		p.gridfn(nominal_gfns::gfn__global_z, irho,isigma) = global_z;
		}
		}
	}
}
	  }

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

//
// This function interpolates the Cactus $g_{ij}$ and $K_{ij}$, and
// the spatial derivatives $\partial_k g_{ij}$, to the trial horizon
// surface position given by h.
//
// Inputs (angular gridfns, on ghosted grid):
// ... defined on ghosted grid
// ... only values on nominal grid are actually used as input
//	h				# shape of trial surface
//
// Inputs (angular gridfns, all on the nominal grid):
//	xx,yy,zz			# xyz positions of grid points
//
// Inputs (Cactus 3-D gridfns):
//	gxx,gxy,gxz,gyy,gyz,gzz		# 3-metric $g_{ij}$
//	kxx,kxy,kxz,kyy,kyz,kzz		# extrinsic curvature $K_{ij}$
//
// Inputs (angular gridfns, all on the nominal grid):
//	## computed directly from h
//	xx,yy,zz			# xyz positions
//
// Outputs (angular gridfns, all on the nominal grid):
//	g_dd_{11,12,13,22,23,33}			# $g_{ij}$
//	K_dd_{11,12,13,22,23,33}			# $K_{ij}$
//	partial_d_g_dd_{1,2,3}{11,12,13,22,23,33}	# $\partial_k g_{ij}$
//
// On the first call this function also modifies the interpolator
// parameter table.
//
namespace {
void interpolate_geometry(patch_system& ps,
			  const struct cactus_grid_info& cgi,
			  const struct geometry_interpolator_info& gii)
{
CCTK_VInfo(CCTK_THORNSTRING,
	   "      interpolate $g_{ij}$, $K_{ij}$ from Cactus 3-D grid");

int status;

const int N_interp_points = ps.N_grid_points();
const int interp_coords_type_code = CCTK_VARIABLE_REAL;
const void* const interp_coords[N_GRID_DIMS]
  = {
    static_cast<const void*>(ps.gridfn_data(nominal_gfns::gfn__global_x)),
    static_cast<const void*>(ps.gridfn_data(nominal_gfns::gfn__global_y)),
    static_cast<const void*>(ps.gridfn_data(nominal_gfns::gfn__global_z)),
    };

const int N_INPUT_ARRAYS = 12;
const CCTK_INT input_array_type_codes[N_INPUT_ARRAYS]
	= {
	  // $g_{ij}$
	  CCTK_VARIABLE_REAL, CCTK_VARIABLE_REAL, CCTK_VARIABLE_REAL,
			      CCTK_VARIABLE_REAL, CCTK_VARIABLE_REAL,
						  CCTK_VARIABLE_REAL,
	    // $K_{ij}$
	  CCTK_VARIABLE_REAL, CCTK_VARIABLE_REAL, CCTK_VARIABLE_REAL,
			      CCTK_VARIABLE_REAL, CCTK_VARIABLE_REAL,
						  CCTK_VARIABLE_REAL,
	  };
const void* const input_arrays[N_INPUT_ARRAYS]
	= {
	  static_cast<const void*>(cgi.g_dd_11_data),
	  static_cast<const void*>(cgi.g_dd_12_data),
	  static_cast<const void*>(cgi.g_dd_13_data),
	  static_cast<const void*>(cgi.g_dd_22_data),
	  static_cast<const void*>(cgi.g_dd_23_data),
	  static_cast<const void*>(cgi.g_dd_33_data),
	  static_cast<const void*>(cgi.K_dd_11_data),
	  static_cast<const void*>(cgi.K_dd_12_data),
	  static_cast<const void*>(cgi.K_dd_13_data),
	  static_cast<const void*>(cgi.K_dd_22_data),
	  static_cast<const void*>(cgi.K_dd_23_data),
	  static_cast<const void*>(cgi.K_dd_33_data),
	  };

const int N_OUTPUT_ARRAYS = 30;

const CCTK_INT output_array_type_codes[N_OUTPUT_ARRAYS]
	= {
 // $g_{ij}$         $\partial_x g_{ij}$ $\partial_y g_{ij}$ $\partial_z g_{ij}$
 CCTK_VARIABLE_REAL, CCTK_VARIABLE_REAL, CCTK_VARIABLE_REAL, CCTK_VARIABLE_REAL,
 CCTK_VARIABLE_REAL, CCTK_VARIABLE_REAL, CCTK_VARIABLE_REAL, CCTK_VARIABLE_REAL,
 CCTK_VARIABLE_REAL, CCTK_VARIABLE_REAL, CCTK_VARIABLE_REAL, CCTK_VARIABLE_REAL,
 CCTK_VARIABLE_REAL, CCTK_VARIABLE_REAL, CCTK_VARIABLE_REAL, CCTK_VARIABLE_REAL,
 CCTK_VARIABLE_REAL, CCTK_VARIABLE_REAL, CCTK_VARIABLE_REAL, CCTK_VARIABLE_REAL,
 CCTK_VARIABLE_REAL, CCTK_VARIABLE_REAL, CCTK_VARIABLE_REAL, CCTK_VARIABLE_REAL,
 // $K_{ij}$
 CCTK_VARIABLE_REAL, CCTK_VARIABLE_REAL, CCTK_VARIABLE_REAL,
		     CCTK_VARIABLE_REAL, CCTK_VARIABLE_REAL,
					 CCTK_VARIABLE_REAL,
	  };
const CCTK_INT operand_indices[N_OUTPUT_ARRAYS]
	= {
	  0, 0, 0, 0,		// g_dd_11
	  1, 1, 1, 1,		// g_dd_12
	  2, 2, 2, 2,		// g_dd_13
	  3, 3, 3, 3,		// g_dd_22
	  4, 4, 4, 4,		// g_dd_23
	  5, 5, 5, 5,		// g_dd_33
	   6,  7,  8,		// K_dd_{11,12,13}
	       9, 10,		// K_dd_{22,23}
		  11,		// K_dd_33
	  };
#define DERIV(x)	x
const CCTK_INT operation_codes[N_OUTPUT_ARRAYS]
	= {
	  DERIV(0), DERIV(1), DERIV(2), DERIV(3),	// g_dd_11
	  DERIV(0), DERIV(1), DERIV(2), DERIV(3),	// g_dd_12
	  DERIV(0), DERIV(1), DERIV(2), DERIV(3),	// g_dd_13
	  DERIV(0), DERIV(1), DERIV(2), DERIV(3),	// g_dd_22
	  DERIV(0), DERIV(1), DERIV(2), DERIV(3),	// g_dd_23
	  DERIV(0), DERIV(1), DERIV(2), DERIV(3),	// g_dd_33
	  DERIV(0), DERIV(0), DERIV(0),			// K_dd_{11,12,13}
		    DERIV(0), DERIV(0),			// K_dd_{22,23}
			      DERIV(0),			// K_dd_{33}
	  };
void* const output_arrays[N_OUTPUT_ARRAYS]
  = {
    static_cast<void*>(ps.gridfn_data(nominal_gfns::gfn__g_dd_11)),
    static_cast<void*>(ps.gridfn_data(nominal_gfns::gfn__partial_d_g_dd_111)),
    static_cast<void*>(ps.gridfn_data(nominal_gfns::gfn__partial_d_g_dd_211)),
    static_cast<void*>(ps.gridfn_data(nominal_gfns::gfn__partial_d_g_dd_311)),
    static_cast<void*>(ps.gridfn_data(nominal_gfns::gfn__g_dd_12)),
    static_cast<void*>(ps.gridfn_data(nominal_gfns::gfn__partial_d_g_dd_112)),
    static_cast<void*>(ps.gridfn_data(nominal_gfns::gfn__partial_d_g_dd_212)),
    static_cast<void*>(ps.gridfn_data(nominal_gfns::gfn__partial_d_g_dd_312)),
    static_cast<void*>(ps.gridfn_data(nominal_gfns::gfn__g_dd_13)),
    static_cast<void*>(ps.gridfn_data(nominal_gfns::gfn__partial_d_g_dd_113)),
    static_cast<void*>(ps.gridfn_data(nominal_gfns::gfn__partial_d_g_dd_213)),
    static_cast<void*>(ps.gridfn_data(nominal_gfns::gfn__partial_d_g_dd_313)),
    static_cast<void*>(ps.gridfn_data(nominal_gfns::gfn__g_dd_22)),
    static_cast<void*>(ps.gridfn_data(nominal_gfns::gfn__partial_d_g_dd_122)),
    static_cast<void*>(ps.gridfn_data(nominal_gfns::gfn__partial_d_g_dd_222)),
    static_cast<void*>(ps.gridfn_data(nominal_gfns::gfn__partial_d_g_dd_322)),
    static_cast<void*>(ps.gridfn_data(nominal_gfns::gfn__g_dd_23)),
    static_cast<void*>(ps.gridfn_data(nominal_gfns::gfn__partial_d_g_dd_123)),
    static_cast<void*>(ps.gridfn_data(nominal_gfns::gfn__partial_d_g_dd_223)),
    static_cast<void*>(ps.gridfn_data(nominal_gfns::gfn__partial_d_g_dd_323)),
    static_cast<void*>(ps.gridfn_data(nominal_gfns::gfn__g_dd_33)),
    static_cast<void*>(ps.gridfn_data(nominal_gfns::gfn__partial_d_g_dd_133)),
    static_cast<void*>(ps.gridfn_data(nominal_gfns::gfn__partial_d_g_dd_233)),
    static_cast<void*>(ps.gridfn_data(nominal_gfns::gfn__partial_d_g_dd_333)),
    static_cast<void*>(ps.gridfn_data(nominal_gfns::gfn__K_dd_11)),
    static_cast<void*>(ps.gridfn_data(nominal_gfns::gfn__K_dd_12)),
    static_cast<void*>(ps.gridfn_data(nominal_gfns::gfn__K_dd_13)),
    static_cast<void*>(ps.gridfn_data(nominal_gfns::gfn__K_dd_22)),
    static_cast<void*>(ps.gridfn_data(nominal_gfns::gfn__K_dd_23)),
    static_cast<void*>(ps.gridfn_data(nominal_gfns::gfn__K_dd_33)),
    };

bool first_time = true;
if (first_time)
   then {
	first_time = false;

	// store derivative info in interpolator parameter table
	CCTK_VInfo(CCTK_THORNSTRING,
		   "         setting up derivative info for interpolator");

	status = Util_TableSetIntArray(gii.param_table_handle,
				       N_OUTPUT_ARRAYS, operand_indices,
				       "operand_indices");
	if (status < 0)
	   then error_exit(ERROR_EXIT,
"***** interpolate_geometry():\n"
"        unable to set operand_indices in interpolator parameter table!\n"
"        Util_TableSetIntArray() status=%d\n"
,
			   status);				/*NOTREACHED*/

	status = Util_TableSetIntArray(gii.param_table_handle,
				       N_OUTPUT_ARRAYS, operation_codes,
				       "operation_codes");
	if (status < 0)
	   then error_exit(ERROR_EXIT,
"***** interpolate_geometry():\n"
"        unable to set operation_codes in interpolator parameter table!\n"
"        Util_TableSetIntArray() status=%d\n"
,
			   status);				/*NOTREACHED*/
	}

CCTK_VInfo(CCTK_THORNSTRING,
	   "         calling interpolator (%d points)",
	   N_interp_points);
status = CCTK_InterpLocalUniform(N_GRID_DIMS,
				 gii.operator_handle, gii.param_table_handle,
				 cgi.coord_origin, cgi.coord_delta,
				 N_interp_points,
				    interp_coords_type_code,
				    interp_coords,
				 N_INPUT_ARRAYS,
				    cgi.gridfn_dims,
				    input_array_type_codes,
				    input_arrays,
				 N_OUTPUT_ARRAYS,
				    output_array_type_codes,
				    output_arrays);
if (status == CCTK_ERROR_INTERP_POINT_X_RANGE)
   then {
	// look in interpolator output table entries
	// to see *which* point is out-of-range
	CCTK_INT out_of_range_pt, out_of_range_axis, out_of_range_end;
	if (    (Util_TableGetInt(gii.param_table_handle,
				  &out_of_range_pt,
				  "out_of_range_pt") < 0)
	     || (Util_TableGetInt(gii.param_table_handle,
				  &out_of_range_axis,
				  "out_of_range_axis") < 0)
	     || (Util_TableGetInt(gii.param_table_handle,
				  &out_of_range_end,
				  "out_of_range_end") < 0)    )
	   then error_exit(ERROR_EXIT,
"***** interpolate_geometry():\n"
"        point out of range when interpolating geometry info from 3-D grid!\n"
"        ==> the trial horizon surface is (at least partially)\n"
"            outside the grid and/or in an excised region!\n"
"        (unable to get info about which point is out of range:\n"
"         maybe an interpolator problem?)\n");			/*NOTREACHED*/

	assert(out_of_range_pt >= 0);
	assert(out_of_range_pt < ps.N_grid_points());
	const double global_x = ps.gridfn_data(nominal_gfns::gfn__global_x)
				   [out_of_range_pt];
	const double global_y = ps.gridfn_data(nominal_gfns::gfn__global_y)
				   [out_of_range_pt];
	const double global_z = ps.gridfn_data(nominal_gfns::gfn__global_z)
				   [out_of_range_pt];

	assert(out_of_range_axis >= 0);
	assert(out_of_range_axis < N_GRID_DIMS);
	const char axis = "xyz"[out_of_range_axis];

	assert((out_of_range_end == -1) || (out_of_range_end == +1));
	const char end = (out_of_range_end == -1) ? '-' : '+';

	error_exit(ERROR_EXIT,
"***** interpolate_geometry():\n"
"        the point (%g,%g,%g) on the trial horizon surface\n"
"        is outside the grid in the %c%c direction!\n"
,
		   global_x, global_y, global_z,
		   end, axis);					/*NOTREACHED*/
	}
if (status < 0)
   then error_exit(ERROR_EXIT,
"***** interpolate_geometry(): error return from interpolator!\n"
"        CCTK_InterpLocalUniform() status=%d\n"
,
		   status);					/*NOTREACHED*/
}
	  }

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

//
// This function computes H(h), and optionally its Jacobian coefficients,
// (from which the Jacobian matrix may be computed later).  This function
// uses a mixture of algebraic operations and (rho,sigma) finite differencing.
// The computation is done (entirely) on the nominal angular grid.
//
// Arguments:
// Jacobian_flag = true to compute the Jacobian coefficients,
//		   false to skip this.
//
namespace {
void compute_H(patch_system& ps, bool Jacobian_flag)
{
CCTK_VInfo(CCTK_THORNSTRING, "      computing H(h)");

	for (int pn = 0 ; pn < ps.N_patches() ; ++pn)
	{
	patch& p = ps.ith_patch(pn);

		for (int irho = p.min_irho() ; irho <= p.max_irho() ; ++irho)
		{
		for (int isigma = p.min_isigma() ;
		     isigma <= p.max_isigma() ;
		     ++isigma)
		{
		//
		// compute the X_ud and X_udd derivative coefficients
		// ... n.b. this uses the *local* (x,y,z) coordinates
		//
		const fp r = p.ghosted_gridfn(ghosted_gfns::gfn__h,
					      irho,isigma);
		const fp rho = p.rho_of_irho(irho);
		const fp sigma = p.sigma_of_isigma(isigma);
		fp xx, yy, zz;
		p.xyz_of_r_rho_sigma(r,rho,sigma, xx, yy, zz);

		// 1st derivative coefficients X_ud
		const fp X_ud_11 = p.partial_rho_wrt_x(xx, yy, zz);
		const fp X_ud_12 = p.partial_rho_wrt_y(xx, yy, zz);
		const fp X_ud_13 = p.partial_rho_wrt_z(xx, yy, zz);
		const fp X_ud_21 = p.partial_sigma_wrt_x(xx, yy, zz);
		const fp X_ud_22 = p.partial_sigma_wrt_y(xx, yy, zz);
		const fp X_ud_23 = p.partial_sigma_wrt_z(xx, yy, zz);

		// 2nd derivative coefficient gridfns X_udd
		const fp X_udd_111 = p.partial2_rho_wrt_xx(xx, yy, zz);
		const fp X_udd_112 = p.partial2_rho_wrt_xy(xx, yy, zz);
		const fp X_udd_113 = p.partial2_rho_wrt_xz(xx, yy, zz);
		const fp X_udd_122 = p.partial2_rho_wrt_yy(xx, yy, zz);
		const fp X_udd_123 = p.partial2_rho_wrt_yz(xx, yy, zz);
		const fp X_udd_133 = p.partial2_rho_wrt_zz(xx, yy, zz);
		const fp X_udd_211 = p.partial2_sigma_wrt_xx(xx, yy, zz);
		const fp X_udd_212 = p.partial2_sigma_wrt_xy(xx, yy, zz);
		const fp X_udd_213 = p.partial2_sigma_wrt_xz(xx, yy, zz);
		const fp X_udd_222 = p.partial2_sigma_wrt_yy(xx, yy, zz);
		const fp X_udd_223 = p.partial2_sigma_wrt_yz(xx, yy, zz);
		const fp X_udd_233 = p.partial2_sigma_wrt_zz(xx, yy, zz);

		//
		// "call" the Maple-generated code
		// ... each cg/*.c file has a separate set of temp variables,
		//     and so must be inside its own set of { } braces
		//

		// gridfn #defins
		#include "cg.hh"

		  {
		// g_uu
		#include "../gr.cg/inverse_metric.c"
		  }

		  {
		// K, K_uu
		#include "../gr.cg/extrinsic_curvature_trace_raise.c"
		  }

		  {
		// partial_d_g_uu
		#include "../gr.cg/inverse_metric_gradient.c"
		  }

		  {
		// partial_d_ln_sqrt_g
		#include "../gr.cg/metric_det_gradient.c"
		  }

		  {
		// HA, HB, HC, HD, H
		#include "../gr.cg/horizon_function.c"
		  }

		if (Jacobian_flag)
		   then {
			// partial_H_wrt_partial_d_h, partial_H_wrt_partial_dd_h
			#include "../gr.cg/horizon_Jacobian.c"
			}
		}
		}
	}
}
	  }