-
Notifications
You must be signed in to change notification settings - Fork 1
/
getData.c
executable file
·91 lines (82 loc) · 2.45 KB
/
getData.c
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
/* Title: getting Data from simulation snapshot
# Author: Vatsal Sanjay
# Physics of Fluids
*/
#include "axi.h"
#include "navier-stokes/centered.h"
#include "fractions.h"
char filename[80];
int nx, ny, len;
double xmin, ymin, xmax, ymax, Deltax, Deltay, Ohf, Ohd, Ohs;
scalar f1[], f2[], D2c[], vel[];
scalar * list = NULL;
int main(int a, char const *arguments[])
{
sprintf (filename, "%s", arguments[1]);
xmin = atof(arguments[2]); ymin = atof(arguments[3]);
xmax = atof(arguments[4]); ymax = atof(arguments[5]);
ny = atoi(arguments[6]);
Ohf = atof(arguments[7]); Ohd = atof(arguments[8]);
Ohs = atof(arguments[9]);
list = list_add (list, D2c);
list = list_add (list, vel);
// boundary conditions
/*
Actual run and codes!
*/
restore (file = filename);
f1.prolongation = fraction_refine;
f2.prolongation = fraction_refine;
boundary((scalar *){f1, f2, u.x, u.y});
foreach() {
double D11 = (u.y[0,1] - u.y[0,-1])/(2*Delta);
double D22 = (u.y[]/y);
double D33 = (u.x[1,0] - u.x[-1,0])/(2*Delta);
double D13 = 0.5*( (u.y[1,0] - u.y[-1,0] + u.x[0,1] - u.x[0,-1])/(2*Delta) );
double D2 = sq(D11)+sq(D22)+sq(D33)+2.0*sq(D13);
D2c[] = 2*(clamp(f1[]*(1-f2[]), 0., 1.) * Ohf + clamp(f1[]*f2[], 0., 1.) * Ohd + clamp((1-f1[]), 0., 1.) * Ohs)*D2;
if (D2c[] > 0.){
D2c[] = log(D2c[])/log(10);
} else {
D2c[] = -10;
}
vel[] = sqrt(sq(u.x[])+sq(u.y[]));
}
boundary ((scalar *){D2c, vel});
FILE * fp = ferr;
Deltay = (double)(ymax-ymin)/(ny);
// fprintf(ferr, "%g\n", Deltay);
nx = (int)(xmax - xmin)/Deltay;
// fprintf(ferr, "%d\n", nx);
Deltax = (double)(xmax-xmin)/(nx);
// fprintf(ferr, "%g\n", Deltax);
len = list_len(list);
// fprintf(ferr, "%d\n", len);
double ** field = (double **) matrix_new (nx, ny+1, len*sizeof(double));
for (int i = 0; i < nx; i++) {
double x = Deltax*(i+1./2) + xmin;
for (int j = 0; j < ny; j++) {
double y = Deltay*(j+1./2) + ymin;
int k = 0;
for (scalar s in list){
field[i][len*j + k++] = interpolate (s, x, y);
}
}
}
for (int i = 0; i < nx; i++) {
double x = Deltax*(i+1./2) + xmin;
for (int j = 0; j < ny; j++) {
double y = Deltay*(j+1./2) + ymin;
fprintf (fp, "%g %g", x, y);
int k = 0;
for (scalar s in list){
fprintf (fp, " %g", field[i][len*j + k++]);
}
fputc ('\n', fp);
}
}
fflush (fp);
fclose (fp);
matrix_free (field);
}