summaryrefslogtreecommitdiff
path: root/src/main/Coord.c
diff options
context:
space:
mode:
authorallen <allen@17b73243-c579-4c4c-a9d2-2d5706c11dac>1999-07-27 10:36:43 +0000
committerallen <allen@17b73243-c579-4c4c-a9d2-2d5706c11dac>1999-07-27 10:36:43 +0000
commitac7ee254d8f227ecc27bd5ac48ea8b82c8af3927 (patch)
tree2ec28821f68a0bf8618964a1c5573cb63f044932 /src/main/Coord.c
parentfd62b400921a4d1f9eb4dae64c6943917196e3ef (diff)
Added lower and upper bound coordinate registration for each coordinate
on each GH. The relevant functions are CCTK_RegisterCoordRange(GH,lower,upper,"name") (this is done in CartGrid3D now after the coords are calculated) then to get at the values CCTK_CoordRange(GH,lower,upper,"name") Note that in C lower and upper are pointers to the values. This only all works for CCTK_REAL coords at the moment. git-svn-id: http://svn.cactuscode.org/flesh/trunk@793 17b73243-c579-4c4c-a9d2-2d5706c11dac
Diffstat (limited to 'src/main/Coord.c')
-rw-r--r--src/main/Coord.c118
1 files changed, 114 insertions, 4 deletions
diff --git a/src/main/Coord.c b/src/main/Coord.c
index 82e2a66a..8da6909a 100644
--- a/src/main/Coord.c
+++ b/src/main/Coord.c
@@ -21,9 +21,12 @@
#include "Misc.h"
#include "FortranString.h"
-
static cHandledData *coordinates = NULL;
static int num_coords = 0;
+static struct COORD_RANGE *first = NULL;
+
+struct Coordprops *CCTKi_CoordData(const char *name);
+int CCTKi_CoordHande(const char *name);
/*@@
@routine RegisterCoord_ByIndex
@@ -192,12 +195,87 @@ int CCTK_RegisterCoord(const char *coordname,
int CCTK_RegisterCoordRange(cGH *GH, CCTK_REAL min, CCTK_REAL max,
const char *coordname)
{
- int retval;
-
- return retval;
+ coord_range *newguy;
+
+ /* New coord_range */
+ newguy = (coord_range *)malloc(sizeof(coord_range));
+
+ newguy->GH = GH;
+
+ newguy->props = CCTKi_CoordData(coordname);
+
+#ifdef DEBUG_COORD
+ printf("Registering range (%f,%f) for %s (on %x)\n",min,max,coordname,newguy);
+#endif
+ newguy->lower = min;
+ newguy->upper = max;
+
+ newguy->next = first;
+ first = newguy;
+
+ return 1;
+
+}
+
+void FMODIFIER FORTRAN_NAME(CCTK_RegisterCoordRange)(cGH *GH, CCTK_REAL *lower, CCTK_REAL *upper, ONE_FORTSTRING_ARG)
+{
+ ONE_FORTSTRING_CREATE(name)
+ CCTK_RegisterCoordRange (GH,*lower,*upper,name);
+ free(name);
}
+int CCTKi_CoordHandle(const char *name)
+{
+ int handle;
+ struct Coordprops *coord;
+
+ for (handle = 0;;handle++)
+ {
+ coord = (struct Coordprops *)Util_GetHandledData(coordinates, handle);
+ if (coord)
+ {
+ if (CCTK_Equals(name,(const char *)coord->name))
+ return handle;
+ }
+ else
+ {
+ char *msg;
+ msg = (char *)malloc( 100*sizeof(char)+sizeof(name) );
+ sprintf(msg,"Could not find registered coordinate %s",name);
+ CCTK_WARN(2,msg);
+ if (msg) free(msg);
+ return ERROR_COORDNOTFOUND;
+ }
+
+ }
+}
+
+struct Coordprops *CCTKi_CoordData(const char *name)
+{
+ int handle;
+ struct Coordprops *coord;
+
+ for (handle = 0;;handle++)
+ {
+ coord = (struct Coordprops *)Util_GetHandledData(coordinates, handle);
+ if (coord)
+ {
+ if (CCTK_Equals(name,(const char *)coord->name))
+ return coord;
+ }
+ else
+ {
+ char *msg;
+ msg = (char *)malloc( 100*sizeof(char)+sizeof(name) );
+ sprintf(msg,"Could not find registered coordinate %s",name);
+ CCTK_WARN(2,msg);
+ if (msg) free(msg);
+ return NULL;
+ }
+
+ }
+}
int CCTK_CoordIndex(const char *name)
{
@@ -259,3 +337,35 @@ CCTK_REAL CCTK_CoordOrigin(const char *name)
}
}
+
+int CCTK_CoordRange(cGH *GH, CCTK_REAL *lower, CCTK_REAL *upper, const char *name)
+{
+ coord_range *curr;
+
+ for (curr=first;curr;curr=curr->next)
+ {
+
+#ifdef DEBUG_COORD
+ printf("name = %s, currname = %s\n",name,curr->props->name);
+#endif
+
+ if (curr->GH == GH && CCTK_Equals(name,curr->props->name))
+ {
+ *lower = curr->lower;
+ *upper = curr->upper;
+
+#ifdef DEBUG_COORD
+ printf("Returning range (%f,%f) for %s (from %x)\n",*lower,*upper,name,curr);
+#endif
+
+ return;
+ }
+ }
+}
+
+void FMODIFIER FORTRAN_NAME(CCTK_CoordRange)(cGH *GH, CCTK_REAL *lower, CCTK_REAL *upper, ONE_FORTSTRING_ARG)
+{
+ ONE_FORTSTRING_CREATE(name)
+ CCTK_CoordRange (GH,lower,upper,name);
+ free(name);
+}