Changeset 5590


Ignore:
Timestamp:
08/26/10 09:46:56 (15 years ago)
Author:
seroussi
Message:

keep cleaning stokes

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

Legend:

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

    r5589 r5590  
    489489        /*Parameters*/
    490490        double rho_ice,gravity;
    491         double surface_normal[3];
    492491        double bed_normal[3];
    493492        double bed;
     
    596595
    597596                        /*Get normal vector to the bed */
    598                         SurfaceNormal(&surface_normal[0],xyz_list_tria);
    599                         bed_normal[0] = - surface_normal[0]; //Program is for surface, so the normal to the bed is the opposite of the result
    600                         bed_normal[1] = - surface_normal[1];
    601                         bed_normal[2] = - surface_normal[2];
     597                        BedNormal(&bed_normal[0],xyz_list_tria);
    602598
    603599                        /*basalforce*/
     
    22852281
    22862282/*Penta specific routines: */
     2283/*FUNCTION Penta::BedNormal {{{1*/
     2284void Penta::BedNormal(double* bed_normal, double xyz_list[3][3]){
     2285
     2286        int i;
     2287        double v13[3];
     2288        double v23[3];
     2289        double normal[3];
     2290        double normal_norm;
     2291
     2292        for (i=0;i<3;i++){
     2293                v13[i]=xyz_list[0][i]-xyz_list[2][i];
     2294                v23[i]=xyz_list[1][i]-xyz_list[2][i];
     2295        }
     2296
     2297        normal[0]=v13[1]*v23[2]-v13[2]*v23[1];
     2298        normal[1]=v13[2]*v23[0]-v13[0]*v23[2];
     2299        normal[2]=v13[0]*v23[1]-v13[1]*v23[0];
     2300
     2301        normal_norm=sqrt( pow(normal[0],2)+pow(normal[1],2)+pow(normal[2],2) );
     2302
     2303        /*Bed normal is opposite to surface normal*/
     2304        *(bed_normal)=-normal[0]/normal_norm;
     2305        *(bed_normal+1)=-normal[1]/normal_norm;
     2306        *(bed_normal+2)=-normal[2]/normal_norm;
     2307
     2308}
     2309/*}}}*/
    22872310/*FUNCTION Penta::CreateKMatrixBalancedthickness {{{1*/
    22882311void  Penta::CreateKMatrixBalancedthickness(Mat Kgg){
     
    29132936        double     xyz_list[numgrids][3];
    29142937        double    xyz_list_tria[numgrids2d][3];
    2915         double    surface_normal[3];
    29162938        double    bed_normal[3];
    29172939
     
    29292951        double     D[8][8]={0.0};
    29302952        double     D_scalar;
    2931         double     tBD[27][8];
    29322953        double     DLStokes[14][14]={0.0};
    2933         double     tLDStokes[numdof2d][14];
    29342954
    29352955        /* gaussian points: */
     
    30413061
    30423062                        /*  Do the triple product tB*D*Bprime: */
    3043                         MatrixMultiply(&B[0][0],8,27,1,&D[0][0],8,8,0,&tBD[0][0],0);
    3044                         MatrixMultiply(&tBD[0][0],27,8,0,&B_prime[0][0],8,27,0,&Ke_gaussian[0][0],0);
     3063                        TripleMultiply( &B[0][0],8,27,1,
     3064                                                &D[0][0],8,8,0,
     3065                                                &B_prime[0][0],8,27,0,
     3066                                                &Ke_gaussian[0][0],0);
    30453067
    30463068                        /*Add Ke_gaussian and Ke_gaussian to terms in pKe. Watch out for column orientation from matlab: */
     
    30933115
    30943116                        /*Get normal vecyor to the bed */
    3095                         SurfaceNormal(&surface_normal[0],xyz_list_tria);
    3096 
    3097                         bed_normal[0]=-surface_normal[0]; //Program is for surface, so the normal to the bed is the opposite of the result
    3098                         bed_normal[1]=-surface_normal[1];
    3099                         bed_normal[2]=-surface_normal[2];
     3117                        BedNormal(&bed_normal[0],xyz_list_tria);
    31003118
    31013119                        /*Calculate DL on gauss point */
     
    31183136
    31193137                        /*  Do the triple product tL*D*L: */
    3120                         MatrixMultiply(&LStokes[0][0],14,numdof2d,1,&DLStokes[0][0],14,14,0,&tLDStokes[0][0],0);
    3121                         MatrixMultiply(&tLDStokes[0][0],numdof2d,14,0,&LprimeStokes[0][0],14,numdof2d,0,&Ke_drag_gaussian[0][0],0);
     3138                        TripleMultiply( &LStokes[0][0],14,numdof2d,1,
     3139                                                &DLStokes[0][0],14,14,0,
     3140                                                &LprimeStokes[0][0],14,numdof2d,0,
     3141                                                &Ke_drag_gaussian[0][0],0);
    31223142
    31233143                        for(i=0;i<numdof2d;i++){
     
    40834103        double             xyz_list_tria[numgrids2d][3];
    40844104        double         xyz_list[numgrids][3];
    4085         double             surface_normal[3];
    40864105        double             bed_normal[3];
    40874106        double         bed;
     
    41254144        double     D_scalar;
    41264145        double     tBD[27][8];
    4127         double     P_terms[numdof]={0.0};
    41284146
    41294147        Tria*            tria=NULL;
     
    42844302
    42854303                        /*Get normal vecyor to the bed */
    4286                         SurfaceNormal(&surface_normal[0],xyz_list_tria);
    4287 
    4288                         bed_normal[0]=-surface_normal[0]; //Program is for surface, so the normal to the bed is the opposite of the result
    4289                         bed_normal[1]=-surface_normal[1];
    4290                         bed_normal[2]=-surface_normal[2];
     4304                        BedNormal(&bed_normal[0],xyz_list_tria);
    42914305
    42924306                        for(i=0;i<numgrids2d;i++){
     
    43014315        ReduceVectorStokes(&Pe_reduced[0], &Ke_temp[0][0], &Pe_temp[0]);
    43024316
    4303         for(i=0;i<numdof;i++){
    4304                 P_terms[i]+=Pe_reduced[i];
    4305         }
    4306 
    4307         /*Add P_terms to global vector pg: */
    4308         VecSetValues(pg,numdof,doflist,(const double*)P_terms,ADD_VALUES);
     4317        /*Add Pe_reduced to global vector pg: */
     4318        VecSetValues(pg,numdof,doflist,(const double*)Pe_reduced,ADD_VALUES);
    43094319
    43104320        /*Free ressources:*/
  • issm/trunk/src/c/objects/Elements/Penta.h

    r5578 r5590  
    123123                /*}}}*/
    124124                /*Penta specific routines:{{{1*/
     125                void      BedNormal(double* bed_normal, double xyz_list[3][3]);
    125126                void      CreateKMatrixBalancedthickness(Mat Kggg);
    126127                void      CreateKMatrixBalancedvelocities(Mat Kggg);
Note: See TracChangeset for help on using the changeset viewer.