aboutsummaryrefslogtreecommitdiff
path: root/schedule.ccl
blob: 44f9b6d5ed84f6940109ad42fa79f8230c7495de (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
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
# 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)
{
  if (MoL_Num_Evolved_Vars)
  {
    if (MoL_Num_Scratch_Levels) 
    {
      STORAGE: ScratchSpace
      if (MoL_Max_Evolved_Array_Size)
      {
#	STORAGE: ArrayScratchSpace
      }
    }
  }
  else if (MoL_Num_Scratch_Levels) 
  {
    if (MoL_Max_Evolved_Array_Size)
    {
#      STORAGE: ArrayScratchSpace
    }
  }
  if (MoL_Num_SaveAndRestore_Vars)
  {
    STORAGE: SandRScratchSpace
  }  
  if (MoL_Max_Evolved_Array_Size)
  {
#    STORAGE: ArraySandRScratchSpace
  }
#  STORAGE: ComplexScratchSpace
#  STORAGE: ComplexArrayScratchSpace
#  STORAGE: ComplexSandRScratchSpace
#  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 Wragh
{
  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 Wragh
  {
    LANG: C
    OPTIONS: GLOBAL
    STORAGE: RKAlphaCoefficients
    STORAGE: RKBetaCoefficients
  } "Initialize the generic Runge-Kutta coefficients"
}

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

schedule MoL_SetScheduleStatus AT Wragh AFTER MoL_SetupIndexArrays
{
  LANG: C
  OPTIONS: GLOBAL
} "Set the flag so it is ok to register with MoL"

schedule GROUP MoL_Register AT Wragh AFTER MoL_SetScheduleStatus
{
} "The group where physics thorns register variables with MoL"

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

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

##########################################
###  Initialise the step size control  ###
##########################################

schedule MoL_StartLoop AT Evol BEFORE MoL_Evolution
{
  LANG: C
  OPTIONS: LEVEL
} "Initialise the step size control"

schedule MoL_StartLoop AT Initial
{
  LANG: C
  OPTIONS: LEVEL
} "Initialise the step size control"

######################################################
###  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.               ###
######################################################

# This fairly complicated mess of conditionals is to try and
# ensure that we never ask for storage for a vector group with
# no members. It could probably be simplified.

if (MoL_Num_Scratch_Levels)
{
  if (MoL_Num_Evolved_Vars)
  {
    if (MoL_Num_SaveAndRestore_Vars)
    {  
      if (MoL_Max_Evolved_Array_Size)
      {
	schedule GROUP MoL_Evolution AT Evol WHILE MoL::MoL_Stepsize_Bad
	{
	  STORAGE: ScratchSpace
	  STORAGE: SandRScratchSpace
# 	  STORAGE: ArrayScratchSpace
# 	  STORAGE: ArraySandRScratchSpace
	  #   STORAGE: ComplexScratchSpace
	  #   STORAGE: ComplexSandRScratchSpace
	  #   STORAGE: ComplexArrayScratchSpace
	  #   STORAGE: ComplexArraySandRScratchSpace
	} "A single Cactus evolution step using MoL"
      }
      else
      {
	schedule GROUP MoL_Evolution AT Evol WHILE MoL::MoL_Stepsize_Bad
	{
	  STORAGE: ScratchSpace
	  STORAGE: SandRScratchSpace
	  #   STORAGE: ComplexScratchSpace
	  #   STORAGE: ComplexSandRScratchSpace
	  #   STORAGE: ComplexArrayScratchSpace
	  #   STORAGE: ComplexArraySandRScratchSpace
	} "A single Cactus evolution step using MoL"
      }
    }
    else
    {
      if (MoL_Max_Evolved_Array_Size)
      {
	schedule GROUP MoL_Evolution AT Evol WHILE MoL::MoL_Stepsize_Bad
	{
	  STORAGE: ScratchSpace
# 	  STORAGE: ArrayScratchSpace
# 	  STORAGE: ArraySandRScratchSpace
	  #   STORAGE: ComplexScratchSpace
	  #   STORAGE: ComplexSandRScratchSpace
	  #   STORAGE: ComplexArrayScratchSpace
	  #   STORAGE: ComplexArraySandRScratchSpace
	} "A single Cactus evolution step using MoL"
      }
      else
      {
	schedule GROUP MoL_Evolution AT Evol WHILE MoL::MoL_Stepsize_Bad
	{
	  STORAGE: ScratchSpace
	  #   STORAGE: ComplexScratchSpace
	  #   STORAGE: ComplexSandRScratchSpace
	  #   STORAGE: ComplexArrayScratchSpace
	  #   STORAGE: ComplexArraySandRScratchSpace
	} "A single Cactus evolution step using MoL"
      }
    }
  }
  else 
  {
    if (MoL_Num_SaveAndRestore_Vars)
    {
      if (MoL_Max_Evolved_Array_Size)
      {
	schedule GROUP MoL_Evolution AT Evol WHILE MoL::MoL_Stepsize_Bad
	{
	  STORAGE: SandRScratchSpace
# 	  STORAGE: ArrayScratchSpace
# 	  STORAGE: ArraySandRScratchSpace
	  #   STORAGE: ComplexScratchSpace
	  #   STORAGE: ComplexSandRScratchSpace
	  #   STORAGE: ComplexArrayScratchSpace
	  #   STORAGE: ComplexArraySandRScratchSpace
	} "A single Cactus evolution step using MoL"
      }
      else
      {
	schedule GROUP MoL_Evolution AT Evol WHILE MoL::MoL_Stepsize_Bad
	{
	  STORAGE: SandRScratchSpace
	  #   STORAGE: ComplexScratchSpace
	  #   STORAGE: ComplexSandRScratchSpace
	  #   STORAGE: ComplexArrayScratchSpace
	  #   STORAGE: ComplexArraySandRScratchSpace
	} "A single Cactus evolution step using MoL"
      }
    }
    else
    {
      if (MoL_Max_Evolved_Array_Size)
      {
	schedule GROUP MoL_Evolution AT Evol WHILE MoL::MoL_Stepsize_Bad
	{
# 	  STORAGE: ArrayScratchSpace
# 	  STORAGE: ArraySandRScratchSpace
	  #   STORAGE: ComplexScratchSpace
	  #   STORAGE: ComplexSandRScratchSpace
	  #   STORAGE: ComplexArrayScratchSpace
	  #   STORAGE: ComplexArraySandRScratchSpace
	} "A single Cactus evolution step using MoL"
      }
      else
      {
	schedule GROUP MoL_Evolution AT Evol WHILE MoL::MoL_Stepsize_Bad
	{
	  #   STORAGE: ComplexScratchSpace
	  #   STORAGE: ComplexSandRScratchSpace
	  #   STORAGE: ComplexArrayScratchSpace
	  #   STORAGE: ComplexArraySandRScratchSpace
	} "A single Cactus evolution step using MoL"
      }
    }
  }
}
else 
{
  if (MoL_Num_Evolved_Vars)
  {
    if (MoL_Num_SaveAndRestore_Vars)
    {
      if (MoL_Max_Evolved_Array_Size)
      {
	schedule GROUP MoL_Evolution AT Evol WHILE MoL::MoL_Stepsize_Bad
	{
	  STORAGE: SandRScratchSpace
# 	  STORAGE: ArraySandRScratchSpace
	  #   STORAGE: ComplexScratchSpace
	  #   STORAGE: ComplexSandRScratchSpace
	  #   STORAGE: ComplexArrayScratchSpace
	  #   STORAGE: ComplexArraySandRScratchSpace
	} "A single Cactus evolution step using MoL"
      }
      else
      {
	schedule GROUP MoL_Evolution AT Evol WHILE MoL::MoL_Stepsize_Bad
	{
	  STORAGE: SandRScratchSpace
	  #   STORAGE: ComplexScratchSpace
	  #   STORAGE: ComplexSandRScratchSpace
	  #   STORAGE: ComplexArrayScratchSpace
	  #   STORAGE: ComplexArraySandRScratchSpace
	} "A single Cactus evolution step using MoL"
      }
    }
    else
    {
      if (MoL_Max_Evolved_Array_Size)
      {
	schedule GROUP MoL_Evolution AT Evol WHILE MoL::MoL_Stepsize_Bad
	{
# 	  STORAGE: ArraySandRScratchSpace
	  #   STORAGE: ComplexScratchSpace
	  #   STORAGE: ComplexSandRScratchSpace
	  #   STORAGE: ComplexArrayScratchSpace
	  #   STORAGE: ComplexArraySandRScratchSpace
	} "A single Cactus evolution step using MoL"
      }
      else
      {
	schedule GROUP MoL_Evolution AT Evol WHILE MoL::MoL_Stepsize_Bad
	{
	  #   STORAGE: ComplexScratchSpace
	  #   STORAGE: ComplexSandRScratchSpace
	  #   STORAGE: ComplexArrayScratchSpace
	  #   STORAGE: ComplexArraySandRScratchSpace
	} "A single Cactus evolution step using MoL"
      }
    }
  }
  else 
  {
    if (MoL_Num_SaveAndRestore_Vars)
    {
      if (MoL_Max_Evolved_Array_Size)
      {
	schedule GROUP MoL_Evolution AT Evol WHILE MoL::MoL_Stepsize_Bad
	{
	  STORAGE: SandRScratchSpace
# 	  STORAGE: ArraySandRScratchSpace
	  #   STORAGE: ComplexScratchSpace
	  #   STORAGE: ComplexSandRScratchSpace
	  #   STORAGE: ComplexArrayScratchSpace
	  #   STORAGE: ComplexArraySandRScratchSpace
	} "A single Cactus evolution step using MoL"
      }
      else
      {
	schedule GROUP MoL_Evolution AT Evol WHILE MoL::MoL_Stepsize_Bad
	{
	  STORAGE: SandRScratchSpace
	  #   STORAGE: ComplexScratchSpace
	  #   STORAGE: ComplexSandRScratchSpace
	  #   STORAGE: ComplexArrayScratchSpace
	  #   STORAGE: ComplexArraySandRScratchSpace
	} "A single Cactus evolution step using MoL"
      }
    }
    else
    {
      if (MoL_Max_Evolved_Array_Size)
      {
	schedule GROUP MoL_Evolution AT Evol WHILE MoL::MoL_Stepsize_Bad
	{
# 	  STORAGE: ArraySandRScratchSpace
	  #   STORAGE: ComplexScratchSpace
	  #   STORAGE: ComplexSandRScratchSpace
	  #   STORAGE: ComplexArrayScratchSpace
	  #   STORAGE: ComplexArraySandRScratchSpace
	} "A single Cactus evolution step using MoL"
      }
      else
      {
	schedule GROUP MoL_Evolution AT Evol WHILE MoL::MoL_Stepsize_Bad
	{
	  #   STORAGE: ComplexScratchSpace
	  #   STORAGE: ComplexSandRScratchSpace
	  #   STORAGE: ComplexArrayScratchSpace
	  #   STORAGE: ComplexArraySandRScratchSpace
	} "A single Cactus evolution step using MoL"
      }
    }
  }
}


if (MoL_Num_Evolved_Vars_Slow)
{
   STORAGE: ScratchSpaceSlow
}

######################################################
###  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
{
} "MoL internal setup for the evolution step"

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

########################################################
###  Note that the option LEVEL here is to ensure    ###
###  that the time is set once per refinement level  ###
###  and not once overall.                           ###
########################################################

schedule MoL_SetTime IN MoL_StartStep 
{
  LANG: C
  OPTIONS: LEVEL
} "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
{
} "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.                ###
#################################################################

if (!skip_initial_copy)
{
  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
{
} "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 time step is initialised to zero  ###
##############################################

if (init_RHS_zero)
{
  schedule MoL_InitRHS IN MoL_Step BEFORE MoL_CalcRHS
  {
    LANG: C
  } "Initialise the RHS functions"
}

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

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

#############################################################
###  Any modification of the RHS done by external thorns  ###
###  (dissipation etc.) should be done in MoL_PostRHS     ###
#############################################################

schedule GROUP MoL_PostRHS IN MoL_Step AFTER MoL_CalcRHS BEFORE (MoL_NaNCheck MoL_Add) 
{
} "Modify RHS functions"

###############################################################
###  Certain operations, specifically boundary conditions   ###
###  applied to the RHS must be performed after all other   ###
###  operations. These can be scheduled in this bin, under  ###
###  the assumption that things like dissipation are        ###
###  scheduled in the MoL_PostRHS bin. It is the users      ###
###  problem to ensure that this is really done.            ###
###############################################################

schedule GROUP MoL_RHSBoundaries IN MoL_Step AFTER MoL_PostRHS BEFORE (MoL_NaNCheck MoL_Add)
{
} "Any 'final' modifications to the RHS functions (boundaries etc.)"

#####################################################
###  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 MoL_PostStepModify)
  {
    LANG: C
  } "Updates calculated with a generic method"
}
else if (CCTK_Equals(ODE_Method,"Euler")) 
{
  schedule MoL_EulerAdd AS MoL_Add IN MoL_Step AFTER MoL_CalcRHS BEFORE MoL_PostStep
  {
    LANG: C
  } "Updates calculated with the Euler 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,"RK4"))
{
  schedule MoL_RK4Add AS MoL_Add IN MoL_Step AFTER MoL_CalcRHS BEFORE MoL_PostStep
  {
    LANG: C
  } "Updates calculated with the efficient Runge-Kutta 4 method"
}
else if (CCTK_Equals(ODE_Method,"RK45") || CCTK_Equals(ODE_Method,"RK45CK"))
{
  STORAGE: ErrorEstimate ErrorScalars

  schedule MoL_RK45Add AS MoL_Add IN MoL_Step AFTER MoL_CalcRHS BEFORE MoL_PostStep
  {
    LANG: C
  } "Updates calculated with the Runge-Kutta 45 method"
}
else if (CCTK_Equals(ODE_Method,"RK65")) 
{
  STORAGE: ErrorEstimate ErrorScalars

  schedule MoL_RK65Add AS MoL_Add IN MoL_Step AFTER MoL_CalcRHS BEFORE MoL_PostStep
  {
    LANG: C
  } "Updates calculated with the Runge-Kutta 65 method"
}
else if (CCTK_Equals(ODE_Method,"RK87")) 
{
  STORAGE: ErrorEstimate ErrorScalars

  schedule MoL_RK87Add AS MoL_Add IN MoL_Step AFTER MoL_CalcRHS BEFORE MoL_PostStep
  {
    LANG: C
  } "Updates calculated with the Runge-Kutta 87 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"
}
else if (CCTK_Equals(ODE_Method,"AB"))
{
  schedule MoL_ABAdd AS MoL_Add IN MoL_Step AFTER MoL_CalcRHS BEFORE MoL_PostStep
  {
    LANG: C
  } "Updates calculated with the Adams-Bashforth"
}
else if (CCTK_Equals(ODE_Method,"RK2-MR-2:1")) 
{
  schedule MoL_RK2_MR_2_1_Add AS MoL_Add IN MoL_Step AFTER MoL_CalcRHS BEFORE MoL_PostStep
  {
    LANG: C
  } "Updates calculated with the multirate Runge-Kutta 2 method"
}
else if (CCTK_Equals(ODE_Method,"RK4-MR-2:1")) 
{
  schedule MoL_RK4_MR_2_1_Add AS MoL_Add IN MoL_Step AFTER MoL_CalcRHS BEFORE MoL_PostStep
  {
    LANG: C
  } "Updates calculated with the multirate Runge-Kutta 4 method"
}
else if (CCTK_Equals(ODE_Method,"RK4-RK2")) 
{
  schedule MoL_RK4_RK2_Add AS MoL_Add IN MoL_Step AFTER MoL_CalcRHS BEFORE MoL_PostStep
  {
    LANG: C
  } "Updates calculated with the multirate RK4/RK2 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
{
} "The group for physics thorns to schedule boundary calls etc."

if (set_ID_boundaries)
{
  schedule GROUP MoL_PostStep AT PostInitial
  {
  } "Ensure that everything is correct after the initial data have been set up"
}

##################################################################
###  Schedule the PostStep parts in the Carpet 'PostRegrid'    ###
###  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.              ###
##################################################################

schedule GROUP MoL_PostStep AT PostRegrid
{
} "Ensure that everything is correct after regridding"

##################################################################
###  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.              ###
##################################################################

if (set_ID_boundaries)
{
  schedule GROUP MoL_PostStep AT PostRestrictInitial
  {
  } "Ensure that everything is correct after restriction"
}

schedule GROUP MoL_PostStep AT PostRestrict
{
} "Ensure that everything is correct after restriction"

##############################################################
###  Schedule the PostStep parts after recovery            ###
###  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.          ###
##############################################################

if(run_MoL_PostStep_in_Post_Recover_Variables) {
schedule GROUP MoL_PostStep AT Post_Recover_Variables
{
} "Ensure that everything is correct after recovery"
}

#########################################################################
###  Physics thorns can enforce constraints in PostStepModify.        ###
###  The difference between PostStep and PostStepModify is that       ###
###  PostStep is scheduled at many other occasions, whereas the       ###
###  PostStepModify is only scheduled during evolution.               ###
#########################################################################

schedule GROUP MoL_PostStepModify IN MoL_Step AFTER MoL_Add BEFORE MoL_PostStep
{
} "The group for physics thorns to schedule enforcing constraints"

schedule GROUP MoL_PostStepModify At PostInitial BEFORE MoL_PostStep
{
} "The group for physics thorns to schedule enforcing constraints"

##########################################################################
###  Schedule a pseudo-evolution group to handle variables which are   ###
###  not evolved, but which should be calculated at every time step.   ###
##########################################################################

schedule GROUP MoL_PseudoEvolution AT PostInitial AFTER MoL_PostStep
{
} "Calculate pseudo-evolved quantities"

schedule GROUP MoL_PseudoEvolution AT Evol AFTER MoL_Evolution
{
} "Calculate pseudo-evolved quantities"

schedule GROUP MoL_PseudoEvolutionBoundaries AT PostRegridInitial AFTER MoL_PostStep
{
} "Apply boundary conditions to pseudo-evolved quantities"

schedule GROUP MoL_PseudoEvolutionBoundaries AT PostRegrid AFTER MoL_PostStep
{
} "Apply boundary conditions to pseudo-evolved quantities"

schedule GROUP MoL_PseudoEvolutionBoundaries AT PostRestrictInitial AFTER MoL_PostStep
{
} "Apply boundary conditions to pseudo-evolved quantities"

schedule GROUP MoL_PseudoEvolutionBoundaries AT PostRestrict AFTER MoL_PostStep
{
} "Apply boundary conditions to pseudo-evolved quantities"

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

schedule MoL_DecrementCounter IN MoL_Step AFTER MoL_Add BEFORE (MoL_PostStep MoL_PostStepModify)
{
  LANG: C
  OPTIONS: LEVEL
} "Alter the counter number"

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

schedule MoL_ResetDeltaTime IN MoL_Step AFTER (MoL_PostStep MoL_PostStepModify)
{
  LANG: C
  OPTIONS: LEVEL
} "If necessary, change the timestep"

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

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

###################################################
###  Loop until the step size was small enough  ###
###################################################

if (adaptive_stepsize)
{
  # Adaptive step size control
  schedule MoL_InitAdaptiveError IN MoL_Evolution AFTER MoL_PostStep
  {
    LANG: C
    OPTIONS: LEVEL
  } "Control the step size: initialize error check variables"
  
  schedule MoL_FindAdaptiveError IN MoL_Evolution AFTER MoL_InitAdaptiveError
  {
    LANG: C
  } "Control the step size: compute error check variables"
  
  schedule MoL_ReduceAdaptiveError IN MoL_Evolution AFTER MoL_FindAdaptiveError
  {
    LANG: C
    OPTIONS: LEVEL
  } "Control the step size: reduce error check variables"

  schedule MoL_SetEstimatedDt AT POSTSTEP 
  {
    LANG: C
    OPTIONS: LEVEL
  } "Control the step size: set the new timestep"
}
else
{
  schedule MoL_FinishLoop IN MoL_Evolution AFTER MoL_Step
  {
    LANG: C
    OPTIONS: LEVEL
  } "Control the step size"
}

################################################################
###  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"