aboutsummaryrefslogtreecommitdiff
path: root/schedule.ccl
blob: a6bb2ebf73de6590c3946faa368a7ff67a34ecb6 (plain)
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
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
# Schedule definitions for thorn MoL
# $Header$

##########################################################
###  Always require storage for the counters and time  ###
##########################################################

STORAGE: MoL_Counters, MoL_Original_Time

########################################################
###  Storage for the scratch space if memory hungry  ###
########################################################

# NOTE: I don't think this does what I expected.
# I now think that this is always switching on memory,
# regardless of the parameter...

if (MoL_Memory_Always_On)
{
  STORAGE: ScratchSpace
#  STORAGE: ComplexScratchSpace
  STORAGE: ArrayScratchSpace
#  STORAGE: ComplexArrayScratchSpace
  STORAGE: SandRScratchSpace
#  STORAGE: ComplexSandRScratchSpace
  STORAGE: ArraySandRScratchSpace
#  STORAGE: ComplexArraySandRScratchSpace
}

############################################################
###  If using the generic Runge-Kutta solver, switch on  ###
###  storage for the coefficient arrays                  ###
############################################################

if (CCTK_Equals(ODE_Method,"Generic"))
{
  STORAGE: RKAlphaCoefficients
  STORAGE: RKBetaCoefficients
}

#############################
###  The actual routines  ###
#############################

########################
###  Startup banner  ###
########################

schedule MoL_Startup AT Startup
{
  LANG: C
} "Startup banner"

#####################################
###  Parameter checking routine.  ###
#####################################

schedule MoL_ParamCheck AT ParamCheck
{
  LANG: C
} "Basic parameter checking"

#################################################
###  Allocate the arrays for the GF indexes.  ###
#################################################

schedule MoL_SetupIndexArrays AT Initial
{
  LANG: C
} "Set up the MoL bookkeeping index arrays"

schedule MoL_SetupIndexArrays AT Recover_Variables
{
  LANG: C
} "Set up the MoL bookkeeping index arrays"

################################################
###  Initialize the coefficients for the RK  ###
###  arrays if required                      ###
################################################

if (CCTK_Equals(ODE_Method,"Generic"))
{
  schedule MoL_SetupRKCoefficients AT Initial
  {
    LANG: C
    STORAGE: RKAlphaCoefficients
    STORAGE: RKBetaCoefficients
  } "Initialize the generic Runge-Kutta coefficients"

  schedule MoL_SetupRKCoefficients AT Recover_Variables
  {
    LANG: C
    STORAGE: RKAlphaCoefficients
    STORAGE: RKBetaCoefficients
  } "Initialize the generic Runge-Kutta coefficients"
}

#################################################
###  The group where physics thorns call the  ###
###  registration functions                   ###
#################################################

schedule GROUP MoL_Register AT PostInitial 
{
  LANG:C
} "The group where physics thorns register variables with MoL"

schedule GROUP MoL_Register AT Post_Recover_Variables
{
  LANG:C
} "The group where physics thorns register variables with MoL"

if (initial_data_is_crap)
{
  schedule MoL_FillAllLevels AT PostInitial AFTER MoL_Register
  {
    LANG:C
  } "A bad routine. Fills all previous timelevels with data copied from the current."
}

schedule MoL_ReportNumberVariables AT PostInitial AFTER MoL_Register
{
  LANG:C
} "Report how many of each type of variable there are"

######################################################
###  The evolution step. This is almost a self     ###
###  contained EVOL step with PRE and POST steps   ###
###  to allow changing the type of the variables,  ###
###  boundary enforcement and so on.               ###
######################################################

# NOTE: I temporarily comment out the storage statements as I do not 
# want to write out the if statements above! So this will not currently 
# work with the memory hungry parameter to no.

schedule GROUP MoL_Evolution AT Evol
{
  LANG: C
   STORAGE: ScratchSpace
#   STORAGE: ComplexScratchSpace
   STORAGE: SandRScratchSpace
#   STORAGE: ComplexSandRScratchSpace
   STORAGE: ArrayScratchSpace
#   STORAGE: ComplexArrayScratchSpace
   STORAGE: ArraySandRScratchSpace
#   STORAGE: ComplexArraySandRScratchSpace
} "A single Cactus evolution step using MoL"

######################################################
###  StartStep contains the routines that just do  ###
###  internal MoL stuff; setting the counter, and  ###
###  changing the time and timestep if required.   ###
######################################################

schedule GROUP MoL_StartStep IN MoL_Evolution
{
  LANG: C
} "MoL internal setup for the evolution step"

schedule MoL_SetCounter IN MoL_StartStep 
{
  LANG: C
} "Set the counter for the ODE method to loop over"

########################################################
###  Note that the option GLOBAL here is to ensure   ###
###  that the time is set once per refinement level  ###
###  and not once overall.                           ###
###  I think with current implementations this is    ###
###  not required.                                   ###
########################################################

schedule MoL_SetTime IN MoL_StartStep 
{
  LANG: C
  ###  OPTION: GLOBAL
} "Ensure the correct time and timestep are used"

#################################################################
###  PreStep is where physics thorns can do their own setup.  ###
###  This would include scheduling the function calls to      ###
###  change the type of variable.                             ###
#################################################################

schedule GROUP MoL_PreStep IN MoL_Evolution AFTER MoL_StartStep BEFORE MoL_Step
{
  LANG: C
} "Physics thorns can schedule preloop setup routines in here"

