| { |
| "thorn_name": "CactusElliptic/EllBase", |
| "url": "https://bitbucket.org/cactuscode/cactuselliptic.git", |
| "configuration": "PROVIDES EllBase\n{\n SCRIPT\n LANG\n}\n\n", |
| "interface": "# Interface definition for thorn EllBase\n# $Header$\nimplements: ellbase\n\nINCLUDES HEADER: EllBase.h in EllBase.h\nINCLUDES HEADER: Ell_DBstructure.h in Ell_DBstructure.h\n", |
| "param": "# Parameter definitions for thorn EllBase\n# $Header$\n\nrestricted:\n\nKEYWORD elliptic_verbose \"elliptic verbosity\"\n{\n \"yes\" :: \"be verbose in elliptic\"\n \"no\" :: \"silence in elliptic\"\n \"debug\":: \"even more verbose in elliptic\"\n} \"no\"\n", |
| "schedule": "# Schedule definitions for thorn EllBase\n# $Header$\n\nschedule Ell_RegisterBaseEqTypes at STARTUP\n{\n LANG:C\n} \"Register the standard elliptic classes\"\n", |
| "src": { |
| "make.code.defn": "# Main make.code.defn file for thorn EllBase\n# $Header$\n\n# Source files in this directory\nSRCS = Ell_Interface.c Ell_Register.c Startup.c Ell_DBstructure.c\n\n# Subdirectories containing source files\nSUBDIRS = \n\n", |
| "Ell_Register.c": " /*@@\n @header Ell_Register.h\n @date \n @author Gerd Lanferman\n @desc \n Registration routines for elliptic classes and solvers \n @enddesc \n @version $Header$\n @@*/\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n\n#include \"cctk.h\"\n#include \"cctk_Parameters.h\"\n\n#include \"EllBase.h\"\n\n#include \"StoreNamedData.h\"\n\nstatic const char *rcsid = \"$Header$\";\n\nCCTK_FILEVERSION(CactusElliptic_EllBase_Ell_Register_c)\n\nstatic pNamedData *EqNameDB;\n\nint Ell_RegisterSolver(void (*function), \n const char *sname, \n const char *eqname); \n\nint Ell_RegisterEq(void *(function)(const char *, void*), const char *eqname);\n\n\n/* Ell_RegisterEq takes a routine (\"function\") and registers that routine \n under the name \"eqname\" in the EqNameDB\"\n Application: Call Ell_Register with the routine that registers a solver \n for a elliptic equation class. */\n\n\nint Ell_RegisterEq(void *(function)(const char *, void*), const char *eqname) \n{\n\n DECLARE_CCTK_PARAMETERS\n\n int retval = ELL_FAILURE;\n\n /* Register if function not already there with this name */\n\n if (!GetNamedData(EqNameDB, eqname))\n {\n if (StoreNamedData(&EqNameDB, eqname, (void*)function)==0)\n {\n if CCTK_EQUALS(elliptic_verbose,\"yes\") \n {\n CCTK_VInfo(CCTK_THORNSTRING,\"Registered elliptic class: %s\",eqname);\n }\n retval = ELL_SUCCESS;\n }\n else\n {\n CCTK_VInfo(CCTK_THORNSTRING,\"Failed to register elliptic class: %s\",\n eqname);\n }\n }\n else\n {\n CCTK_VWarn(0,__LINE__,__FILE__,CCTK_THORNSTRING,\n \"Elliptic class %s already registered\",eqname);\n retval = ELL_CLASSEXISTS;\n }\n\n return retval;\n\n \n\n}\n\n/* Ell_RegisterSolver takes a routine (\"function\") and registers that \n routine under the name \"sname\" with the database specified by \"eqname\".\n So, how do we get to the database, after all it needs to be hardcoded\n as pNamedData ? Well, we know its name and in Ell_RegisterEq we have \n registered a function under the equation class name. \n We now get that function and use that function to register the solver.\n Sounds confusing, well it is. The advantage is, that somebody can come \n up with a new equation class and can keep the database (the pNamedData\n declaration) in his own routine and does not have to put it in a central\n place. Amen*/\n\nint Ell_RegisterSolver(void (*function), \n const char *sname, \n const char *eqname) \n{\n\n DECLARE_CCTK_PARAMETERS\n\n int retval=ELL_FAILURE;\n int ierr;\n int (*fn)(void *, const char *);\n\n fn = (int(*)(void (*func), const char *solvename))\n GetNamedData(EqNameDB, eqname);\n\n if (fn)\n {\n\n ierr = fn(function,sname);\n\n if (ierr==ELL_SUCCESS)\n {\n\n if CCTK_EQUALS(elliptic_verbose,\"yes\") \n {\n CCTK_VInfo(CCTK_THORNSTRING,\n \"Registered elliptic solver %s for %s\",sname,eqname);\n }\n \n retval = ELL_SUCCESS;\n }\n else if (ierr==ELL_SOLVEREXISTS)\n {\n CCTK_VWarn(0,__LINE__,__FILE__,CCTK_THORNSTRING,\n \"Ell_RegisterSolver: \"\n \"Registered second solver %s for %s\",sname,eqname);\n retval = ELL_SOLVEREXISTS;\n }\n else \n {\n CCTK_VWarn(1,__LINE__,__FILE__,CCTK_THORNSTRING,\n \"Ell_RegisterSolver: \"\n \"Failed to register solver %s for %s\",sname,eqname);\n }\n\n }\n else\n {\n CCTK_WARN(0,\"Ell_RegisterSolver: Cannot get function in EqName\");\n retval = ELL_NOCLASS;\n }\n \n return retval; \n}\n", |
| "Ell_DBstructure.c": "/*@@\n @file Ell_DBstructure.c\n @date \n @author Gerd Lanfermann\n @desc\n Database for elliptic parameters\n @enddesc\n @version $Id$\n @@*/\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n\n#include \"cctk.h\"\n#include \"cctk_Parameters.h\"\n#include \"cctk_WarnLevel.h\"\n#include \"cctk_FortranString.h\"\n\n#include \"StoreNamedData.h\"\n\n#include \"Ell_DBstructure.h\"\n\nstatic const char *rcsid = \"$Header$\";\n\nCCTK_FILEVERSION(CactusElliptic_EllBase_Ell_DBstructure_c)\n\n/********************************************************************\n ******************** External Routines ************************\n ********************************************************************/\nvoid CCTK_FCALL CCTK_FNAME(Ell_IsKey)\n (int *ierr, ONE_FORTSTRING_ARG);\nvoid CCTK_FCALL CCTK_FNAME(Ell_DeleteKey)\n (int *ierr, ONE_FORTSTRING_ARG);\nvoid CCTK_FCALL CCTK_FNAME(Ell_SetRealKey)\n (int *ierr, CCTK_REAL *value, ONE_FORTSTRING_ARG); \nvoid CCTK_FCALL CCTK_FNAME(Ell_SetIntKey)\n (int *ierr, CCTK_INT *value, ONE_FORTSTRING_ARG);\nvoid CCTK_FCALL CCTK_FNAME(Ell_SetStrKey)\n (int *ierr, TWO_FORTSTRINGS_ARGS);\nvoid CCTK_FCALL CCTK_FNAME(Ell_GetRealKey)\n (int *ierr, CCTK_REAL *value, ONE_FORTSTRING_ARG);\nvoid CCTK_FCALL CCTK_FNAME(Ell_GetIntKey)\n (int *ierr, CCTK_INT *value, ONE_FORTSTRING_ARG);\nvoid CCTK_FCALL CCTK_FNAME(Ell_GetStrKey)\n (int *nchar, char **cstring,ONE_FORTSTRING_ARG);\n\n/********************************************************************\n ******************** Internal Typedefs ************************\n ********************************************************************/\n\nstruct t_ellthingy\n{\n int type;\n int been_set;\n union \n {\n CCTK_REAL r;\n CCTK_INT i;\n char *s;\n } vals;\n};\n\n/********************************************************************\n ******************** Static Variables *************************\n ********************************************************************/\n\nstatic pNamedData *EllInfoDB;\n\n/********************************************************************\n ******************** Internal Routines ************************\n ********************************************************************/\n\nint Ell_CreateKey(int vartype, const char *keychain) \n{\n\n DECLARE_CCTK_PARAMETERS\n\n struct t_ellthingy* new;\n int retval;\n\n if ((struct t_ellthingy*)GetNamedData(EllInfoDB, keychain)) \n {\n retval = ELLCREATE_TWICE;\n } \n else \n {\n\n new = (struct t_ellthingy*)malloc(sizeof(struct t_ellthingy));\n \n new->type = vartype;\n new->been_set = 0;\n new->vals.r = 0.0;\n new->vals.i = 0;\n new->vals.s = NULL;\n \n if (StoreNamedData(&EllInfoDB, keychain, new)!=0) \n {\n if (!CCTK_Equals(elliptic_verbose,\"no\")) \n {\n char *msg;\n const char *name=CCTK_VarTypeName(vartype);\n msg = (char *)malloc( \n (200 + strlen(keychain) + strlen(name) )*sizeof(char) );\n sprintf(msg,\"Failed to create %s (%s)\",keychain,name);\n CCTK_INFO(msg);\n free(msg);\n }\n retval = ELLCREATE_FAILED;\n }\n else\n {\n if (!CCTK_Equals(elliptic_verbose,\"no\")) \n {\n char *msg;\n const char *name=CCTK_VarTypeName(vartype);\n msg = (char *)malloc( \n (200 + strlen(keychain) + strlen(name) )*sizeof(char) );\n sprintf(msg,\"Created %s (%s)\",keychain,name);\n CCTK_INFO(msg);\n free(msg);\n }\n retval = 0;\n }\n\n }\n \n return(retval);\n\n \n\n} \n\nint Ell_IsKey(const char *keychain) \n{\n int retval=ELL_ISNOKEY;\n if ((struct t_ellthingy*)GetNamedData(EllInfoDB, keychain)) \n {\n retval = 0;\n } \n else\n {\n retval = ELL_ISNOKEY;\n }\n return(retval);\n}\n\nvoid CCTK_FCALL CCTK_FNAME(Ell_IsKey)(int *ierr, ONE_FORTSTRING_ARG) \n{\n ONE_FORTSTRING_CREATE(key)\n *ierr = Ell_IsKey(key);\n free(key);\n}\n\nint Ell_UnsetKey(const char *keychain) \n{\n\n struct t_ellthingy* getme;\n int retval;\n\n getme = (struct t_ellthingy*)GetNamedData(EllInfoDB, keychain);\n \n if (!(getme)) \n {\n CCTK_VWarn(4,__LINE__,__FILE__,CCTK_THORNSTRING,\n \"Ell_GetRealKey: Cannot get structure with key %s\",keychain);\n retval = ELLGET_NOKEY;\n } \n else \n {\n getme->been_set = ELL_NO;\n retval = 0;\n }\n return(retval);\n}\n\nint Ell_DeleteKey(const char *keychain) \n{\n int retval;\n /* avoid compiler warnings */\n keychain = keychain;\n CCTK_INFO(\"Ell_DeleteKey: Routine not implemented yet!\");\n retval = 1;\n return(retval);\n}\n\nvoid CCTK_FCALL CCTK_FNAME(Ell_DeleteKey)(int *ierr, ONE_FORTSTRING_ARG)\n{\n ONE_FORTSTRING_CREATE(key);\n *ierr = Ell_DeleteKey(key);\n free(key);\n}\n \n\nint Ell_SetRealKey(CCTK_REAL value, const char *keychain) \n{\n int retval;\n struct t_ellthingy *setme;\n\n setme = GetNamedData(EllInfoDB, keychain);\n if (!(setme)) \n { \n retval = ELLSET_FAILED;\n } \n else if (setme->type!=CCTK_VARIABLE_REAL) \n {\n retval = ELLSET_BADTYPE;\n CCTK_VWarn(4,__LINE__,__FILE__,CCTK_THORNSTRING,\n \"Ell_SetRealKey: Key %s not of type CCTK_REAL (type %d)\",\n keychain,setme->type);\n }\n else \n {\n setme->type = CCTK_VARIABLE_REAL;\n setme->vals.r = value;\n setme->been_set = ELL_YES;\n retval=0;\n }\n\n return(retval);\n}\n\nvoid CCTK_FCALL CCTK_FNAME(Ell_SetRealKey)\n (int *ierr, CCTK_REAL *value, ONE_FORTSTRING_ARG) \n{\n ONE_FORTSTRING_CREATE(key)\n *ierr = Ell_SetRealKey(*value, key);\n free(key);\n} \n\nint Ell_SetIntKey(CCTK_INT value, const char *keychain) \n{\n int retval;\n struct t_ellthingy *setme;\n\n setme = GetNamedData(EllInfoDB, keychain);\n if (!(setme)) \n { \n retval = ELLSET_FAILED;\n }\n else if (setme->type!=CCTK_VARIABLE_INT) \n {\n retval = ELLSET_BADTYPE;\n printf(\"Ell_SetIntKey: The key you try to set is not of type CCTK_INT: >%s< (type %d)\\n\",\n keychain,setme->type);\n }\n else {\n setme->type = CCTK_VARIABLE_INT;\n setme->vals.i = value;\n setme->been_set = ELL_YES;\n retval=0;\n }\n return(retval);\n}\n\nvoid CCTK_FCALL CCTK_FNAME(Ell_SetIntKey)\n (int *ierr, CCTK_INT *value, ONE_FORTSTRING_ARG) \n{\n ONE_FORTSTRING_CREATE(key)\n *ierr = Ell_SetIntKey(*value, key);\n free(key);\n} \n\nint Ell_SetStrKey(char *value, const char *keychain) \n{\n int retval;\n struct t_ellthingy *setme;\n\n setme = GetNamedData(EllInfoDB, keychain);\n if (!(setme)) \n { \n retval = ELLSET_FAILED;\n } \n else if (setme->type!=CCTK_VARIABLE_STRING) \n {\n retval = ELLSET_BADTYPE;\n CCTK_VWarn(4,__LINE__,__FILE__,CCTK_THORNSTRING,\n \"Ell_SetStrKey: Key %s not of type STRING (type %d)\",\n keychain,setme->type);\n }\n else \n {\n setme->type = CCTK_VARIABLE_STRING;\n setme->vals.s = strdup(value);\n setme->been_set = ELL_YES;\n retval = 0;\n }\n\n return(retval);\n\n}\n\nvoid CCTK_FCALL CCTK_FNAME(Ell_SetStrKey)\n (int *ierr, TWO_FORTSTRINGS_ARGS) \n{\n TWO_FORTSTRINGS_CREATE(value,key)\n *ierr = Ell_SetStrKey(value, key);\n free(value);\n free(key);\n} \n\n\nint Ell_GetRealKey(CCTK_REAL *value, const char *keychain) \n{\n\n struct t_ellthingy *getme=NULL;\n int retval;\n\n getme = (struct t_ellthingy*)GetNamedData(EllInfoDB, keychain);\n\n if (!(getme)) \n {\n CCTK_VWarn(4,__LINE__,__FILE__,CCTK_THORNSTRING,\n \"Ell_GetRealKey: Cannot get structure for key %s\",keychain);\n retval = ELLGET_NOKEY;\n }\n else if (getme->type!=CCTK_VARIABLE_REAL) \n {\n CCTK_VWarn(4,__LINE__,__FILE__,CCTK_THORNSTRING,\n \"Ell_GetRealKey: Not getting a CCTK_REAL value off key %s \"\n \"type %d (need %d)\\n\",\n keychain,getme->type,CCTK_VARIABLE_REAL);\n retval = ELLGET_BADTYPE;\n }\n else if (getme->been_set==ELL_NO) \n {\n CCTK_VWarn(4,__LINE__,__FILE__,CCTK_THORNSTRING,\n \"Ell_GetRealKey: Key %s has not been set to any value\",\n keychain);\n retval = ELLGET_NOTSET;\n }\n else \n {\n *value=getme->vals.r;\n retval=0;\n }\n return(retval);\n}\n\nvoid CCTK_FCALL CCTK_FNAME(Ell_GetRealKey)\n (int *ierr, CCTK_REAL *value, ONE_FORTSTRING_ARG) \n{\n ONE_FORTSTRING_CREATE(key)\n *ierr = Ell_GetRealKey(value, key); \n free(key);\n}\n\nint Ell_GetIntKey(CCTK_INT *value,const char *keychain) \n{\n\n struct t_ellthingy *getme=NULL;\n int retval;\n\n getme = (struct t_ellthingy*)GetNamedData(EllInfoDB, keychain);\n\n if (!(getme)) \n {\n printf(\"Ell_GetIntKey: Cannot get structure with key >%s< \\n\",keychain);\n printf(\"Ell_GetIntKey: Create first!\\n\");\n retval = ELLGET_NOKEY;\n }\n else if (getme->type!=CCTK_VARIABLE_INT) \n {\n CCTK_VWarn(4,__LINE__,__FILE__,CCTK_THORNSTRING,\n \"Ell_GetIntKey: Not getting a CCTK_INT value from key %s \"\n \"(type %d)\",\n keychain,getme->type);\n retval = ELLGET_BADTYPE;\n } \n else if (getme->been_set==ELL_NO) \n {\n CCTK_VWarn(4,__LINE__,__FILE__,CCTK_THORNSTRING,\n \"Ell_GetIntKey: Key %s has not been set to any value (type %d)\",\n keychain,getme->type);\n retval = ELLGET_NOTSET;\n } \n else \n {\n *value=getme->vals.i;\n retval=0;\n } \n\n return(retval);\n}\n\nvoid CCTK_FCALL CCTK_FNAME(Ell_GetIntKey)\n (int *ierr, CCTK_INT *value, ONE_FORTSTRING_ARG) \n{\n ONE_FORTSTRING_CREATE(key)\n *ierr = Ell_GetIntKey(value, key);\n free(key);\n}\n\nint Ell_GetStrKey(char **value, const char *keychain) \n{\n\n struct t_ellthingy *getme=NULL;\n int retval;\n\n *value = NULL;\n\n getme = (struct t_ellthingy*)GetNamedData(EllInfoDB, keychain);\n\n if (!(getme)) \n {\n CCTK_VWarn(4,__LINE__,__FILE__,CCTK_THORNSTRING,\n \"Ell_GetStrKey: Cannot get structure with key %s\",keychain);\n retval = ELLGET_NOKEY;\n }\n else if (getme->type!=CCTK_VARIABLE_STRING) \n {\n CCTK_VWarn(4,__LINE__,__FILE__,CCTK_THORNSTRING,\n \"Ell_GetStrKey: Not getting a CCTK_STRING from this key %s \"\n \"type: %d\", keychain,getme->type);\n retval = ELLGET_BADTYPE;\n }\n else if (getme->been_set==ELL_NO) \n {\n CCTK_VWarn(4,__LINE__,__FILE__,CCTK_THORNSTRING,\n \"Ell_GetStrKey: Key %s has not been set\", keychain);\n retval = ELLGET_NOTSET;\n } \n else \n {\n *value=strdup(getme->vals.s);\n retval=0;\n }\n return(retval);\n}\n\nvoid CCTK_FCALL CCTK_FNAME(Ell_GetStrKey)\n (int *nchar, char **cstring,ONE_FORTSTRING_ARG)\n{ \n int i;\n ONE_FORTSTRING_CREATE(fstring)\n ONE_FORTSTRING_PTR(fptr)\n\n if (strlen(*cstring) > cctk_strlen1) \n {\n char *message;\n message = (char *)malloc( (200+strlen(*cstring))*sizeof(char) );\n sprintf(message,\"Cannot output %s to char* of length %zu\\n\",\n *cstring,(size_t)cctk_strlen1);\n CCTK_Warn (1,__LINE__,__FILE__,\"Cactus\",message);\n free(message);\n *nchar = -1;\n }\n\n for (i=0;i<(int)strlen(*cstring);i++) \n {\n fptr[i] = (*cstring)[i];\n }\n\n for (i=(int)strlen(*cstring);i<(int)cctk_strlen1;i++)\n {\n fptr[i] = ' ';\n }\n\n fptr[strlen(*cstring)] = '\\0';\n\n *nchar = strlen(*cstring);\n\n free(fstring);\n}\n", |
| "Ell_Interface.c": " /*@@\n @header Ell_Interface.h\n @date \n @author Gerd Lanferman\n @desc \n Elliptic class routines for:\n\n * Registering the equation class wrapper (the function which is called for\n a specific class of problems by passing all the necessay arguments PLUS\n the name of the desired solver \n\n * Equation class wrapper, for each elliptic class \n Derives the function to call from the passed registration name of the \n solver \"sname\".\n\n @enddesc \n @version $Header$\n @@*/\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n\n#include \"cctk.h\"\n#include \"cctk_Parameters.h\"\n#include \"cctk_FortranString.h\" \n#include \"StoreNamedData.h\" \n\n#include \"EllBase.h\"\n\nstatic const char *rcsid = \"$Header$\";\n\nCCTK_FILEVERSION(CactusElliptic_EllBase_Ell_Interface_c)\n\nstatic pNamedData *LinConfMetricSolverDB;\nstatic pNamedData *LinMetricSolverDB;\nstatic pNamedData *LinFlatSolverDB;\nstatic pNamedData *BrBrConfMetricSolverDB;\nstatic pNamedData *PolyConfMetricSolverDB;\n\nint Ell_LinFlatRegistry(void (*function), const char *sname);\nint Ell_LinConfMetricRegistry(int (*function), const char *sname);\nint Ell_LinMetricRegistry(void (*function), const char *sname);\nint Ell_BrBrConfMetricRegistry(void (*function), const char *sname);\nint Ell_PolyConfMetricRegistry(void (*function), const char *sname);\n\nint Ell_LinConfMetricSolver(cGH *GH, \n int *MetricPsi, \n int FieldIndex, \n int MIndex, \n int NIndex, \n CCTK_REAL *AbsTol, \n CCTK_REAL *RelTol, \n const char *sname);\nint Ell_LinMetricSolver(cGH *GH, \n int *Metric, \n int FieldIndex, \n int MIndex, \n int NIndex, \n CCTK_REAL *AbsTol, \n CCTK_REAL *RelTol, \n const char *sname);\nint Ell_BrBrConfMetricSolver(cGH *GH, \n int *MetricPsi, \n int FieldIndex, \n int MIndex, \n int NIndex, \n CCTK_REAL *AbsTol, \n CCTK_REAL *RelTol, \n const char *sname);\nint Ell_PolyConfMetricSolver(cGH *GH, \n int *MetricPsi, \n int FieldIndex, \n int *PIndex, \n int Pcount, \n CCTK_REAL *AbsTol, \n CCTK_REAL *RelTol, \n const char *sname);\nint Ell_LinFlatSolver(cGH *GH, \n int FieldIndex, \n int MIndex, \n int NIndex, \n CCTK_REAL *AbsTol, \n CCTK_REAL *RelTol, \n const char *sname);\n\n\nvoid CCTK_FCALL CCTK_FNAME(Ell_LinConfMetricSolver)\n (int *ierr, \n cGH **GH, \n int *MetricPsi, \n int *FieldIndex, \n int *MIndex, \n int *NIndex, \n CCTK_REAL *AbsTol, \n CCTK_REAL *RelTol, \n ONE_FORTSTRING_ARG);\nvoid CCTK_FCALL CCTK_FNAME(Ell_LinMetricSolver)\n (int *ierr, \n cGH **GH, \n int *Metric, \n int *FieldIndex, \n int *MIndex, \n int *NIndex, \n CCTK_REAL *AbsTol, \n CCTK_REAL *RelTol, \n ONE_FORTSTRING_ARG);\nvoid CCTK_FCALL CCTK_FNAME(Ell_LinFlatSolver)\n (int *ierr, \n cGH **GH, \n int *FieldIndex, \n int *MIndex, \n int *NIndex, \n CCTK_REAL *AbsTol, \n CCTK_REAL *RelTol, \n ONE_FORTSTRING_ARG);\nvoid CCTK_FCALL CCTK_FNAME(Ell_BrBrConfMetricSolver)\n (int *ierr, \n cGH **GH, \n int *MetricPsi, \n int *FieldIndex, \n int *MIndex, \n int *NIndex, \n CCTK_REAL *AbsTol, \n CCTK_REAL *RelTol, \n ONE_FORTSTRING_ARG);\nvoid CCTK_FCALL CCTK_FNAME(Ell_PolyConfMetricSolver)\n (int *ierr, \n cGH **GH, \n int *MetricPsi, \n int *FieldIndex, \n int *PIndex, \n int *Pcount, \n CCTK_REAL *AbsTol, \n CCTK_REAL *RelTol, \n ONE_FORTSTRING_ARG);\n\n\n\n/*\n######################################################\n###### Elliptic Equation class: LinEllConfMetric #####\n######################################################\n*/\n\nint Ell_LinConfMetricRegistry(int (*function), const char *sname) \n{\n int retval;\n\n if(!GetNamedData(LinConfMetricSolverDB,sname))\n {\n StoreNamedData(&LinConfMetricSolverDB,sname,(int*)function);\n retval = ELL_SUCCESS;\n }\n else\n {\n retval = ELL_SOLVEREXISTS;\n }\n \n return retval;\n}\n\nint Ell_LinConfMetricSolver(cGH *GH, \n int *MetricPsi, \n int FieldIndex, \n int MIndex, \n int NIndex, \n CCTK_REAL *AbsTol, \n CCTK_REAL *RelTol, \n const char *sname) \n{\n\n int retval=ELL_SUCCESS;\n int (*fn)(cGH *,int *,int,int,int,CCTK_REAL *,CCTK_REAL *);\n \n fn = (int(*)(cGH*,int*,int,int,int,CCTK_REAL*,CCTK_REAL*))\n (GetNamedData(LinConfMetricSolverDB,sname));\n\n if (fn)\n {\n retval = fn(GH, MetricPsi, FieldIndex, MIndex, NIndex, AbsTol, RelTol);\n } \n else \n { \n CCTK_WARN(2,\"Cannot find solver for LinEllConfMetric\");\n retval = ELL_NOSOLVER;\n }\n\n return retval;\n\n}\n\nvoid CCTK_FCALL CCTK_FNAME(Ell_LinConfMetricSolver)\n (int *ierr, \n cGH **GH, \n int *MetricPsi, \n int *FieldIndex, \n int *MIndex, \n int *NIndex, \n CCTK_REAL *AbsTol, \n CCTK_REAL *RelTol, \n ONE_FORTSTRING_ARG) \n{\n\n ONE_FORTSTRING_CREATE(sname); \n\n *ierr = Ell_LinConfMetricSolver(*GH, \n MetricPsi, \n *FieldIndex, \n *MIndex, \n *NIndex, \n AbsTol, \n RelTol, \n sname);\n free(sname);\n\n}\n\n\n\n/*\n##################################################\n###### Elliptic Equation class: LinEllMetric #####\n##################################################\n*/\n\nint Ell_LinMetricRegistry(void (*function), const char *sname) \n{\n int retval;\n\n if(!GetNamedData(LinMetricSolverDB,sname))\n {\n StoreNamedData(&LinMetricSolverDB,sname,(void*)function);\n retval = ELL_SUCCESS;\n }\n else\n {\n retval = ELL_SOLVEREXISTS;\n }\n \n return retval;\n}\n\nint Ell_LinMetricSolver(cGH *GH, \n int *Metric, \n int FieldIndex, \n int MIndex, \n int NIndex, \n CCTK_REAL *AbsTol, \n CCTK_REAL *RelTol, \n const char *sname) \n{\n\n int retval=ELL_SUCCESS;\n int (*fn)(cGH *,int *,int,int,int,CCTK_REAL *,CCTK_REAL *);\n \n fn = (int(*)(cGH*,int*,int,int,int,CCTK_REAL*,CCTK_REAL*))\n (GetNamedData(LinMetricSolverDB,sname));\n\n if (fn)\n {\n retval = fn(GH, Metric, FieldIndex, MIndex, NIndex, AbsTol, RelTol);\n } \n else \n { \n CCTK_WARN(2,\"Cannot find solver for LinEllMetric\");\n retval = ELL_NOSOLVER;\n }\n\n return(retval);\n}\n \nvoid CCTK_FCALL CCTK_FNAME(Ell_LinMetricSolver)\n (int *ierr, \n cGH **GH, \n int *Metric, \n int *FieldIndex, \n int *MIndex, \n int *NIndex, \n CCTK_REAL *AbsTol, \n CCTK_REAL *RelTol, \n ONE_FORTSTRING_ARG) \n{\n\n ONE_FORTSTRING_CREATE(sname); \n\n *ierr = Ell_LinMetricSolver(*GH, \n Metric, \n *FieldIndex, \n *MIndex, \n *NIndex, \n AbsTol, \n RelTol, \n sname);\n free(sname);\n}\n \n\n\n/*\n################################################\n###### Elliptic Equation class: LinEllFlat #####\n################################################\n*/\n\nint Ell_LinFlatRegistry(void (*function), const char *sname) \n{\n int retval;\n\n if(!GetNamedData(LinFlatSolverDB,sname))\n {\n StoreNamedData(&LinFlatSolverDB,sname,(void*)function);\n retval = ELL_SUCCESS;\n }\n else\n {\n retval = ELL_SOLVEREXISTS;\n }\n \n return retval;\n\n}\n\nint Ell_LinFlatSolver(cGH *GH, \n int FieldIndex, \n int MIndex, \n int NIndex, \n CCTK_REAL *AbsTol, \n CCTK_REAL *RelTol, \n const char *sname) \n{\n\n int retval=ELL_SUCCESS;\n int (*fn)(cGH *,int,int,int,CCTK_REAL *,CCTK_REAL *);\n \n fn = (int (*)(cGH *,int,int,int,CCTK_REAL *,CCTK_REAL *)) \n (GetNamedData(LinFlatSolverDB,sname));\n\n if (fn)\n {\n retval = fn(GH, FieldIndex, MIndex, NIndex, AbsTol, RelTol);\n } \n else \n { \n CCTK_WARN(2,\"Ell_LinFlatSolver: Cannot find solver for LinEllFlat\");\n retval = ELL_NOSOLVER;\n }\n \n return retval;\n}\n \nvoid CCTK_FCALL CCTK_FNAME(Ell_LinFlatSolver)\n (int *ierr, \n cGH **GH, \n int *FieldIndex, \n int *MIndex, \n int *NIndex, \n CCTK_REAL *AbsTol, \n CCTK_REAL *RelTol, \n ONE_FORTSTRING_ARG) \n{\n\n ONE_FORTSTRING_CREATE(sname); \n *ierr = Ell_LinFlatSolver(*GH, \n *FieldIndex, \n *MIndex, \n *NIndex, \n AbsTol, \n RelTol, \n sname);\n free(sname);\n\n}\n\n\n/*\n####################################################\n###### Elliptic Equation class: BrBrConfMetric #####\n####################################################\n(Brandt-Bruemann Data with conformal metric) \n*/\n\nint Ell_BrBrConfMetricRegistry(void (*function), const char *sname) \n{\n int retval;\n\n if(!GetNamedData(BrBrConfMetricSolverDB,sname))\n {\n StoreNamedData(&BrBrConfMetricSolverDB,sname, (void*)function);\n retval = ELL_SUCCESS;\n }\n else\n {\n retval = ELL_SOLVEREXISTS;\n }\n \n return retval;\n\n}\n\nint Ell_BrBrConfMetricSolver(cGH *GH, \n int *MetricPsi, \n int FieldIndex, \n int MIndex, \n int NIndex, \n CCTK_REAL *AbsTol, \n CCTK_REAL *RelTol, \n const char *sname) \n{\n\n int retval=ELL_SUCCESS;\n int (*fn)(cGH *,int *,int,int,int,CCTK_REAL *,CCTK_REAL *);\n \n fn = (int(*)(cGH*,int*,int,int,int,CCTK_REAL*,CCTK_REAL*))\n (GetNamedData(BrBrConfMetricSolverDB,sname));\n\n if (fn)\n {\n retval = fn(GH, MetricPsi, FieldIndex, MIndex, NIndex, AbsTol, RelTol);\n } \n else \n { \n CCTK_WARN(2,\"Ell_BrBrConfMetricSolver: Cannot find solver for BrBrConfMetric\");\n retval = ELL_NOSOLVER;\n }\n\n return retval;\n\n}\n\nvoid CCTK_FCALL CCTK_FNAME(Ell_BrBrConfMetricSolver)\n (int *ierr, \n cGH **GH, \n int *MetricPsi, \n int *FieldIndex, \n int *MIndex, \n int *NIndex, \n CCTK_REAL *AbsTol, \n CCTK_REAL *RelTol, \n ONE_FORTSTRING_ARG) \n{\n\n ONE_FORTSTRING_CREATE(sname); \n\n *ierr = Ell_BrBrConfMetricSolver(*GH, \n MetricPsi, \n *FieldIndex, \n *MIndex, \n *NIndex, \n AbsTol, \n RelTol, \n sname);\n\n free(sname);\n\n}\n\n\n/*\n####################################################\n###### Elliptic Equation class: PolyConfMetric #####\n####################################################\n*/\n\nint Ell_PolyConfMetricRegistry(void (*function), const char *sname) \n{\n int retval;\n\n if(!GetNamedData(PolyConfMetricSolverDB,sname))\n {\n StoreNamedData(&PolyConfMetricSolverDB,sname, (void*)function);\n retval = ELL_SUCCESS;\n }\n else\n {\n retval = ELL_SOLVEREXISTS;\n }\n \n return retval;\n}\n\nint Ell_PolyConfMetricSolver(cGH *GH, \n int *MetricPsi, \n int FieldIndex, \n int *PIndex, \n int Pcount, \n CCTK_REAL *AbsTol, \n CCTK_REAL *RelTol, \n const char *sname) \n{\n\n int retval=ELL_SUCCESS;\n int (*fn)(cGH *,int *,int,int *,int,CCTK_REAL *,CCTK_REAL *);\n \n fn = (int(*)(cGH*,int*,int,int*,int,CCTK_REAL*,CCTK_REAL*))\n (GetNamedData(PolyConfMetricSolverDB,sname));\n\n if (fn)\n {\n retval = fn(GH, MetricPsi, FieldIndex, PIndex, Pcount, AbsTol, RelTol);\n } \n else \n { \n CCTK_WARN(2,\"Cannot find solver for PolyConfMetric\");\n retval = ELL_NOSOLVER;\n }\n \n return retval;\n\n}\n\nvoid CCTK_FCALL CCTK_FNAME(Ell_PolyConfMetricSolver)\n (int *ierr, \n cGH **GH, \n int *MetricPsi, \n int *FieldIndex, \n int *PIndex, \n int *Pcount, \n CCTK_REAL *AbsTol, \n CCTK_REAL *RelTol, \n ONE_FORTSTRING_ARG) \n{\n\n ONE_FORTSTRING_CREATE(sname); \n *ierr = Ell_PolyConfMetricSolver(*GH, \n MetricPsi, \n *FieldIndex, \n PIndex, \n *Pcount, \n AbsTol, \n RelTol, \n sname);\n free(sname);\n\n}\n", |
| "Ell_DBstructure.h": "#ifndef _ELL_DBSTRUCTURE_H_\n#define _ELL_DBSTRUCTURE_H_\n\n\n\n#define ELL_NO 0\n#define ELL_YES 1\n#define ELL_ISNOKEY -1\n\n#define ELLCREATE_FAILED -1\n#define ELLCREATE_TWICE 1\n \n#define ELLGET_NOKEY -1\n#define ELLGET_BADTYPE -2\n#define ELLGET_NOTSET -3\n\n#define ELLSET_FAILED -1\n#define ELLSET_BADTYPE -2\n\n\n#ifdef CCODE\n\n#ifdef __cplusplus \nextern \"C\" {\n#endif\n\nint Ell_CreateKey(int vartype, const char *keychain);\nint Ell_IsKey(const char *keychain);\nint Ell_UnsetKey(const char *keychain);\nint Ell_DeleteKey(const char *keychain);\n\nint Ell_SetRealKey(CCTK_REAL value, const char *keychain);\nint Ell_SetIntKey(CCTK_INT value, const char *keychain);\nint Ell_SetStrKey(char *value, const char *keychain);\n\nint Ell_GetRealKey(CCTK_REAL *value, const char *keychain);\nint Ell_GetIntKey(CCTK_INT *value,const char *keychain);\nint Ell_GetStrKey(char **value, const char *keychain);\n\n\n#ifdef __cplusplus \n}\n#endif\n\n#endif /* CCODE */\n\n\n\n#endif /* _ELL_DBSTRUCTURE_H_ */\n", |
| "EllBase.h": " /*@@\n @header EllBase.h\n @date \n @author Gerd Lanferman\n @desc \n Basic Elliptic solver functions. \n @enddesc \n @version $Header$\n @@*/\n\n#ifndef _ELLBASE_H_\n#define _ELLBASE_H_\n\n#define ELL_SUCCESS 0\n#define ELL_NOSOLVER -1\n#define ELL_NOCONVERGENCE -2\n#define ELL_NOCLASS -3\n#define ELL_SOLVEREXISTS -4\n#define ELL_CLASSEXISTS -5\n#define ELL_FAILURE -6\n\n#ifdef CCODE\n\n/* Argumennt structure for the four different types of elliptic solvers\n provided at this point. Difference is MetricI, MetricPsiI and StencilGFI, \n which are arrays holding the grid function indices of the metric, \n metric+psi or the 27 stencil grid functions, respectively */\n\n#define LINELL_FLAT3D_ARGS \\\n cGH *GH, \\\n CCTK_REAL tolerance, \\\n int FieldIndex, \\\n int MIndex, \\\n int NIndex \\\n\n#ifdef __cplusplus\nextern \"C\"\n{\n#endif\n\nint Ell_RegisterSolver(void (*function), \n const char *sname, \n const char *eqname);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif\n\n#endif /* _ELLBASE_H_ */\n", |
| "Startup.c": " /*@@\n @file Startup.c\n @date Wed Apr 19 20:35:04 2000\n @author Gerd Lanfermann\n @desc \n Startup.c\n @enddesc \n @@*/\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n\n#include \"cctk.h\"\n\n#include \"Ell_DBstructure.h\"\n\nstatic const char *rcsid = \"$Header$\";\n\nCCTK_FILEVERSION(CactusElliptic_EllBase_Startup_c)\n\nint Ell_RegisterBaseEqTypes(void);\n\n\n /*@@\n @routine Ell_RegisterBaseEqTypes\n @date Wed Apr 19 20:36:08 2000\n @author Gerd Lanfermann\n @desc \n At Startup, EllBase registers the elliptic equation classes for which \n it provides solvers. Other routines, which may come up with new classes, \n can registers the classes in their own thorns.\n @enddesc \n @calls \n @calledby \n @history \n \n @endhistory \n\n@@*/\n\n\nint Ell_RegisterBaseEqTypes(void) \n{\n\n int Ell_RegisterEq(void (*function),const char *);\n void Ell_LinConfMetricRegistry(void (*function),const char *);\n void Ell_LinMetricRegistry(void (*function),const char *);\n void Ell_LinFlatRegistry(void (*function),const char *);\n void Ell_BrBrConfMetricRegistry(void (*function),const char *);\n void Ell_PolyConfMetricRegistry(void (*function),const char *);\n \n int err=0;\n \n err += Ell_RegisterEq(Ell_LinConfMetricRegistry, \"Ell_LinConfMetric\");\n err += Ell_RegisterEq(Ell_BrBrConfMetricRegistry,\"Ell_BrBrConfMetric\");\n err += Ell_RegisterEq(Ell_PolyConfMetricRegistry,\"Ell_PolyConfMetric\");\n err += Ell_RegisterEq(Ell_LinMetricRegistry, \"Ell_LinMetric\");\n err += Ell_RegisterEq(Ell_LinFlatRegistry, \"Ell_LinFlat\");\n\n err += Ell_CreateKey(CCTK_VARIABLE_STRING,\n \"EllLinFlat::Bnd\");\n err += Ell_CreateKey(CCTK_VARIABLE_STRING,\n \"EllLinConfMetric::Bnd\");\n err += Ell_CreateKey(CCTK_VARIABLE_STRING,\n \"EllLinMetric::Bnd\");\n\n err += Ell_CreateKey(CCTK_VARIABLE_STRING,\n \"EllLinFlat::Bnd::Robin\");\n err += Ell_CreateKey(CCTK_VARIABLE_STRING,\n \"EllLinConfMetric::Bnd::Robin\");\n err += Ell_CreateKey(CCTK_VARIABLE_STRING,\n \"EllLinMetric::Bnd::Robin\");\n \n /* Register the variables needed to use these boundaries */\n err += Ell_CreateKey(CCTK_VARIABLE_REAL, \n \"EllLinConfMetric::Bnd::Robin::inf\"); \n err += Ell_CreateKey(CCTK_VARIABLE_INT, \n \"EllLinConfMetric::Bnd::Robin::falloff\"); \n err += Ell_CreateKey(CCTK_VARIABLE_REAL, \n \"EllLinConfMetric::Bnd::Const::V0\");\n\n /* Register the variables needed to use these boundaries */\n err += Ell_CreateKey(CCTK_VARIABLE_REAL, \n \"EllLinMetric::Bnd::Robin::inf\"); \n err += Ell_CreateKey(CCTK_VARIABLE_INT, \n \"EllLinMetric::Bnd::Robin::falloff\"); \n err += Ell_CreateKey(CCTK_VARIABLE_REAL, \"EllLinMetric::Bnd::Const::V0\");\n\n /* Register the variables needed to use these boundaries */\n err += Ell_CreateKey(CCTK_VARIABLE_REAL, \n \"EllLinFlat::Bnd::Robin::inf\"); \n err += Ell_CreateKey(CCTK_VARIABLE_INT, \n \"EllLinFlat::Bnd::Robin::falloff\"); \n err += Ell_CreateKey(CCTK_VARIABLE_REAL, \n \"EllLinFlat::Bnd::Const::V0\");\n\n if (err<0) CCTK_WARN(1,\"Error registering the basic elliptic classes\");\n \n return 0;\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{EllBase}\n\\author{Gerd Lanfermann}\n\\date{$ $Date$ $}\n\n\\maketitle\n\n% Do not delete next line\n% START CACTUS THORNGUIDE\n\n\\begin{abstract}\nInfrastructure for standard elliptic solvers\n\\end{abstract}\n\n\n\\section{Introduction}\nFollowing a brief introduction to the elliptic solver interfaces\nprovided by {\\tt EllBase}, we explain how to add a \nnew class of elliptic equations and how to implement a particular solver \nfor any class.\nWe do not discuss the individual elliptic solvers here since these are\ndocumented in their own thorns.\n\n\\subsection{Purpose of Thorn}\n\nThorn EllBase provides the basic functionality for \n\\begin{itemize}\n\\item registering a class of elliptic equations\n\\item register a solver for any particular class\n\\end{itemize}\n\nThe solvers are called by the user through a unique interface, which calls the \nrequired elliptic solver for a class using the name under which the solver \nroutine is registered. \n\n{\\tt EllBase} itself defines the elliptic classes\n\\begin{enumerate}\n\\item{\\bf flat:} {\\tt Ell\\_LinFlat}\\\\\nsolves a linear elliptic equation in flat space: $\\nabla \\phi + M \\phi\n+N = 0 $\n\n\\item{\\bf metric:} {\\tt Ell\\_LinMetric}\\\\\nsolves a linear elliptic equation for a given metric: $\\nabla_{g} \\phi\n+ M \\phi + N = 0 $\n\\item{\\bf conformal metric:} {\\tt Ell\\_LinConfMetric}\\\\\n solves a linear elliptic equation for a\ngiven metric and a conformal factor: $\\nabla_{cg} \\phi + M \\phi\n+ N = 0 $\n\\item{\\bf generic:} solves a linear elliptic equation by passing the \n\tstencil functions. There is support for a maximum of 27 stencil \n\tfunctions ($3^3$). {\\em This is not implemented, yet.}\n\\end{enumerate}\n\n\\section{Technical Specification}\n\n\\begin{itemize}\n\n\\item{Implements:} {\\tt ellbase}\n\\item{Inherits from:} {\\tt grid}\n\\item{Tested with thorns:} \\\\\n{\\tt CactusElliptic/EllTest},\\\\\n {\\tt CactusWave/IDScalarWaveElliptic}\n\n\\end{itemize}\n\n\\section{ToDo}\n\\begin{itemize}\n\\item{}Add more standard equation classes.\n\\item{}The method for passing boundary conditions into the \nelliptic solvers has not fully consolidated. We have some good ideas\non what the interface should look like, but the implementation will\ntake some time. If you are worried about BCs, please contact me.\n\\end{itemize}\n\n\\section{Solving an elliptic equation}\nEllBase provides a calling interface for each of the elliptic classes \nimplemented.\nAs a user you must provide all information needed for a\nparticular elliptic class. In general this will include\n\\begin{itemize}\n\\item{} the gridfunction(s) to solve for\n\\item{} the coefficient matrix or source terms\n\\item{} information on termination tolerances\n\\item{} the name of the solver to be used\n\\end{itemize}\n\n{\\bf Motivation:} At a later stage you might want to compile with a different \nsolver for this elliptic class: just change the name of the solver in your\nelliptic interface call. If somebody improves a solver you have been using,\nthere is no need for you to change any code on your side: the interface \nwill hide all of that. Another advantage is that your code will compile \nand run, even though certain solvers are not compiled in. In this case, you \nwill have to do some return value checking to offer alternatives.\n\n\\subsection{{\\tt Ell\\_LinFlat}}\nTo call this interface from {\\bf Fortran}:\n\\begin{verbatim}\n\t call Ell_LinFlatSolver(ierr, cctkGH, phi_gfi, M_gfi, N_gfi,\n\t. AbsTol, RelTol, \"solvername\") \n\\end{verbatim}\nTo call this interface from {\\bf C}:\n\\begin{verbatim}\n\n\t ierr = Ell_LinFlatSolver(GH, phi_gfi, M_gfi, N_gfi,\n\t AbsTol, RelTol, \"solvername\"); \n\\end{verbatim}\n{\\bf Argument List:}\n\\begin{itemize}\n\\item{\\tt ierr}: return value: ``0'' for success.\n\\item{\\tt cctkGH}: the Fortran ``pointer'' to the grid function\nhierachy.\n\\item{\\tt GH}: the C pointer to the grid hierarchy, type: {\\tt pGH *GH}.\n\\item{\\tt phi\\_gif}: the integer {\\em index} of the grid function to solve\nfor.\n\\item{\\tt M\\_gfi}: the integer {\\em index} of the grid function which holds\n$M$.\n\\item{\\tt N\\_gif}: the integer {\\em index} of the grid function which holds $N$.\n\\item{\\tt AbsTol}: array of size $3$: holding {\\em absolute} tolerance values for the \n$L_1$, $L_2$, $L_\\infty$ norm. Check if the solver side supports\nthese norms. The interface side does not guarantee that these norms are \nactually implemenented by a solver. See the section on norms: \\ref{sec:ellnorms}.\n\\item{\\tt RelTol}: array of size $3$: holding {\\em relative}\ntolerance factors for the $L_1$, $L_2$, $L_\\infty$. Check if the \nsolver side supports these norms. The interface side does not\nguarantee that these norms are actually implemenented by a solver. \nSee the section on Norms: \\ref{sec:ellnorms}.\n\\item{\\tt \"solvername\"}: the name of a solver, which is registered\nfor a particular equation class. How does one find out the names? Either\ncheck the documentation of the elliptic solvers or check for\nregistration infomation outputted by a cactus at runtime.\n\\end{itemize}\n{\\bf Example use in Fortran}, as used in the WaveToy arrangement: {\\tt\nCactusWave/IDScalarWave}:\n\\begin{verbatim}\n\nc We derive the grid function indicies from the names of the \nc grid functions:\n call CCTK_VarIndex (Mcoeff_gfi, \"idscalarwaveelliptic::Mcoeff\")\n call CCTK_VarIndex (Ncoeff_gfi, \"idscalarwaveelliptic::Ncoeff\")\n call CCTK_VarIndex (phi_gfi, \"wavetoy::phi\")\n\nc Load the Absolute Tolerance Arrays\n AbsTol(1)=1.0d-5\n AbsTol(2)=1.0d-5\n AbsTol(3)=1.0d-5\n\nc Load the Relative Tolerance Arrays, they are not\nc used here: -1\n RelTol(1)=-1\n RelTol(2)=-1\n RelTol(3)=-1\n\nc Call to elliptic solver, named ``sor''\n call Ell_LinFlatSolver(ierr, cctkGH, \n . phi_gfi, Mcoeff_gfi, Ncoeff_gfi, AbsTol, RelTol,\n . \"sor\")\n\nc Do some error checking, a call to another solver \nc could be coded here\n if (ierr.ne.0) then\n call CCTK_WARN(0,\"Requested solver not found / solve failed\");\n endif\n\\end{verbatim}\n\n\n\\subsection{{\\tt Ell\\_LinMetric}}\nTo call this interface from {\\bf Fortran}:\n\\begin{verbatim}\n\t call Ell_LinMetricSolver(ierr, cctkGH, Metric_gfi, \n\t.\t \t phi_gfi, M_gfi, N_gfi,\n\t. AbsTol, RelTol, \"solvername\") \n\\end{verbatim}\nTo call this interface from {\\bf C}:\n\\begin{verbatim}\n\t ierr = Ell_LinMetricSolver(GH, Metric_gfi, \n\t\t \t phi_gfi, M_gfi, N_gfi,\n\t AbsTol, RelTol, \"solvername\");\n\\end{verbatim}\n{\\bf Argument List:}\n\\begin{itemize}\n\\item{\\tt ierr}: return value: ``0'' success\n\\item{\\tt cctkGH}: the Fortran ``pointer'' to the grid function\nhierachy.\n\\item{\\tt GH}: the C pointer to the grid hierarchy, type: {\\tt pGH\n*GH}\n\\item{\\tt Metric\\_gfi}: array of size $6$, containing the {\\em index} components of \nthe metric $g$: $g_{11}$, $g_{12}$, $g_{13}$, $g_{22}$, $g_{23}$,\n$g_{33}$. The {\\bf order} is important.\n\\item{\\tt phi\\_gif}: the integer {\\em index} of the grid function so solver\nfor.\n\\item{\\tt M\\_gfi}: the integer {\\em index} of the grid function which holds\n$M$.\n\\item{\\tt N\\_gif}: the integer {\\em index} of the grid function which holds $N$\n\\item{\\tt AbsTol}: array of size $3$: holding {\\em absolute} tolerance values for the \n$L_1$, $L_2$, $L_\\infty$ Norm. Check, if the solver side supports\nthese norms.The interface side does not guarantee that these norms are \nactually implemenented by a solver. See the section on Norms: \\ref{sec:ellnorms}.\n\\item{\\tt RelTol}: array of size $3$: holding {\\em relative}\ntolerance factors for the $L_1$, $L_2$, $L_\\infty$. Check, if the \nsolver side supports these norms. The interface side does not\nguarantee that these norms are actually implemenented by a solver. \nSee the section on Norms: \\ref{sec:ellnorms}.\n\\item{\\tt \"solvername\"}: the name of a solver, which is registered\nfor a particular equation class. How to find out the names ? Either\ncheck the documentation of the elliptic solvers or check for\nregistration infomation outputted by a cactus at runtime.\n\\end{itemize}\n\n\\subsection{{\\tt Ell\\_LinConfMetric}}\nTo call this interface from {\\bf Fortran}:\n\\begin{verbatim}\n\t call Ell_LinMetricSolver(ierr, cctkGH, MetricPsi_gfi, \n\t.\t \t phi_gfi, M_gfi, N_gfi,\n\t. AbsTol, RelTol, \"solvername\") \n\\end{verbatim}\nTo call this interface from {\\bf C}:\n\\begin{verbatim}\n\t ierr = Ell_LinMetricSolver(GH, MetricPsi_gfi, \n\t\t \t phi_gfi, M_gfi, N_gfi,\n\t AbsTol, RelTol, \"solvername\");\n\\end{verbatim}\n{\\bf Argument List:}\n\\begin{itemize}\n\\item{\\tt ierr}: return value: ``0'' success\n\\item{\\tt cctkGH}: the Fortran ``pointer'' to the grid function\nhierachy.\n\\item{\\tt GH}: the C pointer to the grid hierarchy, type: {\\tt pGH\n*GH}\n\\item{\\tt MetricPsi\\_gfi}: array of size $7$, containing the {\\em\ngrid function index} of the metric components and the {\\em grid\nfunction index} of the conformal factor $\\Psi$: $g_{11}$, \n$g_{12}$, $g_{13}$, $g_{22}$, $g_{23}$, $g_{33}$, $\\Psi$. The {\\bf order} is important.\n\\item{\\tt phi\\_gif}: the integer {\\em index} of the grid function so solver\nfor.\n\\item{\\tt M\\_gfi}: the integer {\\em index} of the grid function which holds\n$M$.\n\\item{\\tt N\\_gif}: the integer {\\em index} of the grid function which holds $N$\n\\item{\\tt AbsTol}: array of size $3$: holding {\\em absolute} tolerance values for the \n$L_1$, $L_2$, $L_\\infty$ Norm. Check, if the solver side supports\nthese norms.The interface side does not guarantee that these norms are \nactually implemenented by a solver. See the section on Norms: \\ref{sec:ellnorms}.\n\\item{\\tt RelTol}: array of size $3$: holding {\\em relative}\ntolerance factors for the $L_1$, $L_2$, $L_\\infty$. Check, if the \nsolver side supports these norms. The interface side does not\nguarantee that these norms are actually implemenented by a solver. \nSee the section on Norms: \\ref{sec:ellnorms}.\n\\item{\\tt \"solvername\"}: the name of a solver, which is registered\nfor a particular equation class. How to find out the names ? Either\ncheck the documentation of the elliptic solvers or check for\nregistration infomation outputted by a cactus at runtime.\n\n\\end{itemize}\n\n\n\n\\section{Extending the elliptic solver class}\n\nEllBase by itself does not provide any elliptic solving capabilities. \nIt merely provides the registration structure and calling interface.\n\nThe idea of a unified calling interface can be motivated as follows: \nassume you a have elliptic problem which conforms to one of the elliptic \nclasses defined in EllBase.\n\n\n\\subsection{Registration Mechanism}\n\nBefore a user can successfully apply a elliptic solver to one of his problems,\ntwo things need to be done by the author who programs the solver.\n\\begin{itemize}\n\\item{\\bf Register a class of elliptic equations} Depending on the elliptic \nproblem This provides the unique calling, the solving routines needs to have \nspecific input data. The interface, which is called by the user, has to \nreflect these arguments. EllBase already offers \nseveral of these interfaces, but if you need to have a new one, you can \nprovide your own.\n\n\\item{\\bf Register a solver for a particular elliptic equation class}\nOnce a class of elliptic equations has been made available as described \nabove, the author can now register solvers for that particular class. \nLater a user will access the solver calling the interface with the \narguments needed for the elliptic class and a name, under which a solver \nfor this elliptic problem has been registered.\n\\end{itemize}\n\nThe registration process is part of the authors thorn, not part of EllBase. \nThere is no need to change code in EllBase. Usually, a author of solver \nroutines will register the routines that register an elliptic equation class \nand/or an elliptic solver in the STARTUP timebin. If a author registers both, class and solver, you must make \nsure, that the elliptic class is registered {\\em before} the solver \nregistration takes place. \n\n\\subsection{EllBase Programming Guide}\n\nHere we give a step by step guide on how to implement an new elliptic \nsolver class, its interface and provide a solver for this class. Since \nsome of the functionality needed in the registration code can only be \nachieved in C, a basic knowledge of C is helpful.\n\n\\begin{itemize}\n\\item{\\bf Assumption}:\n\\begin{itemize} \n\\item{}The elliptic equation \nclass will be called ``{\\em SimpleEllClass}'': it will be flat space solver, \nthat only \ntakes the coefficient matrix $M$: \n%\\begin{equation}\n%\\nabla \\phi - M \\phi \\eq 0\n%\\end{equation}\nNote that this solver class is already provided by EllBase.\n\\item{}The name of the demonstration thorn will be \n``{\\tt ThornFastSOR}''. Since I will only demonstrate the registration principle \nand calling structure, I leave it to the interested reader to write a really \nfast SOR solver.\n\\item{}The solver for this elliptic equation will be called ``{\\tt FastSOR\\_solver}''\nand will be written in Fortran. Since Fortran cannot be called\ndirectly by the registration mechanism, we\nneed to have C wrapper function ``{\\tt FastSOR\\_wrapper}''. \n\\end{itemize}\n\n\\item{\\bf Elliptic class declaration}: {\\tt SimpleEllThorn/src/SimpleEll\\_Class.c} \n\\begin{verbatim}\n\\end{verbatim}\n\n\\item{\\bf Elliptic solver interface}: {\\tt src/SimpleEll\\_Interface.c}\n\\begin{verbatim}\n\n#include ``cctk.h''\n#include ``cctk_Parameters.h''\n\n#include ``cctk_FortranString.h'' \n#include ``StoreNamedData.h''\n\nstatic pNamedData *SimpleEllSolverDB;\n\nvoid Ell_SimpleEllSolverRegistry(void (*solver_func), const char *solver_name)\n{\n StoreNamedData(&SimpleEllSolverDB,solver_name,(void*)solver_func);\n}\n\\end{verbatim}\nThe routine above registers the solver (or better the function pointer of the solver routine ``*solve\\_func'') for the equation class \n{\\em SimpleEllClass} by the name {\\tt solver\\_name} in the database {\\tt\nSimpleEllSolverDB}. This database is declared in statement {\\tt static pNamedData...}.\n\n\nNext, we write our interface in the same file {\\tt ./SimpleEll\\_Interface.c}:\n\\begin{verbatim}\nvoid Ell_SimpleEllSolver(cGH *GH, int *FieldIndex, int *MIndex, \n\t\t CCTK_REAL *AbsTol, CCTK_REAL *RelTol,\n const char *solver_name) {\n\n/* prototype for the equation class wrapper:\n grid hierarchy(*GH), ID-number of field to solve for (*FieldIndex),\n two arrays of size three holding convergence information (*AbsTol, *RelTol)\n*/\n void (*fn)(cGH *GH, int *FieldIndex, int *AbsTol, int *RelTol);\n\n /* derive the function name from the requested name and hope it is there */\n fn = (void(*)) GetNamedData(LinConfMetricSolverDB,solver_name);\n if (!fn) CCTK_WARN(0,''Ell_SimpleEllSolver: Cannot find solver! ``);\n\n /* Now that we have the function pointer to our solver, call the \n solver and pass through all the necessary arguments */\n fn( GH, FieldIndex, MIndex, AbsTol, RelTol);\n}\n\n\\end{verbatim}\nThe interface {\\tt Ell\\_SimpleEllSolver} is called from the user side. It receives a pointer to the grid hierarchy, the ID-number of the field to solver for, two arrays which the used upload with convergence test info, and finally, the name of the solver the user want to employ {\\tt *solver\\_name}. {\\bf Note:} all these quantities are referenced by pointers, hence the ``*''.\n\nWithin the interface, the solver\\_name is used to get the pointer to function which was registered under this name.\nOnce the function is known, it called with all the arguments passed to \nthe interface.\n\nTo allow calls from Fortran, the interface in C needs to be ``wrapped''. \n(This wrapping is different from the one necessary to make to actual solver \naccessible by the elliptic registry).\n\n\\begin{verbatim}\n/* Fortran wrapper for the routine Ell_SimpleEllSolver */\nvoid CCTK_FCALL CCTK_FNAME(Ell_SimpelEllSolver)\n (cGH *GH, int *FieldIndex, int *MIndex, \n int *AbsTol, int *RelTol, ONE_FORTSTRING_ARG) {\n ONE_FORTSTRING_CREATE(solver_name);\n\n /* Call the interface */\n Ell_SimpleEllSolver(GH, FieldIndex, MIndex, AbsTol, RelTol, solver_name);\n free(solver_name);\n}\n\\end{verbatim}\n\n\\item{\\bf Elliptic solver}:{\\tt ./src/FastSOR\\_solver.F}\\\\\nHere we show the first lines of the Fortran code for the solver:\n\n\\begin{verbatim}\n subroutine FastSOR_solver(_CCTK_ARGUMENTS,\n . Mlinear_lsh,Mlinear, \n . var,\n . abstol,reltol)\n\n implicit none\n\n _DECLARE_CCTK_ARGUMENTS\n DECLARE_CCTK_PARAMETERS\n INTEGER CCTK_Equals\n\n INTEGER Mlinear_lsh(3)\n CCTK_REAL Mlinear(Mlinear_lsh(1),Mlinear_lsh(2),Mlinear_lsh(3))\n CCTK_REAL var(cctk_lsh(1),cctk_lsh(2),cctk_lsh(3))\n\t\n INTEGER Mlinear_storage\n\nc We have no storage for M if they are of size one in each direction\n if ((Mlinear_lsh(1).eq.1) .and. \n . (Mlinear_lsh(2).eq.1) .and.\n . (Mlinear_lsh(3).eq.1)) then\n Mlinear_storage=0\n else\n Mlinear_storage=1\n endif\n\n\n\\end{verbatim}\nThis Fortran solver receives the following arguments: the ``typical''\n CCTK\\_ARGUMENTS: {\\tt \\_CCTK\\_ARGUMENTS},\nthe {\\em size} of the coefficient matrix: {\\tt Mlinear\\_lsh}, the coefficient\nmatrix {\\tt Mlinear}, the variable to solve for: {\\tt var}, and the two arrays with convergence information. \n\nIn the declaration section, we declare: the cctk arguments, the Mlinear size array, the coefficient matrix, by the 3-dim. size array, the variable to solve for. Why do we pass the size of Mlinear explicitly and do not use the \n{\\tt cctk\\_lsh} (processor local shape of a grid function) as we did for {\\tt var} ? The reason is the following: while we can expect the storage of {\\tt var} to be {\\em on} for the solve, there is no reason (in a more general elliptic case) to assume, that the coefficient \nmatrix has storage allocated, perhaps it is not needed at all! In this case, we have to protect ourself against referencing empty arrays. For this reason, we also employ the flag {\\tt Mlinear\\_storage}.\n\n\\item{\\bf Elliptic solver wrapper}:{\\tt ./src/FastSOR\\_wrapper.c}\\\\\nThe Fortran solver can not be used within the elliptic registry directly. \nInstead the Fortran code is called through a wrapper:\n\\begin{verbatim}\n\nvoid FastSOR_wrapper(cGH *GH, int *FieldIndex, int *MIndex, \n\t\t int *AbsTol,int *RelTol) {\n\n CCTK_REAL *Mlinear=NULL, *var=NULL;\n int Mlinear_lsh[3];\n int i;\n\n var = (CCTK_REAL*) CCTK_VarDataPtrI(GH,0,*FieldIndex);\n\n if (*MIndex>0) Mlinear = (CCTK_REAL*) CCTK_VarDataPtrI(GH,0,*MIndex);\n\n\n if (GH->cctk_dim>3)\n CCTK_WARN(0,''This elliptic solver implementation does not do dimension>3!''); \n \n for (i=0;i<GH->cctk_dim;i++) {\n if((*MIndex<0)) Mlinear_lsh[i]=1;\n else Mlinear_lsh[i]=GH->cctk_lsh[i];\n }\n\n /* call the fortran routine */\n CCTK_FNAME(SimpleEll_Solver)(_PASS_CCTK_C2F(GH),\n Mlinear_lsh, Mlinear, var, \t\n\t AbsTol, RelTol);\n}\n\\end{verbatim}\n\nThe wrapper {\\tt FastSOR\\_wrapper} takes these arguments: the indices \nof the field to solve for ({\\tt FieldIndex}) and the coefficient matrix \n({\\tt MIndex}), the two arrays containing\nconvergence information ({\\tt AbsTol, RelTol}). \nIn the body of the program we provide two CCTK\\_REAL pointers to the \ndata section of the field to solver ({\\tt var, Mlinear}) by means of {\\tt Get\\_VarDataPtrI}. For Mlinear, we only do this, if the index is non-negative. \nA negative index is a signal by the user that the coefficient matrix has \nno storage allocated.(For more general elliptic equation cases, e.g. no \nsource terms.)\n To make this information of a possibly empty matrix available to Fortran, we load a 3-dim. and pass this array through to Fortran. See discussion above.\n\n\n\\item{\\bf Elliptic solver startup}: {\\tt ./src/Startup.c}\\\\\nThe routine below in {\\tt Startup.c} performs the registration of our solver wrapper {\\tt FastSOR\\_wrapper} under the name ``{\\em fastsor}'' for the elliptic class ``{\\em Ell\\_SimpleEll}''. We do not register with the solver interface \n{\\tt Ell\\_SimpleEllSolver} directly, but with the class. In {\\tt\nStartup,c} we have:\n\\begin{verbatim}\n#include ``cctk.h''\n#include ``cctk_Parameters.h''\n\nvoid FastSOR_register(cGH *GH) {\n\n /* protoype of the solver wrapper: */\n void FastSOR_wrapper(cGH *GH, int *FieldIndex, int *MIndex,\n \tint *AbsTol, int*RelTol);\n\n Ell_RegisterSolver(FastSOR_wrapper,''fastsor'',''Ell_SimpleEll'');\n}\n\\end{verbatim}\nNote that more solver registration code could be put here (registration \nfor other classes, etc.)\n\n\n\\item{\\bf Elliptic solver scheduling}: {\\tt schedule.ccl}\nWe schedule the registration of the fast SOR solver at CCTK\\_BASE, by this time, \n{\\em the elliptic class} {\\tt Ell\\_SimpleEll} has already been registered. \n\\begin{verbatim}\nschedule FastSOR_register at CCTK_INITIAL\n{\n LANG:C\n} ``Register the fast sor solver''\n\\end{verbatim}\n\n\\end{itemize}\n\n\\section{Norms}\n\\label{sec:ellnorms}\n\n% Do not delete next line\n% END CACTUS THORNGUIDE\n\n\\end{document}\n" |
| } |
| } |