Changeset 5847


Ignore:
Timestamp:
09/16/10 13:11:42 (15 years ago)
Author:
Mathieu Morlighem
Message:

split MacAyeal2d and MacAyeal3d in Penta

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

Legend:

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

    r5843 r5847  
    21932193        switch(approximation){
    21942194                case MacAyealApproximationEnum:
    2195                         CreateKMatrixDiagnosticMacAyeal( Kgg);
     2195                        CreateKMatrixDiagnosticMacAyeal2d( Kgg);
    21962196                        break;
    21972197                case PattynApproximationEnum:
     
    22062206                        break;
    22072207                case MacAyealPattynApproximationEnum:
    2208                         CreateKMatrixDiagnosticMacAyeal( Kgg);
     2208                        CreateKMatrixDiagnosticMacAyeal3d( Kgg);
    22092209                        CreateKMatrixDiagnosticPattyn( Kgg);
    22102210                        CreateKMatrixCouplingMacAyealPattyn( Kgg);
     
    22902290
    22912291}
    2292 /*FUNCTION Penta::CreateKMatrixDiagnosticMacAyeal{{{1*/
    2293 void Penta::CreateKMatrixDiagnosticMacAyeal( Mat Kgg){
     2292/*FUNCTION Penta::CreateKMatrixDiagnosticMacAyeal2d{{{1*/
     2293void Penta::CreateKMatrixDiagnosticMacAyeal2d(Mat Kgg){
    22942294       
    2295         /* local declarations */
    2296         int             i,j;
    2297 
    2298         /* node data: */
     2295        /*If on water, skip stiffness: */
     2296        if(IsOnWater()) return;
     2297
     2298        /*Figure out if this pentaelem is collapsed. If so, then bailout, except if it is at the
     2299          bedrock, in which case we spawn a tria element using the 3 first grids, and use it to build
     2300          the stiffness matrix. */
     2301
     2302        if (!IsOnBed()){
     2303                /*This element should be collapsed, but this element is not on the bedrock, therefore all its
     2304                 * dofs have already been frozen! Do nothing: */
     2305                return;
     2306        }
     2307        else{
     2308
     2309                /*This element should be collapsed into a tria element at its base. Create this tria element,
     2310                 *and use its CreateKMatrix functionality to fill the global stiffness matrix: */
     2311
     2312                /*Depth Averaging B*/
     2313                this->InputDepthAverageAtBase(RheologyBEnum,RheologyBbarEnum,MaterialsEnum);
     2314
     2315                /*Call Tria function*/
     2316                Tria* tria=(Tria*)SpawnTria(0,1,2); //grids 0, 1 and 2 make the new tria.
     2317                tria->CreateKMatrix(Kgg,NULL,NULL);
     2318                delete tria->matice; delete tria;
     2319
     2320                /*Delete B averaged*/
     2321                this->matice->inputs->DeleteInput(RheologyBbarEnum);
     2322
     2323                return;
     2324        }
     2325}
     2326/*}}}*/
     2327/*FUNCTION Penta::CreateKMatrixDiagnosticMacAyeal3d{{{1*/
     2328void Penta::CreateKMatrixDiagnosticMacAyeal3d( Mat Kgg){
     2329
    22992330        const int    numdof2d=2*NUMVERTICES2D;
     2331        int             i,j,ig;
    23002332        double       xyz_list[NUMVERTICES][3];
    23012333        int*         doflist=NULL;
    2302 
    2303         /* 3d gaussian points: */
    2304         int     ig;
    23052334        GaussPenta *gauss=NULL;
    23062335        GaussTria  *gauss_tria=NULL;
    2307 
    2308         /* material data: */
    2309         double viscosity; //viscosity
    2310         double oldviscosity; //viscosity
    2311         double newviscosity; //viscosity
    2312 
    2313         /* strain rate: */
     2336        double viscosity, oldviscosity, newviscosity, viscosity_overshoot;
    23142337        double epsilon[5]; /* epsilon=[exx,eyy,exy,exz,eyz];*/
    23152338        double oldepsilon[5]; /* epsilon=[exx,eyy,exy,exz,eyz];*/
    2316 
    2317         /* matrices: */
    23182339        double B[3][numdof2d];
    23192340        double Bprime[3][numdof2d];
     
    23232344        double DL[2][2]={0.0}; //for basal drag
    23242345        double DL_scalar;
    2325 
    2326         /* local element matrices: */
    23272346        double Ke_gg[numdof2d][numdof2d]={0.0}; //local element stiffness matrix
    23282347        double Ke_gg_gaussian[numdof2d][numdof2d]; //stiffness matrix evaluated at the gaussian point.
    23292348        double Jdet;
    2330 
    2331         /*slope: */
    23322349        double  slope[2]={0.0};
    23332350        double  slope_magnitude;
    2334 
    2335         /*friction: */
    23362351        double  alpha2_list[3];
    23372352        double  alpha2;
    2338 
    23392353        double MAXSLOPE=.06; // 6 %
    23402354        double MOUNTAINKEXPONENT=10;
    2341 
    2342         /*parameters: */
    2343         double viscosity_overshoot;
    2344 
    2345         /*Collapsed formulation: */
    23462355        Tria*  tria=NULL;
    23472356        Penta* pentabase=NULL;
    2348         int  approximation;
    2349 
    2350         inputs->GetParameterValue(&approximation,ApproximationEnum);
    23512357
    23522358        /*If on water, skip stiffness: */
    2353         if(approximation==MacAyealApproximationEnum){
    2354                 if(IsOnWater())return;
    2355 
    2356                 /*Figure out if this pentaelem is collapsed. If so, then bailout, except if it is at the
    2357                   bedrock, in which case we spawn a tria element using the 3 first grids, and use it to build
    2358                   the stiffness matrix. */
    2359 
    2360                 if (!IsOnBed()){
    2361                         /*This element should be collapsed, but this element is not on the bedrock, therefore all its
    2362                          * dofs have already been frozen! Do nothing: */
    2363                         return;
    2364                 }
    2365                 else{
    2366 
    2367                         /*This element should be collapsed into a tria element at its base. Create this tria element,
    2368                          *and use its CreateKMatrix functionality to fill the global stiffness matrix: */
    2369 
    2370                         /*Depth Averaging B*/
    2371                         this->InputDepthAverageAtBase(RheologyBEnum,RheologyBbarEnum,MaterialsEnum);
    2372 
    2373                         /*Call Tria function*/
    2374                         tria=(Tria*)SpawnTria(0,1,2); //grids 0, 1 and 2 make the new tria.
    2375                         tria->CreateKMatrix(Kgg,NULL,NULL);
    2376                         delete tria->matice; delete tria;
    2377 
    2378                         /*Delete B averaged*/
    2379                         this->matice->inputs->DeleteInput(RheologyBbarEnum);
    2380 
    2381                         return;
    2382                 }
    2383         }
    2384         else if(approximation==MacAyealPattynApproximationEnum){
    2385                 /*retrieve some parameters: */
    2386                 this->parameters->FindParam(&viscosity_overshoot,ViscosityOvershootEnum);
    2387 
    2388                 /*If on water, skip stiffness: */
    2389                 if(IsOnWater())return;
    2390 
    2391                 /*Find penta on bed as this is a macayeal elements: */
    2392                 pentabase=GetBasalElement();
    2393                 tria=pentabase->SpawnTria(0,1,2); //grids 0, 1 and 2 make the new tria.
    2394 
    2395                 /* Get node coordinates and dof list: */
    2396                 GetVerticesCoordinates(&xyz_list[0][0], nodes,NUMVERTICES);
    2397                 tria->GetDofList(&doflist,MacAyealApproximationEnum,GsetEnum);  //Pattyn dof list
    2398 
    2399                 /*Retrieve all inputs we will be needing: */
    2400                 Input* vx_input=inputs->GetInput(VxEnum);       ISSMASSERT(vx_input);
    2401                 Input* vy_input=inputs->GetInput(VyEnum);       ISSMASSERT(vy_input);
    2402                 Input* vxold_input=inputs->GetInput(VxOldEnum); ISSMASSERT(vxold_input);
    2403                 Input* vyold_input=inputs->GetInput(VyOldEnum); ISSMASSERT(vyold_input);
    2404 
    2405                 /* Start  looping on the number of gaussian points: */
    2406                 gauss=new GaussPenta(5,5);
    2407                 gauss_tria=new GaussTria();
    2408                 for (ig=gauss->begin();ig<gauss->end();ig++){
    2409 
    2410                         gauss->GaussPoint(ig);
    2411                         gauss->SynchronizeGaussTria(gauss_tria);
    2412 
    2413                         /*Get strain rate from velocity: */
    2414                         this->GetStrainRate3dPattyn(&epsilon[0],&xyz_list[0][0],gauss,vx_input,vy_input);
    2415                         this->GetStrainRate3dPattyn(&oldepsilon[0],&xyz_list[0][0],gauss,vxold_input,vyold_input);
    2416 
    2417                         /*Get viscosity: */
    2418                         matice->GetViscosity3d(&viscosity, &epsilon[0]);
    2419                         matice->GetViscosity3d(&oldviscosity, &oldepsilon[0]);
    2420 
    2421                         /*Get B and Bprime matrices: */
    2422                         tria->GetBMacAyeal(&B[0][0], &xyz_list[0][0], gauss_tria);
    2423                         tria->GetBprimeMacAyeal(&Bprime[0][0], &xyz_list[0][0], gauss_tria);
    2424 
    2425                         /* Get Jacobian determinant: */
    2426                         GetJacobianDeterminant(&Jdet, &xyz_list[0][0],gauss);
    2427 
    2428                         /*Build the D matrix: we plug the gaussian weight, the viscosity, and the jacobian determinant
    2429                           onto this scalar matrix, so that we win some computational time: */
    2430                         newviscosity=viscosity+viscosity_overshoot*(viscosity-oldviscosity);
    2431                         D_scalar=2*newviscosity*gauss->weight*Jdet;
    2432                         for (i=0;i<3;i++) D[i][i]=D_scalar;
    2433 
    2434                         /*  Do the triple product tB*D*Bprime: */
    2435                         TripleMultiply( &B[0][0],3,numdof2d,1,
    2436                                                 &D[0][0],3,3,0,
    2437                                                 &Bprime[0][0],3,numdof2d,0,
    2438                                                 &Ke_gg_gaussian[0][0],0);
    2439 
    2440                         /* Add the Ke_gg_gaussian, and optionally Ke_gg_gaussian onto Ke_gg: */
    2441                         for(i=0;i<numdof2d;i++) for(j=0;j<numdof2d;j++) Ke_gg[i][j]+=Ke_gg_gaussian[i][j];
    2442                 }
    2443 
    2444                 /*Add Ke_gg to global matrix Kgg: */
    2445                 MatSetValues(Kgg,numdof2d,doflist,numdof2d,doflist,(const double*)Ke_gg,ADD_VALUES);
    2446 
    2447                 //Deal with 2d friction at the bedrock interface
    2448                 if(IsOnBed() && !IsOnShelf()){
    2449                         /*Build a tria element using the 3 grids of the base of the penta. Then use
    2450                          * the tria functionality to build a friction stiffness matrix on these 3
    2451                          * grids: */
    2452 
    2453                         tria->CreateKMatrixDiagnosticMacAyealFriction(Kgg,NULL,NULL);
    2454                 }
    2455 
    2456                 /*Clean up and return*/
    2457                 delete tria->matice;
    2458                 delete tria;
    2459                 delete gauss_tria;
    2460                 delete gauss;
    2461                 xfree((void**)&doflist);
    2462         }
     2359        if(IsOnWater())return;
     2360
     2361        /*Find penta on bed as this is a macayeal elements: */
     2362        pentabase=GetBasalElement();
     2363        tria=pentabase->SpawnTria(0,1,2); //grids 0, 1 and 2 make the new tria.
     2364
     2365        /* Get dof list: */
     2366        tria->GetDofList(&doflist,MacAyealApproximationEnum,GsetEnum);  //Pattyn dof list
     2367
     2368        /*Retrieve all inputs and parameters*/
     2369        GetVerticesCoordinates(&xyz_list[0][0], nodes,NUMVERTICES);
     2370        this->parameters->FindParam(&viscosity_overshoot,ViscosityOvershootEnum);
     2371        Input* vx_input=inputs->GetInput(VxEnum);       ISSMASSERT(vx_input);
     2372        Input* vy_input=inputs->GetInput(VyEnum);       ISSMASSERT(vy_input);
     2373        Input* vxold_input=inputs->GetInput(VxOldEnum); ISSMASSERT(vxold_input);
     2374        Input* vyold_input=inputs->GetInput(VyOldEnum); ISSMASSERT(vyold_input);
     2375
     2376        /* Start  looping on the number of gaussian points: */
     2377        gauss=new GaussPenta(5,5);
     2378        gauss_tria=new GaussTria();
     2379        for (ig=gauss->begin();ig<gauss->end();ig++){
     2380
     2381                gauss->GaussPoint(ig);
     2382                gauss->SynchronizeGaussTria(gauss_tria);
     2383
     2384                tria->GetBMacAyeal(&B[0][0], &xyz_list[0][0], gauss_tria);
     2385                tria->GetBprimeMacAyeal(&Bprime[0][0], &xyz_list[0][0], gauss_tria);
     2386
     2387
     2388                this->GetStrainRate3dPattyn(&epsilon[0],&xyz_list[0][0],gauss,vx_input,vy_input);
     2389                this->GetStrainRate3dPattyn(&oldepsilon[0],&xyz_list[0][0],gauss,vxold_input,vyold_input);
     2390                matice->GetViscosity3d(&viscosity, &epsilon[0]);
     2391                matice->GetViscosity3d(&oldviscosity, &oldepsilon[0]);
     2392                newviscosity=viscosity+viscosity_overshoot*(viscosity-oldviscosity);
     2393                GetJacobianDeterminant(&Jdet, &xyz_list[0][0],gauss);
     2394                D_scalar=2*newviscosity*gauss->weight*Jdet;
     2395                for (i=0;i<3;i++) D[i][i]=D_scalar;
     2396
     2397                TripleMultiply( &B[0][0],3,numdof2d,1,
     2398                                        &D[0][0],3,3,0,
     2399                                        &Bprime[0][0],3,numdof2d,0,
     2400                                        &Ke_gg_gaussian[0][0],0);
     2401
     2402                for(i=0;i<numdof2d;i++) for(j=0;j<numdof2d;j++) Ke_gg[i][j]+=Ke_gg_gaussian[i][j];
     2403        }
     2404
     2405        MatSetValues(Kgg,numdof2d,doflist,numdof2d,doflist,(const double*)Ke_gg,ADD_VALUES);
     2406
     2407        //Deal with 2d friction at the bedrock interface
     2408        if(IsOnBed() && !IsOnShelf()){
     2409                /*Build a tria element using the 3 grids of the base of the penta. Then use
     2410                 * the tria functionality to build a friction stiffness matrix on these 3
     2411                 * grids: */
     2412
     2413                tria->CreateKMatrixDiagnosticMacAyealFriction(Kgg,NULL,NULL);
     2414        }
     2415
     2416        /*Clean up and return*/
     2417        delete tria->matice;
     2418        delete tria;
     2419        delete gauss_tria;
     2420        delete gauss;
     2421        xfree((void**)&doflist);
    24632422}
    24642423/*}}}*/
  • issm/trunk/src/c/objects/Elements/Penta.h

    r5843 r5847  
    127127                void      CreateKMatrixDiagnosticHoriz( Mat Kgg);
    128128                void      CreateKMatrixDiagnosticHutter( Mat Kgg);
    129                 void      CreateKMatrixDiagnosticMacAyeal( Mat Kgg);
     129                void      CreateKMatrixDiagnosticMacAyeal2d(Mat Kgg);
     130                void      CreateKMatrixDiagnosticMacAyeal3d(Mat Kgg);
    130131                void      CreateKMatrixDiagnosticPattyn( Mat Kgg);
    131132                void      CreateKMatrixDiagnosticStokes( Mat Kgg);
Note: See TracChangeset for help on using the changeset viewer.