Changeset 5203


Ignore:
Timestamp:
08/12/10 14:32:30 (15 years ago)
Author:
seroussi
Message:

Kmatrix coupling

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

Legend:

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

    r5174 r5203  
    755755                        return;
    756756                }
     757                else if(approximation==MacAyealPattynApproximationEnum){
     758                        ISSMERROR("coupling MacAyeal/Pattyn not implemented yet");
     759                        CreateKMatrixDiagnosticMacAyeal( Kgg);
     760                        CreateKMatrixDiagnosticPattyn( Kgg);
     761                        CreateKMatrixCouplingMacAyealPattyn( Kgg);
     762                }
    757763                else ISSMERROR("Approximation %s not supported yet",EnumToString(approximation));
    758764        }
     
    827833                else if(approximation==HutterApproximationEnum){
    828834                        return;
     835                }
     836                else if(approximation==MacAyealPattynApproximationEnum){
     837                        CreatePVectorDiagnosticMacAyeal( pg);
     838                        CreatePVectorDiagnosticPattyn( pg);
    829839                }
    830840                else ISSMERROR("Approximation %s not supported yet",EnumToString(approximation));
     
    20832093}
    20842094/*}}}*/
     2095/*FUNCTION Penta::CreateKMatrixCouplingMacAyealPattyn{{{1*/
     2096void Penta::CreateKMatrixCouplingMacAyealPattyn( Mat Kgg){
     2097
     2098        /* local declarations */
     2099        int             i,j;
     2100
     2101        /* node data: */
     2102        const int    numgrids=6; // Pattyn numgrids
     2103        const int    numdof=2*numgrids;
     2104        const int    numgrids2=3; //MacAyeal numgrids
     2105        const int    numdof2=2*numgrids2;
     2106        double       xyz_list[numgrids][3];
     2107        int*         doflist=NULL;
     2108        int*         doflist2=NULL;
     2109
     2110        /* 3d gaussian points: */
     2111        int     num_gauss,ig;
     2112        double* first_gauss_area_coord  =  NULL;
     2113        double* second_gauss_area_coord =  NULL;
     2114        double* third_gauss_area_coord  =  NULL;
     2115        double* fourth_gauss_vert_coord  =  NULL;
     2116        double* area_gauss_weights           =  NULL;
     2117        double* vert_gauss_weights           =  NULL;
     2118        int     ig1,ig2;
     2119        double  gauss_weight1,gauss_weight2;
     2120        double  gauss_coord[4];
     2121        int     order_area_gauss;
     2122        int     num_vert_gauss;
     2123        int     num_area_gauss;
     2124        double  gauss_weight;
     2125
     2126        /* 2d gaussian point: */
     2127        int     num_gauss2d;
     2128        double* first_gauss_area_coord2d  =  NULL;
     2129        double* second_gauss_area_coord2d =  NULL;
     2130        double* third_gauss_area_coord2d  =  NULL;
     2131        double* gauss_weights2d=NULL;
     2132        double  gauss_l1l2l3[3];
     2133
     2134        /* material data: */
     2135        double viscosity; //viscosity
     2136        double oldviscosity; //viscosity
     2137        double newviscosity; //viscosity
     2138
     2139        /* strain rate: */
     2140        double epsilon[5]; /* epsilon=[exx,eyy,exy,exz,eyz];*/
     2141        double oldepsilon[5]; /* epsilon=[exx,eyy,exy,exz,eyz];*/
     2142
     2143        /* matrices: */
     2144        double B[3][numdof];
     2145        double Bprime[3][numdof2];
     2146        double L[2][numdof];
     2147        double D[3][3]={0.0};            // material matrix, simple scalar matrix.
     2148        double D_scalar;
     2149        double DL[2][2]={0.0}; //for basal drag
     2150        double DL_scalar;
     2151
     2152        /* local element matrices: */
     2153        double Ke_gg[numdof][numdof2]={0.0}; //local element stiffness matrix
     2154        double Ke_gg_gaussian[numdof][numdof2]; //stiffness matrix evaluated at the gaussian point.
     2155        double Jdet;
     2156
     2157        /*friction: */
     2158        double  alpha2_list[3];
     2159        double  alpha2;
     2160
     2161        /*parameters: */
     2162        double viscosity_overshoot;
     2163
     2164        /*Collapsed formulation: */
     2165        Tria*  tria     =NULL;
     2166        Penta* pentabase=NULL;
     2167
     2168        /*inputs: */
     2169        bool onwater;
     2170        bool onbed;
     2171        bool shelf;
     2172        Input* vx_input=NULL;
     2173        Input* vy_input=NULL;
     2174        Input* vxold_input=NULL;
     2175        Input* vyold_input=NULL;
     2176
     2177        /*retrieve inputs :*/
     2178        inputs->GetParameterValue(&onwater,ElementOnWaterEnum);
     2179        inputs->GetParameterValue(&onbed,ElementOnBedEnum);
     2180        inputs->GetParameterValue(&shelf,ElementOnIceShelfEnum);
     2181
     2182        /*retrieve some parameters: */
     2183        this->parameters->FindParam(&viscosity_overshoot,ViscosityOvershootEnum);
     2184
     2185        /*If on water, skip stiffness: */
     2186        if(onwater)return;
     2187
     2188        /*Find penta on bed as pattyn must be coupled to the dofs on the bed: */
     2189        pentabase=GetBasalElement();
     2190        tria=pentabase->SpawnTria(0,1,2); //grids 0, 1 and 2 make the new tria.
     2191
     2192        /* Get node coordinates and dof list: */
     2193        GetVerticesCoordinates(&xyz_list[0][0], nodes, numgrids);
     2194        GetDofList(&doflist);  //Pattyn dof list
     2195        GetDofList(&doflist2); //MacAyeal dof list
     2196
     2197        /*Get gaussian points and weights. Penta is an extrusion of a Tria, we therefore
     2198          get tria gaussian points as well as segment gaussian points. For tria gaussian
     2199          points, order of integration is 2, because we need to integrate the product tB*D*B'
     2200          which is a polynomial of degree 3 (see GaussTria for more details). For segment gaussian
     2201          points, same deal, which yields 3 gaussian points.*/
     2202
     2203        order_area_gauss=5;
     2204        num_vert_gauss=5;
     2205
     2206        GaussPenta( &num_area_gauss, &first_gauss_area_coord, &second_gauss_area_coord, &third_gauss_area_coord, &area_gauss_weights, &fourth_gauss_vert_coord,&vert_gauss_weights,order_area_gauss,num_vert_gauss);
     2207
     2208        /*Retrieve all inputs we will be needing: */
     2209        vx_input=inputs->GetInput(VxEnum);
     2210        vy_input=inputs->GetInput(VyEnum);
     2211        vxold_input=inputs->GetInput(VxOldEnum);
     2212        vyold_input=inputs->GetInput(VyOldEnum);
     2213
     2214        /* Start  looping on the number of gaussian points: */
     2215        for (ig1=0; ig1<num_area_gauss; ig1++){
     2216                for (ig2=0; ig2<num_vert_gauss; ig2++){
     2217
     2218                        /*Pick up the gaussian point: */
     2219                        gauss_weight1=*(area_gauss_weights+ig1);
     2220                        gauss_weight2=*(vert_gauss_weights+ig2);
     2221                        gauss_weight=gauss_weight1*gauss_weight2;
     2222
     2223                        gauss_coord[0]=*(first_gauss_area_coord+ig1);
     2224                        gauss_coord[1]=*(second_gauss_area_coord+ig1);
     2225                        gauss_coord[2]=*(third_gauss_area_coord+ig1);
     2226                        gauss_coord[3]=*(fourth_gauss_vert_coord+ig2);
     2227
     2228                        /*Get strain rate from velocity: */
     2229                        this->GetStrainRate3dPattyn(&epsilon[0],&xyz_list[0][0],gauss_coord,vx_input,vy_input);
     2230                        this->GetStrainRate3dPattyn(&oldepsilon[0],&xyz_list[0][0],gauss_coord,vxold_input,vyold_input);
     2231
     2232                        /*Get viscosity: */
     2233                        matice->GetViscosity3d(&viscosity, &epsilon[0]);
     2234                        matice->GetViscosity3d(&oldviscosity, &oldepsilon[0]);
     2235
     2236                        /*Get B and Bprime matrices: */
     2237                        GetBMacAyealPattyn(&B[0][0], &xyz_list[0][0], gauss_coord);
     2238                        tria->GetBprimeMacAyeal(&Bprime[0][0], &xyz_list[0][0], gauss_coord);
     2239
     2240                        /* Get Jacobian determinant: */
     2241                        GetJacobianDeterminant(&Jdet, &xyz_list[0][0],gauss_coord);
     2242
     2243                        /*Build the D matrix: we plug the gaussian weight, the viscosity, and the jacobian determinant
     2244                          onto this scalar matrix, so that we win some computational time: */
     2245
     2246                        newviscosity=viscosity+viscosity_overshoot*(viscosity-oldviscosity);
     2247                        D_scalar=newviscosity*gauss_weight*Jdet;
     2248                        for (i=0;i<3;i++){
     2249                                D[i][i]=D_scalar;
     2250                        }
     2251
     2252                        /*  Do the triple product tB*D*Bprime: */
     2253                        TripleMultiply( &B[0][0],3,numdof,1,
     2254                                                &D[0][0],3,3,0,
     2255                                                &Bprime[0][0],3,numdof2,0,
     2256                                                &Ke_gg_gaussian[0][0],0);
     2257
     2258                        /* Add the Ke_gg_gaussian, and optionally Ke_gg_gaussian onto Ke_gg: */
     2259                        for( i=0; i<numdof; i++){
     2260                                for(j=0;j<numdof2; j++){
     2261                                        Ke_gg[i][j]+=Ke_gg_gaussian[i][j];
     2262                                }
     2263                        }
     2264                } //for (ig2=0; ig2<num_vert_gauss; ig2++)
     2265        } //for (ig1=0; ig1<num_area_gauss; ig1++)
     2266
     2267        /*Add Ke_gg to global matrix Kgg: */
     2268        // one need to be transposed
     2269        MatSetValues(Kgg,numdof,doflist,numdof2,doflist2,(const double*)Ke_gg,ADD_VALUES);
     2270        MatSetValues(Kgg,numdof2,doflist2,numdof,doflist,(const double*)Ke_gg,ADD_VALUES);
     2271
     2272        //Deal with 2d friction at the bedrock interface
     2273        if((onbed && !shelf)){
     2274
     2275                /*Build a tria element using the 3 grids of the base of the penta. Then use
     2276                 * the tria functionality to build a friction stiffness matrix on these 3
     2277                 * grids: */
     2278
     2279                tria->CreateKMatrixDiagnosticHorizFriction(Kgg);
     2280        }
     2281
     2282        delete tria;
     2283        delete pentabase;
     2284
     2285        xfree((void**)&first_gauss_area_coord);
     2286        xfree((void**)&second_gauss_area_coord);
     2287        xfree((void**)&third_gauss_area_coord);
     2288        xfree((void**)&fourth_gauss_vert_coord);
     2289        xfree((void**)&area_gauss_weights);
     2290        xfree((void**)&vert_gauss_weights);
     2291        xfree((void**)&first_gauss_area_coord2d);
     2292        xfree((void**)&second_gauss_area_coord2d);
     2293        xfree((void**)&third_gauss_area_coord2d);
     2294        xfree((void**)&gauss_weights2d);
     2295        xfree((void**)&doflist);
     2296}
     2297/*}}}*/
    20852298/*FUNCTION Penta::CreateKMatrixDiagnosticHutter{{{1*/
    20862299void  Penta::CreateKMatrixDiagnosticHutter(Mat Kgg){
     
    22682481        double Ke_gg[numdof][numdof]={0.0}; //local element stiffness matrix
    22692482        double Ke_gg_gaussian[numdof][numdof]; //stiffness matrix evaluated at the gaussian point.
    2270         double Ke_gg_drag_gaussian[numdof][numdof]; //stiffness matrix contribution from drag
    22712483        double Jdet;
    22722484
     
    27983010                                                &Ke_gg_gaussian[0][0],0);
    27993011
    2800                         /* Add the Ke_gg_gaussian, and optionally Ke_gg_drag_gaussian onto Ke_gg: */
     3012                        /* Add the Ke_gg_gaussian, and optionally Ke_gg_gaussian onto Ke_gg: */
    28013013                        for( i=0; i<numdof; i++){
    28023014                                for(j=0;j<numdof;j++){
     
    31093321                                        D_scalar=D_scalar*dt;
    31103322                                }
    3111                                 K[0][0]=D_scalar*pow(u,2);       K[0][1]=D_scalar*fabs(u)*fabs(v);
    3112                                 K[1][0]=D_scalar*fabs(u)*fabs(v);K[1][1]=D_scalar*pow(v,2);
     3323                                //K[0][0]=D_scalar*pow(u,2);       K[0][1]=D_scalar*fabs(u)*fabs(v);
     3324                                //K[1][0]=D_scalar*fabs(u)*fabs(v);K[1][1]=D_scalar*pow(v,2);
     3325                                K[0][0]=D_scalar*pow(u,2);       K[0][1]=D_scalar*(u)*(v);
     3326                                K[1][0]=D_scalar*(u)*(v);        K[1][1]=D_scalar*pow(v,2);
    31133327
    31143328                                /*Get B_artdiff: */
  • issm/trunk/src/c/objects/Elements/Penta.h

    r5166 r5203  
    115115                void      CreateKMatrixBalancedthickness(Mat Kggg);
    116116                void      CreateKMatrixBalancedvelocities(Mat Kggg);
     117                void      CreateKMatrixCouplingMacAyealPattyn( Mat Kgg);
    117118                void      CreateKMatrixDiagnosticHutter( Mat Kgg);
    118119                void      CreateKMatrixDiagnosticMacAyeal( Mat Kgg);
  • issm/trunk/src/c/objects/Elements/PentaRef.cpp

    r4990 r5203  
    5252
    5353/*Reference Element numerics*/
     54/*FUNCTION PentaRef::GetBMacAyealPattyn {{{1*/
     55void PentaRef::GetBMacAyealPattyn(double* B, double* xyz_list, double* gauss){
     56        /*Compute B  matrix. B=[B1 B2 B3 B4 B5 B6] where Bi is of size 5*NDOF2.
     57         * For grid i, Bi can be expressed in the actual coordinate system
     58         * by:
     59         *       Bi=[ dh/dx          0      ]
     60         *          [   0           dh/dy   ]
     61         *          [ 1/2*dh/dy  1/2*dh/dx  ]
     62         * where h is the interpolation function for grid i.
     63         *
     64         * We assume B has been allocated already, of size: 5x(NDOF2*numgrids)
     65         */
     66
     67        int i;
     68        const int numgrids=6;
     69        const int NDOF3=3;
     70        const int NDOF2=2;
     71
     72        double dh1dh6[NDOF3][numgrids];
     73
     74        /*Get dh1dh6 in actual coordinate system: */
     75        GetNodalFunctionsP1Derivatives(&dh1dh6[0][0],xyz_list, gauss);
     76
     77        /*Build B: */
     78        for (i=0;i<numgrids;i++){
     79                *(B+NDOF2*numgrids*0+NDOF2*i)=dh1dh6[0][i];
     80                *(B+NDOF2*numgrids*0+NDOF2*i+1)=0.0;
     81
     82                *(B+NDOF2*numgrids*1+NDOF2*i)=0.0;
     83                *(B+NDOF2*numgrids*1+NDOF2*i+1)=dh1dh6[1][i];
     84
     85                *(B+NDOF2*numgrids*2+NDOF2*i)=(float).5*dh1dh6[1][i];
     86                *(B+NDOF2*numgrids*2+NDOF2*i+1)=(float).5*dh1dh6[0][i];
     87
     88        }
     89
     90}
     91/*}}}*/
    5492/*FUNCTION PentaRef::GetBPattyn {{{1*/
    5593void PentaRef::GetBPattyn(double* B, double* xyz_list, double* gauss){
  • issm/trunk/src/c/objects/Elements/PentaRef.h

    r4921 r5203  
    3232                void GetJacobianDeterminant(double*  Jdet, double* xyz_list,double* gauss);
    3333                void GetJacobianInvert(double*  Jinv, double* xyz_list,double* gauss);
     34                void GetBMacAyealPattyn(double* B, double* xyz_list, double* gauss);
    3435                void GetBPattyn(double* B, double* xyz_list, double* gauss);
    3536                void GetBprimePattyn(double* B, double* xyz_list, double* gauss);
Note: See TracChangeset for help on using the changeset viewer.