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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
|
#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 "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));
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->resolution=1;
myGH->uniq_verts=1;
myGH->isovalue=isovalue;
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 '.' */
memset(&isotimes, 0, sizeof(isotimes));
memset(&cdtimes, 0, sizeof(cdtimes));
return 1;
}
/************************************************************/
void IsoSurfaceEnd(cGH *GH)
{
isosurfacerGH *myGH;
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
}
int IsoSurfacer_rfrTraverseGH (cGH *GH, int rfrpoint)
{
return 0;
}
|