next up previous contents
Next: Size and Distrib Up: Cactus Variables Previous: Group Types   Contents

Timelevels

These are best introduced by an example using finite differencing. Consider the 1-D wave equation

12#12 (part81)

To solve this by partial differences, one discretises the derivatives to get an equation relating the solution at different times. There are many ways to do this, one of which produces the following difference equation
13#13 (part82)

which relates the three timelevels 14#14, 15#15, and 16#16.

Obviously, the code could just use three variables, one for each timelevel. This turns out, however, to be inefficient, because as soon as the time is incremented to 14#14, it would be necessary to copy data from the 15#15 variable to the 16#16 variable and from the 14#14 variable to the 15#15 variable.

To remove this extraneous copy, Cactus allows you to specify the number of timelevels used by your numerical scheme. It then generates variables with the base name (e.g. phi) suffixed by a qualifier for which timelevel is being referred to--no suffix for the next timelevel, and _p for each previous timelevel.

The timelevels are rotated (by the driver thorn) at the start of each evolution step, that is:

initial
poststep
analysis

loop:
  rotate timelevels
  t = t + dt
  it = it + 1
  prestep
  evolve
  poststep
  analysis

Timelevel rotation means that, for example, phi_p now holds the values of the former phi, and phi_p_p the values of the former phi_p, etc. Note that after rotation, phi is undefined, and its values should not be used until they have been updated.

All timelevels, except the current level, should be considered read-only during evolution, that is, their values should not be changed by thorns. The exception to this rule is for function initialisation, when the values at the previous timelevels do need to be explicitly filled out.


next up previous contents
Next: Size and Distrib Up: Cactus Variables Previous: Group Types   Contents