Changeset 5738
- Timestamp:
- 09/10/10 08:21:51 (15 years ago)
- Location:
- issm/trunk/src/c/objects
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk/src/c/objects/Elements/Tria.cpp
r5734 r5738 3884 3884 } 3885 3885 3886 /*Add Ke to global matrix Kgg: */3887 3886 MatSetValues(Kgg,numdof,doflist,numdof,doflist,(const double*)Ke,ADD_VALUES); 3888 3887 -
issm/trunk/src/c/objects/Elements/TriaRef.cpp
r5719 r5738 118 118 *(B+NDOF2*numgrids*2+NDOF2*i+1)=(float).5*dh1dh3[0][i]; 119 119 } 120 } 121 /*}}}*/ 122 /*FUNCTION TriaRef::GetSegmentBFlux{{{1*/ 123 void TriaRef::GetSegmentBFlux(double* B,GaussTria* gauss, int index1,int index2){ 124 /*Compute B matrix. B=[phi1 phi2 -phi3 -phi4] 125 * 126 * and phi1=phi3 phi2=phi4 127 * 128 * We assume B has been allocated already, of size: 1x4 129 */ 130 131 const int numgrids=3; 132 double l1l3[numgrids]; 133 134 GetNodalFunctions(&l1l3[0],gauss); 135 136 B[0] = +l1l3[index1]; 137 B[1] = +l1l3[index2]; 138 B[2] = -l1l3[index1]; 139 B[3] = -l1l3[index2]; 140 } 141 /*}}}*/ 142 /*FUNCTION TriaRef::GetSegmentBprimeFlux{{{1*/ 143 void TriaRef::GetSegmentBprimeFlux(double* Bprime,GaussTria* gauss, int index1,int index2){ 144 /*Compute Bprime matrix. Bprime=[phi1 phi2 phi3 phi4] 145 * 146 * and phi1=phi3 phi2=phi4 147 * 148 * We assume Bprime has been allocated already, of size: 1x4 149 */ 150 151 const int numgrids=3; 152 double l1l3[numgrids]; 153 154 GetNodalFunctions(&l1l3[0],gauss); 155 156 Bprime[0] = l1l3[index1]; 157 Bprime[1] = l1l3[index2]; 158 Bprime[2] = l1l3[index1]; 159 Bprime[3] = l1l3[index2]; 120 160 } 121 161 /*}}}*/ -
issm/trunk/src/c/objects/Elements/TriaRef.h
r5719 r5738 48 48 void GetNodalFunctions(double* l1l2l3,GaussTria* gauss); 49 49 void GetSegmentNodalFunctions(double* l1l2l3,GaussTria* gauss, int index1,int index2); 50 void GetSegmentBFlux(double* B,GaussTria* gauss, int index1,int index2); 51 void GetSegmentBprimeFlux(double* Bprime,GaussTria* gauss, int index1,int index2); 50 52 void GetNodalFunctionsDerivatives(double* l1l2l3,double* xyz_list, double* gauss); 51 53 void GetNodalFunctionsDerivatives(double* l1l2l3,double* xyz_list, GaussTria* gauss); -
issm/trunk/src/c/objects/Loads/Numericalflux.cpp
r5737 r5738 3 3 */ 4 4 5 /*Headers:*/ 6 /*{{{1*/ 5 7 #ifdef HAVE_CONFIG_H 6 8 #include "config.h" 7 9 #else 8 10 #error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!" … … 15 17 #include "../../include/include.h" 16 18 #include "../objects.h" 17 18 extern int my_rank; 19 /*}}}*/ 20 21 /*Load macros*/ 22 #define NUMVERTICES 4 23 #define NDOF1 1 19 24 20 25 /*Numericalflux constructors and destructor*/ … … 394 399 void Numericalflux::CreateKMatrixInternal(Mat Kgg){ 395 400 396 /* local declarations */ 397 int i,j,ig; 398 int analysis_type; 399 400 /* node data: */ 401 const int numgrids=4; 402 const int NDOF1=1; 403 const int numdof=NDOF1*numgrids; 404 double xyz_list[numgrids][3]; 405 double normal[2]; 406 int* doflist=NULL; 407 408 /* gaussian points: */ 409 int num_gauss; 410 double* gauss_coords =NULL; 411 double gauss_coord; 412 double* gauss_weights=NULL; 413 double gauss_weight; 414 415 /* matrices: */ 416 double B[numgrids]; 417 double L[numgrids]; 418 double DL1,DL2; 419 double Ke_gg1[numdof][numdof]; 420 double Ke_gg2[numdof][numdof]; 421 double Ke_gg[numdof][numdof]={0.0}; 422 double Jdet; 423 424 /*input parameters for structural analysis (diagnostic): */ 425 double vx,vy; 426 double UdotN; 427 double dt; 428 int found; 429 int dim; 430 431 /*dynamic objects pointed to by hooks: */ 432 Input *vxaverage_input = NULL; 433 Input *vyaverage_input = NULL; 434 435 /*Retrieve parameters: */ 401 /* constants*/ 402 const int numdof=NDOF1*NUMVERTICES; 403 404 /* Intermediaries*/ 405 int i,j,ig,index1,index2,analysis_type; 406 double DL1,DL2,Jdet,dt,vx,vy,UdotN; 407 double xyz_list[NUMVERTICES][3]; 408 double normal[2]; 409 double B[numdof]; 410 double Bprime[numdof]; 411 double Ke_gg1[numdof][numdof]; 412 double Ke_gg2[numdof][numdof]; 413 double Ke_gg[numdof][numdof] = {0.0}; 414 int *doflist = NULL; 415 GaussTria *gauss; 416 417 GetVerticesCoordinates(&xyz_list[0][0], nodes,NUMVERTICES); 418 GetDofList(&doflist); 419 420 /*Retrieve all inputs and parameters we will be needing: */ 421 Tria* tria=(Tria*)element; 422 Input* vxaverage_input=tria->inputs->GetInput(VxEnum); 423 Input* vyaverage_input=tria->inputs->GetInput(VyEnum); 436 424 this->parameters->FindParam(&analysis_type,AnalysisTypeEnum); 437 parameters->FindParam(&dim,DimEnum);438 439 /*recover objects from hooks: */440 Tria* tria=(Tria*)element;441 442 /*recover parameters: */443 if (analysis_type==PrognosticAnalysisEnum){444 parameters->FindParam(&dt,DtEnum);445 }446 else if (analysis_type==BalancedthicknessAnalysisEnum || analysis_type==AdjointBalancedthicknessAnalysisEnum){447 /*No transient term is involved*/448 dt=1;449 }450 else{451 ISSMERROR("analysis_type %s not supported yet",EnumToString(analysis_type));452 }453 454 /* Get node coordinates, dof list and normal vector: */455 GetVerticesCoordinates(&xyz_list[0][0], nodes, numgrids);456 GetDofList(&doflist);457 425 GetNormal(&normal[0],xyz_list); 458 459 /*Retrieve all inputs we will be needing: */ 460 if(dim==2){ 461 vxaverage_input=tria->inputs->GetInput(VxEnum); 462 vyaverage_input=tria->inputs->GetInput(VyEnum); 463 } 464 465 /* Get gaussian points and weights (make this a statically initialized list of points? fstd): */ 466 num_gauss=2; 467 gaussSegment(&gauss_coords, &gauss_weights,num_gauss); 426 switch(analysis_type){ 427 case PrognosticAnalysisEnum: 428 parameters->FindParam(&dt,DtEnum); break; 429 case BalancedthicknessAnalysisEnum: case AdjointBalancedthicknessAnalysisEnum: 430 dt=1; break;/*No transient term is involved*/ 431 default: 432 ISSMERROR("analysis_type %s not supported yet",EnumToString(analysis_type)); 433 } 468 434 469 435 /* Start looping on the number of gaussian points: */ 470 for (ig=0; ig<num_gauss; ig++){ 471 472 /*Pick up the gaussian point: */ 473 gauss_weight=gauss_weights[ig]; 474 gauss_coord =gauss_coords[ig]; 475 476 /* Get Jacobian determinant: */ 477 GetJacobianDeterminant(&Jdet,xyz_list,gauss_coord); 478 479 //Get vx, vy and v.n 480 this->GetParameterValue(&vx,gauss_coord,vxaverage_input); 481 this->GetParameterValue(&vy,gauss_coord,vyaverage_input); 482 436 index1=tria->GetNodeIndex(nodes[0]); 437 index2=tria->GetNodeIndex(nodes[1]); 438 gauss=new GaussTria(index1,index2,2); 439 for(ig=gauss->begin();ig<gauss->end();ig++){ 440 441 gauss->GaussPoint(ig); 442 443 tria->GetSegmentBFlux(&B[0],gauss,index1,index2); 444 tria->GetSegmentBprimeFlux(&Bprime[0],gauss,index1,index2); 445 446 vxaverage_input->GetParameterValue(&vx,gauss); 447 vyaverage_input->GetParameterValue(&vy,gauss); 483 448 UdotN=vx*normal[0]+vy*normal[1]; 484 // if (fabs(UdotN)<1.0e-9 && analysis_type==BalancedthicknessAnalysisEnum) printf("Edge number %i has a flux very small (u.n = %g ), which could lead to unaccurate results\n",id,UdotN); 485 486 /*Get L and B: */ 487 GetL(&L[0],gauss_coord,numdof); 488 GetB(&B[0],gauss_coord); 489 490 /*Compute DLs*/ 491 DL1=gauss_weight*Jdet*dt*UdotN/2; 492 DL2=gauss_weight*Jdet*dt*fabs(UdotN)/2; 493 494 /* Do the triple products: */ 449 tria->GetSegmentJacobianDeterminant(&Jdet,&xyz_list[0][0],gauss); 450 DL1=gauss->weight*Jdet*dt*UdotN/2; 451 DL2=gauss->weight*Jdet*dt*fabs(UdotN)/2; 452 495 453 TripleMultiply(&B[0],1,numdof,1, 496 454 &DL1,1,1,0, 497 & L[0],1,numdof,0,455 &Bprime[0],1,numdof,0, 498 456 &Ke_gg1[0][0],0); 499 457 TripleMultiply(&B[0],1,numdof,1, … … 502 460 &Ke_gg2[0][0],0); 503 461 504 /* Add the Ke_gg_gaussian, and optionally Ke_gg_drag_gaussian onto Ke_gg: */ 505 for( i=0; i<numdof; i++) for(j=0;j<numdof;j++) Ke_gg[i][j]+=Ke_gg1[i][j]; 506 for( i=0; i<numdof; i++) for(j=0;j<numdof;j++) Ke_gg[i][j]+=Ke_gg2[i][j]; 507 508 } // for (ig=0; ig<num_gauss; ig++) 509 510 /*Add Ke_gg to global matrix Kgg: */ 462 for(i=0;i<numdof;i++) for(j=0;j<numdof;j++) Ke_gg[i][j]+=Ke_gg1[i][j]; 463 for(i=0;i<numdof;i++) for(j=0;j<numdof;j++) Ke_gg[i][j]+=Ke_gg2[i][j]; 464 } 465 511 466 MatSetValues(Kgg,numdof,doflist,numdof,doflist,(const double*)Ke_gg,ADD_VALUES); 512 513 xfree((void**)&gauss_coords);514 xfree((void**)&gauss_weights);515 467 516 468 /*Free ressources:*/ 469 delete gauss; 517 470 xfree((void**)&doflist); 518 471 … … 528 481 /* node data: */ 529 482 const int numgrids=2; 530 const int NDOF1=1;531 483 const int numdof=NDOF1*numgrids; 532 484 double xyz_list[numgrids][3]; … … 555 507 double dt; 556 508 int dofs[1]={0}; 557 int found;558 509 int dim; 559 510 … … 668 619 /* node data: */ 669 620 const int numgrids=2; 670 const int NDOF1=1;671 621 const int numdof=NDOF1*numgrids; 672 622 double xyz_list[numgrids][3]; … … 695 645 double dt; 696 646 int dofs[1]={0}; 697 int found;698 647 int dim; 699 648
Note:
See TracChangeset
for help on using the changeset viewer.