-
Notifications
You must be signed in to change notification settings - Fork 1
/
rectangleWeight.m
211 lines (174 loc) · 4.36 KB
/
rectangleWeight.m
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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
function [w, dwdx, dwdy] = rectangleWeight(type, para, x,y,xI,yI,dmIx,dmIy)
% EVALUATE WEIGHT FUNCTION
%
% SYNTAX:[w, dwdx, dwdy] = rectangleWeight(type, para, x,y,xI,yI,dmIx,dmIy)
%
% INPUT PARAMETERS
% type - Type of weight function
% para - Weight function parameter
% x,y - gauss point coordinates
% xI,yI - nodal point coordinate
% dmIx - Support size with respect to x direction
% dmIy - Support size with respect to y direction
% OUTPUT PARAMETERS
% w - Value of weight function at r
% dwdx - Value of first order derivative of weight function with respect to x at r
% dwdy - Value of first order derivative of weight function with respect to y at r
rx = abs(x-xI)/dmIx;
ry = abs(y-yI)/dmIy; % define the support size is a rectangle
if(rx==0)
drdx=0;
elseif(x-xI>0)
drdx = 1/dmIx;
elseif(x-xI<0)
drdx = -1/dmIx;
end
if(ry==0)
drdy=0;
elseif(y-yI>0)
drdy = 1/dmIy;
elseif(y-yI<0)
drdy = -1/dmIy;
end
% EVALUATE WEIGHT FUNCTION AND ITS FIRST AND SECOND ORDER OF DERIVATIVES WITH RESPECT r AT r
if (type == 'GAUSS')
[wx,dwdrx] = Gauss(para,rx);
[wy,dwdry] = Gauss(para,ry);
elseif (type == 'CUBIC')
[wx,dwdrx] = Cubic(rx);
[wy,dwdry] = Cubic(ry);
elseif (type == 'SPLI3')
[wx,dwdrx] = Spline3(rx);
[wy,dwdry] = Spline3(ry);
elseif (type == 'SPLI5')
[wx,dwdrx] = Spline5(rx);
[wy,dwdry] = Spline5(ry);
elseif (type == 'power')
[wx,dwdrx] = power_function(para,rx);
[wy,dwdry] = power_function(para,ry);
elseif (type == 'CRBF1')
[wx,dwdrx] = CSRBF1(rx);
[wy,dwdry] = CSRBF1(ry);
elseif (type == 'CRBF2')
[wx,dwdrx] = CSRBF2(rx);
[wy,dwdry] = CSRBF2(ry);
elseif (type == 'CRBF3')
[wx,dwdrx] = CSRBF3(rx);
[wy,dwdry] = CSRBF3(ry);
elseif (type == 'CRBF4')
[wx,dwdrx] = CSRBF4(rx);
[wy,dwdry] = CSRBF4(ry);
elseif (type == 'CRBF5')
[wx,dwdrx] = CSRBF5(rx);
[wy,dwdry] = CSRBF5(ry);
elseif (type == 'CRBF6')
[wx,dwdrx] = CSRBF6(rx);
[wy,dwdry] = CSRBF6(ry);
else
error('Invalid type of weight function.');
end
w = wx*wy;
dwdx = wy*dwdrx * drdx;
dwdy= wx*dwdry * drdy;
function [w,dwdr] = Gauss(beta,r)
if (r>1.0)
w = 0.0;
dwdr = 0.0;
else
b2 = beta*beta;
r2 = r*r;
eb2 = exp(-b2);
w = (exp(-b2*r2) - eb2) / (1.0 - eb2);
dwdr = -2*b2*r*exp(-b2*r2) / (1.0 - eb2);
end
function [w,dwdr] = Cubic(r)
if (r>1.0)
w = 0.0;
dwdr = 0.0;
else
w = 1-6*r^2+8*r^3-3*r^4;
dwdr = -12*r+24*r^2-12*r^3;
end
function [w,dwdr] = Spline3(r)
if (r>1.0)
w = 0.0;
dwdr = 0.0;
elseif (r<=0.5)
w = 2/3 - 4*r^2 + 4*r^3;
dwdr = -8*r + 12*r^2;
else
w = 4/3 - 4*r + 4*r^2 - 4*r^3/3;
dwdr = -4 + 8*r -4*r^2;
end
function [w,dwdr] = Spline5(r)
if (r>1.0)
w = 0.0;
dwdr = 0.0;
else
w = 1-10*r^3+15*r^4-6*r^5;
dwdr = -30*r^2 + 60*r^3-30*r^4;
end
function [w,dwdr] = power_function(arfa,r)
if (r>1.0)
w = 0.0;
dwdr = 0.0;
else
a2 = arfa*arfa;
r2 = r*r;
w = exp(-r2/a2);
dwdr = (-2*r/a2)*exp(-r2/a2);
end
function [w,dwdr] = CSRBF2(r)
if (r>1.0)
w = 0.0;
dwdr = 0.0;
else
w = (1-r)^6*(6+36*r+82*r^2+72*r^3+30*r^4+5*r^5);
dwdr = 11*r*(r+2)*(5*r^3+15*r^2+18*r+4)*(r-1)^5;
end
function [w,dwdr] = CSRBF1(r)
if (r>1.0)
w = 0.0;
dwdr = 0.0;
else
w = (1-r)^4*(4+16*r+12*r^2+3*r^3);
dwdr = -4*(1-r)^3*(4+16*r+12*r^2+3*r^3)+(1-r)^4*(16+24*r+9*r^2);
end
function [w,dwdr] = CSRBF3(r)
if (r>1.0)
w = 0.0;
dwdr = 0.0;
elseif(r==0)
w = 1/3;
dwdr = 0.0;
else
w = 1/3+r^2-4/3*r^3+2*r^2*log(r);
dwdr = 4*r-4*r^2+4*r*log(r);
end
function [w,dwdr] = CSRBF4(r)
if (r>1.0)
w = 0.0;
dwdr = 0.0;
elseif(r==0)
w = 1/15;
dwdr = 0.0;
else
w = 1/15+19/6*r^2-16/3*r^3+3*r^4-16/15*r^5+1/6*r^6+2*r^2*log(r);
dwdr = 25/3*r-16*r^2+12*r^3-16/3*r^4+r^5+4*r*log(r);
end
function [w,dwdr] = CSRBF5(r)
if (r>1.0)
w = 0.0;
dwdr = 0.0;
else
w = (1-r)^6*(35*r^2+18*r+3);
dwdr =-6*(1-r)^5*(35*r^2+18*r+3)+(1-r)^6*(70*r+18);
end
function [w,dwdr] = CSRBF6(r)
if (r>1.0)
w = 0.0;
dwdr = 0.0;
else
w = (1-r)^8*(32*r^3+25*r^2+8*r+1);
dwdr =-8*(1-r)^7*(32*r^3+25*r^2+8*r+1)+(1-r)^8*(96*r^2+50*r+8);
end