Changeset 17629


Ignore:
Timestamp:
04/02/14 16:46:22 (11 years ago)
Author:
Mathieu Morlighem
Message:

CHG: fixing Newton algo with first guess

Location:
issm/trunk-jpl/src/c
Files:
3 edited

Legend:

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

    r17628 r17629  
    35523552        xDelete<IssmDouble>(xyz_list);
    35533553        xDelete<IssmDouble>(Dstar);
    3554         xDelete<IssmDouble>(d);
     3554xDelete<IssmDouble>(d);
    35553555        xDelete<IssmDouble>(D);
    35563556        xDelete<IssmDouble>(tau);
     
    42444244        int         dim,tausize,meshtype;
    42454245        IssmDouble  epsxx,epsyy,epszz,epsxy,epsxz,epsyz,D_scalar;
     4246        IssmDouble  epsxx_old,epsyy_old,epszz_old,epsxy_old,epsxz_old,epsyz_old;
    42464247        IssmDouble  sigmapxx,sigmapyy,sigmapzz,sigmapxy,sigmapxz,sigmapyz;
    42474248        IssmDouble  dvx[3],dvy[3],dvz[3],B,n;
     
    42874288                }
    42884289
     4290                /*Get previous d*/
     4291                Input* epsxx_input=element->GetInput(StrainRatexxEnum); _assert_(epsxx_input);
     4292                Input* epsyy_input=element->GetInput(StrainRateyyEnum); _assert_(epsyy_input);
     4293                Input* epsxy_input=element->GetInput(StrainRatexyEnum); _assert_(epsxy_input);
     4294                Input* epszz_input=NULL; Input* epsxz_input=NULL; Input* epsyz_input=NULL;
     4295                if(dim==3){
     4296                        epszz_input=element->GetInput(StrainRatezzEnum); _assert_(epszz_input);
     4297                        epsxz_input=element->GetInput(StrainRatexzEnum); _assert_(epsxz_input);
     4298                        epsyz_input=element->GetInput(StrainRateyzEnum); _assert_(epsyz_input);
     4299                }
     4300
    42894301                /*Get tau*/
    42904302                Input* sigmapxx_input=element->GetInput(DeviatoricStressxxEnum); _assert_(sigmapxx_input);
     
    43124324                                sigmapxz_input->GetInputValue(&sigmapxz,gauss);
    43134325                                sigmapyz_input->GetInputValue(&sigmapyz,gauss);
     4326                        }
     4327
     4328                        /*Get previous d*/
     4329                        epsxx_input->GetInputValue(&epsxx_old,gauss);
     4330                        epsyy_input->GetInputValue(&epsyy_old,gauss);
     4331                        epsxy_input->GetInputValue(&epsxy_old,gauss);
     4332                        if(dim==3){
     4333                                epszz_input->GetInputValue(&epszz_old,gauss);
     4334                                epsxz_input->GetInputValue(&epsxz_old,gauss);
     4335                                epsyz_input->GetInputValue(&epsyz_old,gauss);
    43144336                        }
    43154337
     
    43334355                        B_input->GetInputValue(&B,gauss);
    43344356                        n_input->GetInputValue(&n,gauss);
    4335                         coef1 = (B/2.)*pow(1./sqrt(2.),(1.-n)/n); //2 eta_0
     4357                        coef1 = B*pow(1./sqrt(2.),(1.-n)/n); //2 eta_0 = 2 * B/(2* (1/sqrt(2)  )^(n-1)/n )
    43364358                        coef2 = r;
    43374359                        if(dim==2){
     
    43534375                        }
    43544376                        IssmDouble dnorm;
    4355                         NewtonSolveDnorm(&dnorm,coef1,coef2,coef3,n);
     4377                        if(dim==2){
     4378                                dnorm = sqrt( epsxx_old*epsxx_old + epsyy_old*epsyy_old + 2.*epsxy_old*epsxy_old );
     4379                        }
     4380                        else{
     4381                                dnorm = sqrt( epsxx_old*epsxx_old + epsyy_old*epsyy_old + epszz_old*epszz_old
     4382                                                        +2.*(epsxy_old*epsxy_old + epsxz_old*epsxz_old + epsyz_old*epsyz_old));
     4383                        }
     4384                        NewtonSolveDnorm(&dnorm,coef1,coef2,coef3,n,dnorm);
    43564385
    43574386                        /*Create Ke*/
     
    44124441                IssmDouble* tau_xz = NULL;
    44134442                IssmDouble* tau_yz = NULL;
    4414                 Input* epsxx_input=element->GetInput(StrainRatexxEnum); _assert_(epsxx_input);
    4415                 Input* epsyy_input=element->GetInput(StrainRateyyEnum); _assert_(epsyy_input);
    4416                 Input* epsxy_input=element->GetInput(StrainRatexyEnum); _assert_(epsxy_input);
    4417                 Input* epszz_input=NULL; Input* epsxz_input=NULL; Input* epsyz_input=NULL;
    4418                 if(dim==3){
    4419                         epszz_input=element->GetInput(StrainRatezzEnum); _assert_(epszz_input);
    4420                         epsxz_input=element->GetInput(StrainRatexzEnum); _assert_(epsxz_input);
    4421                         epsyz_input=element->GetInput(StrainRateyzEnum); _assert_(epsyz_input);
    4422                 }
    44234443                delete gauss;
    44244444                gauss = element->NewGauss();
  • issm/trunk-jpl/src/c/shared/Numerics/NewtonSolveDnorm.cpp

    r17553 r17629  
    33#include "../Exceptions/exceptions.h"
    44
    5 int NewtonSolveDnorm(IssmDouble* pdnorm,IssmDouble c1,IssmDouble c2,IssmDouble c3,IssmDouble n){
     5int NewtonSolveDnorm(IssmDouble* pdnorm,IssmDouble c1,IssmDouble c2,IssmDouble c3,IssmDouble n,IssmDouble dnorm){
    66        /* solve the following equation using Newton-Raphson
    77         *
     
    2626
    2727        /*Initial guess*/
    28         IssmDouble y1 = 0.;
     28        IssmDouble y1 = log10(dnorm);
    2929
    3030        while(true){
  • issm/trunk-jpl/src/c/shared/Numerics/numerics.h

    r17546 r17629  
    3838int         cubic(IssmDouble a, IssmDouble b, IssmDouble c, IssmDouble d, double X[3], int *num);
    3939
    40 int         NewtonSolveDnorm(IssmDouble* pdnorm,IssmDouble c1,IssmDouble c2,IssmDouble c3,IssmDouble n);
     40int         NewtonSolveDnorm(IssmDouble* pdnorm,IssmDouble c1,IssmDouble c2,IssmDouble c3,IssmDouble n,IssmDouble dnorm);
    4141
    4242#endif //ifndef _NUMERICS_H_
Note: See TracChangeset for help on using the changeset viewer.