Changeset 5929


Ignore:
Timestamp:
09/21/10 16:17:43 (14 years ago)
Author:
Mathieu Morlighem
Message:

more ElementVectors

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

Legend:

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

    r5926 r5929  
    753753                        pe=CreatePVectorDiagnosticHoriz();
    754754                        if(pe) pe->AddToGlobal(pg,pf);
    755                         delete pe;
     755                        if(pe) delete pe;
    756756                        break;
    757757                case AdjointHorizAnalysisEnum:
    758758                        pe=CreatePVectorAdjointHoriz();
    759759                        if(pe) pe->AddToGlobal(pg,pf);
    760                         delete pe;
     760                        if(pe) delete pe;
    761761                        break;
    762762                case DiagnosticHutterAnalysisEnum:
    763                         CreatePVectorDiagnosticHutter( pg);
     763                        pe=CreatePVectorDiagnosticHutter();
     764                        if(pe) pe->AddToGlobal(pg,pf);
     765                        if(pe) delete pe;
    764766                        break;
    765767                case DiagnosticVertAnalysisEnum:
     
    767769                        break;
    768770                case BedSlopeXAnalysisEnum: case SurfaceSlopeXAnalysisEnum: case BedSlopeYAnalysisEnum: case SurfaceSlopeYAnalysisEnum:
    769                         CreatePVectorSlope( pg);
     771                        pe=CreatePVectorSlope();
     772                        if(pe) pe->AddToGlobal(pg,pf);
     773                        if(pe) delete pe;
    770774                        break;
    771775                case PrognosticAnalysisEnum:
     
    32713275/*}}}*/
    32723276/*FUNCTION Penta::CreatePVectorDiagnosticHutter{{{1*/
    3273 void  Penta::CreatePVectorDiagnosticHutter(Vec pg){
     3277ElementVector* Penta::CreatePVectorDiagnosticHutter(void){
    32743278
    32753279        int i,j,k;
    3276        
     3280        int      ig;
    32773281        const int numdofs=NDOF2*NUMVERTICES;
    3278         int*      doflist=NULL;
    3279         double    pe_g[numdofs]={0.0};
    32803282        double    xyz_list[NUMVERTICES][3];
    32813283        double    xyz_list_segment[2][3];
     
    32853287        int       node0,node1;
    32863288        GaussPenta* gauss=NULL;
    3287         int      ig;
    32883289        double   slope[2];
    3289 
    32903290        double   z_g;
    32913291        double   rho_ice,gravity,n,B;
     
    32933293        double   ub,vb;
    32943294        double   surface,thickness;
    3295 
    3296         /*flags: */
    32973295        int  connectivity[2];
    32983296
    3299         /*If on water, skip: */
    3300         if(IsOnWater())return;
    3301 
    3302         /*recover doflist: */
    3303         GetDofList(&doflist,NoneApproximationEnum,GsetEnum);
    3304 
    3305         /*recover parameters: */
     3297        /*Initialize Element vector and return if necessary*/
     3298        if(IsOnWater()) return NULL;
     3299        ElementVector* pe=NewElementVector(nodes,NUMVERTICES,this->parameters);
     3300
     3301        /*Retrieve all inputs and parameters*/
     3302        GetVerticesCoordinates(&xyz_list[0][0], nodes, NUMVERTICES);
    33063303        rho_ice=matpar->GetRhoIce();
    33073304        gravity=matpar->GetG();
    33083305        n=matice->GetN();
    33093306        B=matice->GetB();
    3310 
    3311         //recover extra inputs
    33123307        Input* thickness_input=inputs->GetInput(ThicknessEnum);  ISSMASSERT(thickness_input);
    33133308        Input* surface_input=inputs->GetInput(SurfaceEnum);      ISSMASSERT(surface_input);
    33143309        Input* slopex_input=inputs->GetInput(SurfaceSlopeXEnum); ISSMASSERT(slopex_input);
    33153310        Input* slopey_input=inputs->GetInput(SurfaceSlopeYEnum); ISSMASSERT(slopey_input);
    3316 
    3317         GetVerticesCoordinates(&xyz_list[0][0], nodes, NUMVERTICES);
    33183311        for(i=0;i<NUMVERTICES;i++)z_list[i]=xyz_list[i][2];
    33193312
     
    33493342
    33503343                        if (IsOnSurface()){
    3351                                 for(j=0;j<NDOF2;j++) pe_g[2*node1+j]+=constant_part*pow((surface-z_g)/B,n)*slope[j]*Jdet*gauss->weight/(double)connectivity[1];
     3344                                for(j=0;j<NDOF2;j++) pe->values[2*node1+j]+=constant_part*pow((surface-z_g)/B,n)*slope[j]*Jdet*gauss->weight/(double)connectivity[1];
    33523345                        }
    33533346                        else{//connectivity is too large, should take only half on it
    3354                                 for(j=0;j<NDOF2;j++) pe_g[2*node1+j]+=constant_part*pow((surface-z_g)/B,n)*slope[j]*Jdet*gauss->weight*2/(double)connectivity[1];
     3347                                for(j=0;j<NDOF2;j++) pe->values[2*node1+j]+=constant_part*pow((surface-z_g)/B,n)*slope[j]*Jdet*gauss->weight*2/(double)connectivity[1];
    33553348                        }
    33563349                }
     
    33633356                        vb=constant_part*slope[1];
    33643357
    3365                         pe_g[2*node0]+=ub/(double)connectivity[0];
    3366                         pe_g[2*node0+1]+=vb/(double)connectivity[0];
    3367                 }
    3368         }
    3369 
    3370         /*Add pe_g to global vector pg: */
    3371         VecSetValues(pg,numdofs,doflist,(const double*)pe_g,ADD_VALUES);
    3372 
    3373         /*Clean up */
    3374         xfree((void**)&doflist);
     3358                        pe->values[2*node0]+=ub/(double)connectivity[0];
     3359                        pe->values[2*node0+1]+=vb/(double)connectivity[0];
     3360                }
     3361        }
     3362
     3363        /*Clean up and return*/
     3364        return pe;
    33753365}
    33763366/*}}}*/
     
    37733763/*}}}*/
    37743764/*FUNCTION Penta::CreatePVectorSlope {{{1*/
    3775 void Penta::CreatePVectorSlope( Vec pg){
    3776 
    3777         if (!IsOnBed() || IsOnWater()) return;
     3765ElementVector* Penta::CreatePVectorSlope(void){
     3766
     3767        if (!IsOnBed() || IsOnWater()) return NULL;
    37783768
    37793769        /*Call Tria function*/
     
    37813771        ElementVector* pe=tria->CreatePVectorSlope();
    37823772        delete tria->matice; delete tria;
    3783         pe->AddToGlobal(pg,NULL);
    3784         delete pe;
    37853773
    37863774        /*clean up and return*/
    3787         return;
     3775        return pe;
    37883776}
    37893777/*}}}*/
  • issm/trunk/src/c/objects/Elements/Penta.h

    r5926 r5929  
    159159                ElementVector* CreatePVectorCouplingPattynStokesFriction(void);
    160160                ElementVector* CreatePVectorDiagnosticHoriz(void);
    161                 void      CreatePVectorDiagnosticHutter( Vec pg);
     161                ElementVector* CreatePVectorDiagnosticHutter(void);
    162162                ElementVector* CreatePVectorDiagnosticMacAyeal(void);
    163163                ElementVector* CreatePVectorDiagnosticMacAyealPattyn(void);
     
    171171                void      CreatePVectorMelting( Vec pg);
    172172                void      CreatePVectorPrognostic( Vec pg);
    173                 void      CreatePVectorSlope( Vec pg);
     173                ElementVector* CreatePVectorSlope(void);
    174174                void      CreatePVectorThermal( Vec pg);
    175175                void      GetDofList(int** pdoflist,int approximation_enum,int setenum);
Note: See TracChangeset for help on using the changeset viewer.