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
|
#include <assert.h>
#include <stdlib.h>
#include <algorithm>
#include "cctk.h"
#include "cctki_GHExtensions.h"
#include "gh.hh"
#include "carpet.hh"
extern "C" {
static const char* rcsid = "$Header: /home/eschnett/C/carpet/Carpet/Carpet/Carpet/src/CallFunction.cc,v 1.13 2003/08/10 21:59:51 schnetter Exp $";
CCTK_FILEVERSION(Carpet_Carpet_CallFunction_cc);
}
namespace Carpet {
using namespace std;
/// Traverse one function on all components of one refinement level
/// of one multigrid level.
int CallFunction (void* function, ///< the function to call
cFunctionData* attribute, ///< attributes of the function
void* data) ///< ???
{
// Checkpoint ("%*sStarting CallFunction...", 2*reflevel, "");
cGH* cgh = (cGH*)data;
if (attribute->global || reflevel==-1) {
// Global operation: call once
if (do_global_mode) {
assert (component == -1);
const int saved_mglevel = mglevel;
if (mglevel!=-1) set_mglevel (cgh, -1);
const int saved_reflevel = reflevel;
if (reflevel!=-1) set_reflevel (cgh, -1);
Checkpoint ("Global mode call at %s to %s::%s",
attribute->where, attribute->thorn, attribute->routine);
const int res = CCTK_CallFunction (function, attribute, data);
assert (res==0);
if (reflevel!=saved_reflevel) set_reflevel (cgh, saved_reflevel);
if (mglevel!=saved_mglevel) set_mglevel (cgh, saved_mglevel);
}
} else if (attribute->level) {
// Level operation: call once per refinement level
Checkpoint ("%*sLevel mode call at %s to %s::%s", 2*reflevel, "",
attribute->where, attribute->thorn, attribute->routine);
const int res = CCTK_CallFunction (function, attribute, data);
assert (res==0);
} else {
// Local operation: call once per component
BEGIN_LOCAL_COMPONENT_LOOP(cgh, CCTK_GF) {
Checkpoint ("%*sLocal mode call on component %d at %s to %s::%s",
2*reflevel, "", component,
attribute->where, attribute->thorn, attribute->routine);
const int res = CCTK_CallFunction (function, attribute, data);
assert (res==0);
} END_LOCAL_COMPONENT_LOOP;
}
// Checkpoint ("%*sdone with CallFunction.", 2*reflevel, "");
// The return value indicates whether the grid functions have been
// synchronised.
// return 0: let the flesh do the synchronisation, if necessary
return 0;
}
} // namespace Carpet
|