aboutsummaryrefslogtreecommitdiff
path: root/src/IsoSurfacer.c
diff options
context:
space:
mode:
authorjshalf <jshalf@bfcf8e34-485d-4d46-a995-1fd6fa6fb178>2000-09-26 05:05:56 +0000
committerjshalf <jshalf@bfcf8e34-485d-4d46-a995-1fd6fa6fb178>2000-09-26 05:05:56 +0000
commit5fba974c16f9bbf6e5e0cd7ec3ab09ec83a79218 (patch)
treedeef203e34a327778c1e7d056be310c95ee3fa52 /src/IsoSurfacer.c
parent1a826b78b503406ab21d25148e52c7547a0e578a (diff)
More code reorganization and removal of C++ items.
git-svn-id: http://svn.cactuscode.org/arrangements/CactusPUGHIO/IsoSurfacer/trunk@3 bfcf8e34-485d-4d46-a995-1fd6fa6fb178
Diffstat (limited to 'src/IsoSurfacer.c')
-rw-r--r--src/IsoSurfacer.c127
1 files changed, 47 insertions, 80 deletions
diff --git a/src/IsoSurfacer.c b/src/IsoSurfacer.c
index 0ba1c99..ab629d3 100644
--- a/src/IsoSurfacer.c
+++ b/src/IsoSurfacer.c
@@ -70,14 +70,14 @@ extern isotimes_st cdtimes;
/***************************************************************************/
-/// Ugly global variables
+/* Ugly global variables: Should move to the GH */
- static polypatch perprocessor, totals;
- static GridAll_st GridAll;
+static polypatch perprocessor, totals;
+static GridAll_st GridAll;
#ifdef CCTK_MPI
- static int print_time=0;
- static double taccum;
- double t1;
+static int print_time=0;
+static double taccum;
+double t1;
#endif
#ifndef true
@@ -252,49 +252,32 @@ static int IsoSurfacerHandleCommands(cGH *GH)
return 0;
}
-static bool doIso(int i, cGH *GH, isosurfacerGH *myGH)
+static int doIso(int i, cGH *GH, isosurfacerGH *myGH)
{
/* need to rediscover how to mess with this */
-#if 0
- char* fullname = CCTK_FullName (i);
- /* see if we are to iterate on this GH.*/
- param_map::iterator it = myGH->isoparms.find( fullname );
- free (fullname);
-
- if (it == myGH->isoparms.end() || !(*it).second)
- return false;
-
- isoparms_st&myIso = *(*it).second;
-
- int firstiter = myIso.firstIteration;
- if(GH->cctk_iteration < firstiter)
- return false;
- int itiso = myIso.outfreq;
- if (!(itiso && (GH->cctk_iteration - firstiter) % itiso == 0))
- return false;
- return true;
-#endif
- return false;
+ char *fullname = CCTK_FullName (i);
+ if(!strcmp(fullname,myGH->funcName)){
+ if(myGH->firstIteration<=GH->cctk_iteration &&
+ !((GH->cctk_iteration-myGH->firstIteration) % myGH->outfreq))
+ return 1;
+ }
+ return 0;
}
static void computeIso(int i, cGH *GH, isosurfacerGH *myGH)
{
DECLARE_CCTK_PARAMETERS
-
- char* fullname = CCTK_FullName (i);
-
- isoparms_st*ptrIsofunc = myGH->isoparms[ fullname ];
-
- if (!ptrIsofunc)
- return;
+ /* is it really required to have this static here?? */
+ static par_st parms;
+ char* fullname = CCTK_FullName (i);
- isoparms_st&isofunc = *ptrIsofunc;
+ isoparms_st *isofunc = myGH->isoparms;
/* 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++) {
+ for (unsigned int j = 0; j < isofunc->isolevels.size(); j++) {
/* Do the bcast for nisolevels here */
isotimes.ncalls++;
#ifndef _WIN32
@@ -308,25 +291,20 @@ static void computeIso(int i, cGH *GH, isosurfacerGH *myGH)
if (GridAll.timelevel > 0)
GridAll.timelevel--;
-
- // is it really required to have this static here??
- static par_st parms;
-
+ /* This needs to be removed.
+ should just use isoparms_st everywhere */
parms.outfname = NULL;
- parms.outtype = isofunc.formats;
- parms.isovalue = (CCTK_REAL4)isofunc.isolevels[j].value;
- parms.step = isofunc.resolution;
- parms.doRemoveDuplicateVertices = isofunc.uniq_verts;
+ 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
- if(nusurfacer) /* use the new isosurfacer */
- NuFindSurface(GH,i,parms.isovalue,&perprocessor);
- else /* use the old isosurfacer */
- FindIsoSurface(GH, (void *)&GridAll, &perprocessor, &parms);
+ NuFindSurface(GH,i,parms.isovalue,&perprocessor);
#ifdef CCTK_MPI
taccum += (MPI_Wtime()-t1);
if(print_time)
@@ -359,23 +337,23 @@ static void computeIso(int i, cGH *GH, isosurfacerGH *myGH)
printf("%d vertices, %d triangles\n", totals.nverts, totals.npolys);
if(parms.outtype & BIN)
- WriteBin(GH, &totals, &parms, fullname, isofunc.isolevels[j].value);
+ WriteBin(GH, &totals, &parms, fullname, isofunc->isolevels[j].value);
if(parms.outtype & ASCII)
WriteASCII(GH, &totals, &parms, fullname,
- isofunc.isolevels[j].value);
+ isofunc->isolevels[j].value);
if(parms.outtype & UCD)
- WriteUCD(GH, &totals, &parms, fullname, isofunc.isolevels[j].value);
+ WriteUCD(GH, &totals, &parms, fullname, isofunc->isolevels[j].value);
if(parms.outtype & VRML)
- WriteVRML(GH, &totals, &parms, fullname,isofunc.isolevels[j].value);
+ WriteVRML(GH, &totals, &parms, fullname,isofunc->isolevels[j].value);
if(parms.outtype & SOCK)
- WriteSock(GH, &totals,&parms,fullname,j, isofunc.isolevels[j]);
+ WriteSock(GH, &totals,&parms,fullname,j, isofunc->isolevels[j]);
if(parms.outtype & ISOHDF5)
- WriteHDF5(GH, &totals,&parms,fullname,j, isofunc.isolevels[j]);
+ WriteHDF5(GH, &totals,&parms,fullname,j, isofunc->isolevels[j]);
} else
printf(" no isosurface\n");
@@ -411,7 +389,7 @@ int IsoSurfacer(cGH *GH){
/* Perhaps do a bcast for "changed" flags.
which are embedded in each iso. */
for (int i = 0; i<CCTK_NumVars (); i++) { /* for each Grid */
- if (!doIso(i, GH, myGH))
+ if (!doIso(i, GH, myGH)) /* JMS still must translate this GH extension flag */
continue;
if (CCTK_QueryGroupStorageI(GH,CCTK_GroupIndexFromVarI(i))) {
@@ -495,12 +473,14 @@ void CollectData(cGH *GH, polypatch *perprocessor, polypatch *totals) {
totals->nverts /= 3;
totals->npolys /= 3;
-
/*
Kludge by M. Panea:
- Allocate 3 more than necessary so as to divert the output of processors
+ Allocate 3 more than necessary so as to divert
+ the output of processors
with nverts=0 to a dummy area in the upper part of totals->verts.
Otherwise the MPI_Gatherv routine gives lots of problems.
+ This is problem which is particular to the T3E native
+ implementation of MPI.
*/
if(lastNverts < totals->nverts){
REALLOC(totals->verts, 3+3*totals->nverts, CCTK_REAL4);
@@ -556,21 +536,24 @@ void WriteSock(cGH *GH, polypatch *totals, par_st *parms,
const char *fullname, int isoindex,
Isolevel&IsoL)
{
- // Was: parms->timestep, which was callnumber from above.
+ /* Was: parms->timestep, which was callnumber from above. */
sprintf(tmpstring," :%s[%u]=%f,%u range=%f:%f",
full_id,isoindex,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
}
/***************************************************************************/
@@ -587,6 +570,7 @@ static void WriteHDF5(cGH *GH, polypatch *totals, par_st *parms,
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 */
IOHDF5_WriteIsosurface (GH, filename, fullname,
(CCTK_INT) GH->cctk_iteration,
(CCTK_INT) GridAll.timelevel,
@@ -594,8 +578,8 @@ static void WriteHDF5(cGH *GH, polypatch *totals, par_st *parms,
(CCTK_REAL) parms->minval, (CCTK_REAL) parms->maxval,
(int) totals->npolys, totals->polys,
(int) totals->nverts, totals->verts);
+#endif
free (filename);
-
#else
CCTK_WARN (1, "No HDF5 isosurface output because CactusPUGHIO/IOHDF5 was not compiled in !");
@@ -857,7 +841,7 @@ 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)
{
/* Get the GH extensions for IOUtil and IOASCII */
@@ -870,24 +854,7 @@ int IsoSurfacer_TimeForOutput(cGH *GH, int i)
/* Perhaps do a bcast for "changed" flags.
which are embedded in each iso. */
- return doIso(i, GH, myGH);
-
-/*
-
- if (! myGH->do_iso[i])
- return 0;
-
-int firstiter = myGH->isoparms[i].firstIteration;
- if(GH->cctk_iteration < firstiter)
- return 0;
-
-int itiso = myGH->isoparms[i].outfreq;
- if (!(itiso && (GH->cctk_iteration - firstiter) % itiso == 0))
- return 0;
-
- return 1;
-*/
-
+ return doIso(i, GH, myGH);
}
int IsoSurfacer_TriggerOutput(cGH *GH,int variable)