diff options
author | schnetter <schnetter@c3c03602-0f4f-0410-b3fa-d2c81c8a7dc5> | 2004-04-09 14:32:38 +0000 |
---|---|---|
committer | schnetter <schnetter@c3c03602-0f4f-0410-b3fa-d2c81c8a7dc5> | 2004-04-09 14:32:38 +0000 |
commit | f807b2b60d10d9b0ca76541d5c630ad55eb1bb3e (patch) | |
tree | a236d36218522e388edf4ae854854f4692299f66 /src | |
parent | 3185a4c67b74fab036f554d44ed0e5a2f0d69e60 (diff) |
Fix bugs, clean up, and add test case.
git-svn-id: http://svn.cactuscode.org/arrangements/CactusNumerical/RotatingSymmetry90/trunk@3 c3c03602-0f4f-0410-b3fa-d2c81c8a7dc5
Diffstat (limited to 'src')
-rw-r--r-- | src/registersymmetry.c | 40 | ||||
-rw-r--r-- | src/rotatingsymmetry90.c | 93 |
2 files changed, 81 insertions, 52 deletions
diff --git a/src/registersymmetry.c b/src/registersymmetry.c index be8999c..da80afa 100644 --- a/src/registersymmetry.c +++ b/src/registersymmetry.c @@ -15,27 +15,23 @@ void Rot90_RegisterSymmetry (CCTK_ARGUMENTS) CCTK_INT width[6]; CCTK_INT ierr; - if (rotating_symmetry_90) { - - for (f=0; f<6; ++f) { - faces[f] = 0; - width[f] = 0; - } - - faces[0] = 1; - width[0] = cctk_nghostzones[0]; - faces[1] = 1; - width[1] = cctk_nghostzones[1]; - - handle = SymmetryRegister ("rotating_symmetry_90"); - if (handle < 0) { - CCTK_WARN (0, "Could not register symmetry boundary condition"); - } - - ierr = SymmetryRegisterGrid (cctkGH, handle, faces, width); - if (ierr < 0) { - CCTK_WARN (0, "Could not register the symmetry boundaries -- probably some other thorn has already registered the same boundary faces for a different symmetry"); - } - + for (f=0; f<6; ++f) { + faces[f] = 0; + width[f] = 0; + } + + faces[0] = 1; + width[0] = cctk_nghostzones[0]; + faces[1] = 1; + width[1] = cctk_nghostzones[1]; + + handle = SymmetryRegister ("rotating_symmetry_90"); + if (handle < 0) { + CCTK_WARN (0, "Could not register symmetry boundary condition"); + } + + ierr = SymmetryRegisterGrid (cctkGH, handle, faces, width); + if (ierr < 0) { + CCTK_WARN (0, "Could not register the symmetry boundaries -- probably some other thorn has already registered the same boundary faces for a different symmetry"); } } diff --git a/src/rotatingsymmetry90.c b/src/rotatingsymmetry90.c index f31bb66..b39e518 100644 --- a/src/rotatingsymmetry90.c +++ b/src/rotatingsymmetry90.c @@ -16,6 +16,46 @@ +static int convert_index (int const step, + int const index, + int const * restrict const alldirs, + int * restrict const parity) +{ + int srcindex; + assert (index>=0 && index<3); + assert (alldirs); + assert (alldirs[0]>=0 && alldirs[0]<3); + assert (alldirs[1]>=0 && alldirs[1]<3); + assert (alldirs[1] != alldirs[0]); + assert (parity); + assert (abs(*parity) == 1); + switch (step) { + case 0: + /* x face: counterclockwise, 90 degrees */ + if (index == alldirs[0]) srcindex = alldirs[1], *parity *= -1; + else if (index == alldirs[1]) srcindex = alldirs[0], *parity *= +1; + else srcindex = index , *parity *= +1; + break; + case 1: + /* y face: clockwise, 90 degrees */ + if (index == alldirs[0]) srcindex = alldirs[1], *parity *= +1; + else if (index == alldirs[1]) srcindex = alldirs[0], *parity *= -1; + else srcindex = index , *parity *= +1; + break; + case 2: + /* xy edge: 180 degrees */ + if (index == alldirs[0]) srcindex = alldirs[0], *parity *= -1; + else if (index == alldirs[1]) srcindex = alldirs[1], *parity *= -1; + else srcindex = index , *parity *= +1; + break; + default: + assert (0); + } + return srcindex; +} + + + int BndRot90VI (cGH const * restrict const cctkGH, int const * restrict const stencil, int const vi) @@ -64,8 +104,6 @@ int BndRot90VI (cGH const * restrict const cctkGH, assert (stencil); assert (vi>=0 && vi<CCTK_NumVars()); - if (! rotating_symmetry_90) return; - if (verbose) { fullname = CCTK_FullName(vi); assert (fullname); @@ -74,10 +112,6 @@ int BndRot90VI (cGH const * restrict const cctkGH, fullname); free (fullname); } - for (d=0; d<group.dim; ++d) { - x0[d] = CCTK_ORIGIN_SPACE(d); - dx[d] = CCTK_DELTA_SPACE(d); - } /* Get and check group info */ gi = CCTK_GroupIndexFromVarI (vi); @@ -95,6 +129,11 @@ int BndRot90VI (cGH const * restrict const cctkGH, varptr = CCTK_VarDataPtrI (cctkGH, 0, vi); assert (varptr); + for (d=0; d<group.dim; ++d) { + x0[d] = CCTK_ORIGIN_SPACE(d); + dx[d] = CCTK_DELTA_SPACE(d); + } + /* Find tensor type, source variable, and parity */ { int table; @@ -230,46 +269,38 @@ int BndRot90VI (cGH const * restrict const cctkGH, assert (0); } + parity = +1; if (CCTK_EQUALS (tensortypealias, "scalar")) { /* scalar */ srcvi = vi; - parity = +1; + /* do nothing */ } else if (CCTK_EQUALS (tensortypealias, "u")) { /* vector */ int srcindex; - if (srcindex == dir[0]) srcindex = otherdir[0], parity = +1; - else if (srcindex == otherdir[0]) srcindex = dir[0], parity = -1; - else srcindex = index, parity = +1; + srcindex = convert_index (step, index, alldirs, &parity); srcvi = firstvar + srcindex; } else if (CCTK_EQUALS (tensortypealias, "dd_sym")) { /* symmetric tensor */ int index1, index2; int srcindex1, srcindex2; int srcindex; - switch (index) { - case 0: index1=0, index2=0; break; - case 1: index1=0, index2=1; break; - case 2: index1=0, index2=2; break; - case 3: index1=1, index2=1; break; - case 4: index1=1, index2=2; break; - case 5: index1=2, index2=2; break; - default: assert(0); + { + int const expand1[6] = { 0,0,0,1,1,2 }; + int const expand2[6] = { 0,1,2,1,2,2 }; + index1 = expand1[index]; + index2 = expand2[index]; } - parity = +1; - if (srcindex1 == dir[0]) srcindex1 = otherdir[0], parity *= +1; - else if (srcindex1 == otherdir[0]) srcindex1 = dir[0], parity *= -1; - else srcindex1 = index1, parity *= +1; - if (srcindex2 == dir[0]) srcindex2 = otherdir[0], parity *= +1; - else if (srcindex2 == otherdir[0]) srcindex2 = dir[0], parity *= -1; - else srcindex2 = index2, parity *= +1; + srcindex1 = convert_index (step, index1, alldirs, &parity); + srcindex2 = convert_index (step, index2, alldirs, &parity); { - int compact[3][3] = { 0,1,2, 1,3,4, 2,4,5 }; + int const compact[3][3] = { 0,1,2, 1,3,4, 2,4,5 }; srcindex = compact[srcindex1][srcindex2]; } srcvi = firstvar + srcindex; } else { assert (0); } + srcptr = CCTK_VarDataPtrI (cctkGH, 0, srcvi); assert (srcptr); @@ -326,19 +357,22 @@ int BndRot90VI (cGH const * restrict const cctkGH, switch (ndirs) { case 1: /* face */ - for (q=0; q<1; ++q) { + for (q=0; q<ndirs; ++q) { xferinfo[otherdir[q]].src.off = stencil[otherdir[q]] + offset[otherdir[q]]; xferinfo[otherdir[q]].src.len = stencil[ dir[q]]; xferinfo[ dir[q]].dst.off = 0; xferinfo[ dir[q]].dst.len = stencil[ dir[q]]; xferinfo[ dir[q]].xpose = otherdir[q]; - xferinfo[otherdir[q]].xpose = dir[1]; + xferinfo[otherdir[q]].xpose = dir[q]; + // Note: For other rotations that in the xy plane, the + // flipping might be different + xferinfo[ dir[q]].flip = 1; } break; case 2: /* edge */ - for (q=0; q<1; ++q) { + for (q=0; q<ndirs; ++q) { xferinfo[otherdir[q]].src.off = stencil[otherdir[q]] + offset[otherdir[q]]; xferinfo[otherdir[q]].src.len = stencil[ dir[q]]; xferinfo[ dir[q]].dst.off = 0; @@ -369,7 +403,6 @@ int BndRot90VI (cGH const * restrict const cctkGH, assert (abs(parity) == 1); if (parity == -1) { int i, j, k; - assert (dir == 0); assert (group.dim == 3); assert (group.vartype == CCTK_VARIABLE_REAL); for (k=0; k<xferinfo[2].dst.len; ++k) { |