-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCal.c
173 lines (120 loc) · 2.29 KB
/
Cal.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
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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
#include <stdio.h>
#include <math.h>
#include "Global.h"
/*
Basis functions
Derivatives of Basis functions
Norms of Basis functions
Quadrature points
coefficents of RK
initial conditions
*/
int AllocateMem();
//***************************************
// Basis functions
//****************************************
float Basis(int order,float x){
float answer;
switch(order){
case 0:
answer = 1;
break;
case 1:
answer = x;
break;
case 2:
answer = 0.5*(3*pow(x,2) - 1);
break;
case 3:
answer = 0.5*(5*pow(x,3) - 3*x);
break;
case 4:
answer = (1./8.)*(35*pow(x,4) - 30*pow(x,2) + 3);
break;
case 5:
answer = (1./8.)*(63*pow(x,5) - 70*pow(x,3) + 15*x);
break;
}
return(answer);
}
//***************************************
// derivative of Basis functions
//****************************************
float Basis_X(int order, float x){
float answer;
switch(order){
case 0:
answer = 0;
break;
case 1:
answer = 1;
break;
case 2:
answer = 3*x;
break;
case 3:
answer = 0.5*(15*pow(x,2) - 3);
break;
case 4:
answer = (1./8.)*(140*pow(x,3) - 60*pow(x,1));
break;
case 5:
answer = (1./8.)*(315*pow(x,4) - 210*pow(x,2) + 15);
break;
}
return(answer);
}
float GaussPoints(){
rXg[0] = 0.23861918;
rXg[1] = 0.66120939;
rXg[2] = 0.93246951;
rXg[3] = - 0.23861918;
rXg[4] = - 0.66120939;
rXg[5] = - 0.93246951;
rWg[0] = 0.46791393;
rWg[1] = 0.36076157;
rWg[2] = 0.17132449;
rWg[3] = 0.46791393;
rWg[4] = 0.36076157;
rWg[5] = 0.17132449;
}
float Norms(int iorder){
float answer;
answer = 2.0/(2.0*iorder + 1);
return (answer);
}
float RKINT(){
switch(IRK){
case 1:
rRKAlpha[0]=1.0;
rRKBeta[0]= 0.0;
rRKGamma[0]= 1.0;
/*
rRKAlpha(1)=1.D0
rRKAlpha(2)=0.5D0
rRKBeta(1)= 0.D0
rRKBeta(2)= 0.5D0
rRKGamma(1)= 1.0D0
rRKGamma(2)= 0.5D0
*/
case 2:
rRKAlpha[0]=1.0;
rRKAlpha[1]=0.5;
rRKBeta[0]= 0.0;
rRKBeta[1]= 0.5;
rRKGamma[0]= 1.0;
rRKGamma[1]= 0.5; //1.0
break;
case 3:
rRKAlpha[0]=1.0;
rRKAlpha[1]=0.75;
rRKAlpha[2]=1.0/3.0;
rRKBeta[0]= 0.0;
rRKBeta[1]= 0.25;
rRKBeta[2]= 2.0/3.0;
rRKGamma[0]= 1.0;
rRKGamma[1]= 0.25;
rRKGamma[2]= 2.0/3.0;
break;
}
}