diff options
author | jshalf <jshalf@bfcf8e34-485d-4d46-a995-1fd6fa6fb178> | 2000-09-26 07:44:10 +0000 |
---|---|---|
committer | jshalf <jshalf@bfcf8e34-485d-4d46-a995-1fd6fa6fb178> | 2000-09-26 07:44:10 +0000 |
commit | 1e52ae4f26cb5a7d1729f0867024bd3ad1ca44b3 (patch) | |
tree | a474f65bf276b3ce66b22f6fb637e2d15e4e7844 | |
parent | 5fba974c16f9bbf6e5e0cd7ec3ab09ec83a79218 (diff) |
More bugfixes and C++'ism removal.
Now it all compiles, but doesn't really talk to anything yet.
Sockets are next I guess.
git-svn-id: http://svn.cactuscode.org/arrangements/CactusPUGHIO/IsoSurfacer/trunk@4 bfcf8e34-485d-4d46-a995-1fd6fa6fb178
-rw-r--r-- | param.ccl | 4 | ||||
-rw-r--r-- | src/IsoSurfacer.c | 187 | ||||
-rw-r--r-- | src/IsoSurfacerGH.h | 36 | ||||
-rw-r--r-- | src/IsoSurfacerInit.c | 30 | ||||
-rw-r--r-- | src/NuSurfacer.h | 3 | ||||
-rw-r--r-- | src/common.h | 8 |
6 files changed, 122 insertions, 146 deletions
@@ -8,12 +8,12 @@ STRING output_format "What form to output the datasets" STEERABLE = ALWAYS .* :: "Comma separated list. Can be UCD, VRML, ASCII, SOCK or None" } "None" -STRING output_var "What Grid Function name to output" +STRING output_var "What Grid Function name to output" STEERABLE = ALWAYS { .* :: "Eventually a comma separated list, but now a single name" } "None" -CCTK_REAL4 isovalue "Isosurface value" STEERABLE = ALWAYS +CCTK_REAL isovalue "Isosurface value" STEERABLE = ALWAYS { .* :: "Any floating point value" } 1.0 diff --git a/src/IsoSurfacer.c b/src/IsoSurfacer.c index ab629d3..8baee5e 100644 --- a/src/IsoSurfacer.c +++ b/src/IsoSurfacer.c @@ -61,9 +61,9 @@ static void WriteASCII(cGH *GH, polypatch *totals, par_st *parms, static void WriteUCD(cGH *GH, polypatch *totals, par_st *parms, const char *fullname, CCTK_REAL4 isolevel); static void WriteSock(cGH *GH, polypatch *totals, par_st *parms, - const char *fullname, int isoindex, Isolevel&IL); + const char *fullname, int isoindex, CCTK_REAL4 isolevel); static void WriteHDF5(cGH *GH, polypatch *totals, par_st *parms, - const char *fullname, int isoindex, Isolevel&IL); + const char *fullname, int isoindex, CCTK_REAL4 isolevel); extern isotimes_st isotimes; extern isotimes_st cdtimes; @@ -73,7 +73,7 @@ extern isotimes_st cdtimes; /* Ugly global variables: Should move to the GH */ static polypatch perprocessor, totals; -static GridAll_st GridAll; +static GridAll_st GridAll; /* JMS: This is nutty... must get rid of this */ #ifdef CCTK_MPI static int print_time=0; static double taccum; @@ -271,114 +271,114 @@ static void computeIso(int i, cGH *GH, isosurfacerGH *myGH) /* is it really required to have this static here?? */ static par_st parms; char* fullname = CCTK_FullName (i); + int j; - isoparms_st *isofunc = myGH->isoparms; + isoparms_st *isofunc = myGH; /* if the do_iso flag is set */ /* then draw an iso for each level of surfaces requested */ - for (unsigned int j = 0; j < isofunc->isolevels.size(); j++) { - /* Do the bcast for nisolevels here */ - isotimes.ncalls++; + /* Do the bcast for nisolevels here */ + isotimes.ncalls++; #ifndef _WIN32 - isotimes.realtime_begin = times(&isotimes.tms_begin); + 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; - + + 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(); + t1=MPI_Wtime(); #endif - NuFindSurface(GH,i,parms.isovalue,&perprocessor); + 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); + 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); + + 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; - CollectData(GH, &perprocessor, &totals); + 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 (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 (verbose) + printf(" | IsoSurfacer: GF=%s, value %f,", + fullname, parms.isovalue); + + if(totals.nverts > 0) { if (verbose) - printf(" | IsoSurfacer: GF=%s, value %f,", - fullname, parms.isovalue); + printf("%d vertices, %d triangles\n", totals.nverts, totals.npolys); - if(totals.nverts > 0) { - - if (verbose) - printf("%d vertices, %d triangles\n", totals.nverts, totals.npolys); - - if(parms.outtype & BIN) - WriteBin(GH, &totals, &parms, fullname, isofunc->isolevels[j].value); - - if(parms.outtype & ASCII) - WriteASCII(GH, &totals, &parms, fullname, - isofunc->isolevels[j].value); - - if(parms.outtype & UCD) - WriteUCD(GH, &totals, &parms, fullname, isofunc->isolevels[j].value); - - if(parms.outtype & VRML) - WriteVRML(GH, &totals, &parms, fullname,isofunc->isolevels[j].value); - - if(parms.outtype & SOCK) - WriteSock(GH, &totals,&parms,fullname,j, isofunc->isolevels[j]); - - if(parms.outtype & ISOHDF5) - WriteHDF5(GH, &totals,&parms,fullname,j, isofunc->isolevels[j]); - - } else - printf(" no isosurface\n"); + if(parms.outtype & BIN) + WriteBin(GH, &totals, &parms, fullname, isofunc->isovalue); + if(parms.outtype & ASCII) + WriteASCII(GH, &totals, &parms, fullname, + isofunc->isovalue); - if(polybackup || vertbackup){ /* copy back datastructures */ - totals.polys=polybackup; - totals.verts=vertbackup; - } + if(parms.outtype & UCD) + WriteUCD(GH, &totals, &parms, fullname, isofunc->isovalue); + + if(parms.outtype & VRML) + WriteVRML(GH, &totals, &parms, fullname,isofunc->isovalue); + + if(parms.outtype & SOCK) + WriteSock(GH, &totals,&parms,fullname,j, isofunc->isovalue); + + if(parms.outtype & ISOHDF5) + WriteHDF5(GH, &totals,&parms,fullname,j, isofunc->isovalue); + + } else + printf(" no isosurface\n"); + + + if(polybackup || vertbackup){ /* copy back datastructures */ + totals.polys=polybackup; + 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); + 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; @@ -388,7 +388,7 @@ int IsoSurfacer(cGH *GH){ /* do a check for new isosurfaces */ /* Perhaps do a bcast for "changed" flags. which are embedded in each iso. */ - for (int i = 0; i<CCTK_NumVars (); i++) { /* for each Grid */ + 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 */ continue; @@ -400,7 +400,7 @@ int IsoSurfacer(cGH *GH){ "No storage assigned for '%s'", CCTK_VarName (i)); } } - return true; + return 1; } /***************************************************************************/ @@ -534,24 +534,23 @@ void CollectData(cGH *GH, polypatch *perprocessor, polypatch *totals) { void WriteSock(cGH *GH, polypatch *totals, par_st *parms, const char *fullname, int isoindex, - Isolevel&IsoL) + CCTK_REAL4 IsoValue) { +#if 0 /* Was: parms->timestep, which was callnumber from above. */ - sprintf(tmpstring," :%s[%u]=%f,%u range=%f:%f", - full_id,isoindex,parms->isovalue, + char tmpstring[128]; + sprintf(tmpstring," :%s[0]=%f,%u range=%f:%f", + fullname,parms->isovalue, GH->cctk_iteration, parms->minval,parms->maxval); puts(tmpstring); /********Now write vertices**********/ *tmpstring='v'; verts = totals->nverts > 0 ? totals->verts : tmpvert; -#if 0 /* disabled for now */ DS->sendData(tmpstring,3*totals->nverts,DataType::int2type(REMOTE_IO_FLOAT32),verts); -#endif /********Now write polygons**********/ *tmpstring='c'; polys = totals->npolys > 0 ? totals->polys : tmppoly; -#if 0 /* disabled for now */ DS->sendData(tmpstring,3*totals->npolys,DataType::int2type(REMOTE_IO_INT32),polys); #endif } @@ -559,7 +558,7 @@ void WriteSock(cGH *GH, polypatch *totals, par_st *parms, /***************************************************************************/ static void WriteHDF5(cGH *GH, polypatch *totals, par_st *parms, - const char *fullname, int isoindex, Isolevel&IsoL) + const char *fullname, int isoindex, CCTK_REAL4 IsoValue) { DECLARE_CCTK_PARAMETERS #ifdef CACTUSPUGHIO_IOHDF5 diff --git a/src/IsoSurfacerGH.h b/src/IsoSurfacerGH.h index 5e5de6b..63194a9 100644 --- a/src/IsoSurfacerGH.h +++ b/src/IsoSurfacerGH.h @@ -1,31 +1,6 @@ // The extensions to the GH structure from IsoSurfacer. #ifndef __IsoSurface_GH_h_ #define __IsoSurface_GH_h_ -struct Isolevel -{ - float value; - int Ncolorinfo; - union - { - struct - { - CCTK_REAL4 transparency, - ForeGround_red, ForeGround_green, ForeGround_blue, - BackGround_red, BackGround_green, BackGround_blue; - } - colors; - - CCTK_REAL4 colorinfo[7]; - }; - - Isolevel() - : value(0.0) - , Ncolorinfo(0) - { - for(int i=0; i<7; i++) - colorinfo[i] = 0.7; - } -}; #define BIN 1 #define ASCII 2 @@ -35,21 +10,18 @@ struct Isolevel #define ISOHDF5 32 #define NONE 64 -typedef struct isoparms_st +typedef struct isosurfacerGH { char *funcName; - CCTK_REAL4 isolevel; + CCTK_REAL4 isovalue; short int formats; short int outfreq; short int firstIteration; short int resolution; short int uniq_verts; short int RunIsoSurfacer; -} isoparms_st; +} isosurfacerGH; -struct isosurfacerGH -{ - isoparms_st isoparms; -}; +typedef isosurfacerGH isoparms_st; #endif // __IsoSurface_GH_h_ diff --git a/src/IsoSurfacerInit.c b/src/IsoSurfacerInit.c index ce2ca1c..3c2dcf9 100644 --- a/src/IsoSurfacerInit.c +++ b/src/IsoSurfacerInit.c @@ -12,8 +12,6 @@ #include <cctk.h> #include <cctk_Parameters.h> -#include "http_GHExtensions.hpp" - #include "IsoSurfacerGH.h" #include "IsoSurfacerInit.h" @@ -38,7 +36,7 @@ int IsoSurfacer_InitGH (cGH *GH){ int outer_boundary_cutoff char *outdir */ - int n; + int n,i; isosurfacerGH *myGH; myGH = (isosurfacerGH *) GH->extensions [CCTK_GHExtensionHandle ("IsoSurfacer")]; @@ -52,7 +50,7 @@ int IsoSurfacer_InitGH (cGH *GH){ myGH->uniq_verts=1; myGH->isovalue=isovalue; - for(i=0;i<CCTK_NumVars();i++){ + for(i=0,n=CCTK_NumVars();i<n;i++){ char *fullname = CCTK_FullName (i); if(CCTK_Equals (fullname, output_var)) myGH->funcName=output_var; @@ -60,14 +58,14 @@ int IsoSurfacer_InitGH (cGH *GH){ free(fullname); } - if(strstr(output_format,"UCD")) myGH->format|=UCD; - if(strstr(output_format,"ASCII")) myGH->format|=ASCII; - if(strstr(output_format,"BIN")) myGH->format|=BIN; - if(strstr(output_format,"SOCK")) myGH->format|=SOCK; - if(strstr(output_format,"HDF5")) myGH->format|=HDF5; - if(strstr(output_format,"VRML")) myGH->format|=VRML; - - if(myGH->funcName==0 || myGH->format==0) + if(strstr(output_format,"UCD")) myGH->formats|=UCD; + if(strstr(output_format,"ASCII")) myGH->formats|=ASCII; + if(strstr(output_format,"BIN")) myGH->formats|=BIN; + if(strstr(output_format,"SOCK")) myGH->formats|=SOCK; + if(strstr(output_format,"HDF5")) myGH->formats|=ISOHDF5; + if(strstr(output_format,"VRML")) myGH->formats|=VRML; + + if(myGH->funcName==0 || myGH->formats==0) myGH->RunIsoSurfacer = 0; else myGH->RunIsoSurfacer = 1; @@ -82,20 +80,20 @@ int IsoSurfacer_InitGH (cGH *GH){ /* otherwise, the outdir need not be created if it is '.' */ memset(&isotimes, 0, sizeof(isotimes)); memset(&cdtimes, 0, sizeof(cdtimes)); - return true; + return 1; } /************************************************************/ void IsoSurfaceEnd(cGH *GH) { - - + isosurfacerGH *myGH; + myGH = (isosurfacerGH *) GH->extensions [CCTK_GHExtensionHandle ("IsoSurfacer")]; if( myGH->RunIsoSurfacer == 0 ) return; #if 0 - isosurfacerGH *myGH; + myGH = (isosurfacerGH *) GH->extensions [CCTK_GHExtensionHandle ("IsoSurfacer")]; diff --git a/src/NuSurfacer.h b/src/NuSurfacer.h index 8089cdd..8636c60 100644 --- a/src/NuSurfacer.h +++ b/src/NuSurfacer.h @@ -1,8 +1,7 @@ #ifndef _NUSURFACER_H_ #define _NUSURFACER_H_ -#include "FindIsoSurface.h" -void InitCellArrays(cGH *gh); +#include "common.h" void NuFindSurface(cGH *gh, int index,CCTK_REAL isovalue,polypatch *results); #endif diff --git a/src/common.h b/src/common.h index ef17b67..53db6d5 100644 --- a/src/common.h +++ b/src/common.h @@ -55,4 +55,12 @@ typedef struct } par_st; +typedef struct GridAll_st +{ + cGH *GH; + int gfi; + int timelevel; + CCTK_REAL *x, *y, *z; +} GridAll_st; + #endif |