Changeset 26601


Ignore:
Timestamp:
11/10/21 18:30:41 (3 years ago)
Author:
Mathieu Morlighem
Message:

CHG: better way if fixing friction singularity when v=0

File:
1 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/c/classes/Loads/Friction.cpp

    r26585 r26601  
    197197        IssmDouble vmag = VelMag(gauss);
    198198
    199         /*Check to prevent dividing by zero if vmag==0*/
    200         if(vmag==0. && (s-1.)<=0.) alpha_complement=0.;
    201         else alpha_complement=pow(Neff,r)*pow(vmag,(s-1));
     199        if(s==1.){
     200                /*This is to make AD happy and avoid 0^0*/
     201                alpha_complement=pow(Neff,r);
     202        }
     203        else{
     204                /*Check to prevent dividing by zero if vmag==0*/
     205                if(vmag==0. && (s-1.)<0.) alpha_complement=0.;
     206                else alpha_complement=pow(Neff,r)*pow(vmag,(s-1.));
     207        }
    202208
    203209        /*Assign output pointers:*/
     
    344350        IssmDouble vmag = VelMag(gauss);
    345351
    346         /*Check to prevent dividing by zero if vmag==0*/
    347         if(vmag==0. && (s-1.)<=0.){
    348                 alpha2=0.;
     352        if(s==1.){
     353                /*This is to make AD happy and avoid 0^0*/
     354                alpha2=drag_coefficient*drag_coefficient*pow(Neff,r);
    349355        }
    350356        else{
    351                 alpha2=drag_coefficient*drag_coefficient*pow(Neff,r)*pow(vmag,(s-1.));
     357                /*Check to prevent dividing by zero if vmag==0*/
     358                if(vmag==0. && (s-1.)<0.) alpha2=0.;
     359                else alpha2=drag_coefficient*drag_coefficient*pow(Neff,r)*pow(vmag,(s-1.));
    352360        }
    353361
     
    541549
    542550        /*Check to prevent dividing by zero if vmag==0*/
    543         if(vmag==0. && (s-1.)<=0.) alpha2=0.;
    544         else alpha2=drag_coefficient*drag_coefficient*pow(Neff,r)*pow(vmag,(s-1.));
     551        if(s==1.){
     552                /*This is to make AD happy and avoid 0^0*/
     553                alpha2=drag_coefficient*drag_coefficient*pow(Neff,r);
     554        }
     555        else{
     556                if(vmag==0. && (s-1.)<0.) alpha2=0.;
     557                else alpha2=drag_coefficient*drag_coefficient*pow(Neff,r)*pow(vmag,(s-1.));
     558        }
    545559
    546560        /*Assign output pointers:*/
     
    586600        IssmDouble vmag = VelMag(gauss);
    587601
    588         /*Check to prevent dividing by zero if vmag==0*/
    589         if(vmag==0. && (s-1.)<=0.) alpha2=0.;
    590         else alpha2=drag_coefficient*drag_coefficient*pow(Neff,r)*pow(vmag,(s-1.));
     602        if(s==1.){
     603                /*This is to make AD happy and avoid 0^0*/
     604                alpha2=drag_coefficient*drag_coefficient*pow(Neff,r);
     605        }
     606        else{
     607                /*Check to prevent dividing by zero if vmag==0*/
     608                if(vmag==0. && (s-1.)<0.) alpha2=0.;
     609                else alpha2=drag_coefficient*drag_coefficient*pow(Neff,r)*pow(vmag,(s-1.));
     610        }
    591611
    592612        /*Assign output pointers:*/
Note: See TracChangeset for help on using the changeset viewer.