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
|
// misc-driver.cc -- misc support routines
// $Header$
//
// Cactus_gridfn_varindex - get Cactus gridfn variable index
// Cactus_gridfn_dataptr - get Cactus gridfn data pointer
// ***** template instantiations *****
//
#include <stdio.h>
#include <assert.h>
#include <math.h>
#include "util_Table.h"
#include "cctk.h"
#include "cctk_Arguments.h"
#include "cctk_Parameters.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"
using jtutil::error_exit;
#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 "../gr/gfns.hh"
#include "../gr/gr.hh"
#include "horizon_sequence.hh"
#include "BH_diagnostics.hh"
#include "driver.hh"
//******************************************************************************
//
// This function gets the Cactus variable index of a given gridfn, and
// checks to make sure this is valid (i.e. that it's not an error code).
//
int Cactus_gridfn_varindex(const char gridfn_name[])
{
const int varindex = CCTK_VarIndex(gridfn_name);
if (varindex < 0)
then CCTK_VWarn(FATAL_ERROR, __LINE__, __FILE__, CCTK_THORNSTRING,
"\n"
" Cactus_gridfn_varindex(): error return from CCTK_VarIndex()\n"
" for Cactus gridfn!\n"
" name=\"%s\" status=%d"
,
gridfn_name, varindex); /*NOTREACHED*/
return varindex;
}
//******************************************************************************
//
// This template function gets the Cactus data pointer for a single gridfn,
// and optionally checks to make sure this is non-NULL.
//
// Arguments:
// T = The desired CCTK_* datatype.
// GH --> The Cactus grid hierarchy.
// gridfn_name[] = The character-string name of the grid function;
// this is used only for formatting error messages.
// check_for_NULL = true ==> check to make sure the data pointer is non-NULL
// false ==> skip this check (presumably because a NULL
// pointer is ok)
//
template <typename T>
T* Cactus_gridfn_dataptr(const cGH *GH, int varindex,
const char gridfn_name[],
bool check_for_NULL /* = true */)
{
const int time_level = 0;
T* data_ptr = static_cast<T*>( CCTK_VarDataPtrI(GH, time_level, varindex) );
if (check_for_NULL && (data_ptr == NULL))
then CCTK_VWarn(FATAL_ERROR, __LINE__, __FILE__, CCTK_THORNSTRING,
"\n"
" Cactus_gridfn_dataptr(): got unexpected NULL data pointer\n"
" for Cactus gridfn!\n"
" name=\"%s\" varindex=%d"
,
gridfn_name, varindex); /*NOTREACHED*/
return data_ptr;
}
//******************************************************************************
template CCTK_REAL* Cactus_gridfn_dataptr<CCTK_REAL>(const cGH*, int,
const char*,
bool /* = true */);
template CCTK_INT* Cactus_gridfn_dataptr<CCTK_INT>(const cGH*, int,
const char*,
bool /* = true */);
|