| { |
| "thorn_name": "CactusNumerical/ReflectionSymmetry", |
| "url": "https://bitbucket.org/cactuscode/cactusnumerical.git", |
| "configuration": "", |
| "interface": "# Interface definition for thorn ReflectionSymmetry\n\nIMPLEMENTS: ReflectionSymmetry\n\n\n\nCCTK_INT FUNCTION SymmetryRegister (CCTK_STRING IN sym_name)\nREQUIRES FUNCTION SymmetryRegister\n\n# which_faces : array [N_FACES] \n# symmetry_zone_width: array [N_FACES]\nCCTK_INT FUNCTION \\\n SymmetryRegisterGrid \\\n (CCTK_POINTER IN cctkGH, \\\n CCTK_INT IN sym_handle, \\\n CCTK_INT IN ARRAY which_faces, \\\n CCTK_INT IN ARRAY symmetry_zone_width)\nREQUIRES FUNCTION SymmetryRegisterGrid\n\nCCTK_INT FUNCTION \\\n SymmetryRegisterGridInterpolator \\\n (CCTK_POINTER IN cctkGH, \\\n CCTK_INT IN sym_handle, \\\n CCTK_INT CCTK_FPOINTER IN symmetry_interpolate \\\n (CCTK_POINTER_TO_CONST IN cctkGH, \\\n CCTK_INT IN N_dims, \\\n CCTK_INT IN local_interp_handle, \\\n CCTK_INT IN param_table_handle, \\\n CCTK_INT IN coord_system_handle, \\\n CCTK_INT IN N_interp_points, \\\n CCTK_INT IN interp_coords_type, \\\n CCTK_POINTER_TO_CONST ARRAY IN interp_coords, \\\n CCTK_INT IN N_input_arrays, \\\n CCTK_INT ARRAY IN input_array_indices, \\\n CCTK_INT IN N_output_arrays, \\\n CCTK_INT ARRAY IN output_array_types, \\\n CCTK_POINTER ARRAY IN output_arrays, \\\n CCTK_INT IN faces))\nREQUIRES FUNCTION SymmetryRegisterGridInterpolator\n\nCCTK_INT FUNCTION \\\n SymmetryInterpolateFaces \\\n (CCTK_POINTER_TO_CONST IN cctkGH, \\\n CCTK_INT IN N_dims, \\\n CCTK_INT IN local_interp_handle, \\\n CCTK_INT IN param_table_handle, \\\n CCTK_INT IN coord_system_handle, \\\n CCTK_INT IN N_interp_points, \\\n CCTK_INT IN interp_coords_type, \\\n CCTK_POINTER_TO_CONST ARRAY IN interp_coords, \\\n CCTK_INT IN N_input_arrays, \\\n CCTK_INT ARRAY IN input_array_indices, \\\n CCTK_INT IN N_output_arrays, \\\n CCTK_INT ARRAY IN output_array_types, \\\n CCTK_POINTER ARRAY IN output_arrays, \\\n CCTK_INT IN faces)\nREQUIRES FUNCTION SymmetryInterpolateFaces\n\n\n\nCCTK_INT FUNCTION Boundary_SelectedGVs \\\n (CCTK_POINTER_TO_CONST IN GH, \\\n CCTK_INT IN array_size, \\\n CCTK_INT ARRAY OUT var_indicies, \\\n CCTK_INT ARRAY OUT faces, \\\n CCTK_INT ARRAY OUT boundary_widths, \\\n CCTK_INT ARRAY OUT table_handles, \\\n CCTK_STRING IN bc_name)\nUSES FUNCTION Boundary_SelectedGVs\n\n\n\nCCTK_INT FUNCTION GetBoundarySpecification \\\n (CCTK_INT IN size, \\\n CCTK_INT OUT ARRAY nboundaryzones, \\\n CCTK_INT OUT ARRAY is_internal, \\\n CCTK_INT OUT ARRAY is_staggered, \\\n CCTK_INT OUT ARRAY shiftout)\nREQUIRES FUNCTION GetBoundarySpecification\n", |
| "param": "# Parameter definitions for thorn ReflectionSymmetry\n\nBOOLEAN verbose \"Produce screen output while applying boundary conditions\"\n{\n} \"no\"\n\n\n\nBOOLEAN reflection_x \"Reflection symmetry at the lower x boundary\"\n{\n} \"no\"\n\nBOOLEAN reflection_y \"Reflection symmetry at the lower y boundary\"\n{\n} \"no\"\n\nBOOLEAN reflection_z \"Reflection symmetry at the lower z boundary\"\n{\n} \"no\"\n\n\n\nBOOLEAN reflection_upper_x \"Reflection symmetry at the upper x boundary\"\n{\n} \"no\"\n\nBOOLEAN reflection_upper_y \"Reflection symmetry at the upper y boundary\"\n{\n} \"no\"\n\nBOOLEAN reflection_upper_z \"Reflection symmetry at the upper z boundary\"\n{\n} \"no\"\n\n\n\nBOOLEAN avoid_origin_x \"Stagger about the origin on the lower x boundary?\"\n{\n} \"yes\"\n\nBOOLEAN avoid_origin_y \"Stagger about the origin on the lower y boundary?\"\n{\n} \"yes\"\n\nBOOLEAN avoid_origin_z \"Stagger about the origin on the lower z boundary?\"\n{\n} \"yes\"\n\n\n\nBOOLEAN avoid_origin_upper_x \"Stagger about the origin on the upper x boundary?\"\n{\n} \"yes\"\n\nBOOLEAN avoid_origin_upper_y \"Stagger about the origin on the upper y boundary?\"\n{\n} \"yes\"\n\nBOOLEAN avoid_origin_upper_z \"Stagger about the origin on the upper z boundary?\"\n{\n} \"yes\"\n", |
| "schedule": "# Schedule definitions for thorn ReflectionSymmetry\n\nSCHEDULE ReflectionSymmetry_Register IN SymmetryRegister\n{\n LANG: C\n} \"Register reflection symmetry boundaries\"\n\nSCHEDULE ReflectionSymmetry_Apply IN BoundaryConditions\n{\n LANG: C\n} \"Apply reflection symmetries\"\n", |
| "src": { |
| "make.code.defn": "# Main make.code.defn file for thorn ReflectionSymmetry\n\n# Source files in this directory\nSRCS = apply.c interpolate.c register.c\n\n# Subdirectories containing source files\nSUBDIRS = \n", |
| "interpolate.c": "#include <assert.h>\n#include <math.h>\n#include <stdlib.h>\n#include <string.h>\n\n#include \"cctk.h\"\n#include \"cctk_Parameters.h\"\n\n#include \"util_ErrorCodes.h\"\n#include \"util_Table.h\"\n\n#include \"reflection.h\"\n\n\n\nCCTK_INT\nReflectionSymmetry_Interpolate (CCTK_POINTER_TO_CONST restrict const cctkGH,\n CCTK_INT const N_dims,\n CCTK_INT const local_interp_handle,\n CCTK_INT const param_table_handle,\n CCTK_INT const coord_system_handle,\n CCTK_INT const N_interp_points,\n CCTK_INT const interp_coords_type,\n CCTK_POINTER_TO_CONST restrict const interp_coords[],\n CCTK_INT const N_input_arrays,\n CCTK_INT const input_array_indices[],\n CCTK_INT const N_output_arrays,\n CCTK_INT const output_array_types[],\n CCTK_POINTER restrict const output_arrays[],\n CCTK_INT const faces)\n{\n DECLARE_CCTK_PARAMETERS;\n \n int do_reflection[6];\n \n CCTK_POINTER_TO_CONST restrict new_interp_coords[3];\n CCTK_INT newfaces;\n \n CCTK_INT * restrict operand_indices;\n CCTK_INT * restrict operation_codes;\n CCTK_INT * restrict output_array_indices;\n \n int dir;\n \n int iret;\n \n int m;\n int n;\n int d;\n \n int ierr;\n \n \n \n /* Get symmetry information */\n do_reflection[0] = reflection_x;\n do_reflection[1] = reflection_upper_x;\n do_reflection[2] = reflection_y;\n do_reflection[3] = reflection_upper_y;\n do_reflection[4] = reflection_z;\n do_reflection[5] = reflection_upper_z;\n \n newfaces = faces;\n for (d=0; d<6; ++d) {\n if (do_reflection[d]) {\n assert (newfaces & (1 << d));\n newfaces &= ~ (1 << d);\n }\n }\n \n \n \n /* Fold coordinates */\n assert (interp_coords_type == CCTK_VARIABLE_REAL);\n for (dir=0; dir<3; ++dir) {\n assert (! do_reflection[2*dir+1]);\n \n if (do_reflection[2*dir]) {\n CCTK_REAL * restrict coords_in_dir\n = malloc (N_interp_points * sizeof (CCTK_REAL));\n assert (N_interp_points == 0 || coords_in_dir);\n \n for (n=0; n<N_interp_points; ++n) {\n CCTK_REAL const pos = ((CCTK_REAL const *)interp_coords[dir])[n];\n CCTK_REAL const newpos = fabs(pos);\n coords_in_dir[n] = newpos;\n }\n new_interp_coords[dir] = coords_in_dir;\n } else {\n new_interp_coords[dir] = interp_coords[dir];\n }\n }\n \n \n \n /* Recursive call */\n iret = SymmetryInterpolateFaces\n (cctkGH, \n N_dims, local_interp_handle, param_table_handle, coord_system_handle,\n N_interp_points, interp_coords_type, (CCTK_POINTER_TO_CONST)new_interp_coords,\n N_input_arrays, input_array_indices,\n N_output_arrays, output_array_types, (CCTK_POINTER_TO_CONST)output_arrays,\n newfaces);\n \n \n \n /* Free coordinates */\n for (dir=0; dir<3; ++dir) {\n if (do_reflection[2*dir]) {\n free ((void*)new_interp_coords[dir]);\n }\n }\n \n \n \n /* Find output variable indices */\n operand_indices = malloc (N_output_arrays * sizeof *operand_indices);\n assert (operand_indices);\n ierr = Util_TableGetIntArray\n (param_table_handle, N_output_arrays, operand_indices, \"operand_indices\");\n if (ierr == UTIL_ERROR_TABLE_NO_SUCH_KEY) {\n assert (N_output_arrays == N_input_arrays);\n for (m=0; m<N_output_arrays; ++m) {\n operand_indices[m] = m; /* set output index to input index */\n }\n } else {\n assert (ierr == N_output_arrays);\n }\n \n operation_codes = malloc (N_output_arrays * sizeof *operation_codes);\n assert (operation_codes);\n ierr = Util_TableGetIntArray\n (param_table_handle, N_output_arrays, operation_codes, \"operation_codes\");\n if (ierr == UTIL_ERROR_TABLE_NO_SUCH_KEY) {\n assert (N_output_arrays == N_input_arrays);\n for (m=0; m<N_output_arrays; ++m) {\n operation_codes[m] = 0; /* do not take derivatives */\n }\n } else {\n assert (ierr == N_output_arrays);\n }\n \n output_array_indices\n = malloc (N_output_arrays * sizeof *output_array_indices);\n assert (output_array_indices);\n for (m=0; m<N_output_arrays; ++m) {\n assert (operand_indices[m]>=0 && operand_indices[m]<N_input_arrays);\n output_array_indices[m] = input_array_indices[operand_indices[m]];\n assert (output_array_indices[m]==-1\n || (output_array_indices[m]>=0\n && output_array_indices[m]<CCTK_NumVars()));\n }\n \n \n \n /* Unfold tensor types */\n for (m=0; m<N_output_arrays; ++m) {\n if (output_array_indices[m]!=-1) {\n \n int vi, gi;\n int numvars, firstvar, vectorlength;\n cGroup group;\n char * groupname;\n \n int table;\n char tensortypealias[1000];\n enum tensortype { UNKNOWN,\n SCALAR, VECTOR, SYMTENSOR, SYMTENSOR3, TENSOR,\n WEYLSCALARS_REAL, MANUALCARTESIAN };\n enum tensortype ttype;\n CCTK_INT tensorparity;\n int tcomponent;\n \n int parities[3];\n int check_dir[3];\n int needs_checking;\n\n \n vi = output_array_indices[m];\n assert (vi>=0 && vi<CCTK_NumVars());\n gi = CCTK_GroupIndexFromVarI (vi);\n assert (gi>=0 && gi<CCTK_NumGroups());\n\n ierr = CCTK_GroupData (gi, &group);\n assert (!ierr);\n \n numvars = CCTK_NumVarsInGroupI(gi);\n assert (numvars>0);\n firstvar = CCTK_FirstVarIndexI(gi);\n assert (firstvar>=0);\n vectorlength = group.vectorlength;\n assert (vectorlength>=0);\n assert (vectorlength==1 || group.vectorgroup);\n table = CCTK_GroupTagsTableI(gi);\n assert (table>=0);\n \n \n \n /* Get and check tensor type information */\n ierr = Util_TableGetString\n (table, sizeof tensortypealias, tensortypealias, \"tensortypealias\");\n if (ierr == UTIL_ERROR_TABLE_NO_SUCH_KEY) {\n groupname = CCTK_GroupName(gi);\n assert (groupname);\n CCTK_VWarn (4, __LINE__, __FILE__, CCTK_THORNSTRING,\n \"Tensor type alias not declared for group \\\"%s\\\" -- assuming a scalar\",\n groupname);\n free (groupname);\n strcpy (tensortypealias, \"scalar\");\n } else if (ierr<0) {\n groupname = CCTK_GroupName(gi);\n assert (groupname);\n CCTK_VWarn (0, __LINE__, __FILE__, CCTK_THORNSTRING,\n \"Error in tensor type alias declaration for group \\\"%s\\\"\",\n groupname);\n free (groupname);\n }\n \n ttype = UNKNOWN;\n tcomponent = 0;\n if (CCTK_EQUALS (tensortypealias, \"scalar\")) {\n /* scalar */\n if (numvars != vectorlength) {\n groupname = CCTK_GroupName(gi);\n assert (groupname);\n CCTK_VWarn (4, __LINE__, __FILE__, CCTK_THORNSTRING,\n \"Group \\\"%s\\\" has the tensor type alias \\\"scalar\\\", but contains more than 1 element\",\n groupname);\n free (groupname);\n }\n ttype = SCALAR;\n tcomponent = 0;\n } else if (CCTK_EQUALS (tensortypealias, \"4scalar\")) {\n /* 4-scalar */\n assert (numvars == vectorlength);\n ttype = SCALAR;\n tcomponent = 0;\n } else if (CCTK_EQUALS (tensortypealias, \"u\")\n || CCTK_EQUALS (tensortypealias, \"d\"))\n {\n /* vector */\n const int numcomps = 3;\n /* special case to handle things like vel[3] */\n assert (numvars % numcomps == 0 && \n (numvars == numcomps * vectorlength || numvars == vectorlength));\n ttype = VECTOR;\n if(numvars == vectorlength) {\n tcomponent = (vi - firstvar);\n } else {\n tcomponent = (vi - firstvar) / vectorlength;\n }\n } else if (CCTK_EQUALS (tensortypealias, \"4u\")\n || CCTK_EQUALS (tensortypealias, \"4d\"))\n {\n /* 4-vector */\n const int numcomps = 4;\n assert (numvars % numcomps == 0 && numvars == numcomps * vectorlength);\n if ((vi - firstvar) / vectorlength == 0) {\n ttype = SCALAR;\n tcomponent = 0;\n } else {\n ttype = VECTOR;\n tcomponent = (vi - firstvar) / vectorlength - 1;\n }\n } else if (CCTK_EQUALS (tensortypealias, \"uu_sym\")\n || CCTK_EQUALS (tensortypealias, \"dd_sym\"))\n {\n /* symmetric tensor */\n const int numcomps = 6;\n assert (numvars % numcomps == 0 && numvars == numcomps * vectorlength);\n ttype = SYMTENSOR;\n tcomponent = (vi - firstvar) / vectorlength;\n } else if (CCTK_EQUALS (tensortypealias, \"uu\")\n || CCTK_EQUALS (tensortypealias, \"ud\")\n || CCTK_EQUALS (tensortypealias, \"du\")\n || CCTK_EQUALS (tensortypealias, \"dd\"))\n {\n /* non-symmetric tensor */\n const int numcomps = 9;\n assert (numvars % numcomps == 0 && numvars == numcomps * vectorlength);\n ttype = TENSOR;\n tcomponent = (vi - firstvar) / vectorlength;\n } else if (CCTK_EQUALS (tensortypealias, \"4uu_sym\")\n || CCTK_EQUALS (tensortypealias, \"4dd_sym\"))\n {\n /* symmetric 4-tensor */\n const int numcomps = 10;\n assert (numvars % numcomps == 0 && numvars == numcomps * vectorlength);\n if ((vi - firstvar) / vectorlength == 0) {\n ttype = SCALAR;\n tcomponent = 0;\n } else if ((vi - firstvar) / vectorlength <= 3) {\n ttype = VECTOR;\n tcomponent = (vi - firstvar) / vectorlength - 1;\n } else {\n ttype = SYMTENSOR;\n tcomponent = (vi - firstvar) / vectorlength - 4;\n }\n } else if (CCTK_EQUALS (tensortypealias, \"ddd_sym\")) {\n /* 3rd rank tensor, symmetric in last 2 indices */\n const int numcomps = 18;\n assert (numvars % numcomps == 0 && numvars == numcomps * vectorlength);\n ttype = SYMTENSOR3;\n tcomponent = (vi - firstvar) / vectorlength;\n } else if (CCTK_EQUALS (tensortypealias, \"weylscalars_real\")) {\n /* Weyl scalars, stored as 10 real numbers */\n const int numcomps = 10;\n assert (numvars % numcomps == 0 && numvars == numcomps * vectorlength);\n ttype = WEYLSCALARS_REAL;\n tcomponent = (vi - firstvar) / vectorlength;\n } else if (CCTK_EQUALS (tensortypealias, \"ManualCartesian\")) {\n /* Reflection symmetries specified by hand */\n ttype = MANUALCARTESIAN;\n tcomponent = vi - firstvar;\n } else {\n groupname = CCTK_GroupName(gi);\n assert (groupname);\n CCTK_VWarn (0, __LINE__, __FILE__, CCTK_THORNSTRING,\n \"Illegal tensor type alias \\\"%s\\\" for group \\\"%s\\\"\", \n\t\t tensortypealias, groupname);\n free (groupname);\n }\n \n switch (ttype) {\n case SCALAR:\n assert (tcomponent>=0 && tcomponent<1);\n break;\n case VECTOR:\n assert (tcomponent>=0 && tcomponent<3);\n break;\n case SYMTENSOR:\n assert (tcomponent>=0 && tcomponent<6);\n break;\n case SYMTENSOR3:\n assert (tcomponent>=0 && tcomponent<18);\n break;\n case TENSOR:\n assert (tcomponent>=0 && tcomponent<9);\n break;\n case WEYLSCALARS_REAL:\n assert (tcomponent>=0 && tcomponent<10);\n break;\n case MANUALCARTESIAN:\n /* No restriction on number of components */\n break;\n default:\n assert (0);\n }\n \n ierr = Util_TableGetInt (table, & tensorparity, \"tensorparity\");\n if (ierr == UTIL_ERROR_TABLE_NO_SUCH_KEY) {\n tensorparity = +1;\n } else if (ierr<0) {\n groupname = CCTK_GroupName(gi);\n assert (groupname);\n CCTK_VWarn (0, __LINE__, __FILE__, CCTK_THORNSTRING,\n \"Error in tensor parity declaration for group \\\"%s\\\"\",\n groupname);\n free (groupname);\n }\n \n \n \n /* Calculate parities */\n parities[0] = parities[1] = parities[2] = +1;\n switch (ttype) {\n case SCALAR:\n /* do nothing */\n break;\n case VECTOR:\n parities[tcomponent] = -1;\n break;\n case SYMTENSOR:\n switch (tcomponent) {\n case 0: break;\n case 1: parities[0] = parities[1] = -1; break;\n case 2: parities[0] = parities[2] = -1; break;\n case 3: break;\n case 4: parities[1] = parities[2] = -1; break;\n case 5: break;\n default: assert (0);\n }\n break;\n case SYMTENSOR3:\n switch (tcomponent % 6) {\n case 0: break;\n case 1: parities[0] = parities[1] = -1; break;\n case 2: parities[0] = parities[2] = -1; break;\n case 3: break;\n case 4: parities[1] = parities[2] = -1; break;\n case 5: break;\n default: assert (0);\n }\n switch (tcomponent / 6) {\n case 0: parities[0] *= -1; break;\n case 1: parities[1] *= -1; break;\n case 2: parities[2] *= -1; break;\n default: assert (0);\n }\n break;\n case TENSOR:\n switch (tcomponent) {\n case 0: break;\n case 1: parities[0] = parities[1] = -1; break;\n case 2: parities[0] = parities[2] = -1; break;\n case 3: parities[1] = parities[0] = -1; break;\n case 4: break;\n case 5: parities[1] = parities[2] = -1; break;\n case 6: parities[2] = parities[0] = -1; break;\n case 7: parities[2] = parities[1] = -1; break;\n case 8: break;\n default: assert (0);\n }\n break;\n case WEYLSCALARS_REAL: {\n static int const weylparities[10][3] =\n {{+1,+1,+1},\n {-1,-1,-1},\n {+1,+1,+1},\n {-1,-1,-1},\n {+1,+1,+1},\n {-1,-1,-1},\n {+1,+1,+1},\n {-1,-1,-1},\n {+1,+1,+1},\n {-1,-1,-1}};\n for (dir=0; dir<3; ++dir) {\n parities[dir] = weylparities[tcomponent][dir];\n }\n break;\n }\n case MANUALCARTESIAN:\n ReflectionSymmetry_GetManualParities(table, gi, parities);\n break;\n default:\n assert (0);\n }\n \n \n \n /* Take derivatives into account */\n {\n int code = operation_codes[m];\n while (code) {\n d = code % 10 - 1;\n code /= 10;\n assert (d>=0 && d<3);\n parities[d] *= -1;\n }\n }\n \n \n \n /* Are there negative parities? */\n needs_checking = 0;\n for (dir=0; dir<3; ++dir) {\n check_dir[dir] = do_reflection[2*dir] && parities[dir]*tensorparity < 0;\n needs_checking |= check_dir[dir];\n }\n\n \n \n \n /* Loop over all points and unfold */\n if (needs_checking) {\n for (n=0; n<N_interp_points; ++n) {\n int parity = 1; /* all types have their \"natural\" sign in the +++ octant */\n /* Is the point outside the domain? */\n for (dir=0; dir<3; ++dir) {\n if (check_dir[dir]) {\n CCTK_REAL const pos = ((CCTK_REAL const *)interp_coords[dir])[n];\n if (pos < 0) {\n /* Reflect the tensor component */\n parity *= -1; /* we only get here if parities[dir]*tensorparity < 0 */\n }\n }\n }\n ((CCTK_REAL *)output_arrays[m])[n] *= parity;\n }\n }\n \n }\n } /* for m */\n \n \n \n /* Free output variable indices */\n free (operand_indices);\n free (operation_codes);\n free (output_array_indices);\n \n \n \n /* Return */\n return iret;\n}\n\nvoid ReflectionSymmetry_GetManualParities(int table, int gi, int *parities)\n{\n char cartsyms[100];\n char *groupname = NULL;\n int i = 0;\n int ierr = -1;\n\n /* Get and check tensor type information */\n ierr = Util_TableGetString\n (table, sizeof cartsyms, cartsyms, \"cartesianreflectionparities\");\n if (ierr == UTIL_ERROR_TABLE_NO_SUCH_KEY) {\n groupname = CCTK_GroupName(gi);\n assert (groupname);\n CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,\n\t\t\"Cartesian refection parity not declared for group \\\"%s\\\" -- aborting\",\n\t\tgroupname);\n assert(0);\n } else if (ierr<0) {\n groupname = CCTK_GroupName(gi);\n assert (groupname);\n CCTK_VWarn (0, __LINE__, __FILE__, CCTK_THORNSTRING,\n\t\t\"Error in tensor type alias declaration for group \\\"%s\\\"\",\n\t\tgroupname);\n free (groupname);\n }\n\n if (strlen(cartsyms) != 3)\n {\n CCTK_VWarn (0, __LINE__, __FILE__, CCTK_THORNSTRING,\n\t\t\"Invalid format for cartesianreflectionparities: must be xxx where x is + or - for group %s\",\n\t\tgroupname);\n }\n\n for (i = 0; i < 3; i++)\n {\n switch (cartsyms[i])\n {\n case '+':\n parities[i] = 1;\n break;\n case '-':\n parities[i] = -1;\n break;\n default:\n CCTK_VWarn (0, __LINE__, __FILE__, CCTK_THORNSTRING,\n\t\t \"Invalid format for cartesianreflectionparities: must be xxx where x is + or - for group %s\",\n\t\t groupname);\n }\n }\n}\n", |
| "register.c": "#include \"cctk.h\"\n#include \"cctk_Arguments.h\"\n#include \"cctk_Parameters.h\"\n\n#include \"reflection.h\"\n\nvoid\nReflectionSymmetry_Register (CCTK_ARGUMENTS)\n{\n DECLARE_CCTK_ARGUMENTS_ReflectionSymmetry_Register;\n DECLARE_CCTK_PARAMETERS;\n \n int do_reflection[6];\n \n CCTK_INT nboundaryzones[6];\n CCTK_INT is_internal[6];\n CCTK_INT is_staggered[6];\n CCTK_INT shiftout[6];\n \n CCTK_INT handle;\n CCTK_INT faces[6];\n CCTK_INT width[6];\n int f;\n CCTK_INT ierr;\n \n do_reflection[0] = reflection_x;\n do_reflection[1] = reflection_upper_x;\n do_reflection[2] = reflection_y;\n do_reflection[3] = reflection_upper_y;\n do_reflection[4] = reflection_z;\n do_reflection[5] = reflection_upper_z;\n \n /* Get the boundary specification */\n ierr = GetBoundarySpecification\n (6, nboundaryzones, is_internal, is_staggered, shiftout);\n if (ierr < 0)\n {\n CCTK_WARN (0, \"Could not get the boundary specification\");\n }\n \n for (f=0; f<6; ++f)\n {\n if (do_reflection[f])\n {\n faces[f] = 1;\n width[f] = nboundaryzones[f/2];\n }\n else\n {\n faces[f] = 0;\n width[f] = 0;\n }\n }\n \n handle = SymmetryRegister (\"reflection_symmetry\");\n if (handle < 0)\n {\n CCTK_WARN (0, \"Could not register symmetry boundary condition\");\n }\n \n ierr = SymmetryRegisterGrid (cctkGH, handle, faces, width);\n if (ierr < 0)\n {\n CCTK_WARN (0, \"Could not register the symmetry boundaries -- probably some other thorn has already registered the same boundary faces for a different symmetry\");\n }\n \n ierr = SymmetryRegisterGridInterpolator\n (cctkGH, handle, ReflectionSymmetry_Interpolate);\n if (ierr < 0)\n {\n CCTK_WARN (0, \"Could not register the symmetry interpolator\");\n }\n}\n", |
| "reflection.h": "#ifndef REFLECTIONSYMMETRY_H\n#define REFLECTIONSYMMETRY_H\n\n#include \"cctk.h\"\n#include \"cctk_Arguments.h\"\n\nvoid ReflectionSymmetry_Apply (CCTK_ARGUMENTS);\n\nCCTK_INT\nReflectionSymmetry_Interpolate (CCTK_POINTER_TO_CONST restrict const cctkGH,\n CCTK_INT const N_dims,\n CCTK_INT const local_interp_handle,\n CCTK_INT const param_table_handle,\n CCTK_INT const coord_system_handle,\n CCTK_INT const N_interp_points,\n CCTK_INT const interp_coords_type,\n CCTK_POINTER_TO_CONST restrict const interp_coords[],\n CCTK_INT const N_input_arrays,\n CCTK_INT const input_array_indices[],\n CCTK_INT const N_output_arrays,\n CCTK_INT const output_array_types[],\n CCTK_POINTER restrict const output_arrays[],\n CCTK_INT const faces);\n\nvoid \nReflectionSymmetry_GetManualParities(int table, int gi, int *parities);\n\n#endif /* ! defined REFLECTIONSYMMETRY_H */\n", |
| "apply.c": "#include <assert.h>\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n\n#include \"cctk.h\"\n#include \"cctk_Arguments.h\"\n#include \"cctk_Parameters.h\"\n\n#include \"util_ErrorCodes.h\"\n#include \"util_Table.h\"\n\n#include \"reflection.h\"\n\n\n\n#define COPY_PRE(VARTYPE) \\\n static void \\\n copy_##VARTYPE (VARTYPE * restrict const var, \\\n int const ni, int const nj, int const nk, \\\n int const imin, int const jmin, int const kmin, \\\n int const imax, int const jmax, int const kmax, \\\n int const ioff, int const joff, int const koff, \\\n int const idir, int const jdir, int const kdir, \\\n int const parity) \\\n { \\\n assert (abs(idir)==1); \\\n assert (abs(jdir)==1); \\\n assert (abs(kdir)==1); \\\n int const iioff = ioff + (1 - idir) * imin; \\\n int const jjoff = joff + (1 - jdir) * jmin; \\\n int const kkoff = koff + (1 - kdir) * kmin; \\\n int const iimin = iioff + idir * imin; \\\n int const jjmin = jjoff + jdir * jmin; \\\n int const kkmin = kkoff + kdir * kmin; \\\n int const iimax = iioff + idir * imax; \\\n int const jjmax = jjoff + jdir * jmax; \\\n int const kkmax = kkoff + kdir * kmax; \\\n assert (imin>=0 && imax<=ni); \\\n assert (jmin>=0 && jmax<=nj); \\\n assert (kmin>=0 && kmax<=nk); \\\n assert (iimin>=0 && iimax<=ni); \\\n assert (jjmin>=0 && jjmax<=nj); \\\n assert (kkmin>=0 && kkmax<=nk); \\\n assert (iimax>=-1 && iimin<ni); \\\n assert (jjmax>=-1 && jjmin<nj); \\\n assert (kkmax>=-1 && kkmin<nk);\n\n#define COPY_LOOP(VARTYPE) \\\n for (int k=kmin; k<kmax; ++k) { \\\n for (int j=jmin; j<jmax; ++j) { \\\n for (int i=imin; i<imax; ++i) { \\\n int const dstind = i + ni * (j + nj * k); \\\n int const ii = iioff + idir * i; \\\n int const jj = jjoff + jdir * j; \\\n int const kk = kkoff + kdir * k; \\\n int const srcind = ii + ni * (jj + nj * kk); \\\n var[dstind] = parity * var[srcind]; \\\n } \\\n } \\\n } \\\n\n#define COPY_POST(VARTYPE) \\\n }\n\n#ifdef HAVE_CCTK_INT1\nCOPY_PRE(CCTK_INT1)\n#pragma omp parallel for\nCOPY_LOOP(CCTK_INT1)\nCOPY_POST(CCTK_INT1)\n#endif\n\n#ifdef HAVE_CCTK_INT2\nCOPY_PRE(CCTK_INT2)\n#pragma omp parallel for\nCOPY_LOOP(CCTK_INT2)\nCOPY_POST(CCTK_INT2)\n#endif\n\n#ifdef HAVE_CCTK_INT4\nCOPY_PRE(CCTK_INT4)\n#pragma omp parallel for\nCOPY_LOOP(CCTK_INT4)\nCOPY_POST(CCTK_INT4)\n#endif\n\n#ifdef HAVE_CCTK_INT8\nCOPY_PRE(CCTK_INT8)\n#pragma omp parallel for\nCOPY_LOOP(CCTK_INT8)\nCOPY_POST(CCTK_INT8)\n#endif\n\n#ifdef HAVE_CCTK_INT16\nCOPY_PRE(CCTK_INT16)\n#pragma omp parallel for\nCOPY_LOOP(CCTK_INT16)\nCOPY_POST(CCTK_INT16)\n#endif\n\n#ifdef HAVE_CCTK_REAL4\nCOPY_PRE(CCTK_REAL4)\n#pragma omp parallel for\nCOPY_LOOP(CCTK_REAL4)\nCOPY_POST(CCTK_REAL4)\n#endif\n\n#ifdef HAVE_CCTK_REAL8\nCOPY_PRE(CCTK_REAL8)\n#pragma omp parallel for\nCOPY_LOOP(CCTK_REAL8)\nCOPY_POST(CCTK_REAL8)\n#endif\n\n#ifdef HAVE_CCTK_REAL16\nCOPY_PRE(CCTK_REAL16)\n#pragma omp parallel for\nCOPY_LOOP(CCTK_REAL16)\nCOPY_POST(CCTK_REAL16)\n#endif\n\n#ifdef HAVE_CCTK_COMPLEX8\nCOPY_PRE(CCTK_COMPLEX8)\n#pragma omp parallel for\nCOPY_LOOP(CCTK_COMPLEX8)\nCOPY_POST(CCTK_COMPLEX8)\n#endif\n\n#ifdef HAVE_CCTK_COMPLEX16\nCOPY_PRE(CCTK_COMPLEX16)\n#pragma omp parallel for\nCOPY_LOOP(CCTK_COMPLEX16)\nCOPY_POST(CCTK_COMPLEX16)\n#endif\n\n#ifdef HAVE_CCTK_COMPLEX32\nCOPY_PRE(CCTK_COMPLEX32)\n#pragma omp parallel for\nCOPY_LOOP(CCTK_COMPLEX32)\nCOPY_POST(CCTK_COMPLEX32)\n#endif\n\n#undef COPY_PRE\n#undef COPY_LOOP\n#undef COPY_POST\n\n\n\nstatic int\nBndReflectVI (cGH const * restrict const cctkGH,\n int const vi)\n{\n DECLARE_CCTK_PARAMETERS;\n \n int gi;\n cGroup group;\n cGroupDynamicData data;\n int firstvar, numvars, vectorlength;\n char * restrict fullname;\n \n void * restrict varptr;\n \n int table;\n char tensortypealias[1000];\n enum tensortype { TT_UNKNOWN,\n SCALAR, VECTOR, SYMTENSOR, SYMTENSOR3a, SYMTENSOR3b, TENSOR,\n WEYLSCALARS_REAL, MANUALCARTESIAN };\n enum tensortype ttype;\n CCTK_INT tensorparity;\n int tcomponent;\n \n /* The stagger type is defined for grid variable groups, and\n depending on this type, each variable in the group may be\n staggered differently. This implies that groups with FACE or EDGE\n staggering have well-defined tensor types. */\n /* The stagger type is defined assuming a cell-centered grid, since\n this seems to be the common case where different stagger types\n are used. If the grid is vertex centered, then we currently abort\n when staggered grid variables are encountered. (We determine the\n centering of the grid via the avoid_origin_* parameters.) */\n char staggertype[1000];\n enum staggertype { ST_UNKNOWN, CELL, FACE, EDGE, VERTEX };\n enum staggertype stype;\n \n int do_reflection[6];\n int do_stagger_grid[6];\n \n int dir, face;\n \n int ash[3], imin[3], imax[3], ioff[3], idir[3];\n \n int parity;\n int do_stagger;\n int manual_parities[3];\n\n int d;\n \n int ierr;\n \n \n \n /* Check arguments */\n if (! cctkGH) {\n CCTK_WARN (0, \"Argument cctkGH is NULL\");\n }\n if (vi < 0 || vi >= CCTK_NumVars()) {\n CCTK_WARN (0, \"Illegal variable index\");\n }\n \n if (verbose) {\n fullname = CCTK_FullName (vi);\n if (! fullname) {\n CCTK_WARN (0, \"Internal error in CCTK_FullName\");\n }\n CCTK_VInfo (CCTK_THORNSTRING,\n \"Applying reflection boundary conditions to \\\"%s\\\"\",\n fullname);\n free (fullname);\n }\n \n \n \n /* Get and check group information */\n gi = CCTK_GroupIndexFromVarI (vi);\n if (gi < 0 || gi > CCTK_NumGroups()) {\n CCTK_WARN (0, \"Internal error in CCTK_GroupIndexFromVarI\");\n }\n \n ierr = CCTK_GroupData (gi, &group);\n assert (!ierr);\n assert (group.grouptype == CCTK_GF);\n assert (group.disttype == CCTK_DISTRIB_DEFAULT);\n \n firstvar = CCTK_FirstVarIndexI (gi);\n assert (firstvar>=0 && firstvar<CCTK_NumVars());\n numvars = CCTK_NumVarsInGroupI (gi);\n assert (numvars>=0);\n vectorlength = group.vectorlength;\n assert (vectorlength>=0);\n assert (vectorlength==1 || group.vectorgroup);\n \n ierr = CCTK_GroupDynamicData (cctkGH, gi, &data);\n assert (!ierr);\n \n table = CCTK_GroupTagsTableI(gi);\n assert (table>=0);\n \n varptr = CCTK_VarDataPtrI (cctkGH, 0, vi);\n if (!varptr) {\n fullname = CCTK_FullName (vi);\n CCTK_VInfo (CCTK_THORNSTRING,\n \"assertion for \\\"%s\\\"\",\n fullname);\n free (fullname);\n }\n assert (varptr);\n \n \n \n /* Get and check tensor type information */\n ierr = Util_TableGetString\n (table, sizeof tensortypealias, tensortypealias, \"tensortypealias\");\n if (ierr == UTIL_ERROR_TABLE_NO_SUCH_KEY) {\n /* assume a scalar */\n if (numvars != 1) {\n static int * restrict didwarn = 0;\n if (! didwarn) {\n didwarn = calloc (CCTK_NumGroups(), sizeof *didwarn);\n }\n if (! didwarn[gi]) {\n didwarn[gi] = 1;\n {\n char * groupname = CCTK_GroupName(gi);\n assert (groupname);\n CCTK_VWarn (2, __LINE__, __FILE__, CCTK_THORNSTRING,\n \"Group \\\"%s\\\" has no tensor type and contains more than one element -- treating these as \\\"scalar\\\"\",\n groupname);\n free (groupname);\n }\n }\n }\n strcpy (tensortypealias, \"scalar\");\n } else if (ierr<0) {\n char * groupname = CCTK_GroupName(gi);\n assert (groupname);\n CCTK_VWarn (0, __LINE__, __FILE__, CCTK_THORNSTRING,\n \"Error in tensor type alias declaration for group \\\"%s\\\": %d\",\n groupname, ierr);\n free (groupname);\n }\n \n ttype = TT_UNKNOWN;\n tcomponent = 0;\n if (CCTK_EQUALS (tensortypealias, \"scalar\")) {\n /* scalar */\n ttype = SCALAR;\n tcomponent = 0;\n } else if (CCTK_EQUALS (tensortypealias, \"4scalar\")) {\n /* 4-scalar */\n ttype = SCALAR;\n tcomponent = 0;\n } else if (CCTK_EQUALS (tensortypealias, \"u\")\n || CCTK_EQUALS (tensortypealias, \"d\"))\n {\n /* vector */\n const int numcomps = 3;\n /* special case to handle things like vel[3] */\n assert (numvars % numcomps == 0 && \n (numvars == numcomps * vectorlength || numvars == vectorlength));\n ttype = VECTOR;\n if(numvars == vectorlength) {\n tcomponent = (vi - firstvar);\n } else {\n tcomponent = (vi - firstvar) / vectorlength;\n }\n } else if (CCTK_EQUALS (tensortypealias, \"4u\")\n || CCTK_EQUALS (tensortypealias, \"4d\"))\n {\n /* 4-vector */\n const int numcomps = 4;\n assert (numvars % numcomps == 0 && numvars == numcomps * vectorlength);\n if ((vi - firstvar) / vectorlength == 0) {\n ttype = SCALAR;\n tcomponent = 0;\n } else {\n ttype = VECTOR;\n tcomponent = (vi - firstvar) / vectorlength - 1;\n }\n } else if (CCTK_EQUALS (tensortypealias, \"uu_sym\")\n || CCTK_EQUALS (tensortypealias, \"dd_sym\"))\n {\n /* symmetric tensor */\n const int numcomps = 6;\n assert (numvars % numcomps == 0 && numvars == numcomps * vectorlength);\n ttype = SYMTENSOR;\n tcomponent = (vi - firstvar) / vectorlength;\n } else if (CCTK_EQUALS (tensortypealias, \"uu\")\n || CCTK_EQUALS (tensortypealias, \"ud\")\n || CCTK_EQUALS (tensortypealias, \"du\")\n || CCTK_EQUALS (tensortypealias, \"dd\"))\n {\n /* non-symmetric tensor */\n const int numcomps = 9;\n assert (numvars % numcomps == 0 && numvars == numcomps * vectorlength);\n ttype = TENSOR;\n tcomponent = (vi - firstvar) / vectorlength;\n } else if (CCTK_EQUALS (tensortypealias, \"4uu_sym\")\n || CCTK_EQUALS (tensortypealias, \"4dd_sym\"))\n {\n /* symmetric 4-tensor */\n const int numcomps = 10;\n assert (numvars % numcomps == 0 && numvars == numcomps * vectorlength);\n if ((vi - firstvar) / vectorlength == 0) {\n ttype = SCALAR;\n tcomponent = 0;\n } else if ((vi - firstvar) / vectorlength <= 3) {\n ttype = VECTOR;\n tcomponent = (vi - firstvar) / vectorlength - 1;\n } else {\n ttype = SYMTENSOR;\n tcomponent = (vi - firstvar) / vectorlength - 4;\n }\n } else if (CCTK_EQUALS (tensortypealias, \"dd_sym_d\")) {\n /* 3rd rank tensor, symmetric in first 2 indices */\n const int numcomps = 18;\n assert (numvars % numcomps == 0 && numvars == numcomps * vectorlength);\n ttype = SYMTENSOR3a;\n tcomponent = (vi - firstvar) / vectorlength;\n } else if (CCTK_EQUALS (tensortypealias, \"ddd_sym\")) {\n /* 3rd rank tensor, symmetric in last 2 indices */\n const int numcomps = 18;\n assert (numvars % numcomps == 0 && numvars == numcomps * vectorlength);\n ttype = SYMTENSOR3b;\n tcomponent = (vi - firstvar) / vectorlength;\n } else if (CCTK_EQUALS (tensortypealias, \"weylscalars_real\")) {\n /* Weyl scalars, stored as 10 real values. NOTE: This assumes\n that Psi_0 comes first, which is NOT the default with\n PsiKadelia. */\n const int numcomps = 10;\n assert (numvars % numcomps == 0 && numvars == numcomps * vectorlength);\n ttype = WEYLSCALARS_REAL;\n tcomponent = (vi - firstvar) / vectorlength;\n } else if (CCTK_EQUALS (tensortypealias, \"ManualCartesian\")) {\n /* Reflection symmetries specified by hand */\n ttype = MANUALCARTESIAN;\n tcomponent = vi - firstvar;\n } else {\n char * groupname = CCTK_GroupName(gi);\n assert (groupname);\n CCTK_VWarn (0, __LINE__, __FILE__, CCTK_THORNSTRING,\n \"Illegal tensor type alias \\\"%s\\\" for group \\\"%s\\\"\",\n tensortypealias, groupname);\n free (groupname);\n }\n \n switch (ttype) {\n case SCALAR:\n assert (tcomponent>=0 && tcomponent<1);\n break;\n case VECTOR:\n assert (tcomponent>=0 && tcomponent<3);\n break;\n case SYMTENSOR:\n assert (tcomponent>=0 && tcomponent<6);\n break;\n case SYMTENSOR3a:\n assert (tcomponent>=0 && tcomponent<18);\n break;\n case SYMTENSOR3b:\n assert (tcomponent>=0 && tcomponent<18);\n break;\n case TENSOR:\n assert (tcomponent>=0 && tcomponent<9);\n break;\n case WEYLSCALARS_REAL:\n assert (tcomponent>=0 && tcomponent<10);\n break;\n case MANUALCARTESIAN:\n /* No restriction on number of components */\n ReflectionSymmetry_GetManualParities(table, gi, manual_parities);\n break;\n\n default:\n assert (0);\n }\n \n ierr = Util_TableGetInt (table, & tensorparity, \"tensorparity\");\n if (ierr == UTIL_ERROR_TABLE_NO_SUCH_KEY) {\n tensorparity = +1;\n } else if (ierr<0) {\n char * groupname = CCTK_GroupName(gi);\n assert (groupname);\n CCTK_VWarn (0, __LINE__, __FILE__, CCTK_THORNSTRING,\n \"Error in tensor parity declaration for group \\\"%s\\\": %d\",\n groupname, ierr);\n free (groupname);\n }\n \n \n \n /* Get and check stagger type information */\n ierr = Util_TableGetString\n (table, sizeof staggertype, staggertype, \"staggertype\");\n if (ierr == UTIL_ERROR_TABLE_NO_SUCH_KEY) {\n /* assume cell centering */\n strcpy (staggertype, \"cell\");\n } else if (ierr<0) {\n char * groupname = CCTK_GroupName(gi);\n assert (groupname);\n CCTK_VWarn (0, __LINE__, __FILE__, CCTK_THORNSTRING,\n \"Error in stagger type declaration for group \\\"%s\\\": %d\",\n groupname, ierr);\n free (groupname);\n }\n \n stype = ST_UNKNOWN;\n if (CCTK_EQUALS (staggertype, \"cell\")) {\n /* cell */\n stype = CELL;\n } else if (CCTK_EQUALS (staggertype, \"face\")) {\n /* face */\n stype = FACE;\n } else if (CCTK_EQUALS (staggertype, \"edge\")) {\n /* edge */\n stype = EDGE;\n } else if (CCTK_EQUALS (staggertype, \"vertex\")) {\n /* vertex */\n stype = VERTEX;\n } else {\n char * groupname = CCTK_GroupName(gi);\n assert (groupname);\n CCTK_VWarn (0, __LINE__, __FILE__, CCTK_THORNSTRING,\n \"Illegal stagger type \\\"%s\\\" for group \\\"%s\\\"\",\n staggertype, groupname);\n free (groupname);\n }\n \n \n \n /* Reflection symmetry information */\n do_reflection[0] = reflection_x;\n do_reflection[1] = reflection_upper_x;\n do_reflection[2] = reflection_y;\n do_reflection[3] = reflection_upper_y;\n do_reflection[4] = reflection_z;\n do_reflection[5] = reflection_upper_z;\n \n do_stagger_grid[0] = avoid_origin_x;\n do_stagger_grid[1] = avoid_origin_upper_x;\n do_stagger_grid[2] = avoid_origin_y;\n do_stagger_grid[3] = avoid_origin_upper_y;\n do_stagger_grid[4] = avoid_origin_z;\n do_stagger_grid[5] = avoid_origin_upper_z;\n \n \n \n /* Loop over all directions and faces */\n for (dir=0; dir<3; ++dir) {\n for (face=0; face<2; ++face) {\n /* If there is a reflection symmetry on that face */\n if (do_reflection[2*dir+face]) {\n /* If we have the outer boundary of that face */\n if (cctkGH->cctk_bbox[2*dir+face]) {\n \n /* Find parity */\n parity = tensorparity;\n switch (ttype) {\n case SCALAR:\n parity *= +1;\n break;\n case VECTOR:\n parity *= dir == tcomponent ? -1 : +1;\n break;\n case SYMTENSOR:\n switch (tcomponent) {\n case 0: parity *= +1; break;\n case 1: parity *= (dir == 0 || dir == 1) ? -1 : +1; break;\n case 2: parity *= (dir == 0 || dir == 2) ? -1 : +1; break;\n case 3: parity *= +1; break;\n case 4: parity *= (dir == 1 || dir == 2) ? -1 : +1; break;\n case 5: parity *= +1; break;\n default: assert (0);\n }\n break;\n case SYMTENSOR3a:\n switch (tcomponent / 3) {\n case 0: parity *= +1; break;\n case 1: parity *= (dir == 0 || dir == 1) ? -1 : +1; break;\n case 2: parity *= (dir == 0 || dir == 2) ? -1 : +1; break;\n case 3: parity *= +1; break;\n case 4: parity *= (dir == 1 || dir == 2) ? -1 : +1; break;\n case 5: parity *= +1; break;\n default: assert (0);\n }\n switch (tcomponent % 3) {\n case 0: parity *= dir == 0 ? -1 : +1; break;\n case 1: parity *= dir == 1 ? -1 : +1; break;\n case 2: parity *= dir == 2 ? -1 : +1; break;\n default: assert (0);\n }\n break;\n case SYMTENSOR3b:\n switch (tcomponent % 6) {\n case 0: parity *= +1; break;\n case 1: parity *= (dir == 0 || dir == 1) ? -1 : +1; break;\n case 2: parity *= (dir == 0 || dir == 2) ? -1 : +1; break;\n case 3: parity *= +1; break;\n case 4: parity *= (dir == 1 || dir == 2) ? -1 : +1; break;\n case 5: parity *= +1; break;\n default: assert (0);\n }\n switch (tcomponent / 6) {\n case 0: parity *= dir == 0 ? -1 : +1; break;\n case 1: parity *= dir == 1 ? -1 : +1; break;\n case 2: parity *= dir == 2 ? -1 : +1; break;\n default: assert (0);\n }\n break;\n case TENSOR:\n switch (tcomponent) {\n case 0: parity *= +1; break;\n case 1: parity *= (dir == 0 || dir == 1) ? -1 : +1; break;\n case 2: parity *= (dir == 0 || dir == 2) ? -1 : +1; break;\n case 3: parity *= (dir == 1 || dir == 0) ? -1 : +1; break;\n case 4: parity *= +1; break;\n case 5: parity *= (dir == 1 || dir == 2) ? -1 : +1; break;\n case 6: parity *= (dir == 2 || dir == 0) ? -1 : +1; break;\n case 7: parity *= (dir == 2 || dir == 1) ? -1 : +1; break;\n case 8: parity *= +1; break;\n default: assert (0);\n }\n break;\n case WEYLSCALARS_REAL: {\n static int const weylparities[10][3] =\n {{+1,+1,+1},\n {-1,-1,-1},\n {+1,+1,+1},\n {-1,-1,-1},\n {+1,+1,+1},\n {-1,-1,-1},\n {+1,+1,+1},\n {-1,-1,-1},\n {+1,+1,+1},\n {-1,-1,-1}};\n parity *= weylparities[tcomponent][dir];\n break;\n }\n case MANUALCARTESIAN:\n parity = manual_parities[dir];\n break;\n default:\n assert (0);\n }\n \n /* Find staggering */\n do_stagger = do_stagger_grid[2*dir+face];\n switch (stype) {\n case CELL:\n /* do nothing */\n break;\n case FACE:\n assert (face == 0); /* assume lower face */\n assert (do_stagger); /* assume cell-centered grid */\n assert (ttype == VECTOR); /* TODO: support other tensor types */\n if (dir == tcomponent) do_stagger = !do_stagger;\n break;\n case EDGE:\n assert (face == 0); /* assume lower face */\n assert (do_stagger); /* assume cell-centered grid */\n assert (ttype == VECTOR); /* TODO: support other tensor types */\n if (dir != tcomponent) do_stagger = !do_stagger;\n break;\n case VERTEX:\n assert (face == 0); /* assume lower face */\n assert (do_stagger); /* assume cell-centered grid */\n do_stagger = !do_stagger;\n break;\n default:\n assert (0);\n }\n \n /* Find region extent */\n for (d=0; d<3; ++d) {\n ash[d] = cctkGH->cctk_ash[d];\n imin[d] = 0;\n imax[d] = cctkGH->cctk_lsh[d];\n ioff[d] = 0;\n idir[d] = 1;\n }\n /* To determine the correct expressions for ioff below,\n * consider the definitions of iimin and iimax in the macro\n * COPY_PRE above:\n *\n * iioff = ioff + (1 - idir) * imin\n * iimin = iioff + idir * imin\n * iimax = iioff + idir * imax\n *\n * We need idir = -1 since the loop copying into the\n * symmetry zones traverses the grid points in opposite\n * directions.\n *\n * Using the expressions above, one chooses the desired\n * values of iimin and iimax, and can then solve the\n * equations above for ioff.\n */\n if (face == 0) {\n imax[dir] = cctkGH->cctk_nghostzones[dir];\n ioff[dir] = (+ 2*cctkGH->cctk_nghostzones[dir] - 1 \n + (do_stagger ? 0 : 1));\n idir[dir] = -1;\n } else {\n imin[dir] = cctkGH->cctk_lsh[dir] - cctkGH->cctk_nghostzones[dir];\n ioff[dir] = - 1 - (do_stagger ? 0 : 1); \n idir[dir] = -1;\n }\n \n /* Ensure that there are sufficient interior zones, since\n this thorn does not support filling symmetry zones from\n other symmetry zones */\n {\n int const have_points = cctkGH->cctk_gsh[dir];\n int const need_points =\n 3 * cctkGH->cctk_nghostzones[dir]\n + !do_stagger_grid[2*dir] + !do_stagger_grid[2*dir+1];\n if (need_points > have_points) {\n CCTK_VWarn (CCTK_WARN_ABORT, __LINE__, __FILE__, CCTK_THORNSTRING,\n \"Cannot apply symmetry boundary zones in the %s %c direction, since there seem to be more symmetry zones than interior zones\",\n (face==0 ? \"lower\" : \"upper\"),\n \"xyz\"[dir]);\n }\n }\n \n /* Copy region */\n switch (group.vartype) {\n \n#define ARGS varptr, \\\n ash[0], ash[1], ash[2], \\\n imin[0], imin[1], imin[2], \\\n imax[0], imax[1], imax[2], \\\n ioff[0], ioff[1], ioff[2], \\\n idir[0], idir[1], idir[2], \\\n parity\n\n#ifdef HAVE_CCTK_INT1\n case CCTK_VARIABLE_INT1:\n#ifdef CCTK_INTEGER_PRECISION_1\n case CCTK_VARIABLE_INT:\n#endif\n copy_CCTK_INT1 (ARGS);\n break;\n#endif\n \n#ifdef HAVE_CCTK_INT2\n case CCTK_VARIABLE_INT2:\n#ifdef CCTK_INTEGER_PRECISION_2\n case CCTK_VARIABLE_INT:\n#endif\n copy_CCTK_INT2 (ARGS);\n break;\n#endif\n \n#ifdef HAVE_CCTK_INT4\n case CCTK_VARIABLE_INT4:\n#ifdef CCTK_INTEGER_PRECISION_4\n case CCTK_VARIABLE_INT:\n#endif\n copy_CCTK_INT4 (ARGS);\n break;\n#endif\n \n#ifdef HAVE_CCTK_INT8\n case CCTK_VARIABLE_INT8:\n#ifdef CCTK_INTEGER_PRECISION_8\n case CCTK_VARIABLE_INT:\n#endif\n copy_CCTK_INT8 (ARGS);\n break;\n#endif\n \n#ifdef HAVE_CCTK_INT16\n case CCTK_VARIABLE_INT16:\n#ifdef CCTK_INTEGER_PRECISION_16\n case CCTK_VARIABLE_INT:\n#endif\n copy_CCTK_INT16 (ARGS);\n break;\n#endif\n \n#ifdef HAVE_CCTK_REAL4\n case CCTK_VARIABLE_REAL4:\n#ifdef CCTK_REAL_PRECISION_4\n case CCTK_VARIABLE_REAL:\n#endif\n copy_CCTK_REAL4 (ARGS);\n break;\n#endif\n \n#ifdef HAVE_CCTK_REAL8\n case CCTK_VARIABLE_REAL8:\n#ifdef CCTK_REAL_PRECISION_8\n case CCTK_VARIABLE_REAL:\n#endif\n copy_CCTK_REAL8 (ARGS);\n break;\n#endif\n \n#ifdef HAVE_CCTK_REAL16\n case CCTK_VARIABLE_REAL16:\n#ifdef CCTK_REAL_PRECISION_16\n case CCTK_VARIABLE_REAL:\n#endif\n copy_CCTK_REAL16 (ARGS);\n break;\n#endif\n \n#ifdef HAVE_CCTK_COMPLEX8\n case CCTK_VARIABLE_COMPLEX8:\n#ifdef CCTK_COMPLEX_PRECISION_8\n case CCTK_VARIABLE_COMPLEX:\n#endif\n copy_CCTK_COMPLEX8 (ARGS);\n break;\n#endif\n \n#ifdef HAVE_CCTK_COMPLEX16\n case CCTK_VARIABLE_COMPLEX16:\n#ifdef CCTK_COMPLEX_PRECISION_16\n case CCTK_VARIABLE_COMPLEX:\n#endif\n copy_CCTK_COMPLEX16 (ARGS);\n break;\n#endif\n \n#ifdef HAVE_CCTK_COMPLEX32\n case CCTK_VARIABLE_COMPLEX32:\n#ifdef CCTK_COMPLEX_PRECISION_32\n case CCTK_VARIABLE_COMPLEX:\n#endif\n copy_CCTK_COMPLEX32 (ARGS);\n break;\n#endif\n \n#undef ARGS\n \n default:\n CCTK_WARN (0, \"Unsupported variable type\");\n }\n \n } /* if cctk_bbox */\n } /* if do_reflection */\n } /* for face */\n } /* for dir */\n \n /* Success */\n return 0;\n}\n\n\n\n/* When CoordBase is used to specify the location of the boundary\n points, then ensure that the CoordBase parameters and this thorn's\n parameters are consistent. */\nstatic\nvoid\nCheckBoundaryParameters (cGH const * restrict const cctkGH,\n int const vi,\n int const * restrict const stencil)\n{\n DECLARE_CCTK_PARAMETERS;\n \n static int did_check = 0;\n \n int type; /* Parameter type */\n void const * ptr; /* Pointer to parameter value */\n char const * coordtype; /* CartGrid3D::type */\n \n int dim; /* Number of dimensions of vi */\n \n CCTK_INT * restrict nboundaryzones; /* CoordBase boundary location */\n CCTK_INT * restrict is_internal;\n CCTK_INT * restrict is_staggered;\n CCTK_INT * restrict shiftout;\n \n int do_reflection[6]; /* This thorn's parameters */\n int do_stagger_grid[6];\n \n int d;\n int ierr;\n \n \n \n /* Check only once to save time */\n if (did_check) return;\n \n /* Check only for grid functions */\n if (CCTK_GroupTypeFromVarI (vi) != CCTK_GF) return;\n \n did_check = 1;\n \n /* Check whether CartGrid3D is active */\n if (! CCTK_IsThornActive (\"CartGrid3D\")) return;\n \n /* Check whether CoordBase is used */\n ptr = CCTK_ParameterGet (\"type\", \"CartGrid3D\", & type);\n assert (ptr != 0);\n assert (type == PARAMETER_KEYWORD);\n coordtype = * (char const * const *) ptr;\n if (! CCTK_EQUALS (coordtype, \"coordbase\")) return;\n \n /* Get the boundary specification */\n dim = CCTK_GroupDimFromVarI (vi);\n assert (dim >= 0);\n nboundaryzones = malloc (2*dim * sizeof *nboundaryzones);\n is_internal = malloc (2*dim * sizeof *is_internal);\n is_staggered = malloc (2*dim * sizeof *is_staggered);\n shiftout = malloc (2*dim * sizeof *shiftout);\n ierr = GetBoundarySpecification\n (2*dim, nboundaryzones, is_internal, is_staggered, shiftout);\n assert (! ierr);\n \n /* Reflection symmetry information */\n assert (dim == 3);\n do_reflection[0] = reflection_x;\n do_reflection[1] = reflection_upper_x;\n do_reflection[2] = reflection_y;\n do_reflection[3] = reflection_upper_y;\n do_reflection[4] = reflection_z;\n do_reflection[5] = reflection_upper_z;\n \n do_stagger_grid[0] = avoid_origin_x;\n do_stagger_grid[1] = avoid_origin_upper_x;\n do_stagger_grid[2] = avoid_origin_y;\n do_stagger_grid[3] = avoid_origin_upper_y;\n do_stagger_grid[4] = avoid_origin_z;\n do_stagger_grid[5] = avoid_origin_upper_z;\n \n /* Check the boundary sizes */\n for (d=0; d<6; ++d) {\n if (do_reflection[d]) {\n char const dir = \"xyz\"[d/2];\n char const * const face = (d%2==0) ? \"lower\" : \"upper\";\n if (stencil[d/2] != nboundaryzones[d]) {\n CCTK_VWarn (CCTK_WARN_ABORT,\n __LINE__, __FILE__, CCTK_THORNSTRING,\n \"The %s %c face is a symmetry boundary. Since there are %d ghost zones in the %c direction, the corresponding CoordBase boundary width must also be %d. The boundary width is currently %d.\",\n face, dir,\n stencil[d/2], dir, stencil[d/2],\n (int) nboundaryzones[d]);\n }\n if (is_internal[d]) {\n CCTK_VWarn (CCTK_WARN_ABORT,\n __LINE__, __FILE__, CCTK_THORNSTRING,\n \"The %s %c face is a symmetry boundary. The corresponding CoordBase boundary must not be internal.\",\n face, dir);\n }\n if (do_stagger_grid[d] != is_staggered[d]) {\n CCTK_VWarn (CCTK_WARN_ABORT,\n __LINE__, __FILE__, CCTK_THORNSTRING,\n \"The %s %c face is a symmetry boundary. The symmetry condition and the corresponding CoordBase boundary must either be both staggered or both not staggered.\",\n face, dir);\n }\n if ((do_stagger_grid[d] ? 0 : 1) != shiftout[d]) {\n CCTK_VWarn (CCTK_WARN_ABORT,\n __LINE__, __FILE__, CCTK_THORNSTRING,\n \"The %s %c face is a symmetry boundary. If the symmetry condition is staggered, then the corresponding CoordBase shiftout must be 0; otherwise it must be 1.\",\n face, dir);\n }\n }\n }\n \n /* Free memory */\n free (nboundaryzones);\n free (is_internal);\n free (is_staggered);\n free (shiftout);\n}\n\nvoid\nReflectionSymmetry_Apply (CCTK_ARGUMENTS)\n{\n DECLARE_CCTK_ARGUMENTS;\n DECLARE_CCTK_PARAMETERS;\n \n int vi;\n int dim;\n int * restrict stencil;\n int i;\n int ierr;\n\n int nvars;\n CCTK_INT * restrict indices;\n CCTK_INT * restrict faces;\n CCTK_INT * restrict widths;\n CCTK_INT * restrict tables;\n int istat;\n\n nvars = Boundary_SelectedGVs (cctkGH, 0, NULL, NULL, NULL, NULL, NULL);\n if (nvars < 0) {\n CCTK_WARN (0, \"Internal error in Boundary_SelectedGVs\");\n }\n\n if (nvars == 0) {\n /* Nothing to do */\n return;\n }\n\n indices = malloc (nvars * sizeof *indices);\n if (! indices) {\n CCTK_WARN (0, \"Out of memory\");\n }\n faces = malloc (nvars * sizeof *faces);\n if (! faces) {\n CCTK_WARN (0, \"Out of memory\");\n }\n widths = malloc (nvars * sizeof *widths);\n if (! widths) {\n CCTK_WARN (0, \"Out of memory\");\n }\n tables = malloc (nvars * sizeof *tables);\n if (! tables) {\n CCTK_WARN (0, \"Out of memory\");\n }\n\n istat = Boundary_SelectedGVs\n (cctkGH, nvars, indices, faces, widths, tables, 0);\n if (istat != nvars) {\n CCTK_WARN (0, \"Internal error in Boundary_SelectedGVs\");\n }\n\n for (i=0; i<nvars; ++i) {\n vi = indices[i];\n if (vi < 0 || vi >= CCTK_NumVars()) {\n CCTK_WARN (0, \"Illegal variable index\");\n }\n\n if (widths[i] < 0) {\n CCTK_WARN (0, \"Illegal boundary width\");\n }\n\n dim = CCTK_GroupDimFromVarI (vi);\n if (dim < 0) {\n CCTK_WARN (0, \"Illegal dimension\");\n }\n\n stencil = malloc (dim * sizeof *stencil);\n if (! stencil) {\n CCTK_WARN (0, \"Out of memory\");\n }\n ierr = CCTK_GroupnghostzonesVI (cctkGH, dim, stencil, vi);\n if (ierr) {\n CCTK_WARN (0, \"Internal error in CCTK_GroupnghostzonesVI\");\n }\n \n CheckBoundaryParameters (cctkGH, vi, stencil);\n \n ierr = BndReflectVI (cctkGH, vi);\n if (ierr) {\n CCTK_WARN (0, \"Internal error in BndReflectVI\");\n }\n \n free (stencil);\n }\n\n free (indices);\n free (faces);\n free (widths);\n free (tables);\n}\n" |
| }, |
| "test": {}, |
| "doc": { |
| "documentation.tex": "% *======================================================================*\n% Cactus Thorn template for ThornGuide documentation\n% Author: Ian Kelley\n% Date: Sun Jun 02, 2002\n%\n% Thorn documentation in the latex file doc/documentation.tex\n% will be included in ThornGuides built with the Cactus make system.\n% The scripts employed by the make system automatically include\n% pages about variables, parameters and scheduling parsed from the\n% relevant thorn CCL files.\n%\n% This template contains guidelines which help to assure that your\n% documentation will be correctly added to ThornGuides. More\n% information is available in the Cactus UsersGuide.\n%\n% Guidelines:\n% - Do not change anything before the line\n% % START CACTUS THORNGUIDE\",\n% except for filling in the title, author, date, etc. fields.\n% - Each of these fields should only be on ONE line.\n% - Author names should be separated with a \\\\ or a comma.\n% - You can define your own macros, but they must appear after\n% the START CACTUS THORNGUIDE line, and must not redefine standard\n% latex commands.\n% - To avoid name clashes with other thorns, 'labels', 'citations',\n% 'references', and 'image' names should conform to the following\n% convention:\n% ARRANGEMENT_THORN_LABEL\n% For example, an image wave.eps in the arrangement CactusWave and\n% thorn WaveToyC should be renamed to CactusWave_WaveToyC_wave.eps\n% - Graphics should only be included using the graphicx package.\n% More specifically, with the \"\\includegraphics\" command. Do\n% not specify any graphic file extensions in your .tex file. This\n% will allow us to create a PDF version of the ThornGuide\n% via pdflatex.\n% - References should be included with the latex \"\\bibitem\" command.\n% - Use \\begin{abstract}...\\end{abstract} instead of \\abstract{...}\n% - Do not use \\appendix, instead include any appendices you need as\n% standard sections.\n% - For the benefit of our Perl scripts, and for future extensions,\n% please use simple latex.\n%\n% *======================================================================*\n%\n% Example of including a graphic image:\n% \\begin{figure}[ht]\n% \t\\begin{center}\n% \t \\includegraphics[width=6cm]{MyArrangement_MyThorn_MyFigure}\n% \t\\end{center}\n% \t\\caption{Illustration of this and that}\n% \t\\label{MyArrangement_MyThorn_MyLabel}\n% \\end{figure}\n%\n% Example of using a label:\n% \\label{MyArrangement_MyThorn_MyLabel}\n%\n% Example of a citation:\n% \\cite{MyArrangement_MyThorn_Author99}\n%\n% Example of including a reference\n% \\bibitem{MyArrangement_MyThorn_Author99}\n% {J. Author, {\\em The Title of the Book, Journal, or periodical}, 1 (1999),\n% 1--16. {\\tt http://www.nowhere.com/}}\n%\n% *======================================================================*\n\n% If you are using CVS use this line to give version information\n\n\\documentclass{article}\n\n% Use the Cactus ThornGuide style file\n% (Automatically used from Cactus distribution, if you have a\n% thorn without the Cactus Flesh download this from the Cactus\n% homepage at www.cactuscode.org)\n\\usepackage{../../../../doc/latex/cactus}\n\n\\begin{document}\n\n% The author of the documentation\n\\author{Erik Schnetter \\textless schnetter@aei.mpg.de\\textgreater}\n\n% The title of the document (not necessarily the name of the Thorn)\n\\title{ReflectionSymmetry}\n\n% the date your document was last changed, if your document is in CVS,\n% please use:\n\\date{June 01 2004}\n\n\\maketitle\n\n% Do not delete next line\n% START CACTUS THORNGUIDE\n\n% Add all definitions used in this documentation here\n% \\def\\mydef etc\n\n% Add an abstract for this thorn's documentation\n\\begin{abstract}\n\n\\end{abstract}\n\n% The following sections are suggestive only.\n% Remove them or add your own.\n\n\\section{Introduction}\n\n\\section{Physical System}\n\n\\section{Numerical Implementation}\n\n\\section{Using This Thorn}\n\n\\subsection{Obtaining This Thorn}\n\n\\subsection{Basic Usage}\n\n\\subsection{Special Behaviour}\n\n\\subsection{Interaction With Other Thorns}\n\n\\subsection{Examples}\n\n\\subsection{Support and Feedback}\n\n\\section{History}\n\n\\subsection{Thorn Source Code}\n\n\\subsection{Thorn Documentation}\n\n\\subsection{Acknowledgements}\n\n\n\\begin{thebibliography}{9}\n\n\\end{thebibliography}\n\n% Do not delete next line\n% END CACTUS THORNGUIDE\n\n\\end{document}\n" |
| } |
| } |