Changeset 5387 for issm/trunk


Ignore:
Timestamp:
08/18/10 16:08:34 (15 years ago)
Author:
seroussi
Message:

moved HorizFriction into MacAyeal, Pattyn and MacAyealPattynCOupling friction

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

Legend:

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

    r5373 r5387  
    25022502                 * grids: */
    25032503
    2504                 tria->CreateKMatrixDiagnosticHorizFriction(Kgg);
     2504                tria->CreateKMatrixCouplingMacAyealPattynFriction(Kgg);
    25052505        }
    25062506
     
    28352835
    28362836                tria=(Tria*)SpawnTria(0,1,2); //grids 0, 1 and 2 make the new tria.
    2837                 tria->CreateKMatrixDiagnosticHorizFriction(Kgg);
     2837                tria->CreateKMatrixDiagnosticPattynFriction(Kgg);
    28382838                delete tria->matice; delete tria;
    28392839        }
  • issm/trunk/src/c/objects/Elements/Tria.cpp

    r5358 r5387  
    35913591        /*Do not forget to include friction: */
    35923592        if(!shelf){
    3593                 CreateKMatrixDiagnosticHorizFriction(Kgg);
     3593                CreateKMatrixDiagnosticMacAyealFriction(Kgg);
    35943594        }
    35953595
     
    36013601}
    36023602/*}}}*/
    3603 /*FUNCTION Tria::CreateKMatrixDiagnosticHorizFriction {{{1*/
    3604 void  Tria::CreateKMatrixDiagnosticHorizFriction(Mat Kgg){
     3603/*FUNCTION Tria::CreateKMatrixCouplingMacAyealPattynFriction {{{1*/
     3604void  Tria::CreateKMatrixCouplingMacAyealPattynFriction(Mat Kgg){
    36053605
    36063606        /* local declarations */
     
    36123612        const int numdof   = 2 *numvertices;
    36133613        double    xyz_list[numvertices][3];
    3614         int*      doflist=NULL;
     3614        int*      doflistm=NULL;
     3615        int*      doflistp=NULL;
    36153616        int       numberofdofspernode=2;
    36163617
     
    36693670        /* Get node coordinates and dof list: */
    36703671        GetVerticesCoordinates(&xyz_list[0][0], nodes, numvertices);
    3671         GetDofList(&doflist);
     3672        GetDofList(&doflistm,MacAyealApproximationEnum);
     3673        GetDofList(&doflistp,PattynApproximationEnum);
     3674
     3675        if (shelf){
     3676                /*no friction, do nothing*/
     3677                return;
     3678        }
     3679
     3680        /*build friction object, used later on: */
     3681        if (drag_type!=2)ISSMERROR(" non-viscous friction not supported yet!");
     3682        friction=new Friction("2d",inputs,matpar,analysis_type);
     3683
     3684        /*COMPUT alpha2_list (TO BE DELETED)*/
     3685        for(i=0;i<numvertices;i++){
     3686                friction->GetAlpha2(&alpha2_list[i],&gauss[i][0],VxEnum,VyEnum,VzEnum);
     3687        }
     3688
     3689        /* Get gaussian points and weights (make this a statically initialized list of points? fstd): */
     3690        GaussTria( &num_gauss, &first_gauss_area_coord, &second_gauss_area_coord, &third_gauss_area_coord, &gauss_weights, 2);
     3691
     3692        /* Start  looping on the number of gaussian points: */
     3693        for (ig=0; ig<num_gauss; ig++){
     3694                /*Pick up the gaussian point: */
     3695                gauss_weight=*(gauss_weights+ig);
     3696                gauss_l1l2l3[0]=*(first_gauss_area_coord+ig);
     3697                gauss_l1l2l3[1]=*(second_gauss_area_coord+ig);
     3698                gauss_l1l2l3[2]=*(third_gauss_area_coord+ig);
     3699
     3700                /*Friction: */
     3701                // friction->GetAlpha2(&alpha2, gauss_l1l2l3,VxEnum,VyEnum,VzEnum); // TO UNCOMMENT
     3702                TriaRef::GetParameterValue(&alpha2,&alpha2_list[0],gauss_l1l2l3); // TO BE DELETED
     3703
     3704                // If we have a slope > 6% for this element,  it means  we are on a mountain. In this particular case,
     3705                //velocity should be = 0. To achieve this result, we set alpha2_list to a very high value: */
     3706                surface_input->GetParameterDerivativeValue(&slope[0],&xyz_list[0][0],&gauss_l1l2l3[0]);
     3707                slope_magnitude=sqrt(pow(slope[0],2)+pow(slope[1],2));
     3708
     3709                if (slope_magnitude>MAXSLOPE){
     3710                        alpha2=pow((double)10,MOUNTAINKEXPONENT);
     3711                }
     3712
     3713                /* Get Jacobian determinant: */
     3714                GetJacobianDeterminant2d(&Jdet, &xyz_list[0][0],gauss_l1l2l3);
     3715
     3716                /*Get L matrix: */
     3717                GetL(&L[0][0], &xyz_list[0][0], gauss_l1l2l3,numberofdofspernode);
     3718
     3719               
     3720                DL_scalar=alpha2*gauss_weight*Jdet;
     3721                for (i=0;i<2;i++){
     3722                        DL[i][i]=DL_scalar;
     3723                }
     3724               
     3725                /*  Do the triple producte tL*D*L: */
     3726                TripleMultiply( &L[0][0],2,numdof,1,
     3727                                        &DL[0][0],2,2,0,
     3728                                        &L[0][0],2,numdof,0,
     3729                                        &Ke_gg_gaussian[0][0],0);
     3730
     3731                for( i=0; i<numdof; i++) for(j=0;j<numdof;j++) Ke_gg[i][j]+=Ke_gg_gaussian[i][j];
     3732
     3733        } // for (ig=0; ig<num_gauss; ig++)
     3734
     3735        /*Add Ke_gg to global matrix Kgg: */
     3736        MatSetValues(Kgg,numdof,doflistm,numdof,doflistp,(const double*)Ke_gg,ADD_VALUES);
     3737        MatSetValues(Kgg,numdof,doflistp,numdof,doflistm,(const double*)Ke_gg,ADD_VALUES);
     3738
     3739        xfree((void**)&first_gauss_area_coord);
     3740        xfree((void**)&second_gauss_area_coord);
     3741        xfree((void**)&third_gauss_area_coord);
     3742        xfree((void**)&gauss_weights);
     3743        xfree((void**)&doflistm);
     3744        xfree((void**)&doflistp);
     3745        delete friction;
     3746}       
     3747/*}}}*/
     3748/*FUNCTION Tria::CreateKMatrixDiagnosticMacAyealFriction {{{1*/
     3749void  Tria::CreateKMatrixDiagnosticMacAyealFriction(Mat Kgg){
     3750
     3751        /* local declarations */
     3752        int       i,j;
     3753        int       analysis_type;
     3754
     3755        /* node data: */
     3756        const int numvertices = 3;
     3757        const int numdof   = 2 *numvertices;
     3758        double    xyz_list[numvertices][3];
     3759        int*      doflist=NULL;
     3760        int       numberofdofspernode=2;
     3761
     3762        /* gaussian points: */
     3763        int     num_gauss,ig;
     3764        double *first_gauss_area_coord  = NULL;
     3765        double *second_gauss_area_coord = NULL;
     3766        double *third_gauss_area_coord  = NULL;
     3767        double *gauss_weights           = NULL;
     3768        double  gauss_weight;
     3769        double  gauss_l1l2l3[3];
     3770
     3771        /* matrices: */
     3772        double L[2][numdof];
     3773        double DL[2][2]={{ 0,0 },{0,0}}; //for basal drag
     3774        double DL_scalar;
     3775
     3776        /* local element matrices: */
     3777        double Ke_gg[numdof][numdof]={0.0};
     3778        double Ke_gg_gaussian[numdof][numdof]; //stiffness matrix contribution from drag
     3779       
     3780        double Jdet;
     3781       
     3782        /*slope: */
     3783        double  slope[2]={0.0,0.0};
     3784        double  slope_magnitude;
     3785
     3786        /*friction: */
     3787        Friction *friction = NULL;
     3788        double    alpha2;
     3789        double    alpha2_list[numvertices];                                       //TO BE DELETED
     3790        double    gauss[numvertices][numvertices] = {{1,0,0},{0,1,0},{0,0,1}}; //TO BE DELETED
     3791
     3792        double MAXSLOPE=.06; // 6 %
     3793        double MOUNTAINKEXPONENT=10;
     3794
     3795        /*inputs: */
     3796        bool shelf;
     3797        int  drag_type;
     3798        Input* surface_input=NULL;
     3799        Input* vx_input=NULL;
     3800        Input* vy_input=NULL;
     3801        Input* vz_input=NULL;
     3802
     3803        /*retrive parameters: */
     3804        parameters->FindParam(&analysis_type,AnalysisTypeEnum);
     3805
     3806        /*retrieve inputs :*/
     3807        inputs->GetParameterValue(&shelf,ElementOnIceShelfEnum);
     3808        inputs->GetParameterValue(&drag_type,DragTypeEnum);
     3809        surface_input=inputs->GetInput(SurfaceEnum);
     3810        vx_input=inputs->GetInput(VxEnum);
     3811        vy_input=inputs->GetInput(VyEnum);
     3812        vz_input=inputs->GetInput(VzEnum);
     3813       
     3814        /* Get node coordinates and dof list: */
     3815        GetVerticesCoordinates(&xyz_list[0][0], nodes, numvertices);
     3816        GetDofList(&doflist,MacAyealApproximationEnum);
     3817
     3818        if (shelf){
     3819                /*no friction, do nothing*/
     3820                return;
     3821        }
     3822
     3823        /*build friction object, used later on: */
     3824        if (drag_type!=2)ISSMERROR(" non-viscous friction not supported yet!");
     3825        friction=new Friction("2d",inputs,matpar,analysis_type);
     3826
     3827        /*COMPUT alpha2_list (TO BE DELETED)*/
     3828        for(i=0;i<numvertices;i++){
     3829                friction->GetAlpha2(&alpha2_list[i],&gauss[i][0],VxEnum,VyEnum,VzEnum);
     3830        }
     3831
     3832        /* Get gaussian points and weights (make this a statically initialized list of points? fstd): */
     3833        GaussTria( &num_gauss, &first_gauss_area_coord, &second_gauss_area_coord, &third_gauss_area_coord, &gauss_weights, 2);
     3834
     3835        /* Start  looping on the number of gaussian points: */
     3836        for (ig=0; ig<num_gauss; ig++){
     3837                /*Pick up the gaussian point: */
     3838                gauss_weight=*(gauss_weights+ig);
     3839                gauss_l1l2l3[0]=*(first_gauss_area_coord+ig);
     3840                gauss_l1l2l3[1]=*(second_gauss_area_coord+ig);
     3841                gauss_l1l2l3[2]=*(third_gauss_area_coord+ig);
     3842
     3843                /*Friction: */
     3844                // friction->GetAlpha2(&alpha2, gauss_l1l2l3,VxEnum,VyEnum,VzEnum); // TO UNCOMMENT
     3845                TriaRef::GetParameterValue(&alpha2,&alpha2_list[0],gauss_l1l2l3); // TO BE DELETED
     3846
     3847                // If we have a slope > 6% for this element,  it means  we are on a mountain. In this particular case,
     3848                //velocity should be = 0. To achieve this result, we set alpha2_list to a very high value: */
     3849                surface_input->GetParameterDerivativeValue(&slope[0],&xyz_list[0][0],&gauss_l1l2l3[0]);
     3850                slope_magnitude=sqrt(pow(slope[0],2)+pow(slope[1],2));
     3851
     3852                if (slope_magnitude>MAXSLOPE){
     3853                        alpha2=pow((double)10,MOUNTAINKEXPONENT);
     3854                }
     3855
     3856                /* Get Jacobian determinant: */
     3857                GetJacobianDeterminant2d(&Jdet, &xyz_list[0][0],gauss_l1l2l3);
     3858
     3859                /*Get L matrix: */
     3860                GetL(&L[0][0], &xyz_list[0][0], gauss_l1l2l3,numberofdofspernode);
     3861
     3862               
     3863                DL_scalar=alpha2*gauss_weight*Jdet;
     3864                for (i=0;i<2;i++){
     3865                        DL[i][i]=DL_scalar;
     3866                }
     3867               
     3868                /*  Do the triple producte tL*D*L: */
     3869                TripleMultiply( &L[0][0],2,numdof,1,
     3870                                        &DL[0][0],2,2,0,
     3871                                        &L[0][0],2,numdof,0,
     3872                                        &Ke_gg_gaussian[0][0],0);
     3873
     3874                for( i=0; i<numdof; i++) for(j=0;j<numdof;j++) Ke_gg[i][j]+=Ke_gg_gaussian[i][j];
     3875
     3876        } // for (ig=0; ig<num_gauss; ig++)
     3877
     3878        /*Add Ke_gg to global matrix Kgg: */
     3879        MatSetValues(Kgg,numdof,doflist,numdof,doflist,(const double*)Ke_gg,ADD_VALUES);
     3880
     3881        xfree((void**)&first_gauss_area_coord);
     3882        xfree((void**)&second_gauss_area_coord);
     3883        xfree((void**)&third_gauss_area_coord);
     3884        xfree((void**)&gauss_weights);
     3885        xfree((void**)&doflist);
     3886        delete friction;
     3887}       
     3888/*}}}*/
     3889/*FUNCTION Tria::CreateKMatrixDiagnosticPattynFriction {{{1*/
     3890void  Tria::CreateKMatrixDiagnosticPattynFriction(Mat Kgg){
     3891
     3892        /* local declarations */
     3893        int       i,j;
     3894        int       analysis_type;
     3895
     3896        /* node data: */
     3897        const int numvertices = 3;
     3898        const int numdof   = 2 *numvertices;
     3899        double    xyz_list[numvertices][3];
     3900        int*      doflist=NULL;
     3901        int       numberofdofspernode=2;
     3902
     3903        /* gaussian points: */
     3904        int     num_gauss,ig;
     3905        double *first_gauss_area_coord  = NULL;
     3906        double *second_gauss_area_coord = NULL;
     3907        double *third_gauss_area_coord  = NULL;
     3908        double *gauss_weights           = NULL;
     3909        double  gauss_weight;
     3910        double  gauss_l1l2l3[3];
     3911
     3912        /* matrices: */
     3913        double L[2][numdof];
     3914        double DL[2][2]={{ 0,0 },{0,0}}; //for basal drag
     3915        double DL_scalar;
     3916
     3917        /* local element matrices: */
     3918        double Ke_gg[numdof][numdof]={0.0};
     3919        double Ke_gg_gaussian[numdof][numdof]; //stiffness matrix contribution from drag
     3920       
     3921        double Jdet;
     3922       
     3923        /*slope: */
     3924        double  slope[2]={0.0,0.0};
     3925        double  slope_magnitude;
     3926
     3927        /*friction: */
     3928        Friction *friction = NULL;
     3929        double    alpha2;
     3930        double    alpha2_list[numvertices];                                       //TO BE DELETED
     3931        double    gauss[numvertices][numvertices] = {{1,0,0},{0,1,0},{0,0,1}}; //TO BE DELETED
     3932
     3933        double MAXSLOPE=.06; // 6 %
     3934        double MOUNTAINKEXPONENT=10;
     3935
     3936        /*inputs: */
     3937        bool shelf;
     3938        int  drag_type;
     3939        Input* surface_input=NULL;
     3940        Input* vx_input=NULL;
     3941        Input* vy_input=NULL;
     3942        Input* vz_input=NULL;
     3943
     3944        /*retrive parameters: */
     3945        parameters->FindParam(&analysis_type,AnalysisTypeEnum);
     3946
     3947        /*retrieve inputs :*/
     3948        inputs->GetParameterValue(&shelf,ElementOnIceShelfEnum);
     3949        inputs->GetParameterValue(&drag_type,DragTypeEnum);
     3950        surface_input=inputs->GetInput(SurfaceEnum);
     3951        vx_input=inputs->GetInput(VxEnum);
     3952        vy_input=inputs->GetInput(VyEnum);
     3953        vz_input=inputs->GetInput(VzEnum);
     3954       
     3955        /* Get node coordinates and dof list: */
     3956        GetVerticesCoordinates(&xyz_list[0][0], nodes, numvertices);
     3957        GetDofList(&doflist,PattynApproximationEnum);
    36723958
    36733959        if (shelf){
  • issm/trunk/src/c/objects/Elements/Tria.h

    r5311 r5387  
    124124                void      CreateKMatrixBalancedvelocities(Mat Kgg);
    125125                void      CreateKMatrixDiagnosticMacAyeal(Mat Kgg);
    126                 void      CreateKMatrixDiagnosticHorizFriction(Mat Kgg);
     126                void      CreateKMatrixCouplingMacAyealPattynFriction(Mat Kgg);
     127                void      CreateKMatrixDiagnosticMacAyealFriction(Mat Kgg);
     128                void      CreateKMatrixDiagnosticPattynFriction(Mat Kgg);
    127129                void      CreateKMatrixDiagnosticHutter(Mat Kgg);
    128130                void      CreateKMatrixDiagnosticSurfaceVert(Mat Kgg);
Note: See TracChangeset for help on using the changeset viewer.