Changeset 18491


Ignore:
Timestamp:
09/10/14 09:12:28 (11 years ago)
Author:
abuzzi
Message:

CNG: code more constrained

File:
1 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified issm/trunk-jpl/src/m/contrib/gravity/vfsa_mpi.cpp

    r18479 r18491  
    169169        // Pp->Echo();
    170170
    171         double  rhoi = 890;           /* ice density     */
     171        double  rhoi = 917;           /* ice density     */
    172172        double  rhow = 1030;          /* water density   */
    173173        // double  rhos = 2013;               /* sediment density */
     
    186186
    187187        double ctr=1;            /* parameter for filtering */
    188         double sd=0.1;
     188        double sd=0.5;
    189189
    190190        Matrix *xobs= new Matrix(ny,nx);
     
    669669        Matrix* m1grsm=new Matrix(my,mx);
    670670        Matrix* m1col=new Matrix(mx*my,1);
     671        Matrix* m1gr2=new Matrix(my,mx);
     672        Matrix* m1grsm2=new Matrix(my,mx);
     673        Matrix* m1col2=new Matrix(mx*my,1);
     674        Matrix* nptflag= new Matrix(mx*my,1);
    671675        double u=0;
    672676        double y=0;
    673677        m1->MatrixEqual(m0);
     678        nptflag->MatrixSum(icethick,bathy);
     679        /* first layer: ice */
    674680        for (int i=0;i<mx*my;i++){
    675                 if(icethick->GetValue(i,0)==0){
    676                         u=double (rand())/ double(RAND_MAX);
     681                if(nptflag->GetValue(i,0)==0){
     682                        u=double(rand())/double(RAND_MAX);
    677683                        y=signe(u-0.5)*T*(pow(1+1/T,fabs(2*u-1))-1);
    678684                        m1->SetValue(i,1,m0->GetValue(i,1)+y*ptval);
     685                        m1->SetValue(i,2,m1->GetValue(i,1)+1e-10);
    679686                        if(m1->GetValue(i,1)<=m1->GetValue(i,0)){
    680687                                m1->SetValue(i,1,m1->GetValue(i,0)+1e-10);
     688                                m1->SetValue(i,2,m1->GetValue(i,1)+1e-10);
    681689                        }
    682690                        if(m1->GetValue(i,1)>=m1->GetValue(i,0)+mmax){
    683691                                m1->SetValue(i,1,m1->GetValue(i,0)+mmax);
    684                         }
    685                 }
    686         }
     692                                m1->SetValue(i,2,m1->GetValue(i,1)+1e-10);
     693                        }
     694                }
     695        }
     696
    687697        m1->ExtractColumn(m1col,1);
    688698        vec2gridsimple(m1col,m1gr,mx,my);
    689699        filtergrav(m1grsm,m1gr,ctr,sd,mx,my);
    690700        reshape(m1grsm,m1col,mx,my);
     701        m1->ExtractColumn(m1col2,2);
     702        vec2gridsimple(m1col2,m1gr2,mx,my);
     703        filtergrav(m1grsm2,m1gr2,ctr,sd,mx,my);
     704        reshape(m1grsm2,m1col2,mx,my);
     705
    691706        for (int i=0;i<mx*my;i++){
    692                 if(icethick->GetValue(i,0)==0){
     707                if(nptflag->GetValue(i,0)==0){
    693708                        m1->SetValue(i,1,m1col->GetValue(i,0));
     709                        m1->SetValue(i,2,m1col2->GetValue(i,0));
     710                        if(m1->GetValue(i,1)<m1->GetValue(i,0)){
     711                                m1->SetValue(i,1,m1->GetValue(i,0)+1e-10);
     712                                m1->SetValue(i,2,m1->GetValue(i,1)+1e-10);
     713                        }
    694714                }
    695715                else{
    696716                        m1->SetValue(i,1,m0->GetValue(i,1));
    697                 }
    698                 if(m1->GetValue(i,1)<=m1->GetValue(i,0)){
    699                         m1->SetValue(i,1,m1->GetValue(i,0)+1e-10);
    700                 }
    701         }
    702 
    703         for (int i=0;i<mx*my;i++){
    704                 if(bathy->GetValue(i,0)==0){
    705                         u=double (rand())/ double(RAND_MAX);
    706                         y=signe(u-0.5)*T*(pow(1+1/T,fabs(2*u-1))-1);
    707                         m1->SetValue(i,2,m0->GetValue(i,2)+y*ptval);
    708                         if(m1->GetValue(i,2)<=m1->GetValue(i,1)){
    709                                 m1->SetValue(i,2,m1->GetValue(i,1)+1e-10);
    710                         }
    711                         if(m1->GetValue(i,2)>=m1->GetValue(i,1)+mmax2){
    712                                 m1->SetValue(i,2,m1->GetValue(i,1)+mmax2);
    713                         }
    714                 }
    715         }
    716         m1->ExtractColumn(m1col,2);
    717         vec2gridsimple(m1col,m1gr,mx,my);
    718         filtergrav(m1grsm,m1gr,ctr,sd,mx,my);
    719         reshape(m1grsm,m1col,mx,my);
    720         for (int i=0;i<mx*my;i++){
    721                 if(bathy->GetValue(i,0)==0){
    722                         m1->SetValue(i,2,m1col->GetValue(i,0));
    723                 }
    724                 else{
    725717                        m1->SetValue(i,2,m0->GetValue(i,2));
    726718                }
    727                 if(m1->GetValue(i,2)<=m1->GetValue(i,1)){
    728                         m1->SetValue(i,2,m1->GetValue(i,1)+1e-10);
    729                 }
    730         }
     719        }
     720
     721                                /* second layer: water */
     722//      for (int i=0;i<mx*my;i++){
     723//              if(bathy->GetValue(i,0)==0){
     724//                      u=double (rand())/ double(RAND_MAX);
     725//                      y=signe(u-0.5)*T*(pow(1+1/T,fabs(2*u-1))-1);
     726//                      m1->SetValue(i,2,m0->GetValue(i,2)+y*ptval);
     727//                      if(m1->GetValue(i,2)<=m1->GetValue(i,1)){
     728//                              m1->SetValue(i,2,m1->GetValue(i,1)+1e-10);
     729//                      }
     730//                      if(m1->GetValue(i,2)>=m1->GetValue(i,1)+mmax2){
     731//                              m1->SetValue(i,2,m1->GetValue(i,1)+mmax2);
     732//                      }
     733//              }
     734//      }
     735//      m1->ExtractColumn(m1col,2);
     736//      vec2gridsimple(m1col,m1gr,mx,my);
     737//      filtergrav(m1grsm,m1gr,ctr,sd,mx,my);
     738//      reshape(m1grsm,m1col,mx,my);
     739//      for (int i=0;i<mx*my;i++){
     740//              if(bathy->GetValue(i,0)==0){
     741//                      m1->SetValue(i,2,m1col->GetValue(i,0));
     742//              }
     743//              else{
     744//                      m1->SetValue(i,2,m0->GetValue(i,2));
     745//              }
     746//              if(m1->GetValue(i,2)<=m1->GetValue(i,1)){
     747//                      m1->SetValue(i,2,m1->GetValue(i,1)+1e-10);
     748//              }
     749//      }
    731750        delete m1gr;
    732751        delete m1grsm;
    733752        delete m1col;
     753        delete m1gr2;
     754        delete m1grsm2;
     755        delete m1col2;
     756        delete nptflag;
    734757}/*}}}*/
    735758double signe(double a){/*{{{*/
Note: See TracChangeset for help on using the changeset viewer.