Changeset 4898
- Timestamp:
- 07/30/10 09:00:31 (15 years ago)
- Location:
- issm/trunk/src/c
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk/src/c/objects/Elements/Penta.cpp
r4885 r4898 4014 4014 } 4015 4015 /*}}}*/ 4016 /*FUNCTION Penta::GetMatrixInvert {{{1*/4017 void Penta::GetMatrixInvert(double* Ke_invert, double* Ke){4018 /*Inverse a 3 by 3 matrix only */4019 4020 double a,b,c,d,e,f,g,h,i;4021 double det;4022 int calculationdof=3;4023 4024 /*Take the matrix components: */4025 a=*(Ke+calculationdof*0+0);4026 b=*(Ke+calculationdof*0+1);4027 c=*(Ke+calculationdof*0+2);4028 d=*(Ke+calculationdof*1+0);4029 e=*(Ke+calculationdof*1+1);4030 f=*(Ke+calculationdof*1+2);4031 g=*(Ke+calculationdof*2+0);4032 h=*(Ke+calculationdof*2+1);4033 i=*(Ke+calculationdof*2+2);4034 4035 det=a*(e*i-f*h)-b*(d*i-f*g)+c*(d*h-e*g);4036 4037 *(Ke_invert+calculationdof*0+0)=(e*i-f*h)/det;4038 *(Ke_invert+calculationdof*0+1)=(c*h-b*i)/det;4039 *(Ke_invert+calculationdof*0+2)=(b*f-c*e)/det;4040 *(Ke_invert+calculationdof*1+0)=(f*g-d*i)/det;4041 *(Ke_invert+calculationdof*1+1)=(a*i-c*g)/det;4042 *(Ke_invert+calculationdof*1+2)=(c*d-a*f)/det;4043 *(Ke_invert+calculationdof*2+0)=(d*h-e*g)/det;4044 *(Ke_invert+calculationdof*2+1)=(b*g-a*h)/det;4045 *(Ke_invert+calculationdof*2+2)=(a*e-b*d)/det;4046 4047 }4048 /*}}}*/4049 4016 /*FUNCTION Penta::GetParameterValue(double* pvalue, double* v_list,double* gauss_coord) {{{1*/ 4050 4017 void Penta::GetParameterValue(double* pvalue, double* v_list,double* gauss_coord){ … … 5186 5153 5187 5154 /*Inverse the matrix corresponding to bubble part Kbb */ 5188 GetMatrixInvert(&Kbbinv[0][0], &Kbb[0][0]);5155 Matrix3x3Invert(&Kbbinv[0][0], &Kbb[0][0]); 5189 5156 5190 5157 /*Multiply matrices to create the reduce matrix Ke_reduced */ … … 5230 5197 5231 5198 /*Inverse the matrix corresponding to bubble part Kbb */ 5232 GetMatrixInvert(&Kbbinv[0][0], &Kbb[0][0]);5199 Matrix3x3Invert(&Kbbinv[0][0], &Kbb[0][0]); 5233 5200 5234 5201 /*Multiply matrices to create the reduce matrix Ke_reduced */ -
issm/trunk/src/c/objects/Elements/Penta.h
r4885 r4898 140 140 void GetDofList1(int* doflist); 141 141 int GetElementType(void); 142 void GetMatrixInvert(double* Ke_invert, double* Ke);143 142 void GetNodalFunctions(double* l1l6, double* gauss_coord); 144 143 void GetNodalFunctionsDerivatives(double* dh1dh6,double* xyz_list, double* gauss_coord); -
issm/trunk/src/c/objects/Elements/PentaRef.cpp
r4885 r4898 698 698 /*On a penta, Jacobian varies according to coordinates. We need to get the Jacobian, and take 699 699 * the determinant of it: */ 700 const int NDOF3=3;701 double J[NDOF3][NDOF3]; 702 700 double J[3][3]; 701 702 /*Get Jacobian*/ 703 703 GetJacobian(&J[0][0],xyz_list,gauss); 704 704 705 *Jdet= J[0][0]*J[1][1]*J[2][2]-J[0][0]*J[1][2]*J[2][1]-J[1][0]*J[0][1]*J[2][2]+J[1][0]*J[0][2]*J[2][1]+J[2][0]*J[0][1]*J[1][2]-J[2][0]*J[0][2]*J[1][1]; 706 707 if(*Jdet<0){ 708 ISSMERROR("negative jacobian determinant!"); 709 } 705 /*Get Determinant*/ 706 Matrix3x3Determinant(Jdet,&J[0][0]); 707 if(*Jdet<0) ISSMERROR("negative jacobian determinant!"); 708 710 709 } 711 710 /*}}}*/ 712 711 /*FUNCTION PentaRef::GetJacobianInvert {{{1*/ 713 void PentaRef::GetJacobianInvert(double* 714 715 double Jdet;716 const int NDOF3=3;712 void PentaRef::GetJacobianInvert(double* Jinv, double* xyz_list,double* gauss){ 713 714 /*Jacobian*/ 715 double J[3][3]; 717 716 718 717 /*Call Jacobian routine to get the jacobian:*/ 719 GetJacobian( Jinv, xyz_list, gauss);718 GetJacobian(&J[0][0], xyz_list, gauss); 720 719 721 720 /*Invert Jacobian matrix: */ 722 Matrix Inverse(Jinv,NDOF3,NDOF3,NULL,0,&Jdet);721 Matrix3x3Invert(Jinv,&J[0][0]); 723 722 } 724 723 /*}}}*/ -
issm/trunk/src/c/objects/Elements/TriaRef.cpp
r4885 r4898 249 249 /*The Jacobian determinant is constant over the element, discard the gaussian points. 250 250 * J is assumed to have been allocated of size NDOF2xNDOF2.*/ 251 252 double x1,x2,x3,y1,y2,y3; 253 254 x1=*(xyz_list+3*0+0); 255 y1=*(xyz_list+3*0+1); 256 x2=*(xyz_list+3*1+0); 257 y2=*(xyz_list+3*1+1); 258 x3=*(xyz_list+3*2+0); 259 y3=*(xyz_list+3*2+1); 260 261 *Jdet=SQRT3/6.0*((x2-x1)*(y3-y1)-(y2-y1)*(x3-x1)); 262 263 if(Jdet<0){ 264 ISSMERROR("negative jacobian determinant!"); 265 } 251 double J[2][2]; 252 253 /*Get Jacobian*/ 254 GetJacobian(&J[0][0],xyz_list,gauss); 255 256 /*Get Determinant*/ 257 Matrix2x2Determinant(Jdet,&J[0][0]); 258 if(Jdet<0) ISSMERROR("negative jacobian determinant!"); 266 259 267 260 } … … 296 289 void TriaRef::GetJacobianInvert(double* Jinv, double* xyz_list,double* gauss){ 297 290 298 double Jdet; 299 const int NDOF2=2; 300 const int numgrids=3; 291 /*Jacobian*/ 292 double J[2][2]; 301 293 302 294 /*Call Jacobian routine to get the jacobian:*/ 303 GetJacobian( Jinv, xyz_list, gauss);295 GetJacobian(&J[0][0], xyz_list, gauss); 304 296 305 297 /*Invert Jacobian matrix: */ 306 Matrix Inverse(Jinv,NDOF2,NDOF2,NULL,0,&Jdet);298 Matrix2x2Invert(Jinv,&J[0][0]); 307 299 308 300 } -
issm/trunk/src/c/shared/Matrix/MatrixUtils.cpp
r4885 r4898 188 188 } 189 189 190 /*In debugging mode, check that we are not dealing with simple matrices*/ 191 ISSMASSERT(!(ndim==2 && nrow==2)); 192 ISSMASSERT(!(ndim==3 && nrow==3)); 193 190 194 /* initialize local variables and arrays */ 191 195 … … 338 342 return noerr; 339 343 }/*}}}*/ 344 /*FUNCTION Matrix2x2Determinant(double* Adet,double* A) {{{1*/ 345 void Matrix2x2Determinant(double* Adet,double* A){ 346 /*Compute determinant of a 2x2 matrix*/ 347 348 /*det = a*d - c*b*/ 349 *Adet= A[0]*A[3]-A[2]*A[1]; 350 } 351 /*}}}*/ 352 /*FUNCTION Matrix2x2Invert(double* Ainv,double* A) {{{1*/ 353 void Matrix2x2Invert(double* Ainv,double* A){ 354 355 /*Intermediaries*/ 356 double det; 357 358 /*Compute determinant*/ 359 Matrix2x2Determinant(&det,A); 360 if (fabs(det) < DBL_EPSILON) ISSMERROR("Determinant smaller that machine epsilon"); 361 362 /*Compute invert*/ 363 Ainv[0]= A[3]/det; /* = d/det */ 364 Ainv[1]= - A[1]/det; /* = -b/det */ 365 Ainv[2]= - A[2]/det; /* = -c/det */ 366 Ainv[3]= A[0]/det; /* = a/det */ 367 368 }/*}}}*/ 369 /*FUNCTION Matrix3x3Determinant(double* Adet,double* A) {{{1*/ 370 void Matrix3x3Determinant(double* Adet,double* A){ 371 /*Compute determinant of a 3x3 matrix*/ 372 373 /*det = a*(e*i-f*h)-b*(d*i-f*g)+c*(d*h-e*g)*/ 374 *Adet= A[0]*A[4]*A[8]-A[0]*A[5]*A[7]-A[3]*A[1]*A[8]+A[3]*A[2]*A[7]+A[6]*A[1]*A[5]-A[6]*A[2]*A[4]; 375 } 376 /*}}}*/ 377 /*FUNCTION Matrix3x3Invert(double* Ainv,double* A) {{{1*/ 378 void Matrix3x3Invert(double* Ainv,double* A){ 379 380 /*Intermediaries*/ 381 double det; 382 383 /*Compute determinant*/ 384 Matrix3x3Determinant(&det,A); 385 if (fabs(det) < DBL_EPSILON) ISSMERROR("Determinant smaller that machine epsilon"); 386 387 /*Compute invert*/ 388 Ainv[0]=(A[4]*A[8]-A[5]*A[7])/det; /* = (e*i-f*h)/det */ 389 Ainv[1]=(A[2]*A[7]-A[1]*A[8])/det; /* = (c*h-b*i)/det */ 390 Ainv[2]=(A[1]*A[5]-A[2]*A[4])/det; /* = (b*f-c*e)/det */ 391 Ainv[3]=(A[5]*A[6]-A[3]*A[8])/det; /* = (f*g-d*i)/det */ 392 Ainv[4]=(A[0]*A[8]-A[2]*A[6])/det; /* = (a*i-c*g)/det */ 393 Ainv[5]=(A[2]*A[3]-A[0]*A[5])/det; /* = (c*d-a*f)/det */ 394 Ainv[6]=(A[3]*A[7]-A[4]*A[6])/det; /* = (d*h-e*g)/det */ 395 Ainv[7]=(A[1]*A[6]-A[0]*A[7])/det; /* = (b*g-a*h)/det */ 396 Ainv[8]=(A[0]*A[4]-A[1]*A[3])/det; /* = (a*e-b*d)/det */ 397 398 }/*}}}*/ -
issm/trunk/src/c/shared/Matrix/matrix.h
r3332 r4898 4 4 5 5 #ifndef _MATRIXUTILS_H_ 6 #define 6 #define _MATRIXUTILS_H_ 7 7 8 int TripleMultiply( double* a, int nrowa, int ncola, int itrna, double* b, int nrowb, int ncolb, int itrnb, double* c, int nrowc, int ncolc, int itrnc, double* d, int iaddd); 9 int MatrixMultiply( double* a, int nrowa, int ncola, int itrna, double* b, int nrowb, int ncolb, int itrnb, double* c, int iaddc ); 10 int MatrixInverse( double* a, int ndim, int nrow, double* b, int nvec, double* pdet ); 11 8 int TripleMultiply( double* a, int nrowa, int ncola, int itrna, double* b, int nrowb, int ncolb, int itrnb, double* c, int nrowc, int ncolc, int itrnc, double* d, int iaddd); 9 int MatrixMultiply( double* a, int nrowa, int ncola, int itrna, double* b, int nrowb, int ncolb, int itrnb, double* c, int iaddc ); 10 int MatrixInverse( double* a, int ndim, int nrow, double* b, int nvec, double* pdet ); 11 void Matrix2x2Invert(double* Ainv, double* A); 12 void Matrix2x2Determinant(double* Adet,double* A); 13 void Matrix3x3Invert(double* Ainv, double* A); 14 void Matrix3x3Determinant(double* Adet,double* A); 12 15 13 16 #endif //ifndef _MATRIXUTILS_H_
Note:
See TracChangeset
for help on using the changeset viewer.