einsteintoolkit / CactusNumerical_SphericalSurface.json
xinshuo's picture
Upload folder using huggingface_hub
10a2580 verified
Raw
History Blame Contribute Delete
51.6 kB
{
"thorn_name": "CactusNumerical/SphericalSurface",
"url": "https://bitbucket.org/cactuscode/cactusnumerical.git",
"configuration": "",
"interface": "# Interface definition for thorn SphericalSurface\n\nIMPLEMENTS: SphericalSurface\ninherits: grid\n\n\n\n# Get current refinement level\nCCTK_INT FUNCTION GetRefinementLevel (CCTK_POINTER_TO_CONST IN cctkGH)\nUSES FUNCTION GetRefinementLevel\n\n# simple translation function from user-friendly name to numerical Id\n# if name is not empty returns the matching name and -1 if no name matches\n# if name is empty returns fallbackid\nCCTK_INT \\\nFUNCTION sf_IdFromName (CCTK_INT IN fallbackid, CCTK_POINTER_TO_CONST IN name)\nPROVIDES FUNCTION sf_IdFromName WITH SphericalSurface_IdFromName LANGUAGE C\n\n\n\nPUBLIC:\n\n\n# To be defined by the setting thorn.\n# Suggested meanings:\n# zero: The surface data are invalid (garbage)\n# one: The surface data are valid in principle, although they may be outdated\nCCTK_INT sf_active[nsurfaces] TYPE=scalar\n\n# To be defined by the setting thorn.\n# Suggested meanings: \n# zero: No surface is provided at this time step\n# negative: No surface could be found at this time step\n# positive: The surface data are valid\nCCTK_INT sf_valid[nsurfaces] TYPE=scalar\n\n\n\n\n\nCCTK_REAL sf_info[nsurfaces] TYPE=scalar\n{\n # The following are covariant quantities:\n \n # proper area:\n # A := int(S) sqrt(q) dS\n # with q_ij the 2-metric on the surface\n sf_area\n \n \n \n # The following are coordinate-dependent quantities:\n \n # monopole moment (average coordinate radius):\n # M := int(S) h ds / A\n sf_mean_radius\n\n # dipole moment:\n # D^i := int(S) x^i dS / A\n sf_centroid_x sf_centroid_y sf_centroid_z\n\n # quadrupole moment:\n # Q^ij := int(S) y^i y^j dS / A with y^i := x^i - D^i\n sf_quadrupole_xx sf_quadrupole_xy sf_quadrupole_xz\n sf_quadrupole_yy sf_quadrupole_yz sf_quadrupole_zz\n \n \n \n # minimum and maximum coordinate radius\n sf_min_radius sf_max_radius\n\n # bounding box\n sf_min_x sf_min_y sf_min_z sf_max_x sf_max_y sf_max_z\n} \"Surface information\"\n\n\n\n# the finest reflevel each surface is intersecting\nCCTK_INT sf_minreflevel[nsurfaces] TYPE=scalar\n\n# the finest reflevel that contains the entire surface\nCCTK_INT sf_maxreflevel[nsurfaces] TYPE=scalar\n\n\nCCTK_REAL sf_radius[nsurfaces] TYPE=array DIM=2 SIZE=maxntheta,maxnphi DISTRIB=constant #TAGS='convergence_power=1'\n\nCCTK_REAL sf_origin[nsurfaces] TYPE=scalar\n{\n # these are to be set together with the radius grid array\n sf_origin_x sf_origin_y sf_origin_z\n}\n\n\n \nCCTK_REAL sf_coordinate_descriptors[nsurfaces] TYPE=scalar\n{\n # these are set up by this thorn, and should be treated as read-only\n sf_origin_theta sf_origin_phi\n sf_delta_theta sf_delta_phi\n} \"Surface coordinate descriptors\"\n\n\n\nCCTK_INT sf_shape_descriptors[nsurfaces] TYPE=scalar\n{\n sf_ntheta sf_nphi\n sf_nghoststheta sf_nghostsphi\n} \"Surface shape descriptors\"\n\n\nprivate:\n\n\nCCTK_REAL sf_coordinate_estimators[nsurfaces] TYPE=scalar\n{\n sf_delta_theta_estimate sf_delta_phi_estimate\n} \"Surface coordinate estimators\"\n",
"param": "# Parameter definitions for thorn SphericalSurface\n\nRESTRICTED:\n\n# You can enlarge the possible number of surfaces by changing the maximum\n# 42 in the parameter nsurfaces, and by changing the array sizes [42] found\n# in many of the parameters below.\n\nCCTK_INT nsurfaces \"Number of surfaces\" STEERABLE=recover\n{\n 0:42 :: \"\"\n} 0\n\n# can be queried via SphericalSurface_IdFromName()\nCCTK_STRING name[42] \"User friendly name of spherical surface\" STEERABLE=always\n{\n \"\" :: \"none set\"\n \".*\" :: \"any string\"\n} \"\"\n\n\n# Warning: this will MPI hang when the number of components per refinement\n# level differs between processors\nBOOLEAN auto_res[42] \"Automatically determine resolution according to radius and Cartesian resolution\"\n{\n} no\n\n\nCCTK_REAL auto_res_ratio[42] \"Multiplicative factor by which we want to scale the resolution with respect to Cartesian resolution\"\n{\n 0:* :: \"\"\n} 2.0\n\n\nKEYWORD auto_res_grid[42] \"Choose resolution according to how grids overlap\" \n{\n \"fully contained\" :: \"SF must be fully contained in Cartesian grid\"\n \"overlap\" :: \"SF overlaps with grid\"\n \"multipatch\" :: \"SF potentially overlaps with a spherical mutipatch grid\"\n} \"fully contained\"\n\n\n\nBOOLEAN verbose \"Shall I be verbose?\"\n{\n} no\n\n\n# Default parameter values do not trigger accumulator expressions.\n# Therefore the default values here must be large enough for the default\n# surface shape.\n\n# These parameters change the size of a checkpointed grid array. When changing them you will have to skip recovering sf_radius.\n\n#CCTK_INT maxntheta \"do not set this parameter directly\" ACCUMULATOR=((x>y)*x+!(x>y)*y)\nCCTK_INT maxntheta \"Maximum number of grid points in the theta direction\" STEERABLE=RECOVER\n{\n 0:* :: \"\"\n} 19\n\n#CCTK_INT maxnphi \"do not set this parameter directly\" ACCUMULATOR=((x>y)*x+!(x>y)*y)\nCCTK_INT maxnphi \"Maximum number of grid points in the phi direction\" STEERABLE=RECOVER\n{\n 0:* :: \"\"\n} 38\n\n\nCCTK_INT ntheta[42] \"Number of grid points in the theta direction\" STEERABLE=always #ACCUMULATOR-BASE maxntheta\n{\n 0:* :: \"must be at least 3*nghoststheta\"\n} 19\n\nCCTK_INT nphi[42] \"Number of grid points in the phi direction\" STEERABLE=always #ACCUMULATOR-BASE maxnphi\n{\n 0:* :: \"must be at least 3*nghostsphi\"\n} 38\n\n\n\nCCTK_INT nghoststheta[42] \"Number of ghost zones in the theta direction\" STEERABLE=always #ACCUMULATOR-BASE maxnghoststheta\n{\n 0:* :: \"\"\n} 2\n\nCCTK_INT nghostsphi[42] \"Number of ghost zones in the phi direction\" STEERABLE=always #ACCUMULATOR-BASE maxnghostsphi\n{\n 0:* :: \"\"\n} 2\n\n\n\nBOOLEAN symmetric_x[42] \"Reflection symmetry in the x direction\" STEERABLE=always\n{\n} no\n\nBOOLEAN symmetric_y[42] \"Reflection symmetry in the y direction\" STEERABLE=always\n{\n} no\n\nBOOLEAN symmetric_z[42] \"Reflection symmetry in the z direction\" STEERABLE=always\n{\n} no\n\n\n\nPRIVATE:\n\n\n\n\n\n# Place a surfaces at a certain location\n\nCCTK_REAL origin_x[42] \"Origin for surface\" STEERABLE=always\n{\n * :: \"origin\"\n} 0.0\n\nCCTK_REAL origin_y[42] \"Origin for surface\" STEERABLE=always\n{\n * :: \"origin\"\n} 0.0\n\nCCTK_REAL origin_z[42] \"Origin for surface\" STEERABLE=always\n{\n * :: \"origin\"\n} 0.0\n\n\n\nBOOLEAN set_spherical[42] \"Place surface at a certain radius\" STEERABLE=always\n{\n} no\n\nCCTK_REAL radius[42] \"Radius for surface\" STEERABLE=always\n{\n * :: \"radius\"\n} 0.0\n\n\n\nBOOLEAN set_elliptic[42] \"Place surface at a certain radius\" STEERABLE=always\n{\n} no\n\nCCTK_REAL radius_x[42] \"Radius for surface\" STEERABLE=always\n{\n * :: \"radius\"\n} 0.0\n\nCCTK_REAL radius_y[42] \"Radius for surface\" STEERABLE=always\n{\n * :: \"radius\"\n} 0.0\n\nCCTK_REAL radius_z[42] \"Radius for surface\" STEERABLE=always\n{\n * :: \"radius\"\n} 0.0\n",
"schedule": "# Schedule definitions for thorn SphericalSurface\n\nSTORAGE: sf_active\nSTORAGE: sf_valid\nSTORAGE: sf_info\nSTORAGE: sf_radius sf_origin\nSTORAGE: sf_coordinate_descriptors\nSTORAGE: sf_coordinate_estimators\nSTORAGE: sf_shape_descriptors\nSTORAGE: sf_minreflevel\nSTORAGE: sf_maxreflevel\n\n\n\nSCHEDULE SphericalSurface_SetupRes AT basegrid BEFORE SphericalSurface_Setup AFTER SpatialCoordinates AFTER CorrectCoordinates\n{\n LANG: C\n OPTIONS: global loop-local\n WRITES: SphericalSurface::sf_coordinate_estimators(everywhere)\n WRITES: SphericalSurface::sf_minreflevel(everywhere)\n WRITES: SphericalSurface::sf_maxreflevel(everywhere)\n} \"Set surface resolution automatically\"\n\nSCHEDULE SphericalSurface_Setup AT basegrid\n{\n LANG: C\n OPTIONS: global\n READS: SphericalSurface::sf_coordinate_estimators\n READS: SphericalSurface::sf_minreflevel\n READS: SphericalSurface::sf_maxreflevel\n WRITES: SphericalSurface::sf_shape_descriptors(everywhere)\n WRITES: SphericalSurface::sf_coordinate_descriptors(everywhere)\n WRITES: SphericalSurface::sf_active(everywhere)\n WRITES: SphericalSurface::sf_valid(everywhere)\n} \"Calculate surface coordinate descriptors\"\n\nSCHEDULE SphericalSurface_Set AT basegrid BEFORE SphericalSurface_HasBeenSet\n{\n LANG: C\n OPTIONS: global\n READS: SphericalSurface::sf_shape_descriptors\n READS: SphericalSurface::sf_coordinate_descriptors\n WRITES: SphericalSurface::sf_active(everywhere)\n WRITES: SphericalSurface::sf_valid(everywhere)\n WRITES: SphericalSurface::sf_info(everywhere)\n WRITES: SphericalSurface::sf_origin(everywhere)\n WRITES: SphericalSurface::sf_radius(everywhere)\n} \"Set surface radii to be used for initial setup in other thorns\"\n\nSCHEDULE GROUP SphericalSurface_HasBeenSet AT basegrid\n{\n} \"Set the spherical surfaces before this group, and use it afterwards\"\n\n\n\nSCHEDULE SphericalSurface_Set AT poststep BEFORE SphericalSurface_HasBeenSet\n{\n LANG: C\n OPTIONS: global\n} \"Set surface radii\"\n\nSCHEDULE GROUP SphericalSurface_HasBeenSet AT poststep\n{\n} \"Set the spherical surfaces before this group, and use it afterwards\"\n\n\n\nSCHEDULE SphericalSurface_CheckState IN SphericalSurface_HasBeenSet\n{\n LANG: C\n OPTIONS: global\n READS: SphericalSurface::sf_valid\n READS: SphericalSurface::sf_active\n} \"Test the state of the spherical surfaces\"\n\n\n\nschedule SphericalSurface_ParamCheck AT ParamCheck\n{\n LANG: C\n OPTIONS: global\n} \"Check that all surface names are unique\"\n",
"src": {
"radius.c": "#include <assert.h>\n#include <math.h>\n#include <stdio.h>\n\n#include \"cctk.h\"\n#include \"cctk_Arguments.h\"\n#include \"cctk_Parameters.h\"\n\n\n\nstatic\nCCTK_REAL min (CCTK_REAL const x, CCTK_REAL const y)\n{\n return x < y ? x : y;\n}\n\nstatic\nCCTK_REAL max (CCTK_REAL const x, CCTK_REAL const y)\n{\n return x > y ? x : y;\n}\n\n\n\nvoid SphericalSurface_Set (CCTK_ARGUMENTS)\n{\n DECLARE_CCTK_ARGUMENTS_SphericalSurface_Set;\n DECLARE_CCTK_PARAMETERS;\n \n CCTK_REAL const pi = 3.1415926535897932384626433832795028841971693993751;\n \n int n;\n int i, j;\n \n \n \n for (n=0; n<nsurfaces; ++n) {\n \n if (set_spherical[n]) {\n \n sf_active[n] = +1;\n sf_valid[n] = +1;\n \n sf_area[n] = 4 * pi * pow (radius[n], 2);\n \n sf_mean_radius[n] = radius[n];\n \n sf_centroid_x[n] = origin_x[n];\n sf_centroid_y[n] = origin_y[n];\n sf_centroid_z[n] = origin_z[n];\n \n sf_quadrupole_xx[n] = 0.0;\n sf_quadrupole_xy[n] = 0.0;\n sf_quadrupole_xz[n] = 0.0;\n sf_quadrupole_yy[n] = 0.0;\n sf_quadrupole_yz[n] = 0.0;\n sf_quadrupole_zz[n] = 0.0;\n \n sf_min_radius[n] = radius[n];\n sf_max_radius[n] = radius[n];\n \n sf_min_x[n] = origin_x[n] - radius[n];\n sf_min_y[n] = origin_y[n] - radius[n];\n sf_min_z[n] = origin_z[n] - radius[n];\n sf_max_x[n] = origin_x[n] + radius[n];\n sf_max_y[n] = origin_y[n] + radius[n];\n sf_max_z[n] = origin_z[n] + radius[n];\n \n for (j=0; j<sf_nphi[n]; ++j) {\n for (i=0; i<sf_ntheta[n]; ++i) {\n int const ind = i + maxntheta * (j + maxnphi * n);\n sf_radius[ind] = radius[n];\n }\n }\n \n sf_origin_x[n] = origin_x[n];\n sf_origin_y[n] = origin_y[n];\n sf_origin_z[n] = origin_z[n];\n \n } else if (set_elliptic[n]) {\n \n /*\n * Equation for an ellipsoid:\n * x^2 / rx^2 + y^2 / ry^2 + z^2/ rz^2 = 1\n * where rx, ry, rz are the radii in the x, y, and z directions.\n *\n * With\n * x = r (sin theta) (cos phi)\n * y = r (sin theta) (sin phi)\n * z = r (cos theta)\n *\n * we get the solution\n * 1/r^2 = x^2/rx^2 + y^2/ry^2 + z^2/rz^2\n *\n * With the form\n * x A x = 1\n * we obtain\n * A = diag [1/rx^2, 1/ry^2, 1/rz^2]\n */\n \n CCTK_REAL const rx2 = pow (radius_x[n], 2);\n CCTK_REAL const ry2 = pow (radius_y[n], 2);\n CCTK_REAL const rz2 = pow (radius_z[n], 2);\n \n sf_active[n] = +1;\n sf_valid[n] = +1;\n \n sf_area[n] = 0 * 4 * pi * pow (radius[n], 2);\n \n sf_mean_radius[n] = 0 * radius[n];\n \n sf_centroid_x[n] = origin_x[n];\n sf_centroid_y[n] = origin_y[n];\n sf_centroid_z[n] = origin_z[n];\n \n sf_quadrupole_xx[n] = 1.0 / rz2;\n sf_quadrupole_xy[n] = 0.0;\n sf_quadrupole_xz[n] = 0.0;\n sf_quadrupole_yy[n] = 1.0 / ry2;\n sf_quadrupole_yz[n] = 0.0;\n sf_quadrupole_zz[n] = 1.0 / rx2;\n \n sf_min_radius[n] = min (radius_x[n], min (radius_y[n], radius_z[n]));\n sf_max_radius[n] = max (radius_x[n], max (radius_y[n], radius_z[n]));\n \n sf_min_x[n] = origin_x[n] - radius_x[n];\n sf_min_y[n] = origin_y[n] - radius_y[n];\n sf_min_z[n] = origin_z[n] - radius_z[n];\n sf_max_x[n] = origin_x[n] + radius_x[n];\n sf_max_y[n] = origin_y[n] + radius_y[n];\n sf_max_z[n] = origin_z[n] + radius_z[n];\n \n for (j=0; j<sf_nphi[n]; ++j) {\n for (i=0; i<sf_ntheta[n]; ++i) {\n int const ind = i + maxntheta * (j + maxnphi * n);\n CCTK_REAL const theta = sf_origin_theta[n] + i * sf_delta_theta[n];\n CCTK_REAL const phi = sf_origin_phi[n] + j * sf_delta_phi[n];\n CCTK_REAL const x2 = pow (sin(theta) * cos(phi), 2);\n CCTK_REAL const y2 = pow (sin(theta) * sin(phi), 2);\n CCTK_REAL const z2 = pow (cos(theta) , 2);\n sf_radius[ind] = 1.0 / sqrt (x2 / rx2 + y2 / ry2 + z2 / rz2);\n }\n }\n \n sf_origin_x[n] = origin_x[n];\n sf_origin_y[n] = origin_y[n];\n sf_origin_z[n] = origin_z[n];\n \n }\n \n } /* for n */\n}\n",
"make.code.defn": "# Main make.code.defn file for thorn SphericalSurface\n\n# Source files in this directory\nSRCS = check.c radius.c setup.cc\n\n# Subdirectories containing source files\nSUBDIRS = \n\n",
"check.c": "#include <assert.h>\n#include <math.h>\n#include <stdio.h>\n\n#include \"cctk.h\"\n#include \"cctk_Arguments.h\"\n#include \"cctk_Parameters.h\"\n\n\n\nvoid SphericalSurface_CheckState (CCTK_ARGUMENTS)\n{\n DECLARE_CCTK_ARGUMENTS_SphericalSurface_CheckState;\n DECLARE_CCTK_PARAMETERS;\n \n int n;\n \n for (n=0; n<nsurfaces; ++n) {\n \n if (sf_valid[n] > 0 && sf_active[n] == 0) {\n \n CCTK_VWarn (CCTK_WARN_ABORT, __LINE__, __FILE__, CCTK_THORNSTRING,\n \"Surface #%d has sf_valid set to a positive value, but does \"\n \"not have sf_active set. This is an error in the thorn \"\n \"which calculated this surface\", n);\n \n }\n \n }\n}\n",
"setup.cc": "#include <assert.h>\n#include <math.h>\n#include <stdio.h>\n\n#include \"cctk.h\"\n#include \"cctk_Arguments.h\"\n#include \"cctk_Parameters.h\"\n\n//#include <mpi.h>\n\n\n// local functions\nstatic bool all_sf_names_are_unique(CCTK_INT warnlevel);\nstatic int get_reflevel (cGH const * const cctkGH);\n\n\nstatic int get_reflevel (cGH const * const cctkGH)\n{\n if (CCTK_IsFunctionAliased (\"GetRefinementLevel\")) {\n return GetRefinementLevel (cctkGH);\n } else {\n return 0;\n }\n}\n\n\n// simple translation function from user-friendly name to numerical Id\n// if name is not empty returns the matching name and -1 if no name matches\n// if name is empty returns fallbackid\nextern \"C\" CCTK_INT SphericalSurface_IdFromName (CCTK_INT fallbackid, CCTK_POINTER_TO_CONST sfname)\n{\n DECLARE_CCTK_PARAMETERS;\n CCTK_INT retval = -1;\n\n // re-check for unique names since the parameters are steerable\n if(!all_sf_names_are_unique(CCTK_WARN_ALERT))\n CCTK_WARN(CCTK_WARN_ABORT, \"Not all spherical surface names are unique.\"); \n\n if (CCTK_Equals(static_cast<CCTK_STRING>(sfname), \"\")) {\n\n retval = fallbackid;\n } else {\n\n for (CCTK_INT n=0; n<nsurfaces; ++n) {\n \n if (CCTK_Equals(static_cast<CCTK_STRING>(sfname), name[n])) {\n \n retval = n;\n break;\n }\n }\n\n if (retval == -1) {\n CCTK_VWarn(CCTK_WARN_ALERT, __LINE__, __FILE__, CCTK_THORNSTRING,\n \"Did not find spherical surface with name '%s'.\", \n static_cast<CCTK_STRING>(sfname));\n }\n }\n\n return retval;\n}\n\n// utility function to check if all SphericalSurface names are unique (or empty)\nstatic bool all_sf_names_are_unique(CCTK_INT warnlevel)\n{\n DECLARE_CCTK_PARAMETERS;\n bool all_unique = true;\n\n for (int i=0; i<nsurfaces; ++i) {\n if (CCTK_Equals(static_cast<CCTK_STRING>(name[i]), \"\"))\n continue;\n for (int j=i+1; j<nsurfaces; ++j) {\n if (CCTK_Equals(static_cast<CCTK_STRING>(name[i]), static_cast<CCTK_STRING>(name[j]))) {\n CCTK_VWarn(warnlevel, __LINE__, __FILE__, CCTK_THORNSTRING,\n \"Duplicate names for spherical surfaces %d and %d: %s == %s\", \n i,j, name[i], name[j]);\n all_unique = false;\n }\n }\n }\n\n return all_unique;\n}\n\n// check early that all SphericalSurface names are valid\nextern \"C\" void SphericalSurface_ParamCheck (CCTK_ARGUMENTS)\n{\n DECLARE_CCTK_ARGUMENTS_SphericalSurface_ParamCheck;\n\n if (!all_sf_names_are_unique(CCTK_WARN_ALERT)) {\n CCTK_PARAMWARN(\"Not all spherical surface names are unique.\");\n }\n}\n \n//TODO: overlap with finer levels still seems to be incorrect!\n\nextern \"C\" void SphericalSurface_Setup (CCTK_ARGUMENTS)\n{\n DECLARE_CCTK_ARGUMENTS_SphericalSurface_Setup;\n DECLARE_CCTK_PARAMETERS;\n \n CCTK_REAL const pi = 4 * atan(CCTK_REAL(1.0));\n \n int ierr;\n \n \n \n if (nsurfaces == 0) return;\n \n \n \n int const group = CCTK_GroupIndex (\"SphericalSurface::sf_radius\");\n assert (group>=0);\n cGroup groupinfo;\n ierr = CCTK_GroupData (group, &groupinfo);\n assert (!ierr);\n cGroupDynamicData groupdata;\n ierr = CCTK_GroupDynamicData (cctkGH, group, &groupdata);\n assert (!ierr);\n \n \n \n for (int n=0; n<nsurfaces; ++n) {\n \n if (!auto_res[n])\n {\n // set resolution according to given parameters\n \n // internal consistency checks\n assert (groupdata.dim == 2);\n assert (groupdata.gsh[0] >= ntheta[n]);\n assert (groupdata.gsh[1] >= nphi[n]);\n \n assert (ntheta[n] >= 3*nghoststheta[n] && ntheta[n] <= maxntheta);\n assert (nphi[n] >= 3*nghostsphi[n] && nphi[n] <= maxnphi);\n \n \n \n // copy parameters into grid functions\n sf_ntheta[n] = ntheta[n];\n sf_nphi[n] = nphi[n];\n sf_nghoststheta[n] = nghoststheta[n];\n sf_nghostsphi[n] = nghostsphi[n];\n }\n else\n {\n // we already have an approximate delta-spacing calculated in \"SetupRes\"\n // based on that, we calculate the number of necessary gridpoints...\n CCTK_WARN(1, \"AutoRes will NOT work with checkpoint/recovery!\");\n \n CCTK_REAL theta_range = pi;\n CCTK_REAL phi_range = 2*pi;\n \n if (symmetric_x[n])\n phi_range /= 2;\n \n if (symmetric_y[n])\n phi_range /= 2;\n \n if (symmetric_z[n])\n theta_range /= 2;\n \n sf_ntheta[n] = lrint(theta_range/sf_delta_theta_estimate[n]) + 2*nghoststheta[n];\n sf_nphi[n] = lrint(phi_range /sf_delta_phi_estimate[n] ) + 2*nghostsphi[n];\n \n // ...make number of theta-gridpoints odd...\n if (sf_ntheta[n] % 2 != 1)\n sf_ntheta[n] += 1;\n \n // ... and make inner phi-gridpoints divisible by 4 since some thorns require that (e.g. IsolatedHorizon)\n sf_nphi[n] += 4 - (sf_nphi[n]-2*nghostsphi[n]) % 4 + 2*nghostsphi[n];\n \n // consistency check\n if (sf_ntheta[n] < 3*nghoststheta[n]) \n {\n CCTK_WARN(1, \"AutoRes: Determined sf_ntheta[n] < 3*nghoststheta[n]! Setting sf_ntheta[n] = 3*nghoststheta[n]!\");\n sf_ntheta[n] = 3*nghoststheta[n];\n }\n if (sf_ntheta[n] > maxntheta)\n {\n CCTK_WARN(1, \"AutoRes: Determined sf_ntheta[n] > maxntheta! You should increase maxntheta or auto_res_ratio[n]! Setting sf_ntheta[n] = maxntheta!\");\n sf_ntheta[n] = maxntheta;\n }\n if (sf_nphi[n] < 3*nghostsphi[n]) \n {\n CCTK_WARN(1, \"AutoRes: Determined sf_nphi[n] < 3*nghostsphi[n]! Setting sf_nphi[n] = 3*nghostsphi[n]!\");\n sf_nphi[n] = 3*nghostsphi[n];\n }\n if (sf_nphi[n] > maxnphi)\n {\n CCTK_WARN(1, \"AutoRes: Determined sf_nphi[n] > maxnphi! You should increase maxnphi or auto_res_ratio[n]! Setting sf_nphi[n] = maxnphi!\");\n sf_nphi[n] = maxnphi;\n }\n \n // check, if there are enough maxntheta,maxnphi gridpoints to remove symmetries\n // (some thorns require that)\n if (symmetric_z[n])\n {\n if (2*(sf_ntheta[n]-2*nghoststheta[n])+2*nghoststheta[n] > maxntheta)\n\t CCTK_WARN(0, \"maxntheta is not big enough to remove z-symmetry (some thorns may require that)!\");\n }\n \n if (symmetric_x[n])\n {\n if (symmetric_y[n])\n {\n if (4*(sf_nphi[n]-2*nghostsphi[n])+2*nghostsphi[n] > maxnphi)\n {\n CCTK_WARN(0, \"maxnphi is not big enough to remove x-symmetry and y-symmetry (some thorns may require that)!\");\n }\n }\n else\n {\n if (2*(sf_nphi[n]-2*nghostsphi[n])+2*nghostsphi[n] > maxnphi)\n {\n CCTK_WARN(0, \"maxnphi is not big enough to remove x-symmetry and y-symmetry (some thorns may require that)!\");\n }\n }\n }\n else\n {\n if (symmetric_y[n])\n {\n if (2*(sf_nphi[n]-2*nghostsphi[n])+2*nghostsphi[n] > maxnphi)\n {\n CCTK_WARN(0, \"maxnphi is not big enough to remove x-symmetry and y-symmetry (some thorns may require that)!\");\n }\n }\n }\n\n \n sf_nghoststheta[n] = nghoststheta[n];\n sf_nghostsphi[n] = nghostsphi[n];\n \n if (verbose)\n {\n CCTK_VInfo (CCTK_THORNSTRING, \"SphericalSurface[%d]: setting sf_ntheta = %d\", n, int(sf_ntheta[n]));\n CCTK_VInfo (CCTK_THORNSTRING, \"SphericalSurface[%d]: setting sf_nphi = %d\", n, int(sf_nphi[n]));\n }\n }\n \n if (verbose)\n {\n CCTK_VInfo (CCTK_THORNSTRING, \"SphericalSurface[%d]: finest refinement-level that fully contains this surface: sf_maxreflevel = %d\", n, int(sf_maxreflevel[n]));\n CCTK_VInfo (CCTK_THORNSTRING, \"SphericalSurface[%d]: finest refinement-level that overlaps with this surface : sf_minreflevel = %d\", n, int(sf_minreflevel[n]));\n }\n \n // coordinates in the theta direction\n // avoid_sf_origin_theta = 1\n if (symmetric_z[n]) {\n \n // upper hemisphere: z>=0, theta in (0, pi/2)\n sf_delta_theta[n] = pi/2 / (sf_ntheta[n] - 2*nghoststheta[n] - 0.5);\n sf_origin_theta[n] = - (nghoststheta[n] - 0.5) * sf_delta_theta[n];\n \n } else {\n \n // both hemispheres: theta in (0, pi)\n sf_delta_theta[n] = pi / (sf_ntheta[n] - 2*nghoststheta[n]);\n sf_origin_theta[n] = - (nghoststheta[n] - 0.5) * sf_delta_theta[n];\n \n }\n \n \n \n // coordinates in the phi direction\n // avoid_sf_origin_phi = 0\n if (symmetric_x[n]) {\n if (symmetric_y[n]) {\n \n // one quadrant: x>=0, y>=0, phi in [0, pi/2]\n assert (sf_nphi[n] - 2*nghostsphi[n] >= 1);\n sf_delta_phi[n] = pi/2 / (sf_nphi[n] - 2*nghostsphi[n] - 1);\n sf_origin_phi[n] = - nghostsphi[n] * sf_delta_phi[n];\n \n } else {\n \n // two quadrants: x>=0, phi in [-pi/2, pi/2]\n assert (sf_nphi[n] - 2*nghostsphi[n] >= 2);\n sf_delta_phi[n] = pi / (sf_nphi[n] - 2*nghostsphi[n] - 1);\n sf_origin_phi[n] = - pi/2 - nghostsphi[n] * sf_delta_phi[n];\n \n }\n } else {\n if (symmetric_y[n]) {\n \n // two quadrants: y>=0, phi in [0, pi]\n assert (sf_nphi[n] - 2*nghostsphi[n] >= 2);\n sf_delta_phi[n] = pi / (sf_nphi[n] - 2*nghostsphi[n] - 1);\n sf_origin_phi[n] = - nghostsphi[n] * sf_delta_phi[n];\n \n } else {\n \n // all quadrants: phi in [0, 2pi)\n assert (sf_nphi[n] - 2*nghostsphi[n] >= 4);\n sf_delta_phi[n] = 2*pi / (sf_nphi[n] - 2*nghostsphi[n]);\n sf_origin_phi[n] = - nghostsphi[n] * sf_delta_phi[n];\n \n }\n }\n \n if (verbose) {\n CCTK_VInfo (CCTK_THORNSTRING, \"SphericalSurface[%d]: sf_delta_theta = %.6f, sf_delta_phi = %.6f\\n\", n, sf_delta_theta[n], sf_delta_phi[n]);\n }\n \n // mark surface as uninitialised\n sf_active[n] = 0;\n sf_valid[n] = 0;\n \n } // for n\n}\n\n\n\nextern \"C\" void SphericalSurface_SetupRes (CCTK_ARGUMENTS)\n{\n DECLARE_CCTK_ARGUMENTS_SphericalSurface_SetupRes;\n DECLARE_CCTK_PARAMETERS;\n \n static bool first_call = true;\n \n int min_reduction_handle = CCTK_ReductionArrayHandle(\"minimum\");\n int max_reduction_handle = CCTK_ReductionArrayHandle(\"maximum\");\n\n if (min_reduction_handle < 0)\n CCTK_WARN(0, \"Cannot get reduction handle for minimum operation.\");\n if (max_reduction_handle < 0)\n CCTK_WARN(0, \"Cannot get reduction handle for maximum operation.\");\n \n for (int n=0; n<nsurfaces; ++n) \n {\n \n // try to find out with which Carpet::reflevel completely contains\n // the current surface and will intersect and and store the\n // result so that other thorns such as the kick-thorn\n // can decide which reflevel to use\n \n // set resolution according to Radius and Cartesian resolution\n\n if (!auto_res[n])\n continue;\n \n CCTK_REAL my_radius;\n \n if (!set_spherical[n] && !set_elliptic[n])\n {\n // we have a problem...without a radius we cannot estimate a proper resolution\n // Here, we simply assume r=1 if radius[n] == 0.\n // If you want a better estimate of the resolution, set the radius parameter to an initial guess!\n \n if (radius[n] == 0)\n my_radius = 1;\n else\n\t my_radius = radius[n];\n }\n else\n {\n my_radius = radius[n];\n }\n \n if (verbose) {\n CCTK_VInfo (CCTK_THORNSTRING, \"SphericalSurface: myradius = %f\", double(my_radius));\n }\n // get theta/phi delta-spacing by looking at Cartesian grid\n \n // first test, if we have an overlap with a certain reflevel\n // we do this by calculating a sphere based on the corners of the Cartesian local patch\n // on this processor.\n //unsigned long l[2];\n \n //l[0] = CCTK_GFINDEX3D(cctkGH, 0, 0, 0);\n //l[1] = CCTK_GFINDEX3D(cctkGH, cctk_lsh[0]-1, cctk_lsh[1]-1, cctk_lsh[2]-1);\n \n bool is_overlapping = false;\n CCTK_REAL cart_radius = 0; // radius of Cart. grid\n CCTK_REAL cart_origin[3]; // origin of Cart. grid\n \n //CCTK_ORIGIN_SPACE(0) + (cctk_lbnd[0]) * CCTK_DELTA_SPACE(0) - (CCTK_ORIGIN_SPACE(0) + (cctk_lbnd[0] + cctk_lsh[0]) * CCTK_DELTA_SPACE(0))\n \n // calculate radius of Cartesian grid\n cart_origin[0] = 0.5 * cctk_lsh[0] * CCTK_DELTA_SPACE(0); //(x[l[1]] - x[l[0]]) / 2.0;\n cart_origin[1] = 0.5 * cctk_lsh[1] * CCTK_DELTA_SPACE(1); //(y[l[1]] - y[l[0]]) / 2.0;\n cart_origin[2] = 0.5 * cctk_lsh[2] * CCTK_DELTA_SPACE(2); //(z[l[1]] - z[l[0]]) / 2.0;\n \n cart_radius = sqrt(cart_origin[0]*cart_origin[0] + cart_origin[1]*cart_origin[1] + cart_origin[2]*cart_origin[2]);\n \n if (verbose) {\n CCTK_VInfo (CCTK_THORNSTRING, \"SphericalSurface: cart_radius = %f, cart_origin = %f, %f, %f\", double(cart_radius), double(cart_origin[0]), double(cart_origin[1]), double(cart_origin[2]));\n }\n\n // set origin of Cartesian grid\n cart_origin[0] += CCTK_ORIGIN_SPACE(0) + cctk_lbnd[0] * CCTK_DELTA_SPACE(0); //x[l[0]];\n cart_origin[1] += CCTK_ORIGIN_SPACE(1) + cctk_lbnd[1] * CCTK_DELTA_SPACE(1); //y[l[0]];\n cart_origin[2] += CCTK_ORIGIN_SPACE(2) + cctk_lbnd[2] * CCTK_DELTA_SPACE(2); //z[l[0]];\n \n // norm of displacement vector between origin of Cart. grid and origin of SphericalSurface\n CCTK_REAL dist = sqrt( (cart_origin[0]-origin_x[n]) * (cart_origin[0]-origin_x[n])\n + (cart_origin[1]-origin_y[n]) * (cart_origin[1]-origin_y[n])\n + (cart_origin[2]-origin_z[n]) * (cart_origin[2]-origin_z[n]));\n \n // does our spherical shell overlap with the processor's local grid patch? \n if (my_radius+cart_radius >= dist && // Cart. grid and SphericalSurface overlap\n cart_radius+dist > my_radius && // Cart. grid patch is not fully contained in this SphericalSurface\n -cart_radius+dist < my_radius) // Cart. grid patch is not outside of the spherical shell\n is_overlapping = true;\n \n // get resolution\n if (is_overlapping)\n {\n if (CCTK_Equals(auto_res_grid[n], \"overlap\"))\n {\n sf_delta_theta_estimate[n] = auto_res_ratio[n] / my_radius * sqrt(CCTK_DELTA_SPACE(0)*CCTK_DELTA_SPACE(0) \n + CCTK_DELTA_SPACE(1)*CCTK_DELTA_SPACE(1) \n + CCTK_DELTA_SPACE(2)*CCTK_DELTA_SPACE(2));\n \n sf_delta_phi_estimate[n] = auto_res_ratio[n] / my_radius * sqrt(CCTK_DELTA_SPACE(0)*CCTK_DELTA_SPACE(0) \n + CCTK_DELTA_SPACE(1)*CCTK_DELTA_SPACE(1) \n + CCTK_DELTA_SPACE(2)*CCTK_DELTA_SPACE(2));\n }\n \n // store reflevel\n sf_minreflevel[n] = get_reflevel(cctkGH);\n }\n else if (first_call)\n {\n // set to very high value initially (otherwise would be zero\n // and reported as minimum value in following MPI communication)\n sf_delta_theta_estimate[n] = 10000;\n sf_delta_phi_estimate[n] = 10000; \n }\n \n if (CCTK_Equals(auto_res_grid[n], \"overlap\"))\n {\n // find minimum value of \"sf_delta_phi/theta\" over all processors\n CCTK_REAL dummy = 0;\n //MPI_Allreduce(&sf_delta_theta_estimate[n], &dummy, 1, MPI_DOUBLE, MPI_MIN, MPI_COMM_WORLD);\n CCTK_ReduceLocScalar(cctkGH, -1, min_reduction_handle, &sf_delta_theta_estimate[n], &dummy, CCTK_VARIABLE_REAL);\n sf_delta_theta_estimate[n] = dummy;\n \n dummy = 0;\n //MPI_Allreduce(&sf_delta_phi_estimate[n], &dummy, 1, MPI_DOUBLE, MPI_MIN, MPI_COMM_WORLD);\n CCTK_ReduceLocScalar(cctkGH, -1, min_reduction_handle, &sf_delta_phi_estimate[n], &dummy, CCTK_VARIABLE_REAL);\n sf_delta_phi_estimate[n] = dummy;\n \n /*\n // input arrays and output values\n const CCTK_INT input_array_variable_indices[2]\n = { CCTK_VarIndex(\"SphericalSurface::sf_delta_theta_estimate\"),\n CCTK_VarIndex(\"SphericalSurface::sf_delta_phi_estimate\") };\n const CCTK_INT output_value_type_codes[2]\n = { CCTK_VARIABLE_REAL, CCTK_VARIABLE_REAL };\n void *const output_numbers[2]\n = { (void *) output_for_real_values,\n (void *) output_for_real_values };\n \n const int status\n = CCTK_ReduceGridArrays(GH,\n 0,\n 2, input_array_variable_indices,\n 2, output_value_type_codes,\n output_values);\n */\n }\n \n // find maximum value of \"sf_minreflevel\" over all processors\n int idummy;\n //MPI_Allreduce(&sf_minreflevel[n], &idummy, 1, MPI_INT, MPI_MAX, MPI_COMM_WORLD);\n CCTK_ReduceLocScalar(cctkGH, -1, max_reduction_handle, &sf_minreflevel[n], &idummy, CCTK_VARIABLE_INT);\n sf_minreflevel[n] = idummy;\n\n\n\n // find reflevel that completely contains this surface\n // FIXME: This algorithm does not take into account multiple\n // disconnected refinement regions.\n \n \n //safety margin of 6 points around sphere\n CCTK_INT const np = 6;\n \n CCTK_REAL max_radius = my_radius + ( sqrt( np*np*CCTK_DELTA_SPACE(0)*CCTK_DELTA_SPACE(0) \n + np*np*CCTK_DELTA_SPACE(1)*CCTK_DELTA_SPACE(1)\n + np*np*CCTK_DELTA_SPACE(2)*CCTK_DELTA_SPACE(2) ) ); \n\n if (verbose) {\n //CCTK_VInfo (CCTK_THORNSTRING, \"SphericalSurface: calculated max_radius = %.12f\\n\", max_radius);\n CCTK_VInfo (CCTK_THORNSTRING, \"SphericalSurface: buffer_radius = %.12f\", double (sqrt( np*np*CCTK_DELTA_SPACE(0)*CCTK_DELTA_SPACE(0) \n + np*np*CCTK_DELTA_SPACE(1)*CCTK_DELTA_SPACE(1)\n + np*np*CCTK_DELTA_SPACE(2)*CCTK_DELTA_SPACE(2) )));\n }\n\n /*\n unsigned long k[8];\n \n k[0] = CCTK_GFINDEX3D(cctkGH, 0, 0, 0);\n k[1] = CCTK_GFINDEX3D(cctkGH, cctk_lsh[0]-1, 0, 0);\n k[2] = CCTK_GFINDEX3D(cctkGH, 0, cctk_lsh[1]-1, 0);\n k[3] = CCTK_GFINDEX3D(cctkGH, cctk_lsh[0]-1, cctk_lsh[1]-1, 0);\n k[4] = CCTK_GFINDEX3D(cctkGH, 0, 0, cctk_lsh[2]-1);\n k[5] = CCTK_GFINDEX3D(cctkGH, cctk_lsh[0]-1, 0, cctk_lsh[2]-1);\n k[6] = CCTK_GFINDEX3D(cctkGH, 0, cctk_lsh[1]-1, cctk_lsh[2]-1);\n k[7] = CCTK_GFINDEX3D(cctkGH, cctk_lsh[0]-1, cctk_lsh[1]-1, cctk_lsh[2]-1);\n */\n \n unsigned long kx[8], ky[8], kz[8];\n \n kx[0] = 0; ky[0] = 0; kz[0] = 0;\n kx[1] = cctk_lsh[0]-1, ky[1] = 0; kz[1] = 0;\n kx[2] = 0; ky[2] = cctk_lsh[1]-1; kz[2] = 0;\n kx[3] = cctk_lsh[0]-1; ky[3] = cctk_lsh[1]-1; kz[3] = 0;\n kx[4] = 0; ky[4] = 0; kz[4] = cctk_lsh[2]-1;\n kx[5] = cctk_lsh[0]-1; ky[5] = 0; kz[5] = cctk_lsh[2]-1;\n kx[6] = 0; ky[6] = cctk_lsh[1]-1; kz[6] = cctk_lsh[2]-1;\n kx[7] = cctk_lsh[0]-1; ky[7] = cctk_lsh[1]-1; kz[7] = cctk_lsh[2]-1;\n \n \n int i;\n bool is_contained = false;\n for (i=0; i < 8; i++)\n {\n //if (max_radius < sqrt(x[k[i]]*x[k[i]] + y[k[i]]*y[k[i]] + z[k[i]]*z[k[i]]))\n // is_contained = true;\n CCTK_REAL xx = CCTK_ORIGIN_SPACE(0) + (cctk_lbnd[0] + kx[i]) * CCTK_DELTA_SPACE(0);\n CCTK_REAL yy = CCTK_ORIGIN_SPACE(1) + (cctk_lbnd[1] + ky[i]) * CCTK_DELTA_SPACE(1);\n CCTK_REAL zz = CCTK_ORIGIN_SPACE(2) + (cctk_lbnd[2] + kz[i]) * CCTK_DELTA_SPACE(2);\n if (max_radius < sqrt(xx*xx + yy*yy + zz*zz))\n is_contained = true;\n }\n \n int max_rl = 0;\n if (is_contained)\n {\n if (CCTK_Equals(auto_res_grid[n], \"fully contained\"))\n {\n sf_delta_theta_estimate[n] = auto_res_ratio[n] / my_radius * sqrt(CCTK_DELTA_SPACE(0)*CCTK_DELTA_SPACE(0) \n + CCTK_DELTA_SPACE(1)*CCTK_DELTA_SPACE(1) \n + CCTK_DELTA_SPACE(2)*CCTK_DELTA_SPACE(2));\n \n sf_delta_phi_estimate[n] = auto_res_ratio[n] / my_radius * sqrt(CCTK_DELTA_SPACE(0)*CCTK_DELTA_SPACE(0) \n + CCTK_DELTA_SPACE(1)*CCTK_DELTA_SPACE(1) \n + CCTK_DELTA_SPACE(2)*CCTK_DELTA_SPACE(2));\n }\n \n max_rl = get_reflevel(cctkGH);\n }\n else if (first_call)\n {\n // set to zero initially\n sf_delta_theta_estimate[n] = 0;\n sf_delta_phi_estimate[n] = 0; \n }\n \n \n // find minimum value of \"sf_maxreflevel\" over all processors\n //MPI_Allreduce(&max_rl, &idummy, 1, MPI_INT, MPI_MIN, MPI_COMM_WORLD);\n CCTK_ReduceLocScalar(cctkGH, -1, min_reduction_handle, &max_rl, &idummy, CCTK_VARIABLE_INT);\n if (idummy != 0 || first_call)\n\tsf_maxreflevel[n] = idummy;\n \n // this condition can become true because of this approximate algorithm\n // which does not take into account disconnected ref. regions\n if (sf_maxreflevel[n] > sf_minreflevel[n])\n sf_maxreflevel[n] = sf_minreflevel[n]; // can still be incorrect!\n\t\n \n if (CCTK_Equals(auto_res_grid[n], \"fully contained\"))\n {\n // find maximum value of \"sf_delta_phi/theta\" over all processors\n CCTK_REAL dummy = 0;\n //MPI_Allreduce(&sf_delta_theta_estimate[n], &dummy, 1, MPI_DOUBLE, MPI_MAX, MPI_COMM_WORLD);\n CCTK_ReduceLocScalar(cctkGH, -1, max_reduction_handle, &sf_delta_theta_estimate[n], &dummy, CCTK_VARIABLE_REAL);\n sf_delta_theta_estimate[n] = dummy;\n \n dummy = 0;\n //MPI_Allreduce(&sf_delta_phi_estimate[n], &dummy, 1, MPI_DOUBLE, MPI_MAX, MPI_COMM_WORLD);\n CCTK_ReduceLocScalar(cctkGH, -1, max_reduction_handle, &sf_delta_phi_estimate[n], &dummy, CCTK_VARIABLE_REAL);\n sf_delta_phi_estimate[n] = dummy;\n }\n \n if (verbose) {\n CCTK_VInfo (CCTK_THORNSTRING, \"SphericalSurface: sf_maxreflevel[%d] = %d, sf_minreflevel[%d] = %d\", n, int(sf_maxreflevel[n]), n, int(sf_minreflevel[n]));\n CCTK_VInfo (CCTK_THORNSTRING, \"SphericalSurface: sf_delta_theta[%d] = %.6f, sf_delta_phi[%d] = %.6f\\n\", n, sf_delta_theta_estimate[n], n, sf_delta_phi_estimate[n]);\n }\n\n }\n \n first_call = false;\n \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\\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@cct.lsu.edu\\textgreater}\n\n% The title of the document (not necessarily the name of the Thorn)\n\\title{SphericalSurface}\n\n% the date your document was last changed\n\\date{2007-03-06}\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\\begin{abstract}\nThis thorn provides a repository for two-dimensional surfaces with\nspherical topology. This thorn does not actually do anything with\nthese surfaces, but allows other thorns to store and retrieve the\nsurfaces and some associated information. The exact interpretation of\nthe stored quantities is up to the using thorns, but certain standard\ndefinitions are suggested.\n\\end{abstract}\n\n\n\n\\section{Introduction}\n\nMany thorns work on manifolds that are two-dimensional, closed\nsurfaces. Examples are apparent and event horizons, or the surfaces\non which gravitational waves are extracted. Other such surfaces might\nbe excision or outer boundaries (although these are currently not\ntreated as such). There is a need to have a common representation for\nsuch surfaces, so that the surface-finding thorns and the thorns\nworking with these surfaces can be independent. A common\nrepresentation will also facilitate visualisation. This thorn\n\\texttt{SphericalSurface} provides just such a common representation.\n\nThis thorn is not meant to do anything else but be a ``repository''\nfor surfaces. It is up to the surface-finding and surface-using\nthorns to agree on the details of the information stored. Of course,\nstandard definitions for the stored quantities are suggested. (For\nexample, there is no exact definition of the quadrupole moment,\nbecause this definition will depend on the kind of surface that is\nstored. However, it is specified that the quadrupole moment should be\ncalculate with respect to the centroid, and that it should not be\ntrace-free.)\n\nThis thorn provides storage for several independent surfaces,\nidentified by an \\emph{index}. It is up to the user to specify,\nprobably in the parameter file, which thorns use what surfaces for\nwhat purpose.\n\n\n\n\\section{Surface Definition}\n\nThis thorn provides, for each surface, a two-dimensional grid array\n\\code{sf\\_radius} and grid scalars \\code{sf\\_origin\\_x},\n\\code{sf\\_origin\\_y}, and \\code{sf\\_origin\\_z}. The number of\nsurfaces is determined by the parameter \\code{nsurfaces}, which has\nto be set in the parameter file.\n\n\\code{sf\\_radius} should contain the radius of the surface as\nmeasured from its origin, where the arrays indices vary in the\n$\\theta$ and $\\phi$ direction, respectively. Both the radius array\nand the surface origin are supposed to be set when a surface is\nstored.\n\nThe coordinates on the surface, i.e.\\ the grid origin and spacing in\nthe $\\theta$ and $\\phi$ directions, is available from the grid scalars\n\\code{sf\\_origin\\_theta}, \\code{sf\\_origin\\_phi},\n\\code{sf\\_delta\\_theta}, and \\code{sf\\_delta\\_phi}. These grid\nscalars are set by the thorn SphericalSurface in the \\code{basegrid}\nbin, and are meant to be read-only for other thorns.\n\n\n\n\\begin{quotation}\n\\subsection*{A note on vector grid variables}\n\nA relatively new addition to Cactus (in November 2003) are vector grid\nvariables. These are essentially arrays of grid variables. Thorn\nSphericalSurface makes use of these by storing the surfaces in such\narrays. That means that in order to access data from a single\nsurface, on has to use the corresponding surface index as array index.\nIn a similar manner, thorn SurfaceIndex uses array parameters for its\nparameters (except certain global ones).\n\nThis should be kept in mind when writing source code. C has the\nunfortunate property of converting arrays into meaningless integers if\nan array subscript is accidentally omitted. Fortran knows whole-array\nexpressions, meaning that it would act on all surfaces instead of a\nsingle one if an array subscript is accidentally omitted.\n\nEach element of a vector grid function is a grid function. (The term\n``grid function vector'' might have been more appropriate.) As such,\nit has a name, which can be used e.g.\\ for output. The name consists\nof the vector grid function name to which the surface index in square\nbrackets has been appended.\n\\end{quotation}\n\n\n\n\\subsection{Global Surface Quantities}\n\nIn many cases, only some abstract information about the surface is of\ninterest, such as its mean radius or its quadrupole moment. For that\npurpose there are additional grid scalars that carry this information.\nThese grid scalars are also supposed to be set when a surface is\nstored. These grid scalars are\n\\begin{description}\n\n\\item[\\code{sf\\_mean\\_radius}] Mean of the surface radius. This\nshould be the arithmetic mean where the radii have been weighted with\n$\\sin\\theta$, or a suitable generalisation thereof. This quantity is\nalso supposed to be a measure of the surface's monopole moment. One\nsuggested expression is $M=\\sqrt{A}$ with $A = \\int_S d\\Omega\\, r^2 /\n\\int_S d\\Omega$.\n\n\\item[\\code{sf\\_min\\_radius}, \\code{sf\\_max\\_radius}] Minimum and\nmaximum of the surface radius.\n\n\\item[\\code{sf\\_centroid\\_x}, \\code{sf\\_centroid\\_y},\n\\code{sf\\_centroid\\_z}] The centre of the surface. While the\nquantities \\code{sf\\_origin\\_*} denote the point from which the\nradius of the surface is measured, the quantities\n\\code{sf\\_centroid\\_*} should contain the point which is\n``logically'' the centre of the surface. This quantity is supposed to\nbe a measure of the dipole moment of the surface. One suggested\nexpression is $D^i = \\int_S d\\Omega\\, x^i / A$.\n\n\\item[\\code{sf\\_quadrupole\\_xx}, \\code{sf\\_quadrupole\\_xy},\n\\code{sf\\_quadrupole\\_xz}, \\code{sf\\_quadrupole\\_yy},\n\\code{sf\\_quadrupole\\_yz}, \\code{sf\\_quadrupole\\_zz}] The\nquadrupole moment of the surface. This should be the full quadrupole\nmoment and not a trace-free quantity. One suggested expression is\n$Q^{ij} = \\int_S d\\Omega\\, y^i y^j / A$ with $y^i = x^i - D^i$.\n\n\\item[\\code{sf\\_min\\_x}, \\code{sf\\_min\\_y}, \\code{sf\\_min\\_z},\n\\code{sf\\_max\\_x}, \\code{sf\\_max\\_y}, \\code{sf\\_max\\_z}] The\nbounding box of the surface.\n\n\\end{description}\nNote that the integral expressions are only suggestions which should\nbe adapted to whatever is natural for the stored surface. The\nsuggested integral expressions also depend on the metric which is\nused; this should be a ``natural'' metric for the surface. E.g.\\ for\napparent horizons, this might be the induced two-metric $q_{ij}$ from\nthe projection of the ADM three-metric $\\gamma_{ij}$.\n\n\n\n\\subsection{Validity of Surface Data}\n\nThere is also an integer flag \\code{valid} available. Its\ndefinition is up to the surface-providing thorn. The following\ninterpretations are \\emph{suggested}:\n\\begin{description}\n\n\\item[zero:] No surface is provided at this time step.\n\n\\item[negative:] No surface could be found at this time step.\n\n\\item[positive:] The surface data are valid.\n\n\\end{description}\nNote that, if this flag is used, it is necessary to set this flag at\nevery iteration. This flag is not automatically reset to zero.\n\n\n\n\\section{Surface Array Shape}\n\nThe number of grid points in the radius array \\code{sf\\_radius} is\ndetermined by the parameters \\code{ntheta} and \\code{nphi}. These\narrays exist for each surface. (Internally, thorn SphericalSurface\nstores all surfaces with the same array shape \\code{maxntheta} and\n\\code{maxnphi}, so that the parameters \\code{ntheta} and\n\\code{nphi} must not be used for index calculations. Use the\nsurfaces \\code{lsh} instead.) The surface array shape includes\nghost or boundary zones at the array edges. These ghost zones have\nthe same size for all surfaces.\n\nNote that because the radius arrays are stored with larger size\n$\\code{maxntheta} \\times \\code{maxnphi}$, the actual radius data\n(of size\n$\\code{ntheta[surface\\_number]} \\times \\code{nphi[surface\\_number]}$\nelements) is in general {\\em not contiguous in memory.\\/}\nIf you want to interpolate a SphericalSurface surface radius,\nyou need to either copy the radius data to a contiguous 2-D array of size\n$\\code{ntheta[surface\\_number]} \\times \\code{nphi[surface\\_number]}$,\nor use an interpolator which supports such non-contiguous input arrays.\nThe AEIThorns/AEILocalInterp local interpolation thorn supports these\nvia the \\code{input\\_array\\_strides} parameter-table option.\nSee the AEILocalInterp thorn guide for details.\n\n\n\n\\section{Surface Symmetries}\n\nIt is often the case that one uses symmetries to reduce the size of\nthe simulation domain, such as octant or quadrant mode. Whenever a\nsymmetry plane intersects a surface, only part of the surface is\nactually stored. The user has to define the symmetries of each\nsurface in the parameter file via the parameters\n\\code{sf\\_symmetry\\_x}, \\code{sf\\_symmetry\\_y}, and\n\\code{sf\\_symmetry\\_z}. They indicate that a \nreflection symmetry exists in the corresponding direction. The\nsurface origin is required to lie in the corresponding symmetry\nplanes.\n\nThorn SphericalSurface takes these symmetries into account when it\ncalculates the grid spacing and the origin of the surface coordinates\n$\\theta$ and $\\phi$.\n\n\n\n\\section{Input and Output}\n\nAs the surfaces are stored as grid variables, the standard input and\noutput routines will work for them. The standard visualisation tools\nwill be able to visualise them. The surfaces will also automatically\nbe checkpointed and restored.\n\n\n\n\\subsection{Acknowledgements}\n\nThis thorn was suggested during meetings of the numerical relativity\ngroup at the AEI. Jonathan Thornburg provided many detailed and\nuseful suggestions. Ed Evans, Carsten Gundlach, Ian Hawke, and Denis\nPollney contributed comments and suggestions.\n\n% Do not delete next line\n% END CACTUS THORNGUIDE\n\n\\end{document}\n"
}
}