einsteintoolkit / CactusBase_Time.json
xinshuo's picture
Upload folder using huggingface_hub
10a2580 verified
Raw
History Blame Contribute Delete
12.1 kB
{
"thorn_name": "CactusBase/Time",
"url": "https://bitbucket.org/cactuscode/cactusbase.git",
"configuration": "",
"interface": "# Interface definition for thorn Time\n\nimplements: time\n\npublic:\n\nREAL speedvars type=SCALAR\n{\n courant_wave_speed\n courant_min_time\n} \"Speed to use for Courant condition\"\n\nprivate:\n\nREAL couranttemps type=SCALAR\n{\n courant_dt\n} \"Variable just for output\"\n",
"param": "# Parameter definitions for thorn Time\n\nshares: cactus\n \nUSES REAL cctk_final_time\nUSES KEYWORD terminate\n\nrestricted:\n\nKEYWORD timestep_method \"Method for calculating timestep\"\n{\n \"given\" :: \"Use given timestep\"\n \"courant_static\" :: \"Courant condition at BASEGRID (using dtfac)\"\n \"courant_speed\" :: \"Courant condition at POSTSTEP (using wavespeed and courant_fac)\"\n \"courant_time\" :: \"Courant condition at POSTSTEP (using min time and courant_fac)\"\n} \"courant_static\"\n\nBOOLEAN timestep_outonly \"Don't set a dynamic timestep, just output what it would be\"\n{\n} \"no\"\n\nprivate:\n\nREAL timestep \"Absolute value for timestep\"\n{\n *:* :: \"Could be anything\"\n} 0.0\n\nREAL dtfac \"The standard timestep condition dt = dtfac*max(delta_space)\"\n{\n 0:* :: \"For positive timestep\"\n *:0 :: \"For negative timestep\"\n} 0.5 \n\nREAL courant_fac \"The courant timestep condition dt = courant_fac*max(delta_space)/speed/sqrt(dim)\"\n{\n 0:* :: \"For positive timestep\"\n *:0 :: \"For negative timestep\"\n} 0.9\n\nINT timestep_outevery \"How often to output courant timestep\"\n{\n 1:* :: \"Zero means no output\"\n} 1\n\nBOOLEAN verbose \"Give selective information about timestep setting\"\n{\n} \"no\"\n",
"schedule": "# Schedule definitions for thorn Time\n\nSTORAGE: speedvars, couranttemps\n\nschedule Time_Initialise at CCTK_BASEGRID before Time_Simple\n{\n LANG: C\n OPTIONS: global\n WRITES: Time::speedvars\n WRITES: Time::courant_dt(everywhere)\n} \"Initialise Time variables\"\n\nif (CCTK_Equals (timestep_method, \"courant_static\"))\n{\n schedule Time_Simple at CCTK_BASEGRID as TemporalSpacings after SpatialSpacings\n {\n LANG: C\n OPTIONS: singlemap\n } \"Set timestep based on Courant condition (courant_static)\"\n}\nelse if (CCTK_Equals (timestep_method, \"courant_speed\"))\n{\n schedule Time_Courant at CCTK_BASEGRID as TemporalSpacings after SpatialSpacings\n {\n LANG: C\n OPTIONS: singlemap\n READS: Time::speedvars\n WRITES: Time::courant_dt(everywhere)\n } \"Set timestep based on Courant condition (courant_speed)\"\n\n schedule Time_Courant at CCTK_POSTSTEP as TemporalSpacings after SpatialSpacings\n {\n LANG: C\n OPTIONS: singlemap\n READS: Time::speedvars\n WRITES: Time::courant_dt(everywhere)\n } \"Reset timestep each iteration\"\n}\nelse if (CCTK_Equals (timestep_method, \"courant_time\"))\n{\n schedule Time_Simple at CCTK_BASEGRID as TemporalSpacings after SpatialSpacings\n {\n LANG: C\n OPTIONS: singlemap\n } \"Set timestep based on Courant condition (courant_time)\"\n\n schedule Time_Courant at CCTK_POSTSTEP as TemporalSpacings after SpatialSpacings\n {\n LANG: C\n OPTIONS: singlemap\n READS: Time::speedvars\n WRITES: Time::courant_dt(everywhere)\n } \"Reset timestep each iteration\"\n}\nelse if (CCTK_Equals (timestep_method, \"given\"))\n{\n schedule Time_Given at CCTK_BASEGRID as TemporalSpacings after SpatialSpacings\n {\n LANG: C\n OPTIONS: singlemap\n } \"Set fixed timestep\"\n}\n",
"src": {
"make.code.defn": "# Main make.code.defn file for thorn Time\n\n# Source files in this directory\nSRCS = Courant.c Given.c Initialise.c Simple.c\n\n# Subdirectories containing source files\nSUBDIRS = \n\n",
"Given.c": "/*@@\n @file Given.c\n @date September 4 1999\n @author Gabrielle Allen\n @desc\n Standard specification of timestep\n @enddesc\n@@*/\n\n#include <stdlib.h>\n\n#include <cctk.h>\n#include <cctk_Arguments.h>\n#include <cctk_Parameters.h>\n\nvoid Time_Given(CCTK_ARGUMENTS) {\n DECLARE_CCTK_PARAMETERS;\n DECLARE_CCTK_ARGUMENTS_Time_Given;\n\n cctkGH->cctk_delta_time = timestep;\n}\n",
"Courant.c": "/*@@\n @file Courant.c\n @date September 4 1999\n @author Gabrielle Allen\n @desc\n Specification of timestep using Courant condition\n @enddesc\n@@*/\n\n#include <math.h>\n#include <stdlib.h>\n\n#include <cctk.h>\n#include <cctk_Arguments.h>\n#include <cctk_Parameters.h>\n\nvoid Time_Courant(CCTK_ARGUMENTS) {\n DECLARE_CCTK_PARAMETERS;\n DECLARE_CCTK_ARGUMENTS_Time_Courant;\n\n /* Calculate the minimum grid spacing */\n CCTK_REAL min_spacing = cctk_delta_space[0];\n\n if (cctk_dim >= 2) {\n min_spacing =\n (min_spacing < cctk_delta_space[1] ? min_spacing : cctk_delta_space[1]);\n }\n\n if (cctk_dim >= 3) {\n min_spacing =\n (min_spacing < cctk_delta_space[2] ? min_spacing : cctk_delta_space[2]);\n }\n\n if (cctk_dim >= 4) {\n CCTK_WARN(0, \"Time Step not defined for greater than 4 dimensions\");\n }\n\n /* Calculate the courant timestep */\n if (CCTK_Equals(timestep_method, \"courant_time\")) {\n *courant_dt = courant_fac *(*courant_min_time) / sqrt((double)cctk_dim);\n } else if (CCTK_Equals(timestep_method, \"courant_speed\")) {\n *courant_dt = courant_fac *min_spacing / (*courant_wave_speed) /\n sqrt((double)cctk_dim);\n }\n\n if (CCTK_Equals(terminate, \"time\") || CCTK_Equals(terminate, \"both\")) {\n if (cctkGH->cctk_time + *courant_dt > cctk_final_time) {\n *courant_dt = (1 + 1.e-10) * (cctk_final_time - cctkGH->cctk_time);\n }\n }\n\n /* Set the Cactus timestep */\n\n if (!timestep_outonly) {\n cctkGH->cctk_delta_time = *courant_dt;\n if (verbose) {\n CCTK_VInfo(CCTK_THORNSTRING, \"Time step set to %g\", CCTK_DELTA_TIME);\n }\n } else {\n cctkGH->cctk_delta_time = dtfac * min_spacing;\n if (cctkGH->cctk_iteration % timestep_outevery == 0) {\n CCTK_VInfo(CCTK_THORNSTRING, \"Courant timestep would be %g\", *courant_dt);\n }\n }\n}\n",
"Initialise.c": "/*@@\n @file Initialise.c\n @date May 12 2001\n @author Gabrielle Allen\n @desc\n Initialise grid variables\n @enddesc\n@@*/\n\n#include <cctk.h>\n#include <cctk_Arguments.h>\n\nvoid Time_Initialise(CCTK_ARGUMENTS) {\n DECLARE_CCTK_ARGUMENTS_Time_Initialise;\n\n *courant_wave_speed = 0;\n *courant_min_time = 0;\n *courant_dt = 0;\n}\n",
"Simple.c": "/*@@\n @file Simple.c\n @date September 4 1999\n @author Gabrielle Allen\n @desc\n Standard specification of timestep\n @enddesc\n@@*/\n\n#include <stdlib.h>\n\n#include <cctk.h>\n#include <cctk_Arguments.h>\n#include <cctk_Parameters.h>\n\nvoid Time_Simple(CCTK_ARGUMENTS) {\n DECLARE_CCTK_ARGUMENTS_Time_Simple;\n DECLARE_CCTK_PARAMETERS;\n\n /* Calculate the minimum grid spacing */\n CCTK_REAL min_spacing = cctk_delta_space[0];\n for (int d = 1; d < cctk_dim; ++d) {\n min_spacing =\n (min_spacing < cctk_delta_space[d] ? min_spacing : cctk_delta_space[d]);\n }\n\n /* Calculate the timestep */\n cctkGH->cctk_delta_time = dtfac * min_spacing;\n\n if (verbose) {\n CCTK_VInfo(CCTK_THORNSTRING,\n \"Using a simple Courant condition to set then timestep\");\n CCTK_VInfo(CCTK_THORNSTRING, \" ... using a dtfac of %g\", (double)dtfac);\n CCTK_VInfo(CCTK_THORNSTRING, \" ... using a minimum spacing of %g\",\n (double)min_spacing);\n }\n\n CCTK_VInfo(CCTK_THORNSTRING, \"Timestep set to %g (courant_static)\",\n (double)(cctkGH->cctk_delta_time / cctkGH->cctk_timefac));\n}\n"
},
"test": {},
"doc": {
"documentation.tex": "\\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\\title{Time}\n\\author{Gabrielle Allen}\n\\date{$ $Date$ $}\n\n\\maketitle\n\n% Do not delete next line\n% START CACTUS THORNGUIDE\n\n\\begin{abstract}\nCalculates the timestep used for an evolution\n\\end{abstract}\n\n\\section{Purpose}\n\nThis thorn provides routines for calculating\nthe timestep for an evolution based on the spatial Cartesian grid spacing and\na wave speed. \n\n\\section{Description}\n\nThorn {\\tt Time} uses one of four methods to decide on the timestep\nto be used for the simulation. The method is chosen using the\nkeyword parameter {\\tt time::timestep\\_method}. \n\n\\begin{itemize}\n\n\\item{} {\\tt time::timestep\\_method = \"given\"} \n\n\tThe timestep is fixed to the\n\tvalue of the parameter {\\tt time::timestep}. \n\n\\item{} {\\tt time::timestep\\_method = \"courant\\_static\"} \n\n\tThis is the default\n\tmethod, which calculates the timestep once at the start of the\n\tsimulation, based on a simple courant type condition using \n\tthe spatial gridsizes and the parameter {\\tt time::dtfac}.\n$$\n\\Delta t = \\mbox{\\tt dtfac} * \\mbox{min}(\\Delta x^i)\n$$\n\tNote that it is up to the user to custom {\\tt dtfac} to take\n\tinto account the dimension of the space being used, and the wave speed.\n\n\\item{} {\\tt time::timestep\\_method = \"courant\\_speed\"} \n\n\tThis choice implements a \n\tdynamic courant type condition, the timestep being set before each\n\titeration using the spatial dimension of the grid, the spatial grid sizes, the \n\tparameter {\\tt courant\\_fac} and the grid variable {\\tt courant\\_wave\\_speed}. \n\tThe algorithm used is\n$$\n\\Delta t = \\mbox{\\tt courant\\_fac} * \\mbox{min}(\\Delta x^i)/\\mbox{\\tt courant\\_wave\\_speed}/\\sqrt{\\mbox dim}\n$$\n\tFor this algorithm to be successful, the variable {\\tt courant\\_wave\\_speed}\n\tmust have been set by some thorn to the maximum propagation speed on the grid {\\it before}\n\tthis thorn sets the timestep, that is {\\tt AT POSTSTEP BEFORE Time\\_Courant} (or earlier \n\tin the evolution loop). [Note: The name {\\tt courant\\_wave\\_speed} was poorly \n\tchosen here, the required speed is the maximum propagation speed on \n the grid which may be larger than the maximum wave speed (for example\n with a shock wave in hydrodynamics, also it is possible to have\n propagation without waves as with a pure advection equation).\n\n\\item{} {\\tt time::timestep\\_method = \"courant\\_time\"} \n\n\tThis choice is similar to the\n\tmethod {\\tt courant\\_speed} above, in implementing a dynamic timestep.\n\tHowever the timestep is chosen using\n$$\n\\Delta t = \\mbox{\\tt courant\\_fac} * \\mbox{\\tt courant\\_min\\_time}/\\sqrt{\\mbox dim}\n$$\n where the grid variable {\\tt courant\\_min\\_time} must be set by some thorn to\n\tthe minimum time for a wave to cross a gridzone {\\it before}\n\tthis thorn sets the timestep, that is {\\tt AT POSTSTEP BEFORE Time\\_Courant} (or earlier \n\tin the evolution loop). \n\n\\end{itemize}\n\nIn all cases, Thorn {\\tt Time} sets the Cactus variable {\\tt cctk\\_delta\\_time}\nwhich is passed as part of the macro {\\tt CCTK\\_ARGUMENTS} to thorns called \nby the scheduler.\n\nNote that for hyperbolic problems, the Courant condition gives a minimum \nrequirement for stability, namely that the numerical domain of dependency\nmust encompass the physical domain of dependency, or\n$$\n\\Delta t \\le \\mbox{min}(\\Delta x^i)/\\mbox{wave speed}/\\sqrt{\\mbox dim}\n$$\n\n\\section{Examples}\n\n\\noindent\n{\\bf Fixed Value Timestep}\n\n{\\tt\n\\begin{verbatim}\ntime::timestep_method = \"given\"\ntime::timestep = 0.1\n\\end{verbatim}\n}\n\n\n\\noindent\n{\\bf Calculate Static Timestep Based on Grid Spacings}\n\n\\noindent\nThe following parameters set the timestep to be 0.25\n\n{\\tt\n\\begin{verbatim}\ngrid::dx = 0.5\ngrid::dy = 1.0\ngrid::dz = 1.0\ntime::timestep_method = \"courant_static\"\ntime::dtfac = 0.5\n\\end{verbatim}\n}\n\n% Do not delete next line\n% END CACTUS THORNGUIDE\n\n\\end{document}\n"
}
}