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
|
#include <assert.h>
#include <math.h>
#include <stdlib.h>
#include "cctk.h"
#include "cctk_Parameters.h"
#include "ggf.hh"
#include "gh.hh"
#include "carpet.hh"
extern "C" {
static const char* rcsid = "$Header: /home/eschnett/C/carpet/Carpet/Carpet/Carpet/src/Restrict.cc,v 1.27 2004/05/21 18:16:23 schnetter Exp $";
CCTK_FILEVERSION(Carpet_Carpet_Restrict_cc);
}
namespace Carpet {
using namespace std;
void Restrict (const cGH* cgh)
{
DECLARE_CCTK_PARAMETERS;
assert (is_level_mode());
if (suppress_restriction) {
Checkpoint ("Restriction suppressed");
return;
}
Checkpoint ("Restrict");
// Restrict
if (reflevel < reflevels-1) {
for (comm_state<dim> state; !state.done(); state.step()) {
for (int group=0; group<CCTK_NumGroups(); ++group) {
if (CCTK_GroupTypeI(group) == CCTK_GF) {
if (CCTK_QueryGroupStorageI(cgh, group)) {
const int tl = 0;
for (int m=0; m<(int)arrdata.at(group).size(); ++m) {
assert (m<(int)arrdata.at(group).size());
// use background time here (which may not be modified
// by the user)
const CCTK_REAL time = vtt.at(m)->time (tl, reflevel, mglevel);
const CCTK_REAL time1 = vtt.at(m)->time (0, reflevel, mglevel);
const CCTK_REAL time2
= (cgh->cctk_time - cctk_initial_time) / delta_time;
assert (fabs(time1 - time2) / (fabs(time1) + fabs(time2) + fabs(cgh->cctk_delta_time)) < 1e-12);
for (int var=0; var<CCTK_NumVarsInGroupI(group); ++var) {
assert (var<(int)arrdata.at(group).at(m).data.size());
for (int c=0; c<vhh.at(m)->components(reflevel); ++c) {
arrdata.at(group).at(m).data.at(var)->ref_restrict
(state, tl, reflevel, c, mglevel, time);
}
}
}
} // if group has storage
} // if grouptype == CCTK_GF
} // loop over groups
} // for state
} // if not finest refinement level
// Sync
if (reflevel < reflevels-1) {
for (comm_state<dim> state; !state.done(); state.step()) {
for (int group=0; group<CCTK_NumGroups(); ++group) {
if (CCTK_GroupTypeI(group) == CCTK_GF) {
if (CCTK_QueryGroupStorageI(cgh, group)) {
const int tl = 0;
for (int m=0; m<(int)arrdata.at(group).size(); ++m) {
assert (m<(int)arrdata.at(group).size());
for (int var=0; var<CCTK_NumVarsInGroupI(group); ++var) {
assert (var<(int)arrdata.at(group).at(m).data.size());
for (int c=0; c<vhh.at(m)->components(reflevel); ++c) {
arrdata.at(group).at(m).data.at(var)->sync
(state, tl, reflevel, c, mglevel);
}
}
}
} // if group has storage
} // if grouptype == CCTK_GF
} // loop over groups
} // for state
} // if not finest refinement level
}
} // namespace Carpet
|