Changeset 5921


Ignore:
Timestamp:
09/21/10 14:02:29 (15 years ago)
Author:
Mathieu Morlighem
Message:

Some ElementVector, more to come

Location:
issm/trunk/src/c/objects/Elements
Files:
3 edited

Legend:

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

    r5917 r5921  
    29842984void  Penta::CreatePVectorAdjointMacAyeal(Vec p_g){
    29852985
    2986         int i;
    2987         Tria* tria=NULL;
    2988 
    2989         /*If on water, skip: */
    2990         if(IsOnWater()) return;
    2991 
    2992         /*Bail out if this element if:
    2993          * -> Non MacAyeal and not on the surface
    2994          * -> MacAyeal(2d model) and not on bed) */
    2995         if (!IsOnBed()){
    2996                 return;
    2997         }
    2998         else{
    2999 
    3000                 /*This element should be collapsed into a tria element at its base. Create this tria element,
    3001                  * and compute pe_g*/
    3002                 tria=(Tria*)SpawnTria(0,1,2); //grids 0, 1 and 2 make the new tria (lower face).
    3003                 tria->CreatePVectorAdjointHoriz(p_g);
    3004                 delete tria->matice; delete tria;
    3005                 return;
    3006         }
     2986        if (!IsOnBed() || IsOnWater()) return;
     2987
     2988        /*Call Tria function*/
     2989        Tria* tria=(Tria*)SpawnTria(0,1,2); //grids 0, 1 and 2 make the new tria.
     2990        ElementVector* pe=tria->CreatePVectorAdjointHoriz();
     2991        delete tria->matice; delete tria;
     2992        pe->AddToGlobal(p_g,NULL);
     2993        delete pe;
     2994
     2995        /*clean up and return*/
     2996        return;
    30072997}
    30082998/*}}}*/
     
    30103000void  Penta::CreatePVectorAdjointPattyn(Vec p_g){
    30113001
    3012         int i;
    3013         Tria* tria=NULL;
    3014 
    3015         /*If on water, skip: */
    3016         if(IsOnWater()) return;
    3017 
    3018         /*Bail out if this element if:
    3019          * -> Non MacAyeal and not on the surface
    3020          * -> MacAyeal(2d model) and not on bed) */
    3021         if (!IsOnSurface()){
    3022                 return;
    3023         }
    3024         else{
    3025 
    3026                 tria=(Tria*)SpawnTria(3,4,5); //grids 3, 4 and 5 make the new tria (upper face).
    3027                 tria->CreatePVectorAdjointHoriz(p_g);
    3028                 delete tria->matice; delete tria;
    3029                 return;
    3030         }
     3002        if (!IsOnSurface() || IsOnWater()) return;
     3003
     3004        /*Call Tria function*/
     3005        Tria* tria=(Tria*)SpawnTria(3,4,5); //grids 3, 4 and 5 make the new tria (upper face).
     3006        ElementVector* pe=tria->CreatePVectorAdjointHoriz();
     3007        delete tria->matice; delete tria;
     3008        pe->AddToGlobal(p_g,NULL);
     3009        delete pe;
     3010
     3011        /*clean up and return*/
     3012        return;
    30313013}
    30323014/*}}}*/
     
    33713353void  Penta::CreatePVectorDiagnosticMacAyeal(Vec pg){
    33723354
    3373         /*Spawning: */
    3374         Tria* tria=NULL;
    3375 
    3376         /*If on water, skip load: */
    3377         if(IsOnWater())return;
    3378 
    3379         /*Figure out if this pentaelem is Macayeal. If so, then bailout, except if it is at the
     3355        /*Figure out if this penta is collapsed. If so, then bailout, except if it is at the
    33803356          bedrock, in which case we spawn a tria element using the 3 first grids, and use it to build
    3381           the load vector. */
    3382 
    3383         if (!IsOnBed()){
    3384                 /*This element should be collapsed, but this element is not on the bedrock, therefore all its
    3385                  * dofs have already been frozen! Do nothing: */
    3386                 return;
    3387         }
    3388         else{
    3389 
    3390                 /*This element should be collapsed into a tria element at its base. Create this tria element,
    3391                  *and use its CreatePVector functionality to return an elementary load vector: */
    3392                 tria=(Tria*)SpawnTria(0,1,2); //grids 0, 1 and 2 make the new tria.
    3393                 tria->CreatePVector(pg,NULL);
    3394                 delete tria->matice; delete tria;
    3395                 return;
    3396         }
     3357          the stiffness matrix. */
     3358        if (!IsOnBed() || IsOnWater()) return;
     3359
     3360        /*Call Tria function*/
     3361        Tria* tria=(Tria*)SpawnTria(0,1,2); //grids 0, 1 and 2 make the new tria.
     3362        ElementVector* pe=tria->CreatePVectorDiagnosticMacAyeal();
     3363        delete tria->matice; delete tria;
     3364        pe->AddToGlobal(pg,NULL);
     3365        delete pe;
     3366
     3367        /*clean up and return*/
     3368        return;
    33973369}
    33983370/*}}}*/
  • issm/trunk/src/c/objects/Elements/Tria.cpp

    r5917 r5921  
    751751        switch(analysis_type){
    752752                case DiagnosticHorizAnalysisEnum:
    753                         CreatePVectorDiagnosticMacAyeal( pg,pf);
     753                        pe=CreatePVectorDiagnosticMacAyeal();
     754                        pe->AddToGlobal(pg,pf);
     755                        delete pe;
    754756                        break;
    755757                case AdjointHorizAnalysisEnum:
    756                         CreatePVectorAdjointHoriz( pg);
     758                        pe=CreatePVectorAdjointHoriz();
     759                        pe->AddToGlobal(pg,pf);
     760                        delete pe;
    757761                        break;
    758762                case DiagnosticHutterAnalysisEnum:
     
    36663670/*}}}*/
    36673671/*FUNCTION Tria::CreatePVectorDiagnosticMacAyeal {{{1*/
    3668 void Tria::CreatePVectorDiagnosticMacAyeal( Vec pg, Vec pf){
     3672ElementVector* Tria::CreatePVectorDiagnosticMacAyeal(){
    36693673
    36703674        /*Constants*/
     
    36783682        double         slope[2];
    36793683        double         l1l2l3[3];
    3680         double         pe_g[numdof]={0.0};
    36813684        double         pe_g_gaussian[numdof];
    36823685        GaussTria*     gauss=NULL;
    3683         ElementVector* pe=NULL;
    3684 
    3685         /*First, if we are on water, return empty vector: */
    3686         if(IsOnWater()) return;
    3687 
    3688         /*Retrieve all Inputs and parameters: */
     3686
     3687        /*Initialize Element vector and return if necessary*/
     3688        if(IsOnWater()) return NULL;
     3689        ElementVector* pe=NewElementVector(nodes,NUMVERTICES,this->parameters);
     3690
     3691        /*Retrieve all inputs and parameters*/
     3692        GetVerticesCoordinates(&xyz_list[0][0], nodes, NUMVERTICES);
    36893693        inputs->GetParameterValue(&drag_type,DragTypeEnum);
    36903694        Input* thickness_input=inputs->GetInput(ThicknessEnum); ISSMASSERT(thickness_input);
    36913695        Input* surface_input=inputs->GetInput(SurfaceEnum);     ISSMASSERT(surface_input);
    36923696        Input* drag_input=inputs->GetInput(DragCoefficientEnum);ISSMASSERT(drag_input);
    3693 
    3694         /*Get node coordinates and dof list: */
    3695         GetVerticesCoordinates(&xyz_list[0][0], nodes, NUMVERTICES);
    36963697
    36973698        /* Start  looping on the number of gaussian points: */
     
    37283729                        }
    37293730                }
    3730 
    3731                 for( i=0; i<numdof; i++)pe_g[i]+=pe_g_gaussian[i];
    3732         }
    3733 
    3734         pe=NewElementVector(nodes,NUMVERTICES,this->parameters,MacAyealApproximationEnum);
    3735         pe->AddValues(&pe_g[0]);
    3736         pe->AddToGlobal(pg,pf);
    3737 
    3738         /*Free ressources:*/
    3739         delete pe;
     3731                for(i=0;i<numdof;i++) pe->values[i]+=pe_g_gaussian[i];
     3732        }
     3733
     3734        /*Clean up and return*/
    37403735        delete gauss;
    3741 
    3742 
     3736        return pe;
    37433737}
    37443738/*}}}*/
     
    37983792/*}}}*/
    37993793/*FUNCTION Tria::CreatePVectorAdjointHoriz{{{1*/
    3800 void Tria::CreatePVectorAdjointHoriz(Vec p_g){
    3801 
    3802         int i;
    3803 
    3804         /* node data: */
    3805         const int    numdof=2*NUMVERTICES;
     3794ElementVector* Tria::CreatePVectorAdjointHoriz(void){
     3795
     3796        /*Constants*/
     3797        const int    numdof=NDOF2*NUMVERTICES;
    38063798        double       xyz_list[NUMVERTICES][3];
    3807         int*         doflist=NULL;
    3808 
    3809         /* grid data: */
    38103799        double vx_list[NUMVERTICES];
    38113800        double vy_list[NUMVERTICES];
     
    38153804        double duy_list[NUMVERTICES];
    38163805        double weights_list[NUMVERTICES];
    3817 
    3818         /* gaussian points: */
     3806        int i;
    38193807        int     ig;
    38203808        GaussTria* gauss=NULL;
    3821 
    3822         /* parameters: */
    38233809        double  obs_velocity_mag,velocity_mag;
    38243810        double  dux,duy;
    38253811        double  meanvel, epsvel;
    3826 
    3827         /*element vector : */
    3828         double  pe_g[numdof]={0.0};
    38293812        double  pe_g_gaussian[numdof];
    3830 
    3831         /* Jacobian: */
    38323813        double Jdet;
    3833 
    3834         /*nodal functions: */
    38353814        double l1l2l3[3];
    3836 
    3837         /*relative and algorithmic fitting: */
    38383815        double scalex=0;
    38393816        double scaley=0;
     
    38423819        int    response;
    38433820
    3844         /*retrieve some parameters: */
     3821        /*Initialize Element vector and return if necessary*/
     3822        if(IsOnWater()) return NULL;
     3823        ElementVector* pe=NewElementVector(nodes,NUMVERTICES,this->parameters);
     3824
     3825        /*Retrieve all inputs and parameters*/
     3826        GetVerticesCoordinates(&xyz_list[0][0], nodes, NUMVERTICES);
    38453827        this->parameters->FindParam(&meanvel,MeanVelEnum);
    38463828        this->parameters->FindParam(&epsvel,EpsVelEnum);
    3847 
    3848         /* Get node coordinates and dof list: */
    3849         GetVerticesCoordinates(&xyz_list[0][0], nodes, NUMVERTICES);
    3850         GetDofList(&doflist,NoneApproximationEnum,GsetEnum);
    3851 
    3852         /* Recover input data: */
    38533829        GetParameterListOnVertices(&obs_vx_list[0],VxObsEnum);
    38543830        GetParameterListOnVertices(&obs_vy_list[0],VyObsEnum);
     
    38563832        GetParameterListOnVertices(&vy_list[0],VyEnum);
    38573833        GetParameterListOnVertices(&weights_list[0],WeightsEnum);
    3858 
    38593834        inputs->GetParameterValue(&response,CmResponseEnum);
    38603835        if(response==SurfaceAverageVelMisfitEnum){
     
    39863961                gauss->GaussPoint(ig);
    39873962
    3988                 /* Get Jacobian determinant: */
    39893963                GetJacobianDeterminant2d(&Jdet, &xyz_list[0][0],gauss);
    3990 
    3991                 /* Get nodal functions value at gaussian point:*/
    39923964                GetNodalFunctions(l1l2l3, gauss);
    39933965
    3994                 /*Build due_g_gaussian vector: we have three cases here, according to which type of misfit we are using. */
    3995 
    3996                 /*Compute absolute(x/y) at gaussian point: */
    39973966                TriaRef::GetParameterValue(&dux, &dux_list[0],gauss);
    39983967                TriaRef::GetParameterValue(&duy, &duy_list[0],gauss);
    39993968
    4000                 /*compute Du*/
    40013969                for (i=0;i<NUMVERTICES;i++){
    40023970                        pe_g_gaussian[i*NDOF2+0]=dux*Jdet*gauss->weight*l1l2l3[i];
     
    40043972                }
    40053973
    4006                 /*Add pe_g_gaussian vector to pe_g: */
    4007                 for( i=0; i<numdof; i++){
    4008                         pe_g[i]+=pe_g_gaussian[i];
    4009                 }
    4010         }
    4011 
    4012         /*Add pe_g to global vector p_g: */
    4013         VecSetValues(p_g,numdof,doflist,(const double*)pe_g,ADD_VALUES);
     3974                for(i=0;i<numdof;i++) pe->values[i]+=pe_g_gaussian[i];
     3975        }
    40143976
    40153977        /*Clean up and return*/
    40163978        delete gauss;
    4017         xfree((void**)&doflist);
     3979        return pe;
    40183980}
    40193981/*}}}*/
  • issm/trunk/src/c/objects/Elements/Tria.h

    r5916 r5921  
    143143                void      CreatePVectorBalancedvelocities(Vec pg);
    144144                void      CreatePVectorDiagnosticBaseVert(Vec pg);
    145                 void      CreatePVectorDiagnosticMacAyeal(Vec pg,Vec pf);
    146                 void      CreatePVectorAdjointHoriz(Vec pg);
     145                ElementVector* CreatePVectorDiagnosticMacAyeal(void);
     146                ElementVector* CreatePVectorAdjointHoriz(void);
    147147                void      CreatePVectorAdjointStokes(Vec pg);
    148148                void      CreatePVectorAdjointBalancedthickness(Vec pg);
Note: See TracChangeset for help on using the changeset viewer.