source: issm/oecreview/Archive/17984-18295/ISSM-18223-18224.diff@ 18296

Last change on this file since 18296 was 18296, checked in by Mathieu Morlighem, 11 years ago

Added 17984-18295

File size: 3.9 KB
  • ../trunk-jpl/src/c/analyses/AdjointBalancethickness2Analysis.cpp

     
    4747
    4848        /*Intermediaries */
    4949        int         num_responses,i;
    50         IssmDouble  hobs,hu2,weight,NUMx,NUMy,DEN,Jdet;
    51         IssmDouble  vx,vy,vbar2,nux,nuy,phi,dphi[2];
     50        IssmDouble  hobs,hu2,weight,Jdet;
     51        IssmDouble  NUMxH2,NUMyH2,DENH2;
     52        IssmDouble  NUMxUbar,NUMyUbar,DENUbar;
     53        IssmDouble  vxobs,vyobs,vxobsbar,vyobsbar,vbarobs2,vbarobs;
     54        IssmDouble  nux,nuy,phi,dphi[2];
    5255        int        *responses = NULL;
    5356        IssmDouble *xyz_list  = NULL;
    5457
     
    6770        Input* thicknessobs_input = element->GetInput(InversionThicknessObsEnum);              _assert_(thicknessobs_input);
    6871        Input* weights_input      = element->GetInput(InversionCostFunctionsCoefficientsEnum); _assert_(weights_input);
    6972        Input* potential_input = element->GetInput(PotentialEnum);             _assert_(potential_input);
    70         Input* vx_input        = element->GetInput(BalancethicknessVxObsEnum); _assert_(vx_input);
    71         Input* vy_input        = element->GetInput(BalancethicknessVyObsEnum); _assert_(vy_input);
     73        Input* vxobs_input     = element->GetInput(BalancethicknessVxObsEnum); _assert_(vxobs_input);
     74        Input* vyobs_input     = element->GetInput(BalancethicknessVyObsEnum); _assert_(vyobs_input);
    7275        Input* nux_input       = element->GetInput(BalancethicknessNuxEnum);   _assert_(nux_input);
    7376        Input* nuy_input       = element->GetInput(BalancethicknessNuyEnum);   _assert_(nuy_input);
    7477
     
    8184                element->NodalFunctions(basis,gauss);
    8285                element->NodalFunctionsDerivatives(dbasis,xyz_list,gauss);
    8386
    84                 vx_input->GetInputValue(&vx,gauss);
    85                 vy_input->GetInputValue(&vy,gauss);
     87                vxobs_input->GetInputValue(&vxobs,gauss);
     88                vyobs_input->GetInputValue(&vyobs,gauss);
    8689                nux_input->GetInputValue(&nux,gauss);
    8790                nuy_input->GetInputValue(&nuy,gauss);
    8891                potential_input->GetInputValue(&phi,gauss);
    8992                potential_input->GetInputDerivativeValue(&dphi[0],xyz_list,gauss);
    9093                thicknessobs_input->GetInputValue(&hobs,gauss);
    9194
    92                 vbar2 = (nux*nux*vx*vx + nuy*nuy*vy*vy);
    93                 hu2 = hobs*hobs*vbar2;
     95                vxobsbar = nux*vxobs;
     96                vyobsbar = nuy*vyobs;
    9497
    95                 NUMx = 2.*dbasis[0]*dphi[0]*(dphi[0]*dphi[0] + dphi[1]*dphi[1] - hu2);
    96                 NUMy = 2.*dbasis[1]*dphi[1]*(dphi[0]*dphi[0] + dphi[1]*dphi[1] - hu2);
    97                 DEN = vbar2*vbar2+1.e-14;
     98                vbarobs2 = (nux*nux*vxobs*vxobs + nuy*nuy*vyobs*vyobs);
     99                vbarobs  = sqrt(vbarobs2);
     100                hu2 = hobs*hobs*vbarobs2;
    98101
     102                /*H^2 - Hobs^2*/
     103                NUMxH2 = 2.*dbasis[0]*dphi[0]*(dphi[0]*dphi[0] + dphi[1]*dphi[1] - hu2);
     104                NUMyH2 = 2.*dbasis[1]*dphi[1]*(dphi[0]*dphi[0] + dphi[1]*dphi[1] - hu2);
     105                DENH2 = vbarobs2*vbarobs2+1.e-14;
     106
     107                /*Ubar-Ubar_obs*/
     108                NUMxUbar = (vyobsbar*dphi[0]*dphi[1] - vxobsbar*dphi[1]*dphi[1])*vbarobs*dbasis[0];
     109                NUMyUbar = (vyobsbar*dphi[0]*dphi[0] - vxobsbar*dphi[0]*dphi[1])*vbarobs*dbasis[1];
     110                DENUbar  = pow(dphi[0]*dphi[0] + dphi[1]*dphi[1],3./2.)+1.e-14;
     111
    99112                /*Loop over all requested responses*/
    100113                for(int resp=0;resp<num_responses;resp++){
    101114                        weights_input->GetInputValue(&weight,gauss,responses[resp]);
    102115
    103116                        switch(responses[resp]){
    104117                                case Balancethickness2MisfitEnum:
    105                                         //for(i=0;i<numnodes;i++) pe->values[i]+=(NUMx+NUMy)/DEN *weight*Jdet*gauss->weight;
    106                                         for(i=0;i<numnodes;i++) pe->values[i]+= phi*basis[i]*weight*Jdet*gauss->weight;
     118                                        /*J = (H^2 - Hobs^2)^2*/
     119                                        //for(i=0;i<numnodes;i++) pe->values[i]+=(NUMxH2+NUMyH2)/DENH2 *weight*Jdet*gauss->weight; NOT WORKING
     120                                        /*J = phi^2*/
     121                                        //for(i=0;i<numnodes;i++) pe->values[i]+= phi*basis[i]*weight*Jdet*gauss->weight; OK
     122                                        /*J = (ubar - nux*uobs)^2*/
     123                                        for(i=0;i<numnodes;i++) pe->values[i]+=(NUMxUbar-NUMyUbar)/DENUbar *weight*Jdet*gauss->weight;
    107124                                        break;
    108125                                default:
    109126                                        _error_("response " << EnumToStringx(responses[resp]) << " not supported yet");
Note: See TracBrowser for help on using the repository browser.