summaryrefslogtreecommitdiff
path: root/src/main/CactusDefaultInitialise.c
blob: 79529873651cf90f502146806334e44687675985 (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
 /*@@
   @file      CactusDefaultInitialise.c
   @date      Tue Sep 29 12:45:04 1998
   @author    Tom Goodale
   @desc
              Default Cactus initialisation routine.
   @enddesc
   @version   $Id$
 @@*/

#include <stdio.h>

#include "cctk_Misc.h"
#include "cctk_Flesh.h"
#include "cctk_Parameter.h"

#include "cctki_GHExtensions.h"
#include "cctki_ScheduleBindings.h"
#include "cctki_WarnLevel.h"

#include "CactusMainDefaults.h"
#include "CactusCommFunctions.h"

static const char *rcsid = "$Header$";

CCTK_FILEVERSION(main_CactusDefaultInitialise_c);

/*# define DEBUG_CCTK 1 */

/********************************************************************
 ********************* Local Routine Prototypes *********************
 ********************************************************************/
static void CactusInitialiseGH (const tFleshConfig *config, cGH *GH);


 /*@@
   @routine    CactusDefaultInitialise
   @date       Tue Sep 29 12:45:04 1998
   @author     Tom Goodale
   @desc
               Default initialisation routine.
   @enddesc
   @calls      CCTK_SetupGH
               CCTKi_AddGH
               CactusInitialiseGH

   @var        config
   @vdesc      flesh configuration structure
   @vtype      tFleshConfig *
   @vio        inout
   @endvar

   @returntype int
   @returndesc
               0 for success
   @endreturndesc
@@*/
int CactusDefaultInitialise (tFleshConfig *config)
{
  cGH *GH;
  int convergence_level;

#if 0
  CactusResetTimer (config->timer[INITIALISATION]);
  CactusResetTimer (config->timer[EVOLUTION]);
  CactusResetTimer (config->timer[ELLIPTIC]);

  CactusStartTimer (config->timer[INITIALISATION]);
#endif

  convergence_level = 0;
  while ((GH = CCTK_SetupGH (config, convergence_level)))
  {
    CCTKi_AddGH (config, convergence_level, GH);

    CactusInitialiseGH (config, GH);

    convergence_level++;
  };

#if 0
  CactusStopTimer (config->timer[INITIALISATION]);
#endif

  return (0);
}


 /*@@
   @routine    CactusInitialiseGH
   @date       Mon Feb  1 12:13:09 1999
   @author     Tom Goodale
   @desc
               Responsible for initialising a GH.
   @enddesc
   @calls      CCTKi_ScheduleGHInit
               CCTKi_InitGHExtensions
               CCTKi_FinaliseParamWarn
               CCTK_Traverse

   @var        config
   @vdesc      flesh configuration structure
   @vtype      tFleshConfig *
   @vio        inout
   @endvar
   @var        GH
   @vdesc      the GH to initialize
   @vtype      cGH *
   @vio        inout
   @endvar
@@*/
static void CactusInitialiseGH (const tFleshConfig *config, cGH *GH)
{
  const char *recovery_mode;


  recovery_mode = *(const char *const *)
                  CCTK_ParameterGet ("recovery_mode", "Cactus", NULL);

  /* Initialise time */
  GH->cctk_time = *(const CCTK_REAL *)
                  CCTK_ParameterGet ("cctk_initial_time", "Cactus", NULL);

  /* Initialise iteration number */
  GH->cctk_iteration = 0;

#ifdef DEBUG_CCTK
  CCTK_PRINTSEPARATOR
  printf ("In Cactus_Initialise\n--------------------\n");
  printf ("  Initializing GH->cctk_time = %f\n", GH->cctk_time);
  printf ("  Initializing GH->cctk_iteration = %u\n", GH->cctk_iteration);
  CCTK_PRINTSEPARATOR
#endif

  /* Do the schedule initialisation on this GH */
  CCTKi_ScheduleGHInit (GH);

  /* Initialise all the extensions. */
  CCTKi_InitGHExtensions (GH);

  CCTK_Traverse (GH, "CCTK_WRAGH");

  /* FIXME : PARAM_CHECK SHOULD BE BEFORE HERE */
  CCTK_Traverse (GH, "CCTK_PARAMCHECK");
  CCTKi_FinaliseParamWarn ();

  CCTK_Traverse (GH, "CCTK_BASEGRID");

  if (! (config->recovered && CCTK_Equals (recovery_mode, "strict")))
  {
    /* Traverse routines setting up initial data */
    CCTK_Traverse (GH, "CCTK_INITIAL");

    /* Traverse poststep initial routines which should only be done once */
    CCTK_Traverse (GH, "CCTK_POSTINITIAL");
    CCTK_Traverse (GH, "CCTK_POSTPOSTINITIAL");
    CCTK_Traverse (GH, "CCTK_POSTSTEP");
  }

  /* Traverse recovery and post-recovery routines */
  if (config->recovered)
  {
    CCTK_Traverse (GH, "CCTK_RECOVER_VARIABLES");
    CCTK_Traverse (GH, "CCTK_POST_RECOVER_VARIABLES");
  }

  /* Traverse ID checkpoint routines */
  CCTK_Traverse (GH, "CCTK_CPINITIAL");
}