aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjshalf <jshalf@bfcf8e34-485d-4d46-a995-1fd6fa6fb178>2000-10-07 05:09:03 +0000
committerjshalf <jshalf@bfcf8e34-485d-4d46-a995-1fd6fa6fb178>2000-10-07 05:09:03 +0000
commite626a0effb3f657a36f2c9be6f80149814d620f3 (patch)
tree9941e00d1fe5c47c4aeb472e14256df4028ad5f2
parenta56d13efe4ca5ae5ec16daf48a1842e61de89109 (diff)
OK,
it builds... Isn't carefully tested, but at least it builds. I got rid of an awful lot of extraneous crap and in particular *all* of the static global variables. We can add crap back when its clear that it is a necessity. For some reason CCTK_INT8 was an unrecognized type in the build. You might want to add that back to the Socket.c if its clear why this type was not recognized. This only affects the subroutine IsoWriteDataToClients() git-svn-id: http://svn.cactuscode.org/arrangements/CactusPUGHIO/IsoSurfacer/trunk@7 bfcf8e34-485d-4d46-a995-1fd6fa6fb178
-rw-r--r--src/IsoSurfacer.c414
-rw-r--r--src/IsoSurfacerGH.h24
-rw-r--r--src/IsoSurfacerInit.c80
-rw-r--r--src/IsoSurfacerInit.h17
-rw-r--r--src/NuSurfacer.c61
-rw-r--r--src/NuSurfacer.h7
-rw-r--r--src/Sockets.c6
-rw-r--r--src/common.h37
8 files changed, 201 insertions, 445 deletions
diff --git a/src/IsoSurfacer.c b/src/IsoSurfacer.c
index 6ad8190..dd50173 100644
--- a/src/IsoSurfacer.c
+++ b/src/IsoSurfacer.c
@@ -19,20 +19,6 @@
with at a later time.)
@enddesc
@@*/
-
-
-#ifndef TCP
-#define TCP
-#endif
-
-#define Append_Or_EnlargeAndAppend(outs, tmps) \
-q = p; \
-if( (p += strlen(tmps)) >= lfs ) \
-{ \
- (outs) = ((char *)realloc((void *)(outs), 2 * lfs * sizeof(char))); \
- lfs *= 2; \
-} \
-strcpy(&(outs)[q], (tmps))
#include <stdio.h>
#include <string.h>
@@ -47,102 +33,38 @@ strcpy(&(outs)[q], (tmps))
#include "IsoSurfacerGH.h"
#include "IsoSurfacerInit.h"
-#include "common.h"
#include "NuSurfacer.h"
+/* *******Some Macro Definitions *************/
+#define NEW(n,what) ((what*)malloc((n)*sizeof(what)))
+#define REALLOC(object,n,what) \
+ if((object) != NULL) free(object); \
+ (object) = NEW(n,what); \
+ if((object) == NULL) printf("IsoSurfacer: REALLOC failed!\n")
-/* Some function forward declarations */
+#define Append_Or_EnlargeAndAppend(outs, tmps) \
+q = p; \
+if( (p += strlen(tmps)) >= lfs ) \
+{ \
+ (outs) = ((char *)realloc((void *)(outs), 2 * lfs * sizeof(char))); \
+ lfs *= 2; \
+} \
+strcpy(&(outs)[q], (tmps))
+/* ***** Some function forward declarations ***** */
static void CollectData(cGH *GH, polypatch *perprocessor, polypatch *totals);
-static void WriteBin(cGH *GH, polypatch *totals, par_st *parms,
+static void WriteBin(cGH *GH, polypatch *totals,isosurfacerGH *myGH,
const char *fullname, CCTK_REAL4 isolevel);
-static void WriteVRML(cGH *GH, polypatch *totals, par_st *parms,
+static void WriteVRML(cGH *GH, polypatch *totals,
const char *fullname, CCTK_REAL4 isolevel);
-static void WriteASCII(cGH *GH, polypatch *totals, par_st *parms,
+static void WriteASCII(cGH *GH, polypatch *totals,
const char *fullname, CCTK_REAL4 isolevel);
-static void WriteUCD(cGH *GH, polypatch *totals, par_st *parms,
+static void WriteUCD(cGH *GH, polypatch *totals,
const char *fullname, CCTK_REAL4 isolevel);
-static void WriteSock(cGH *GH, polypatch *totals, par_st *parms,
+static void WriteSock(cGH *GH, polypatch *totals, isosurfacerGH *myGH,
const char *fullname, int isoindex, CCTK_REAL4 isolevel);
-static void WriteHDF5(cGH *GH, polypatch *totals, par_st *parms,
+static void WriteHDF5(cGH *GH, polypatch *totals, isosurfacerGH *myGH,
const char *fullname, int isoindex, CCTK_REAL4 isolevel);
-extern isotimes_st isotimes;
-extern isotimes_st cdtimes;
-
/***************************************************************************/
-
-/* Ugly global variables: Should move to the GH */
-
-static polypatch perprocessor, totals;
-static GridAll_st GridAll; /* JMS: This is nutty... must get rid of this */
-#ifdef CCTK_MPI
-static int print_time=0;
-static double taccum;
-double t1;
-#endif
-
-#ifndef true
-#define true 1
-#endif
-#ifndef false
-#define false 0
-#endif
-
-static int GridInit(cGH *GH)
-{
- static int done = false;
- int i;
- if (done)
- return true;
-
- done = true;
- GridAll.GH = GH;
- /* get the data pointer to the current timelevel of GF X */
- i = CCTK_CoordIndex (-1,"x","cart3d");
- if (i < 0) {
- CCTK_WARN (1, "Could not get index of 'x' coordinate");
- return false;
- }
- GridAll.timelevel = CCTK_NumTimeLevelsFromVarI (i) - 1;
- if (GridAll.timelevel > 0)
- GridAll.timelevel--;
- if (CCTK_VarTypeI (i) != CCTK_VARIABLE_REAL) {
- CCTK_WARN (1, "Expected 'x' coordinate to be a REAL variable !");
- return false;
- }
- GridAll.x = (CCTK_REAL *) CCTK_VarDataPtrI (GH, GridAll.timelevel, i);
-
- /* get the data pointer to the current timelevel of GF Y */
- i = CCTK_CoordIndex (-1,"y","cart3d");
- if (i < 0) {
- CCTK_WARN (1, "Could not get index of 'y' coordinate");
- return false;
- }
- if (CCTK_VarTypeI (i) != CCTK_VARIABLE_REAL) {
- CCTK_WARN (1, "Expected 'y' coordinate to be a REAL variable !");
- return false;
- }
- GridAll.y = (CCTK_REAL *) CCTK_VarDataPtrI (GH, GridAll.timelevel, i);
-
- /* get the data pointer to the current timelevel of GF Z */
- i = CCTK_CoordIndex (-1,"z","cart3d");
- if (i < 0) {
- CCTK_WARN (1, "Could not get index of 'z' coordinate");
- return false;
- }
- if (CCTK_VarTypeI (i) != CCTK_VARIABLE_REAL) {
- CCTK_WARN (1, "Expected 'z' coordinate to be a REAL variable !");
- return false;
- }
- GridAll.z = (CCTK_REAL *) CCTK_VarDataPtrI (GH, GridAll.timelevel, i);
-
- totals.verts = NULL;
- totals.polys = NULL;
- perprocessor.verts = NULL;
- perprocessor.polys = NULL;
-
- return true;
-}
-
static int IsoSurfacerHandleCommands(cGH *GH)
{
isosurfacerGH *myGH = (isosurfacerGH *) GH->extensions [CCTK_GHExtensionHandle ("IsoSurfacer")];
@@ -191,205 +113,132 @@ static int IsoSurfacerHandleCommands(cGH *GH)
break;
char *obj = catenated+64,
*val = catenated+128; */
-#if 0
- HTTPCommand*Cmd = http_ReceiveNextCommand(GH, "isosurf" );
-
- if (!Cmd)
- break;
-
- char *obj = Cmd->target,
- *val = Cmd->value;
-
- char gridname[64];
- int isoindex = 0;
- strcpy(gridname,obj);
-
- /* FUNCTIONALITY: gridfunc[?] means: create a new isosurface */
-
- /* gridfunc[4] means: 4th isosurface level */
-
- char *s = strchr(gridname,'[');
- if (s){
- *s='\0';
- s++;
- char *ss=strchr(s,']');
- if (ss){
- *ss='\0';
- }
- if (*s == '?')
- isoindex = -1;
- else{
- isoindex=atoi(s);
- if (isoindex < 0 )
- isoindex = 0;
- }
- }
-
- /* Check if the requested gridfunc already has iso parameters */
-
- /* param_map::iterator git = myGH->isoparms.find( (const char*)gridname ); */
-
- if (git == myGH->isoparms.end() ) { /* not found? --> create new params */
- /* printf( "No Isoparams for %s\n", gridname ); */
-
- isoparms_st*params = new isoparms_st();
- params->funcName = strdup( gridname );
- params->formats |= SOCK;
-
- myGH->isoparms[ params->funcName ] = params;
- }
- isoparms_st*params = myGH->isoparms[ gridname ];
- assert( params && params->funcName);
- if (isoindex < 0 || (unsigned int) isoindex >= params->isolevels.size() ){
- params->isolevels.push_back( Isolevel() );
- isoindex = params->isolevels.size() -1 ;
- }
- Isolevel&current = params->isolevels[isoindex];
- current.value = atof(val); /* Note: Setting of colorinfo not implemented yet. */
- delete Cmd;
-#endif
-
+
+ puts("Nuthin to do (yet)");
+ /* Here it just needs to read from the control socket
+ and then change the isosurface appropriately */
return 0;
}
-static int doIso(int i, cGH *GH, isosurfacerGH *myGH)
+static int doIso(int index, cGH *GH, isosurfacerGH *myGH)
{
/* need to rediscover how to mess with this */
- char *fullname = CCTK_FullName (i);
+ char *fullname = CCTK_FullName (index);
if(!strcmp(fullname,myGH->funcName)){
if(myGH->firstIteration<=GH->cctk_iteration &&
- !((GH->cctk_iteration-myGH->firstIteration) % myGH->outfreq))
+ !((GH->cctk_iteration-myGH->firstIteration) % myGH->outfreq)){
+ free(fullname);
return 1;
+ }
}
+ free(fullname);
return 0;
}
-static void computeIso(int i, cGH *GH, isosurfacerGH *myGH)
+static void computeIso(int index, cGH *GH, isosurfacerGH *myGH)
{
DECLARE_CCTK_PARAMETERS
- /* is it really required to have this static here?? */
- static par_st parms;
- char* fullname = CCTK_FullName (i);
- int j;
-
- isoparms_st *isofunc = myGH;
-
- /* if the do_iso flag is set */
- /* then draw an iso for each level of surfaces requested */
-
- /* Do the bcast for nisolevels here */
- isotimes.ncalls++;
-#ifndef _WIN32
- isotimes.realtime_begin = times(&isotimes.tms_begin);
-#endif
-
- GridAll.gfi = i;
-
- /* get the current timelevel */
- GridAll.timelevel = CCTK_NumTimeLevelsFromVarI (i) - 1;
- if (GridAll.timelevel > 0)
- GridAll.timelevel--;
-
- /* This needs to be removed.
- should just use isoparms_st everywhere */
- parms.outfname = NULL;
- parms.outtype = isofunc->formats;
- parms.isovalue = isofunc->isovalue;
- parms.step = isofunc->resolution;
- parms.doRemoveDuplicateVertices = isofunc->uniq_verts;
- parms.useTree = parms.doRemoveDuplicateVertices;
- parms.doEliminateSmallTriangles = 0;
-
-#ifdef CCTK_MPI
- t1=MPI_Wtime();
-#endif
- NuFindSurface(GH,i,parms.isovalue,&perprocessor);
-#ifdef CCTK_MPI
- taccum += (MPI_Wtime()-t1);
- if(print_time)
- fprintf(stderr," | %s[p=%u] Accumtime=%f\n",
- nusurfacer ? "Newsurf" : "Oldsurf", CCTK_MyProc(GH),taccum);
-#endif
-
- CollectData(GH, &perprocessor, &totals);
+ /* is it really required to have this static here?? */
+ char* fullname = CCTK_FullName (index);
+ int i,j;
+ int nx,ny,nz;
+ CCTK_REAL *xcoords,*ycoords,*zcoords,*data;
+ int timelevel;
+ timelevel = CCTK_NumTimeLevelsFromVarI (index);
+ if (timelevel > 0)
+ timelevel--;
+ data = (CCTK_REAL *) GH->data [index][timelevel];
+ nx=GH->cctk_lsh[0]; ny=GH->cctk_lsh[1]; nz=GH->cctk_lsh[2];
+
+ /* get the data pointer to the current timelevel of GF X */
+ i = CCTK_CoordIndex (-1,"x","cart3d");
+ timelevel = CCTK_NumTimeLevelsFromVarI (i) - 1; /* first time... get proper timelevel */
+ if (timelevel > 0)
+ timelevel--;
+ xcoords = (CCTK_REAL *) CCTK_VarDataPtrI (GH, timelevel, i);
+ /* get the data pointer to the current timelevel of GF Y */
+ i = CCTK_CoordIndex (-1,"y","cart3d");
+ ycoords = (CCTK_REAL *) CCTK_VarDataPtrI (GH, timelevel, i);
+ /* get the data pointer to the current timelevel of GF Z */
+ i = CCTK_CoordIndex (-1,"z","cart3d");
+ zcoords = (CCTK_REAL *) CCTK_VarDataPtrI (GH, timelevel, i);
+ /* Actually perform the Isosurfacing Operation */
+ NuFindSurface(data,nx,ny,nz,xcoords,ycoords,zcoords,myGH->isovalue,&(myGH->perprocessor));
+ /* And collect the geometry to node 0 */
+ CollectData(GH, &(myGH->perprocessor), &(myGH->totals));
+ /* and for the writers, collect min,max to node 0 */
+ if(myGH->formats & (SOCK|ISOHDF5|BIN)){
+ int handle;
+ handle = CCTK_ReductionHandle ("minimum");
+ CCTK_Reduce (GH, 0,handle,1,CCTK_VARIABLE_REAL,
+ &(myGH->minval),1, index);
+ handle = CCTK_ReductionHandle ("maximum");
+ CCTK_Reduce (GH, 0, handle, 1, CCTK_VARIABLE_REAL,
+ &(myGH->maxval), 1, index);
+ }
if (CCTK_MyProc (GH) == 0){
CCTK_INT4 tmppolys[3] = {0,0,0};
CCTK_REAL4 tmpverts[3] = {0.0,0.0,0.0};
CCTK_INT4 *polybackup=0;
CCTK_REAL4 *vertbackup=0;
-
- if(allow_empty_sends && totals.nverts<=0){ /* lets kludge it! */
- totals.nverts=1; /* one vertex */
- totals.npolys=1; /* one polygon which refers to the same vertex 3 times */
- polybackup=totals.polys; totals.polys = tmppolys;
- vertbackup=totals.verts; totals.verts = tmpverts;
+ if(allow_empty_sends && myGH->totals.nverts<=0){ /* lets kludge it! YEAH! */
+ myGH->totals.nverts=1; /* one vertex */
+ myGH->totals.npolys=1; /* one polygon which refers to the same vertex 3 times */
+ polybackup=myGH->totals.polys; myGH->totals.polys = tmppolys;
+ vertbackup=myGH->totals.verts; myGH->totals.verts = tmpverts;
}
if (verbose)
printf(" | IsoSurfacer: GF=%s, value %f,",
- fullname, parms.isovalue);
+ fullname, myGH->isovalue);
- if(totals.nverts > 0) {
+ if(myGH->totals.nverts > 0) {
if (verbose)
- printf("%d vertices, %d triangles\n", totals.nverts, totals.npolys);
+ printf("%d vertices, %d triangles\n", myGH->totals.nverts, myGH->totals.npolys);
- if(parms.outtype & BIN)
- WriteBin(GH, &totals, &parms, fullname, isofunc->isovalue);
+ if(myGH->formats & BIN)
+ WriteBin(GH, &myGH->totals, myGH, fullname, myGH->isovalue);
- if(parms.outtype & ASCII)
- WriteASCII(GH, &totals, &parms, fullname,
- isofunc->isovalue);
+ if(myGH->formats & ASCII)
+ WriteASCII(GH, &myGH->totals, fullname, myGH->isovalue);
- if(parms.outtype & UCD)
- WriteUCD(GH, &totals, &parms, fullname, isofunc->isovalue);
+ if(myGH->formats & UCD)
+ WriteUCD(GH, &myGH->totals,fullname, myGH->isovalue);
- if(parms.outtype & VRML)
- WriteVRML(GH, &totals, &parms, fullname,isofunc->isovalue);
+ if(myGH->formats & VRML)
+ WriteVRML(GH, &myGH->totals, fullname,myGH->isovalue);
- if(parms.outtype & SOCK)
- WriteSock(GH, &totals,&parms,fullname,j, isofunc->isovalue);
+ /* !!!!!!!!!!!!!!!!!! what is J representing???? */
+ if(myGH->formats & SOCK)
+ WriteSock(GH, &myGH->totals,myGH,fullname,0, myGH->isovalue);
- if(parms.outtype & ISOHDF5)
- WriteHDF5(GH, &totals,&parms,fullname,j, isofunc->isovalue);
+ if(myGH->formats & ISOHDF5)
+ WriteHDF5(GH, &myGH->totals,myGH,fullname,0, myGH->isovalue);
} else
printf(" no isosurface\n");
-
+ /* !!!!!!!!!!!!!!!! Why the hell are we doing this? !!!!!!!!!!!! */
if(polybackup || vertbackup){ /* copy back datastructures */
- totals.polys=polybackup;
- totals.verts=vertbackup;
+ myGH->totals.polys=polybackup;
+ myGH->totals.verts=vertbackup;
}
}
-#ifndef _WIN32
- isotimes.realtime_end = times(&isotimes.tms_end);
- isotimes.realtime_total +=
- (isotimes.realtime_end - isotimes.realtime_begin);
- isotimes.tms_total.tms_utime +=
- (isotimes.tms_end.tms_utime - isotimes.tms_begin.tms_utime);
- isotimes.tms_total.tms_stime +=
- (isotimes.tms_end.tms_stime - isotimes.tms_begin.tms_stime);
-#endif
-
free (fullname);
}
int IsoSurfacer(cGH *GH){
int i,n;
isosurfacerGH *myGH = (isosurfacerGH *) GH->extensions [CCTK_GHExtensionHandle ("IsoSurfacer")];
- if (!GridInit(GH))
- return false;
-
IsoSurfacerHandleCommands(GH);
-
/* do a check for new isosurfaces */
/* Perhaps do a bcast for "changed" flags.
which are embedded in each iso. */
for (i = 0,n=CCTK_NumVars(); i<n; i++) { /* for each Grid */
- if (!doIso(i, GH, myGH)) /* JMS still must translate this GH extension flag */
+ if (!doIso(i, GH, myGH))
continue;
if (CCTK_QueryGroupStorageI(GH,CCTK_GroupIndexFromVarI(i))) {
@@ -515,29 +364,19 @@ void CollectData(cGH *GH, polypatch *perprocessor, polypatch *totals) {
}
}
-#ifndef _WIN32
- cdtimes.realtime_end = times(&cdtimes.tms_end);
- cdtimes.realtime_total += (cdtimes.realtime_end - cdtimes.realtime_begin);
-
- cdtimes.tms_total.tms_utime +=
- (cdtimes.tms_end.tms_utime - cdtimes.tms_begin.tms_utime);
- cdtimes.tms_total.tms_stime +=
- (cdtimes.tms_end.tms_stime - cdtimes.tms_begin.tms_stime);
-#endif
-
-#else
+#else /* !MPI */
*totals = *perprocessor;
#endif /* MPI */
}
-/***************************************************************************/
+/**************************************************************/
-int IsoWriteDataToClients(const char *metadata,
- CCTK_INT8 size,
+int IsoWriteDataToClients(char *metadata,
+ CCTK_INT4 size,
IsoType type,
CCTK_INT4 *data);
-void WriteSock(cGH *GH, polypatch *totals, par_st *parms,
+void WriteSock(cGH *GH, polypatch *totals, isosurfacerGH *myGH,
const char *fullname, int isoindex,
CCTK_REAL4 IsoValue)
{
@@ -547,11 +386,11 @@ void WriteSock(cGH *GH, polypatch *totals, par_st *parms,
CCTK_REAL4 *verts;
CCTK_INT4 tmppolys[3] = {0,0,0};
CCTK_REAL4 tmpverts[3] = {0.0,0.0,0.0};
-
+ /* Needs to collect min/max here */
sprintf(tmpstring," :%s[0]=%f,%u range=%f:%f",
- fullname,parms->isovalue,
+ fullname,myGH->isovalue,
GH->cctk_iteration,
- parms->minval,parms->maxval);
+ myGH->minval,myGH->maxval);
puts(tmpstring);
/********Now write vertices**********/
*tmpstring='v';
@@ -571,24 +410,24 @@ void WriteSock(cGH *GH, polypatch *totals, par_st *parms,
/***************************************************************************/
-static void WriteHDF5(cGH *GH, polypatch *totals, par_st *parms,
+static void WriteHDF5(cGH *GH, polypatch *totals, isosurfacerGH *myGH,
const char *fullname, int isoindex, CCTK_REAL4 IsoValue)
{
DECLARE_CCTK_PARAMETERS
#ifdef CACTUSPUGHIO_IOHDF5
char *filename;
-
filename = (char *) malloc (strlen (outdir) + strlen (fullname) +
strlen (PUGH_pGH (GH)->identity_string) + 20);
sprintf (filename, "%s/%s%s.iso.h5", outdir, fullname,
PUGH_pGH (GH)->identity_string);
#if 0 /* disabled for now */
+ /* needs to extract min/max value for GF with CCTK_Reduction op*/
IOHDF5_WriteIsosurface (GH, filename, fullname,
(CCTK_INT) GH->cctk_iteration,
(CCTK_INT) GridAll.timelevel,
- (CCTK_REAL) parms->isovalue,
- (CCTK_REAL) parms->minval, (CCTK_REAL) parms->maxval,
+ (CCTK_REAL) myGH->isovalue,
+ (CCTK_REAL) myGH->minval, (CCTK_REAL) myGH->maxval,
(int) totals->npolys, totals->polys,
(int) totals->nverts, totals->verts);
#endif
@@ -603,23 +442,25 @@ static void WriteHDF5(cGH *GH, polypatch *totals, par_st *parms,
/***************************************************************************/
void
-WriteBin(cGH *GH, polypatch *totals, par_st *parms, const char *fullname,
+WriteBin(cGH *GH, polypatch *totals, isosurfacerGH *myGH, const char *fullname,
CCTK_REAL4 isolevel)
{
/* Write Isosurfaces in Manuel's own format which can
then be read by 'isoshow' and 'isoserver' */
DECLARE_CCTK_PARAMETERS
+ static CCTK_INT4 step=0;
static FILE *bf;
static char fname[256];
static char tmpstring[100];
- static CCTK_INT4 tmp;
+ CCTK_INT4 tmp;
+ CCTK_REAL4 ftmp;
char formatstring[256];
/* Debug printing stuff ---------------------
sprintf(fname," :%s[%u]=%f,%u range=%f:%f",
- fullname,j,parms->isovalue,parms->timestep,
- parms->minval,parms->maxval);
+ fullname,j,myGH->isovalue,myGH->timestep,
+ myGH->minval,myGH->maxval);
printf("SockString = [%s]\n",fname);
--------------------------------------------*/
if(*format_str=='%')
@@ -643,14 +484,15 @@ WriteBin(cGH *GH, polypatch *totals, par_st *parms, const char *fullname,
tmp = (CCTK_INT4)GH->cctk_iteration;
fwrite(&tmp, sizeof(CCTK_INT4), 1, bf);
- fwrite(&parms->isovalue, sizeof(CCTK_REAL4), 1, bf);
+ ftmp=myGH->isovalue;
+ fwrite(&ftmp, sizeof(CCTK_REAL4), 1, bf);
- fwrite(&parms->step, sizeof(CCTK_INT4), 1, bf);
- fwrite(&parms->doRemoveDuplicateVertices, sizeof(CCTK_INT4), 1, bf);
+ fwrite(&step, sizeof(CCTK_INT4), 1, bf);
+ tmp=1;
+ fwrite(&tmp, sizeof(CCTK_INT4), 1, bf);
fwrite(&totals->nverts, sizeof(CCTK_INT4), 1, bf);
fwrite(&totals->npolys, sizeof(CCTK_INT4), 1, bf);
-
fwrite(totals->verts, sizeof(CCTK_REAL4), 3*totals->nverts, bf);
if(totals->npolys > 0)
fwrite(totals->polys, sizeof(CCTK_INT4), 3*totals->npolys, bf);
@@ -661,7 +503,7 @@ WriteBin(cGH *GH, polypatch *totals, par_st *parms, const char *fullname,
/***************************************************************************/
void
-WriteVRML(cGH *GH, polypatch *totals, par_st *parms, const char *fullname,
+WriteVRML(cGH *GH, polypatch *totals, const char *fullname,
CCTK_REAL4 isolevel)
{
/* Write isosurfaces in VRML 1.0 ASCII format
@@ -729,7 +571,7 @@ WriteVRML(cGH *GH, polypatch *totals, par_st *parms, const char *fullname,
/***************************************************************************/
void
-WriteASCII(cGH *GH, polypatch *totals, par_st *parms, const char *fullname,
+WriteASCII(cGH *GH, polypatch *totals, const char *fullname,
CCTK_REAL4 isolevel)
{
/* Write Iso's in Paul's ASCII format */
@@ -787,7 +629,7 @@ WriteASCII(cGH *GH, polypatch *totals, par_st *parms, const char *fullname,
/***************************************************************************/
void
-WriteUCD(cGH *GH, polypatch *totals, par_st *parms, const char *fullname,
+WriteUCD(cGH *GH, polypatch *totals, const char *fullname,
CCTK_REAL4 isolevel)
{
/* Write Iso's in AVS ascii UCD format */
@@ -855,29 +697,21 @@ WriteUCD(cGH *GH, polypatch *totals, par_st *parms, const char *fullname,
/***************************************************************************/
/* this is pretty redundant. Should be removed and just use doIso() */
-int IsoSurfacer_TimeForOutput(cGH *GH, int i)
-{
+int IsoSurfacer_TimeForOutput(cGH *GH, int i){
/* Get the GH extensions for IOUtil and IOASCII */
isosurfacerGH *myGH = (isosurfacerGH *)GH->extensions[CCTK_GHExtensionHandle("IsoSurfacer")];
-
if (!myGH)
- return false;
-
+ return 0;
/* do a check for new isosurfaces */
/* Perhaps do a bcast for "changed" flags.
which are embedded in each iso. */
-
return doIso(i, GH, myGH);
}
-int IsoSurfacer_TriggerOutput(cGH *GH,int variable)
-{
+int IsoSurfacer_TriggerOutput(cGH *GH,int variable){
isosurfacerGH *myGH;
-
myGH = (isosurfacerGH *) GH->extensions [CCTK_GHExtensionHandle ("IsoSurfacer")];
-
computeIso(variable,GH,myGH);
-
/* FIXME MAYBE
myGH->out1D_last[variable] = GH->cctk_iteration;
*/
diff --git a/src/IsoSurfacerGH.h b/src/IsoSurfacerGH.h
index 6612e6c..ac299e7 100644
--- a/src/IsoSurfacerGH.h
+++ b/src/IsoSurfacerGH.h
@@ -2,27 +2,39 @@
#ifndef __IsoSurface_GH_h_
#define __IsoSurface_GH_h_
+#include "cctk.h"
+
#define BIN 1
#define ASCII 2
#define UCD 4
#define VRML 8
#define SOCK 16
#define ISOHDF5 32
-#define NONE 64
+#define NONE 64 /* sounds kooky, but its for forcing the
+ surfacer to run without output for
+ benchmarking purposes */
+
+typedef struct polypatch
+{
+ CCTK_REAL4 *verts;
+ CCTK_INT4 nverts;
+ CCTK_INT4 *polys;
+ CCTK_INT4 npolys;
+} polypatch;
typedef struct isosurfacerGH
{
- char *funcName;
- CCTK_REAL4 isovalue;
+ char *funcName; /* will be an array of names & vals later */
+ CCTK_REAL isovalue; /* must be same as GF data for efficiency */
+ CCTK_REAL minval,maxval; /* range of this grid function */
short int formats;
short int outfreq;
short int firstIteration;
- short int resolution;
- short int uniq_verts;
short int RunIsoSurfacer;
+ polypatch perprocessor,totals; // un-collected geometry for this node
} isosurfacerGH;
-typedef isosurfacerGH isoparms_st;
+// typedef isosurfacerGH isoparms_st;
typedef enum {Byte=0,Int8=0,Int16=1,Int32=2,Int64=3,
Float32=4,Float64=5,
diff --git a/src/IsoSurfacerInit.c b/src/IsoSurfacerInit.c
index 3c2dcf9..c74698f 100644
--- a/src/IsoSurfacerInit.c
+++ b/src/IsoSurfacerInit.c
@@ -12,17 +12,23 @@
#include <cctk.h>
#include <cctk_Parameters.h>
-#include "IsoSurfacerGH.h"
#include "IsoSurfacerInit.h"
-isotimes_st isotimes; /* JMS: should not be a global */
-isotimes_st cdtimes;
-
/***************************************************************/
void *IsoSurfacer_SetupGH (tFleshConfig *config,
int convergence_level,
cGH *GH){
isosurfacerGH *myGH=(isosurfacerGH*)malloc(sizeof(isosurfacerGH));
+ /* initialize values */
+ myGH->funcName=0;
+ myGH->formats=0;
+ myGH->outfreq=0;
+ myGH->firstIteration=0;
+ myGH->isovalue=0.0;
+ myGH->perprocessor.verts = myGH->totals.verts = NULL;
+ myGH->perprocessor.nverts = myGH->totals.nverts = 0;
+ myGH->perprocessor.polys = myGH->totals.polys = NULL;
+ myGH->perprocessor.npolys = myGH->totals.npolys = 0;
return myGH;
}
@@ -36,7 +42,7 @@ int IsoSurfacer_InitGH (cGH *GH){
int outer_boundary_cutoff
char *outdir
*/
- int n,i;
+ int n,i;
isosurfacerGH *myGH;
myGH = (isosurfacerGH *) GH->extensions [CCTK_GHExtensionHandle ("IsoSurfacer")];
@@ -46,9 +52,13 @@ int IsoSurfacer_InitGH (cGH *GH){
myGH->formats=0;
myGH->outfreq=output_frequency;
myGH->firstIteration=output_start;
- myGH->resolution=1;
- myGH->uniq_verts=1;
myGH->isovalue=isovalue;
+ myGH->perprocessor.verts = myGH->totals.verts = NULL;
+ myGH->perprocessor.nverts = myGH->totals.nverts = 0;
+ myGH->perprocessor.polys = myGH->totals.polys = NULL;
+ myGH->perprocessor.npolys = myGH->totals.npolys = 0;
+ myGH->minval=0.0;
+ myGH->maxval=1.0;
for(i=0,n=CCTK_NumVars();i<n;i++){
char *fullname = CCTK_FullName (i);
@@ -78,8 +88,6 @@ int IsoSurfacer_InitGH (cGH *GH){
free (cmd);
}
/* otherwise, the outdir need not be created if it is '.' */
- memset(&isotimes, 0, sizeof(isotimes));
- memset(&cdtimes, 0, sizeof(cdtimes));
return 1;
}
@@ -91,61 +99,9 @@ void IsoSurfaceEnd(cGH *GH)
myGH = (isosurfacerGH *) GH->extensions [CCTK_GHExtensionHandle ("IsoSurfacer")];
if( myGH->RunIsoSurfacer == 0 )
return;
-
-#if 0
-
-
- myGH = (isosurfacerGH *) GH->extensions [CCTK_GHExtensionHandle ("IsoSurfacer")];
-
- /* Close Data Connections (If open) */
- if(myGH->datasocket) {
- CCTK_INT4 i=0;
- SendData(myGH->datasocket,"done",1,INT32,&i);
- delete static_cast<DataSender*>(myGH->datasocket);
- }
- if(myGH->commandsocket)
- delete static_cast<CommandReceiver*>(myGH->commandsocket);
-
-#endif // EXTERNAL_REMOTEIO
-
- printf("IsoSurfacer timing \n");
- printf("\n Total number of calls to the IsoSurfacer: %d\n", isotimes.ncalls);
- printf(" Time spent in IsoSurfacer:\n");
- printf(" Total real time : %.4f s\n",
- isotimes.realtime_total * 1.0 / CLK_TCK);
-#ifndef _WIN32
- printf(" Total user time : %.4f s\n",
- isotimes.tms_total.tms_utime * 1.0 / CLK_TCK);
- printf(" Total system time : %.4f s\n",
- isotimes.tms_total.tms_stime * 1.0 / CLK_TCK);
- printf(" Average real time per call : %.4f s\n",
- isotimes.realtime_total * 1.0 / CLK_TCK / isotimes.ncalls);
- printf(" Average user time per call : %.4f s\n",
- isotimes.tms_total.tms_utime * 1.0 / CLK_TCK / isotimes.ncalls);
- printf(" Average system time per call : %.4f s\n",
- isotimes.tms_total.tms_stime * 1.0 / CLK_TCK / isotimes.ncalls);
-#endif
- printf("\n Total number of calls to CollectData: %d\n", cdtimes.ncalls);
- printf(" Time spent in CollectData:\n");
- printf(" Total real time : %.4f s\n",
- cdtimes.realtime_total * 1.0 / CLK_TCK);
-#ifndef _WIN32
- printf(" Total user time : %.4f s\n",
- cdtimes.tms_total.tms_utime * 1.0 / CLK_TCK);
- printf(" Total system time : %.4f s\n",
- cdtimes.tms_total.tms_stime * 1.0 / CLK_TCK);
-#endif
- printf(" Average real time per call : %.4f s\n",
- cdtimes.realtime_total * 1.0 / CLK_TCK / cdtimes.ncalls);
-#ifndef _WIN32
- printf(" Average user time per call : %.4f s\n",
- cdtimes.tms_total.tms_utime * 1.0 / CLK_TCK / cdtimes.ncalls);
- printf(" Average system time per call : %.4f s\n",
- cdtimes.tms_total.tms_stime * 1.0 / CLK_TCK / cdtimes.ncalls);
- printf("--------------------------------------------------\n");
-#endif
}
+/* What the hell??? */
int IsoSurfacer_rfrTraverseGH (cGH *GH, int rfrpoint)
{
return 0;
diff --git a/src/IsoSurfacerInit.h b/src/IsoSurfacerInit.h
index a20b5ac..0a710e2 100644
--- a/src/IsoSurfacerInit.h
+++ b/src/IsoSurfacerInit.h
@@ -10,22 +10,7 @@
#endif
#include <limits.h>
-#include "common.h"
-
-typedef struct isotimes_str
-{
-#ifndef _WIN32
- struct tms tms_begin;
- struct tms tms_end;
- struct tms tms_total;
-#endif
-
- clock_t realtime_begin;
- clock_t realtime_end;
- clock_t realtime_total;
-
- CCTK_INT4 ncalls;
-} isotimes_st;
+#include "IsoSurfacerGH.h"
/* prototypes of functions to be registered */
void *IsoSurfacer_SetupGH (tFleshConfig *config, int convergence_level,cGH *GH);
diff --git a/src/NuSurfacer.c b/src/NuSurfacer.c
index d12aba8..8e12186 100644
--- a/src/NuSurfacer.c
+++ b/src/NuSurfacer.c
@@ -3,8 +3,7 @@
#endif
#include <stdlib.h>
#include <stdio.h>
-#include "common.h"
-#include "cctk.h"
+#include "IsoSurfacerGH.h"
#include "CactusPUGH/PUGH/src/include/pugh.h"
#include "NuSurfacer.h"
@@ -289,14 +288,24 @@ static TRIANGLE_CASES triCases[] = {
for(nvals+=lst->nelem;lst->nelem<nvals;lst->nelem++) \
lst->array[lst->nelem] = vals[lst->nelem]; }
-#define ComputePoints(pughGH, pindex,p1,p2) { int pointindex=pindex[0]; \
-p1[0]=(isofl)(i+xMapOffset[pointindex])*pughGH->dx0+pughGH->lx0;\
-p1[1]=(isofl)(j+yMapOffset[pointindex])*pughGH->dy0+pughGH->ly0;\
-p1[2]=(isofl)(k+zMapOffset[pointindex])*pughGH->dz0+pughGH->lz0;\
+#define ComputePoints(xcoords,ycoords,zcoords,pindex,p1,p2,xl,yl) { \
+int pointindex=pindex[0]; \
+int _ii,_jj,_kk,_idx;\
+_ii=i+xMapOffset[pointindex];\
+_jj=j+yMapOffset[pointindex];\
+_kk=k+zMapOffset[pointindex];\
+_idx=_ii+_jj*xl+_kk*yl;\
+p1[0]=(CCTK_REAL)xcoords[_idx];\
+p1[1]=(CCTK_REAL)ycoords[_idx];\
+p1[2]=(CCTK_REAL)zcoords[_idx];\
pointindex=pindex[1];\
-p2[0]=(isofl)(i+xMapOffset[pointindex])*pughGH->dx0+pughGH->lx0;\
-p2[1]=(isofl)(j+yMapOffset[pointindex])*pughGH->dy0+pughGH->ly0;\
-p2[2]=(isofl)(k+zMapOffset[pointindex])*pughGH->dz0+pughGH->lz0;}
+_ii=i+xMapOffset[pointindex];\
+_jj=j+yMapOffset[pointindex];\
+_kk=k+zMapOffset[pointindex];\
+_idx=_ii+_jj*xl+_kk*yl;\
+p2[0]=(CCTK_REAL)xcoords[_idx];\
+p2[1]=(CCTK_REAL)ycoords[_idx];\
+p2[2]=(CCTK_REAL)zcoords[_idx];}
#define SetEdgeMaskP(idx_,data_,value_,mask_) { \
register int _cmask=1; \
@@ -312,13 +321,13 @@ p2[2]=(isofl)(k+zMapOffset[pointindex])*pughGH->dz0+pughGH->lz0;}
}
#define AddInterpolatedVertex(isoval,idx,pindex,p1,p2,vertlist) { \
- isofl _v,_d,_p1val,_p2val; int _i; \
+ CCTK_REAL4 _v,_d,_p1val,_p2val; int _i; \
_p1val = data[idx+cellOffset[pindex[0]]]; \
_p2val = data[idx+cellOffset[pindex[1]]]; \
_d=(isoval-_p1val)/(_p2val-_p1val); \
for( _i=0;_i<3;_i++){ \
_v=(p2[_i]-p1[_i])*_d + p1[_i]; \
- ArrayAddElem(isofl,vertlist,_v); \
+ ArrayAddElem(CCTK_REAL4,vertlist,_v); \
} \
}
@@ -332,7 +341,7 @@ typedef struct IsoCell {
} IsoCell;
IsoCell *cellslice;
-DeclareArray(isofl,FloatArray); /* declare a list of floats for vertices */
+DeclareArray(CCTK_REAL4,FloatArray); /* declare a list of floats for vertices */
DeclareArray(CCTK_INT4,IntArray); /* declare a list of intes for triangle connectivity */
FloatArray *vertexlist;
IntArray *trianglelist;
@@ -361,14 +370,13 @@ static int isoCellVindex[12]={1,0,1,0,
1,0,1,0,
2,2,2,2};
-void InitCellArrays(cGH *GH){
+void InitCellArrays(nx,ny){
int i,j;
- int nx=GH->cctk_lsh [0],ny=GH->cctk_lsh [1];
int ix=1,iy=nx,iz=nx*ny;
cellslice = New(IsoCell,2*nx*ny); /* 2 slices */
for(i=0;i<nx*ny*2;i++)
for(j=0;j<3;j++) cellslice[i].v[j]=-1; /* init all verts */
- vertexlist = New(FloatArray,1); InitArray(isofl,vertexlist);
+ vertexlist = New(FloatArray,1); InitArray(CCTK_REAL4,vertexlist);
trianglelist = New(IntArray,1); InitArray(CCTK_INT4,trianglelist);
/* celloffset */
cellOffset[0] = 0;
@@ -388,31 +396,24 @@ void InitCellArrays(cGH *GH){
isoCellOffset[10]=-(ix); isoCellOffset[11]=0;/* -yx,-y,-x,0*/
}
-void NuFindSurface(cGH *GH, int index,CCTK_REAL isovalue,polypatch *results){
+void NuFindSurface(CCTK_REAL *data,
+ int nx,int ny,int nz,
+ CCTK_REAL *xcoords, CCTK_REAL *ycoords, CCTK_REAL *zcoords,
+ CCTK_REAL isovalue, polypatch *results){
static int initialized_nusurf=0;
TRIANGLE_CASES *triCase;
EDGE_LIST *edge;
int i,j,k,imax,jmax,kmax;
int timelevel;
int idx,nverts=0; /* vertex and triangle counters for offsets */
- CCTK_REAL *data;
- int nx=GH->cctk_lsh [0],ny=GH->cctk_lsh [1],nz=GH->cctk_lsh [2],slicesize,slicemodulo;
- pGH *pughGH;
-
- pughGH = PUGH_pGH (GH);
+ int slicesize,slicemodulo;
if(!initialized_nusurf){
initialized_nusurf=1;
- InitCellArrays(GH);
+ InitCellArrays(nx,ny);
}
ResetArray(vertexlist); /* zero the vertex count (but keep storage) */
ResetArray(trianglelist); /* zero the triangle count (but keep storage) */
-
- timelevel = CCTK_NumTimeLevelsFromVarI (index);
- if (timelevel > 0)
- timelevel--;
- data = (CCTK_REAL *) GH->data [index][timelevel];
-
/*****Sliceinit */
slicesize=nx*ny; slicemodulo=slicesize*2;
if(!cellslice) cellslice = New(IsoCell,slicemodulo);
@@ -426,7 +427,7 @@ void NuFindSurface(cGH *GH, int index,CCTK_REAL isovalue,polypatch *results){
int isocellidx;
int mask;
int edgenumber;
- isofl p1[3],p2[3];
+ CCTK_REAL4 p1[3],p2[3];
int isocellnum;
int isocellvindex; /* 12 maps to 3 */
int elem,*elemp;
@@ -455,7 +456,7 @@ void NuFindSurface(cGH *GH, int index,CCTK_REAL isovalue,polypatch *results){
elem=*elemp;
if(elem<0){ /* add that vertex */
elem=*elemp=nverts;
- ComputePoints(pughGH, edges[edgenumber],p1,p2);
+ ComputePoints(xcoords,ycoords,zcoords, edges[edgenumber],p1,p2,nx,slicesize);
AddInterpolatedVertex(isovalue,idx,edges[edgenumber],p1,p2,vertexlist);
nverts++;
}
diff --git a/src/NuSurfacer.h b/src/NuSurfacer.h
index 8636c60..f5c5c29 100644
--- a/src/NuSurfacer.h
+++ b/src/NuSurfacer.h
@@ -1,7 +1,10 @@
#ifndef _NUSURFACER_H_
#define _NUSURFACER_H_
-#include "common.h"
-void NuFindSurface(cGH *gh, int index,CCTK_REAL isovalue,polypatch *results);
+#include "IsoSurfacerGH.h"
+void NuFindSurface(CCTK_REAL *data,
+ int nx,int ny,int nz,
+ CCTK_REAL *xcoords, CCTK_REAL *ycoords, CCTK_REAL *zcoords,
+ CCTK_REAL isovalue, polypatch *results);
#endif
diff --git a/src/Sockets.c b/src/Sockets.c
index 88c67d7..9d8afb8 100644
--- a/src/Sockets.c
+++ b/src/Sockets.c
@@ -326,14 +326,14 @@ int Iso_Poll(cGH *cctkGH, long sec, long usec)
}
int IsoWriteDataToClients(const char *metadata,
- CCTK_INT8 size,
+ CCTK_INT4 size,
IsoType type,
CCTK_INT4 *data)
{
int retval;
- CCTK_INT8 i;
+ CCTK_INT4 i;
CCTK_INT4 datatype;
- CCTK_INT8 datasize;
+ CCTK_INT4 datasize;
isoSocket *this;
isoSocket *next;
diff --git a/src/common.h b/src/common.h
index 53db6d5..f4bb8a7 100644
--- a/src/common.h
+++ b/src/common.h
@@ -3,41 +3,6 @@
#include "cctk.h"
-#define X 0
-#define Y 1
-#define Z 2
-#define V 3
-
-#define NEW(n,what) ((what*)malloc((n)*sizeof(what)))
-/*
-#define REALLOC(object,n,what) \
- (object) = (what*)realloc((void *)(object), (n)*sizeof(what)); \
- if((object) == NULL) printf("IsoSurfacer: realloc failed!\n")
- */
-#define REALLOC(object,n,what) \
- if((object) != NULL) free(object); \
- (object) = NEW(n,what); \
- if((object) == NULL) printf("IsoSurfacer: REALLOC failed!\n")
-
-#define ABS(x) ((x) < 0 ? (-(x)) : (x))
-
-typedef CCTK_REAL4 isofl;
-typedef double extfl;
-
-typedef int machint;
-
-#define BIN 1
-#define ASCII 2
-#define UCD 4
-
-typedef struct
-{
- isofl *verts;
- CCTK_INT4 nverts;
- CCTK_INT4 *polys;
- CCTK_INT4 npolys;
-} polypatch;
-
typedef struct
{
@@ -50,7 +15,7 @@ typedef struct
CCTK_INT4 doEliminateSmallTriangles;
// CCTK_INT4 timestep; timestep information is really not required here!
- isofl minval;
+ isofl minval; // need to use cactus collective ops for this
isofl maxval;
} par_st;