From 5607ee841d9d3e8954af8379503d3a7c309ecfce Mon Sep 17 00:00:00 2001 From: schnetter Date: Wed, 11 Nov 2009 03:26:14 +0000 Subject: Correct indexing error with staggered grids. Shorten and simplify the code that switches between the variable types. Remove cvs $Header$ comments. git-svn-id: http://svn.cactuscode.org/arrangements/CactusNumerical/ReflectionSymmetry/trunk@27 082bdb00-0f4f-0410-b49e-b1835e5f2039 --- doc/documentation.tex | 3 - interface.ccl | 1 - param.ccl | 1 - schedule.ccl | 1 - src/apply.c | 159 +++++++++++++++++++------------------------------- src/interpolate.c | 5 -- src/make.code.defn | 1 - src/reflection.h | 2 - src/register.c | 5 -- 9 files changed, 60 insertions(+), 118 deletions(-) diff --git a/doc/documentation.tex b/doc/documentation.tex index fbc1f83..96cf75e 100644 --- a/doc/documentation.tex +++ b/doc/documentation.tex @@ -2,7 +2,6 @@ % Cactus Thorn template for ThornGuide documentation % Author: Ian Kelley % Date: Sun Jun 02, 2002 -% $Header$ % % Thorn documentation in the latex file doc/documentation.tex % will be included in ThornGuides built with the Cactus make system. @@ -66,7 +65,6 @@ % *======================================================================* % If you are using CVS use this line to give version information -% $Header$ \documentclass{article} @@ -86,7 +84,6 @@ % the date your document was last changed, if your document is in CVS, % please use: -% \date{$ $Date$ $} \date{June 01 2004} \maketitle diff --git a/interface.ccl b/interface.ccl index d1c90c4..698d073 100644 --- a/interface.ccl +++ b/interface.ccl @@ -1,5 +1,4 @@ # Interface definition for thorn ReflectionSymmetry -# $Header$ IMPLEMENTS: ReflectionSymmetry diff --git a/param.ccl b/param.ccl index f6406ec..d32ff00 100644 --- a/param.ccl +++ b/param.ccl @@ -1,5 +1,4 @@ # Parameter definitions for thorn ReflectionSymmetry -# $Header$ BOOLEAN verbose "Produce screen output while applying boundary conditions" { diff --git a/schedule.ccl b/schedule.ccl index 8c5db0e..f872979 100644 --- a/schedule.ccl +++ b/schedule.ccl @@ -1,5 +1,4 @@ # Schedule definitions for thorn ReflectionSymmetry -# $Header$ SCHEDULE ReflectionSymmetry_Register IN SymmetryRegister { diff --git a/src/apply.c b/src/apply.c index c1736c6..17e2f1c 100644 --- a/src/apply.c +++ b/src/apply.c @@ -1,4 +1,5 @@ #include +#include #include #include @@ -13,11 +14,6 @@ -static const char rcsid[] = "$Header$"; -CCTK_FILEVERSION(AEIDevelopment_ReflectionSymmetry_apply_c); - - - #define COPY_PRE(VARTYPE) \ static void \ copy_##VARTYPE (VARTYPE const * restrict const srcvar, \ @@ -29,24 +25,27 @@ CCTK_FILEVERSION(AEIDevelopment_ReflectionSymmetry_apply_c); int const idir, int const jdir, int const kdir, \ int const parity) \ { \ + assert (abs(idir)==1); \ + assert (abs(jdir)==1); \ + assert (abs(kdir)==1); \ int const iioff = ioff + (1 - idir) * imin; \ int const jjoff = joff + (1 - jdir) * jmin; \ int const kkoff = koff + (1 - kdir) * kmin; \ - int const iimin = iioff + idir*imin; \ - int const jjmin = jjoff + jdir*jmin; \ - int const kkmin = kkoff + kdir*kmin; \ - int const iimax = iioff + idir*imax; \ - int const jjmax = jjoff + jdir*jmax; \ - int const kkmax = kkoff + kdir*kmax; \ - assert(imin>=0 && imax<=ni); \ - assert(jmin>=0 && jmax<=nj); \ - assert(kmin>=0 && kmax<=nk); \ - assert(iimin>=0 && iimax<=ni); \ - assert(jjmin>=0 && jjmax<=nj); \ - assert(kkmin>=0 && kkmax<=nk); \ - assert(iimax>=-1 && iimin=-1 && jjmin=-1 && kkmin=0 && imax<=ni); \ + assert (jmin>=0 && jmax<=nj); \ + assert (kmin>=0 && kmax<=nk); \ + assert (iimin>=0 && iimax<=ni); \ + assert (jjmin>=0 && jjmax<=nj); \ + assert (kkmin>=0 && kkmax<=nk); \ + assert (iimax>=-1 && iimin=-1 && jjmin=-1 && kkmin= CCTK_NumVars()) { CCTK_WARN (0, "Illegal variable index"); } @@ -463,7 +458,7 @@ BndReflectVI (cGH const * restrict const cctkGH, {-1,-1,-1}, {+1,+1,+1}, {-1,-1,-1}, - {+1,+1,+1}, + {+1,+1,+1}, {-1,-1,-1}}; parity *= weylparities[tcomponent][dir]; break; @@ -483,30 +478,48 @@ BndReflectVI (cGH const * restrict const cctkGH, if (face == 0) { imax[dir] = cctkGH->cctk_nghostzones[dir]; ioff[dir] = (+ 2*cctkGH->cctk_nghostzones[dir] - 1 - + (do_stagger[2*dir+face] ? 0 : 1)); + - (do_stagger[2*dir+face] ? 0 : 1)); idir[dir] = -1; } else { imin[dir] = cctkGH->cctk_lsh[dir] - cctkGH->cctk_nghostzones[dir]; ioff[dir] = (- 2*cctkGH->cctk_nghostzones[dir] + 1 - - (do_stagger[2*dir+face] ? 0 : 1)); + + (do_stagger[2*dir+face] ? 0 : 1)); idir[dir] = -1; } + /* Ensure that there are sufficient interior zones, since + this thorn does not support filling symmetry zones from + other symmetry zones */ + { + int const have_points = cctkGH->cctk_lsh[dir]; + int const need_points = + 3 * cctkGH->cctk_nghostzones[dir] + + do_stagger[2*dir] + do_stagger[2*dir+1]; + if (need_points < have_points) { + CCTK_VWarn (CCTK_WARN_ABORT, __LINE__, __FILE__, CCTK_THORNSTRING, + "Cannot apply symmetry boundary zones in the %s %c direction, since there seem to be more symmetry zones than interior zones", + (face==0 ? "lower" : "upper"), + "xyz"[dir]); + } + } + /* Copy region */ switch (group.vartype) { +#define ARGS varptr, varptr, \ + lsh[0], lsh[1], lsh[2], \ + imin[0], imin[1], imin[2], \ + imax[0], imax[1], imax[2], \ + ioff[0], ioff[1], ioff[2], \ + idir[0], idir[1], idir[2], \ + parity + #ifdef HAVE_CCTK_INT1 case CCTK_VARIABLE_INT1: #ifdef CCTK_INTEGER_PRECISION_1 case CCTK_VARIABLE_INT: #endif - copy_CCTK_INT1 (varptr, varptr, - lsh[0], lsh[1], lsh[2], - imin[0], imin[1], imin[2], - imax[0], imax[1], imax[2], - ioff[0], ioff[1], ioff[2], - idir[0], idir[1], idir[2], - parity); + copy_CCTK_INT1 (ARGS); break; #endif @@ -515,13 +528,7 @@ BndReflectVI (cGH const * restrict const cctkGH, #ifdef CCTK_INTEGER_PRECISION_2 case CCTK_VARIABLE_INT: #endif - copy_CCTK_INT2 (varptr, varptr, - lsh[0], lsh[1], lsh[2], - imin[0], imin[1], imin[2], - imax[0], imax[1], imax[2], - ioff[0], ioff[1], ioff[2], - idir[0], idir[1], idir[2], - parity); + copy_CCTK_INT2 (ARGS); break; #endif @@ -530,13 +537,7 @@ BndReflectVI (cGH const * restrict const cctkGH, #ifdef CCTK_INTEGER_PRECISION_4 case CCTK_VARIABLE_INT: #endif - copy_CCTK_INT4 (varptr, varptr, - lsh[0], lsh[1], lsh[2], - imin[0], imin[1], imin[2], - imax[0], imax[1], imax[2], - ioff[0], ioff[1], ioff[2], - idir[0], idir[1], idir[2], - parity); + copy_CCTK_INT4 (ARGS); break; #endif @@ -545,13 +546,7 @@ BndReflectVI (cGH const * restrict const cctkGH, #ifdef CCTK_INTEGER_PRECISION_8 case CCTK_VARIABLE_INT: #endif - copy_CCTK_INT8 (varptr, varptr, - lsh[0], lsh[1], lsh[2], - imin[0], imin[1], imin[2], - imax[0], imax[1], imax[2], - ioff[0], ioff[1], ioff[2], - idir[0], idir[1], idir[2], - parity); + copy_CCTK_INT8 (ARGS); break; #endif @@ -560,13 +555,7 @@ BndReflectVI (cGH const * restrict const cctkGH, #ifdef CCTK_REAL_PRECISION_4 case CCTK_VARIABLE_REAL: #endif - copy_CCTK_REAL4 (varptr, varptr, - lsh[0], lsh[1], lsh[2], - imin[0], imin[1], imin[2], - imax[0], imax[1], imax[2], - ioff[0], ioff[1], ioff[2], - idir[0], idir[1], idir[2], - parity); + copy_CCTK_REAL4 (ARGS); break; #endif @@ -575,13 +564,7 @@ BndReflectVI (cGH const * restrict const cctkGH, #ifdef CCTK_REAL_PRECISION_8 case CCTK_VARIABLE_REAL: #endif - copy_CCTK_REAL8 (varptr, varptr, - lsh[0], lsh[1], lsh[2], - imin[0], imin[1], imin[2], - imax[0], imax[1], imax[2], - ioff[0], ioff[1], ioff[2], - idir[0], idir[1], idir[2], - parity); + copy_CCTK_REAL8 (ARGS); break; #endif @@ -590,13 +573,7 @@ BndReflectVI (cGH const * restrict const cctkGH, #ifdef CCTK_REAL_PRECISION_16 case CCTK_VARIABLE_REAL: #endif - copy_CCTK_REAL16 (varptr, varptr, - lsh[0], lsh[1], lsh[2], - imin[0], imin[1], imin[2], - imax[0], imax[1], imax[2], - ioff[0], ioff[1], ioff[2], - idir[0], idir[1], idir[2], - parity); + copy_CCTK_REAL16 (ARGS); break; #endif @@ -605,13 +582,7 @@ BndReflectVI (cGH const * restrict const cctkGH, #ifdef CCTK_COMPLEX_PRECISION_8 case CCTK_VARIABLE_COMPLEX: #endif - copy_CCTK_COMPLEX8 (varptr, varptr, - lsh[0], lsh[1], lsh[2], - imin[0], imin[1], imin[2], - imax[0], imax[1], imax[2], - ioff[0], ioff[1], ioff[2], - idir[0], idir[1], idir[2], - parity); + copy_CCTK_COMPLEX8 (ARGS); break; #endif @@ -620,13 +591,7 @@ BndReflectVI (cGH const * restrict const cctkGH, #ifdef CCTK_COMPLEX_PRECISION_16 case CCTK_VARIABLE_COMPLEX: #endif - copy_CCTK_COMPLEX16 (varptr, varptr, - lsh[0], lsh[1], lsh[2], - imin[0], imin[1], imin[2], - imax[0], imax[1], imax[2], - ioff[0], ioff[1], ioff[2], - idir[0], idir[1], idir[2], - parity); + copy_CCTK_COMPLEX16 (ARGS); break; #endif @@ -635,16 +600,12 @@ BndReflectVI (cGH const * restrict const cctkGH, #ifdef CCTK_COMPLEX_PRECISION_32 case CCTK_VARIABLE_COMPLEX: #endif - copy_CCTK_COMPLEX32 (varptr, varptr, - lsh[0], lsh[1], lsh[2], - imin[0], imin[1], imin[2], - imax[0], imax[1], imax[2], - ioff[0], ioff[1], ioff[2], - idir[0], idir[1], idir[2], - parity); + copy_CCTK_COMPLEX32 (ARGS); break; #endif +#undef ARGS + default: CCTK_WARN (0, "Unsupported variable type"); } @@ -860,7 +821,7 @@ ReflectionSymmetry_Apply (CCTK_ARGUMENTS) CheckBoundaryParameters (cctkGH, vi, stencil); - ierr = BndReflectVI (cctkGH, stencil, vi); + ierr = BndReflectVI (cctkGH, vi); if (ierr) { CCTK_WARN (0, "Internal error in BndReflectVI"); } diff --git a/src/interpolate.c b/src/interpolate.c index 9ec8c17..d30ed32 100644 --- a/src/interpolate.c +++ b/src/interpolate.c @@ -13,11 +13,6 @@ -static const char rcsid[] = "$Header$"; -CCTK_FILEVERSION(AEIDevelopment_ReflectionSymmetry_interpolate_c); - - - CCTK_INT ReflectionSymmetry_Interpolate (CCTK_POINTER_TO_CONST restrict const cctkGH_, CCTK_INT const N_dims, diff --git a/src/make.code.defn b/src/make.code.defn index 24a04f5..06e0a02 100644 --- a/src/make.code.defn +++ b/src/make.code.defn @@ -1,5 +1,4 @@ # Main make.code.defn file for thorn ReflectionSymmetry -# $Header$ # Source files in this directory SRCS = apply.c interpolate.c register.c diff --git a/src/reflection.h b/src/reflection.h index 19328a7..dc12fec 100644 --- a/src/reflection.h +++ b/src/reflection.h @@ -1,5 +1,3 @@ -/* $Header$ */ - #ifndef REFLECTIONSYMMETRY_H #define REFLECTIONSYMMETRY_H diff --git a/src/register.c b/src/register.c index 2ae4b58..5a538e0 100644 --- a/src/register.c +++ b/src/register.c @@ -6,11 +6,6 @@ -static const char rcsid[] = "$Header$"; -CCTK_FILEVERSION(AEIDevelopment_ReflectionSymmetry_register_c); - - - void ReflectionSymmetry_Register (CCTK_ARGUMENTS) { -- cgit v1.2.3