Changeset 24088
- Timestamp:
- 07/14/19 19:14:42 (6 years ago)
- Location:
- issm/trunk-jpl/src/c
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/c/classes/Elements/Tria.cpp
r24049 r24088 2021 2021 } 2022 2022 _error_("Node provided not found among element nodes"); 2023 } 2024 /*}}}*/ 2025 int Tria::GetVertexIndex(Vertex* vertex){/*{{{*/ 2026 2027 _assert_(vertices); 2028 for(int i=0;i<NUMVERTICES;i++){ 2029 if(vertex==vertices[i]) 2030 return i; 2031 } 2032 _error_("Vertex provided not found among element nodes"); 2023 2033 } 2024 2034 /*}}}*/ … … 4429 4439 /*Recover nodes ids needed to initialize the node hook.*/ 4430 4440 switch(finiteelement_type){ 4441 case P0DGEnum: 4442 numnodes = 1; 4443 tria_node_ids = xNew<int>(numnodes); 4444 tria_node_ids[0]= index + 1; 4445 break; 4431 4446 case P1Enum: 4432 4447 numnodes = 3; -
issm/trunk-jpl/src/c/classes/Elements/Tria.h
r24049 r24088 85 85 void GetLevelCoordinates(IssmDouble** pxyz_front,IssmDouble* xyz_list,int levelsetenum,IssmDouble level); 86 86 int GetNodeIndex(Node* node); 87 int GetVertexIndex(Vertex* vertex); 87 88 int GetNumberOfNodes(void); 88 89 int GetNumberOfNodes(int enum_type); -
issm/trunk-jpl/src/c/classes/Loads/Numericalflux.cpp
r23959 r24088 17 17 /*Load macros*/ 18 18 #define NUMVERTICES 2 19 #define NUMNODES_INTERNAL 420 #define NUMNODES_BOUNDARY 221 19 22 20 /*Numericalflux constructors and destructor*/ … … 33 31 34 32 /* Intermediary */ 35 int j; 36 int pos1,pos2,pos3,pos4; 37 int num_nodes; 33 int pos1,pos2,pos3,pos4; 34 int num_nodes; 38 35 39 36 /*numericalflux constructor data: */ 40 int numericalflux_elem_ids[2]; 41 int numericalflux_vertex_ids[2]; 42 int numericalflux_node_ids[4]; 43 int numericalflux_type; 37 int numericalflux_elem_ids[2]; 38 int numericalflux_vertex_ids[2]; 39 int numericalflux_node_ids[4]; 40 int numericalflux_type; 41 int numericalflux_degree; 44 42 45 43 /*Get edge*/ … … 58 56 else{ 59 57 /* internal edge: connected to 2 elements */ 60 58 num_nodes=4; 61 59 numericalflux_type=InternalEnum; 62 60 numericalflux_elem_ids[0]=e1; … … 64 62 } 65 63 64 /*FIXME: hardcode element degree for now*/ 65 this->flux_degree= P1DGEnum; 66 66 67 /*1: Get vertices ids*/ 67 68 numericalflux_vertex_ids[0]=i1; … … 69 70 70 71 /*2: Get node ids*/ 71 if (numericalflux_type==InternalEnum){ 72 73 /*Now, we must get the nodes of the 4 nodes located on the edge*/ 74 75 /*2: Get the column where these ids are located in the index*/ 72 if(numericalflux_type==InternalEnum){ 73 /*Get the column where these ids are located in the index*/ 76 74 pos1=pos2=pos3=pos4=UNDEF; 77 for( j=0;j<3;j++){75 for(int j=0;j<3;j++){ 78 76 if(iomodel->elements[3*(e1-1)+j]==i1) pos1=j+1; 79 77 if(iomodel->elements[3*(e1-1)+j]==i2) pos2=j+1; … … 83 81 _assert_(pos1!=UNDEF && pos2!=UNDEF && pos3!=UNDEF && pos4!=UNDEF); 84 82 85 /* 3:We have the id of the elements and the position of the vertices in the index83 /* We have the id of the elements and the position of the vertices in the index 86 84 * we can compute their dofs!*/ 87 85 numericalflux_node_ids[0]=3*(e1-1)+pos1; … … 91 89 } 92 90 else{ 93 94 /*2: Get the column where these ids are located in the index*/ 91 /*Get the column where these ids are located in the index*/ 95 92 pos1=pos2=UNDEF; 96 for( j=0;j<3;j++){93 for(int j=0;j<3;j++){ 97 94 if(iomodel->elements[3*(e1-1)+j]==i1) pos1=j+1; 98 95 if(iomodel->elements[3*(e1-1)+j]==i2) pos2=j+1; … … 100 97 _assert_(pos1!=UNDEF && pos2!=UNDEF); 101 98 102 /* 3:We have the id of the elements and the position of the vertices in the index99 /* We have the id of the elements and the position of the vertices in the index 103 100 * we can compute their dofs!*/ 104 101 numericalflux_node_ids[0]=3*(e1-1)+pos1; … … 106 103 } 107 104 108 /*Ok, we have everything to build the object: */ 109 this->id=numericalflux_id; 110 this->flux_type = numericalflux_type; 105 /*Assign object fields: */ 106 this->id = numericalflux_id; 107 this->flux_type = numericalflux_type; 108 this->flux_degree = numericalflux_degree; 111 109 112 110 /*Hooks: */ 113 this->hnodes = new Hook(numericalflux_node_ids,num_nodes);114 this->hvertices = new Hook(&numericalflux_vertex_ids[0],2);115 this->helement = new Hook(numericalflux_elem_ids,1); // take only the first element for now116 117 / /this->parameters: we still can't point to it, it may not even exist. Configure will handle this.118 this->parameters =NULL;119 this->element =NULL;120 this->nodes =NULL;111 this->hnodes = new Hook(numericalflux_node_ids,num_nodes); 112 this->hvertices = new Hook(&numericalflux_vertex_ids[0],2); 113 this->helement = new Hook(numericalflux_elem_ids,1); // take only the first element for now 114 115 /*other fields*/ 116 this->parameters = NULL; 117 this->element = NULL; 118 this->nodes = NULL; 121 119 } 122 120 /*}}}*/ … … 139 137 numericalflux->id=this->id; 140 138 numericalflux->flux_type=this->flux_type; 139 numericalflux->flux_degree=this->flux_degree; 141 140 142 141 /*point parameters: */ … … 161 160 _printf_(" id: " << id << "\n"); 162 161 _printf_(" flux_type: " << this->flux_type<< "\n"); 162 _printf_(" flux_degree: " << this->flux_degree<< "\n"); 163 163 hnodes->DeepEcho(); 164 164 hvertices->DeepEcho(); … … 175 175 _printf_(" id: " << id << "\n"); 176 176 _printf_(" flux_type: " << this->flux_type<< "\n"); 177 _printf_(" flux_degree: " << this->flux_degree<< "\n"); 177 178 hnodes->Echo(); 178 179 hvertices->Echo(); … … 193 194 MARSHALLING(id); 194 195 MARSHALLING(flux_type); 196 MARSHALLING(flux_degree); 195 197 196 198 if(marshall_direction==MARSHALLING_BACKWARD){ … … 300 302 _assert_(nodes); 301 303 302 switch(this->flux_type){ 303 case InternalEnum: 304 for(int i=0;i<NUMNODES_INTERNAL;i++) lidlist[i]=nodes[i]->Lid(); 305 return; 306 case BoundaryEnum: 307 for(int i=0;i<NUMNODES_BOUNDARY;i++) lidlist[i]=nodes[i]->Lid(); 308 return; 309 default: 310 _error_("Numericalflux type " << EnumToStringx(this->flux_type) << " not supported yet"); 311 } 304 int numnodes = this->GetNumberOfNodes(); 305 for(int i=0;i<numnodes;i++) lidlist[i]=nodes[i]->Lid(); 312 306 } 313 307 /*}}}*/ … … 317 311 _assert_(nodes); 318 312 319 switch(this->flux_type){ 320 case InternalEnum: 321 for(int i=0;i<NUMNODES_INTERNAL;i++) sidlist[i]=nodes[i]->Sid(); 322 return; 323 case BoundaryEnum: 324 for(int i=0;i<NUMNODES_BOUNDARY;i++) sidlist[i]=nodes[i]->Sid(); 325 return; 326 default: 327 _error_("Numericalflux type " << EnumToStringx(this->flux_type) << " not supported yet"); 328 } 313 int numnodes = this->GetNumberOfNodes(); 314 for(int i=0;i<numnodes;i++) sidlist[i]=nodes[i]->Sid(); 329 315 } 330 316 /*}}}*/ 331 317 int Numericalflux::GetNumberOfNodes(void){/*{{{*/ 332 318 333 switch(this->flux_type){ 334 case InternalEnum: 335 return NUMNODES_INTERNAL; 336 case BoundaryEnum: 337 return NUMNODES_BOUNDARY; 338 default: 339 _error_("Numericalflux type " << EnumToStringx(this->flux_type) << " not supported yet"); 319 if(this->flux_degree==P0DGEnum){ 320 switch(this->flux_type){ 321 case InternalEnum: 322 return 2; 323 case BoundaryEnum: 324 return 1; 325 default: 326 _error_("Numericalflux type " << EnumToStringx(this->flux_type) << " not supported yet"); 327 } 328 } 329 else if(this->flux_degree==P1DGEnum){ 330 switch(this->flux_type){ 331 case InternalEnum: 332 return 4; 333 case BoundaryEnum: 334 return 2; 335 default: 336 _error_("Numericalflux type " << EnumToStringx(this->flux_type) << " not supported yet"); 337 } 338 } 339 else{ 340 _error_("Numericalflux " << EnumToStringx(this->flux_degree) << " not supported yet"); 340 341 } 341 342 … … 474 475 ElementMatrix* Numericalflux::CreateKMatrixBalancethicknessBoundary(void){/*{{{*/ 475 476 476 /* constants*/ 477 const int numdof=NDOF1*NUMNODES_BOUNDARY; 477 /*Initialize Element matrix and return if necessary*/ 478 Tria* tria=(Tria*)element; 479 if(!tria->IsIceInElement()) return NULL; 478 480 479 481 /* Intermediaries*/ 480 int i,j,ig,index1,index2; 481 IssmDouble DL,Jdet,vx,vy,mean_vx,mean_vy,UdotN; 482 IssmDouble xyz_list[NUMVERTICES][3]; 483 IssmDouble normal[2]; 484 IssmDouble L[numdof]; 485 IssmDouble Ke_g[numdof][numdof]; 486 GaussTria *gauss; 487 488 /*Initialize Element matrix and return if necessary*/ 489 ElementMatrix* Ke = NULL; 490 Tria* tria=(Tria*)element; 491 if(!tria->IsIceInElement()) return NULL; 482 IssmDouble DL,Jdet,vx,vy,mean_vx,mean_vy; 483 IssmDouble xyz_list[NUMVERTICES][3]; 484 IssmDouble normal[2]; 492 485 493 486 /*Retrieve all inputs and parameters*/ … … 498 491 499 492 /*Check wether it is an inflow or outflow BC (0 is the middle of the segment)*/ 500 in dex1=tria->GetNodeIndex(nodes[0]);501 in dex2=tria->GetNodeIndex(nodes[1]);502 503 gauss=new GaussTria();493 int index1=tria->GetVertexIndex(vertices[0]); 494 int index2=tria->GetVertexIndex(vertices[1]); 495 496 GaussTria* gauss=new GaussTria(); 504 497 gauss->GaussEdgeCenter(index1,index2); 505 498 vxaverage_input->GetInputValue(&mean_vx,gauss); … … 507 500 delete gauss; 508 501 509 UdotN=mean_vx*normal[0]+mean_vy*normal[1];510 if 502 IssmDouble UdotN=mean_vx*normal[0]+mean_vy*normal[1]; 503 if(UdotN<=0){ 511 504 return NULL; /*(u,n)<0 -> inflow, PenaltyCreatePVector will take care of it*/ 512 505 } 513 else{ 514 Ke=new ElementMatrix(nodes,NUMNODES_BOUNDARY,this->parameters); 515 } 506 507 /*Initialize Element vector and other vectors*/ 508 int numnodes = this->GetNumberOfNodes(); 509 ElementMatrix *Ke = new ElementMatrix(nodes,numnodes,this->parameters); 510 IssmDouble *basis = xNew<IssmDouble>(numnodes); 516 511 517 512 /* Start looping on the number of gaussian points: */ 518 513 gauss=new GaussTria(index1,index2,2); 519 for(i g=gauss->begin();ig<gauss->end();ig++){514 for(int ig=gauss->begin();ig<gauss->end();ig++){ 520 515 521 516 gauss->GaussPoint(ig); 522 517 523 tria->GetSegmentNodalFunctions(& L[0],gauss,index1,index2,tria->FiniteElement());518 tria->GetSegmentNodalFunctions(&basis[0],gauss,index1,index2,tria->FiniteElement()); 524 519 525 520 vxaverage_input->GetInputValue(&vx,gauss); … … 529 524 DL=gauss->weight*Jdet*UdotN; 530 525 531 TripleMultiply(&L[0],1,numdof,1, 532 &DL,1,1,0, 533 &L[0],1,numdof,0, 534 &Ke_g[0][0],0); 535 536 for(i=0;i<numdof;i++) for(j=0;j<numdof;j++) Ke->values[i*numdof+j]+=Ke_g[i][j]; 526 for(int i=0;i<numnodes;i++){ 527 for(int j=0;j<numnodes;j++){ 528 Ke->values[i*numnodes+j]+=DL*basis[i]*basis[j]; 529 } 530 } 537 531 } 538 532 539 533 /*Clean up and return*/ 534 xDelete<IssmDouble>(basis); 540 535 delete gauss; 541 536 return Ke; … … 543 538 /*}}}*/ 544 539 ElementMatrix* Numericalflux::CreateKMatrixBalancethicknessInternal(void){/*{{{*/ 545 546 /* constants*/547 const int numdof=NDOF1*NUMNODES_INTERNAL;548 549 /* Intermediaries*/550 int i,j,ig,index1,index2;551 IssmDouble DL1,DL2,Jdet,vx,vy,UdotN;552 IssmDouble xyz_list[NUMVERTICES][3];553 IssmDouble normal[2];554 IssmDouble B[numdof];555 IssmDouble Bprime[numdof];556 IssmDouble Ke_g1[numdof][numdof];557 IssmDouble Ke_g2[numdof][numdof];558 GaussTria *gauss;559 540 560 541 /*Initialize Element matrix and return if necessary*/ 561 542 Tria* tria=(Tria*)element; 562 543 if(!tria->IsIceInElement()) return NULL; 563 ElementMatrix* Ke=new ElementMatrix(nodes,NUMNODES_INTERNAL,this->parameters); 544 545 /* Intermediaries*/ 546 IssmDouble DL1,DL2,Jdet,vx,vy,UdotN; 547 IssmDouble xyz_list[NUMVERTICES][3]; 548 IssmDouble normal[2]; 549 550 /*Fetch number of nodes for this flux*/ 551 int numnodes = this->GetNumberOfNodes(); 552 553 /*Initialize variables*/ 554 ElementMatrix *Ke = new ElementMatrix(nodes,numnodes,this->parameters); 555 IssmDouble *B = xNew<IssmDouble>(numnodes); 556 IssmDouble *Bprime = xNew<IssmDouble>(numnodes); 564 557 565 558 /*Retrieve all inputs and parameters*/ … … 570 563 571 564 /* Start looping on the number of gaussian points: */ 572 in dex1=tria->GetNodeIndex(nodes[0]);573 in dex2=tria->GetNodeIndex(nodes[1]);574 gauss=new GaussTria(index1,index2,2);575 for(i g=gauss->begin();ig<gauss->end();ig++){565 int index1=tria->GetVertexIndex(vertices[0]); 566 int index2=tria->GetVertexIndex(vertices[1]); 567 GaussTria* gauss=new GaussTria(index1,index2,2); 568 for(int ig=gauss->begin();ig<gauss->end();ig++){ 576 569 577 570 gauss->GaussPoint(ig); … … 587 580 DL2=gauss->weight*Jdet*fabs(UdotN)/2; 588 581 589 TripleMultiply(&B[0],1,numdof,1, 590 &DL1,1,1,0, 591 &Bprime[0],1,numdof,0, 592 &Ke_g1[0][0],0); 593 TripleMultiply(&B[0],1,numdof,1, 594 &DL2,1,1,0, 595 &B[0],1,numdof,0, 596 &Ke_g2[0][0],0); 597 598 for(i=0;i<numdof;i++) for(j=0;j<numdof;j++) Ke->values[i*numdof+j]+=Ke_g1[i][j]; 599 for(i=0;i<numdof;i++) for(j=0;j<numdof;j++) Ke->values[i*numdof+j]+=Ke_g2[i][j]; 582 for(int i=0;i<numnodes;i++){ 583 for(int j=0;j<numnodes;j++){ 584 Ke->values[i*numnodes+j]+=DL1*B[i]*Bprime[j]; 585 Ke->values[i*numnodes+j]+=DL2*B[i]*B[j]; 586 } 587 } 600 588 } 601 589 602 590 /*Clean up and return*/ 591 xDelete<IssmDouble>(B); 592 xDelete<IssmDouble>(Bprime); 603 593 delete gauss; 604 594 return Ke; … … 619 609 ElementMatrix* Numericalflux::CreateKMatrixMasstransportBoundary(void){/*{{{*/ 620 610 621 /* constants*/622 const int numdof=NDOF1*NUMNODES_BOUNDARY;623 624 /* Intermediaries*/625 int i,j,ig,index1,index2;626 IssmDouble DL,Jdet,dt,vx,vy,mean_vx,mean_vy,UdotN;627 IssmDouble xyz_list[NUMVERTICES][3];628 IssmDouble normal[2];629 IssmDouble L[numdof];630 IssmDouble Ke_g[numdof][numdof];631 GaussTria *gauss;632 633 611 /*Initialize Element matrix and return if necessary*/ 634 ElementMatrix* Ke = NULL;635 612 Tria* tria=(Tria*)element; 636 613 if(!tria->IsIceInElement()) return NULL; 637 614 615 /* Intermediaries*/ 616 IssmDouble DL,Jdet,vx,vy,mean_vx,mean_vy; 617 IssmDouble xyz_list[NUMVERTICES][3]; 618 IssmDouble normal[2]; 619 638 620 /*Retrieve all inputs and parameters*/ 639 621 GetVerticesCoordinates(&xyz_list[0][0],vertices,NUMVERTICES); 640 parameters->FindParam(&dt,TimesteppingTimeStepEnum);622 IssmDouble dt = parameters->FindParam(TimesteppingTimeStepEnum); 641 623 Input* vxaverage_input=tria->inputs->GetInput(VxEnum); _assert_(vxaverage_input); 642 624 Input* vyaverage_input=tria->inputs->GetInput(VyEnum); _assert_(vyaverage_input); … … 644 626 645 627 /*Check wether it is an inflow or outflow BC (0 is the middle of the segment)*/ 646 in dex1=tria->GetNodeIndex(nodes[0]);647 in dex2=tria->GetNodeIndex(nodes[1]);648 649 gauss=new GaussTria();628 int index1=tria->GetVertexIndex(vertices[0]); 629 int index2=tria->GetVertexIndex(vertices[1]); 630 631 GaussTria* gauss=new GaussTria(); 650 632 gauss->GaussEdgeCenter(index1,index2); 651 633 vxaverage_input->GetInputValue(&mean_vx,gauss); … … 653 635 delete gauss; 654 636 655 UdotN=mean_vx*normal[0]+mean_vy*normal[1];656 if 637 IssmDouble UdotN=mean_vx*normal[0]+mean_vy*normal[1]; 638 if(UdotN<=0){ 657 639 return NULL; /*(u,n)<0 -> inflow, PenaltyCreatePVector will take care of it*/ 658 640 } 659 else{ 660 Ke=new ElementMatrix(nodes,NUMNODES_BOUNDARY,this->parameters); 661 } 641 642 /*Initialize Element vector and other vectors*/ 643 int numnodes = this->GetNumberOfNodes(); 644 ElementMatrix *Ke = new ElementMatrix(nodes,numnodes,this->parameters); 645 IssmDouble *basis = xNew<IssmDouble>(numnodes); 662 646 663 647 /* Start looping on the number of gaussian points: */ 664 648 gauss=new GaussTria(index1,index2,2); 665 for(i g=gauss->begin();ig<gauss->end();ig++){649 for(int ig=gauss->begin();ig<gauss->end();ig++){ 666 650 667 651 gauss->GaussPoint(ig); 668 652 669 tria->GetSegmentNodalFunctions(& L[0],gauss,index1,index2,tria->FiniteElement());653 tria->GetSegmentNodalFunctions(&basis[0],gauss,index1,index2,tria->FiniteElement()); 670 654 671 655 vxaverage_input->GetInputValue(&vx,gauss); … … 675 659 DL=gauss->weight*Jdet*dt*UdotN; 676 660 677 TripleMultiply(&L[0],1,numdof,1, 678 &DL,1,1,0, 679 &L[0],1,numdof,0, 680 &Ke_g[0][0],0); 681 682 for(i=0;i<numdof;i++) for(j=0;j<numdof;j++) Ke->values[i*numdof+j]+=Ke_g[i][j]; 661 for(int i=0;i<numnodes;i++){ 662 for(int j=0;j<numnodes;j++){ 663 Ke->values[i*numnodes+j]+=DL*basis[i]*basis[j]; 664 } 665 } 683 666 } 684 667 685 668 /*Clean up and return*/ 669 xDelete<IssmDouble>(basis); 686 670 delete gauss; 687 671 return Ke; … … 689 673 /*}}}*/ 690 674 ElementMatrix* Numericalflux::CreateKMatrixMasstransportInternal(void){/*{{{*/ 691 692 /* constants*/693 const int numdof=NDOF1*NUMNODES_INTERNAL;694 695 /* Intermediaries*/696 int i,j,ig,index1,index2;697 IssmDouble DL1,DL2,Jdet,dt,vx,vy,UdotN;698 IssmDouble xyz_list[NUMVERTICES][3];699 IssmDouble normal[2];700 IssmDouble B[numdof];701 IssmDouble Bprime[numdof];702 IssmDouble Ke_g1[numdof][numdof];703 IssmDouble Ke_g2[numdof][numdof];704 GaussTria *gauss;705 675 706 676 /*Initialize Element matrix and return if necessary*/ 707 677 Tria* tria=(Tria*)element; 708 678 if(!tria->IsIceInElement()) return NULL; 709 ElementMatrix* Ke=new ElementMatrix(nodes,NUMNODES_INTERNAL,this->parameters); 679 680 /* Intermediaries*/ 681 IssmDouble DL1,DL2,Jdet,vx,vy,UdotN; 682 IssmDouble xyz_list[NUMVERTICES][3]; 683 IssmDouble normal[2]; 684 685 /*Fetch number of nodes for this flux*/ 686 int numnodes = this->GetNumberOfNodes(); 687 688 /*Initialize variables*/ 689 ElementMatrix *Ke = new ElementMatrix(nodes,numnodes,this->parameters); 690 IssmDouble *B = xNew<IssmDouble>(numnodes); 691 IssmDouble *Bprime = xNew<IssmDouble>(numnodes); 710 692 711 693 /*Retrieve all inputs and parameters*/ 712 694 GetVerticesCoordinates(&xyz_list[0][0],vertices,NUMVERTICES); 713 parameters->FindParam(&dt,TimesteppingTimeStepEnum);695 IssmDouble dt = parameters->FindParam(TimesteppingTimeStepEnum); 714 696 Input* vxaverage_input=tria->inputs->GetInput(VxEnum); 715 697 Input* vyaverage_input=tria->inputs->GetInput(VyEnum); … … 717 699 718 700 /* Start looping on the number of gaussian points: */ 719 in dex1=tria->GetNodeIndex(nodes[0]);720 in dex2=tria->GetNodeIndex(nodes[1]);721 gauss=new GaussTria(index1,index2,2);722 for(i g=gauss->begin();ig<gauss->end();ig++){701 int index1=tria->GetVertexIndex(vertices[0]); 702 int index2=tria->GetVertexIndex(vertices[1]); 703 GaussTria* gauss=new GaussTria(index1,index2,2); 704 for(int ig=gauss->begin();ig<gauss->end();ig++){ 723 705 724 706 gauss->GaussPoint(ig); … … 734 716 DL2=gauss->weight*Jdet*dt*fabs(UdotN)/2; 735 717 736 TripleMultiply(&B[0],1,numdof,1, 737 &DL1,1,1,0, 738 &Bprime[0],1,numdof,0, 739 &Ke_g1[0][0],0); 740 TripleMultiply(&B[0],1,numdof,1, 741 &DL2,1,1,0, 742 &B[0],1,numdof,0, 743 &Ke_g2[0][0],0); 744 745 for(i=0;i<numdof;i++) for(j=0;j<numdof;j++) Ke->values[i*numdof+j]+=Ke_g1[i][j]; 746 for(i=0;i<numdof;i++) for(j=0;j<numdof;j++) Ke->values[i*numdof+j]+=Ke_g2[i][j]; 718 for(int i=0;i<numnodes;i++){ 719 for(int j=0;j<numnodes;j++){ 720 Ke->values[i*numnodes+j]+=DL1*B[i]*Bprime[j]; 721 Ke->values[i*numnodes+j]+=DL2*B[i]*B[j]; 722 } 723 } 747 724 } 748 725 749 726 /*Clean up and return*/ 727 xDelete<IssmDouble>(B); 728 xDelete<IssmDouble>(Bprime); 750 729 delete gauss; 751 730 return Ke; … … 772 751 ElementVector* Numericalflux::CreatePVectorBalancethicknessBoundary(void){/*{{{*/ 773 752 774 /* constants*/ 775 const int numdof=NDOF1*NUMNODES_BOUNDARY; 753 /*Initialize Load Vector and return if necessary*/ 754 Tria* tria=(Tria*)element; 755 if(!tria->IsIceInElement()) return NULL; 776 756 777 757 /* Intermediaries*/ 778 int i,ig,index1,index2; 779 IssmDouble DL,Jdet,vx,vy,mean_vx,mean_vy,UdotN,thickness; 758 IssmDouble DL,Jdet,vx,vy,mean_vx,mean_vy,thickness; 780 759 IssmDouble xyz_list[NUMVERTICES][3]; 781 760 IssmDouble normal[2]; 782 IssmDouble L[numdof];783 GaussTria *gauss;784 785 /*Initialize Load Vector and return if necessary*/786 ElementVector* pe = NULL;787 Tria* tria=(Tria*)element;788 if(!tria->IsIceInElement()) return NULL;789 761 790 762 /*Retrieve all inputs and parameters*/ 791 763 GetVerticesCoordinates(&xyz_list[0][0],vertices,NUMVERTICES); 792 Input* vxaverage_input =tria->inputs->GetInput(VxEnum); _assert_(vxaverage_input);793 Input* vyaverage_input =tria->inputs->GetInput(VyEnum);_assert_(vyaverage_input);794 Input* thickness_input =tria->inputs->GetInput(ThicknessEnum); _assert_(thickness_input);764 Input* vxaverage_input = tria->inputs->GetInput(VxEnum); _assert_(vxaverage_input); 765 Input* vyaverage_input = tria->inputs->GetInput(VyEnum); _assert_(vyaverage_input); 766 Input* thickness_input = tria->inputs->GetInput(ThicknessEnum); _assert_(thickness_input); 795 767 GetNormal(&normal[0],xyz_list); 796 768 797 769 /*Check wether it is an inflow or outflow BC (0 is the middle of the segment)*/ 798 index1=tria->GetNodeIndex(nodes[0]); 799 index2=tria->GetNodeIndex(nodes[1]); 800 801 gauss=new GaussTria(); 770 int index1=tria->GetVertexIndex(vertices[0]); 771 int index2=tria->GetVertexIndex(vertices[1]); 772 GaussTria* gauss=new GaussTria(); 802 773 gauss->GaussEdgeCenter(index1,index2); 803 774 vxaverage_input->GetInputValue(&mean_vx,gauss); 804 775 vyaverage_input->GetInputValue(&mean_vy,gauss); 805 776 delete gauss; 806 UdotN=mean_vx*normal[0]+mean_vy*normal[1];807 if 777 IssmDouble UdotN=mean_vx*normal[0]+mean_vy*normal[1]; 778 if(UdotN>0){ 808 779 return NULL; /*(u,n)>0 -> outflow, PenaltyCreateKMatrix will take care of it*/ 809 780 } 810 else{ 811 pe=new ElementVector(nodes,NUMNODES_BOUNDARY,this->parameters); 812 } 781 782 /*Initialize Load Vector */ 783 int numnodes = this->GetNumberOfNodes(); 784 ElementVector *pe = new ElementVector(nodes,numnodes,this->parameters); 785 IssmDouble *basis = xNew<IssmDouble>(numnodes); 813 786 814 787 /* Start looping on the number of gaussian points: */ 815 788 gauss=new GaussTria(index1,index2,2); 816 for(i g=gauss->begin();ig<gauss->end();ig++){789 for(int ig=gauss->begin();ig<gauss->end();ig++){ 817 790 818 791 gauss->GaussPoint(ig); 819 792 820 tria->GetSegmentNodalFunctions(& L[0],gauss,index1,index2,tria->FiniteElement());793 tria->GetSegmentNodalFunctions(&basis[0],gauss,index1,index2,tria->FiniteElement()); 821 794 822 795 vxaverage_input->GetInputValue(&vx,gauss); … … 828 801 DL= - gauss->weight*Jdet*UdotN*thickness; 829 802 830 for(i =0;i<numdof;i++) pe->values[i] += DL*L[i];803 for(int i=0;i<numnodes;i++) pe->values[i] += DL*basis[i]; 831 804 } 832 805 833 806 /*Clean up and return*/ 807 xDelete<IssmDouble>(basis); 834 808 delete gauss; 835 809 return pe; … … 857 831 ElementVector* Numericalflux::CreatePVectorMasstransportBoundary(void){/*{{{*/ 858 832 859 /* constants*/ 860 const int numdof=NDOF1*NUMNODES_BOUNDARY; 833 /*Initialize Load Vector and return if necessary*/ 834 Tria* tria=(Tria*)element; 835 if(!tria->IsIceInElement()) return NULL; 861 836 862 837 /* Intermediaries*/ 863 int i,ig,index1,index2; 864 IssmDouble DL,Jdet,dt,vx,vy,mean_vx,mean_vy,UdotN,thickness; 865 IssmDouble xyz_list[NUMVERTICES][3]; 866 IssmDouble normal[2]; 867 IssmDouble L[numdof]; 868 GaussTria *gauss; 869 870 /*Initialize Load Vector and return if necessary*/ 871 ElementVector* pe = NULL; 872 Tria* tria=(Tria*)element; 873 if(!tria->IsIceInElement()) return NULL; 838 IssmDouble DL,Jdet,vx,vy,mean_vx,mean_vy,thickness; 839 IssmDouble xyz_list[NUMVERTICES][3]; 840 IssmDouble normal[2]; 874 841 875 842 /*Retrieve all inputs and parameters*/ 876 843 GetVerticesCoordinates(&xyz_list[0][0],vertices,NUMVERTICES); 877 parameters->FindParam(&dt,TimesteppingTimeStepEnum);878 Input* vxaverage_input =tria->inputs->GetInput(VxEnum); _assert_(vxaverage_input);879 Input* vyaverage_input =tria->inputs->GetInput(VyEnum);_assert_(vyaverage_input);880 Input* spcthickness_input =tria->inputs->GetInput(MasstransportSpcthicknessEnum); _assert_(spcthickness_input);844 IssmDouble dt = parameters->FindParam(TimesteppingTimeStepEnum); 845 Input* vxaverage_input = tria->inputs->GetInput(VxEnum); _assert_(vxaverage_input); 846 Input* vyaverage_input = tria->inputs->GetInput(VyEnum); _assert_(vyaverage_input); 847 Input* spcthickness_input = tria->inputs->GetInput(MasstransportSpcthicknessEnum); _assert_(spcthickness_input); 881 848 GetNormal(&normal[0],xyz_list); 882 849 883 850 /*Check wether it is an inflow or outflow BC (0 is the middle of the segment)*/ 884 index1=tria->GetNodeIndex(nodes[0]); 885 index2=tria->GetNodeIndex(nodes[1]); 886 887 gauss=new GaussTria(); 851 int index1=tria->GetVertexIndex(vertices[0]); 852 int index2=tria->GetVertexIndex(vertices[1]); 853 GaussTria* gauss=new GaussTria(); 888 854 gauss->GaussEdgeCenter(index1,index2); 889 855 vxaverage_input->GetInputValue(&mean_vx,gauss); 890 856 vyaverage_input->GetInputValue(&mean_vy,gauss); 891 857 delete gauss; 892 893 UdotN=mean_vx*normal[0]+mean_vy*normal[1]; 894 if (UdotN>0){ 858 IssmDouble UdotN=mean_vx*normal[0]+mean_vy*normal[1]; 859 if(UdotN>0){ 895 860 return NULL; /*(u,n)>0 -> outflow, PenaltyCreateKMatrix will take care of it*/ 896 861 } 897 else{ 898 pe=new ElementVector(nodes,NUMNODES_BOUNDARY,this->parameters); 899 } 862 863 /*Initialize Load Vector */ 864 int numnodes = this->GetNumberOfNodes(); 865 ElementVector *pe = new ElementVector(nodes,numnodes,this->parameters); 866 IssmDouble *basis = xNew<IssmDouble>(numnodes); 900 867 901 868 /* Start looping on the number of gaussian points: */ 902 869 gauss=new GaussTria(index1,index2,2); 903 for(i g=gauss->begin();ig<gauss->end();ig++){870 for(int ig=gauss->begin();ig<gauss->end();ig++){ 904 871 905 872 gauss->GaussPoint(ig); 906 873 907 tria->GetSegmentNodalFunctions(& L[0],gauss,index1,index2,tria->FiniteElement());874 tria->GetSegmentNodalFunctions(&basis[0],gauss,index1,index2,tria->FiniteElement()); 908 875 909 876 vxaverage_input->GetInputValue(&vx,gauss); … … 916 883 DL= - gauss->weight*Jdet*dt*UdotN*thickness; 917 884 918 for(i =0;i<numdof;i++) pe->values[i] += DL*L[i];885 for(int i=0;i<numnodes;i++) pe->values[i] += DL*basis[i]; 919 886 } 920 887 921 888 /*Clean up and return*/ 889 xDelete<IssmDouble>(basis); 922 890 delete gauss; 923 891 return pe; … … 935 903 /*Build unit outward pointing vector*/ 936 904 IssmDouble vector[2]; 937 IssmDouble norm;938 905 939 906 vector[0]=xyz_list[1][0] - xyz_list[0][0]; 940 907 vector[1]=xyz_list[1][1] - xyz_list[0][1]; 941 908 942 norm=sqrt(pow(vector[0],2.0)+pow(vector[1],2.0));909 IssmDouble norm=sqrt(pow(vector[0],2.0)+pow(vector[1],2.0)); 943 910 944 911 normal[0]= + vector[1]/norm; -
issm/trunk-jpl/src/c/classes/Loads/Numericalflux.h
r23959 r24088 21 21 int id; 22 22 int flux_type; 23 int flux_degree; 23 24 24 25 /*Hooks*/ -
issm/trunk-jpl/src/c/modules/ModelProcessorx/CreateNodes.cpp
r23640 r24088 50 50 if(iomodel->meshelementtype==TriaEnum){ 51 51 switch(finite_element){ 52 case P0DGEnum: 53 numnodes = iomodel->numberofelements; 54 break; 52 55 case P1Enum: 53 56 numnodes = iomodel->numberofvertices; … … 173 176 if(iomodel->meshelementtype==TriaEnum){ 174 177 switch(finite_element){ 178 case P0DGEnum: 179 element_numnodes=1; 180 element_node_ids[0]=i; 181 break; 175 182 case P1Enum: 176 183 element_numnodes=3; -
issm/trunk-jpl/src/c/shared/Enum/Enum.vim
r24082 r24088 1135 1135 syn keyword cConstant OptionEnum 1136 1136 syn keyword cConstant P0ArrayEnum 1137 syn keyword cConstant P0DGEnum 1137 1138 syn keyword cConstant P1DGEnum 1138 1139 syn keyword cConstant P1P1Enum … … 1280 1281 syn keyword cType Cfsurfacesquare 1281 1282 syn keyword cType Channel 1282 syn keyword cType classes1283 1283 syn keyword cType Constraint 1284 1284 syn keyword cType Constraints … … 1287 1287 syn keyword cType ControlInput 1288 1288 syn keyword cType Covertree 1289 syn keyword cType DataSetParam 1289 1290 syn keyword cType DatasetInput 1290 syn keyword cType DataSetParam1291 1291 syn keyword cType Definition 1292 1292 syn keyword cType DependentObject … … 1301 1301 syn keyword cType ElementHook 1302 1302 syn keyword cType ElementMatrix 1303 syn keyword cType ElementVector 1303 1304 syn keyword cType Elements 1304 syn keyword cType ElementVector1305 1305 syn keyword cType ExponentialVariogram 1306 1306 syn keyword cType ExternalResult … … 1309 1309 syn keyword cType Friction 1310 1310 syn keyword cType Gauss 1311 syn keyword cType GaussianVariogram1312 syn keyword cType gaussobjects1313 1311 syn keyword cType GaussPenta 1314 1312 syn keyword cType GaussSeg 1315 1313 syn keyword cType GaussTetra 1316 1314 syn keyword cType GaussTria 1315 syn keyword cType GaussianVariogram 1317 1316 syn keyword cType GenericExternalResult 1318 1317 syn keyword cType GenericOption … … 1322 1321 syn keyword cType Input 1323 1322 syn keyword cType Inputs 1324 syn keyword cType IntArrayInput1325 1323 syn keyword cType IntInput 1326 1324 syn keyword cType IntMatParam … … 1330 1328 syn keyword cType IssmDirectApplicInterface 1331 1329 syn keyword cType IssmParallelDirectApplicInterface 1332 syn keyword cType krigingobjects1333 1330 syn keyword cType Load 1334 1331 syn keyword cType Loads … … 1341 1338 syn keyword cType Matice 1342 1339 syn keyword cType Matlitho 1343 syn keyword cType matrixobjects1344 1340 syn keyword cType MatrixParam 1345 1341 syn keyword cType Misfit … … 1354 1350 syn keyword cType Observations 1355 1351 syn keyword cType Option 1352 syn keyword cType OptionUtilities 1356 1353 syn keyword cType Options 1357 syn keyword cType OptionUtilities1358 1354 syn keyword cType Param 1359 1355 syn keyword cType Parameters … … 1368 1364 syn keyword cType Regionaloutput 1369 1365 syn keyword cType Results 1366 syn keyword cType RiftStruct 1370 1367 syn keyword cType Riftfront 1371 syn keyword cType RiftStruct1372 1368 syn keyword cType Seg 1373 1369 syn keyword cType SegInput 1370 syn keyword cType SegRef 1374 1371 syn keyword cType Segment 1375 syn keyword cType SegRef1376 1372 syn keyword cType SpcDynamic 1377 1373 syn keyword cType SpcStatic … … 1393 1389 syn keyword cType Vertex 1394 1390 syn keyword cType Vertices 1391 syn keyword cType classes 1392 syn keyword cType gaussobjects 1393 syn keyword cType krigingobjects 1394 syn keyword cType matrixobjects 1395 1395 syn keyword cType AdjointBalancethickness2Analysis 1396 1396 syn keyword cType AdjointBalancethicknessAnalysis … … 1411 1411 syn keyword cType FreeSurfaceBaseAnalysis 1412 1412 syn keyword cType FreeSurfaceTopAnalysis 1413 syn keyword cType GLheightadvectionAnalysis 1413 1414 syn keyword cType GiaIvinsAnalysis 1414 syn keyword cType GLheightadvectionAnalysis1415 1415 syn keyword cType HydrologyDCEfficientAnalysis 1416 1416 syn keyword cType HydrologyDCInefficientAnalysis -
issm/trunk-jpl/src/c/shared/Enum/EnumDefinitions.h
r24082 r24088 1133 1133 OptionEnum, 1134 1134 P0ArrayEnum, 1135 P0DGEnum, 1135 1136 P1DGEnum, 1136 1137 P1P1Enum, -
issm/trunk-jpl/src/c/shared/Enum/EnumToStringx.cpp
r24082 r24088 1137 1137 case OptionEnum : return "Option"; 1138 1138 case P0ArrayEnum : return "P0Array"; 1139 case P0DGEnum : return "P0DG"; 1139 1140 case P1DGEnum : return "P1DG"; 1140 1141 case P1P1Enum : return "P1P1"; -
issm/trunk-jpl/src/c/shared/Enum/StringToEnumx.cpp
r24082 r24088 1164 1164 else if (strcmp(name,"Option")==0) return OptionEnum; 1165 1165 else if (strcmp(name,"P0Array")==0) return P0ArrayEnum; 1166 else if (strcmp(name,"P0DG")==0) return P0DGEnum; 1166 1167 else if (strcmp(name,"P1DG")==0) return P1DGEnum; 1167 1168 else if (strcmp(name,"P1P1")==0) return P1P1Enum; … … 1243 1244 else if (strcmp(name,"StringParam")==0) return StringParamEnum; 1244 1245 else if (strcmp(name,"SubelementFriction1")==0) return SubelementFriction1Enum; 1245 else if (strcmp(name,"SubelementFriction2")==0) return SubelementFriction2Enum;1246 1246 else stage=11; 1247 1247 } 1248 1248 if(stage==11){ 1249 if (strcmp(name,"SubelementMelt1")==0) return SubelementMelt1Enum; 1249 if (strcmp(name,"SubelementFriction2")==0) return SubelementFriction2Enum; 1250 else if (strcmp(name,"SubelementMelt1")==0) return SubelementMelt1Enum; 1250 1251 else if (strcmp(name,"SubelementMelt2")==0) return SubelementMelt2Enum; 1251 1252 else if (strcmp(name,"SubelementMigration")==0) return SubelementMigrationEnum;
Note:
See TracChangeset
for help on using the changeset viewer.