#######################################################################
###  Check to see if any type changing functions have been called,  ###
###  and if so do the necessary bookkeeping.                        ###
###  Right now, I think this is unnecessary, now that we don't      ###
###  reallocate any scratch space.                                  ###
#######################################################################

#schedule MoL_CheckVariableType IN MoL_Evolution AFTER MoL_PreStep BEFORE MoL_Step
#{
#  LANG: C
#} "If a physics thorn wants to change the type of a variable, do the bookkeeping"

#################################################################
###  Copy (ouch) the data into the correct timelevel so that  ###
###  the physics thorn knows where to find it.                ###
#################################################################

schedule MoL_InitialCopy IN MoL_Evolution AFTER MoL_PreStep BEFORE MoL_Step
{
  LANG: C
} "Ensure the data is in the correct timelevel"

#################################################
###  The actual loop which updates the data.  ###
#################################################

schedule GROUP MoL_Step WHILE MoL::MoL_Intermediate_Step IN MoL_Evolution AFTER MoL_PreStep
{
  LANG: C
} "The loop over the intermediate steps for the ODE integrator"

####################################################
###  The time integrator prepares the time step  ###
####################################################

if (CCTK_Equals(ODE_Method,"ICN-avg")) 
{
  schedule MoL_ICNAverage AS MoL_Prepare IN MoL_Step BEFORE MoL_CalcRHS
  {
    LANG: C
  } "Averages the time levels for the averaging ICN method"
}

#####################################################
###  The group where all the physics takes place  ###
#####################################################

schedule GROUP MoL_CalcRHS IN MoL_Step
{
  LANG: C
} "Physics thorns schedule the calculation of the discrete spatial operator in here"

#####################################################
###  If required, check for any NaNs in the RHSs  ###
#####################################################

if (MoL_NaN_Check)
{
  schedule MoL_NaNCheck IN MoL_Step AFTER MoL_CalcRHS BEFORE MoL_Add
  {
    LANG: C
  } "Check the RHS GFs for NaNs"
}

######################################################
###  The time integrator performs the update here  ###
######################################################

if (CCTK_Equals(ODE_Method,"Generic"))
{
  schedule MoL_GenericRKAdd AS MoL_Add IN MoL_Step AFTER MoL_CalcRHS BEFORE MoL_PostStep
  {
    LANG: C
  } "Updates calculated with a generic method"
}
else if (CCTK_Equals(ODE_Method,"RK2")) 
{
  schedule MoL_RK2Add AS MoL_Add IN MoL_Step AFTER MoL_CalcRHS BEFORE MoL_PostStep
  {
    LANG: C
  } "Updates calculated with the efficient Runge-Kutta 2 method"
}
else if (CCTK_Equals(ODE_Method,"RK3")) 
{
  schedule MoL_RK3Add AS MoL_Add IN MoL_Step AFTER MoL_CalcRHS BEFORE MoL_PostStep
  {
    LANG: C
  } "Updates calculated with the efficient Runge-Kutta 3 method"
}
else if (CCTK_Equals(ODE_Method,"ICN"))
{
  schedule MoL_ICNAdd AS MoL_Add IN MoL_Step AFTER MoL_CalcRHS BEFORE MoL_PostStep
  {
    LANG: C
  } "Updates calculated with the efficient ICN method"
}
else if (CCTK_Equals(ODE_Method,"ICN-avg"))
{
  schedule MoL_ICNAdd AS MoL_Add IN MoL_Step AFTER MoL_CalcRHS BEFORE MoL_PostStep
  {
    LANG: C
  } "Updates calculated with the averaging ICN method"
}

##################################################
###  Physics thorns can apply boundaries and   ###
###  recalculate constrained variables and so  ###
###  on in PostStep                            ###
##################################################

schedule GROUP MoL_PostStep IN MoL_Step AFTER MoL_Add
{
  LANG: C
} "The group for physics thorns to schedule boundary calls etc."

##################################################################
###  Schedule the PostStep parts in the Carpet 'PostRestrict'  ###
###  bin so that symmetries are automatically done correctly.  ###
###  We may want to change this later as it could be           ###
###  expensive, but it's simplest for the moment.              ###
###  Note that if you compile without Carpet you will get a    ###
###  warning which you can ignore.                             ###
##################################################################

schedule GROUP MoL_PostStep IN PostRestrict
{
  LANG: C
} "Ensure that everything is correct after restriction"

#################################################
###  Final internal MoL stuff; decrement the  ###
###  counter, change time and timestep        ###
#################################################

schedule MoL_DecrementCounter IN MoL_Step AFTER MoL_Step BEFORE MoL_PostStep
{
  LANG: C
} "Alter the counter number"

schedule MoL_ResetTime IN MoL_Step AFTER MoL_DecrementCounter BEFORE MoL_PostStep
{
  LANG: C
} "If necessary, change the time"

schedule MoL_ResetDeltaTime IN MoL_Step AFTER MoL_PostStep
{
  LANG: C
} "If necessary, change the timestep"

##################################################
###  Finally, restore any SaveAndRestore type  ###
###  variables to their original state.        ###
##################################################

schedule MoL_RestoreSandR IN MoL_Evolution AFTER MoL_PostStep
{
  LANG: C
} "Restoring the Save and Restore variables to the original state"

################################################################
###  At the end (but before driver terminate to avoid those  ###
###  irritating segfaults) free the index arrays.            ###
################################################################

schedule MoL_FreeIndexArrays AT Terminate BEFORE Driver_Terminate
{
  LANG: C
} "Free the MoL bookkeeping index arrays"