Ignore:
Timestamp:
08/16/12 10:27:48 (13 years ago)
Author:
Mathieu Morlighem
Message:

CHG: working on L1L2, almost there

File:
1 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/c/classes/objects/Elements/Penta.cpp

    r13051 r13064  
    81828182         * A X^3 + A |rho g (s-z) grad(s)|^2 X - |eps_b|_// = 0     */
    81838183
    8184         _error_("Not supported yet");
    81858184        int        i;
    81868185        IssmDouble a,c,d,z,s,viscosity;
     
    82008199        surface_input->GetInputDerivativeValue(&slope[0],xyz_list,gauss);
    82018200        PentaRef::GetInputValue(&z,&z_list[0],gauss);
    8202         tau_perp = matpar->GetRhoIce() * matpar->GetG() * (s-z)*sqrt(slope[0]*slope[0]+slope[1]*slope[1]);
     8201        tau_perp = matpar->GetRhoIce() * matpar->GetG() * fabs(s-z)*sqrt(slope[0]*slope[0]+slope[1]*slope[1]);
    82038202
    82048203        /* Get eps_b*/
     
    82088207        eps_b = sqrt(epsilon[0]*epsilon[0] + epsilon[1]*epsilon[1] + epsilon[0]*epsilon[1] + epsilon[2]*epsilon[2]);
    82098208        if(eps_b==0.){
    8210                 *pviscosity=2.5*pow(10.,17.);
     8209                *pviscosity = 2.5e+17;
    82118210                return;
    82128211        }
     
    82168215        A=matice->GetA();
    82178216
    8218         /*Solve for tau_par (http://en.wikipedia.org/wiki/Cubic_function)*/
    8219         a=A;
    8220         c=A*tau_perp*tau_perp;
    8221         d=-eps_b;
    8222         tau_par = -1./(3.*a) * pow(0.5*(27.*a*a*d + sqrt(27.*a*a*d*27.*a*a*d -4.*pow(-3.*a*c,3.))),1./3.);
    8223 
    8224         //printf("=======================================\n");
    8225         //printf("tau_par = %g (%g=0?)\n",tau_par,a*tau_par*tau_par*tau_par+c*tau_par+d);
    8226         //printf("a=%g c=%g d=%g\n",a,c,d);
    8227         //IssmDouble coeff[4];
    8228         //coeff[0]=d;
    8229         //coeff[1]=c;
    8230         //coeff[2]=0.;
    8231         //coeff[3]=a;
    8232         //int numroots;
    8233         //IssmDouble roots[3];
    8234         //cubic(coeff,roots,&numroots);
    8235         //tau_par=roots[0];
    8236         //for(i=0;i<numroots;i++) printf(" %g ",roots[i]);
     8217        /*Solve for tau_perp*/
     8218        int        numroots;
     8219        IssmDouble roots[3];
     8220        a = A;
     8221        c = A *tau_perp*tau_perp;
     8222        d = - eps_b;
     8223        cubic(a,0.,c,d,roots,&numroots);
     8224        tau_par=roots[0];
    82378225        //printf(" (%g =0?)\n",a*roots[0]*roots[0]*roots[0]+c*roots[0]+d);
    8238        
    82398226
    82408227        /*Viscosity*/
    8241         viscosity = 1./(2.*A)*pow(tau_par*tau_par + tau_perp*tau_perp ,-2.);
     8228        viscosity = 1./(2.*A*(tau_par*tau_par + tau_perp*tau_perp));
     8229        //printf("denom = %g (%g,%g)\n",tau_par*tau_par + tau_perp*tau_perp,tau_par,tau_perp);
    82428230        _assert_(!isnan(viscosity));
    82438231
Note: See TracChangeset for help on using the changeset viewer.