aboutsummaryrefslogtreecommitdiff
path: root/src/TestSlab.c
blob: 00a81025ef3a08a4569559b7b6dfee4f5fec3dbe (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
#include <stdio.h>
#include <stdlib.h>
#include <math.h>  

#include "cctk.h"
#include "cctk_Parameters.h"
#include "cctk_Arguments.h"
#include "CactusPUGH/PUGH/src/include/pugh.h"
#include "CactusBase/IOUtil/src/ioGH.h"

#define MAX_DIM 3
#define MAX_FACE 6
#define EPS 1e-10
#define BAD -42

#define ABS(a) ((a)<0 ? -(a) : (a))

int IsPointOnProc(int dim, int *gownership, int *pnt);
int GetLocalLine(cGH *GH, 
		 int vardim, int *P_l, int *u_l, int *ds, int len_l,
		 int *locstart, int *locend, int *nlocpoints);

int CollectLocalData1D(cGH *GH, int vindex, int vtype, int vtypesize, int vtimelvl, 
		       int vdim, int *S_l, int *u_l, int ds, int len_l,
		       void **loc_dptr, int *dsize);

void TestSlab(CCTK_ARGUMENTS) {  
  DECLARE_CCTK_ARGUMENTS

  int gs[3], di[3], ds; /* global start/direction/downsampling*/
  int ls[3], le[3];        /* local start/end */
  int nlocpoints;          /* number of points */
  int nprocs,iproc;        /* number of procs */
  int *c_nlocpoints;       /* collected number of points per proc (size nproc) */
  pGH *pughGH;
  int gindex;
  int vtype, vindex, vtypesize, vdim, vtimelvl;
  void *loc_dptr;

  vindex   = CCTK_VarIndex("grid::x");
  gindex   = CCTK_GroupIndexFromVarI(vindex);
  vtype    = CCTK_GroupTypeFromVarI(vindex);
  vtypesize= CCTK_VarTypeSize(vtype);
  vtimelvl = CCTK_NumTimeLevelsFromVarI (vindex) - 1;
  vdim     = CCTK_GroupDimI(gindex);
  

  gs[0]=1;
  gs[1]=5;
  gs[2]=9;
 
  di[0]= 0;
  di[1]=-1;
  di[2]=-2;
  
  ds=1;

  CollectLocalData1D(cctkGH, vindex, vtype, vtypesize, vtimelvl,
		   vdim, gs, di, ds, -1, &loc_dptr, &nlocpoints);


}
   
void TestGetLocalLine(CCTK_ARGUMENTS) {  
  DECLARE_CCTK_ARGUMENTS

  int gs[3], di[3], ds[1]; /* global start/direction/downsampling*/
  int ls[3], le[3];        /* local start/end */
  int nlocpoints;          /* number of points */
  int nprocs,iproc;        /* number of procs */
  int *c_nlocpoints;       /* collected number of points per proc (size nproc) */
  pGH *pughGH; 

  pughGH = PUGH_pGH (cctkGH);

  gs[0]=1;
  gs[1]=5;
  gs[2]=9;
 
  di[0]= 0;
  di[1]=-1;
  di[2]= 2;
  
  ds[0]=1;
  printf("Calling CollectData \n");
  CollectLocalData1D(cctkGH, vindex, vtype, vtypesize, vtimelvl,
		     vdim, gs, di, ds, -1, &loc_dptr, &nlocpoints);


}