Download this page as a Matlab LiveScript
Table of contents
In this section we shall define the properties of basis functions and use these to derive a framework for computing basis functions for all element geometries.
In the finite element methods we usually let basis function have local support and cohere to partition of unity, meaning that a basis function are only valid in one element and that the linear combination of a field and a basis function does not scale the field, i.e., .
Basis functions have local support, i.e., in the node and in all other nodes of the mesh. This can be written as
Now we could derive basis function which are valid for any using the method below, but there are major drawbacks to this for most elements: computing derivatives and numerical integration. For this reason we typically use the range (or even more common ). This range is commonly referred to as the parametric space. And we use the greek letters and instead of and . We will take a look at computing derivatives in the upcoming section Iso-Parametric map.
Lets derive the basis function for this element:
We first begin by creating a matrix with the coordinates, start at any node and go counter clockwise, we'll start in the 90 degree node, this is good practice.
P = [0 0
1 0
0 1]
Now we can visualize the element:
figure
patch(P(:,1),P(:,2),'w','FaceColor','none','DisplayName','Element'); hold on
plot(P(:,1),P(:,2),'ok','MarkerFaceColor','k','MarkerSize',10,'DisplayName','Nodes')
set(gca,'FontSize',14)
np = size(P,1);
xm = mean(P,1);
Tp = P+(xm-P)*0.2;
text(Tp(:,1),Tp(:,2),cellstr(num2str((1:np)')),'FontSize',14)
Now, we make the ansatz that the basis function for a linear triangle is
We need to determine the three constants , and for a three noded element.
We use the definition of a basis function and create our system of equations for our case above where
which leads to
or
so
and then
or
A = [1 0 0
1 1 0
1 0 1];
b = [1;0;0];
a = A\b
a = 3x1
1
-1
-1
syms xi eta
phi_1(xi,eta) = [1, xi, eta]*a
But we can get all of the functions at the same time with
where
C = A\eye(3)
C = 3x3
1 0 0
-1 1 0
-1 0 1
syms xi eta phi
phi(xi,eta) = [1, xi, eta]*C
and we test the newly created function by evaluating it in the coordinates of our triangle:
phi(0,0)
phi(1,0)
phi(0,1)
The element coordinates
P = [0 0
1 0
1 1
0,1];
figure
patch(P(:,1),P(:,2),'w','FaceColor','none','DisplayName','Element'); hold on
plot(P(:,1),P(:,2),'ok','MarkerFaceColor','k','MarkerSize',10,'DisplayName','Nodes')
np = size(P,1);
xm = mean(P,1);
Tp = P+(xm-P)*0.2;
text(Tp(:,1),Tp(:,2),cellstr(num2str((1:np)')),'FontSize',14)
axis equal tight
Ansatz:
A = [1 0 0 0
1 1 0 0
1 1 1 1
1 0 1 0];
C = A\eye(4);
syms xi eta phi
phi(xi,eta) = simplify([1, xi, eta,xi*eta]*C)
matlabFunction(phi);
phi = @(xi,eta)[(xi-1.0).*(eta-1.0),-xi.*(eta-1.0),xi.*eta,-eta.*(xi-1.0)];
phi(P(:,1),P(:,2))
ans = 4x4
1 0 0 0
0 1 0 0
0 0 1 0
0 0 0 1
Another way to get the same basis functions is by multiplying the one dimensional basis with the other:
This is why this element is refereed to as Bi-linear (Two linear). The same reasoning can be applied to get three dimensional basis functions, or tri-linear.
P = [0 0
1 0
0 1
0.5 0
0.5 0.5
0 0.5];
figure
patch(P(1:3,1),P(1:3,2),'w','FaceColor','none','DisplayName','Element'); hold on
plot(P(:,1),P(:,2),'ok','MarkerFaceColor','k','MarkerSize',8,'DisplayName','Nodes')
xlabel('\xi')
ylabel('\eta')
np = size(P,1);
xm = mean(P,1);
Tp = P+(xm-P)*0.2;
text(Tp(:,1),Tp(:,2),cellstr(num2str((1:np)')),'FontSize',14);
axis equal tight
Ansatz:
A = [1 0 0 0 0 0
1 1 0 1 0 0
1 0 1 0 0 1
1 0.5 0 0.5^2 0 0
1 0.5 0.5 0.5^2 0.5*0.5 0.5^2
1 0 0.5 0 0 0.5^2];
C = A\eye(6);
syms xi eta phi
phi(xi,eta) = simplify([1, xi, eta xi^2 xi*eta eta^2]*C);
We'll use matlabFunction to get the numerical function for
simplify(phi).'
Bh = [diff(phi,xi)
diff(phi,eta)]
phi = matlabFunction(phi);
Bh = matlabFunction(Bh);
phi = @(xi,eta)[eta.*-3.0-xi.*3.0+eta.*xi.*4.0+eta.^2.*2.0+xi.^2.*2.0+1.0,xi.*(xi.*2.0-1.0),eta.*(eta.*2.0-1.0),xi.*(eta+xi-1.0).*-4.0,eta.*xi.*4.0,eta.*(eta+xi-1.0).*-4.0];
Bh = @(xi,eta)reshape([eta.*4.0+xi.*4.0-3.0,eta.*4.0+xi.*4.0-3.0,xi.*4.0-1.0,0.0,0.0,eta.*4.0-1.0,eta.*-4.0-xi.*8.0+4.0,xi.*-4.0,eta.*4.0,xi.*4.0,eta.*-4.0,eta.*-8.0-xi.*4.0+4.0],[2,6]);
And we evaluate in all the nodes to verify that it indeed is 1 in its node and 0 every where else
phi(P(:,1),P(:,2))
ans = 6x6
1 0 0 0 0 0
0 1 0 0 0 0
0 0 1 0 0 0
0 0 0 1 0 0
0 0 0 0 1 0
0 0 0 0 0 1
OK!
P = [0 0
1 0
1 1
0 1
0.5, 0
1 0.5
0.5 1
0. 0.5
0.5 0.5];
figure
patch(P(1:4,1),P(1:4,2),'w','FaceColor','none','DisplayName','Element'); hold on
plot(P(:,1),P(:,2),'ok','MarkerFaceColor','k','MarkerSize',8,'DisplayName','Nodes')
xlabel('\xi')
ylabel('\eta')
np = size(P,1);
xm = mean(P,1);
Tp = P+(xm-P)*0.2;Tp(end,1) = Tp(end,1)+0.05;
text(Tp(:,1),Tp(:,2),cellstr(num2str((1:np)')),'FontSize',14)
axis equal tight
Ansatz:
A = [1 0 0 0 0 0 0 0 0
1 1 0 0 1 0 0 0 0
1 1 1 1 1 1 1 1 1
1 0 1 0 0 1 0 0 0
1 0.5 0 0 0.5^2 0 0 0 0
1 1 0.5 0.5 1 0.5^2 0.5 0.5^2 0.5^2
1 0.5 1 0.5 0.5^2 1 0.5^2 0.5 0.5^2
1 0 0.5 0 0 0.5^2 0 0 0
1 0.5 0.5 0.5^2 0.5^2 0.5^2 0.5^3 0.5^3 0.5^4];
C = A\eye(9);
syms xi eta phi
phi(xi,eta) = simplify([1, xi eta xi*eta xi^2 eta^2 xi^2*eta xi*eta^2 xi^2*eta^2]*C);
matlabFunction(phi);
phi =
@(xi,eta)[(eta.*-3.0+eta.^2.*2.0+1.0).*(xi.*-3.0+xi.^2.*2.0+1.0),xi.*(xi.*2.0-1.0).*(eta.*-3.0+eta.^2.*2.0+1.0),eta.*xi.*(eta.*2.0-1.0).*(xi.*2.0-1.0),eta.*(eta.*2.0-1.0).*(xi.*-3.0+xi.^2.*2.0+1.0),xi.*(xi-1.0).*(eta.*-3.0+eta.^2.*2.0+1.0).*-4.0,eta.*xi.*(xi.*2.0-1.0).*(eta-1.0).*-4.0,eta.*xi.*(eta.*2.0-1.0).*(xi-1.0).*-4.0,eta.*(eta-1.0).*(xi.*-3.0+xi.^2.*2.0+1.0).*-4.0,eta.*xi.*(eta-1.0).*(xi-1.0).*1.6e1]
Verify by evaluating all nodes!
phi(P(:,1),P(:,2))
ans = 9x9
1 0 0 0 0 0 0 0 0
0 1 0 0 0 0 0 0 0
0 0 1 0 0 0 0 0 0
0 0 0 1 0 0 0 0 0
0 0 0 0 1 0 0 0 0
0 0 0 0 0 1 0 0 0
0 0 0 0 0 0 1 0 0
0 0 0 0 0 0 0 1 0
0 0 0 0 0 0 0 0 1
OK!
Quadrilaterals - cubic or bi-cubic The coordinates to the nodes:
g1 = 1/3;
g2 = 2/3;
P = [0 0
1 0
1 1
0 1
g1 0
g2 0
1 g1
1 g2
g2 1
g1 1
0 g2
0 g1
g1 g1
g2 g1
g2 g2
g1 g2];
figure
patch(P(1:4,1),P(1:4,2),'w','FaceColor','none','DisplayName','Element'); hold on
plot(P(:,1),P(:,2),'ok','MarkerFaceColor','k','MarkerSize',5,'DisplayName','Nodes')
xlabel('\xi')
ylabel('\eta')
np = size(P,1);
xm = mean(P,1);
Tp = P+(xm-P)*0.1;
text(Tp(:,1),Tp(:,2),cellstr(num2str((1:np)')),'FontSize',14)
axis equal tight
Ansatz:
A = @(x,y)[1+x.*0 x y x.*y x.^2 y.^2 x.^2.*y x.*y.^2 x.^2.*y.^2 x.^3 y.^3 x.^3.*y y.^3.*x x.^3.*y.^2 y.^3.*x.^2 x.^3.*y.^3];
syms x y
S = sym(A(P(:,1),P(:,2)));
C = S\eye(16);
syms xi eta
phi = matlabFunction(simplify(A(xi,eta)*C));
phi = phi(xi,eta); % Wierd bug, needs to be substituted several times to be correct
phi = matlabFunction(phi)
phi =
@(eta,xi)[((eta.*1.1e+1-eta.^2.*1.8e+1+eta.^3.*9.0-2.0).*(xi.*1.1e+1-xi.^2.*1.8e+1+xi.^3.*9.0-2.0))./4.0,eta.*(eta.*-9.0+eta.^2.*9.0+2.0).*(xi.*1.1e+1-xi.^2.*1.8e+1+xi.^3.*9.0-2.0).*(-1.0./4.0),(eta.*xi.*(eta.*-9.0+eta.^2.*9.0+2.0).*(xi.*-9.0+xi.^2.*9.0+2.0))./4.0,xi.*(xi.*-9.0+xi.^2.*9.0+2.0).*(eta.*1.1e+1-eta.^2.*1.8e+1+eta.^3.*9.0-2.0).*(-1.0./4.0),eta.*(eta.*-5.0+eta.^2.*3.0+2.0).*(xi.*1.1e+1-xi.^2.*1.8e+1+xi.^3.*9.0-2.0).*(-9.0./4.0),eta.*(eta.*-4.0+eta.^2.*3.0+1.0).*(xi.*1.1e+1-xi.^2.*1.8e+1+xi.^3.*9.0-2.0).*(9.0./4.0),eta.*xi.*(eta.*-9.0+eta.^2.*9.0+2.0).*(xi.*-5.0+xi.^2.*3.0+2.0).*(9.0./4.0),eta.*xi.*(eta.*-9.0+eta.^2.*9.0+2.0).*(xi.*-4.0+xi.^2.*3.0+1.0).*(-9.0./4.0),eta.*xi.*(eta.*-4.0+eta.^2.*3.0+1.0).*(xi.*-9.0+xi.^2.*9.0+2.0).*(-9.0./4.0),eta.*xi.*(eta.*-5.0+eta.^2.*3.0+2.0).*(xi.*-9.0+xi.^2.*9.0+2.0).*(9.0./4.0),xi.*(xi.*-4.0+xi.^2.*3.0+1.0).*(eta.*1.1e+1-eta.^2.*1.8e+1+eta.^3.*9.0-2.0).*(9.0./4.0),xi.*(xi.*-5.0+xi.^2.*3.0+2.0).*(eta.*1.1e+1-eta.^2.*1.8e+1+eta.^3.*9.0-2.0).*(-9.0./4.0),eta.*xi.*(eta.*-5.0+eta.^2.*3.0+2.0).*(xi.*-5.0+xi.^2.*3.0+2.0).*(8.1e+1./4.0),eta.*xi.*(eta.*-4.0+eta.^2.*3.0+1.0).*(xi.*-5.0+xi.^2.*3.0+2.0).*(-8.1e+1./4.0),eta.*xi.*(eta.*-4.0+eta.^2.*3.0+1.0).*(xi.*-4.0+xi.^2.*3.0+1.0).*(8.1e+1./4.0),eta.*xi.*(eta.*-5.0+eta.^2.*3.0+2.0).*(xi.*-4.0+xi.^2.*3.0+1.0).*(-8.1e+1./4.0)]