aboutsummaryrefslogtreecommitdiff
path: root/src/SandR.c
blob: ea419ff6426c3739093bea8a2447b66bfa722335 (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
 /*@@
   @file      SandR.c
   @date      Sun May 26 03:35:58 2002
   @author    Ian Hawke
   @desc 
   Restores the Save and Restore variables to their original positions.
   @enddesc 
   @version   $Header$
 @@*/

#include "cctk.h"
#include "cctk_Arguments.h"
#include "cctk_Parameters.h"

#include "ExternalVariables.h"

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

CCTK_FILEVERSION(AlphaThorns_MoL_SandR_c);

/********************************************************************
 *********************     Local Data Types   ***********************
 ********************************************************************/

/********************************************************************
 ********************* Local Routine Prototypes *********************
 ********************************************************************/

/********************************************************************
 ***************** Scheduled Routine Prototypes *********************
 ********************************************************************/

void MoL_RestoreSandR(CCTK_ARGUMENTS);

/********************************************************************
 ********************* Other Routine Prototypes *********************
 ********************************************************************/

/********************************************************************
 *********************     Local Data   *****************************
 ********************************************************************/

/********************************************************************
 *********************     External Routines   **********************
 ********************************************************************/

 /*@@
   @routine    MoL_RestoreSandR
   @date       Sun May 26 03:39:02 2002
   @author     Ian Hawke
   @desc 
   Save and Restore variables are those that the physics thorn may 
   need to know to calculate the RHS, but which may be evolved by
   something other than MoL. In order to get the timelevels correct,
   the previous timelevel is copied to the current before the MoL step.
   As we do not know whether the variable will be evolved before or
   after MoL we must save the data that was in the current timelevel, 
   and then restore it at the end of the MoL timestep. This routine
   restores the variables.
   @enddesc 
   @calls     
   @calledby   
   @history 
 
   @endhistory 

@@*/

void MoL_RestoreSandR(CCTK_ARGUMENTS) 
{
  
  DECLARE_CCTK_ARGUMENTS;
  DECLARE_CCTK_PARAMETERS;
  
  CCTK_INT index, var;
  CCTK_INT totalsize;
  CCTK_INT vectorstart;
  CCTK_REAL *SandRDataArray;
  
  totalsize = cctk_lsh[0] * cctk_lsh[1] * cctk_lsh[2];

  for (var = 0; var < MoLNumSandRVariables; var++) 
  {
    
    SandRDataArray = (CCTK_REAL *)CCTK_VarDataPtrI(cctkGH, 0, 
                                                   SandRVariableIndex[var]);
    
    vectorstart = var * totalsize;

#ifdef MOLDEBUG    
    printf("Restore:Variable %s, first entry %g, scratch %g\n",
           CCTK_VarName(SandRVariableIndex[var]), SandRDataArray[0], 
           SandRScratchSpace[vectorstart]);
#endif

    memcpy(SandRDataArray, &SandRScratchSpace[vectorstart], 
           totalsize * sizeof(CCTK_REAL));
  }
  
  return;
  
}

/********************************************************************
 *********************     Local Routines   *************************
 ********************************************************************/