-
Notifications
You must be signed in to change notification settings - Fork 1
/
Init.c
121 lines (64 loc) · 1.22 KB
/
Init.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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include "Global.h"
#include "par.h"
// DRIVER FOR THE INITIAL CONDITIONS
/*
int Driver(){
switch(IFLOWNUM){
case 1:
AdvecInit();
break;
}
}
*/
float InitCond( double x){
double answer;
switch(iTest){
case 0:
answer = 2.0;
break;
case 1:
answer = sin(2.0*PI*x);
break;
case 2:
if(x<0.25 || x>0.75){
answer = 0;
}
else{
answer = 1;
}
break;
default:
printf("this init doesn't exist \n");
exit(EXIT_FAILURE);
break;
}
return (answer);
}
float AdvecInit(){
int i, p, j,k;
float c, midpoint, X_Points;
double answer;
midpoint = IEL_SIZE/2.0;
for (i=1; i<IELEM; i++) {
for (k=0; k<IFLOWNUM; k++) {
for (p=0; p<IORDER; p++) {
sol[i][p][k] = 0.0;
for (j=0; j<6; j++) {
X_Points = midpoint + 0.5*IEL_SIZE*rXg[j];
sol[i][p][k] = sol[i][p][k] + InitCond((double)X_Points)*Basis(p,rXg[j])*rWg[j];
} // quad
sol[i][p][k] = sol[i][p][k]/Norms(p);
}// order
} // flow component
midpoint = midpoint + IEL_SIZE;
}// element
FILE *fpp = fopen("Init.dat","w");
for (i=0 ; i<INODE-1; i++){
fprintf(fpp,"%d %f\n",i,sol[i][0][0] );
//i++;
}
fclose(fpp);
}