diff options
-rw-r--r-- | src/FlatBoundary.c | 60 | ||||
-rw-r--r-- | src/make.code.defn | 2 |
2 files changed, 48 insertions, 14 deletions
diff --git a/src/FlatBoundary.c b/src/FlatBoundary.c index cd0fb41..5681754 100644 --- a/src/FlatBoundary.c +++ b/src/FlatBoundary.c @@ -51,20 +51,19 @@ void ApplyFlatBC(cGH *GH, int *stencil_size, char *name) { DECLARE_CCTK_PARAMETERS - SymmetryGHex *sGHex; /* the Boundary GHextension, needed for ref*/ - int gf,first,last,index; + SymmetryGHex *sGHex; /* the Symmetry GHextension */ + int first,last,index; /* grid function indices */ int type; /* type 0 for a group, type 1 for a variable */ - int num; /* index number of the group (not the gf)*/ - int *doBC; /* flags if lower/upper BCs are - applied (1) or not (0) */ - /* indexing as in bbox: - 0 xlow, 1 xup, 2 ylow, ...(C!) */ + int num; /* index number of the group */ + int *doBC; /* flags if lower/upper BCs are + applied (1) or not (0) + indexing is as in bbox: 0 lower 1 upper */ /* Get the pointer to the SymmetryGHextension */ sGHex = (SymmetryGHex*)GH->extensions[CCTK_GHExtensionHandle("Symmetry")]; /* Allocate memory for doBC */ - doBC = (int *)malloc((GH->cctk_dim*2)*sizeof(int)); + doBC = (int *)malloc(2*(GH->cctk_dim)*sizeof(int)); /* Decide if we have a group or a variable, and get the index */ /* type = 1 (group), type = 0 (var), type = -1 (neither) */ @@ -122,14 +121,25 @@ void ApplyFlatBC(cGH *GH, int *stencil_size, char *name) { doBC[idim*2]=(((sGHex->GFSym[index][idim*2]==GFSYM_NOSYM)|| (sGHex->GFSym[index][idim*2]==GFSYM_UNSET)) && GH->cctk_lsh[idim]>1 && GH->cctk_bbox[idim*2]); - doBC[idim*2+1] = GH->cctk_lsh[idim]>1 && GH->cctk_bbox[idim*2+1]; + doBC[idim*2+1] = (((sGHex->GFSym[index][idim*2+1]==GFSYM_NOSYM)|| + (sGHex->GFSym[index][idim*2+1]==GFSYM_UNSET)) && + GH->cctk_lsh[idim]>1 && GH->cctk_bbox[idim*2+1]); } - /* Assume for now that we have 3D */ - ApplyFlat3D(GH,doBC,GH->cctk_lsh,stencil_size,GH->data[index][0]); + if (GH->cctk_dim == 3) + { + ApplyFlat3D(GH,doBC,GH->cctk_lsh,stencil_size,GH->data[index][0]); + } + else + { + CCTKi_NotYetImplemented("Flat boundaries in other than 3D"); + } + } } + + if (doBC) free(doBC); } void FMODIFIER FORTRAN_NAME(ApplyFlatBC)(cGH *GH, int *stencil_size, ONE_FORTSTRING_ARG) { @@ -141,15 +151,18 @@ void FMODIFIER FORTRAN_NAME(ApplyFlatBC)(cGH *GH, int *stencil_size, ONE_FORTSTR } - - void ApplyFlat3D(cGH *GH,int *doBC,int *lsh,int *stencil_size,CCTK_REAL *var) { if (doBC[0] == 1) { + int j,k,sw; +#ifdef DEBUG_BOUND + printf("Applying flat boundary for lower x\n"); +#endif + for (k=0;k=lsh[2];k++) { for (j=0;j=lsh[1];j++) @@ -165,7 +178,12 @@ void ApplyFlat3D(cGH *GH,int *doBC,int *lsh,int *stencil_size,CCTK_REAL *var) if (doBC[1] == 1) { + int j,k,sw; + +#ifdef DEBUG_BOUND + printf("Applying flat boundary for upper x\n"); +#endif for (k=0;k<lsh[2];k++) { @@ -184,6 +202,10 @@ void ApplyFlat3D(cGH *GH,int *doBC,int *lsh,int *stencil_size,CCTK_REAL *var) { int i,k,sw; +#ifdef DEBUG_BOUND + printf("Applying flat boundary for lower y\n"); +#endif + for (k=0;k<lsh[2];k++) { for (i=0;i<lsh[0];i++) @@ -200,6 +222,10 @@ void ApplyFlat3D(cGH *GH,int *doBC,int *lsh,int *stencil_size,CCTK_REAL *var) if (doBC[3] == 1) { int i,k,sw; + +#ifdef DEBUG_BOUND + printf("Applying flat boundary for upper y\n"); +#endif for (k=0;k<lsh[2];k++) { @@ -218,6 +244,10 @@ void ApplyFlat3D(cGH *GH,int *doBC,int *lsh,int *stencil_size,CCTK_REAL *var) { int i,j,sw; +#ifdef DEBUG_BOUND + printf("Applying flat boundary for lower z\n"); +#endif + for (j=0;j<lsh[1];j++) { for (i=0;i<lsh[0];i++) @@ -235,6 +265,10 @@ void ApplyFlat3D(cGH *GH,int *doBC,int *lsh,int *stencil_size,CCTK_REAL *var) { int i,j,sw; +#ifdef DEBUG_BOUND + printf("Applying flat boundary for upper z\n"); +#endif + for (j=0;j<lsh[1];j++) { for (i=0;i<lsh[0];i++) diff --git a/src/make.code.defn b/src/make.code.defn index a1ab7df..95db209 100644 --- a/src/make.code.defn +++ b/src/make.code.defn @@ -4,7 +4,7 @@ # Source files in this directory SRCS = FlatBoundary.c\ RadiationBoundary.F77\ - RadiationBoundaryWrappers.c + RadiationBoundaryWrappers.c # Subdirectories containing source files SUBDIRS = |