From 55e77c2e6ef77d1234d1844ee759ab8f9f9f2348 Mon Sep 17 00:00:00 2001 From: ianhin Date: Mon, 15 Feb 2010 13:17:11 +0000 Subject: Add ManualCartesian tensor type git-svn-id: http://svn.cactuscode.org/arrangements/CactusNumerical/ReflectionSymmetry/trunk@32 082bdb00-0f4f-0410-b49e-b1835e5f2039 --- src/apply.c | 17 +++++++++++++-- src/interpolate.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- src/reflection.h | 3 +++ 3 files changed, 80 insertions(+), 3 deletions(-) diff --git a/src/apply.c b/src/apply.c index 87d5eb3..278903a 100644 --- a/src/apply.c +++ b/src/apply.c @@ -178,7 +178,7 @@ BndReflectVI (cGH const * restrict const cctkGH, int table; char tensortypealias[1000]; enum tensortype { UNKNOWN, - SCALAR, VECTOR, SYMTENSOR, TENSOR, WEYLSCALARS_REAL }; + SCALAR, VECTOR, SYMTENSOR, TENSOR, WEYLSCALARS_REAL, MANUALCARTESIAN }; enum tensortype ttype; CCTK_INT tensorparity; int tcomponent; @@ -191,7 +191,8 @@ BndReflectVI (cGH const * restrict const cctkGH, int lsh[3], imin[3], imax[3], ioff[3], idir[3]; int parity; - + int manual_parities[3]; + int d; int ierr; @@ -346,6 +347,10 @@ BndReflectVI (cGH const * restrict const cctkGH, assert (numvars == 10); ttype = WEYLSCALARS_REAL; tcomponent = vi - firstvar; + } else if (CCTK_EQUALS (tensortypealias, "ManualCartesian")) { + /* Reflection symmetries specified by hand */ + ttype = MANUALCARTESIAN; + tcomponent = vi - firstvar; } else { char * groupname = CCTK_GroupName(gi); assert (groupname); @@ -371,6 +376,11 @@ BndReflectVI (cGH const * restrict const cctkGH, case WEYLSCALARS_REAL: assert (tcomponent>=0 && tcomponent<10); break; + case MANUALCARTESIAN: + /* No restriction on number of components */ + ReflectionSymmetry_GetManualParities(table, gi, manual_parities); + break; + default: assert (0); } @@ -463,6 +473,9 @@ BndReflectVI (cGH const * restrict const cctkGH, parity *= weylparities[tcomponent][dir]; break; } + case MANUALCARTESIAN: + parity = manual_parities[dir]; + break; default: assert (0); } diff --git a/src/interpolate.c b/src/interpolate.c index d30ed32..b719f41 100644 --- a/src/interpolate.c +++ b/src/interpolate.c @@ -164,7 +164,7 @@ ReflectionSymmetry_Interpolate (CCTK_POINTER_TO_CONST restrict const cctkGH_, int table; char tensortypealias[1000]; enum tensortype { UNKNOWN, - SCALAR, VECTOR, SYMTENSOR, TENSOR, WEYLSCALARS_REAL }; + SCALAR, VECTOR, SYMTENSOR, TENSOR, WEYLSCALARS_REAL, MANUALCARTESIAN }; enum tensortype ttype; CCTK_INT tensorparity; int tcomponent; @@ -282,6 +282,10 @@ ReflectionSymmetry_Interpolate (CCTK_POINTER_TO_CONST restrict const cctkGH_, assert (numvars == 10); ttype = WEYLSCALARS_REAL; tcomponent = vi - firstvar; + } else if (CCTK_EQUALS (tensortypealias, "ManualCartesian")) { + /* Reflection symmetries specified by hand */ + ttype = MANUALCARTESIAN; + tcomponent = vi - firstvar; } else { groupname = CCTK_GroupName(gi); assert (groupname); @@ -307,6 +311,9 @@ ReflectionSymmetry_Interpolate (CCTK_POINTER_TO_CONST restrict const cctkGH_, case WEYLSCALARS_REAL: assert (tcomponent>=0 && tcomponent<10); break; + case MANUALCARTESIAN: + /* No restriction on number of components */ + break; default: assert (0); } @@ -376,6 +383,9 @@ ReflectionSymmetry_Interpolate (CCTK_POINTER_TO_CONST restrict const cctkGH_, } break; } + case MANUALCARTESIAN: + ReflectionSymmetry_GetManualParities(table, gi, parities); + break; default: assert (0); } @@ -437,3 +447,54 @@ ReflectionSymmetry_Interpolate (CCTK_POINTER_TO_CONST restrict const cctkGH_, /* Return */ return iret; } + +void ReflectionSymmetry_GetManualParities(int table, int gi, int *parities) +{ + char cartsyms[100]; + char *groupname = NULL; + int i = 0; + int ierr = -1; + + /* Get and check tensor type information */ + ierr = Util_TableGetString + (table, sizeof cartsyms, cartsyms, "cartesianreflectionparities"); + if (ierr == UTIL_ERROR_TABLE_NO_SUCH_KEY) { + groupname = CCTK_GroupName(gi); + assert (groupname); + CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING, + "Cartesian refection parity not declared for group \"%s\" -- aborting", + groupname); + assert(0); + } else if (ierr<0) { + groupname = CCTK_GroupName(gi); + assert (groupname); + CCTK_VWarn (0, __LINE__, __FILE__, CCTK_THORNSTRING, + "Error in tensor type alias declaration for group \"%s\"", + groupname); + free (groupname); + } + + if (strlen(cartsyms) != 3) + { + CCTK_VWarn (0, __LINE__, __FILE__, CCTK_THORNSTRING, + "Invalid format for cartesianreflectionparities: must be xxx where x is + or - for group %s", + groupname); + } + + for (i = 0; i < 3; i++) + { + switch (cartsyms[i]) + { + case '+': + parities[i] = 1; + break; + case '-': + parities[i] = -1; + break; + default: + CCTK_VWarn (0, __LINE__, __FILE__, CCTK_THORNSTRING, + "Invalid format for cartesianreflectionparities: must be xxx where x is + or - for group %s", + groupname); + } + } +} diff --git a/src/reflection.h b/src/reflection.h index dc12fec..49266ec 100644 --- a/src/reflection.h +++ b/src/reflection.h @@ -26,4 +26,7 @@ ReflectionSymmetry_Register (CCTK_ARGUMENTS); void ReflectionSymmetry_Apply (CCTK_ARGUMENTS); +void +ReflectionSymmetry_GetManualParities(int table, int gi, int *parities); + #endif /* ! defined REFLECTIONSYMMETRY_H */ -- cgit v1.2.3