aboutsummaryrefslogtreecommitdiff
path: root/src/IsoSurfacerInit.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/IsoSurfacerInit.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/IsoSurfacerInit.c')
-rw-r--r--src/IsoSurfacerInit.c402
1 files changed, 33 insertions, 369 deletions
diff --git a/src/IsoSurfacerInit.c b/src/IsoSurfacerInit.c
index 5948426..ce2ca1c 100644
--- a/src/IsoSurfacerInit.c
+++ b/src/IsoSurfacerInit.c
@@ -1,7 +1,3 @@
-#ifndef TCP /* JMS addition */
-#define TCP
-#endif
-
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -16,34 +12,14 @@
#include <cctk.h>
#include <cctk_Parameters.h>
-//#include <cctk_DefineThorn.h>
-
-//#ifdef CACTUSNET_HTTP
-//#include "CactusNet/http/src/http_GHExtensions.hpp"
-//#endif
-
#include "http_GHExtensions.hpp"
-
#include "IsoSurfacerGH.h"
#include "IsoSurfacerInit.h"
-
-/* Some function forward declarations */
-CCTK_INT4 ParseIsoString(char *s, param_map&parms);
-CCTK_INT4 NumberOfItems(char *s, char *d);
-char *GetSubString(char *s, char *d, CCTK_INT4 n);
-
-isotimes_st isotimes;
+isotimes_st isotimes; /* JMS: should not be a global */
isotimes_st cdtimes;
-CCTK_INT4 RunIsoSurfacer;
-
-
-#ifdef CACTUSNET_HTTP
-CactusCommands::Client * IsosurfaceHttpClientCreator(CactusCommands::Reply*msgbuf, CactusCommands::CommandList&cmds );
-#endif
-
/***************************************************************/
void *IsoSurfacer_SetupGH (tFleshConfig *config,
int convergence_level,
@@ -54,6 +30,14 @@ void *IsoSurfacer_SetupGH (tFleshConfig *config,
int IsoSurfacer_InitGH (cGH *GH){
DECLARE_CCTK_PARAMETERS
+ /*
+ The above string declares the following parameters
+ char *output_format
+ int output_frequency
+ int output_start
+ int outer_boundary_cutoff
+ char *outdir
+ */
int n;
isosurfacerGH *myGH;
myGH = (isosurfacerGH *) GH->extensions [CCTK_GHExtensionHandle ("IsoSurfacer")];
@@ -62,47 +46,40 @@ int IsoSurfacer_InitGH (cGH *GH){
/* initialize values */
myGH->funcName=0;
myGH->formats=0;
- myGH->outfreq=1;
- myGH->firstIteration=1;
+ myGH->outfreq=output_frequency;
+ myGH->firstIteration=output_start;
myGH->resolution=1;
myGH->uniq_verts=1;
- myGH->RunIsoSurfacer = 0;
+ myGH->isovalue=isovalue;
- /* OK, this is ridiculous.
- Separate out the isostring components into
- separate things and end this craziness */
- if( (n = ParseIsoString(isosurfacer, myGH->isoparms)) == 0)
- return 0;
-
- RunIsoSurfacer = 1;
- /*
- doIso = 0;
-
- for (i=0; i<CCTK_NumVars (); i++) {
+ for(i=0;i<CCTK_NumVars();i++){
char *fullname = CCTK_FullName (i);
-
- for(j=0; j<n; j++)
- if(CCTK_Equals (fullname, allparms[j].funcName) ) {
- doIso = 1;
- myGH->do_iso [i] = 1;
- myGH->isoparms [i] = allparms[j];
- if((allparms[j]).formats&SOCK){
- printf("usesockets**********\n");
- }
- break;
- }
- free (fullname);
+ if(CCTK_Equals (fullname, output_var))
+ myGH->funcName=output_var;
+ /* Maybe even set the GF here ? */
+ free(fullname);
}
-*/
-
- if (CCTK_MyProc (GH) == 0){
+
+ 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)
+ myGH->RunIsoSurfacer = 0;
+ else
+ myGH->RunIsoSurfacer = 1;
+
+ if (CCTK_MyProc (GH) == 0 && strcmp(outdir,".")){
char *cmd = (char *) malloc (strlen (outdir) + 80);
-
sprintf (cmd, "mkdir -p %s", outdir);
if (system (cmd) < 0)
CCTK_WARN (1, "Problem creating IsoSurfacer output directory");
free (cmd);
}
+ /* otherwise, the outdir need not be created if it is '.' */
memset(&isotimes, 0, sizeof(isotimes));
memset(&cdtimes, 0, sizeof(cdtimes));
return true;
@@ -114,7 +91,7 @@ void IsoSurfaceEnd(cGH *GH)
{
- if( RunIsoSurfacer == 0 )
+ if( myGH->RunIsoSurfacer == 0 )
return;
#if 0
@@ -176,319 +153,6 @@ int IsoSurfacer_rfrTraverseGH (cGH *GH, int rfrpoint)
return 0;
}
-/*****************************************************************************/
-
-CCTK_INT4 ParseIsoString(char *s, param_map&allparms)
-{
- CCTK_INT4 i, j;
- CCTK_INT4 n, m;
- CCTK_INT4 nlevels, nformats;
- char *sub0, *sub1, *sub2;
-
-
-
- /* First see how many functions we have */
- /* by simply counting the number of {} pairs */
- n = NumberOfItems(s, "{}");
-
- if(n == 0)
- {
- printf("Isosurfacer: empty parameter string '%s'\n", s);
- return 0;
- }
-
- /* Allocate that many isoparms structs */
-// *allparms = NEW(n, isoparms_st);
-
- /* Now fill in each isoparms struct with the info for each function */
- for(i=0; i<n; i++)
- {
- sub0 = GetSubString(s, "{}", i);
-
- /* Check that we have the right number of () pairs */
- m = NumberOfItems(sub0, "()");
-
- if(m != 4)
- {
- printf("Isosurfacer: improperly formed parameter string '%s'\n", s);
- printf(" there should be exactly 4 () pairs\n");
- free(sub0);
- return 0;
- }
-
- /*- 1 -----------------------------------------------------------------*/
- /* The first () pair contains the function name */
- char*gridfunc = GetSubString(sub0, "()", 0);
-
- isoparms_st*gridparams = new isoparms_st();
-
- allparms[gridfunc] = gridparams ;
-
- gridparams->funcName = gridfunc;
-
-
- /*- 2 -----------------------------------------------------------------*/
- /* The second () pair contains the list of isosurface levels */
- sub1 = GetSubString(sub0, "()", 1);
-
- /* First see how many there are by counting the number of commas + 1 */
- nlevels = NumberOfItems(sub1, ",");
-
- /* and get the values */
- for(j=0; j<nlevels; j++)
- {
- sub2 = GetSubString(sub1, ",", j);
- gridparams->isolevels.push_back( Isolevel() );
-
- gridparams->isolevels.back().value = atof(sub2);
-
- gridparams->isolevels.back().Ncolorinfo = 0;
-
- char*N = strchr(sub2, ':');
- if (N)
- {
- N++;
- int Nvalues = NumberOfItems(N, "/");
- if (Nvalues > 7 )
- Nvalues = 7;
-
- for(int k=0; k<Nvalues; k++)
- {
- char*sub3 = GetSubString(N, "/", k);
- char*number = sub3;
- while(*number && !isdigit(*number)) number++;
- gridparams->isolevels.back().colorinfo[k] = atof(number);
- free(sub3);
- }
-
- gridparams->isolevels.back().Ncolorinfo = Nvalues;
- }
-
- free(sub2);
- }
- free(sub1);
- /*- 3 -----------------------------------------------------------------*/
- /* The third () pair contains the list of output formats */
- sub1 = GetSubString(sub0, "()", 2);
-
- /* See how many there are by counting the number of commas + 1 */
- nformats = NumberOfItems(sub1, ",");
-
- /* and get the values */
- gridparams->formats = 0;
- for(j=0; j<nformats; j++)
- {
- sub2 = GetSubString(sub1, ",", j);
- if( !strcmp(sub2, "BIN") )
- gridparams->formats |= BIN;
- else if (!strcmp(sub2, "VRML"))
- gridparams->formats |= VRML;
- else if (!strcmp(sub2, "ASCII"))
- gridparams->formats |= ASCII;
- else if (!strcmp(sub2, "UCD")){
-#ifdef VERBOSE
- printf("UCD found in formats string\n");
-#endif
- gridparams->formats |= UCD;
- }
- else if (!strcmp(sub2,"SOCK")){ /* JMS addition */
-#ifdef VERBOSE
- printf("SOCK found in formats string for %d\n",i);
-#endif
- gridparams->formats |= SOCK;
- }
- else if (!strcmp(sub2,"ISOHDF5")){ /* TR addition */
-#ifdef VERBOSE
- printf("HDF5 found in formats string for %d\n",i);
-#endif
- gridparams->formats |= ISOHDF5;
- }
- else if(!strcmp(sub2,"NONE")){
-#ifdef VERBOSE
- printf("NONE string found in formats string\n");
-#endif
- gridparams->formats |= NONE;
- }
- else
- {
- printf("Isosurfacer: invalid output format '%s'\n", sub2);
- printf(" supported formats are: BIN, VRML, ASCII, UCD, SOCK\n");
- free(sub2);
- free(sub1);
- free(sub0);
- return 0;
- }
- free(sub2);
- }
-
- free(sub1);
-
-
- /*- 4 -----------------------------------------------------------------*/
- /* The fourth () pair contains the other various parameters */
- sub1 = GetSubString(sub0, "()", 3);
-
- /* Check that the amount of them is correct (=4) */
- if( NumberOfItems(sub1, ",") != 4)
- {
- printf("Isosurfacer: improperly formed parameter string '%s'\n", s);
- printf(" there should be exactly 4 parameters in the last () pair\n");
- free(sub1);
- free(sub0);
- return 0;
- }
-
- /* The first one is the frequency of output */
- sub2 = GetSubString(sub1, ",", 0);
- gridparams->outfreq = (CCTK_INT4)atoi(sub2);
- free(sub2);
-
- /* Then the first iteration */
- sub2 = GetSubString(sub1, ",", 1);
- gridparams->firstIteration = (CCTK_INT4)atoi(sub2);
- free(sub2);
-
- /* Then the resolution */
- sub2 = GetSubString(sub1, ",", 2);
- gridparams->resolution = (CCTK_INT4)atoi(sub2);
- free(sub2);
-
- /* And finally the "uniq_vertices" flag */
- sub2 = GetSubString(sub1, ",", 3);
- gridparams->uniq_verts = (CCTK_INT4)atoi(sub2);
- free(sub2);
-
- free(sub1);
-
- free(sub0);
- }
-
- return n;
-}
-
-/*****************************************************************************/
-
-CCTK_INT4
-NumberOfItems(char *s, char *d)
-{
- int ld, i;
- int result;
- char *p;
-
- result = 0;
- ld = strlen(d);
-
- switch(ld)
- {
- case 1:
- p = s;
- while( *p != '\0' )
- {
- if( *p++ == d[0] )
- result++;
- }
- if( p != s )
- result++;
- return result;
-
- case 2:
- p = s;
- i = 0;
- while( *p != '\0' )
- {
- if ( *p++ == d[i] )
- {
- result++;
- i = (i==0)?1:0;
- }
- }
- if( (result % 2) != 0 )
- return 0;
- else
- return result/2;
-
- default:
- return 0;
- }
-}
-
-/*****************************************************************************/
-
-char *
-GetSubString(char *s, char *d, CCTK_INT4 n)
-{
- int ld, count, i;
- char *result;
- char *p, *q = NULL;
-
- result = NULL;
- ld = strlen(d);
-
- p = s;
- count = 0;
- switch(ld)
- {
- case 1:
- q = p;
- while( *p != '\0' )
- {
- if( *p++ == d[0] )
- {
- if(count == n)
- break;
- else
- {
- count++;
- q = p;
- }
- }
- }
- if(*p == '\0')
- p++;
- break;
-
- case 2:
- i = 0;
- while( *p != '\0' )
- {
- if ( *p++ == d[i] )
- {
- if(i==0)
- {
- q = p;
- }
- else
- {
- if(count == n)
- break;
- else
- count++;
- }
- i = (i==0)?1:0;
- }
- }
- break;
-
- default:
- return NULL;
- }
-
- if(count == n)
- {
- while( *q == ' ' )
- q++;
- p-=2;
- while( *p == ' ' )
- p--;
- p++;
- result = NEW((p-q+1), char);
- strncpy(result, q, p-q);
- result[p-q] = '\0';
- }
- return result;
-}
-
-/**********************************************************/