source: issm/oecreview/Archive/22819-23185/ISSM-22873-22874.diff

Last change on this file was 23186, checked in by Mathieu Morlighem, 7 years ago

CHG: added Archive/22819-23185

File size: 33.7 KB
  • ../trunk-jpl/src/c/analyses/ThermalAnalysis.cpp

     
    1111        int        M,N;
    1212        int finiteelement;
    1313        iomodel->FindConstant(&finiteelement,"md.thermal.fe");
    14         _assert_(finiteelement==P1Enum); 
     14        _assert_(finiteelement==P1Enum);
    1515
    1616        /*Output*/
    1717        IssmDouble *spcvector  = NULL;
     
    9393
    9494        int finiteelement;
    9595        iomodel->FindConstant(&finiteelement,"md.thermal.fe");
    96         _assert_(finiteelement==P1Enum); 
    97        
     96        _assert_(finiteelement==P1Enum);
     97
    9898        if(iomodel->domaintype==Domain3DEnum) iomodel->FetchData(2,"md.mesh.vertexonbase","md.mesh.vertexonsurface");
    9999        ::CreateNodes(nodes,iomodel,ThermalAnalysisEnum,finiteelement);
    100100        iomodel->DeleteData(2,"md.mesh.vertexonbase","md.mesh.vertexonsurface");
     
    112112        /*Update elements: */
    113113        int finiteelement;
    114114        iomodel->FindConstant(&finiteelement,"md.thermal.fe");
    115         _assert_(finiteelement==P1Enum); 
     115        _assert_(finiteelement==P1Enum);
    116116        int counter=0;
    117117        for(int i=0;i<iomodel->numberofelements;i++){
    118118                if(iomodel->my_elements[i]){
     
    188188                        iomodel->FetchDataToInput(elements,"md.friction.coefficient",FrictionCoefficientEnum);
    189189                        iomodel->FetchDataToInput(elements,"md.friction.p",FrictionPEnum);
    190190                        iomodel->FetchDataToInput(elements,"md.friction.q",FrictionQEnum);
    191                         if (FrictionCoupling==1){
    192                                 iomodel->FetchDataToInput(elements,"md.friction.effective_pressure",FrictionEffectivePressureEnum);
     191                        if (FrictionCoupling==3){
     192                                iomodel->FetchDataToInput(elements,"md.friction.effective_pressure",FrictionEffectivePressureEnum);}
     193                        else if(FrictionCoupling==4){
     194                                iomodel->FetchDataToInput(elements,"md.friction.effective_pressure",EffectivePressureEnum);
    193195                        }
    194196                        break;
    195197                case 2:
     
    201203                        iomodel->FetchDataToInput(elements,"md.friction.C",FrictionCEnum);
    202204                        iomodel->FetchDataToInput(elements,"md.friction.As",FrictionAsEnum);
    203205                        iomodel->FetchDataToInput(elements,"md.friction.q",FrictionQEnum);
    204                         if (FrictionCoupling==1){
    205                                 iomodel->FetchDataToInput(elements,"md.friction.effective_pressure",FrictionEffectivePressureEnum);
     206                        if (FrictionCoupling==3){
     207                                iomodel->FetchDataToInput(elements,"md.friction.effective_pressure",FrictionEffectivePressureEnum);}
     208                        else if(FrictionCoupling==4){
     209                                iomodel->FetchDataToInput(elements,"md.friction.effective_pressure",EffectivePressureEnum);
    206210                        }
    207211                        break;
    208212                case 4:
     
    230234                        iomodel->FetchDataToInput(elements,"md.friction.coefficientcoulomb",FrictionCoefficientcoulombEnum);
    231235                        iomodel->FetchDataToInput(elements,"md.friction.p",FrictionPEnum);
    232236                        iomodel->FetchDataToInput(elements,"md.friction.q",FrictionQEnum);
    233                         if (FrictionCoupling==1){
    234                                 iomodel->FetchDataToInput(elements,"md.friction.effective_pressure",FrictionEffectivePressureEnum);
     237                        if (FrictionCoupling==3){
     238                                iomodel->FetchDataToInput(elements,"md.friction.effective_pressure",FrictionEffectivePressureEnum);}
     239                        else if(FrictionCoupling==4){
     240                                iomodel->FetchDataToInput(elements,"md.friction.effective_pressure",EffectivePressureEnum);
    235241                        }
    236242                        break;
    237243                case 9:
     
    452458                        K[1][0]=h/(2.*vel)*fabs(vy*vx);  K[1][1]=h/(2.*vel)*fabs(vy*vy); K[1][2]=h/(2.*vel)*fabs(vy*vz);
    453459                        K[2][0]=h/(2.*vel)*fabs(vz*vx);  K[2][1]=h/(2.*vel)*fabs(vz*vy); K[2][2]=h/(2.*vel)*fabs(vz*vz);
    454460                        for(int i=0;i<3;i++) for(int j=0;j<3;j++) K[i][j] = D_scalar*K[i][j];
    455                         GetBAdvecprime(Bprime,element,xyz_list,gauss); 
     461                        GetBAdvecprime(Bprime,element,xyz_list,gauss);
    456462
    457463                        TripleMultiply(Bprime,3,numnodes,1,
    458464                                                &K[0][0],3,3,0,
     
    487493        return Ke;
    488494}/*}}}*/
    489495ElementVector* ThermalAnalysis::CreatePVector(Element* element){/*{{{*/
    490        
     496
    491497        /* Check if ice in element */
    492498        if(!element->IsIceInElement()) return NULL;
    493499
     
    700706
    701707}/*}}}*/
    702708void           ThermalAnalysis::GetBAdvec(IssmDouble* B,Element* element,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/
    703         /*Compute B  matrix. B=[B1 B2 B3 B4 B5 B6] where Bi is of size 5*NDOF1. 
     709        /*Compute B  matrix. B=[B1 B2 B3 B4 B5 B6] where Bi is of size 5*NDOF1.
    704710         * For node i, Bi' can be expressed in the actual coordinate system
    705          * by: 
     711         * by:
    706712         *       Bi_advec =[ h ]
    707713         *                 [ h ]
    708714         *                 [ h ]
     
    729735        xDelete<IssmDouble>(basis);
    730736}/*}}}*/
    731737void           ThermalAnalysis::GetBAdvecprime(IssmDouble* B,Element* element,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/
    732         /*Compute B  matrix. B=[B1 B2 B3 B4 B5 B6] where Bi is of size 5*NDOF1. 
     738        /*Compute B  matrix. B=[B1 B2 B3 B4 B5 B6] where Bi is of size 5*NDOF1.
    733739         * For node i, Bi' can be expressed in the actual coordinate system
    734          * by: 
     740         * by:
    735741         *       Biprime_advec=[ dh/dx ]
    736742         *                     [ dh/dy ]
    737743         *                     [ dh/dz ]
     
    758764        xDelete<IssmDouble>(dbasis);
    759765}/*}}}*/
    760766void           ThermalAnalysis::GetBConduct(IssmDouble* B,Element* element,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/
    761         /*Compute B  matrix. B=[B1 B2 B3 B4 B5 B6] where Bi is of size 5*NDOF1. 
     767        /*Compute B  matrix. B=[B1 B2 B3 B4 B5 B6] where Bi is of size 5*NDOF1.
    762768         * For node i, Bi' can be expressed in the actual coordinate system
    763          * by: 
     769         * by:
    764770         *       Bi_conduct=[ dh/dx ]
    765771         *                  [ dh/dy ]
    766772         *                  [ dh/dz ]
  • ../trunk-jpl/src/c/analyses/StressbalanceAnalysis.cpp

     
    610610                         }
    611611                         break;
    612612                case L1L2ApproximationEnum: numdofs =2; break;
    613                 case HOApproximationEnum:   
     613                case HOApproximationEnum:
    614614                         switch(domaintype){
    615615                                 case Domain3DEnum:         numdofs=2; break;
    616616                                 case Domain2DverticalEnum: numdofs=1; break;
     
    784784                        iomodel->FetchDataToInput(elements,"md.friction.coefficient",FrictionCoefficientEnum);
    785785                        iomodel->FetchDataToInput(elements,"md.friction.p",FrictionPEnum);
    786786                        iomodel->FetchDataToInput(elements,"md.friction.q",FrictionQEnum);
    787                         if(FrictionCoupling==1){
    788                                 iomodel->FetchDataToInput(elements,"md.friction.effective_pressure",FrictionEffectivePressureEnum);
     787                        if(FrictionCoupling==3){
     788                                iomodel->FetchDataToInput(elements,"md.friction.effective_pressure",FrictionEffectivePressureEnum);}
     789                        else if(FrictionCoupling==4){
     790                                iomodel->FetchDataToInput(elements,"md.friction.effective_pressure",EffectivePressureEnum);
    789791                        }
    790792                        break;
    791793                case 2:
     
    797799                        iomodel->FetchDataToInput(elements,"md.friction.C",FrictionCEnum);
    798800                        iomodel->FetchDataToInput(elements,"md.friction.As",FrictionAsEnum);
    799801                        iomodel->FetchDataToInput(elements,"md.friction.q",FrictionQEnum);
    800                         if(FrictionCoupling==1){
    801                                 iomodel->FetchDataToInput(elements,"md.friction.effective_pressure",FrictionEffectivePressureEnum);
     802                        if(FrictionCoupling==3){
     803                                iomodel->FetchDataToInput(elements,"md.friction.effective_pressure",FrictionEffectivePressureEnum);}
     804                        else if(FrictionCoupling==4){
     805                                iomodel->FetchDataToInput(elements,"md.friction.effective_pressure",EffectivePressureEnum);
    802806                        }
    803807                        break;
    804808                case 4:
     
    826830                        iomodel->FetchDataToInput(elements,"md.friction.coefficientcoulomb",FrictionCoefficientcoulombEnum);
    827831                        iomodel->FetchDataToInput(elements,"md.friction.p",FrictionPEnum);
    828832                        iomodel->FetchDataToInput(elements,"md.friction.q",FrictionQEnum);
    829                         if(FrictionCoupling==1){
    830                                 iomodel->FetchDataToInput(elements,"md.friction.effective_pressure",FrictionEffectivePressureEnum);
     833                        if(FrictionCoupling==3){
     834                                iomodel->FetchDataToInput(elements,"md.friction.effective_pressure",FrictionEffectivePressureEnum);}
     835                        else if(FrictionCoupling==4){
     836                                iomodel->FetchDataToInput(elements,"md.friction.effective_pressure",EffectivePressureEnum);
     837
    831838                        }
    832839                        break;
    833840                case 9:
     
    933940                else if(newton>0)
    934941                 solutionsequence_newton(femmodel);
    935942                else
    936                  solutionsequence_nonlinear(femmodel,conserve_loads); 
     943                 solutionsequence_nonlinear(femmodel,conserve_loads);
    937944        }
    938         else if(!isFS && (isSSA || isHO || isL1L2)){ 
     945        else if(!isFS && (isSSA || isHO || isL1L2)){
    939946                if(VerboseSolution()) _printf0_("   computing velocities\n");
    940947
    941948                femmodel->SetCurrentConfiguration(StressbalanceAnalysisEnum);
     
    942949                if(newton>0)
    943950                 solutionsequence_newton(femmodel);
    944951                else
    945                  solutionsequence_nonlinear(femmodel,conserve_loads); 
     952                 solutionsequence_nonlinear(femmodel,conserve_loads);
    946953
    947954                if(domaintype==Domain2DverticalEnum && isSSA){
    948955                        femmodel->parameters->SetParam(VxEnum,InputToExtrudeEnum);
     
    965972        int approximation;
    966973        element->GetInputValue(&approximation,ApproximationEnum);
    967974        switch(approximation){
    968                 case FSApproximationEnum: 
     975                case FSApproximationEnum:
    969976                        return CreateDVectorFS(element);
    970977                default:
    971978                        return NULL; //no need for doftypes outside of FS approximation
     
    978985        int approximation;
    979986        element->GetInputValue(&approximation,ApproximationEnum);
    980987        switch(approximation){
    981                 case SSAApproximationEnum: 
     988                case SSAApproximationEnum:
    982989                        return CreateJacobianMatrixSSA(element);
    983                 case HOApproximationEnum: 
     990                case HOApproximationEnum:
    984991                        return CreateJacobianMatrixHO(element);
    985                 case FSApproximationEnum: 
     992                case FSApproximationEnum:
    986993                        return CreateJacobianMatrixFS(element);
    987994                case NoneApproximationEnum:
    988995                        return NULL;
     
    9961003        switch(approximation){
    9971004                case SIAApproximationEnum:
    9981005                        return NULL;
    999                 case SSAApproximationEnum: 
     1006                case SSAApproximationEnum:
    10001007                        return CreateKMatrixSSA(element);
    1001                 case L1L2ApproximationEnum: 
     1008                case L1L2ApproximationEnum:
    10021009                        return CreateKMatrixL1L2(element);
    1003                 case HOApproximationEnum: 
     1010                case HOApproximationEnum:
    10041011                        return CreateKMatrixHO(element);
    1005                 case FSApproximationEnum: 
     1012                case FSApproximationEnum:
    10061013                        return CreateKMatrixFS(element);
    1007                 case SSAHOApproximationEnum: 
     1014                case SSAHOApproximationEnum:
    10081015                        return CreateKMatrixSSAHO(element);
    1009                 case HOFSApproximationEnum: 
     1016                case HOFSApproximationEnum:
    10101017                        return CreateKMatrixHOFS(element);
    1011                 case SSAFSApproximationEnum: 
     1018                case SSAFSApproximationEnum:
    10121019                        return CreateKMatrixSSAFS(element);
    10131020                case NoneApproximationEnum:
    10141021                        return NULL;
     
    10231030        switch(approximation){
    10241031                case SIAApproximationEnum:
    10251032                        return NULL;
    1026                 case SSAApproximationEnum: 
     1033                case SSAApproximationEnum:
    10271034                        return CreatePVectorSSA(element);
    1028                 case L1L2ApproximationEnum: 
     1035                case L1L2ApproximationEnum:
    10291036                        return CreatePVectorL1L2(element);
    1030                 case HOApproximationEnum: 
     1037                case HOApproximationEnum:
    10311038                        return CreatePVectorHO(element);
    1032                 case FSApproximationEnum: 
     1039                case FSApproximationEnum:
    10331040                        return CreatePVectorFS(element);
    1034                 case SSAHOApproximationEnum: 
     1041                case SSAHOApproximationEnum:
    10351042                        return CreatePVectorSSAHO(element);
    1036                 case HOFSApproximationEnum: 
     1043                case HOFSApproximationEnum:
    10371044                        return CreatePVectorHOFS(element);
    1038                 case SSAFSApproximationEnum: 
     1045                case SSAFSApproximationEnum:
    10391046                        return CreatePVectorSSAFS(element);
    10401047                case NoneApproximationEnum:
    10411048                        return NULL;
     
    11251132                case FSApproximationEnum: case NoneApproximationEnum:
    11261133                        InputUpdateFromSolutionFS(solution,element);
    11271134                        return;
    1128                 case SIAApproximationEnum: 
     1135                case SIAApproximationEnum:
    11291136                        return;
    1130                 case SSAApproximationEnum: 
     1137                case SSAApproximationEnum:
    11311138                        InputUpdateFromSolutionSSA(solution,element);
    11321139                        return;
    1133                 case HOApproximationEnum: 
     1140                case HOApproximationEnum:
    11341141                        InputUpdateFromSolutionHO(solution,element);
    11351142                        return;
    11361143                case L1L2ApproximationEnum:
     
    15801587
    15811588        /*Retrieve all inputs and parameters*/
    15821589        element->GetVerticesCoordinates(&xyz_list);
    1583         Input*     thickness_input=element->GetInput(ThicknessEnum); _assert_(thickness_input); 
     1590        Input*     thickness_input=element->GetInput(ThicknessEnum); _assert_(thickness_input);
    15841591        Input*     surface_input  =element->GetInput(SurfaceEnum);   _assert_(surface_input);
    15851592        IssmDouble rhog = element->GetMaterialParameter(MaterialsRhoIceEnum)*element->GetMaterialParameter(ConstantsGEnum);
    15861593
     
    16881695        return pe;
    16891696}/*}}}*/
    16901697void           StressbalanceAnalysis::GetBSSA(IssmDouble* B,Element* element,int dim,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/
    1691         /*Compute B  matrix. B=[B1 B2 B3] where Bi is of size 3*NDOF2. 
     1698        /*Compute B  matrix. B=[B1 B2 B3] where Bi is of size 3*NDOF2.
    16921699         * For node i, Bi can be expressed in the actual coordinate system
    1693          * by: 
     1700         * by:
    16941701         *                   2D                      1D
    16951702         *       Bi=[ dN/dx           0    ]   Bi=[ dN/dx ]
    1696          *          [   0           dN/dy  ]     
    1697          *          [ 1/2*dN/dy  1/2*dN/dx ]     
     1703         *          [   0           dN/dy  ]
     1704         *          [ 1/2*dN/dy  1/2*dN/dx ]
    16981705         * where N is the finiteelement function for node i.
    16991706         *
    17001707         * We assume B has been allocated already, of size: 3x(NDOF2*numnodes)
     
    17281735        xDelete<IssmDouble>(dbasis);
    17291736}/*}}}*/
    17301737void           StressbalanceAnalysis::GetBSSAFriction(IssmDouble* B,Element* element,int dim,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/
    1731         /*Compute B  matrix. B=[B1 B2 B3] where Bi is square and of size 2. 
     1738        /*Compute B  matrix. B=[B1 B2 B3] where Bi is square and of size 2.
    17321739         * For node i, Bi can be expressed in the actual coordinate system
    1733          * by: 
     1740         * by:
    17341741         *                       2D             1D
    17351742         *                 Bi=[ N   0 ]    Bi = N
    17361743         *                    [ 0   N ]
     
    17651772        xDelete<IssmDouble>(basis);
    17661773}/*}}}*/
    17671774void           StressbalanceAnalysis::GetBSSAprime(IssmDouble* Bprime,Element* element,int dim,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/
    1768         /*Compute B'  matrix. B'=[B1' B2' B3'] where Bi' is of size 3*NDOF2. 
     1775        /*Compute B'  matrix. B'=[B1' B2' B3'] where Bi' is of size 3*NDOF2.
    17691776         * For node i, Bi' can be expressed in the actual coordinate system
    1770          * by: 
     1777         * by:
    17711778         *                         2D                        1D
    17721779         *       Bi_prime=[ 2*dN/dx    dN/dy ]     Bi_prime=[ 2*dN/dx ]
    17731780         *                [   dN/dx  2*dN/dy ]
     
    20492056
    20502057        /*Retrieve all inputs and parameters*/
    20512058        element->GetVerticesCoordinates(&xyz_list);
    2052         Input*     thickness_input=element->GetInput(ThicknessEnum); _assert_(thickness_input); 
     2059        Input*     thickness_input=element->GetInput(ThicknessEnum); _assert_(thickness_input);
    20532060        Input*     surface_input  =element->GetInput(SurfaceEnum);   _assert_(surface_input);
    20542061        IssmDouble rhog = element->GetMaterialParameter(MaterialsRhoIceEnum)*element->GetMaterialParameter(ConstantsGEnum);
    20552062
     
    26762683        return pe;
    26772684}/*}}}*/
    26782685void           StressbalanceAnalysis::GetBHO(IssmDouble* B,Element* element,int dim,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/
    2679         /*Compute B  matrix. B=[B1 B2 B3 B4 B5 B6] where Bi is of size 5*NDOF2. 
     2686        /*Compute B  matrix. B=[B1 B2 B3 B4 B5 B6] where Bi is of size 5*NDOF2.
    26802687         * For node i, Bi can be expressed in the actual coordinate system
    2681          * by: 
     2688         * by:
    26822689         *                   3D                        2D
    26832690         *
    26842691         *       Bi=[ dh/dx          0      ]  Bi=[ dh/dx]
    26852692         *          [   0           dh/dy   ]     [ dh/dy]
    2686          *          [ 1/2*dh/dy  1/2*dh/dx  ]     
    2687          *          [ 1/2*dh/dz      0      ]   
    2688          *          [  0         1/2*dh/dz  ]   
     2693         *          [ 1/2*dh/dy  1/2*dh/dx  ]
     2694         *          [ 1/2*dh/dz      0      ]
     2695         *          [  0         1/2*dh/dz  ]
    26892696         * where h is the interpolation function for node i.
    26902697         *
    26912698         * We assume B has been allocated already, of size: 5x(NDOF2*numnodes)
     
    27252732        xDelete<IssmDouble>(dbasis);
    27262733}/*}}}*/
    27272734void           StressbalanceAnalysis::GetBHOFriction(IssmDouble* B,Element* element,int dim,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/
    2728         /*Compute B  matrix. B=[B1 B2 B3] where Bi is square and of size 2. 
     2735        /*Compute B  matrix. B=[B1 B2 B3] where Bi is square and of size 2.
    27292736         * For node i, Bi can be expressed in the actual coordinate system
    2730          * by: 
     2737         * by:
    27312738         *                       3D           2D
    27322739         *                 Bi=[ N   0 ]    Bi=N
    27332740         *                    [ 0   N ]
     
    27622769        xDelete<IssmDouble>(basis);
    27632770}/*}}}*/
    27642771void           StressbalanceAnalysis::GetBHOprime(IssmDouble* Bprime,Element* element,int dim,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/
    2765         /*Compute B'  matrix. B'=[B1' B2' B3'] where Bi' is of size 3*NDOF2. 
     2772        /*Compute B'  matrix. B'=[B1' B2' B3'] where Bi' is of size 3*NDOF2.
    27662773         * For node i, Bi' can be expressed in the actual coordinate system
    2767          * by: 
     2774         * by:
    27682775         *                          3D                      2D
    27692776         *       Bi_prime=[ 2*dN/dx    dN/dy ] Bi_prime=[ 2*dN/dx ]
    27702777         *                [   dN/dx  2*dN/dy ]          [   dN/dy ]
    2771          *                [   dN/dy    dN/dx ] 
     2778         *                [   dN/dy    dN/dx ]
    27722779         * where hNis the finiteelement function for node i.
    27732780         *
    27742781         * We assume B' has been allocated already, of size: 3x(NDOF2*numnodes)
     
    30833090                element->JacobianDeterminantBase(&Jdet,xyz_list_base,gauss);
    30843091                if(dim==2) slope2=slope[0]*slope[0];
    30853092                else if(dim==3) slope2=slope[0]*slope[0]+slope[1]*slope[1];
    3086                 scalar  = rho_water*gravity*sqrt(1+slope2)*gauss->weight*Jdet*dt; 
     3093                scalar  = rho_water*gravity*sqrt(1+slope2)*gauss->weight*Jdet*dt;
    30873094                for(i=0;i<vnumnodes;i++){
    30883095                        for(j=0;j<vnumnodes;j++){
    30893096                                Ke->values[numdof*((i+1)*dim-1)+(j+1)*dim-1] += scalar*vbasis[i]*vbasis[j];
     
    32853292                                BtBUzawa,pnumdof,numdof,0,
    32863293                                &Ke->values[0],1);
    32873294
    3288         if(element->IsOnBase() && 0){ 
     3295        if(element->IsOnBase() && 0){
    32893296                element->FindParam(&rl,AugmentedLagrangianRlambdaEnum);
    32903297                element->GetVerticesCoordinatesBase(&xyz_list_base);
    32913298                element->NormalBase(&normal[0],xyz_list_base);
     
    40844091        for(int ig=gauss->begin();ig<gauss->end();ig++){
    40854092                gauss->GaussPoint(ig);
    40864093                element->JacobianDeterminant(&Jdet,xyz_list,gauss);
    4087                
     4094
    40884095                pressure_input->GetInputValue(&pressure, gauss);
    40894096                element->NodalFunctionsDerivativesVelocity(dbasis,xyz_list,gauss);
    40904097
     
    40954102                }
    40964103        }
    40974104
    4098         if(element->IsOnBase() && 0){ 
     4105        if(element->IsOnBase() && 0){
    40994106                IssmDouble   sigmann;
    41004107                IssmDouble*  vbasis = xNew<IssmDouble>(numnodes);
    41014108
     
    43044311        return pe;
    43054312}/*}}}*/
    43064313void           StressbalanceAnalysis::GetBFS(IssmDouble* B,Element* element,int dim,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/
    4307         /*Compute B  matrix. B=[Bv1 Bv2 ... Bp1 Bp2 ...] where Bvi is of size 3*NDOF3. 
     4314        /*Compute B  matrix. B=[Bv1 Bv2 ... Bp1 Bp2 ...] where Bvi is of size 3*NDOF3.
    43084315         * For node i, Bvi can be expressed in the actual coordinate system
    43094316         * by:     Bvi=[ dphi/dx          0        ]
    43104317         *                                       [   0           dphi/dy     ]
     
    44164423        xDelete<IssmDouble>(pbasis);
    44174424}/*}}}*/
    44184425void           StressbalanceAnalysis::GetBFSFriction(IssmDouble* B,Element* element,int dim,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/
    4419         /* Compute L  matrix. L=[L1 L2 L3] where Li is square and of size numdof. 
     4426        /* Compute L  matrix. L=[L1 L2 L3] where Li is square and of size numdof.
    44204427         * For node i, Li can be expressed in the actual coordinate system
    4421          * by in 3d 
     4428         * by in 3d
    44224429         *       Li=[ h 0 0 0 ]
    44234430         *                    [ 0 h 0 0 ]
    44244431         *      in 2d:
     
    44764483        xDelete<IssmDouble>(vbasis);
    44774484}/*}}}*/
    44784485void           StressbalanceAnalysis::GetBFSprime(IssmDouble* Bprime,Element* element,int dim,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/
    4479         /*      Compute B'  matrix. B'=[B1' B2' B3' B4' B5' B6' Bb'] where Bi' is of size 3*NDOF2. 
     4486        /*      Compute B'  matrix. B'=[B1' B2' B3' B4' B5' B6' Bb'] where Bi' is of size 3*NDOF2.
    44804487         *      For node i, Bi' can be expressed in the actual coordinate system
    4481          *      by: 
     4488         *      by:
    44824489         *                      Bvi' = [  dphi/dx     0     ]
    44834490         *                                       [     0      dphi/dy ]
    44844491         *                                       [  dphi/dy   dphi/dx ]
     
    45894596        xDelete<IssmDouble>(pbasis);
    45904597}/*}}}*/
    45914598void           StressbalanceAnalysis::GetBFSprimeUzawa(IssmDouble* Bprime,Element* element,int dim,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/
    4592         /*      Compute B'  matrix. B'=[B1' B2' B3' B4' B5' B6'] where Bi' is of size 3*NDOF2. 
     4599        /*      Compute B'  matrix. B'=[B1' B2' B3' B4' B5' B6'] where Bi' is of size 3*NDOF2.
    45934600         *      For node i, Bi' can be expressed in the actual coordinate system
    4594          *      by: 
     4601         *      by:
    45954602         *                      Bvi' = [  dphi/dx   dphi/dy ]
    45964603         *
    45974604         *      In 3d
     
    46254632        xDelete<IssmDouble>(vdbasis);
    46264633}/*}}}*/
    46274634void           StressbalanceAnalysis::GetBFSprimevel(IssmDouble* Bprime,Element* element,int dim,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/
    4628         /*      Compute B'  matrix. B'=[B1' B2' B3' B4' B5' B6' Bb'] where Bi' is of size 3*NDOF2. 
     4635        /*      Compute B'  matrix. B'=[B1' B2' B3' B4' B5' B6' Bb'] where Bi' is of size 3*NDOF2.
    46294636         *      For node i, Bi' can be expressed in the actual coordinate system
    4630          *      by: 
     4637         *      by:
    46314638         *                      Bvi' = [  dphi/dx     0     ]
    46324639         *                                       [     0      dphi/dy ]
    46334640         *                                       [  dphi/dy   dphi/dx ]
     
    46884695        xDelete<IssmDouble>(vdbasis);
    46894696}/*}}}*/
    46904697void           StressbalanceAnalysis::GetBFSUzawa(IssmDouble* B,Element* element,int dim,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/
    4691         /*Compute B  matrix. B=[Bp1 Bp2 ...] where Bpi=phi_pi. 
     4698        /*Compute B  matrix. B=[Bp1 Bp2 ...] where Bpi=phi_pi.
    46924699         */
    46934700
    46944701        /*Fetch number of nodes for this finite element*/
     
    47104717        xDelete<IssmDouble>(basis);
    47114718}/*}}}*/
    47124719void           StressbalanceAnalysis::GetBFSvel(IssmDouble* B,Element* element,int dim,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/
    4713         /*Compute B  matrix. B=[Bv1 Bv2 ... Bp1 Bp2 ...] where Bvi is of size 3*NDOF3. 
     4720        /*Compute B  matrix. B=[Bv1 Bv2 ... Bp1 Bp2 ...] where Bvi is of size 3*NDOF3.
    47144721         * For node i, Bvi can be expressed in the actual coordinate system
    47154722         * by:     Bvi=[ dphi/dx          0        ]
    47164723         *                                       [   0           dphi/dy     ]
     
    47754782}/*}}}*/
    47764783void           StressbalanceAnalysis::GetCFS(IssmDouble* C,Element* element,int dim,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/
    47774784        /*Compute C  matrix. C=[Cp1 Cp2 ...] where:
    4778          *     Cpi=[phi phi]. 
     4785         *     Cpi=[phi phi].
    47794786         */
    47804787
    47814788        /*Fetch number of nodes for this finite element*/
     
    47954802        xDelete<IssmDouble>(basis);
    47964803}/*}}}*/
    47974804void           StressbalanceAnalysis::GetCFSprime(IssmDouble* Cprime,Element* element,int dim,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/
    4798         /*      Compute C'  matrix. C'=[C1' C2' ...] 
     4805        /*      Compute C'  matrix. C'=[C1' C2' ...]
    47994806         *                      Ci' = [  phi  0  ]
    48004807         *                            [   0  phi ]
    48014808         *
     
    49294936                /*Allocate new inputs*/
    49304937                int tnumnodes = element->GetNumberOfVertices();      //Tensors, P1 DG
    49314938                IssmDouble* epsxx = xNew<IssmDouble>(tnumnodes); IssmDouble* sigmapxx = xNew<IssmDouble>(tnumnodes);
    4932                 IssmDouble* epsyy = xNew<IssmDouble>(tnumnodes); IssmDouble* sigmapyy = xNew<IssmDouble>(tnumnodes); 
    4933                 IssmDouble* epsxy = xNew<IssmDouble>(tnumnodes); IssmDouble* sigmapxy = xNew<IssmDouble>(tnumnodes); 
    4934                 IssmDouble* epszz = NULL;                        IssmDouble* sigmapzz = NULL; 
    4935                 IssmDouble* epsxz = NULL;                        IssmDouble* sigmapxz = NULL; 
    4936                 IssmDouble* epsyz = NULL;                        IssmDouble* sigmapyz = NULL; 
     4939                IssmDouble* epsyy = xNew<IssmDouble>(tnumnodes); IssmDouble* sigmapyy = xNew<IssmDouble>(tnumnodes);
     4940                IssmDouble* epsxy = xNew<IssmDouble>(tnumnodes); IssmDouble* sigmapxy = xNew<IssmDouble>(tnumnodes);
     4941                IssmDouble* epszz = NULL;                        IssmDouble* sigmapzz = NULL;
     4942                IssmDouble* epsxz = NULL;                        IssmDouble* sigmapxz = NULL;
     4943                IssmDouble* epsyz = NULL;                        IssmDouble* sigmapyz = NULL;
    49374944                if(dim==3){
    49384945                        epszz = xNew<IssmDouble>(tnumnodes); sigmapzz = xNew<IssmDouble>(tnumnodes);
    4939                         epsxz = xNew<IssmDouble>(tnumnodes); sigmapxz = xNew<IssmDouble>(tnumnodes); 
    4940                         epsyz = xNew<IssmDouble>(tnumnodes); sigmapyz = xNew<IssmDouble>(tnumnodes); 
     4946                        epsxz = xNew<IssmDouble>(tnumnodes); sigmapxz = xNew<IssmDouble>(tnumnodes);
     4947                        epsyz = xNew<IssmDouble>(tnumnodes); sigmapyz = xNew<IssmDouble>(tnumnodes);
    49414948                }
    49424949
    49434950                /*Get d and tau*/
     
    51715178                        }
    51725179                        epsxx = dvx[0];
    51735180                        epsyy = dvy[1];
    5174                         epsxy = 0.5*(dvx[1] + dvy[0]); 
     5181                        epsxy = 0.5*(dvx[1] + dvy[0]);
    51755182                        if(dim==3){
    5176                                 epszz = dvz[2];               
     5183                                epszz = dvz[2];
    51775184                                epsxz = 0.5*(dvx[2] + dvz[0]);
    51785185                                epsyz = 0.5*(dvy[2] + dvz[1]);
    51795186                        }
     
    51825189                        IssmDouble coef1,coef2,coef3;
    51835190                        B_input->GetInputValue(&B,gauss);
    51845191                        n_input->GetInputValue(&n,gauss);
    5185                         coef1 = B*pow(1./sqrt(2.),(1.-n)/n); //2 eta_0 = 2 * B/(2* (1/sqrt(2)  )^(n-1)/n ) 
     5192                        coef1 = B*pow(1./sqrt(2.),(1.-n)/n); //2 eta_0 = 2 * B/(2* (1/sqrt(2)  )^(n-1)/n )
    51865193                        coef2 = r;
    51875194                        if(dim==2){
    51885195                                coef3 = sqrt(
     
    52065213                                dnorm = sqrt( epsxx_old*epsxx_old + epsyy_old*epsyy_old + 2.*epsxy_old*epsxy_old );
    52075214                        }
    52085215                        else{
    5209                                 dnorm = sqrt( epsxx_old*epsxx_old + epsyy_old*epsyy_old + epszz_old*epszz_old 
     5216                                dnorm = sqrt( epsxx_old*epsxx_old + epsyy_old*epsyy_old + epszz_old*epszz_old
    52105217                                                        +2.*(epsxy_old*epsxy_old + epsxz_old*epsxz_old + epsyz_old*epsyz_old));
    52115218                        }
    52125219                        /*Initial guess cannot be 0 otherwise log(0)  - inf*/
     
    53595366                        }
    53605367                        epsxx = dvx[0];
    53615368                        epsyy = dvy[1];
    5362                         epsxy = 0.5*(dvx[1] + dvy[0]); 
     5369                        epsxy = 0.5*(dvx[1] + dvy[0]);
    53635370                        if(dim==3){
    5364                                 epszz = dvz[2]; 
     5371                                epszz = dvz[2];
    53655372                                epsxz = 0.5*(dvx[2] + dvz[0]);
    53665373                                epsyz = 0.5*(dvy[2] + dvz[1]);
    53675374                        }
     
    56135620
    56145621        for(i=0;i<numdof2dm;i++) for(j=0;j<numdofs;j++) Ke->values[i*numdoftot+j+numdofm]+=Ke_drag[i][j];
    56155622        for(i=0;i<numdof2d;i++) for(j=0;j<numdof2dm;j++) Ke->values[(i+numdofm)*numdoftot+j]+=Ke_drag2[i][j];
    5616                
     5623
    56175624        /*Transform Coordinate System*/
    56185625        element->TransformStiffnessMatrixCoord(Ke,node_list,numnodes,cs_list);
    56195626
     
    56465653        IssmDouble Bprime2[3][numdofs];
    56475654        IssmDouble D[4][4]={0.0};            // material matrix, simple scalar matrix.
    56485655        IssmDouble D2[3][3]={0.0};            // material matrix, simple scalar matrix.
    5649         IssmDouble Ke_gg[numdofs][numdofm]={0.0}; //local element stiffness matrix 
    5650         IssmDouble Ke_gg2[numdofm][numdofs]={0.0}; //local element stiffness matrix 
     5656        IssmDouble Ke_gg[numdofs][numdofm]={0.0}; //local element stiffness matrix
     5657        IssmDouble Ke_gg2[numdofm][numdofs]={0.0}; //local element stiffness matrix
    56515658        IssmDouble *xyz_list    = NULL;
    56525659
    56535660        /*Find penta on bed as FS must be coupled to the dofs on the bed: */
     
    57185725                                        &Bprime2[0][0],3,numdofs,0,
    57195726                                        &Ke_gg2[0][0],1);
    57205727
    5721         } 
     5728        }
    57225729        for(i=0;i<numdofs;i++) for(j=0;j<numdofm;j++) Ke->values[(i+2*numdofm)*numdoftotal+j]+=Ke_gg[i][j];
    57235730        for(i=0;i<numdofm;i++) for(j=0;j<numdofs;j++) Ke->values[i*numdoftotal+(j+2*numdofm)]+=Ke_gg2[i][j];
    57245731
     
    58025809                this->GetBHOFriction(L,element,3,xyz_list_tria,gauss);
    58035810
    58045811                DL_scalar=alpha2*gauss->weight*Jdet2d;
    5805                 for (i=0;i<2;i++) DL[i][i]=DL_scalar; 
     5812                for (i=0;i<2;i++) DL[i][i]=DL_scalar;
    58065813
    58075814                /*  Do the triple producte tL*D*L: */
    58085815                TripleMultiply( L,2,numdof,1,
     
    58835890
    58845891                element->JacobianDeterminant(&Jdet, xyz_list,gauss);
    58855892                this->GetBSSAHO(B, element,xyz_list, gauss);
    5886                 this->GetBSSAprime(Bprime,basaltria,2,xyz_list, gauss_tria); 
     5893                this->GetBSSAprime(Bprime,basaltria,2,xyz_list, gauss_tria);
    58875894                element->material->ViscosityHO(&viscosity,3,xyz_list,gauss,vx_input,vy_input);
    58885895
    58895896                D_scalar=2*viscosity*gauss->weight*Jdet;
     
    58935900                                        &D[0][0],3,3,0,
    58945901                                        Bprime,3,numdofm,0,
    58955902                                        Ke_gg,1);
    5896         } 
     5903        }
    58975904        for(i=0;i<numdofp;i++) for(j=0;j<numdofm;j++) Ke->values[(i+2*numdofm)*numdoftotal+j]+=Ke_gg[i*numdofm+j];
    58985905        for(i=0;i<numdofm;i++) for(j=0;j<numdofp;j++) Ke->values[i*numdoftotal+(j+2*numdofm)]+=Ke_gg[j*numdofm+i];
    58995906
     
    59025909
    59035910        /*Clean-up and return*/
    59045911        basaltria->DeleteMaterials(); delete basaltria;
    5905        
     5912
    59065913        delete gauss;
    59075914        delete gauss_tria;
    59085915        xDelete<IssmDouble>(B);
     
    59405947        int indices[3]={18,19,20};
    59415948        Ke1->StaticCondensation(3,&indices[0]);
    59425949        int init = element->FiniteElement();
    5943         element->SetTemporaryElementType(P1Enum); 
     5950        element->SetTemporaryElementType(P1Enum);
    59445951        ElementMatrix* Ke2=CreateKMatrixSSA3d(element);
    5945         element->SetTemporaryElementType(init); 
     5952        element->SetTemporaryElementType(init);
    59465953        ElementMatrix* Ke3=CreateKMatrixCouplingSSAFS(element);
    59475954        ElementMatrix* Ke =new ElementMatrix(Ke1,Ke2,Ke3);
    59485955
     
    59865993        /*Initialize Element matrix and return if necessary*/
    59875994        if(element->IsFloating() || !element->IsOnBase()) return NULL;
    59885995
    5989         /*Build a tria element using the 3 nodes of the base of the penta. Then use 
     5996        /*Build a tria element using the 3 nodes of the base of the penta. Then use
    59905997         * the tria functionality to build a friction stiffness matrix on these 3
    59915998         * nodes: */
    59925999        Element* basalelement = element->SpawnBasalElement();
     
    62226229                element->JacobianDeterminant(&Jdet, xyz_list,gauss);
    62236230                element->NodalFunctionsP1(&basis[0],gauss);
    62246231                element->NodalFunctionsP1Derivatives(&dbasis[0][0],xyz_list,gauss);
    6225                
     6232
    62266233                element->material->ViscosityFS(&viscosity,dim,xyz_list,gauss,vx_input,vy_input,vz_input);
    62276234                vzHO_input->GetInputDerivativeValue(&dw[0],xyz_list,gauss);
    62286235
     
    64686475        return pe;
    64696476}/*}}}*/
    64706477void           StressbalanceAnalysis::GetBprimeSSAFS(IssmDouble* Bprime,Element* element,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/
    6471         /*Compute Bprime  matrix. Bprime=[Bprime1 Bprime2 Bprime3 Bprime4 Bprime5 Bprime6] where Bprimei is of size 5*NDOF2. 
     6478        /*Compute Bprime  matrix. Bprime=[Bprime1 Bprime2 Bprime3 Bprime4 Bprime5 Bprime6] where Bprimei is of size 5*NDOF2.
    64726479         * For node i, Bprimei can be expressed in the actual coordinate system
    6473          * by: 
     6480         * by:
    64746481         *       Bprimei=[ 2*dh/dx    dh/dy   0   0 ]
    64756482         *               [  dh/dx    2*dh/dy  0   0 ]
    64766483         *               [  dh/dy     dh/dx   0   0 ]
     
    65176524        }
    65186525}/*}}}*/
    65196526void           StressbalanceAnalysis::GetBprimeSSAFSTria(IssmDouble* Bprime,Element* element,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/
    6520         /*Compute Bprime  matrix. Bprime=[Bprime1 Bprime2 Bprime3] where Bprimei is of size 3*NDOF2. 
     6527        /*Compute Bprime  matrix. Bprime=[Bprime1 Bprime2 Bprime3] where Bprimei is of size 3*NDOF2.
    65216528         * For node i, Bprimei can be expressed in the actual coordinate system
    6522          * by: 
     6529         * by:
    65236530         *       Bprimei=[  dN/dx    0   ]
    65246531         *               [    0    dN/dy ]
    65256532         *               [  dN/dy  dN/dx ]
     
    65526559        xDelete<IssmDouble>(dbasis);
    65536560}/*}}}*/
    65546561void           StressbalanceAnalysis::GetBSSAFS(IssmDouble* B,Element* element,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/
    6555         /*Compute B  matrix. B=[B1 B2 B3 B4 B5 B6] where Bi is of size 5*NDOF2. 
     6562        /*Compute B  matrix. B=[B1 B2 B3 B4 B5 B6] where Bi is of size 5*NDOF2.
    65566563         * For node i, Bi can be expressed in the actual coordinate system
    6557          * by: 
     6564         * by:
    65586565         *       Bi=[ dh/dx          0       0   0 ]
    65596566         *          [   0           dh/dy    0   0 ]
    65606567         *          [ 1/2*dh/dy  1/2*dh/dx   0   0 ]
     
    66106617        }
    66116618}/*}}}*/
    66126619void           StressbalanceAnalysis::GetBSSAFSTria(IssmDouble* B,Element* element,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/
    6613         /*Compute B  matrix. B=[B1 B2 B3] where Bi is of size 3*NDOF2. 
     6620        /*Compute B  matrix. B=[B1 B2 B3] where Bi is of size 3*NDOF2.
    66146621         * For node i, Bi can be expressed in the actual coordinate system
    6615          * by: 
     6622         * by:
    66166623         *       Bi=[   dN/dx         0     ]
    66176624         *          [       0       dN/dy   ]
    66186625         *          [  1/2*dN/dy  1/2*dN/dx ]
     
    66426649        xDelete<IssmDouble>(dbasis);
    66436650}/*}}}*/
    66446651void           StressbalanceAnalysis::GetBSSAHO(IssmDouble* B,Element* element,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/
    6645         /*Compute B  matrix. B=[B1 B2 B3 B4 B5 B6] where Bi is of size 3*NDOF2. 
     6652        /*Compute B  matrix. B=[B1 B2 B3 B4 B5 B6] where Bi is of size 3*NDOF2.
    66466653         * For node i, Bi can be expressed in the actual coordinate system
    6647          * by: 
     6654         * by:
    66486655         *       Bi=[ dh/dx          0      ]
    66496656         *          [   0           dh/dy   ]
    66506657         *          [ 1/2*dh/dy  1/2*dh/dx  ]
     
    66736680        xDelete<IssmDouble>(dbasis);
    66746681}/*}}}*/
    66756682void           StressbalanceAnalysis::GetLprimeFSSSA(IssmDouble* LprimeFS,Element* element,IssmDouble* xyz_list,Gauss* gauss_in){/*{{{*/
    6676         /* Compute Lprime  matrix. Lprime=[Lp1 Lp2 Lp3] where Lpi is square and of size numdof. 
     6683        /* Compute Lprime  matrix. Lprime=[Lp1 Lp2 Lp3] where Lpi is square and of size numdof.
    66776684         * For node i, Lpi can be expressed in the actual coordinate system
    6678          * by: 
     6685         * by:
    66796686         *       Lpi=[ h    0 ]
    66806687         *                     [ 0    h ]
    66816688         *                     [ h    0 ]
     
    67076714        }
    67086715}/*}}}*/
    67096716void           StressbalanceAnalysis::GetLprimeSSAFS(IssmDouble* LprimeFS,Element* element,IssmDouble* xyz_list,Gauss* gauss_in){/*{{{*/
    6710         /* Compute Lprime  matrix. Lprime=[Lp1 Lp2 Lp3] where Lpi is square and of size numdof. 
     6717        /* Compute Lprime  matrix. Lprime=[Lp1 Lp2 Lp3] where Lpi is square and of size numdof.
    67116718         * For node i, Lpi can be expressed in the actual coordinate system
    6712          * by: 
     6719         * by:
    67136720         *       Lpi=[ h    0    0   0]
    67146721         *                     [ 0    h    0   0]
    67156722         *                     [ 0    0    h   0]
     
    68126819        }
    68136820}/*}}}*/
    68146821void           StressbalanceAnalysis::GetLFSSSA(IssmDouble* LFS,Element* element,Gauss* gauss_in){/*{{{*/
    6815         /* Compute L  matrix. L=[L1 L2 L3] where Li is square and of size numdof. 
     6822        /* Compute L  matrix. L=[L1 L2 L3] where Li is square and of size numdof.
    68166823         * For node i, Li can be expressed in the actual coordinate system
    6817          * by: 
     6824         * by:
    68186825         *       Li=[ h    0    0 ]
    68196826         *                    [ 0    h    0 ]
    68206827         *                    [ 0    0    h ]
     
    68526859}/*}}}*/
    68536860void           StressbalanceAnalysis::GetLSSAFS(IssmDouble* LFS,Element* element,Gauss* gauss_in){/*{{{*/
    68546861        /*
    6855          * Compute L  matrix. L=[L1 L2 L3] where Li is square and of size numdof. 
     6862         * Compute L  matrix. L=[L1 L2 L3] where Li is square and of size numdof.
    68566863         * For node i, Li can be expressed in the actual coordinate system
    6857          * by: 
     6864         * by:
    68586865         *       Li=[ h    0 ]
    68596866         *                    [ 0    h ]
    68606867         *                    [ h    0 ]
     
    71577164        element->GetInputListOnNodes(&vz[0],VzEnum,0.);
    71587165        for(i=0;i<numnodes;i++) vel[i]=sqrt(vx[i]*vx[i] + vy[i]*vy[i] + vz[i]*vz[i]);
    71597166
    7160         /*For pressure: we have not computed pressure in this analysis, for this element. We are in 2D, 
     7167        /*For pressure: we have not computed pressure in this analysis, for this element. We are in 2D,
    71617168         *so the pressure is just the pressure at the bedrock: */
    71627169        rho_ice = element->GetMaterialParameter(MaterialsRhoIceEnum);
    71637170        g       = element->GetMaterialParameter(ConstantsGEnum);
Note: See TracBrowser for help on using the repository browser.