Changeset 5922


Ignore:
Timestamp:
09/21/10 14:11:25 (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

    r5921 r5922  
    37713771void Penta::CreatePVectorSlope( Vec pg){
    37723772
    3773         /*Collapsed formulation: */
    3774         Tria*  tria=NULL;
    3775 
    3776         /*If on water, skip: */
    3777         if(IsOnWater())return;
    3778 
    3779         /*Is this element on the bed? :*/
    3780         if(!IsOnBed())return;
    3781 
    3782         /*Spawn Tria element from the base of the Penta: */
    3783         tria=(Tria*)SpawnTria(0,1,2); //grids 0, 1 and 2 make the new tria.
    3784         tria->CreatePVector(pg,NULL);
     3773        if (!IsOnBed() || IsOnWater()) return;
     3774
     3775        /*Call Tria function*/
     3776        Tria* tria=(Tria*)SpawnTria(0,1,2); //grids 0, 1 and 2 make the new tria.
     3777        ElementVector* pe=tria->CreatePVectorSlope();
    37853778        delete tria->matice; delete tria;
     3779        pe->AddToGlobal(pg,NULL);
     3780        delete pe;
     3781
     3782        /*clean up and return*/
    37863783        return;
    37873784}
  • issm/trunk/src/c/objects/Elements/Tria.cpp

    r5921 r5922  
    761761                        break;
    762762                case DiagnosticHutterAnalysisEnum:
    763                         CreatePVectorDiagnosticHutter( pg);
     763                        pe=CreatePVectorDiagnosticHutter();
     764                        pe->AddToGlobal(pg,pf);
     765                        delete pe;
    764766                        break;
    765767                case BedSlopeXAnalysisEnum: case SurfaceSlopeXAnalysisEnum: case BedSlopeYAnalysisEnum: case SurfaceSlopeYAnalysisEnum:
    766                         CreatePVectorSlope( pg);
     768                        pe=CreatePVectorSlope();
     769                        pe->AddToGlobal(pg,pf);
     770                        delete pe;
    767771                        break;
    768772                case PrognosticAnalysisEnum:
     
    36873691        /*Initialize Element vector and return if necessary*/
    36883692        if(IsOnWater()) return NULL;
    3689         ElementVector* pe=NewElementVector(nodes,NUMVERTICES,this->parameters);
     3693        ElementVector* pe=NewElementVector(nodes,NUMVERTICES,this->parameters,MacAyealApproximationEnum);
    36903694
    36913695        /*Retrieve all inputs and parameters*/
     
    41974201/*}}}*/
    41984202/*FUNCTION Tria::CreatePVectorDiagnosticHutter{{{1*/
    4199 void  Tria::CreatePVectorDiagnosticHutter(Vec pg){
     4203ElementVector* Tria::CreatePVectorDiagnosticHutter(void){
    42004204
    42014205        /*Collapsed formulation: */
     
    42054209        double    constant_part,ub,vb;
    42064210        double    rho_ice,gravity,n,B;
    4207         double    pe_g[numdofs];
    42084211        double    slope[2];
    42094212        double    thickness;
     
    42124215        GaussTria* gauss=NULL;
    42134216
    4214         /*If on water, skip: */
    4215         if(IsOnWater())return;
    4216 
    4217         GetDofList(&doflist,NoneApproximationEnum,GsetEnum);
    4218        
    4219         /* Get parameters */
     4217        /*Initialize Element vector and return if necessary*/
     4218        if(IsOnWater()) return NULL;
     4219        ElementVector* pe=NewElementVector(nodes,NUMVERTICES,this->parameters);
     4220
     4221        /*Retrieve all inputs and parameters*/
    42204222        rho_ice=matpar->GetRhoIce();
    42214223        gravity=matpar->GetG();
    42224224        n=matice->GetN();
    42234225        B=matice->GetBbar();
    4224 
    4225         /* Get slopes and thickness */
    42264226        Input* slopex_input=inputs->GetInput(SurfaceSlopeXEnum); ISSMASSERT(slopex_input);
    42274227        Input* slopey_input=inputs->GetInput(SurfaceSlopeYEnum); ISSMASSERT(slopey_input);
     
    42414241                slope2=pow(slope[0],2)+pow(slope[1],2);
    42424242
    4243                 //compute constant_part
    42444243                constant_part=-2*pow(rho_ice*gravity,n)*pow(slope2,((n-1)/2));
    42454244
    4246                 //compute ub
    42474245                ub=-1.58*pow((double)10.0,(double)-10.0)*rho_ice*gravity*thickness*slope[0];
    42484246                vb=-1.58*pow((double)10.0,(double)-10.0)*rho_ice*gravity*thickness*slope[1];
    42494247
    4250                 pe_g[2*i]=(ub-2.0*pow(rho_ice*gravity,n)*pow(slope2,((n-1)/2.0))*pow(thickness,n)/(pow(B,n)*(n+1))*slope[0])/(double)connectivity;
    4251                 pe_g[2*i+1]=(vb-2.0*pow(rho_ice*gravity,n)*pow(slope2,((n-1)/2.0))*pow(thickness,n)/(pow(B,n)*(n+1))*slope[1])/(double)connectivity;
    4252 
    4253         }
    4254 
    4255         VecSetValues(pg,numdofs,doflist,(const double*)pe_g,ADD_VALUES);
     4248                pe->values[2*i]  =(ub-2.0*pow(rho_ice*gravity,n)*pow(slope2,((n-1)/2.0))*pow(thickness,n)/(pow(B,n)*(n+1))*slope[0])/(double)connectivity;
     4249                pe->values[2*i+1]=(vb-2.0*pow(rho_ice*gravity,n)*pow(slope2,((n-1)/2.0))*pow(thickness,n)/(pow(B,n)*(n+1))*slope[1])/(double)connectivity;
     4250        }
    42564251
    42574252        /*Clean up and return*/
    42584253        delete gauss;
    4259         xfree((void**)&doflist);
     4254        return pe;
    42604255}
    42614256/*}}}*/
     
    44154410/*}}}*/
    44164411/*FUNCTION Tria::CreatePVectorSlope {{{1*/
    4417 void Tria::CreatePVectorSlope( Vec pg){
    4418 
    4419         int             i,j;
     4412ElementVector* Tria::CreatePVectorSlope(void){
    44204413
    44214414        /* node data: */
    44224415        const int    numdof=NDOF1*NUMVERTICES;
     4416        int             i,j;
     4417        int     ig;
    44234418        double       xyz_list[NUMVERTICES][3];
    44244419        int*         doflist=NULL;
    4425        
    4426         /* gaussian points: */
    4427         int     ig;
    44284420        GaussTria* gauss=NULL;
    4429 
    4430         /* Jacobian: */
    44314421        double Jdet;
    4432 
    4433         /*nodal functions: */
    44344422        double l1l2l3[3];
    4435 
    4436         /*element vector at the gaussian points: */
    4437         double  pe_g[numdof]={0.0};
    44384423        double  pe_g_gaussian[numdof];
    44394424        double  slope[2];
    44404425        int     analysis_type;
    44414426
    4442         /*inputs :*/
     4427        /*Initialize Element vector and return if necessary*/
     4428        if(IsOnWater()) return NULL;
     4429        ElementVector* pe=NewElementVector(nodes,NUMVERTICES,this->parameters);
     4430
     4431        /*Retrieve all inputs and parameters*/
     4432        parameters->FindParam(&analysis_type,AnalysisTypeEnum);
     4433        GetVerticesCoordinates(&xyz_list[0][0], nodes, NUMVERTICES);
    44434434        Input* slope_input=NULL;
    4444 
    4445         /*retrive parameters: */
    4446         parameters->FindParam(&analysis_type,AnalysisTypeEnum);
    4447 
    4448         /* Get node coordinates and dof list: */
    4449         GetVerticesCoordinates(&xyz_list[0][0], nodes, NUMVERTICES);
    4450         GetDofList(&doflist,NoneApproximationEnum,GsetEnum);
    4451 
    4452         /*Retrieve all inputs we will be needing: */
    44534435        if ( (analysis_type==SurfaceSlopeXAnalysisEnum) || (analysis_type==SurfaceSlopeYAnalysisEnum)){
    44544436                slope_input=inputs->GetInput(SurfaceEnum); ISSMASSERT(slope_input);
     
    44814463
    44824464                /*Add pe_g_gaussian vector to pe_g: */
    4483                 for( i=0; i<numdof; i++)pe_g[i]+=pe_g_gaussian[i];
    4484 
    4485         }
    4486 
    4487         /*Add pe_g to global vector pg: */
    4488         VecSetValues(pg,numdof,doflist,(const double*)pe_g,ADD_VALUES);
     4465                for(i=0;i<numdof;i++) pe->values[i]+=pe_g_gaussian[i];
     4466
     4467        }
    44894468
    44904469        /*Clean up and return*/
    44914470        delete gauss;
    4492         xfree((void**)&doflist);
     4471        return pe;
    44934472}
    44944473/*}}}*/
  • issm/trunk/src/c/objects/Elements/Tria.h

    r5921 r5922  
    147147                void      CreatePVectorAdjointStokes(Vec pg);
    148148                void      CreatePVectorAdjointBalancedthickness(Vec pg);
    149                 void      CreatePVectorDiagnosticHutter(Vec pg);
     149                ElementVector* CreatePVectorDiagnosticHutter(void);
    150150                void      CreatePVectorPrognostic(Vec pg);
    151151                void      CreatePVectorPrognostic_CG(Vec pg);
    152152                void      CreatePVectorPrognostic_DG(Vec pg);
    153                 void      CreatePVectorSlope( Vec pg);
     153                ElementVector* CreatePVectorSlope(void);
    154154                void      CreatePVectorThermalSheet( Vec pg);
    155155                void      CreatePVectorThermalShelf( Vec pg);
Note: See TracChangeset for help on using the changeset viewer.