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
|
/*@@
@file Startup.c
@author Erik Schnetter
@date 2004-03-06
@desc
Thorn startup
@version $Header$
@enddesc
@@*/
#include <stdlib.h>
#include "cctk.h"
#include "util_Table.h"
#include "SymBase.h"
/* the rcs ID and its dummy function to use it */
static const char *const rcsid = "$Header$";
CCTK_FILEVERSION (CactusBase_SymBase_Startup_c);
/*@@
@routine SymBase_Startup
@author Erik Schnetter
@date 2004-03-06
@desc
Register a GH extension and initialise the global variables
@enddesc
@returntype int
@returndesc
status code
0 for success
@endreturndesc
@@*/
int
SymBase_Startup (void)
{
int handle;
int ierr;
handle = CCTK_RegisterGHExtension ("SymBase");
if (handle < 0)
{
CCTK_WARN (0, "Internal Error: Failed to create GH extension for symmetry data");
}
ierr = CCTK_RegisterGHExtensionSetupGH (handle, SymBase_Setup);
if (ierr != 1)
{ /* strange error code convention */
CCTK_WARN (0, "Internal Error: Could not register GH Extension setup routine");
}
SymBase_num_symmetries = 0;
SymBase_symmetry_names = NULL;
return 0; /* no error */
}
/*@@
@routine SymBase_Setup
@author Erik Schnetter
@date 2004-03-06
@desc
Initialise the GH extension
@enddesc
@var config
@vtype tFleshConfig *
@vdesc Internal flesh information, unused
@vio in
@endvar
@var convlev
@vtype int
@vdesc Convergence level, unused
@vio in
@endvar
@var cctkGH
@vtype cGH *
@vdesc Grid hierarchy
@vio in
@endvar
@@*/
void *
SymBase_Setup (tFleshConfig * const config,
int const convlev, cGH * const cctkGH)
{
struct SymBase *symdata;
CCTK_INT symmetry_handle[100];
CCTK_INT symmetry_zone_width[100];
int group;
int face;
int ierr;
/* Create GH extension */
symdata = malloc (sizeof *symdata);
if (!symdata)
{
CCTK_WARN (0, "Failed to allocate memory for symmetry data");
}
/* Initialise handle and zone width arrays */
for (face = 0; face < 100; ++face)
{
symmetry_handle[face] = -1;
symmetry_zone_width[face] = 0;
}
/* Create grid symmetry table */
symdata->sym_table = Util_TableCreate (UTIL_TABLE_FLAGS_CASE_INSENSITIVE);
if (symdata->sym_table < 0)
{
CCTK_WARN (0, "Internal Error: Failed to create symmetry table.");
}
if (2 * cctkGH->cctk_dim > 100)
{
CCTK_WARN (0, "Internal Error: Can currently only handle a hundred faces.");
}
ierr = Util_TableSetIntArray
(symdata->sym_table,
2 * cctkGH->cctk_dim, symmetry_handle, "symmetry_handle");
if (ierr)
{
CCTK_WARN (0, "Internal Error: Failed to create symmetry_handle array");
}
ierr = Util_TableSetIntArray
(symdata->sym_table,
2 * cctkGH->cctk_dim, symmetry_zone_width, "symmetry_zone_width");
if (ierr)
{
CCTK_WARN (0, "Internal Error: Failed to create symmetry_zone_width array");
}
/* Create grid array symmetry tables */
symdata->array_sym_tables
= malloc (CCTK_NumGroups () * sizeof *symdata->array_sym_tables);
if (!symdata->array_sym_tables)
{
CCTK_WARN (0, "Internal Error: Failed to create array for symmetry tables for GAs");
}
for (group = 0; group < CCTK_NumGroups (); ++group)
{
switch (CCTK_GroupTypeI (group))
{
case CCTK_GF:
/* No table */
symdata->array_sym_tables[group] = -1;
break;
case CCTK_SCALAR:
/* FALL_THROUGH */
case CCTK_ARRAY:
/* Create array symmetry table */
symdata->array_sym_tables[group]
= Util_TableCreate (UTIL_TABLE_FLAGS_CASE_INSENSITIVE);
if (symdata->array_sym_tables[group] < 0)
{
CCTK_WARN (0, "Internal Error: Failed to create symmetry table for GA");
}
if (2 * CCTK_GroupDimI (group) > 100)
{
CCTK_WARN (0, "Internal Error: Can only handle 100 faces");
}
ierr = Util_TableSetIntArray
(symdata->array_sym_tables[group],
2 * CCTK_GroupDimI (group), symmetry_handle, "symmetry_handle");
if (ierr)
{
CCTK_WARN (0, "Internal Error: Failed to create symmetry_handle array");
}
ierr = Util_TableSetIntArray
(symdata->array_sym_tables[group],
2 * CCTK_GroupDimI (group), symmetry_zone_width,
"symmetry_zone_width");
if (ierr)
{
CCTK_WARN (0, "Internal Error: Failed to create symmetry_zone_width array");
}
break;
default:
CCTK_WARN (0, "Internal Error: Unknown GV type");
}
}
return symdata;
}
|