BOUNDSHAPEFUNC Shape functions on the boundary in local coordiantes SHAPE = boundshapefunc(TYPE,X,Y) NOTES - On boundary, dimension is smaller e.g. tri6 element, boundary has 3 node (quadratic) and is 1D INPUT: 1. X, Y, Z - local coordinates 2. TYPE - string describing different element typeswhat kind of element 'tri3' - Linear, 2 node 1D shape function 'tri 6'- Quadratic, 3 node 1D shape function 'tet4' - Linear, 3 node triangle shape function 'tet10' - Quadratic, 6 node triangle shape function OUTPUT 1. SHAPE - vector of shape functions on this segment of boundary M Crabb - 29.06.2012
0001 function shape=boundary_shape_function(type,x,y) 0002 %BOUNDSHAPEFUNC Shape functions on the boundary in local coordiantes 0003 %SHAPE = boundshapefunc(TYPE,X,Y) 0004 % 0005 %NOTES - On boundary, dimension is smaller e.g. tri6 element, boundary has 0006 %3 node (quadratic) and is 1D 0007 % 0008 %INPUT: 0009 %1. X, Y, Z - local coordinates 0010 %2. TYPE - string describing different element typeswhat kind of element 0011 % 'tri3' - Linear, 2 node 1D shape function 0012 % 'tri 6'- Quadratic, 3 node 1D shape function 0013 % 'tet4' - Linear, 3 node triangle shape function 0014 % 'tet10' - Quadratic, 6 node triangle shape function 0015 % 0016 %OUTPUT 0017 %1. SHAPE - vector of shape functions on this segment of boundary 0018 % 0019 %M Crabb - 29.06.2012 0020 0021 if(strcmp(type,'tri3')) 0022 shape = boundshapetri3(x,y); 0023 elseif(strcmp(type,'tri6')) 0024 shape = boundshapetri6(x,y); 0025 elseif(strcmp(type,'tri10')) 0026 shape = boundshapetri10(x,y); 0027 elseif(strcmp(type,'tet4')) 0028 shape = boundshapetet4(x,y); 0029 elseif(strcmp(type,'tet10')) 0030 shape = boundshapetet10(x,y); 0031 else 0032 error('Incorrect number of input arguments') 0033 end 0034 0035 0036 0037 %1D Shape functions : Equidistant placed in region [-1,1] 0038 0039 function shape = boundshapetri3(x,y) 0040 shape(1) = 0.5*(1-x); 0041 shape(2) = 0.5*(1+x); 0042 end 0043 0044 %Ordered correctly (vertex basis functions are first : (1,3,2) order) 0045 function shape = boundshapetri6(x,y) 0046 shape(1) = 0.5*x*(x-1); 0047 shape(2) = 0.5*x*(x+1); 0048 shape(3) = (1-x)*(1+x); 0049 end 0050 0051 %Ordered correctly (vertex basis functions are first : (1,3,4,2) order) 0052 function shape = boundshapetri10(x,y) 0053 shape(1) = 0.0625*(1-x)*(3*x-1)*(3*x+1); 0054 shape(2) = 0.0625*(1+x)*(3*x-1)*(3*x+1); 0055 shape(3) = -0.5625*(1+x)*(3*x-1)*(1-x); 0056 shape(4) = 0.5625*(1+x)*(3*x+1)*(1-x); 0057 end 0058 0059 0060 0061 0062 0063 %2D Shape functions : Place on the unit triangle [0,1]*[0,1] axes 0064 0065 function shape = boundshapetet4(x,y) 0066 shape(1) = 1-x-y; 0067 shape(2) = x; 0068 shape(3) = y; 0069 end 0070 0071 %Ordered correctly (i.e. vertex basis function (first 3) are first) 0072 function shape = boundshapetet10(x,y) 0073 shape(1) = (1-x-y)*(1-2*x-2*y); 0074 shape(2) = x*(2*x-1); 0075 shape(3) = y*(2*y-1); 0076 shape(4) = 4*x*(1-x-y); 0077 shape(5) = 4*y*(1-x-y); 0078 shape(6) = 4*x*y; 0079 end 0080 0081 end