/*@@ @file GHExtension.c @date Sun Sept 22 2002 @author Gabrielle Allen and David Rideout @desc CoordBase GHExtension setup @enddesc @version $Header$ @@*/ #include #include "cctk.h" #include "coordbaseGH.h" #include "util_Hash.h" static const char *rcsid = "$Header$"; CCTK_FILEVERSION(CactusBase_CoordBase_GHExtension_c); /******************************************************************** ********************* Scheduled Routine Prototypes *************** ********************************************************************/ void CoordBase_Startup (void); /******************************************************************** ********************* Local Routine Prototypes ********************* ********************************************************************/ static void *CoordBase_SetupGH (tFleshConfig *config, int conv_level, cGH *GH); static int CoordBase_InitGH (cGH *GH); /******************************************************************** ********************* External Routines ********************** ********************************************************************/ /*@@ @routine CoordBase_Startup @date Sunday Sept 22 2002 @author Gabrielle Allen @desc The startup registration routine for CoordBase. Registers the GH extension needed for CoordBase. @enddesc @calls CCTK_RegisterGHExtension CCTK_RegisterGHExtensionSetupGH CCTK_RegisterGHExtensionInitGH @@*/ void CoordBase_Startup (void) { int GHex_handle; GHex_handle = CCTK_RegisterGHExtension ("CoordBase"); CCTK_RegisterGHExtensionSetupGH (GHex_handle, CoordBase_SetupGH); CCTK_RegisterGHExtensionInitGH (GHex_handle, CoordBase_InitGH); } /******************************************************************** ******************** Internal Routines ************************ ********************************************************************/ /*@@ @routine CoordBase_SetupGH @date Sun Sept 22 2002 @author Gabrielle Allen @desc Allocates CoordBase's GH extension structure @enddesc @calls Util_HashCreate @var config @vdesc the CCTK configuration as provided by the flesh @vtype tFleshConfig * @vio unused @endvar @var conv_level @vdesc the convergence level @vtype int @vio unused @endvar @var GH @vdesc Pointer to CCTK grid hierarchy @vtype cGH * @vio in @endvar @returntype void * @returndesc pointer to the allocated GH extension structure @endreturndesc @@*/ static void *CoordBase_SetupGH (tFleshConfig *config, int conv_level, cGH *GH) { coordbaseGH *myGH; /* suppress compiler warnings about unused variables */ (void) (config + 0); (void) (conv_level + 0); (void) (GH + 0); /* allocate the GH extension and its components */ myGH = (coordbaseGH *) malloc (sizeof (coordbaseGH)); if (! myGH) { CCTK_WARN (0, "CoordBase_SetupGH: Unable to allocate memory for GH " "extension"); } myGH->coordsystems = Util_HashCreate(8); myGH->default_coord_systems = (int *) malloc(CCTK_MaxDim()*sizeof(int)); if (! myGH->default_coord_systems) { CCTK_WARN (0, "CoordBase_SetupGH: Unable to allocate memory for GH " "extension"); } return (myGH); } /*@@ @routine CoordBase_InitGH @date 28 July 2003 @author David Rideout @desc Initializes CoordBase's GH extension structure @enddesc @calls CCTK_GHExtension, CCTK_MaxDim @var GH @vdesc Pointer to CCTK grid hierarchy @vtype cGH * @vio in @endvar @returntype int @returndesc pointer to the initialized GH extension structure @endreturndesc @@*/ int CoordBase_InitGH (cGH *GH) { const coordbaseGH *GHex; int i; /* Get the GH extension pointer again... */ GHex = (const coordbaseGH *) CCTK_GHExtension(GH,"CoordBase"); /* Initialize default_coord_systems to invalid table handles */ for (i=0; idefault_coord_systems[i] = -1; } return 0; }