From b576e660b73773945f24a2c67aca0e7657c170ad Mon Sep 17 00:00:00 2001 From: lanfer Date: Wed, 14 Jul 1999 15:03:39 +0000 Subject: The new slicing the registry, have not compiled yet. git-svn-id: http://svn.einsteintoolkit.org/cactus/EinsteinBase/CoordGauge/trunk@2 edbb7e70-9571-45d5-a481-0a560a9b4751 --- src/Slicing.c | 176 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/Slicing.h | 35 ++++++++++++ 2 files changed, 211 insertions(+) create mode 100644 src/Slicing.c create mode 100644 src/Slicing.h diff --git a/src/Slicing.c b/src/Slicing.c new file mode 100644 index 0000000..5856dd3 --- /dev/null +++ b/src/Slicing.c @@ -0,0 +1,176 @@ + /*@@ + @file Slicing.c + @date Wed Jul 14 16:03:12 1999 + @author Gerd Lanfermann + @desc + A flexible calling structure to calling slicing functions: + * a slicing is registered with its name, with a flag to tell if its activated by + a parameter, with a function, which tells if the slicing should be used + in the next interation. + * The function is registered in a startup routine of the code providing the + slicing. + * The param_active flag is set where ? FIXME + * This structure is evaluted during a CCTK_PRESTEP, information can be queried + by all slicings, which can take their turn or skip. + @enddesc + @@*/ + +#include +#include + +#include "cctk.h" +#include "StoreHandledData.h" +#include "WarnLevel.h" +#include "Slicing.h" +#include "ErrorCodes.h" +#include "Groups.h" +#include "Misc.h" + +static char *rcsid = "$Id$"; + +/* Local data holding info on slicings..*/ + +static int num_slics = 0; +static cHandleData *Eslicings = NULL; + + /*@@ + @routine Einstein_RegisterSlicing + @date Wed Jul 14 15:57:32 1999 + @author Gerd Lanfermann + @desc + This routine registers a slicing in a structure whcih provides information + whether it is activated by parameter and which function is responsible + for evaluating whether the slicing should be used in the next iteartion. + @enddesc + @calls + @calledby + @history + + @endhistory + +@@*/ + +int Einstein_RegisterSlicing(const char slice_name) +{ + int handle; + + struct Einstein_slicing *new_slicing; + + /*Check that this Slicing has not been registered, yet */ + handle = Einstein_GetSlicing(slic_name); + + if (handle<0) { + + /* Allocate new slicing structure */ + new_slicing = (struct Einstein_slicing*) malloc(sizeof(struct Einstein_slicing)); + + if (new_slicing) { + + /* store new_slicing in the StoreHandledData-array and returns the handle for it */ + handle = CCTK_NewHandle(&Eslicings, slice_name, new_slicing); + + /*Initialize the Einstein_slicing structure */ + + /* we know the slicing name */ + new_slicing->name = (char *)name; + + /* Function pointer , evaluates if to perform this slicings, allowing + for iteration checks, gridfucntion behavior, etc. Will be set by + Einstein_RegisterTimeToSlice */ + new_slicing->timetoslice = NULL; + + /* Flag to indicate if this slicing activated by a parameter [0/1] */ + new_slicing->param_active = 0; + + } else + { + /* Memory failure */ + handle = -2; /* FIXME: some decent MACROS here */ + } + } + else + { + /* Extension handle already exists */ + handle = -1; + } + + return handle; +} + + /*@@ + @routine Einstein_SetSliceActive + @date Wed Jul 14 16:13:33 1999 + @author Gerd Lanfermann + @desc + Sets the param_active flag to active (1) or inactive (0), reflecting that + it is specified as slicing in the parameter database, or that is not used + anymore. + @enddesc + @calls + @calledby + @history + + @endhistory + +@@*/ + +int Einstein_SetSliceActive(int handle, int flag) +{ + int return_code; + struct Einstein_slicing *slicing; + + slicing = CCTK_GetHandledData(Einstein_slicing, handle); + + if (slicing) { + slicing->param_active = flag; + return_code = 1; + } + else { + /* handle didn't return the data pointer */ + return_code = 0; + } + + return return_code; +} + + + /*@@ + @routine Einstein_RegisterTimeToSlice + @date Wed Jul 14 15:52:09 1999 + @author Gerd Lanfermann + @desc + Routine registers a function with the slicing. This function returns + information whether the slicing is supposed to used during the next + iteration. The user can register any function to check for iteration + conditions, grid function behavior, etc. + @enddesc + @calls + @calledby The user + @history + + @endhistory + +@@*/ + +int Einstein_RegisterTimeToSlice(int handle, void *(*func)(tFleshConfig *, int , cGH)) +{ + int return_code; + struct Einstein_slicing *slicing; + + slicing = CCTK_GetHandledData(Einstein_slicing, handle); + + if (slicing) { + slicing->timetoslice=func; + return_code = 1; + } + else { + /* handle didn't return the data pointer */ + return_code = 0; + } + return return_code; +} + + + + + diff --git a/src/Slicing.h b/src/Slicing.h new file mode 100644 index 0000000..174e3d6 --- /dev/null +++ b/src/Slicing.h @@ -0,0 +1,35 @@ + /*@@ + @file Slicing.h + @date Wed Jul 14 16:20:03 1999 + @author Gerd Lanfermann + @desc + Prototypes and structure for Einstein_slicing. + @enddesc + @@*/ + + +#ifdef __cplusplus +extern "C" { +#endif + + +struct Einstein_slicing +{ + char * name; + int param_active; + void *(*func) timetoslice; +}; + +int Einstein_RegsiterSlicing(const char *name); + +int Einstein_SetSliceActive(int handle,int flag); + +int Einstein_RegisterTimeToSlice(int handle, void *(*func)(tfleshConfig *, int, cGH)); + +#ifdef __cplusplus +} +#endif + +#endif + + -- cgit v1.2.3