Changeset 6150


Ignore:
Timestamp:
10/04/10 13:17:49 (14 years ago)
Author:
seroussi
Message:

added some code for MacAyealStokes

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

Legend:

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

    r6141 r6150  
    830830                        GetSolutionFromInputsDiagnosticHoriz(solution);
    831831                }
    832                 else if (approximation==MacAyealPattynApproximationEnum || approximation==PattynStokesApproximationEnum){
     832                else if (approximation==MacAyealPattynApproximationEnum || approximation==PattynStokesApproximationEnum || approximation==MacAyealStokesApproximationEnum){
    833833                        return; //the elements around will create the solution
    834834                }
     
    44384438                InputUpdateFromSolutionDiagnosticPattynStokes(solution);
    44394439        }
     4440        else if (approximation==MacAyealStokesApproximationEnum){
     4441                InputUpdateFromSolutionDiagnosticMacAyealStokes(solution);
     4442        }
    44404443        else if (approximation==StokesApproximationEnum || approximation==NoneApproximationEnum){
    44414444                InputUpdateFromSolutionDiagnosticStokes(solution);
     
    46274630        xfree((void**)&doflistp);
    46284631        xfree((void**)&doflistm);
     4632}
     4633/*}}}*/
     4634/*FUNCTION Penta::InputUpdateFromSolutionDiagnosticMacAyealStokes {{{1*/
     4635void  Penta::InputUpdateFromSolutionDiagnosticMacAyealStokes(double* solution){
     4636
     4637        int i;
     4638
     4639        const int    numdofm=NDOF2*NUMVERTICES;
     4640        const int    numdofs=NDOF4*NUMVERTICES;
     4641        const int    numdof2d=NDOF2*NUMVERTICES2D;
     4642        int*         doflistm=NULL;
     4643        int*         doflists=NULL;
     4644        double       macayeal_values[numdofm];
     4645        double       stokes_values[numdofs];
     4646        double       vx[NUMVERTICES];
     4647        double       vy[NUMVERTICES];
     4648        double       vz[NUMVERTICES];
     4649        double       vzmacayeal[NUMVERTICES];
     4650        double       vzstokes[NUMVERTICES];
     4651        double       vel[NUMVERTICES];
     4652        int          dummy;
     4653        double       pressure[NUMVERTICES];
     4654        double       xyz_list[NUMVERTICES][3];
     4655        double       stokesreconditioning;
     4656
     4657        double *vzmacayeal_ptr         = NULL;
     4658        Penta  *penta          = NULL;
     4659
     4660        /*OK, we have to add results of this element for macayeal
     4661         * and results from the penta at base for macayeal. Now recover results*/
     4662        penta=GetBasalElement();
     4663
     4664        /*Get dof listof this element (macayeal dofs) and of the penta at base (macayeal dofs): */
     4665        penta->GetDofList(&doflistm,MacAyealApproximationEnum,GsetEnum);
     4666        GetDofList(&doflists,StokesApproximationEnum,GsetEnum);
     4667        this->parameters->FindParam(&stokesreconditioning,StokesReconditioningEnum);
     4668
     4669        /*Get node data: */
     4670        GetVerticesCoordinates(&xyz_list[0][0], nodes, NUMVERTICES);
     4671
     4672        /*Use the dof list to index into the solution vector: */
     4673        for(i=0;i<numdof2d;i++){
     4674                macayeal_values[i]=solution[doflistm[i]];
     4675                macayeal_values[i+numdof2d]=solution[doflistm[i]];
     4676        }
     4677        for(i=0;i<numdofs;i++){
     4678                stokes_values[i]=solution[doflists[i]];
     4679        }
     4680
     4681        /*Ok, we have vx and vy in values, fill in vx and vy arrays: */
     4682        for(i=0;i<NUMVERTICES;i++){
     4683                vx[i]=stokes_values[i*NDOF4+0]+macayeal_values[i*NDOF2+0];
     4684                vy[i]=stokes_values[i*NDOF4+1]+macayeal_values[i*NDOF2+1];
     4685                vzstokes[i]=stokes_values[i*NDOF4+2];
     4686                pressure[i]=stokes_values[i*NDOF4+3]*stokesreconditioning;
     4687        }
     4688
     4689        /*Get Vz*/
     4690        Input* vzmacayeal_input=inputs->GetInput(VzMacAyealEnum);
     4691        if (vzmacayeal_input){
     4692                if (vzmacayeal_input->Enum()!=PentaVertexInputEnum){
     4693                        ISSMERROR("Cannot compute Vel as VzMacAyeal is of type %s",EnumToString(vzmacayeal_input->Enum()));
     4694                }
     4695                vzmacayeal_input->GetValuesPtr(&vzmacayeal_ptr,&dummy);
     4696                for(i=0;i<NUMVERTICES;i++) vzmacayeal[i]=vzmacayeal_ptr[i];
     4697        }
     4698        else{
     4699                ISSMERROR("Cannot update solution as VzMacAyeal is not present");
     4700        }
     4701
     4702        /*Now Compute vel*/
     4703        for(i=0;i<NUMVERTICES;i++) {
     4704                vz[i]=vzmacayeal[i]+vzstokes[i];
     4705                vel[i]=pow( pow(vx[i],2.0) + pow(vy[i],2.0) + pow(vz[i],2.0) , 0.5);
     4706        }
     4707
     4708        /*Now, we have to move the previous Vx and Vy inputs  to old
     4709         * status, otherwise, we'll wipe them off: */
     4710        this->inputs->ChangeEnum(VxEnum,VxOldEnum);
     4711        this->inputs->ChangeEnum(VyEnum,VyOldEnum);
     4712        this->inputs->ChangeEnum(VzEnum,VzOldEnum);
     4713        this->inputs->ChangeEnum(PressureEnum,PressureOldEnum);
     4714
     4715        /*Add vx and vy as inputs to the tria element: */
     4716        this->inputs->AddInput(new PentaVertexInput(VxEnum,vx));
     4717        this->inputs->AddInput(new PentaVertexInput(VyEnum,vy));
     4718        this->inputs->AddInput(new PentaVertexInput(VzEnum,vz));
     4719        this->inputs->AddInput(new PentaVertexInput(VzStokesEnum,vzstokes));
     4720        this->inputs->AddInput(new PentaVertexInput(VelEnum,vel));
     4721        this->inputs->AddInput(new PentaVertexInput(PressureEnum,pressure));
     4722
     4723        /*Free ressources:*/
     4724        xfree((void**)&doflistm);
     4725        xfree((void**)&doflists);
    46294726}
    46304727/*}}}*/
     
    48894986        double       vy[NUMVERTICES];
    48904987        double       vz[NUMVERTICES];
     4988        double       vzmacayeal[NUMVERTICES];
    48914989        double       vzpattyn[NUMVERTICES];
    48924990        double       vzstokes[NUMVERTICES];
     
    49435041        else for(i=0;i<NUMVERTICES;i++) vy[i]=0.0;
    49445042
    4945         /*Do some modifications if we actually have a PattynStokes element*/
     5043        /*Do some modifications if we actually have a PattynStokes or MacAyealStokes element*/
    49465044        if(approximation==PattynStokesApproximationEnum){
    49475045                Input* vzstokes_input=inputs->GetInput(VzStokesEnum);
     
    49575055                }
    49585056        }
     5057        else if(approximation==MacAyealStokesApproximationEnum){
     5058                Input* vzstokes_input=inputs->GetInput(VzStokesEnum);
     5059                if (vzstokes_input){
     5060                        if (vzstokes_input->Enum()!=PentaVertexInputEnum) ISSMERROR("Cannot compute Vel as VzStokes is of type %s",EnumToString(vy_input->Enum()));
     5061                        vzstokes_input->GetValuesPtr(&vzstokes_ptr,&dummy);
     5062                        for(i=0;i<NUMVERTICES;i++) vzstokes[i]=vzstokes_ptr[i];
     5063                }
     5064                else ISSMERROR("Cannot compute Vz as VzStokes in not present in MacAyealStokes element");
     5065                for(i=0;i<NUMVERTICES;i++){
     5066                        vzmacayeal[i]=vz[i];
     5067                        vz[i]=vzmacayeal[i]+vzstokes[i];
     5068                }
     5069        }
    49595070
    49605071        /*Now Compute vel*/
     
    49645075        /*For pressure: we have not computed pressure in this analysis, for this element. We are in 3D,
    49655076         *so the pressure is just the pressure at the z elevation: except it this is a PattynStokes element */
    4966         if(approximation!=PattynStokesApproximationEnum){
     5077        if(approximation!=PattynStokesApproximationEnum &&  approximation!=MacAyealStokesApproximationEnum){
    49675078                rho_ice=matpar->GetRhoIce();
    49685079                g=matpar->GetG();
     
    49755086        this->inputs->ChangeEnum(VzEnum,VzOldEnum);
    49765087
    4977         if(approximation!=PattynStokesApproximationEnum){
     5088        if(approximation!=PattynStokesApproximationEnum && approximation!=MacAyealStokesApproximationEnum){
    49785089                this->inputs->ChangeEnum(PressureEnum,PressureOldEnum);
    49795090                this->inputs->AddInput(new PentaVertexInput(PressureEnum,pressure));
    49805091        }
    4981         else{
     5092        else if(approximation==PattynStokesApproximationEnum){
    49825093                this->inputs->AddInput(new PentaVertexInput(VzPattynEnum,vzpattyn));
     5094        }
     5095        else if(approximation==MacAyealStokesApproximationEnum){
     5096                this->inputs->AddInput(new PentaVertexInput(VzMacAyealEnum,vzpattyn));
    49835097        }
    49845098
  • issm/trunk/src/c/objects/Elements/Penta.h

    r6130 r6150  
    202202                void    InputUpdateFromSolutionDiagnosticMacAyeal( double* solutiong);
    203203                void    InputUpdateFromSolutionDiagnosticMacAyealPattyn( double* solutiong);
     204                void    InputUpdateFromSolutionDiagnosticMacAyealStokes( double* solutiong);
    204205                void    InputUpdateFromSolutionDiagnosticPattyn( double* solutiong);
    205206                void    InputUpdateFromSolutionDiagnosticPattynStokes( double* solutiong);
Note: See TracChangeset for help on using the changeset viewer.