Changeset 5571


Ignore:
Timestamp:
08/25/10 10:03:20 (15 years ago)
Author:
Mathieu Morlighem
Message:

Better gradient for balanced thickness

File:
1 edited

Legend:

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

    r5529 r5571  
    13421342        const int    numgrids=3;
    13431343        const int    NDOF1=1;
    1344         const int    numdof=NDOF1*numgrids;
    1345         double       xyz_list[numgrids][3];
    13461344        int          doflist1[numgrids];
    13471345
     1346        /*Gauss*/
     1347        double  gauss[numgrids][numgrids]={{1,0,0},{0,1,0},{0,0,1}};
     1348
    13481349        /* grid data: */
    1349         double DhDt[numgrids];
    1350 
    1351         /* gaussian points: */
    1352         int     num_gauss,ig;
    1353         double* first_gauss_area_coord  =  NULL;
    1354         double* second_gauss_area_coord =  NULL;
    1355         double* third_gauss_area_coord  =  NULL;
    1356         double* gauss_weights           =  NULL;
    1357         double  gauss_weight;
    1358         double  gauss_l1l2l3[3];
     1350        double lambda;
    13591351
    13601352        /*element vector at the gaussian points: */
    1361         double  grade_g[numgrids]={0.0};
    1362         double  grade_g_gaussian[numgrids];
    1363 
    1364         /* Jacobian: */
    1365         double Jdet;
    1366 
    1367         /*nodal functions: */
    1368         double l1l2l3[3];
    1369         double  lambda;
     1353        double  gradient_g[numgrids];
    13701354
    13711355        /*Inputs*/
    13721356        Input* adjoint_input=NULL;
    13731357
    1374         GetVerticesCoordinates(&xyz_list[0][0], nodes, numgrids);
     1358        /*Retrieve dof list*/
    13751359        GetDofList1(&doflist1[0]);
    13761360
    1377         /* Get gaussian points and weights (make this a statically initialized list of points? fstd): */
    1378         GaussTria( &num_gauss, &first_gauss_area_coord, &second_gauss_area_coord, &third_gauss_area_coord, &gauss_weights, 4);
    1379 
    13801361        /*Retrieve all inputs we will be needing: */
    1381         adjoint_input=inputs->GetInput(AdjointEnum);
    1382 
    1383         /* Start  looping on the number of gaussian points: */
    1384         for (ig=0; ig<num_gauss; ig++){
    1385                 /*Pick up the gaussian point: */
    1386                 gauss_weight=*(gauss_weights+ig);
    1387                 gauss_l1l2l3[0]=*(first_gauss_area_coord+ig);
    1388                 gauss_l1l2l3[1]=*(second_gauss_area_coord+ig);
    1389                 gauss_l1l2l3[2]=*(third_gauss_area_coord+ig);
    1390 
    1391                 /*Get thickness: */
    1392                 adjoint_input->GetParameterValue(&lambda, gauss_l1l2l3);
    1393 
    1394                 /* Get Jacobian determinant: */
    1395                 GetJacobianDeterminant2d(&Jdet, &xyz_list[0][0],gauss_l1l2l3);
    1396 
    1397                 /* Get nodal functions value at gaussian point:*/
    1398                 GetNodalFunctions(l1l2l3, gauss_l1l2l3);
    1399 
    1400                 /*DhDtuild gradje_g_gaussian vector (actually -dJ/dDhDt): */
    1401                 for (i=0;i<numgrids;i++){
    1402                         //standard gradient dJ/dki
    1403                         grade_g_gaussian[i]=-lambda*Jdet*gauss_weight*l1l2l3[i];
    1404                 }
    1405 
    1406                 /*Add grade_g_gaussian to grade_g: */
    1407                 for( i=0; i<numgrids;i++) grade_g[i]+=grade_g_gaussian[i];
     1362        adjoint_input=(Input*)inputs->GetInput(AdjointEnum);
     1363
     1364        /* Start  looping on the vertices: */
     1365        for(i=0; i<numgrids;i++){
     1366                adjoint_input->GetParameterValue(&lambda,&gauss[i][0]);
     1367                gradient_g[i]=-lambda;
    14081368        }
    14091369
    14101370        /*Add grade_g to global vector gradient: */
    1411         VecSetValues(gradient,numgrids,doflist1,(const double*)grade_g,ADD_VALUES);
    1412 
    1413         xfree((void**)&first_gauss_area_coord);
    1414         xfree((void**)&second_gauss_area_coord);
    1415         xfree((void**)&third_gauss_area_coord);
    1416         xfree((void**)&gauss_weights);
     1371        VecSetValues(gradient,numgrids,doflist1,(const double*)gradient_g,INSERT_VALUES);
    14171372}
    14181373/*}}}*/
Note: See TracChangeset for help on using the changeset viewer.