Changeset 678


Ignore:
Timestamp:
06/01/09 16:10:31 (16 years ago)
Author:
seroussi
Message:

velocity depth average now working in serial,depth average on the nodes

Location:
issm/trunk/src/c/objects
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk/src/c/objects/Node.cpp

    r503 r678  
    491491}
    492492               
     493#undef __FUNCT__
     494#define __FUNCT__ "Node::VelocityDepthAverageAtBase"
     495void  Node::VelocityDepthAverageAtBase(Vec ug,double* ug_serial){
     496
     497        /* node data: */
     498        int          doflist1;
     499        int          dofx,dofy;
     500        int          isnodeonsurface;
     501       
     502        Node* node=NULL;
     503        Node* upper_node=NULL;
     504        double velocity2[2];
     505        double velocity1[2];
     506        double velocity_average[2];
     507        double sum[2];
     508        double z1,z2,dz;
     509        double thickness;
     510
     511       
     512        if(onbed==1 & clone==0){
     513                       
     514                doflist1=GetDofList1();
     515
     516                /*this node is on the bed. We are going to:
     517                 * follow the upper nodes until we reach the surface. At each upper node, we'll grab the
     518                 * velocity for this node, and add it to ug. We'll finish by
     519                 * we grab the velocity. Once we know the velocity, we follow the upper nodes,
     520                 * inserting the same velocity value into ug, until we reach the surface: */
     521                sum[0]=0;
     522                sum[1]=0;
     523                thickness=0;
     524
     525                /*get dofs for this base node velocity: we know there are two dofs in ug_serial */
     526                dofx=2*doflist1;
     527                dofy=2*doflist1+1;
     528
     529                node=this;
     530                for(;;){
     531
     532                        if (node->IsOnSurface())break;
     533
     534                        doflist1=node->GetDofList1();
     535                       
     536                        velocity1[0]=ug_serial[2*doflist1];
     537                        velocity1[1]=ug_serial[2*doflist1+1];
     538                        z1=node->GetZ();
     539
     540                        upper_node=node->GetUpperNode();
     541                        doflist1=upper_node->GetDofList1();
     542               
     543                        velocity2[0]=ug_serial[2*doflist1];
     544                        velocity2[1]=ug_serial[2*doflist1+1];
     545                        z2=upper_node->GetZ();
     546
     547                        dz=(z2-z1);
     548                        thickness+=dz;
     549                        velocity_average[0]=(velocity1[0]+velocity2[0])/2.0;
     550                        velocity_average[1]=(velocity1[1]+velocity2[1])/2.0;
     551
     552                        sum[0]+=velocity_average[0]*dz;
     553                        sum[1]+=velocity_average[1]*dz;
     554
     555                        /* get next node: */
     556                        node=node->GetUpperNode();
     557                }
     558
     559                sum[0]=sum[0]/thickness;
     560                sum[1]=sum[1]/thickness;
     561
     562                /* Plug velocity_average*deltaH/H into base of ug: */
     563                VecSetValues(ug,1,&dofx,&sum[0],INSERT_VALUES);
     564                VecSetValues(ug,1,&dofy,&sum[1],INSERT_VALUES);
     565        }
     566}
  • issm/trunk/src/c/objects/Node.h

    r301 r678  
    7777                int   IsOnSurface();
    7878                void  FreezeDof(int dof);
     79                void  VelocityDepthAverageAtBase(Vec ug,double* ug_serial);
    7980
    8081};
  • issm/trunk/src/c/objects/Penta.cpp

    r608 r678  
    19411941        /* node data: */
    19421942        const int    numgrids=6;
    1943         const int    numdof=2*numgrids;
    1944         int          doflist[numdof];
     1943        int          doflist[numgrids];
     1944        int          doflist1;
    19451945        int          nodedofs[2];
    1946         int          numberofdofspernode;
    19471946       
    19481947        Node* node=NULL;
     
    19531952        if(onbed==1){
    19541953                       
    1955                 GetDofList(&doflist[0],&numberofdofspernode);
     1954                GetDofList1(&doflist[0]);
    19561955
    19571956                /*this penta is on the bed. For each node on the base of this penta,
    19581957                 * we grab the velocity. Once we know the velocity, we follow the upper nodes,
    1959                  * inserting the same velocity value into ug, until we reach the surface: */
     1958                 * inserting the same velocity value into ug, until we reach the surface:
     1959                 * the velocity has two ddls vx and vy*/
    19601960                for(i=0;i<3;i++){
    19611961       
     
    19631963       
    19641964                        /*get velocity for this base node: */
    1965                         velocity[0]=ug_serial[doflist[numberofdofspernode*i+0]];
    1966                         velocity[1]=ug_serial[doflist[numberofdofspernode*i+1]];
     1965                        velocity[0]=ug_serial[2*doflist[i]+0];
     1966                        velocity[1]=ug_serial[2*doflist[i]+1];
    19671967
    19681968                        //go througn all nodes which sit on top of this node, until we reach the surface,
     
    19701970                        for(;;){
    19711971
    1972                                 node->GetDofList(&nodedofs[0],&numberofdofspernode);
     1972                                doflist1=node->GetDofList1();
     1973                                nodedofs[0]=2*doflist1;
     1974                                nodedofs[1]=2*doflist1+1;
    19731975                                VecSetValues(ug,1,&nodedofs[0],&velocity[0],INSERT_VALUES);
    19741976                                VecSetValues(ug,1,&nodedofs[1],&velocity[1],INSERT_VALUES);
     
    20302032
    20312033}
    2032 
    2033 #undef __FUNCT__
    2034 #define __FUNCT__ "Penta::VelocityDepthAverageAtBase"
    2035 void  Penta::VelocityDepthAverageAtBase(Vec ug,double* ug_serial){
    2036 
    2037         /* node data: */
    2038         const int    numgrids=6;
    2039         const int    numdof=2*numgrids;
    2040         int          doflist[numdof];
    2041         int          nodedofs[2];
    2042         int          numberofdofspernode;
    2043         int          dofx,dofy;
    2044        
    2045         Node* node=NULL;
    2046         Node* upper_node=NULL;
    2047         int   i;
    2048         double base_velocity[2];
    2049         double velocity2[2];
    2050         double velocity1[2];
    2051         double velocity_average[2];
    2052         double sum[2];
    2053         double z1,z2,dz;
    2054         double thickness;
    2055                
    2056         if(onbed==1){
    2057                        
    2058                 GetDofList(&doflist[0],&numberofdofspernode);
    2059 
    2060                 /*this penta is on the bed. For each node on the base of this penta, we are going to
    2061                  * follow the upper nodes until we reach the surface. At each upper node, we'll grab the
    2062                  * velocity for this node, and add it to ug. We'll finish by
    2063                  * we grab the velocity. Once we know the velocity, we follow the upper nodes,
    2064                  * inserting the same velocity value into ug, until we reach the surface: */
    2065                 for(i=0;i<3;i++){
    2066 
    2067                         //get thickness for this grid
    2068                         thickness=h[i]; //pick up from the penta element itself.
    2069        
    2070                         node=nodes[i]; //base nodes
    2071        
    2072                         /*get dofs for this base node velocity: */
    2073                         dofx=doflist[numberofdofspernode*i+0];
    2074                         dofy=doflist[numberofdofspernode*i+1];
    2075 
    2076                         /*first thing, cancel velocity on the base nodes, so that we start with the value 0: */
    2077                         base_velocity[0]=-ug_serial[doflist[numberofdofspernode*i+0]]; //- to cancel
    2078                         base_velocity[1]=-ug_serial[doflist[numberofdofspernode*i+1]];
    2079                
    2080                         VecSetValues(ug,1,&dofx,&base_velocity[0],ADD_VALUES);
    2081                         VecSetValues(ug,1,&dofy,&base_velocity[1],ADD_VALUES);
    2082 
    2083                         //go through all nodes which sit on top of this node, until we reach the surface,
    2084                         //and plug  deltaV*deltaH/H at base of ug: */
    2085                        
    2086                         for(;;){
    2087 
    2088                                 if (node->IsOnSurface())break;
    2089 
    2090                                 node->GetDofList(&nodedofs[0],&numberofdofspernode);
    2091                                
    2092                                 velocity1[0]=ug_serial[nodedofs[0]];
    2093                                 velocity1[1]=ug_serial[nodedofs[1]];
    2094                                 z1=node->GetZ();
    2095 
    2096                                 upper_node=node->GetUpperNode();
    2097                                 upper_node->GetDofList(&nodedofs[0],&numberofdofspernode);
    2098                        
    2099                                 velocity2[0]=ug_serial[nodedofs[0]];
    2100                                 velocity2[1]=ug_serial[nodedofs[1]];
    2101                                 z2=upper_node->GetZ();
    2102 
    2103                                 dz=(z2-z1);
    2104                                 velocity_average[0]=(velocity1[0]+velocity2[0])/2.0;
    2105                                 velocity_average[1]=(velocity1[1]+velocity2[1])/2.0;
    2106 
    2107                                 sum[0]=velocity_average[0]*dz/thickness;
    2108                                 sum[1]=velocity_average[1]*dz/thickness;
    2109 
    2110                                 /*Plug velocity_average*deltaH/H into base of ug: */
    2111                                 VecSetValues(ug,1,&dofx,&sum[0],ADD_VALUES);
    2112                                 VecSetValues(ug,1,&dofy,&sum[1],ADD_VALUES);
    2113 
    2114                                 /*get next node: */
    2115                                 node=node->GetUpperNode();
    2116                         }
    2117                 }
    2118         }
    2119 }
    2120 
    21212034
    21222035#undef __FUNCT__
  • issm/trunk/src/c/objects/Penta.h

    r607 r678  
    113113                void  VelocityExtrude(Vec ug,double* ug_serial);
    114114                void  ThicknessExtrude(Vec ug,double* ug_serial);
    115                 void  VelocityDepthAverageAtBase(Vec ug,double* ug_serial);
    116115                void  SlopeExtrude(Vec sg,double* sg_serial);
    117116                void  ComputePressure(Vec p_g);
Note: See TracChangeset for help on using the changeset viewer.