FEATool  v1.9Finite Element Analysis Toolbox
sf_quad_H3.m File Reference

## Description

SF_QUAD_H3 Third order 2D C1 Hermite shape function for quadrilaterals.

[ VBASE, NLDOF, XLDOF, SFUN ] = SF_QUAD_H3( I_EVAL, N_SDIM, N_VERT, I_DOF, XI, AINVJAC, VBASE ) Evaluates C1 Hermite shape functions on quadrilaterals with values defined in the nodes, cell center. XI are [-1..1]^2 reference coordinates. (Limited to rectangular grid cells.)

```Input       Value/[Size]           Description
-----------------------------------------------------------------------------------
i_eval      scalar:  1             Evaluate function values
>1             Evaluate values of derivatives
n_sdim      scalar:  2             Number of space dimensions
n_vert      scalar:  4             Number of vertices per cell
i_dof       scalar: 1-16           Local basis function to evaluate
xi          [n_sdim]               Local coordinates of evaluation point
aInvJac     [n,n_sdim*n_sdim]      Inverse of transformation Jacobian
vBase       [n]                    Preallocated output vector
.
Output      Value/[Size]           Description
-----------------------------------------------------------------------------------
vBase       [n]                    Evaluated function values
nLDof       [3,4]                  Number of local degrees of freedom on
vertices, edges, faces, and cell interiors
xLDof       [n_sdim,n_ldof]        Local coordinates of local dofs
sfun        string                 Function name of called shape function
```
See also
sf_quad_Q3

# Code listing

