Changeset 205


Ignore:
Timestamp:
05/04/09 10:55:32 (16 years ago)
Author:
Mathieu Morlighem
Message:

Linearize Du before the integration

File:
1 edited

Legend:

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

    r202 r205  
    663663                GetParameterValue(&alpha2, &alpha2_list[0],gauss_l1l2l3);
    664664
    665                 if (velocity_param){
    666                         DL_scalar=alpha2*gauss_weight*Jdet;
    667                 }
    668                 else{
    669                         DL_scalar=0;
    670                 }
    671                        
     665                DL_scalar=alpha2*gauss_weight*Jdet;
    672666                for (i=0;i<2;i++){
    673667                        DL[i][i]=DL_scalar;
     
    922916        B_param=ParameterInputsRecover(inputs,"B");
    923917        if(temperature_average_param){
     918                temperature_average-0;
    924919                for(i=0;i<3;i++) temperature_average+=temperature_average_param[doflist[i*numberofdofspernode+0]];
    925920                temperature_average=temperature_average/3.0;
     
    13741369        double obs_vx_list[numgrids];
    13751370        double obs_vy_list[numgrids];
     1371        double absolutex[numgrids];
     1372        double absolutey[numgrids];
     1373        double relativex[numgrids];
     1374        double relativey[numgrids];
     1375        double logarithmicx[numgrids];
     1376        double logarithmicy[numgrids];
    13761377
    13771378        /* gaussian points: */
     
    13991400
    14001401        /*relative and algorithmic fitting: */
    1401         double meanvel=0;
    1402         double epsvel=0;
    1403         double scalex=1;
    1404         double scaley=1;
     1402        double scalex=0;
     1403        double scaley=0;
    14051404        double scale=0;
    14061405        double* fit_param=NULL;
     
    14271426                obs_vx_list[i]=obs_velocity[doflist[i*numberofdofspernode+0]];
    14281427                obs_vy_list[i]=obs_velocity[doflist[i*numberofdofspernode+1]];
    1429 
    1430         }
    1431 
     1428        }
     1429
     1430        /*Get Du at the 3 nodes (integration of the linearized function)*/
     1431        if(fit==0){
     1432                /*We are using an absolute misfit: */
     1433                for (i=0;i<numgrids;i++){
     1434                        absolutex[i]=vx_list[i]-obs_vx_list[i];
     1435                        absolutey[i]=vy_list[i]-obs_vy_list[i];
     1436                }
     1437        }
     1438        else if(fit==1){
     1439                /*We are using a relative misfit: */
     1440                for (i=0;i<numgrids;i++){
     1441                        scalex=pow(meanvel/(obs_vx_list[i]+epsvel),2);
     1442                        scaley=pow(meanvel/(obs_vy_list[i]+epsvel),2);
     1443                        if(obs_vx_list[i]==0)scalex=0;
     1444                        if(obs_vy_list[i]==0)scaley=0;
     1445                        relativex[i]=scalex*(vx_list[i]-obs_vx_list[i]);
     1446                        relativey[i]=scaley*(vy_list[i]-obs_vy_list[i]);
     1447                }
     1448        }
     1449        else if(fit==2){
     1450                /*We are using a logarithmic misfit: */
     1451                for (i=0;i<numgrids;i++){
     1452                        velocity_mag=sqrt(pow(vx_list[i],2)+pow(vy_list[i],2))+epsvel; //epsvel to avoid velocity being nil.
     1453                        obs_velocity_mag=sqrt(pow(obs_vx_list[i],2)+pow(obs_vy_list[i],2))+epsvel; //epsvel to avoid observed velocity being nil.
     1454                        scale=8*pow(meanvel,2)/pow(velocity_mag,2)*log(velocity_mag/obs_velocity_mag);
     1455                        logarithmicx[i]=scale*vx_list[i];
     1456                        logarithmicy[i]=scale*vy_list[i];
     1457                }
     1458        }
     1459        else{
     1460                /*Not supported yet! : */
     1461                throw ErrorException(__FUNCT__,exprintf("%s%g","unsupported type of fit: ",fit));
     1462        }
    14321463       
    14331464        /* Get gaussian points and weights (make this a statically initialized list of points? fstd): */
     
    14791510                        /*We are using an absolute misfit: */
    14801511                        for (i=0;i<numgrids;i++){
    1481                                 due_g_gaussian[i*NDOF2+0]=(velocity_x-obs_velocity_x)*Jdet*gauss_weight*l1l2l3[i];
    1482                                 due_g_gaussian[i*NDOF2+1]=(velocity_y-obs_velocity_y)*Jdet*gauss_weight*l1l2l3[i];
     1512                                due_g_gaussian[i*NDOF2+0]=absolutex[i]*Jdet*gauss_weight*l1l2l3[i];
     1513                                due_g_gaussian[i*NDOF2+1]=absolutey[i]*Jdet*gauss_weight*l1l2l3[i];
    14831514                        }
    14841515                }
     
    14901521                        if(obs_velocity_y==0)scaley=0;
    14911522                        for (i=0;i<numgrids;i++){
    1492                                 due_g_gaussian[i*NDOF2+0]=scalex*(velocity_x-obs_velocity_x)*Jdet*gauss_weight*l1l2l3[i];
    1493                                 due_g_gaussian[i*NDOF2+1]=scaley*(velocity_y-obs_velocity_y)*Jdet*gauss_weight*l1l2l3[i];
     1523                                due_g_gaussian[i*NDOF2+0]=relativex[i]*Jdet*gauss_weight*l1l2l3[i];
     1524                                due_g_gaussian[i*NDOF2+1]=relativey[i]*Jdet*gauss_weight*l1l2l3[i];
    14941525                        }
    14951526                }
    14961527                else if(fit==2){
    1497 
    14981528                        /*We are using a logarithmic misfit: */
    14991529                        velocity_mag=sqrt(pow(velocity_x,2)+pow(velocity_y,2))+epsvel; //epsvel to avoid velocity being nil.
     
    15011531                        scale=8*pow(meanvel,2)/pow(velocity_mag,2)*log(velocity_mag/obs_velocity_mag);
    15021532                        for (i=0;i<numgrids;i++){
    1503                                 due_g_gaussian[i*NDOF2+0]=scale*velocity_x*Jdet*gauss_weight*l1l2l3[i];
    1504                                 due_g_gaussian[i*NDOF2+1]=scale*velocity_y*Jdet*gauss_weight*l1l2l3[i];
     1533                                due_g_gaussian[i*NDOF2+0]=logarithmicx[i]*Jdet*gauss_weight*l1l2l3[i];
     1534                                due_g_gaussian[i*NDOF2+1]=logarithmicy[i]*Jdet*gauss_weight*l1l2l3[i];
    15051535                        }
    15061536                }
     
    15101540                }
    15111541               
    1512                
    15131542                /*Add due_g_gaussian vector to due_g: */
    15141543                for( i=0; i<numdofs; i++){
     
    15161545                }
    15171546        }
    1518        
    15191547       
    15201548        /*Add due_g to global vector du_g: */
     
    21272155                                        &Ke_gg_gaussian[0][0],0);
    21282156
     2157               
    21292158                /* Add the Ke_gg_gaussian, and optionally Ke_gg_drag_gaussian onto Ke_gg: */
    21302159                for( i=0; i<numdofs; i++) for(j=0;j<numdofs;j++) Ke_gg[i][j]+=Ke_gg_gaussian[i][j];
     
    23562385                /*Get bed slope: */
    23572386                GetParameterDerivativeValue(&slope[0], &b[0],&xyz_list[0][0], gauss_l1l2l3);
    2358                 dbdx=slope[0];
    2359                 dbdy=slope[1];
     2387                dbdx=-slope[0];
     2388                dbdy=-slope[1];
    23602389
    23612390                /* Get Jacobian determinant: */
Note: See TracChangeset for help on using the changeset viewer.