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
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
|
/*@@
@file Table.c
@author Erik Schnetter
@date 2004/03/07 09:48:53
@desc
Get the symmetry table handle for a grid or grid array
@version $Header$
@enddesc
@@*/
#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_Table_c);
/*@@
@routine SymBase_SymmetryTableHandleForGrid
@author Erik Schnetter
@date 2004-03-06
@desc
Return the symmetry table handle for the grid hierarchy
@enddesc
@var cctkGH
@vtype CCTK_POINTER_TO_CONST
@vdesc Grid hierarchy
@vio in
@endvar
@returntype CCTK_INT
@returndesc
>=0 symmetry table handle
@endreturndesc
@@*/
CCTK_INT
SymBase_SymmetryTableHandleForGrid (CCTK_POINTER_TO_CONST const cctkGH_)
{
cGH const *const cctkGH = cctkGH_;
struct SymBase const *symdata;
if (!cctkGH)
{
CCTK_WARN (0, "internal error: cctkGH does not exist");
}
symdata = CCTK_GHExtension (cctkGH, "SymBase");
if (!symdata)
{
CCTK_WARN (0, "internal error: SymBase GH extension does not exist");
}
return symdata->sym_table;
}
/*@@
@routine SymBase_SymmetryTableHandleForGI
@author Erik Schnetter
@date 2004-03-06
@desc
Return the symmetry table handle for a grid array
@enddesc
@var cctkGH
@vtype CCTK_POINTER_TO_CONST
@vdesc Grid hierarchy
@vio in
@endvar
@var group_index
@vtype CCTK_INT
@vdesc Group
@vio in
@endvar
@returntype CCTK_INT
@returndesc
>=0 symmetry table handle
-6 if group_index has an illegal value
-7 if the group type has an illegal value
-8 if there was an internal error
@endreturndesc
@@*/
CCTK_INT
SymBase_SymmetryTableHandleForGI (CCTK_POINTER_TO_CONST const cctkGH_,
CCTK_INT const group_index)
{
cGH const *const cctkGH = cctkGH_;
struct SymBase const *symdata;
if (!cctkGH)
{
CCTK_WARN (0, "internal error: cctkGH does not exist");
}
symdata = CCTK_GHExtension (cctkGH, "SymBase");
if (!symdata)
{
CCTK_WARN (0, "internal error: SymBase GH extension does not exist");
}
if (group_index < 0 || group_index >= CCTK_NumGroups ())
{
return -6; /* illegal argument */
}
switch (CCTK_GroupTypeI (group_index))
{
case CCTK_GF:
return -7; /* illegal group type */
case CCTK_SCALAR:
case CCTK_ARRAY:
return symdata->array_sym_tables[group_index];
default:
CCTK_WARN (0, "internal error");
}
return -8; /* internal error */
}
/*@@
@routine SymBase_SymmetryTableHandleForGN
@author Erik Schnetter
@date 2004-03-06
@desc
Return the symmetry table handle for a grid array
@enddesc
@var cctkGH
@vtype CCTK_POINTER_TO_CONST
@vdesc Grid hierarchy
@vio in
@endvar
@var group_name
@vtype CCTK_STRING
@vdesc Group
@vio in
@endvar
@returntype CCTK_INT
@returndesc
>=0 symmetry table handle
Error codes of CCTK_GroupIndex
Error codes of SymBase_SymmetryTableHandleForGI
@endreturndesc
@@*/
CCTK_INT
SymBase_SymmetryTableHandleForGN (CCTK_POINTER_TO_CONST const cctkGH_,
CCTK_STRING const group_name)
{
int group_index;
group_index = CCTK_GroupIndex (group_name);
if (group_index < 0)
{
return group_index; /* illegal argument */
}
return SymBase_SymmetryTableHandleForGI (cctkGH_, group_index);
}
/*@@
@routine SymBase_GetSymmetryBoundaries
@author Erik Schnetter
@date 2006-05-16
@desc
Determine which boundaries are symmetry boundaries
@enddesc
@var cctkGH
@vtype CCTK_POINTER_TO_CONST
@vdesc Grid hierarchy
@vio in
@endvar
@var size
@vtype CCTK_INT
@vdesc Array size
@vio in
@endvar
@var symbnd
@vtype CCTK_INT [size]
@vdesc 0 for outer boundary, 1 for symmetry boundary
@vio out
@endvar
@returntype CCTK_INT
@returndesc
0 Success
-10 Wrong array size; must be 2*cctk_dim
-11 Symmetry table handle does not exist
-12 Wrong number of symmetry table entries (internal error)
@endreturndesc
@@*/
CCTK_INT
SymBase_GetSymmetryBoundaries (CCTK_POINTER_TO_CONST const cctkGH_,
CCTK_INT const size,
CCTK_INT * restrict const symbnd)
{
cGH const *const cctkGH = cctkGH_;
struct SymBase const *symdata;
CCTK_INT symtable;
CCTK_INT symmetry_handle [6];
CCTK_INT iret;
int d;
/* Check the arguments */
if (size != 2 * cctkGH->cctk_dim)
{
return -10;
}
/* Get the symmetry table */
symtable = SymmetryTableHandleForGrid (cctkGH);
if (symtable < 0)
{
return -11;
}
/* Get the symmetry handles for each face */
iret = Util_TableGetIntArray
(symtable, 2 * cctkGH->cctk_dim, symmetry_handle, "symmetry_handle");
if (iret != 2 * cctkGH->cctk_dim)
{
return -12;
}
/* A face has a symmetry boundary if there is a valid (non-negative)
handle registered for that face */
for (d = 0; d < 2 * cctkGH->cctk_dim; ++ d)
{
symbnd[d] = symmetry_handle[d] >= 0;
}
/* Success */
return 0;
}
|