@@ -19,7 +19,7 @@ Kyle Konrad
19
19
20
20
// vergini code dependencies
21
21
#include "../vergini/billiard.h"
22
- ;
22
+ extern int verb ;
23
23
24
24
// options specified by command line arguments
25
25
int showTime = 0 ; // flag: print time it takes for countNodalDomains to run
@@ -29,6 +29,7 @@ int mode = -1; // 0 - generate random_percolation grid; 1 - read grid from sta_b
29
29
int maskFlag = 0 ; // flag: use a mask file
30
30
char * maskFile ; // use mask from this file
31
31
int oneFlag = 0 ; // flag: only count one eigenfunction
32
+ int sizeFlag = 0 ; // flag: write domain sizes to file
32
33
33
34
Billiard bil ; // Billiard shape we are using - defined in vergini code
34
35
double dx = -1 ; // grid spacing
@@ -42,11 +43,13 @@ int interp = 1; // boolean whether or not to interpolate
42
43
print a usage statement
43
44
*/
44
45
void usage () {
45
- fprintf (stderr , "USAGE: count -f file [-m maskFile | {-l billiardType -d dx [-k k_0] -M besselOrder -u upsample}] [-t] [-o] [-1] [-n]\n" );
46
+ fprintf (stderr , "USAGE: count -f file [-m maskFile | {-l billiardType -d dx [-k k_0] -M besselOrder -u upsample}] [-t] [-o] [-1] [-n] [-q] [-s] \n" );
46
47
fprintf (stderr , "-t: show timing info\n" );
47
48
fprintf (stderr , "-o: output grid to file\n" );
48
49
fprintf (stderr , "-1: only count first eigenfunction\n" );
49
50
fprintf (stderr , "-n: do not use interpolation\n" );
51
+ fprintf (stderr , "-q: quiet\n" );
52
+ fprintf (stderr , "-s: output nodal domain sizes to file\n" );
50
53
}
51
54
52
55
/*
@@ -63,16 +66,14 @@ void count_processArgs(int argc, char **argv) {
63
66
exit (CMD_LINE_ARG_ERR );
64
67
}
65
68
66
- while ((c = getopt (argc , argv , "f:m:l:d:k:M:u:to1n " )) != -1 ) {
69
+ while ((c = getopt (argc , argv , "f:m:l:d:k:M:u:to1nqs " )) != -1 ) {
67
70
switch (c ) {
68
71
case 'f' :
69
- file = (char * )malloc (strlen (optarg )* sizeof (char ));
70
- strcpy (file , optarg );
72
+ SET (file , optarg );
71
73
mode = 1 ;
72
74
break ;
73
75
case 'm' :
74
- maskFile = (char * )malloc (strlen (optarg )* sizeof (char ));
75
- strcpy (maskFile , optarg );
76
+ SET (maskFile , optarg );
76
77
maskFlag = 1 ;
77
78
break ;
78
79
case 'l' :
@@ -107,6 +108,12 @@ void count_processArgs(int argc, char **argv) {
107
108
case 'n' :
108
109
interp = 0 ;
109
110
break ;
111
+ case 'q' :
112
+ verb = 0 ;
113
+ break ;
114
+ case 's' :
115
+ sizeFlag = 1 ;
116
+ break ;
110
117
case '?' :
111
118
switch (optopt ) {
112
119
case 'f' :
@@ -162,16 +169,21 @@ void count_processArgs(int argc, char **argv) {
162
169
*/
163
170
int runTest (double * * grid , char * * mask , int ny , int nx , double k , double dx , int besselOrder , int upsample , interp_stats * stats ) {
164
171
char sizefilename [50 ];
165
- sprintf (sizefilename , "sizes_%f_%f.dat" , k , dx );
166
- FILE * sizefile = fopen (sizefilename , "w" );
172
+ FILE * sizefile = NULL ;
173
+ if (sizeFlag ) {
174
+ sprintf (sizefilename , "sizes_%f_%f.dat" , k , dx );
175
+ sizefile = fopen (sizefilename , "w" );
176
+ }
167
177
int nd ;
168
178
if (interp ) {
169
179
nd = countNodalDomainsInterp (grid , mask , ny , nx , k , dx , besselOrder , upsample , stats , sizefile );
170
180
}
171
181
else {
172
182
nd = countNodalDomainsNoInterp (grid , mask , ny , nx , sizefile );
173
183
}
174
- fclose (sizefile );
184
+ if (sizeFlag ) {
185
+ fclose (sizefile );
186
+ }
175
187
return nd ;
176
188
}
177
189
@@ -215,8 +227,7 @@ int count_main(int argc, char **argv) {
215
227
free (maskFile );
216
228
}
217
229
218
- printf ("%s\t%s\t%s\t%s\t%s\n" , "k" , "count" , "small domains" , "interp count" , "boundary trouble count" , "edge trouble count" );
219
- printf ("%f\t%d\t%d\t%d\t%d\n" , k_0 , count , stats .small_domain_count , stats .interp_count , stats .boundary_trouble_count , stats .edge_trouble_count );
230
+ printf ("%f,%f,%d,%d,%d,%d\n" , k_0 , dx , count , stats .small_domain_count , stats .interp_count , stats .boundary_trouble_count , stats .edge_trouble_count );
220
231
221
232
}
222
233
0 commit comments