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
|
#include <cstdio>
#include <cassert>
#include "cctk.h"
#include "cctk_Arguments.h"
#include "cctk_Parameters.h"
#include "carpet.hh"
using std::printf;
#define then /* empty */
// prototypes
namespace {
void do_singlemap_stuff(cGH* GH, int map_number, bool test_local_mode);
void do_local_stuff(cGH* GH, int map_number, int component_number);
};
//******************************************************************************
// this function is called in LEVEL mode by the Cactus scheduler
extern "C"
void TestCarpetGridInfo_test(CCTK_ARGUMENTS)
{
DECLARE_CCTK_ARGUMENTS
DECLARE_CCTK_PARAMETERS
cGH* GH = cctkGH;
assert(Carpet::is_level_mode());
for (int map_number = 0 ; map_number < N_maps ; ++map_number)
{
// switch Carpet to this map
Carpet::enter_singlemap_mode(GH, map_number);
do_singlemap_stuff(GH, map_number, (test_local_mode != 0));
Carpet::leave_singlemap_mode(GH);
}
}
//******************************************************************************
// this function is called in SINGLEMAP mode for each patch (= Carpet map)
namespace {
void do_singlemap_stuff(cGH* GH, const int map_number, bool test_local_mode)
{
assert(Carpet::is_singlemap_mode());
cGH* cctkGH = GH; // magic variable name for CCTK_*() macros
DECLARE_CCTK_ARGUMENTS; // set up for CCTK_*() macros
printf("in singlemap mode, map_number=%d\n", map_number);
printf(" cctk_origin_space[]=(%g,%g,%g)\n",
double(GH->cctk_origin_space[0]), double(GH->cctk_origin_space[1]),
double(GH->cctk_origin_space[2]));
printf(" cctk_delta_space[]=(%g,%g,%g)\n",
double(GH->cctk_delta_space[0]), double(GH->cctk_delta_space[1]),
double(GH->cctk_delta_space[2]));
printf(" CCTK_ORIGIN_SPACE()=(%g,%g,%g)\n",
double(CCTK_ORIGIN_SPACE(0)), double(CCTK_ORIGIN_SPACE(1)),
double(CCTK_ORIGIN_SPACE(2)));
printf(" CCTK_DELTA_SPACE()=(%g,%g,%g)\n",
double(CCTK_DELTA_SPACE(0)), double(CCTK_DELTA_SPACE(1)),
double(CCTK_DELTA_SPACE(2)));
if (test_local_mode)
then {
using namespace Carpet; // needed for magic Carpet macros below
BEGIN_LOCAL_COMPONENT_LOOP(GH, CCTK_GF)
{
assert(Carpet::is_local_mode());
const int component_number = Carpet::component;
do_local_stuff(GH, map_number, component_number);
}
END_LOCAL_COMPONENT_LOOP;
}
}
}
//******************************************************************************
namespace {
void do_local_stuff(cGH* GH, int map_number, int component_number)
{
assert(Carpet::is_local_mode());
cGH* cctkGH = GH; // magic variable name for CCTK_*() macros
DECLARE_CCTK_ARGUMENTS; // set up for CCTK_*() macros
printf("in local mode, map_number=%d component_number=%d:\n",
map_number, component_number);
printf(" cctk_origin_space[]=(%g,%g,%g)\n",
double(GH->cctk_origin_space[0]), double(GH->cctk_origin_space[1]),
double(GH->cctk_origin_space[2]));
printf(" cctk_delta_space[]=(%g,%g,%g)\n",
double(GH->cctk_delta_space[0]), double(GH->cctk_delta_space[1]),
double(GH->cctk_delta_space[2]));
printf(" CCTK_ORIGIN_SPACE()=(%g,%g,%g)\n",
double(CCTK_ORIGIN_SPACE(0)), double(CCTK_ORIGIN_SPACE(1)),
double(CCTK_ORIGIN_SPACE(2)));
printf(" CCTK_DELTA_SPACE()=(%g,%g,%g)\n",
double(CCTK_DELTA_SPACE(0)), double(CCTK_DELTA_SPACE(1)),
double(CCTK_DELTA_SPACE(2)));
}
}
|