diff options
Diffstat (limited to 'src/Symmetry.c')
-rw-r--r-- | src/Symmetry.c | 211 |
1 files changed, 181 insertions, 30 deletions
diff --git a/src/Symmetry.c b/src/Symmetry.c index 7b65592..f245600 100644 --- a/src/Symmetry.c +++ b/src/Symmetry.c @@ -15,6 +15,7 @@ #include <string.h> #include "cctk.h" +#include "Symmetry.h" static const char *rcsid = "$Header$"; @@ -66,7 +67,7 @@ int CartApplySym3Di(cGH *GH, int *doSym, int *cntstag, int *lssh, int *ghostz, int *sym, CCTK_REAL *var) { - int i,j,k; + int i, j, k; #ifdef SYM_DEBUG printf(" doSym: %d %d / %d %d / %d %d \n", @@ -79,7 +80,10 @@ int CartApplySym3Di(cGH *GH, int *doSym, int *cntstag, printf(" cntstag: %d %d %d\n",cntstag[0],cntstag[1],cntstag[2]); #endif - if (doSym[0] == 1) + /* + * Apply symmetry to the lower x face. + */ + if (doSym[0] == GFSYM_REFLECTION) { for(k=0; k < lssh[2]; k++) { @@ -87,40 +91,157 @@ int CartApplySym3Di(cGH *GH, int *doSym, int *cntstag, { for(i=0; i < ghostz[0]; i++) { - var[CCTK_GFINDEX3D(GH,i,j,k)] = - sym[0]*var[CCTK_GFINDEX3D(GH,2*ghostz[0]-cntstag[0]-i,j,k)]; + var[CCTK_GFINDEX3D(GH,i,j,k)] = sym[0] * + var[CCTK_GFINDEX3D(GH, 2*ghostz[0]-cntstag[0]-i, j, k)]; } } } } - if (doSym[2] == 1) + else if (doSym[0] == GFSYM_ROTATION_Y) + { + /* + * FIXME: The following loop is local, but global indices are + * FIXME: needed for this to work on multiple processors. + */ + for(k=0; k < lssh[2]; k++) + { + for(j=0; j < lssh[1]; j++) + { + for(i=0; i < ghostz[0]; i++) + { + var[CCTK_GFINDEX3D(GH,i,j,k)] = sym[0] * + var[CCTK_GFINDEX3D(GH, 2*ghostz[0]-cntstag[0]-i, j, lssh[2]-k-1)]; + } + } + } + } + else if (doSym[0] == GFSYM_ROTATION_Z) + { + /* + * FIXME: The following loop is local, but global indices are + * FIXME: needed for this to work on multiple processors. + */ + for(k=0; k < lssh[2]; k++) + { + for(j=0; j < lssh[1]; j++) + { + for(i=0; i < ghostz[0]; i++) + { + var[CCTK_GFINDEX3D(GH,i,j,k)] = sym[0] * + var[CCTK_GFINDEX3D(GH, 2*ghostz[0]-cntstag[0]-i, lssh[1]-j-1, k)]; + } + } + } + } + + /* + * Apply symmetry to the lower y face. + */ + if (doSym[2] == GFSYM_REFLECTION) + { + for(i=0; i < lssh[0]; i++) + { + for(k=0; k < lssh[2]; k++) + { + for(j=0; j < ghostz[1]; j++) + { + var[CCTK_GFINDEX3D(GH,i,j,k)] = sym[2] * + var[CCTK_GFINDEX3D(GH, i, 2*ghostz[1]-cntstag[1]-j, k)]; + } + } + } + } + else if (doSym[2] == GFSYM_ROTATION_X) + { + /* + * FIXME: The following loop is local, but global indices are + * FIXME: needed for this to work on multiple processors. + */ + for(i=0; i < lssh[0]; i++) + { + for(k=0; k < lssh[2]; k++) + { + for(j=0; j < ghostz[1]; j++) + { + var[CCTK_GFINDEX3D(GH,i,j,k)] = sym[2] * + var[CCTK_GFINDEX3D(GH, i, 2*ghostz[1]-cntstag[1]-j, lssh[2]-k-1)]; + } + } + } + } + else if (doSym[2] == GFSYM_ROTATION_Z) + { + /* + * FIXME: The following loop is local, but global indices are + * FIXME: needed for this to work on multiple processors. + */ + for(i=0; i < lssh[0]; i++) + { + for(k=0; k < lssh[2]; k++) + { + for(j=0; j < ghostz[1]; j++) + { + var[CCTK_GFINDEX3D(GH,i,j,k)] = sym[2] * + var[CCTK_GFINDEX3D(GH, lssh[0]-i-1, 2*ghostz[1]-cntstag[1]-j, k)]; + } + } + } + } + + /* + * Apply symmetry to the lower z face. + */ + if (doSym[4] == GFSYM_REFLECTION) { for(i=0; i < lssh[0]; i++) + { + for(j=0; j < lssh[1]; j++) { - for(k=0; k < lssh[2]; k++) - { - for(j=0; j < ghostz[1]; j++) - { - var[CCTK_GFINDEX3D(GH,i,j,k)] = - sym[2]*var[CCTK_GFINDEX3D(GH,i,2*ghostz[1]-cntstag[1]-j,k)]; - } - } + for(k=0; k < ghostz[2]; k++) + { + var[CCTK_GFINDEX3D(GH,i,j,k)] = sym[4] * + var[CCTK_GFINDEX3D(GH, i, j, 2*ghostz[2]-cntstag[2]-k)]; + } } + } } - if (doSym[4] == 1) + else if (doSym[4] == GFSYM_ROTATION_X) { + /* + * FIXME: The following loop is local, but global indices are + * FIXME: needed for this to work on multiple processors. + */ for(i=0; i < lssh[0]; i++) + { + for(j=0; j < lssh[1]; j++) { - for(j=0; j < lssh[1]; j++) - { - for(k=0; k < ghostz[2]; k++) - { - var[CCTK_GFINDEX3D(GH,i,j,k)] = - sym[4]*var[CCTK_GFINDEX3D(GH,i,j,2*ghostz[2]-cntstag[2]-k)]; - } - } + for(k=0; k < ghostz[2]; k++) + { + var[CCTK_GFINDEX3D(GH,i,j,k)] = sym[4] * + var[CCTK_GFINDEX3D(GH, i, lssh[1]-j-1, 2*ghostz[2]-cntstag[2]-k)]; + } } + } } + else if (doSym[4] == GFSYM_ROTATION_Y) + { + /* + * FIXME: The following loop is local, but global indices are + * FIXME: needed for this to work on multiple processors. + */ + for(i=0; i < lssh[0]; i++) + { + for(j=0; j < lssh[1]; j++) + { + for(k=0; k < ghostz[2]; k++) + { + var[CCTK_GFINDEX3D(GH,i,j,k)] = sym[4] * + var[CCTK_GFINDEX3D(GH, lssh[0]-i-1, j, 2*ghostz[2]-cntstag[2]-k)]; + } + } + } + } + return(0); } @@ -149,28 +270,58 @@ int CartApplySym3Di(cGH *GH, int *doSym, int *cntstag, int CartApplySym2Di(cGH *GH, int *doSym, int *cntstag, int *lssh, int *ghostz, int *sym, CCTK_REAL *var) { - int i,j; + int i, j; - if (doSym[0] == 1) + if (doSym[0] == GFSYM_REFLECTION) + { + for(j=0; j < lssh[1]; j++) + { + for(i=0; i < ghostz[0]; i++) + { + var[CCTK_GFINDEX2D(GH,i,j)] = sym[0] * + var[CCTK_GFINDEX2D(GH, 2*ghostz[0]-cntstag[0]-i, j)]; + } + } + } + else if (doSym[0] == GFSYM_ROTATION_Z) { + /* + * FIXME: The following loop is local, but global indices are + * FIXME: needed for this to work on multiple processors. + */ for(j=0; j < lssh[1]; j++) { for(i=0; i < ghostz[0]; i++) { - var[CCTK_GFINDEX2D(GH,i,j)] = - sym[0]*var[CCTK_GFINDEX2D(GH,2*ghostz[0]-cntstag[0]-i,j)]; + var[CCTK_GFINDEX2D(GH,i,j)] = sym[0] * + var[CCTK_GFINDEX2D(GH, 2*ghostz[0]-cntstag[0]-i, lssh[1]-j-1)]; } } } - if (doSym[2] == 1) + if (doSym[2] == GFSYM_REFLECTION) + { + for(i=0; i < lssh[0]; i++) + { + for(j=0; j < ghostz[1]; j++) + { + var[CCTK_GFINDEX2D(GH,i,j)] = sym[2] * + var[CCTK_GFINDEX2D(GH, i, 2*ghostz[1]-cntstag[1]-j)]; + } + } + } + else if (doSym[2] == GFSYM_ROTATION_Z) { + /* + * FIXME: The following loop is local, but global indices are + * FIXME: needed for this to work on multiple processors. + */ for(i=0; i < lssh[0]; i++) { for(j=0; j < ghostz[1]; j++) { - var[CCTK_GFINDEX2D(GH,i,j)] = - sym[2]*var[CCTK_GFINDEX2D(GH,i,2*ghostz[1]-cntstag[1]-j)]; + var[CCTK_GFINDEX2D(GH,i,j)] = sym[2] * + var[CCTK_GFINDEX2D(GH, lssh[0]-i-1, 2*ghostz[1]-cntstag[1]-j)]; } } } @@ -210,7 +361,7 @@ int CartApplySym1Di(cGH *GH, int *doSym, int *cntstag, GH = GH; lssh = lssh; - if (doSym[0] == 1) + if (doSym[0] == GFSYM_REFLECTION) { for(i=0; i < ghostz[0]; i++) { |