``` nLDof = [4 0 0 4;
4 0 0 0;
4 0 0 0];
xLDof = [repmat([-1  1 1 -1;
-1 -1 1  1],1,3) [-1 1 1 -1;-1 -1 1 1]/3];
sfun  = 'sf_quad_H3';

if( nargin>=6 && ~isempty(aInvJac) )

if( any(any(abs(aInvJac(:,2:3))>eps*1e2)) )

aJTmp = tfjacquad( -2 );
if( i_dof==5 || i_dof==9 )
a11 =  aJTmp(:,7)/2;
a12 = -aJTmp(:,6)/2;
a21 = -aJTmp(:,3)/2;
a22 =  aJTmp(:,2)/2;
end
if( i_dof==6 || i_dof==10 )
a11 =  aJTmp(:,7)/2;
a12 = -aJTmp(:,5)/2;
a21 = -aJTmp(:,3)/2;
a22 =  aJTmp(:,1)/2;
end
if( i_dof==7 || i_dof==11 )
a11 =  aJTmp(:,8)/2;
a12 = -aJTmp(:,5)/2;
a21 = -aJTmp(:,4)/2;
a22 =  aJTmp(:,1)/2;
end
if( i_dof==8 || i_dof==12 )
a11 =  aJTmp(:,8)/2;
a12 = -aJTmp(:,6)/2;
a21 = -aJTmp(:,4)/2;
a22 =  aJTmp(:,2)/2;
end

else

a11 = 1./aInvJac(:,1);
a12 = 0;
a21 = 0;
a22 = 1./aInvJac(:,4);

end

end

switch i_eval

case 1

switch i_dof
case 1
vBase = ((xi(1) - 1)*(xi(2) - 1)*(- 153*xi(1)^2*xi(2)^2 - 36*xi(1)^2*xi(2) + 85*xi(1)^2 - 36*xi(1)*xi(2)^2 + 4*xi(1) + 85*xi(2)^2 + 4*xi(2) - 17))/256;
case 2
vBase = ((xi(1) + 1)*(xi(2) - 1)*(153*xi(1)^2*xi(2)^2 + 36*xi(1)^2*xi(2) - 85*xi(1)^2 - 36*xi(1)*xi(2)^2 + 4*xi(1) - 85*xi(2)^2 - 4*xi(2) + 17))/256;
case 3
vBase = -((xi(1) + 1)*(xi(2) + 1)*(153*xi(1)^2*xi(2)^2 - 36*xi(1)^2*xi(2) - 85*xi(1)^2 - 36*xi(1)*xi(2)^2 + 4*xi(1) - 85*xi(2)^2 + 4*xi(2) + 17))/256;
case 4
vBase = -((xi(1) - 1)*(xi(2) + 1)*(- 153*xi(1)^2*xi(2)^2 + 36*xi(1)^2*xi(2) + 85*xi(1)^2 - 36*xi(1)*xi(2)^2 + 4*xi(1) + 85*xi(2)^2 - 4*xi(2) - 17))/256;
case 5
vBase = - (a11*(3*xi(2) - 1)*(3*xi(2) + 1)*(xi(1) - 1)^2*(xi(1) + 1)*(xi(2) - 1))/64 - (a12*(3*xi(1) - 1)*(3*xi(1) + 1)*(xi(1) - 1)*(xi(2) - 1)^2*(xi(2) + 1))/64;
case 6
vBase = (a12*(3*xi(1) - 1)*(3*xi(1) + 1)*(xi(1) + 1)*(xi(2) - 1)^2*(xi(2) + 1))/64 - (a11*(3*xi(2) - 1)*(3*xi(2) + 1)*(xi(1) - 1)*(xi(1) + 1)^2*(xi(2) - 1))/64;
case 7
vBase = (a11*(3*xi(2) - 1)*(3*xi(2) + 1)*(xi(1) - 1)*(xi(1) + 1)^2*(xi(2) + 1))/64 + (a12*(3*xi(1) - 1)*(3*xi(1) + 1)*(xi(1) + 1)*(xi(2) - 1)*(xi(2) + 1)^2)/64;
case 8
vBase = (a11*(3*xi(2) - 1)*(3*xi(2) + 1)*(xi(1) - 1)^2*(xi(1) + 1)*(xi(2) + 1))/64 - (a12*(3*xi(1) - 1)*(3*xi(1) + 1)*(xi(1) - 1)*(xi(2) - 1)*(xi(2) + 1)^2)/64;
case 9
vBase = - (a21*(3*xi(2) - 1)*(3*xi(2) + 1)*(xi(1) - 1)^2*(xi(1) + 1)*(xi(2) - 1))/64 - (a22*(3*xi(1) - 1)*(3*xi(1) + 1)*(xi(1) - 1)*(xi(2) - 1)^2*(xi(2) + 1))/64;
case 10
vBase = (a22*(3*xi(1) - 1)*(3*xi(1) + 1)*(xi(1) + 1)*(xi(2) - 1)^2*(xi(2) + 1))/64 - (a21*(3*xi(2) - 1)*(3*xi(2) + 1)*(xi(1) - 1)*(xi(1) + 1)^2*(xi(2) - 1))/64;
case 11
vBase = (a21*(3*xi(2) - 1)*(3*xi(2) + 1)*(xi(1) - 1)*(xi(1) + 1)^2*(xi(2) + 1))/64 + (a22*(3*xi(1) - 1)*(3*xi(1) + 1)*(xi(1) + 1)*(xi(2) - 1)*(xi(2) + 1)^2)/64;
case 12
vBase = (a21*(3*xi(2) - 1)*(3*xi(2) + 1)*(xi(1) - 1)^2*(xi(1) + 1)*(xi(2) + 1))/64 - (a22*(3*xi(1) - 1)*(3*xi(1) + 1)*(xi(1) - 1)*(xi(2) - 1)*(xi(2) + 1)^2)/64;
case 13
vBase = ((3*xi(2) - 1)*(243*xi(1) - 81)*(xi(1) - 1)*(xi(1) + 1)*(xi(2) - 1)*(xi(2) + 1))/256;
case 14
vBase = -((3*xi(2) - 1)*(243*xi(1) + 81)*(xi(1) - 1)*(xi(1) + 1)*(xi(2) - 1)*(xi(2) + 1))/256;
case 15
vBase = ((3*xi(2) + 1)*(243*xi(1) + 81)*(xi(1) - 1)*(xi(1) + 1)*(xi(2) - 1)*(xi(2) + 1))/256;
case 16
vBase = -((3*xi(2) + 1)*(243*xi(1) - 81)*(xi(1) - 1)*(xi(1) + 1)*(xi(2) - 1)*(xi(2) + 1))/256;
end

case {2,3}

switch i_dof
case 1
dNdxi1 = ((xi(2) - 1)*(- 459*xi(1)^2*xi(2)^2 - 108*xi(1)^2*xi(2) + 255*xi(1)^2 + 234*xi(1)*xi(2)^2 + 72*xi(1)*xi(2) - 162*xi(1) + 121*xi(2)^2 + 4*xi(2) - 21))/256;
dNdxi2 = ((xi(1) - 1)*(- 459*xi(1)^2*xi(2)^2 + 234*xi(1)^2*xi(2) + 121*xi(1)^2 - 108*xi(1)*xi(2)^2 + 72*xi(1)*xi(2) + 4*xi(1) + 255*xi(2)^2 - 162*xi(2) - 21))/256;
case 2
dNdxi1 = ((xi(2) - 1)*(459*xi(1)^2*xi(2)^2 + 108*xi(1)^2*xi(2) - 255*xi(1)^2 + 234*xi(1)*xi(2)^2 + 72*xi(1)*xi(2) - 162*xi(1) - 121*xi(2)^2 - 4*xi(2) + 21))/256;
dNdxi2 = ((xi(1) + 1)*(459*xi(1)^2*xi(2)^2 - 234*xi(1)^2*xi(2) - 121*xi(1)^2 - 108*xi(1)*xi(2)^2 + 72*xi(1)*xi(2) + 4*xi(1) - 255*xi(2)^2 + 162*xi(2) + 21))/256;
case 3
dNdxi1 = ((xi(2) + 1)*(- 459*xi(1)^2*xi(2)^2 + 108*xi(1)^2*xi(2) + 255*xi(1)^2 - 234*xi(1)*xi(2)^2 + 72*xi(1)*xi(2) + 162*xi(1) + 121*xi(2)^2 - 4*xi(2) - 21))/256;
dNdxi2 = ((xi(1) + 1)*(- 459*xi(1)^2*xi(2)^2 - 234*xi(1)^2*xi(2) + 121*xi(1)^2 + 108*xi(1)*xi(2)^2 + 72*xi(1)*xi(2) - 4*xi(1) + 255*xi(2)^2 + 162*xi(2) - 21))/256;
case 4
dNdxi1 = ((xi(2) + 1)*(459*xi(1)^2*xi(2)^2 - 108*xi(1)^2*xi(2) - 255*xi(1)^2 - 234*xi(1)*xi(2)^2 + 72*xi(1)*xi(2) + 162*xi(1) - 121*xi(2)^2 + 4*xi(2) + 21))/256;
dNdxi2 = ((xi(1) - 1)*(459*xi(1)^2*xi(2)^2 + 234*xi(1)^2*xi(2) - 121*xi(1)^2 + 108*xi(1)*xi(2)^2 + 72*xi(1)*xi(2) - 4*xi(1) - 255*xi(2)^2 - 162*xi(2) + 21))/256;
case 5
dNdxi1 = - (a11*(3*xi(2) - 1)*(3*xi(2) + 1)*(xi(1) - 1)^2*(xi(2) - 1))/64 - (a12*(3*xi(1) - 1)*(3*xi(1) + 1)*(xi(2) - 1)^2*(xi(2) + 1))/64 - (3*a12*(3*xi(1) - 1)*(xi(1) - 1)*(xi(2) - 1)^2*(xi(2) + 1))/64 - (3*a12*(3*xi(1) + 1)*(xi(1) - 1)*(xi(2) - 1)^2*(xi(2) + 1))/64 - (a11*(2*xi(1) - 2)*(3*xi(2) - 1)*(3*xi(2) + 1)*(xi(1) + 1)*(xi(2) - 1))/64;
dNdxi2 = - (a11*(3*xi(2) - 1)*(3*xi(2) + 1)*(xi(1) - 1)^2*(xi(1) + 1))/64 - (a12*(3*xi(1) - 1)*(3*xi(1) + 1)*(xi(1) - 1)*(xi(2) - 1)^2)/64 - (3*a11*(3*xi(2) - 1)*(xi(1) - 1)^2*(xi(1) + 1)*(xi(2) - 1))/64 - (3*a11*(3*xi(2) + 1)*(xi(1) - 1)^2*(xi(1) + 1)*(xi(2) - 1))/64 - (a12*(3*xi(1) - 1)*(3*xi(1) + 1)*(2*xi(2) - 2)*(xi(1) - 1)*(xi(2) + 1))/64;
case 6
dNdxi1 = (a12*(3*xi(1) - 1)*(3*xi(1) + 1)*(xi(2) - 1)^2*(xi(2) + 1))/64 - (a11*(3*xi(2) - 1)*(3*xi(2) + 1)*(xi(1) + 1)^2*(xi(2) - 1))/64 + (3*a12*(3*xi(1) - 1)*(xi(1) + 1)*(xi(2) - 1)^2*(xi(2) + 1))/64 + (3*a12*(3*xi(1) + 1)*(xi(1) + 1)*(xi(2) - 1)^2*(xi(2) + 1))/64 - (a11*(2*xi(1) + 2)*(3*xi(2) - 1)*(3*xi(2) + 1)*(xi(1) - 1)*(xi(2) - 1))/64;
dNdxi2 = (a12*(3*xi(1) - 1)*(3*xi(1) + 1)*(xi(1) + 1)*(xi(2) - 1)^2)/64 - (a11*(3*xi(2) - 1)*(3*xi(2) + 1)*(xi(1) - 1)*(xi(1) + 1)^2)/64 - (3*a11*(3*xi(2) - 1)*(xi(1) - 1)*(xi(1) + 1)^2*(xi(2) - 1))/64 - (3*a11*(3*xi(2) + 1)*(xi(1) - 1)*(xi(1) + 1)^2*(xi(2) - 1))/64 + (a12*(3*xi(1) - 1)*(3*xi(1) + 1)*(2*xi(2) - 2)*(xi(1) + 1)*(xi(2) + 1))/64;
case 7
dNdxi1 = (a11*(3*xi(2) - 1)*(3*xi(2) + 1)*(xi(1) + 1)^2*(xi(2) + 1))/64 + (a12*(3*xi(1) - 1)*(3*xi(1) + 1)*(xi(2) - 1)*(xi(2) + 1)^2)/64 + (3*a12*(3*xi(1) - 1)*(xi(1) + 1)*(xi(2) - 1)*(xi(2) + 1)^2)/64 + (3*a12*(3*xi(1) + 1)*(xi(1) + 1)*(xi(2) - 1)*(xi(2) + 1)^2)/64 + (a11*(2*xi(1) + 2)*(3*xi(2) - 1)*(3*xi(2) + 1)*(xi(1) - 1)*(xi(2) + 1))/64;
dNdxi2 = (a11*(3*xi(2) - 1)*(3*xi(2) + 1)*(xi(1) - 1)*(xi(1) + 1)^2)/64 + (a12*(3*xi(1) - 1)*(3*xi(1) + 1)*(xi(1) + 1)*(xi(2) + 1)^2)/64 + (3*a11*(3*xi(2) - 1)*(xi(1) - 1)*(xi(1) + 1)^2*(xi(2) + 1))/64 + (3*a11*(3*xi(2) + 1)*(xi(1) - 1)*(xi(1) + 1)^2*(xi(2) + 1))/64 + (a12*(3*xi(1) - 1)*(3*xi(1) + 1)*(2*xi(2) + 2)*(xi(1) + 1)*(xi(2) - 1))/64;
case 8
dNdxi1 = (a11*(3*xi(2) - 1)*(3*xi(2) + 1)*(xi(1) - 1)^2*(xi(2) + 1))/64 - (a12*(3*xi(1) - 1)*(3*xi(1) + 1)*(xi(2) - 1)*(xi(2) + 1)^2)/64 - (3*a12*(3*xi(1) - 1)*(xi(1) - 1)*(xi(2) - 1)*(xi(2) + 1)^2)/64 - (3*a12*(3*xi(1) + 1)*(xi(1) - 1)*(xi(2) - 1)*(xi(2) + 1)^2)/64 + (a11*(2*xi(1) - 2)*(3*xi(2) - 1)*(3*xi(2) + 1)*(xi(1) + 1)*(xi(2) + 1))/64;
dNdxi2 = (a11*(3*xi(2) - 1)*(3*xi(2) + 1)*(xi(1) - 1)^2*(xi(1) + 1))/64 - (a12*(3*xi(1) - 1)*(3*xi(1) + 1)*(xi(1) - 1)*(xi(2) + 1)^2)/64 + (3*a11*(3*xi(2) - 1)*(xi(1) - 1)^2*(xi(1) + 1)*(xi(2) + 1))/64 + (3*a11*(3*xi(2) + 1)*(xi(1) - 1)^2*(xi(1) + 1)*(xi(2) + 1))/64 - (a12*(3*xi(1) - 1)*(3*xi(1) + 1)*(2*xi(2) + 2)*(xi(1) - 1)*(xi(2) - 1))/64;
case 9
dNdxi1 = - (a21*(3*xi(2) - 1)*(3*xi(2) + 1)*(xi(1) - 1)^2*(xi(2) - 1))/64 - (a22*(3*xi(1) - 1)*(3*xi(1) + 1)*(xi(2) - 1)^2*(xi(2) + 1))/64 - (3*a22*(3*xi(1) - 1)*(xi(1) - 1)*(xi(2) - 1)^2*(xi(2) + 1))/64 - (3*a22*(3*xi(1) + 1)*(xi(1) - 1)*(xi(2) - 1)^2*(xi(2) + 1))/64 - (a21*(2*xi(1) - 2)*(3*xi(2) - 1)*(3*xi(2) + 1)*(xi(1) + 1)*(xi(2) - 1))/64;
dNdxi2 = - (a21*(3*xi(2) - 1)*(3*xi(2) + 1)*(xi(1) - 1)^2*(xi(1) + 1))/64 - (a22*(3*xi(1) - 1)*(3*xi(1) + 1)*(xi(1) - 1)*(xi(2) - 1)^2)/64 - (3*a21*(3*xi(2) - 1)*(xi(1) - 1)^2*(xi(1) + 1)*(xi(2) - 1))/64 - (3*a21*(3*xi(2) + 1)*(xi(1) - 1)^2*(xi(1) + 1)*(xi(2) - 1))/64 - (a22*(3*xi(1) - 1)*(3*xi(1) + 1)*(2*xi(2) - 2)*(xi(1) - 1)*(xi(2) + 1))/64;
case 10
dNdxi1 = (a22*(3*xi(1) - 1)*(3*xi(1) + 1)*(xi(2) - 1)^2*(xi(2) + 1))/64 - (a21*(3*xi(2) - 1)*(3*xi(2) + 1)*(xi(1) + 1)^2*(xi(2) - 1))/64 + (3*a22*(3*xi(1) - 1)*(xi(1) + 1)*(xi(2) - 1)^2*(xi(2) + 1))/64 + (3*a22*(3*xi(1) + 1)*(xi(1) + 1)*(xi(2) - 1)^2*(xi(2) + 1))/64 - (a21*(2*xi(1) + 2)*(3*xi(2) - 1)*(3*xi(2) + 1)*(xi(1) - 1)*(xi(2) - 1))/64;
dNdxi2 = (a22*(3*xi(1) - 1)*(3*xi(1) + 1)*(xi(1) + 1)*(xi(2) - 1)^2)/64 - (a21*(3*xi(2) - 1)*(3*xi(2) + 1)*(xi(1) - 1)*(xi(1) + 1)^2)/64 - (3*a21*(3*xi(2) - 1)*(xi(1) - 1)*(xi(1) + 1)^2*(xi(2) - 1))/64 - (3*a21*(3*xi(2) + 1)*(xi(1) - 1)*(xi(1) + 1)^2*(xi(2) - 1))/64 + (a22*(3*xi(1) - 1)*(3*xi(1) + 1)*(2*xi(2) - 2)*(xi(1) + 1)*(xi(2) + 1))/64;
case 11
dNdxi1 = (a21*(3*xi(2) - 1)*(3*xi(2) + 1)*(xi(1) + 1)^2*(xi(2) + 1))/64 + (a22*(3*xi(1) - 1)*(3*xi(1) + 1)*(xi(2) - 1)*(xi(2) + 1)^2)/64 + (3*a22*(3*xi(1) - 1)*(xi(1) + 1)*(xi(2) - 1)*(xi(2) + 1)^2)/64 + (3*a22*(3*xi(1) + 1)*(xi(1) + 1)*(xi(2) - 1)*(xi(2) + 1)^2)/64 + (a21*(2*xi(1) + 2)*(3*xi(2) - 1)*(3*xi(2) + 1)*(xi(1) - 1)*(xi(2) + 1))/64;
dNdxi2 = (a21*(3*xi(2) - 1)*(3*xi(2) + 1)*(xi(1) - 1)*(xi(1) + 1)^2)/64 + (a22*(3*xi(1) - 1)*(3*xi(1) + 1)*(xi(1) + 1)*(xi(2) + 1)^2)/64 + (3*a21*(3*xi(2) - 1)*(xi(1) - 1)*(xi(1) + 1)^2*(xi(2) + 1))/64 + (3*a21*(3*xi(2) + 1)*(xi(1) - 1)*(xi(1) + 1)^2*(xi(2) + 1))/64 + (a22*(3*xi(1) - 1)*(3*xi(1) + 1)*(2*xi(2) + 2)*(xi(1) + 1)*(xi(2) - 1))/64;
case 12
dNdxi1 = (a21*(3*xi(2) - 1)*(3*xi(2) + 1)*(xi(1) - 1)^2*(xi(2) + 1))/64 - (a22*(3*xi(1) - 1)*(3*xi(1) + 1)*(xi(2) - 1)*(xi(2) + 1)^2)/64 - (3*a22*(3*xi(1) - 1)*(xi(1) - 1)*(xi(2) - 1)*(xi(2) + 1)^2)/64 - (3*a22*(3*xi(1) + 1)*(xi(1) - 1)*(xi(2) - 1)*(xi(2) + 1)^2)/64 + (a21*(2*xi(1) - 2)*(3*xi(2) - 1)*(3*xi(2) + 1)*(xi(1) + 1)*(xi(2) + 1))/64;
dNdxi2 = (a21*(3*xi(2) - 1)*(3*xi(2) + 1)*(xi(1) - 1)^2*(xi(1) + 1))/64 - (a22*(3*xi(1) - 1)*(3*xi(1) + 1)*(xi(1) - 1)*(xi(2) + 1)^2)/64 + (3*a21*(3*xi(2) - 1)*(xi(1) - 1)^2*(xi(1) + 1)*(xi(2) + 1))/64 + (3*a21*(3*xi(2) + 1)*(xi(1) - 1)^2*(xi(1) + 1)*(xi(2) + 1))/64 - (a22*(3*xi(1) - 1)*(3*xi(1) + 1)*(2*xi(2) + 2)*(xi(1) - 1)*(xi(2) - 1))/64;
case 13
dNdxi1 = -(81*(3*xi(2) - 1)*(xi(2) - 1)*(xi(2) + 1)*(- 9*xi(1)^2 + 2*xi(1) + 3))/256;
dNdxi2 = -(81*(3*xi(1) - 1)*(xi(1) - 1)*(xi(1) + 1)*(- 9*xi(2)^2 + 2*xi(2) + 3))/256;
case 14
dNdxi1 = -(81*(3*xi(2) - 1)*(xi(2) - 1)*(xi(2) + 1)*(9*xi(1)^2 + 2*xi(1) - 3))/256;
dNdxi2 = (81*(3*xi(1) + 1)*(xi(1) - 1)*(xi(1) + 1)*(- 9*xi(2)^2 + 2*xi(2) + 3))/256;
case 15
dNdxi1 = (81*(3*xi(2) + 1)*(xi(2) - 1)*(xi(2) + 1)*(9*xi(1)^2 + 2*xi(1) - 3))/256;
dNdxi2 = (81*(3*xi(1) + 1)*(xi(1) - 1)*(xi(1) + 1)*(9*xi(2)^2 + 2*xi(2) - 3))/256;
case 16
dNdxi1 = (81*(3*xi(2) + 1)*(xi(2) - 1)*(xi(2) + 1)*(- 9*xi(1)^2 + 2*xi(1) + 3))/256;
dNdxi2 = -(81*(3*xi(1) - 1)*(xi(1) - 1)*(xi(1) + 1)*(9*xi(2)^2 + 2*xi(2) - 3))/256;
end

if( i_eval==2 )
vBase = aInvJac(:,1).*dNdxi1 + aInvJac(:,2).*dNdxi2;
else
vBase = aInvJac(:,3).*dNdxi1 + aInvJac(:,4).*dNdxi2;
end

case {22,23,32,33}   % Evaluation of second order derivatives.
error('sf_quad_H3: second order derivative evaluation not supported.')

otherwise
vBase = 0;

end```