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
|
/*@@
@file ApplyCartoon.c
@date 6 Jan 2003
@author David Rideout
@desc
Applies the Cartoon boundary condition to all variables
selected for a bc.
@enddesc
@version $Header$
@@*/
#include "cctk.h"
#include "cctk_Arguments.h"
#include "util_Table.h"
#include "Cartoon2D.h"
#include "Cartoon2D_tensors.h"
#include <stdlib.h>
static const char *rcsid = "$Header$";
CCTK_FILEVERSION(BetaThorns_Cartoon2D_ApplyCartoon_c);
/********************************************************************
********************* Local Data Types ***********************
********************************************************************/
/* #define DEBUG 1 */
#define TENSORTYPE_BUFF_SIZE 7
#define PROLONG_BUFF_SIZE 1000
/********************************************************************
********************* Local Routine Prototypes *********************
********************************************************************/
/********************************************************************
***************** Aliased Routine Prototypes ***********************
********************************************************************/
/********************************************************************
***************** Scheduled Routine Prototypes *********************
********************************************************************/
void Cartoon_ApplyBoundaries(CCTK_ARGUMENTS);
/********************************************************************
********************* Other Routine Prototypes *********************
********************************************************************/
/********************************************************************
********************* Local Data *****************************
********************************************************************/
/********************************************************************
********************* Aliased Routines **********************
********************************************************************/
/********************************************************************
********************* Scheduled Routines **********************
********************************************************************/
/*@@
@routine Cartoon_ApplyBoundaries
@date 6 Jan 2003
@author David Rideout
@desc
This will apply the Cartoon boundary condition to all
variables selected for any (physical) boundary condition.
@enddesc
@calls
@history
@endhistory
@var CCTK_ARGUMENTS
@vdesc Cactus argument list
@vtype CCTK_*
@vio in
@endvar
@returntype void
@returndesc
@endreturndesc
@@*/
void Cartoon_ApplyBoundaries(CCTK_ARGUMENTS)
{
DECLARE_CCTK_ARGUMENTS;
int num_vars, err, i, gi, group_tags_table;
CCTK_INT * vars;
char tensortype[TENSORTYPE_BUFF_SIZE];
char prolongtype[PROLONG_BUFF_SIZE];
int prolongmethod;
/* Check grid size */
if(cctk_gsh[1] != 2*cctk_nghostzones[1]+1)
{
CCTK_WARN(0, "Grid size in y direction inappropriate.");
}
/* Allocate memory to hold selected bcs */
num_vars = Boundary_SelectedGVs(cctkGH, 0, NULL, NULL, NULL, NULL, NULL);
#ifdef DEBUG
printf("Cartoon_ApplyBoundaries: num_vars is %d\n",num_vars);
#endif
vars = malloc(num_vars*sizeof *vars);
/* get all selected vars */
err = Boundary_SelectedGVs(cctkGH, num_vars, vars, NULL, NULL, NULL, NULL);
if (err != num_vars)
{
CCTK_VWarn(1, __LINE__, __FILE__, CCTK_THORNSTRING,
"Boundary_SelectedGVs returned %d selected variables, but %d "
"expected", err, num_vars);
}
/* Apply CartoonBC to each of them. */
/* One should probably check to see that the entire group has been
* selected, since Cartoon operates on an entire group at a time.
* For now I'll just skip a variable if it is not a 'group leader'.
*/
for (i=0; i<num_vars; ++i) {
#ifdef DEBUG
printf("Cartoon_ApplyBoundaries: i=%d applying cartoon to vi %d\n",i,
vars[i]);
#endif
gi = CCTK_GroupIndexFromVarI(vars[i]);
if (gi<0) {
CCTK_VWarn(1, __LINE__, __FILE__, CCTK_THORNSTRING,
"Invalid variable index %d selected for a boundary "
"condition", gi);
}
if (vars[i] != CCTK_FirstVarIndexI(gi))
{
/* not a group leader -- skip to next var index */
continue;
}
/* Here one should check that the entire group is registered,
* using CCTK_NumVarsInGroupI.
*/
/* Get table handle for group tags table */
group_tags_table = CCTK_GroupTagsTableI(gi);
if (group_tags_table<0) {
CCTK_VWarn(1, __LINE__, __FILE__, CCTK_THORNSTRING,
"Tags table for variable group %s is %d", CCTK_GroupName(gi),
group_tags_table);
}
/* Get tensor type from group tags table */
err = Util_TableGetString(group_tags_table, TENSORTYPE_BUFF_SIZE,
tensortype, "tensortypealias");
if (err<0)
{
CCTK_VWarn(1, __LINE__, __FILE__, CCTK_THORNSTRING,
"Error in TAGS table for variable group %s",
CCTK_GroupName(gi));
}
#ifdef DEBUG
printf("Cartoon_ApplyBoundaries: tensor type is %s\n",tensortype);
#endif
/* Get prolongation type from group tags table */
err = Util_TableGetString(group_tags_table, PROLONG_BUFF_SIZE,
prolongtype, "Prolongation");
if (err == UTIL_ERROR_TABLE_NO_SUCH_KEY)
{
/* Use the default */
prolongmethod = PROLONG_LAGRANGE;
}
else if (err < 0)
{
CCTK_VWarn(0, __LINE__, __FILE__, CCTK_THORNSTRING,
"Error (%d) in TAGS table for variable group %s", err,
CCTK_GroupName(gi));
}
else
{
if (CCTK_Equals(prolongtype, "None"))
{
prolongmethod = PROLONG_LAGRANGE; /* But why? */
}
else if (CCTK_Equals(prolongtype, "Lagrange"))
{
prolongmethod = PROLONG_LAGRANGE;
}
else if (CCTK_Equals(prolongtype, "TVD"))
{
prolongmethod = PROLONG_ENO;
}
else if (CCTK_Equals(prolongtype, "ENO"))
{
prolongmethod = PROLONG_ENO;
}
else
{
CCTK_VWarn(0, __LINE__, __FILE__, CCTK_THORNSTRING,
"Error in TAGS table for variable group %s",
CCTK_GroupName(gi));
}
}
/* Here one should check that the group's size is correct for the
* specified tensortype.
*/
/* Call BndCartoon2DVI, passing the appropriate tensor type integer
macro */
if (CCTK_Equals(tensortype, "scalar"))
{
BndCartoon2DVI(cctkGH, TENSORTYPE_SCALAR, prolongmethod, vars[i]);
} else if ((CCTK_Equals(tensortype, "u")) || (CCTK_Equals(tensortype, "d")))
{
BndCartoon2DVI(cctkGH, TENSORTYPE_U, prolongmethod, vars[i]);
} else if (CCTK_Equals(tensortype, "dd_sym"))
{
BndCartoon2DVI(cctkGH, TENSORTYPE_DDSYM, prolongmethod, vars[i]);
} else
{
CCTK_VWarn(0, __LINE__, __FILE__, CCTK_THORNSTRING,
"invalid tensor type for group %s", CCTK_GroupName(gi));
}
}
/* Free data */
free(vars);
}
|