aboutsummaryrefslogtreecommitdiff
path: root/schedule.ccl
blob: acb02cb8e74e8315ebfd38fc957a405d19e14e34 (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
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
# Schedule definitions for thorn Whisky
# $Header$

#######################################################################
### We leave the storage on all the time for the variables required ###
### by MoL. There is probably a better way of doing this.           ###
#######################################################################

#################################################
### Storage for the extra timelevels for the  ###
### use of MoL with Einstein                  ###
#################################################

if (timelevels == 3)
{
  STORAGE:dens[3]
  STORAGE:tau[3]
  STORAGE:scon[3]
  STORAGE:w_lorentz[3]
  if (number_of_particles)
  {
    STORAGE:particles[3]
  }
  STORAGE: ADMBase::metric[3], ADMBase::curv[3]
  STORAGE: ADMBase::lapse[3]
}
else
{
  STORAGE:dens[2]
  STORAGE:tau[2]
  STORAGE:scon[2]
  STORAGE:w_lorentz[2]
  if (number_of_particles)
  {
    STORAGE:particles[2]
  }
  STORAGE: ADMBase::metric[2], ADMBase::curv[2]
  STORAGE: ADMBase::lapse[2]
}
STORAGE:whisky_reflevel
STORAGE:densrhs
STORAGE:taurhs
STORAGE:srhs
STORAGE:whisky_eos_scalars
STORAGE:whisky_minima
STORAGE:whisky_scalars
#STORAGE:fluxweightvolume
#STORAGE:cell_surface
if (number_of_particles)
{
  STORAGE:particle_rhs
  STORAGE:particle_arrays
}

if (evolve_tracer)
{
  STORAGE:whisky_tracers[3]
  STORAGE:whisky_cons_tracers[3]
  STORAGE:whisky_tracer_rhs
}

# leave this here for compatibility with older code, should not be used anymore
# and go out at some point
schedule group Whisky_Initial IN HydroBase_Initial
{
} "Whisky initial data group"

#################################################
### Storage for the extra timelevels for the  ###
### use of MoL with Einstein                  ###
#################################################

if (timelevels == 3)
{
  STORAGE: ADMBase::metric[3], ADMBase::curv[3]
  STORAGE: ADMBase::lapse[3]
}
else
{
  STORAGE: ADMBase::metric[2], ADMBase::curv[2]
  STORAGE: ADMBase::lapse[2]
}
if (!CCTK_Equals(initial_shift,"none")) 
{
  if (timelevels == 3)
  {  
    STORAGE: ADMBase::shift[3]
  }
  else
  {
    STORAGE: ADMBase::shift[2]
  }
  if (CCTK_Equals(shift_evolution_method,"Comoving"))
  {
    if (timelevels == 3)
    {  
      STORAGE: whisky_coords[3]
    }
    else
    {
      STORAGE: whisky_coords[2]
    }
    STORAGE: whisky_coords_rhs

    schedule Whisky_SetUpCoords IN HydroBase_Initial
    {
      LANG: Fortran
    } "Set up the coordinates for use with the comoving shift"

    schedule Whisky_EvolveCoords IN WhiskyRHS
    {
      LANG: Fortran
    } "Evolve the coordinates for the comoving shift"

    schedule Whisky_ComovingShift IN HydroBase_PostStep AFTER HydroBase_Con2Prim
    {
      LANG: Fortran
    } "Comoving shift"

  }           
}

##############################################
### Storage for the conformal state scalar ###
##############################################

STORAGE: conformal_state

###############################
### Register startup banner ###
###############################

schedule Whisky_Startup AT WRAGH AFTER EOSBase_GeneralRegister AFTER HydroBase_StartUp
{
  LANG: Fortran
} "Startup banner"

#########################################
### Register the masks with SpaceMask ###
#########################################

schedule Whisky_RegisterMask AT STARTUP
{
  LANG: C
} "Register the hydro masks"


####################################
### Check the parameters are ok. ###
####################################

schedule Whisky_ParamCheck AT PARAMCHECK
{
  LANG: Fortran
} "Check parameters"

######################################
### Standard symmetry registration ###
######################################

schedule Whisky_InitSymBound AT BASEGRID
{
  LANG: Fortran
} "Schedule symmetries"

##########################################################
### Schedule the flux weighting calculation at initial ###
##########################################################

# schedule Whisky_Weights AT CCTK_INITIAL
# {
#   LANG: C
# } "Set up the weighting terms for the fluxes"

###################################
### Register with GZPatchSystem ###
###################################

SCHEDULE GROUP GZPatchSystem_register
{
} "Tell Cactus that this group exists, but is not scheduled from here"

SCHEDULE Whisky_register_GZPatchSystem IN GZPatchSystem_register
{
  LANG: C
  OPTIONS: meta
} "register to-be-interpatch-synchronized variables with GZPatchSystem"

##################################
### Set the handle for the EOS ###
##################################

schedule Whisky_EOSHandle AT CCTK_INITIAL before HydroBase_Initial
{
  LANG: C
} "Set the EOS number"

schedule Whisky_EOSHandle AT CCTK_POST_RECOVER_VARIABLES
{
  LANG: C
} "Set the EOS number"

####################################
### Setup of rho minima scalars  ###
####################################

schedule Whisky_Rho_Minima_Setup  AT CCTK_Initial BEFORE HydroBase_Initial
{
  LANG: Fortran
} "Set up minimum for the rest-mass density in the atmosphere (before intial data)"

if (rho_abs_min_after_recovery > 0.0)
{
  schedule Whisky_Change_Rho_Minimum_At_Recovery AT CCTK_POST_RECOVER_VARIABLES
  {
    LANG: Fortran
  } "Set up minimum for the rest-mass density in the atmosphere (before intial data)"
}

if (CCTK_IsThornActive("PUGH" ))
{
   schedule Whisky_Rho_Minima_Setup_Final_PUGH  AT CCTK_PostInitial BEFORE MoL_PostStep
   {
     LANG: C
   } "Set the value of the rest-mass density of the atmosphere which will be used during the evolution (PUGH)"
}  
else if (CCTK_IsThornActive("Carpet"))
 {
#   schedule Whisky_Rho_Minima_Setup_Final  AT CCTK_PostInitial BEFORE MoL_PostStep
   schedule Whisky_Rho_Minima_Setup_Final AT CCTK_PostPostInitial BEFORE Con2Prim
   {
     LANG: C
   } "Set the value of the rest-mass density of the atmosphere which will be used during the evolution"
 }    

# this is a temporary hack, because carpet does allow only one loop over the levels for Basegrid-Iniital-Postinitial
# so we must compute whisky_rho_min at postpostinitial and the constraints after this (and afer C2P)
#  schedule GROUP ADMConstraintsGroup at CCTK_POSTINITIAL after (MoL_PostStep MoL_PostInitial)
  schedule GROUP ADMConstraintsGroup at CCTK_POSTPOSTINITIAL
  {
  } "Evaluate ADM constraints, and perform symmetry boundary conditions"

######################################################################
### Setup and remove the coefficient arrays for ENO reconstruction ###
######################################################################

if (CCTK_Equals(recon_method,"eno")) 
{

  schedule Whisky_ENOSetup AT CCTK_Basegrid
  {
    LANG:Fortran
  } "Coefficients for ENO reconstruction"

  schedule Whisky_ENOShutdown AT CCTK_Terminate BEFORE Driver_Terminate
  {
    LANG:Fortran
  } "Deallocate ENO coefficients"

}

######################################################################
### This routine is a bit strangely situated, as it's really to do ###
### with initial data. There may be a better place for it later.   ###
### What it does is reset the hydrodynamical quantities if we have ###
### changed the EoS between constructing the initial model and     ###
### evolving. Essentially, we assume that the polytropic EoS that  ###
### we are using for the atmosphere is correct, and reset eps      ###
### given the values for rho. We then can call the primitive to    ###
### conservative routine to get the pressure.                      ###
######################################################################
if (EoS_Change)
{
  if (CCTK_Equals(EoS_Change_type,"Gamma"))
  {
    schedule Whisky_EoSChangeGamma AT CCTK_Initial AFTER HydroBase_Initial BEFORE Whisky_IVP
    { 
      LANG: Fortran
    } "Reset the specific internal energy if the EoS changes between ID and evolution"
  }
  if (CCTK_Equals(EoS_Change_type,"K"))
  {
    schedule Whisky_EoSChangeK AT CCTK_Initial AFTER HydroBase_Initial BEFORE Whisky_IVP
    { 
      LANG: Fortran
    } "Reset the hydro variables if the EoS (K) changes between ID and evolution"
  }
  if (CCTK_Equals(EoS_Change_type,"GammaKS"))
  {
    schedule Whisky_EoSChangeGammaK_Shibata AT CCTK_Initial AFTER HydroBase_Initial BEFORE Whisky_IVP
    { 
      LANG: Fortran
      SYNC: dens
      SYNC: tau
      SYNC: scon
      SYNC: w_lorentz
      SYNC: hydrobase::rho
      SYNC: hydrobase::press
      SYNC: hydrobase::eps
      SYNC: hydrobase::vel
    } "Reset the hydro variables if the EoS Gamma and K change between ID and evolution"
  }
}

#####################################
### Setup of dens minima scalars  ###
#####################################
# commented out, since unused for a long time
#schedule Whisky_Dens_Minima_Setup AT CCTK_Postinitial
#{
#  LANG: Fortran
#} "Set up and check minima for dens"

#################################################
### Standard registration of variables to MoL ###
#################################################

schedule Whisky_Register IN MoL_Register
{
  LANG: C
} "Register variables for MoL"

####################################################
### Setup of any scalars for efficiency purposes ###
####################################################

schedule Whisky_Scalar_Setup IN MoL_PreStep
{
  LANG: Fortran
} "Set up and check scalars for efficiency"

################################################
### We might want to switch off evolution... ###
################################################

if (CCTK_EQUALS(evolution_method, "whisky")) {

STORAGE:whisky_atmosphere_mask
STORAGE:whisky_atmosphere_descriptors

schedule Whisky_SetupMask AT CCTK_Initial BEFORE HydroBase_Initial
{
  LANG: Fortran
} "Initialize the atmosphere mask"

# If using mesh refinement
schedule Whisky_SetupMask AT POSTREGRID BEFORE MoL_PostStep AFTER (MaskOne,MaskZero)
{
  LANG: Fortran
} "Initialize the atmosphere mask"

schedule Whisky_SetupMask AT POSTRESTRICTINITIAL BEFORE HydroBase_PostStep AFTER (MaskOne,MaskZero)
{
  LANG: Fortran
} "Initialize the atmosphere mask"

if (wk_atmosphere)
{
  schedule Whisky_InitAtmosMask AT CCTK_PostInitial
  {
    LANG: Fortran
  } "Set the atmosphere mask"

  schedule Whisky_InitAtmosMask AT POSTREGRID AFTER Whisky_SetupMask BEFORE MoL_PostStep
  {
    LANG: Fortran
  } "Set the atmosphere mask"

  schedule Whisky_InitAtmosMask AT POSTRESTRICTINITIAL AFTER Whisky_SetupMask BEFORE HydroBase_PostStep
  {
    LANG: Fortran
  } "Set the atmosphere mask"
}

schedule Whisky_SetupDescriptors AT CCTK_Initial BEFORE HydroBase_Initial
{
  LANG: C
} "Get and store the mask descriptors"

# If using mesh refinement


#####################################################################
### The group to calculate the update term for MoL. This contains ###
### the calculation of the source terms and the flux update.      ###
#####################################################################

schedule group WhiskyRHS IN HydroBase_RHS
{
  STORAGE:whisky_scalars
} "Calculate the update terms"

#============================================
# Uncomment the following lines for debugging
#
# schedule Whisky_Scalar_Setup AT CCTK_Initial
# {
#   LANG: Fortran
# } "Set up and check scalars for efficiency"
# 
# schedule group WhiskyRHS AT CCTK_Analysis
# {
#   STORAGE:whisky_scalars
#   TRIGGERS: densrhs
#   TRIGGERS: srhs
#   TRIGGERS: taurhs
# } "Calculate the update terms"
# 
# STORAGE:whisky_fluxes
# STORAGE:whisky_con_bext
# STORAGE:whisky_prim_bext
# STORAGE:EOS_temps
# 
# schedule Primitive2ConservativeCells AT CCTK_POSTINITIAL AFTER GZPatchSystem_cxform BEFORE MoL_PostStep
# {
#   LANG: Fortran
# } "Convert to conserved variables"
#
#==============================================

if (number_of_particles)
{
  schedule WhiskyParticleInitial AT CCTK_Initial BEFORE HydroBase_Initial
  {
    OPTIONS: GLOBAL
    LANG: Fortran
  } "Initial data for the particle arrays"

  schedule WhiskyParticleRHS IN WhiskyRHS
  {
    OPTIONS: GLOBAL
    LANG: Fortran
  } "Update terms for the particles"
}

####################################################################
### Do the source terms first, as this does not require the loop ###
### over the different directions                                ###
####################################################################

schedule SourceTerms IN WhiskyRHS BEFORE FluxTerms
{
  LANG: Fortran
} "Source term calculation"

#################################################################
### Initial setup for the loop over the different directions. ###
#################################################################

schedule WhiskyStartLoop IN WhiskyRHS BEFORE FluxTerms
{
  LANG: Fortran
  OPTIONS: level
} "Set the flux_direction variable"

###################################################################
### The group to calculate the update terms from the fluxes. We ###
### do this as a loop over each direction to reduce coding and  ###
### hopefully to reduce bugs. The parameter flux_direction runs ###
### from (3->0) corresponding to (z->x) and stopping. At each   ###
### step in the loop the data is reconstructed and then the     ###
### fluxes are computed by the Riemann solve.                   ###
###################################################################

#######################################################
### Switch between RSA FV and flux split FD methods ###
#######################################################

if (CCTK_Equals(method_type, "RSA FV"))
{

  if (evolve_tracer)
  {  
    schedule group FluxTerms IN WhiskyRHS WHILE Whisky::flux_direction
    {
      STORAGE:whisky_prim_bext
      STORAGE:whisky_con_bext
      STORAGE:whisky_fluxes
      STORAGE:whisky_tracer_cons_bext
      STORAGE:whisky_tracer_prim_bext
      STORAGE:whisky_tracer_flux
    } "Calculation of intercell fluxes"
  }
  else
  {
    schedule group FluxTerms IN WhiskyRHS WHILE Whisky::flux_direction
    {
      STORAGE:whisky_prim_bext
      STORAGE:whisky_con_bext
      STORAGE:whisky_fluxes
    } "Calculation of intercell fluxes"
  }
    
##############################################################
### This is a wrapper call to the reconstruction routines. ###
##############################################################

  if (CCTK_Equals(whisky_eos_type,"General")) {

    schedule Reconstruction IN FluxTerms AS Reconstruct
    {
      LANG: Fortran
    } "Reconstruct the functions at the cell boundaries"
    
  }
  else if (CCTK_Equals(whisky_eos_type,"Polytype")) {
    
    schedule ReconstructionPolytype IN FluxTerms AS Reconstruct
    {
      LANG: Fortran
    } "Reconstruct the functions at the cell boundaries"
    
  }
  
  if (set_trivial_rp_grid_function)
  {
    schedule Set_Trivial_Riemann_Problem_Grid_Function \
    IN FluxTerms AFTER Reconstruct
    {
      LANG: C
      SYNC: whisky_trivial_rp_gf_group
    } "Set the gridfunction for the trp (for debugging only)"
  }
  
######################################################
### This is a wrapper call to the Riemann solvers. ###
######################################################

  if (use_eosgeneral) 
  {
    schedule RiemannSolveGeneral IN FluxTerms AFTER Whisky_Convert AS Riemann
    {
      LANG: Fortran
      STORAGE: EOS_temps
      STORAGE: RoeAverage_temps
    } "Solve the local Riemann problems"
  }
  else if (CCTK_Equals(whisky_eos_type,"General")) {
    
    schedule RiemannSolve IN FluxTerms AFTER Whisky_Convert AS Riemann
    {
      LANG: Fortran
      STORAGE: EOS_temps
    } "Solve the local Riemann problems"
    
  }
  else if (CCTK_Equals(whisky_eos_type,"Polytype")) {
    
    schedule RiemannSolvePolytype IN FluxTerms AFTER Whisky_Convert AS Riemann
    {
      LANG: Fortran
      STORAGE: EOS_temps
    } "Solve the local Riemann problems"
  }
  
}
else if (CCTK_Equals(method_type, "Flux split FD"))
{

  STORAGE:fs_alpha

  if (evolve_tracer)
  {

    schedule group FluxTerms IN WhiskyRHS WHILE Whisky::flux_direction 
    {
      STORAGE: whisky_fluxes
      STORAGE: whisky_tracer_flux
    } "Calculation of intercell fluxes"

    schedule Whisky_FSAlpha IN FluxTerms BEFORE Whisky_SplitFlux
    {
      LANG: Fortran
    } "Compute the maximum characteristic speeds"

    schedule Whisky_SplitFlux IN FluxTerms AS Reconstruct
    {
      LANG: Fortran
      STORAGE: flux_splitting
      STORAGE: whisky_tracer_flux_splitting
      SYNC: whisky_fluxes
    } "Compute the fluxes using WENO5 FD + Lax-Friedrichs splitting"

  }
  else
  {

    schedule group FluxTerms IN WhiskyRHS WHILE Whisky::flux_direction 
    {
      STORAGE: whisky_fluxes
    } "Calculation of intercell fluxes"

    schedule Whisky_FSAlpha IN FluxTerms BEFORE Whisky_SplitFlux
    {
      LANG: Fortran
    } "Compute the maximum characteristic speeds"

    schedule Whisky_SplitFlux IN FluxTerms AS Reconstruct
    {
      LANG: Fortran
      STORAGE: flux_splitting
      SYNC: whisky_fluxes
    } "Compute the fluxes using WENO5 FD + Lax-Friedrichs splitting"

  }

}

###########################################################
### After calculating the fluxes, calculate the update. ###
###########################################################

schedule UpdateCalculation IN FluxTerms AFTER Riemann
{
  LANG: Fortran
} "Calculate the update term from the fluxes"
  
#################################
### Advance the loop counter. ###
#################################

schedule WhiskyAdvanceLoop IN FluxTerms AFTER UpdateCalculation
{
  LANG: Fortran
  OPTIONS: level
} "Decrement the flux_direction variable"

###########################################################
### If we're in the atmosphere or inside the excision   ###
### region then we don't want to do any updating (in    ###
### fact if we're inside the excision region we don't   ###
### want to calculate the fluxes, but we'll worry about ###
### that later). Just zero the update terms where       ###
### certain conditions are violated.                    ###
###########################################################

schedule WhiskyUpdateAtmosphereMask IN WhiskyRHS AFTER FluxTerms
{
  LANG: Fortran
} "Alter the update terms if inside the atmosphere region"

###############################################################
### After we've done the update, there's a few things to do ###
###############################################################

# This should not be used anymore and be removed after some time
schedule group Whisky_PostStep IN HydroBase_PostStep
{
} "Post step tasks for Whisky"

#################################################################
### After MoL has updated the conserved variables, we need to ###
### convert back to primitive variables. This is a wrapper    ###
### over the entire grid.                                     ###
#################################################################

########################################################
### Find the refinement level that is being computed ###
########################################################

schedule Whisky_RefinementLevel IN MoL_PostStep BEFORE (SetMetricTemps,HydroBase_PostStep)
{
  LANG: Fortran
} "Calculate current refinement level"

schedule Whisky_RefinementLevel AT CCTK_PostStep
{
  LANG: Fortran
} "Calculate current refinement level (for the check of the C2P mask)"

schedule Whisky_RefinementLevel AT POSTREGRIDINITIAL 
{
  LANG: Fortran
} "Calculate current refinement level"

schedule Whisky_RefinementLevel AT INITIAL BEFORE HydroBase_Initial
{
  LANG: Fortran
} "Calculate current refinement level"


if (use_eosgeneral) 
{

  STORAGE:Metric_temps

  schedule SetMetricTemps IN MoL_PostStep BEFORE HydroBase_PostStep
  {
    LANG: Fortran
    SYNC: metric_temps
  } "Set the temporary metric terms"

  schedule SetMetricTemps AT POSTRESTRICTINITIAL BEFORE HydroBase_PostStep
  {
    LANG: Fortran
    SYNC: metric_temps
  } "Set the temporary metric terms"


  if (CCTK_Equals(whisky_eos_type,"General")) 
  {

    schedule Conservative2PrimitiveGeneral IN HydroBase_Con2Prim AS Con2Prim
    {
      LANG: Fortran
      STORAGE: Con2Prim_temps
    } "Convert back to primitive variables (general)"

  }
  else if (CCTK_Equals(whisky_eos_type,"Polytype")) 
  {

    schedule Con2PrimPolytypeGeneral IN HydroBase_Con2Prim AS Con2Prim
    {
      LANG: Fortran
      STORAGE: Con2Prim_temps
    } "Convert back to primitive variables (polytype)"

  }

}  
else if (CCTK_Equals(whisky_eos_type,"General")) 
{

  schedule Conservative2Primitive IN HydroBase_Con2Prim AS Con2Prim
  {
    LANG: Fortran
  } "Convert back to primitive variables (general)"

}
else if (CCTK_Equals(whisky_eos_type,"Polytype")) 
{
  
  schedule Conservative2PrimitivePolytype IN HydroBase_Con2Prim AS Con2Prim
  {
    LANG: Fortran
  } "Convert back to primitive variables (polytype)"

}

#################################################################
### Having finished all the updates, we apply the boundary    ###
### conditions and synchronize the conservative and primitive ###
### variables. All other grid functions are reset only in the ###
### interior of the grid and are totally reset at every step, ###
### and so synchronization is not necessary.                  ###
#################################################################

#schedule Whisky_Boundaries IN HydroBase_PostStep AFTER Con2Prim

if (evolve_tracer)
{
  STORAGE:whisky_tracers[3]
  STORAGE:whisky_cons_tracers[3]
  STORAGE:whisky_tracer_rhs
}

if (outflow_boundaries)
{
  schedule Whisky_OutflowBoundaries IN HydroBase_PostStep BEFORE Whisky_Boundaries
  {
    LANG: Fortran
  } "Outflow boundaries over only some of the domain"
}

# This should not be used anymore and should be removed after some time
schedule group Do_Whisky_Boundaries IN HydroBase_Boundaries
{
} "Whisky Boundary conditions group"

if (evolve_tracer)
{
  schedule Whisky_Boundaries IN HydroBase_Select_Boundaries
  {
    LANG: Fortran
    OPTIONS: LEVEL
    SYNC: dens
    SYNC: tau
    SYNC: scon
    SYNC: w_lorentz
    SYNC: HydroBase::rho
    SYNC: HydroBase::press
    SYNC: HydroBase::eps
    SYNC: HydroBase::vel
    SYNC: whisky_cons_tracers
    SYNC: whisky_tracers
  } "Select Whisky boundary conditions"
} else
{
  schedule Whisky_Boundaries IN HydroBase_Select_Boundaries
  {
    LANG: Fortran
    OPTIONS: LEVEL
    SYNC: dens
    SYNC: tau
    SYNC: scon
    SYNC: w_lorentz
    SYNC: HydroBase::rho
    SYNC: HydroBase::press
    SYNC: HydroBase::eps
    SYNC: HydroBase::vel
  } "Select Whisky boundary conditions"
}

############################################################
### Compute first differences of rho for mesh refinement ###
############################################################

# commented out (2006.08.22) since unused, for the time being
#STORAGE:DiffRho

#schedule Whisky_DiffRho IN HydroBase_PostStep AFTER Whisky_ApplyBCs
#{
#  LANG: Fortran
#} "Compute relative differences in rho"


# older version
# schedule Whisky_DiffRho AT POSTREGRID
# {
#   LANG: Fortran
# } "Compute relative differences in rho"

################################################################
### If a point has been marked as requiring resetting to the ###
### atmosphere, this is where we do it.                      ###
###                                                          ###
### You didn't see this abuse of MoL. Nothing to see here,   ###
### move along.                                              ###
################################################################

schedule Whisky_AtmosphereReset IN MoL_Evolution AFTER MoL_Step BEFORE HydroBase_Boundaries AFTER MoL_RestoreSandR
{
  LANG: Fortran
} "Reset the atmosphere"

schedule group HydroBase_Boundaries IN MoL_Evolution AFTER MoL_Step
{
} "HydroBase Boundary conditions group"

} # end of  if (CCTK_EQUALS(hydrobase::evolution_method, "whisky"))
  
if (set_trivial_rp_grid_function)
{
  STORAGE: whisky_trivial_rp_gf_group
}

if (ppm_mppm_debug_eigenvalues)
{
  STORAGE: whisky_mppm_eigenvalues
}

if (compute_DCandMaxima)
{
  STORAGE: whisky_maxima_location
  STORAGE: whisky_maxima_position
  STORAGE: whisky_maxima_iteration
  STORAGE: whisky_maxima_separation
  STORAGE: maxrho_global

  schedule Whisky_InitFindMaxima AT Initial
  {
    LANG:Fortran
    OPTIONS: GLOBAL
  } "Initialize the scalars for the routine that locates the maxima"


  schedule Whisky_InitFindMaxima AT CCTK_POST_RECOVER_VARIABLES
  {
    LANG:Fortran
    OPTIONS: GLOBAL
  } "Initialize the scalars for the routine that locates the maxima"

  schedule GROUP Whisky_DCAndMaxima AT POSTSTEP
  {
    STORAGE: whisky_maxima_location
    STORAGE: whisky_maxima_position
    STORAGE: whisky_maxima_separation
  } "Find the maximum of the density and the star separation"
  
  schedule GROUP Whisky_DCAndMaxima AT CCTK_POST_RECOVER_VARIABLES
  {
    STORAGE: whisky_maxima_location
    STORAGE: whisky_maxima_position
    STORAGE: whisky_maxima_separation
  } "Find the maximum of the density and the star separation"

  if (use_coord_maxima)
  {
 
    schedule Whisky_FindMaxima IN Whisky_DCAndMaxima
    {
      LANG: Fortran
      OPTIONS: local  
  } "Use the maximum of the density to set the position of the center of the star"
    
  }
  else
  {
    
    schedule Whisky_FindWeightedMaxima IN Whisky_DCAndMaxima
    {
      LANG: Fortran
      OPTIONS: local  
    } "Use the weighted maximum of the density to set the position used by DriftCorrect"
    
  }
  
  if (set_dc_centroid)
  {
    schedule Whisky_SetDCCentroid IN Whisky_DCAndMaxima AFTER Whisky_FindMaxima
    {
      LANG: Fortran
      OPTIONS: GLOBAL
    } "Set DriftCorrect"
  }

  if (compute_EqualMassStarSeparation)
  {
    schedule Whisky_FindSeparation IN Whisky_DCAndMaxima AFTER Whisky_FindMaxima
    {
      LANG: Fortran
      OPTIONS: GLOBAL
      TRIGGERS: whisky_maxima_position
      TRIGGERS: whisky_maxima_separation
    } "Find the separation of a binary NS from the maxima"
  }
}

# Check that rho >= whisky_rho_min
if (Check_Rho_Minimum)
{
  schedule Whisky_Check_Rho_Minimum AT ANALYSIS
  {
    LANG: Fortran
    TRIGGERS: HydroBase::rho
    TRIGGERS: HydroBase::press
    TRIGGERS: HydroBase::eps
  } "Check whether somewhere rho(i,j,k) < whisky_rho_min and produce a WARNING"
  
  schedule Whisky_RefinementLevel AT ANALYSIS BEFORE Whisky_Check_Rho_Minimum
  {
    LANG: Fortran
    TRIGGERS: HydroBase::rho
    TRIGGERS: HydroBase::press
    TRIGGERS: HydroBase::eps
  } "Calculate current refinement level"
}

# set and check a mask containing the failures of C2P; if they occur at points overwritten by finer grids, they can be ignored.

STORAGE: whisky_C2P_failed[1]

schedule reset_whisky_C2P_failed AT BASEGRID
{
  LANG: Fortran
} "Initialise the mask function that contains the points where C2P has failed (at BASEGRID)"

schedule reset_whisky_C2P_failed AT CCTK_PRESTEP
{
  LANG: Fortran
} "Reset the mask function that contains the points where C2P has failed (at PRESTEP)"

schedule sync_whisky_C2P_failed AT CCTK_EVOL AFTER MoL_Evolution
{
  LANG: Fortran
  SYNC: whisky_C2P_failed
} "Syncronise the mask function that contains the points where C2P has failed"

schedule check_whisky_C2P_failed AT CCTK_POSTSTEP AFTER Whisky_RefinementLevel
{
  LANG: Fortran
} "Check the mask function that contains the points where C2P has failed and report an error in case a failure is found"

schedule Whisky_Tmunu IN AddToTmunu
{
  LANG: Fortran
} "Compute the energy-momentum tensor"

#the following is necessary because TmunuBase does not have enough schedule

schedule GROUP SetTmunu AT POSTRESTRICTINITIAL AFTER HydroBase_Con2Prim BEFORE ADMConstraintsGroup
{
} "Calculate the stress-energy tensor"

schedule GROUP SetTmunu AT POSTPOSTINITIAL AFTER HydroBase_Con2Prim BEFORE ADMConstraintsGroup
{
} "Calculate the stress-energy tensor"

schedule GROUP SetTmunu AT POST_RECOVER_VARIABLES
{
} "Calculate the stress-energy tensor"

schedule GROUP SetTmunu IN MoL_Evolution AFTER ApplyBCs
{
} "Calculate the stress-energy tensor"