diff options
author | lanfer <lanfer@10716dce-81a3-4424-a2c8-48026a0d3035> | 2000-04-28 14:10:20 +0000 |
---|---|---|
committer | lanfer <lanfer@10716dce-81a3-4424-a2c8-48026a0d3035> | 2000-04-28 14:10:20 +0000 |
commit | 22cb80821bc16b8c6c3c4f5ba34b1088254e6722 (patch) | |
tree | d247830c273e3e738295bd5e248ee0659558c22b /src/TestSlab.c | |
parent | b99a104380065424f5324d3030b6687229bb9c2c (diff) |
first take at Hyperslab - truly develomental
git-svn-id: http://svn.cactuscode.org/arrangements/CactusPUGH/PUGHSlab/trunk@2 10716dce-81a3-4424-a2c8-48026a0d3035
Diffstat (limited to 'src/TestSlab.c')
-rw-r--r-- | src/TestSlab.c | 103 |
1 files changed, 103 insertions, 0 deletions
diff --git a/src/TestSlab.c b/src/TestSlab.c new file mode 100644 index 0000000..9c6329f --- /dev/null +++ b/src/TestSlab.c @@ -0,0 +1,103 @@ + +#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[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; + 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[0]=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; + + GetLocalLine(cctkGH, 3, gs, di, ds, 4, ls, le, &nlocpoints); + printf("TEST: local %d %d %d -> %d %d %d TOTAL: %d\n", + ls[0], ls[1], ls[2], le[0], le[1], le[2], nlocpoints ); + + nprocs = CCTK_nProcs(cctkGH); + c_nlocpoints = (int*) malloc (nprocs*sizeof(int)); + +#ifdef CCTK_MPI + CACTUS_MPI_ERROR(MPI_Gather(&nlocpoints, 1, PUGH_MPI_INT, c_nlocpoints, 1, + PUGH_MPI_INT, 0, pughGH->PUGH_COMM_WORLD)); +#endif + + for (iproc=0;iproc<nprocs;iproc++) + printf(" Proc %d : %d \n",iproc,c_nlocpoints[iproc]); + +} + |