Changeset 848 for issm/trunk/src/c/objects/Node.cpp
- Timestamp:
- 06/08/09 15:52:02 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk/src/c/objects/Node.cpp
r832 r848 550 550 551 551 #undef __FUNCT__ 552 #define __FUNCT__ "Node:: VelocityDepthAverageAtBase"553 void Node:: VelocityDepthAverageAtBase(Vec ug,double* ug_serial){552 #define __FUNCT__ "Node::FieldDepthAverageAtBase" 553 void Node::FieldDepthAverageAtBase(Vec field,double* field_serial,char* fieldname){ 554 554 555 555 /* node data: */ … … 560 560 Node* node=NULL; 561 561 Node* upper_node=NULL; 562 double velocity2[2];563 double velocity1[2];564 double velocity_average[2];565 double sum[2];566 562 double z1,z2,dz; 567 563 double thickness; 568 564 565 /*Are we on the base, not on the surface, and not on a clone node?:*/ 569 566 570 567 if(onbed==1 & clone==0 &onsurface==0){ … … 572 569 doflist1=GetDofList1(); 573 570 574 /*this node is on the bed. We are going to: 575 * follow the upper nodes until we reach the surface. At each upper node, we'll grab the 576 * velocity for this node, and add it to ug. We'll finish by 577 * we grab the velocity. Once we know the velocity, we follow the upper nodes, 578 * inserting the same velocity value into ug, until we reach the surface: */ 579 sum[0]=0; 580 sum[1]=0; 581 thickness=0; 582 583 /*get dofs for this base node velocity: we know there are two dofs in ug_serial */ 584 dofx=2*doflist1; 585 dofy=2*doflist1+1; 586 587 node=this; 588 for(;;){ 589 590 if (node->IsOnSurface())break; 591 592 doflist1=node->GetDofList1(); 571 /*this node is on the bed. We are going to, follow the upper nodes until we reach the surface. At each upper node, 572 * we'll grab the * field for this node, and add it to overall field: */ 573 574 if(strcmp(fieldname,"velocity")==0){ 575 576 /*field is a velocity, 2 dofs per node: */ 577 double velocity2[2]; 578 double velocity1[2]; 579 double velocity_average[2]; 580 double sum[2]; 581 582 sum[0]=0; 583 sum[1]=0; 584 thickness=0; 585 586 /*get dofs for this base node velocity: we know there are two dofs in field_serial */ 587 dofx=2*doflist1; 588 dofy=2*doflist1+1; 589 590 node=this; 591 for(;;){ 592 593 if (node->IsOnSurface())break; 594 595 doflist1=node->GetDofList1(); 596 597 velocity1[0]=field_serial[2*doflist1]; 598 velocity1[1]=field_serial[2*doflist1+1]; 599 z1=node->GetZ(); 600 601 upper_node=node->GetUpperNode(); 602 doflist1=upper_node->GetDofList1(); 593 603 594 velocity1[0]=ug_serial[2*doflist1]; 595 velocity1[1]=ug_serial[2*doflist1+1]; 596 z1=node->GetZ(); 597 598 upper_node=node->GetUpperNode(); 599 doflist1=upper_node->GetDofList1(); 600 601 velocity2[0]=ug_serial[2*doflist1]; 602 velocity2[1]=ug_serial[2*doflist1+1]; 603 z2=upper_node->GetZ(); 604 605 dz=(z2-z1); 606 thickness+=dz; 607 velocity_average[0]=(velocity1[0]+velocity2[0])/2.0; 608 velocity_average[1]=(velocity1[1]+velocity2[1])/2.0; 609 610 sum[0]+=velocity_average[0]*dz; 611 sum[1]+=velocity_average[1]*dz; 612 613 /* get next node: */ 614 node=node->GetUpperNode(); 604 velocity2[0]=field_serial[2*doflist1]; 605 velocity2[1]=field_serial[2*doflist1+1]; 606 z2=upper_node->GetZ(); 607 608 dz=(z2-z1); 609 thickness+=dz; 610 velocity_average[0]=(velocity1[0]+velocity2[0])/2.0; 611 velocity_average[1]=(velocity1[1]+velocity2[1])/2.0; 612 613 sum[0]+=velocity_average[0]*dz; 614 sum[1]+=velocity_average[1]*dz; 615 616 /* get next node: */ 617 node=node->GetUpperNode(); 618 } 619 620 sum[0]=sum[0]/thickness; 621 sum[1]=sum[1]/thickness; 622 623 /* Plfield velocity_average*deltaH/H into base of field: */ 624 VecSetValues(field,1,&dofx,&sum[0],INSERT_VALUES); 625 VecSetValues(field,1,&dofy,&sum[1],INSERT_VALUES); 615 626 } 616 617 sum[0]=sum[0]/thickness; 618 sum[1]=sum[1]/thickness; 619 620 /* Plug velocity_average*deltaH/H into base of ug: */ 621 VecSetValues(ug,1,&dofx,&sum[0],INSERT_VALUES); 622 VecSetValues(ug,1,&dofy,&sum[1],INSERT_VALUES); 623 } 624 } 627 else{ 628 /*field is regular, 1 dof per node: */ 629 double field2; 630 double field1; 631 double field_average; 632 double sum; 633 634 sum=0; 635 thickness=0; 636 637 /*get dofs for this base node velocity: we know there are two dofs in field_serial */ 638 dofx=doflist1; 639 640 node=this; 641 for(;;){ 642 643 if (node->IsOnSurface())break; 644 645 doflist1=node->GetDofList1(); 646 647 field1=field_serial[doflist1]; 648 z1=node->GetZ(); 649 650 upper_node=node->GetUpperNode(); 651 doflist1=upper_node->GetDofList1(); 652 653 field2=field_serial[2*doflist1]; 654 z2=upper_node->GetZ(); 655 656 dz=(z2-z1); 657 thickness+=dz; 658 field_average=(field1+field2)/2.0; 659 660 sum+=field_average*dz; 661 662 /* get next node: */ 663 node=node->GetUpperNode(); 664 } 665 666 sum=sum/thickness; 667 668 /* Plug field_average*deltH/H into base of field: */ 669 VecSetValues(field,1,&dofx,&sum,INSERT_VALUES); 670 } 671 } 672 } 673 674 #undef __FUNCT__ 675 #define __FUNCT__ "Node::FieldExtrude" 676 void Node::FieldExtrude(Vec field,double* field_serial,char* field_name){ 677 678 /* node data: */ 679 int numberofdofspernode; 680 Node* node=NULL; 681 int i; 682 683 /*Is this node on bed? :*/ 684 if (onbed){ 685 686 if (strcmp(field_name,"velocity")==0){ 687 688 /* node data: */ 689 const int numdof=2; 690 int doflist[numdof]; 691 int nodedofs[2]; 692 double fieldnode[2]; 693 694 695 GetDofList(&doflist[0],&numberofdofspernode); 696 697 //initilaize node 698 node=this; 699 700 /*get field for this base node: */ 701 fieldnode[0]=field_serial[doflist[0]]; 702 fieldnode[1]=field_serial[doflist[1]]; 703 704 //go through all nodes which sit on top of this node, until we reach the surface, 705 //and plfield field in field 706 for(;;){ 707 708 node->GetDofList(&nodedofs[0],&numberofdofspernode); 709 VecSetValues(field,1,&nodedofs[0],&fieldnode[0],INSERT_VALUES); 710 VecSetValues(field,1,&nodedofs[1],&fieldnode[1],INSERT_VALUES); 711 712 if (node->IsOnSurface())break; 713 /*get next node: */ 714 node=node->GetUpperNode(); 715 } 716 } //if (strcmp(field_name,"velocity")==0) 717 else if ( 718 (strcmp(field_name,"thickness")==0) || 719 (strcmp(field_name,"surface")==0) || 720 (strcmp(field_name,"bed")==0) || 721 (strcmp(field_name,"slopex")==0) || 722 (strcmp(field_name,"slopey")==0) 723 ){ 724 725 /* node data: */ 726 int doflist; 727 int nodedofs; 728 double fieldnode; 729 730 GetDofList(&doflist,&numberofdofspernode); 731 732 //initilaize node 733 node=this; 734 735 /*get field for this bed node: */ 736 fieldnode=field_serial[doflist]; 737 738 //go through all nodes which sit on top of this node, until we reach the surface, 739 //and pltg fieldnode in field: 740 for(;;){ 741 742 node->GetDofList(&nodedofs,&numberofdofspernode); 743 VecSetValues(field,1,&nodedofs,&fieldnode,INSERT_VALUES); 744 745 if (node->IsOnSurface())break; 746 /*get next node: */ 747 node=node->GetUpperNode(); 748 } 749 } 750 else throw ErrorException(__FUNCT__,exprintf("%s%s%s"," field ",field_name," not supported yet!")); 751 752 } //if (extrude) 753 } 754 755 void Node::UpdateNodePosition(double* thickness,double* bed){ 756 757 int dof; 758 759 dof=this->GetDofList1(); 760 761 if(onbed){ 762 763 /*this node is on the bed, set its z position to the new bed: */ 764 this->x[2]=bed[dof]; 765 } 766 else if (onsurface){ 767 768 /*this node is on the surface, set its z position to the new bed+ new thickness: */ 769 this->x[2]=bed[dof]+thickness[dof]; 770 } 771 else{ 772 /*do nothing, we only update grids belonging to the exterior layers: */ 773 } 774 }
Note:
See TracChangeset
for help on using the changeset viewer.