aboutsummaryrefslogtreecommitdiff
path: root/src/GHExtension.c
blob: 700efa5eb183e242e1c1281feef08f8cc85f2919 (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
 /*@@
   @file      GHExtension.c
   @date      Mon Mar 15 15:48:42 1999
   @author    Gerd Lanfermann
   @desc 
              Set up the symmetry GH extension. This should really be done
              with StoredData
   @enddesc 
   @version   $Id$
 @@*/

#include <stdlib.h>

#include "cctk.h"
#include "Symmetry.h"

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

CCTK_FILEVERSION(CactusBase_CartGrid3D_GHExtension_c)

int Symmetry_InitGHex(cGH *GH);
void *Symmetry_AllocGHex(tFleshConfig *config, int convlevel, cGH *GH);
int Symmetry_InitFGHex(cGH *GH);

void *Symmetry_AllocGHex(tFleshConfig *config, int convlevel, cGH *GH) 
{
  
  int gf,grid_dim,NumVars;     /* Number of  dimensions, grid functions */
  SymmetryGHex *newGHex;       /* Type of GHextension is EinsteinBoundGHex */


  /* avoid compiler warnings about unused arguments */
  config = config;
  convlevel = convlevel;
  GH = GH;

  NumVars  = CCTK_NumVars(); /* Get number of grid functions */
  grid_dim = CCTK_MaxDim();  /* Get maximal dimension of the grid */

  /* allocate the GHextension */
  newGHex = (SymmetryGHex*)malloc(sizeof(SymmetryGHex));
  
  /* allocation for the number of grid functions*/
  newGHex->GFSym = (int **)malloc(NumVars*sizeof(int *));

  /* allocation for the number of dimensions*/
  for (gf=0;gf<NumVars;gf++) 
  {
    newGHex->GFSym[gf] = (int *)malloc(2*grid_dim*sizeof(int));
  }

  /* Now we have something, that looks like [0..NumVars-1][0..grid_dim-1] 
     and we return that: This will be merged into
     the GH and can be referenced  in the following manner:
     int handle  = CCTK_GHExtensionHandle("Symmetry");
                   ..... which returns a pointer the GHextension
     BoundGHex   = ((pGH *)GH->extensions[handle]);
                   ..... BoundGHex can now be used as:
     BoundGHex->GFSym[3][2] = 1 ;
  */ 

  return newGHex;  

}
  
int Symmetry_InitGHex(cGH *GH) 
{
  int retval = 0;
  SymmetryGHex *newGHex;   
  int handle;              
  int gf,d;
  int NumVars =CCTK_NumVars(); 
  int grid_dim;                    

  grid_dim = CCTK_MaxDim();    
  handle   = CCTK_GHExtensionHandle("Symmetry"); 
  newGHex  = (SymmetryGHex*) GH->extensions[handle]; 

  /* ... and initialize them: */
  for (gf=0;gf<NumVars;gf++) 
  {
    for(d=0;d<2*grid_dim;d++) 
    {
      newGHex->GFSym[gf][d] = GFSYM_UNSET;  /* not set */
    }
  }

  return retval;
}