1 /* calculate the shape functions and their derivatives for 2 a triangular face 3 */ 4 TriShapeAndDrv(int p,double par[2],double N[],double dN[][2])5int TriShapeAndDrv(int p,double par[2],double N[],double dN[][2]){ 6 int i,j,nshp=0; 7 double L[3]; 8 9 if(p != 2) 10 return nshp; 11 L[0]=par[0]; 12 L[1]=par[1]; 13 L[2]=1.0e0-par[0]-par[1]; 14 15 /* define shape functions for a quadratic triangle */ 16 17 /* collect all vertex modes */ 18 for(i=0; i<3; i++) { 19 N[i] = L[i]; 20 if(i==2) 21 dN[i][0]=dN[i][1]=-1.0e0; 22 else { 23 for(j=0; j<2; j++) { 24 if(i==j) 25 dN[i][j] = 1.0e0; 26 else 27 dN[i][j] = 0.0e0; 28 } 29 } 30 } 31 nshp=3; 32 if( p > 1 ){ 33 /* collect edge modes (only quadratic for now) */ 34 N[3] = -2.0e0*L[0]*L[1]; 35 N[4] = -2.0e0*L[1]*L[2]; 36 N[5] = -2.0e0*L[0]*L[2]; 37 dN[3][0] = -2.0e0*L[1]; 38 dN[3][1] = -2.0e0*L[0]; 39 dN[4][0] = 2.0e0*L[1]; 40 dN[4][1] = -2.0e0+2.0e0*L[0]+4.0e0*L[1]; 41 dN[5][0] = -2.0e0+4.0e0*L[0]+2.0e0*L[1]; 42 dN[5][1] = 2.0e0*L[0]; 43 nshp=6; 44 } 45 return nshp; 46 } 47 48 49 50 51