Changeset 20029


Ignore:
Timestamp:
01/30/16 14:51:22 (9 years ago)
Author:
Eric.Larour
Message:

CHG: do not compute G_elastic if we are not in elastic mode.
Also, avoid singularity due to discretization of low incidence angles.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/c/analyses/SealevelriseAnalysis.cpp

    r20028 r20029  
    4343        IssmDouble* love_k=NULL;
    4444       
     45        bool elastic=false;
    4546        IssmDouble* G_elastic = NULL;
    4647        int         M;
     
    5455        parameters->AddObject(iomodel->CopyConstantObject(SealevelriseEustaticEnum));
    5556
    56         /*love numbers: */
    57         iomodel->FetchData(&love_h,&nl,NULL,SealevelriseLoveHEnum);
    58         iomodel->FetchData(&love_k,&nl,NULL,SealevelriseLoveKEnum);
     57        iomodel->FetchData(&elastic,SealevelriseElasticEnum);
     58        if(elastic){
    5959
    60         /*compute elastic green function for a range of angles*/
    61         const IssmDouble degacc=.01; M=reCast<int>(180/degacc+1);
    62         G_elastic=xNew<IssmDouble>(M);
    63        
    64         /*compute combined legendre + love number (elastic green function:*/
    65         for(int i=0;i<M;i++){ //watch out the <=
    66                 IssmDouble alpha,x;
    67                 alpha= reCast<IssmDouble>(i)*degacc * PI / 180.0;
    68                
    69                 G_elastic[i]= (love_k[nl-1]-love_h[nl-1])/2.0/sin(alpha/2.0);
    70                 for (int n=0;n<nl;n++) {
    71                         IssmDouble Pn,Pn1,Pn2;
    72                         IssmDouble deltalove;
    73                        
    74                         deltalove = (love_k[n]-love_k[nl-1]-love_h[n]+love_h[nl-1]);
     60                /*love numbers: */
     61                iomodel->FetchData(&love_h,&nl,NULL,SealevelriseLoveHEnum);
     62                iomodel->FetchData(&love_k,&nl,NULL,SealevelriseLoveKEnum);
    7563
    76                         if(n==0)Pn=1;
    77                         else if(n==1)Pn=cos(alpha);
    78                         else Pn= ( (2*n-1)*cos(alpha)*Pn1 - (n-1)*Pn2 ) /n;
    79                         Pn2=Pn1; Pn1=Pn;
     64                /*compute elastic green function for a range of angles*/
     65                const IssmDouble degacc=.01; M=reCast<int>(180/degacc+1);
     66                G_elastic=xNew<IssmDouble>(M);
    8067
    81                         G_elastic[i] += deltalove*Pn;
     68                /*compute combined legendre + love number (elastic green function:*/
     69                for(int i=0;i<M;i++){ //watch out the <=
     70                        IssmDouble alpha,x;
     71                        alpha= reCast<IssmDouble>(i)*degacc * PI / 180.0;
     72
     73                        G_elastic[i]= (love_k[nl-1]-love_h[nl-1])/2.0/sin(alpha/2.0);
     74                        for (int n=0;n<nl;n++) {
     75                                IssmDouble Pn,Pn1,Pn2;
     76                                IssmDouble deltalove;
     77
     78                                deltalove = (love_k[n]-love_k[nl-1]-love_h[n]+love_h[nl-1]);
     79
     80                                if(n==0)Pn=1;
     81                                else if(n==1)Pn=cos(alpha);
     82                                else Pn= ( (2*n-1)*cos(alpha)*Pn1 - (n-1)*Pn2 ) /n;
     83                                Pn2=Pn1; Pn1=Pn;
     84
     85                                G_elastic[i] += deltalove*Pn;
     86                        }
    8287                }
     88
     89                /*Avoid singularity at 0: */
     90                G_elastic[0]=G_elastic[1];
     91                parameters->AddObject(new DoubleVecParam(SealevelriseGElasticEnum,G_elastic,M));
     92
     93                /*free ressources:*/
     94                xDelete<IssmDouble>(G_elastic);
     95
     96                /*free ressources: */
     97                xDelete<IssmDouble>(love_h);
     98                xDelete<IssmDouble>(love_k);
     99                xDelete<IssmDouble>(G_elastic);
    83100        }
    84         parameters->AddObject(new DoubleVecParam(SealevelriseGElasticEnum,G_elastic,M));
    85 
    86         /*free ressources:*/
    87         xDelete<IssmDouble>(G_elastic);
    88 
    89         /*free ressources: */
    90         xDelete<IssmDouble>(love_h);
    91         xDelete<IssmDouble>(love_k);
    92         xDelete<IssmDouble>(G_elastic);
    93101
    94102}/*}}}*/
Note: See TracChangeset for help on using the changeset viewer.