summaryrefslogtreecommitdiff
path: root/src/main/GHExtensions.c
diff options
context:
space:
mode:
authorgoodale <goodale@17b73243-c579-4c4c-a9d2-2d5706c11dac>2000-01-27 23:18:16 +0000
committergoodale <goodale@17b73243-c579-4c4c-a9d2-2d5706c11dac>2000-01-27 23:18:16 +0000
commit1a53d2c962018be2fa3f7299f4fbdae342149768 (patch)
tree3c3b8afc80b4190cfe2839d172fa1391b6dbf4f6 /src/main/GHExtensions.c
parent56543d22f0bdfe6c45d557ecf1d7872b4ad47a98 (diff)
Added the mechanism for allowing drivers to specify a function to be
called at the bottm of a schedule traverse, and changed the flesh to use the new calls. rfrTraverse is now obsolete and will be removed soon. Drivers may now call int CCTK_RegisterGHExtensionScheduleTraverseGH(int handle, int (*func)(cGH *, const char *)) to register a ScheduleTraverse function. This is precisely equivalent to the deprecated CCTK_RegisterGHExtensionrfrTraverseGH except the registered function now takes a string and not a constant. The registered function should then fill out the cGH as per normal, and call int CCTK_ScheduleTraverse(const char *where, void *GH, int (*CallFunction)(void *, cFunctionData *, void *)) with the string and GH passed in, and either NULL or a function which takes a function pointer, a cFunctionData data structure, and a cGH. This function, in turn, may call int CCTK_CallFunction(void *function, cFunctionData *fdata, void *data) with these arguments, or may call the function in some other way if it desires. This allows a driver to loop over all sub-grids at a particular level filling out the cGH at this level of the schedule tree rather than at the top, which was the only option available before. Unigrid drivers should probably still fill out at the top and pass NULL down as it's more efficient to fill out the cGH only once, but AMR or multi-block/patch drivers can now use this mechanism. The old CCTK_rfrTraverse routine has similarly been replaced by int CCTK_Traverse(cGH *GH, const char *where) which loops over all GH extensions calling their registered ScheduleTraverseGH routines. Tom NB these names may change at the next naming meeting, but the functionality should remain. git-svn-id: http://svn.cactuscode.org/flesh/trunk@1317 17b73243-c579-4c4c-a9d2-2d5706c11dac
Diffstat (limited to 'src/main/GHExtensions.c')
-rw-r--r--src/main/GHExtensions.c121
1 files changed, 114 insertions, 7 deletions
diff --git a/src/main/GHExtensions.c b/src/main/GHExtensions.c
index f66b2fa4..5512c3a2 100644
--- a/src/main/GHExtensions.c
+++ b/src/main/GHExtensions.c
@@ -43,6 +43,7 @@ struct GHExtension
void *(*SetupGH)(tFleshConfig *, int, cGH *);
int (*InitGH)(cGH *);
int (*rfrTraverseGH)(cGH *, int);
+ int (*ScheduleTraverseGH)(cGH *, const char *);
};
@@ -53,9 +54,14 @@ static int CheckAllExtensionsSetup(void);
/* Dummy function prototypes. */
-static void *DummySetupGH(tFleshConfig *config, int convergence_level, cGH *GH);
+static void *DummySetupGH(tFleshConfig *config,
+ int convergence_level,
+ cGH *GH);
static int DummyInitGH(cGH *GH);
-static int DummyrfrTraverseGH(cGH *GH, int rfrpoint);
+static int DummyrfrTraverseGH(cGH *GH,
+ int rfrpoint);
+static int DummyScheduleTraverseGH(cGH *GH,
+ const char *where);
/**************************************************************************
@@ -105,6 +111,7 @@ int CCTK_RegisterGHExtension(const char *name)
new_extension->InitGH = NULL;
new_extension->SetupGH = NULL;
new_extension->rfrTraverseGH = NULL;
+ new_extension->ScheduleTraverseGH = NULL;
/* Remember how many extensions there are */
num_extensions++;
@@ -180,7 +187,8 @@ int CCTK_RegisterGHExtensionSetupGH(int handle,
@endhistory
@@*/
-int CCTK_RegisterGHExtensionInitGH(int handle, int (*func)(cGH *))
+int CCTK_RegisterGHExtensionInitGH(int handle,
+ int (*func)(cGH *))
{
int return_code;
struct GHExtension *extension;
@@ -215,7 +223,8 @@ int CCTK_RegisterGHExtensionInitGH(int handle, int (*func)(cGH *))
@endhistory
@@*/
-int CCTK_RegisterGHExtensionrfrTraverseGH(int handle, int (*func)(cGH *, int))
+int CCTK_RegisterGHExtensionrfrTraverseGH(int handle,
+ int (*func)(cGH *, int))
{
int return_code;
struct GHExtension *extension;
@@ -236,6 +245,42 @@ int CCTK_RegisterGHExtensionrfrTraverseGH(int handle, int (*func)(cGH *, int))
return return_code;
}
+ /*@@
+ @routine CCTK_RegisterGHExtensionScheduleTraverseGH
+ @date Thu Jan 27 14:37:09 2000
+ @author Tom Goodale
+ @desc
+ Registers a GH extension Schedule traversal routine routine.
+ @enddesc
+ @calls
+ @calledby
+ @history
+
+ @endhistory
+
+@@*/
+int CCTK_RegisterGHExtensionScheduleTraverseGH(int handle,
+ int (*func)(cGH *, const char *))
+{
+ int return_code;
+ struct GHExtension *extension;
+
+ /* Get the extension. */
+ extension = Util_GetHandledData(GHExtensions, handle);
+
+ if(extension)
+ {
+ extension->ScheduleTraverseGH = func;
+ return_code = 1;
+ }
+ else
+ {
+ return_code = 0;
+ }
+
+ return return_code;
+}
+
/***************************************************************************
*
@@ -345,7 +390,8 @@ int CCTKi_InitGHExtensions(cGH *GH)
@endhistory
@@*/
-int CCTKi_rfrTraverseGHExtensions(cGH *GH, int rfrpoint)
+int CCTKi_rfrTraverseGHExtensions(cGH *GH,
+ int rfrpoint)
{
int handle;
struct GHExtension *extension;
@@ -359,6 +405,34 @@ int CCTKi_rfrTraverseGHExtensions(cGH *GH, int rfrpoint)
return 0;
}
+ /*@@
+ @routine CCTKi_ScheduleTraverseGHExtensions
+ @date Thu Jan 27 14:47:06 2000
+ @author Tom Goodale
+ @desc
+ Calls the routines which an extension needs called at a schedule traversal.
+ @enddesc
+ @calls
+ @calledby
+ @history
+
+ @endhistory
+
+@@*/
+int CCTKi_ScheduleTraverseGHExtensions(cGH *GH,
+ const char *where)
+{
+ int handle;
+ struct GHExtension *extension;
+
+ for(handle = 0; handle < num_extensions; handle++)
+ {
+ extension = (struct GHExtension *)Util_GetHandledData(GHExtensions, handle);
+ extension->ScheduleTraverseGH(GH, where);
+ }
+
+ return 0;
+}
/***************************************************************************
*
@@ -431,6 +505,17 @@ static int CheckAllExtensionsSetup(void)
extension->rfrTraverseGH=DummyrfrTraverseGH;
}
+ /* ScheduleTraverse */
+ if(!extension->ScheduleTraverseGH)
+ {
+ const char *handlename = Util_GetHandleName(GHExtensions, handle);
+ char *message = (char *)malloc(300*sizeof(char));
+ sprintf(message,"GH Extension '%s' has not registered a ScheduleTraverse routine",handlename);
+ CCTK_Warn(4,__LINE__,__FILE__,"Cactus",message) ;
+ free(message);
+ extension->ScheduleTraverseGH=DummyScheduleTraverseGH;
+ }
+
}
return return_code;
@@ -491,7 +576,9 @@ void FMODIFIER FORTRAN_NAME(CCTK_GHExtensionHandle)(int *handle,ONE_FORTSTRING_
@endhistory
@@*/
-static void *DummySetupGH(tFleshConfig *config, int convergence_level, cGH *GH)
+static void *DummySetupGH(tFleshConfig *config,
+ int convergence_level,
+ cGH *GH)
{
return NULL;
}
@@ -531,8 +618,28 @@ static int DummyInitGH(cGH *GH)
@endhistory
@@*/
-static int DummyrfrTraverseGH(cGH *GH, int rfrpoint)
+static int DummyrfrTraverseGH(cGH *GH,
+ int rfrpoint)
{
return 0;
}
+ /*@@
+ @routine DummyScheduleTraverseGH
+ @date Thu Jan 27 14:34:41 2000
+ @author Tom Goodale
+ @desc
+
+ @enddesc
+ @calls
+ @calledby
+ @history
+
+ @endhistory
+
+@@*/
+static int DummyScheduleTraverseGH(cGH *GH,
+ const char *where)
+{
+ return 0;
+}