Changeset 8417


Ignore:
Timestamp:
05/24/11 15:09:01 (14 years ago)
Author:
seroussi
Message:

moved CreateKMatrix DiagnosticPattynFriction from Tria to Penta

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

Legend:

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

    r8416 r8417  
    13711371ElementMatrix* Penta::CreateKMatrixDiagnosticPattynFriction(void){
    13721372
     1373        /*Constants*/
     1374        const int numdof   = NDOF2*NUMVERTICES;
     1375       
     1376        /*Intermediaries */
     1377        int       i,j,ig;
     1378        int       analysis_type,drag_type;
     1379        double    xyz_list[NUMVERTICES][3];
     1380        double    xyz_list_tria[NUMVERTICES2D][3]={0.0};
     1381        double    slope_magnitude,alpha2,Jdet;
     1382        double    slope[3]={0.0,0.0,0.0};
     1383        double    MAXSLOPE=.06; // 6 %
     1384        double    MOUNTAINKEXPONENT=10;
     1385        double    L[2][numdof];
     1386        double    DL[2][2]={{ 0,0 },{0,0}}; //for basal drag
     1387        double    DL_scalar;
     1388        double    Ke_gg_gaussian[numdof][numdof]; //stiffness matrix contribution from drag
     1389        Friction  *friction = NULL;
     1390        GaussPenta *gauss=NULL;
     1391
    13731392        /*Initialize Element matrix and return if necessary*/
    13741393        if(IsOnShelf() || !IsOnBed()) return NULL;
    13751394
    1376         /*Build a tria element using the 3 nodes of the base of the penta. Then use
    1377          * the tria functionality to build a friction stiffness matrix on these 3
    1378          * nodes: */
    1379         Tria* tria=(Tria*)SpawnTria(0,1,2); //nodes 0, 1 and 2 make the new tria.
    1380         ElementMatrix* Ke=tria->CreateKMatrixDiagnosticPattynFriction();
    1381         delete tria->matice; delete tria;
    1382 
    1383         /*clean-up and return*/
     1395        ElementMatrix* Ke=new ElementMatrix(nodes,NUMVERTICES,this->parameters,PattynApproximationEnum);
     1396
     1397        /*Retrieve all inputs and parameters*/
     1398        GetVerticesCoordinates(&xyz_list[0][0], nodes, NUMVERTICES);
     1399        for(i=0;i<NUMVERTICES2D;i++) for(j=0;j<2;j++) xyz_list_tria[i][j]=xyz_list[i][j];
     1400        parameters->FindParam(&analysis_type,AnalysisTypeEnum);
     1401        inputs->GetParameterValue(&drag_type,DragTypeEnum);
     1402        Input* surface_input=inputs->GetInput(SurfaceEnum); _assert_(surface_input);
     1403        Input* vx_input=inputs->GetInput(VxEnum);           _assert_(vx_input);
     1404        Input* vy_input=inputs->GetInput(VyEnum);           _assert_(vy_input);
     1405        Input* vz_input=inputs->GetInput(VzEnum);           _assert_(vz_input);
     1406
     1407        /*build friction object, used later on: */
     1408        if (drag_type!=2)_error_(" non-viscous friction not supported yet!");
     1409        friction=new Friction("2d",inputs,matpar,analysis_type);
     1410
     1411        /* Start  looping on the number of gaussian points: */
     1412        gauss=new GaussPenta(0,1,2,2);
     1413        for (ig=gauss->begin();ig<gauss->end();ig++){
     1414
     1415                gauss->GaussPoint(ig);
     1416
     1417                GetTriaJacobianDeterminant(&Jdet, &xyz_list_tria[0][0],gauss);
     1418                GetL(&L[0][0], gauss,NDOF2);
     1419
     1420                surface_input->GetParameterDerivativeValue(&slope[0],&xyz_list[0][0],gauss);
     1421                friction->GetAlpha2(&alpha2, gauss,VxEnum,VyEnum,VzEnum);
     1422                slope_magnitude=sqrt(pow(slope[0],2)+pow(slope[1],2));
     1423
     1424                // If we have a slope > 6% for this element,  it means  we are on a mountain. In this particular case,
     1425                //velocity should be = 0. To achieve this result, we set alpha2_list to a very high value: */
     1426                if (slope_magnitude>MAXSLOPE){
     1427                        alpha2=pow((double)10,MOUNTAINKEXPONENT);
     1428                }
     1429               
     1430                DL_scalar=alpha2*gauss->weight*Jdet;
     1431                for (i=0;i<2;i++) DL[i][i]=DL_scalar;
     1432               
     1433                TripleMultiply( &L[0][0],2,numdof,1,
     1434                                        &DL[0][0],2,2,0,
     1435                                        &L[0][0],2,numdof,0,
     1436                                        &Ke_gg_gaussian[0][0],0);
     1437
     1438                for(i=0;i<numdof;i++) for(j=0;j<numdof;j++) Ke->values[i*numdof+j]+=Ke_gg_gaussian[i][j];
     1439        }
     1440
     1441        /*Clean up and return*/
     1442        delete gauss;
     1443        delete friction;
    13841444        return Ke;
    13851445}
  • issm/trunk/src/c/objects/Elements/PentaRef.cpp

    r8303 r8417  
    519519
    520520}
     521/*}}}*/
     522/*FUNCTION PentaRef::GetL{{{1*/
     523void PentaRef::GetL(double* L, GaussPenta* gauss, int numdof){
     524        /*Compute L  matrix. L=[L1 L2 L3] where Li is square and of size numdof.
     525         ** For node i, Li can be expressed in the actual coordinate system
     526         ** by:
     527         **       numdof=1:
     528         **                 Li=h;
     529         **       numdof=2:
     530         **                 Li=[ h   0 ]
     531         **                    [ 0   h ]
     532         ** where h is the interpolation function for node i.
     533         **
     534         ** We assume L has been allocated already, of size: NUMNODESP1 (numdof=1), or numdofx(numdof*NUMNODESP1) (numdof=2)
     535         **/
     536
     537        int i;
     538        double l1l6[6];
     539
     540        /*Get l1l6 in actual coordinate system: */
     541        GetNodalFunctionsP1(l1l6,gauss);
     542
     543        /*Build L: */
     544        if(numdof==1){
     545                for (i=0;i<NUMNODESP1;i++){
     546                        L[i]=l1l6[i];
     547                }
     548        }
     549        else{
     550                for (i=0;i<NUMNODESP1;i++){
     551                        *(L+numdof*NUMNODESP1*0+numdof*i)=l1l6[i];
     552                        *(L+numdof*NUMNODESP1*0+numdof*i+1)=0;
     553                        *(L+numdof*NUMNODESP1*1+numdof*i)=0;
     554                        *(L+numdof*NUMNODESP1*1+numdof*i+1)=l1l6[i];
     555                }
     556        }
     557}
    521558/*}}}*/
    522559/*FUNCTION PentaRef::GetLStokes {{{1*/
  • issm/trunk/src/c/objects/Elements/PentaRef.h

    r7070 r8417  
    4949                void GetBVert(double* B, double* xyz_list, GaussPenta* gauss);
    5050                void GetBprimeAdvec(double* Bprime_advec, double* xyz_list, GaussPenta* gauss);
     51                void GetL(double* L, GaussPenta* gauss,int numdof);
    5152                void GetLStokes(double* LStokes, GaussPenta* gauss);
    5253                void GetLprimeStokes(double* LprimeStokes, double* xyz_list, GaussPenta* gauss);
  • issm/trunk/src/c/objects/Elements/Tria.cpp

    r8416 r8417  
    988988        for(i=0;i<numdof;i++) for(j=0;j<numdof;j++) Ke->values[i*numdoftotal+(numdof+j)]+=Ke_gg[i][j];
    989989        for(i=0;i<numdof;i++) for(j=0;j<numdof;j++) Ke->values[(i+numdof)*numdoftotal+j]+=Ke_gg[i][j];
    990 
    991         /*Clean up and return*/
    992         delete gauss;
    993         delete friction;
    994         return Ke;
    995 }       
    996 /*}}}*/
    997 /*FUNCTION Tria::CreateKMatrixDiagnosticPattynFriction {{{1*/
    998 ElementMatrix* Tria::CreateKMatrixDiagnosticPattynFriction(void){
    999 
    1000         /*Constants*/
    1001         const int numdof   = NDOF2*NUMVERTICES;
    1002        
    1003         /*Intermediaries */
    1004         int       i,j,ig;
    1005         int       analysis_type,drag_type;
    1006         double    xyz_list[NUMVERTICES][3];
    1007         double    slope_magnitude,alpha2,Jdet;
    1008         double    slope[2]={0.0,0.0};
    1009         double    MAXSLOPE=.06; // 6 %
    1010         double    MOUNTAINKEXPONENT=10;
    1011         double    L[2][numdof];
    1012         double    DL[2][2]={{ 0,0 },{0,0}}; //for basal drag
    1013         double    DL_scalar;
    1014         double    Ke_gg_gaussian[numdof][numdof]; //stiffness matrix contribution from drag
    1015         Friction  *friction = NULL;
    1016         GaussTria *gauss=NULL;
    1017 
    1018         /*Initialize Element matrix and return if necessary*/
    1019         if(IsOnShelf()) return NULL;
    1020         ElementMatrix* Ke=new ElementMatrix(nodes,NUMVERTICES,this->parameters,PattynApproximationEnum);
    1021 
    1022         /*Retrieve all inputs and parameters*/
    1023         GetVerticesCoordinates(&xyz_list[0][0], nodes, NUMVERTICES);
    1024         parameters->FindParam(&analysis_type,AnalysisTypeEnum);
    1025         inputs->GetParameterValue(&drag_type,DragTypeEnum);
    1026         Input* surface_input=inputs->GetInput(SurfaceEnum); _assert_(surface_input);
    1027         Input* vx_input=inputs->GetInput(VxEnum);           _assert_(vx_input);
    1028         Input* vy_input=inputs->GetInput(VyEnum);           _assert_(vy_input);
    1029         Input* vz_input=inputs->GetInput(VzEnum);           _assert_(vz_input);
    1030 
    1031         /*build friction object, used later on: */
    1032         if (drag_type!=2)_error_(" non-viscous friction not supported yet!");
    1033         friction=new Friction("2d",inputs,matpar,analysis_type);
    1034 
    1035         /* Start  looping on the number of gaussian points: */
    1036         gauss=new GaussTria(2);
    1037         for (ig=gauss->begin();ig<gauss->end();ig++){
    1038 
    1039                 gauss->GaussPoint(ig);
    1040 
    1041                 GetJacobianDeterminant2d(&Jdet, &xyz_list[0][0],gauss);
    1042                 GetL(&L[0][0], &xyz_list[0][0], gauss,NDOF2);
    1043 
    1044                 surface_input->GetParameterDerivativeValue(&slope[0],&xyz_list[0][0],gauss);
    1045                 friction->GetAlpha2(&alpha2, gauss,VxEnum,VyEnum,VzEnum); // TO UNCOMMENT
    1046                 slope_magnitude=sqrt(pow(slope[0],2)+pow(slope[1],2));
    1047 
    1048                 // If we have a slope > 6% for this element,  it means  we are on a mountain. In this particular case,
    1049                 //velocity should be = 0. To achieve this result, we set alpha2_list to a very high value: */
    1050                 if (slope_magnitude>MAXSLOPE){
    1051                         alpha2=pow((double)10,MOUNTAINKEXPONENT);
    1052                 }
    1053                
    1054                 DL_scalar=alpha2*gauss->weight*Jdet;
    1055                 for (i=0;i<2;i++) DL[i][i]=DL_scalar;
    1056                
    1057                 TripleMultiply( &L[0][0],2,numdof,1,
    1058                                         &DL[0][0],2,2,0,
    1059                                         &L[0][0],2,numdof,0,
    1060                                         &Ke_gg_gaussian[0][0],0);
    1061 
    1062                 for(i=0;i<numdof;i++) for(j=0;j<numdof;j++) Ke->values[i*numdof+j]+=Ke_gg_gaussian[i][j];
    1063         }
    1064990
    1065991        /*Clean up and return*/
  • issm/trunk/src/c/objects/Elements/Tria.h

    r8416 r8417  
    151151                ElementMatrix* CreateKMatrixDiagnosticMacAyealFriction(void);
    152152                ElementMatrix* CreateKMatrixCouplingMacAyealPattynFriction(void);
    153                 ElementMatrix* CreateKMatrixDiagnosticPattynFriction(void);
    154153                ElementMatrix* CreateKMatrixDiagnosticHutter(void);
    155154                ElementMatrix* CreateKMatrixMelting(void);
Note: See TracChangeset for help on using the changeset viewer.