-
Notifications
You must be signed in to change notification settings - Fork 0
/
getData-elastic-scalar2D.c
executable file
·100 lines (85 loc) · 2.32 KB
/
getData-elastic-scalar2D.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
92
93
94
95
96
97
98
99
100
/* Title: getting Data from simulation snapshot
# Author: Vatsal Sanjay
# Physics of Fluids
*/
#include "utils.h"
#include "output.h"
scalar f[];
vector u[];
scalar A11[], A12[], A22[]; // conformation tensor
scalar AThTh[];
char filename[80];
int nx, ny, len;
double xmin, ymin, xmax, ymax, Deltax, Deltay;
scalar D2c[], vel[], trA[];
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]);
list = list_add (list, D2c);
list = list_add (list, vel);
list = list_add (list, trA);
/*
Actual run and codes!
*/
restore (file = filename);
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[] = f[]*D2;
if (D2c[] > 0.){
D2c[] = log(D2c[])/log(10);
} else {
D2c[] = -10;
}
vel[] = sqrt(sq(u.x[])+sq(u.y[]));
trA[] = (A11[] + A22[] + AThTh[])/3.0 - 1.0;
if (trA[] > 0.){
trA[] = log(trA[])/log(10);
} else {
trA[] = -10;
}
}
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);
}