forked from SUMatEng/ADIC2D
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSFExpressions.m
21 lines (21 loc) · 2.05 KB
/
SFExpressions.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
function [W,dFdWdP,SFPVec2Mat,Mat2SFPVec,StopCrit]=SFExpressions(SFOrder)
switch SFOrder
case 0 % Zero order SF
W=@(dX,dY,P) [P(1)+dX,P(7)+dY]; % Equation (14)
dFdWdP=@(dX,dY,dfdx,dfdy) [dfdx,dfdy];
SFPVec2Mat=@(P) reshape([1,0,0,0,1,0,P(1),P(7),1],[3,3]); % Equation (22)
Mat2SFPVec=@(W) [W(7),0,0,0,0,0,W(8),0,0,0,0,0];
StopCrit=@(dP,Zeta) sqrt(sum((dP'.*[1,0,0,0,0,0,1,0,0,0,0,0]).^2)); % Equation (23)
case 1 % First order SF
W=@(dX,dY,P) [P(1)+P(3).*dY+dX.*(P(2)+1),P(7)+P(8).*dX+dY.*(P(9)+1)]; % Equation (14)
dFdWdP=@(dX,dY,dfdx,dfdy) [dfdx,dfdx.*dX,dfdx.*dY, dfdy,dfdy.*dX,dfdy.*dY];
SFPVec2Mat=@(P) reshape([P(2)+1,P(8),0,P(3),P(9)+1,0,P(1),P(7),1],[3,3]); % Equation (22)
Mat2SFPVec=@(W) [W(7),W(1)-1.0,W(4),0,0,0,W(8),W(2),W(5)-1.0,0,0,0];
StopCrit=@(dP,Zeta) sqrt(sum((dP'.*[1,Zeta,Zeta,0,0,0,1,Zeta,Zeta,0,0,0]).^2)); % Equation (23)
case 2 % Second order SF
W=@(dX,dY,P) [P(1)+P(3).*dY+P(4).*dX.^2.*(1/2)+P(6).*dY.^2.*(1/2)+dX.*(P(2)+1)+P(5).*dX.*dY,P(7)+P(8).*dX+P(10).*dX.^2.*(1/2)+P(12).*dY.^2.*(1/2)+dY.*(P(9)+1)+P(11).*dX.*dY]; % Equation (14)
dFdWdP=@(dX,dY,dfdx,dfdy) [dfdx,dfdx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