aboutsummaryrefslogtreecommitdiff
path: root/src/IsoSurfacerInit.c
blob: c74698f9bdcb7b3317eb02f65f9754dd1c412d73 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#ifndef	_WIN32
#include <time.h>
#include <unistd.h>
#endif

#include <ctype.h>

#include <cctk.h>
#include <cctk_Parameters.h>

#include "IsoSurfacerInit.h"

/***************************************************************/
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;
}

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,i;
  isosurfacerGH *myGH;
  myGH = (isosurfacerGH *) GH->extensions [CCTK_GHExtensionHandle ("IsoSurfacer")];
  
  printf("IsoInit\n");
  /* initialize values */
  myGH->funcName=0;
  myGH->formats=0;
  myGH->outfreq=output_frequency;
  myGH->firstIteration=output_start;
  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);
    if(CCTK_Equals (fullname, output_var)) 
      myGH->funcName=output_var;
    /* Maybe even set the GF here ? */
    free(fullname);
  }
  
  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;

  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 '.' */
  return 1;
}

/************************************************************/

void IsoSurfaceEnd(cGH *GH)
{
  isosurfacerGH *myGH;
  myGH = (isosurfacerGH *) GH->extensions [CCTK_GHExtensionHandle ("IsoSurfacer")];
  if( myGH->RunIsoSurfacer == 0 )
    return;
}

/* What the hell??? */
int IsoSurfacer_rfrTraverseGH (cGH *GH, int rfrpoint)
{
  return 0;
}