aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorlanfer <lanfer@10716dce-81a3-4424-a2c8-48026a0d3035>2000-05-12 14:02:17 +0000
committerlanfer <lanfer@10716dce-81a3-4424-a2c8-48026a0d3035>2000-05-12 14:02:17 +0000
commit3f803d9c288cafde42592e6166ee289c98c7daff (patch)
treec8e996815406243174658f98471fb7dda79b326e /src
parentee9c4440762e76191fba2112fb80e2fc7201f269 (diff)
2d stuff
git-svn-id: http://svn.cactuscode.org/arrangements/CactusPUGH/PUGHSlab/trunk@14 10716dce-81a3-4424-a2c8-48026a0d3035
Diffstat (limited to 'src')
-rw-r--r--src/CollectData2D.c138
-rw-r--r--src/Hyperslab.h8
-rw-r--r--src/TestSlab2D.c37
3 files changed, 98 insertions, 85 deletions
diff --git a/src/CollectData2D.c b/src/CollectData2D.c
index e2f1dad..f616718 100644
--- a/src/CollectData2D.c
+++ b/src/CollectData2D.c
@@ -16,11 +16,12 @@
#define MAX(a,b) ((a)>(b) ? (a) : (b))
#define MAX_DIM 3
+#define BAD -42
+#define GZ 1
int CollectData2D(cGH *GH, int vindex, int vtimelvl, int vdim,
- int *S_s, int *u_l1, int *u_l2, int *ds,
- int len_l1, int len_l2,
+ int *S_s, int dir[2], int ds[2], int len[2],
void **dptr, int *dsize)
{
return(0);
@@ -28,83 +29,102 @@ int CollectData2D(cGH *GH, int vindex, int vtimelvl, int vdim,
int CollectLocalData2D(cGH *GH, int vindex, int vtimelvl, int vdim,
- int *S_s, int *u_l1, int *u_l2, int *ds,
- int len_l1, int len_l2,
+ int *S_s, int dir[2], int ds[2], int len[2],
void **loc_dptr, int *idx1_dptr, int *idx2_dptr, int *dsize)
{
- int tstart[MAX_DIM], end_l1[MAX_DIM], end_l2[MAX_DIM];
- int gridpnt[MAX_DIM],tpnt[MAX_DIM];
- int l1,l2, lmbd_max, lsh_max;
+ int tstart[MAX_DIM];
int ierr;
- int locstart2[3],locend2[3],nlocpoints2;
+ int *locstart, *locend, nlocpoints, totlocpoints=0;
+ int tlocstart[MAX_DIM], tlocend[MAX_DIM];
+ int u_l1[MAX_DIM], u_l2[MAX_DIM];
- int gindex,vtype,vtypesize;
- int idim,lincount, tmp;
+ int vtype,vtypesize;
+ int idim;
- void *data = CCTK_VarDataPtrI (GH, vtimelvl, vindex);
+ int phasplane=1;
- int *idx1, *idx2;
+ void *data = CCTK_VarDataPtrI (GH, vtimelvl, vindex);
CCTK_REAL *real_dptr = (CCTK_REAL *) *loc_dptr;
-
+
vtype = CCTK_VarTypeI(vindex);
vtypesize = CCTK_VarTypeSize(vtype);
-
- /* Test for orthogonality */
- tmp=0;
- for (idim=0;idim<vdim;idim++)
- tmp+=u_l1[idim]*u_l2[idim];
- if (tmp!=0) printf("Error: not orthogonal\n");
-
-
- /* Calculate maximal length of one arm */
- if (len_l1<0) lmbd_max = 10000;
- else lmbd_max = len_l1;
-
- for (idim=0;idim<vdim;idim++)
- if (ds[0]!=0)
- lmbd_max = MIN(((GH->cctk_gsh[idim]-S_s[idim])/ds[0]),lmbd_max);
- /* Get a max. local size,
- int gridpnt to zero, so we can loop up to maxdim */
- for (idim=0;idim<vdim;idim++)
+ locstart = (int*)malloc(vdim*sizeof(int));
+ locend = (int*)malloc(vdim*sizeof(int));
+
+ for (idim=0; idim<vdim; idim++)
{
- lsh_max = MAX(GH->cctk_lsh[idim], lsh_max);
- gridpnt[idim]=0;
+ tstart[idim] = BAD;
+ locstart[idim] = BAD;
+ locend[idim] = BAD;
+
+ u_l1[idim] = 0;
+ u_l2[idim] = 0;
+
+ if ((idim!=dir[0]) && (idim!=dir[1]))
+ if((GH->cctk_lbnd[idim]<S_s[idim]) &&
+ (GH->cctk_ubnd[idim]>S_s[idim]))
+ {
+ locstart[idim] = S_s[idim];
+ locend[idim] = S_s[idim];
+ phasplane = 1;
+ }
+ else phasplane = 0;
}
-
- printf("MAX LAMDA: %d ",lmbd_max);
-
- /* We do not know how many points along the l2 arm, take maximum lsh */
- *loc_dptr = malloc(lsh_max*lmbd_max * vtypesize);
- idx1 = (int*)malloc(lsh_max*lmbd_max * vtypesize);
- idx2 = (int*)malloc(lsh_max*lmbd_max * vtypesize);
+ u_l1[dir[0]]=1;
+ u_l2[dir[1]]=1;
+
- idx1_dptr = idx1;
- /*$idx2 = idx2_dptr;$*/
- for (l1=0;l1<lmbd_max;l1++)
+ if (S_s[dir[0]]<GH->cctk_ubnd[dir[0]])
{
- for (idim=0;idim<vdim;idim++)
- tpnt[idim] = S_s[idim]+l1*u_l1[idim];
-
- GetLocalLine(GH, vdim, tpnt, u_l2, ds[1], len_l2,
- locstart2, locend2, &nlocpoints2);
-
- for (l2=0; l2<nlocpoints2; l2++)
- {
- for (idim=0;idim<vdim;idim++)
- gridpnt[idim] = locstart2[idim]+ l2 * u_l2[idim];
-
- /*$real_dptr[lincount] =((CCTK_REAL *) data)
- [CCTK_GFINDEX3D(GH,gridpnt[0],gridpnt[1],gridpnt[2])];$*/
- idx1_dptr[lincount] = l1;
- /*idx2_dptr[lincount] = l2;$*/
- lincount++;
+ /* Initialize startpoints */
+ for (idim=0; idim<vdim; idim++) {
+ tstart[idim] = GH->cctk_lbnd[idim]+GH->cctk_nghostzones[idim];
}
+ tstart[dir[0]]=S_s[dir[0]];
+ ierr = GetLocalLine(GH, vdim, tstart, u_l1, ds[0], len[0],
+ tlocstart, tlocend, &nlocpoints);
+ locstart[dir[0]]= tlocstart[dir[0]];
+ locend [dir[0]]= tlocend[dir[0]];
+ totlocpoints=nlocpoints;
+ if (locstart[dir[0]]==BAD) phasplane &=0;
}
+ else phasplane &=0;
+
+ if (S_s[dir[1]]<GH->cctk_ubnd[dir[1]])
+ {
+ /* Initialize startpoints */
+ for (idim=0; idim<vdim; idim++) {
+ tstart[idim] = GH->cctk_lbnd[idim]+GH->cctk_nghostzones[idim];
+ }
+ tstart[dir[1]]=S_s[dir[1]];
+ ierr = GetLocalLine(GH, vdim, tstart, u_l2, ds[1], len[1],
+ tlocstart, tlocend, &nlocpoints);
+ locstart[dir[1]]= tlocstart[dir[1]];
+ locend[dir[1]] = tlocend[dir[1]];
+ totlocpoints*=nlocpoints;
+ }
+ else phasplane &=0;
+
+ if (phasplane)
+ printf("LOC START: %d %d %d %d %d %d -> %d\n",
+ locstart[0],locstart[1],locstart[2],
+ locend[0],locend[1],locend[2],
+ totlocpoints);
+ else
+ printf("proc has no plane\n");
}
+
+
+
+ /*$printf("LB/UB [%d , %d, %d] - [%d, %d, %d] \n",
+ GH->cctk_lbnd[0],GH->cctk_lbnd[1],GH->cctk_lbnd[2],
+ GH->cctk_ubnd[0],GH->cctk_ubnd[1],GH->cctk_ubnd[2]);$*/
+
+
diff --git a/src/Hyperslab.h b/src/Hyperslab.h
index 2061e49..e0be51f 100644
--- a/src/Hyperslab.h
+++ b/src/Hyperslab.h
@@ -9,14 +9,12 @@ int CollectLocalData1D(cGH *GH, int vindex, int vtimelvl, int vdim,
void **loc_dptr, int *dsize);
int CollectData2D(cGH *GH, int vindex, int vtimelvl, int vdim,
- int *S_s, int *u_l1, int *u_l2, int *ds,
- int len_l1, int len_l2,
+ int *S_s, int dir[2], int ds[2], int len[2],
void **dptr, int *dsize);
int CollectLocalData2D(cGH *GH, int vindex, int vtimelvl, int vdim,
- int *S_s, int *u_l1, int *u_l2, int *ds,
- int len_l1, int len_l2,
- void **dptr, int *idx1_ptr, int *idx2_ptr, int *dsize);
+ int *S_s, int dir[2], int ds[2], int len[2],
+ void **dptr, int *idx1_ptr, int *idx2_ptr, int *dsize);
int GetLocalLine(cGH *GH,
int vardim, int *S_l, int *u_l, int ds, int len_l,
diff --git a/src/TestSlab2D.c b/src/TestSlab2D.c
index 0dbe3de..48d6b86 100644
--- a/src/TestSlab2D.c
+++ b/src/TestSlab2D.c
@@ -22,11 +22,11 @@
void TestSlab2D(CCTK_ARGUMENTS) {
DECLARE_CCTK_ARGUMENTS
- int gs[3], di1[3], di2[3]; /* global start/direction (2times) */
- int ds[2]; /* downsampling */
- int ls[3], le[3]; /* local start/end */
- int dsize[1]; /* number of points */
- int nprocs,iproc; /* number of procs */
+ int gs[3], di[2]; /* global start/direction (2times) */
+ int ds[2], len[2]; /* downsampling/length */
+ int ls[3], le[3]; /* local start/end */
+ int dsize[1]; /* number of points */
+ int nprocs,iproc; /* number of procs */
int l;
int *index1, *index2;
@@ -39,27 +39,22 @@ void TestSlab2D(CCTK_ARGUMENTS) {
vtimelvl = CCTK_NumTimeLevelsFromVarI (vindex) - 1;
vdim = CCTK_GroupDimFromVarI(vindex);
- gs[0]=1;
- gs[1]=1;
- gs[2]=1;
+ gs[0]=6;
+ gs[1]=6;
+ gs[2]=5;
- di1[0]= 0;
- di1[1]= 0;
- di1[2]= 1;
+ di[0]= 2;
+ di[1]= 1;
- di2[0]= 0;
- di2[1]= 1;
- di2[2]= 0;
-
-
- ds[0]=1;
+ ds[0]=2;
ds[1]=2;
+ len[0] = -1;
+ len[1] = -1;
+
printf("Calling CollectData2D \n");
CollectLocalData2D(cctkGH, vindex, vtimelvl, vdim,
- gs, di1, di2, ds, 145, -1,
- &dptr, index1, index2, dsize);
-
- printf("TestSlab: %d %d\n",dsize[0], dsize[2]);
+ gs, di, ds, len,
+ &dptr, index1, index2, dsize);
}