source: issm/oecreview/Archive/21724-22754/ISSM-22469-22470.diff@ 22755

Last change on this file since 22755 was 22755, checked in by Mathieu Morlighem, 7 years ago

CHG: added 21724-22754

File size: 4.7 KB
  • ../trunk-jpl/src/c/classes/Elements/Tria.cpp

     
    811811
    812812                /*Update signed distance*/
    813813                dmin = sqrt(dmin);
    814                 if(dmin>10000) dmin=10000;
     814                // if(dmin>10000) dmin=10000;
    815815                if(ls[j]>0){
    816816                        ls[j] = dmin;
    817817                }
     
    27362736        return TriaRef::NumberofNodes(this->VelocityInterpolation());
    27372737}
    27382738/*}}}*/
     2739void       Tria::PicoUpdateBoxid(int* pmax_boxid_basin){/*{{{*/
     2740
     2741        if(!this->IsIceInElement() || !this->IsFloating()) return;
     2742
     2743        //Load inputs and params
     2744        int i, boxid;
     2745        int basin_id, boxid_max;
     2746        IssmDouble dist_gl;
     2747        IssmDouble dist_cf;
     2748        IssmDouble rel_dist_gl;
     2749
     2750        inputs->GetInputValue(&basin_id,BasalforcingsPicoBasinIdEnum);
     2751        boxid_max=pmax_boxid_basin[basin_id]; //0-based
     2752
     2753        Input* dist_gl_input=NULL;
     2754        Input* dist_cf_input=NULL;
     2755        dist_gl_input=inputs->GetInput(DistanceToGroundinglineEnum); _assert_(dist_gl_input);
     2756        dist_cf_input=inputs->GetInput(DistanceToCalvingfrontEnum); _assert_(dist_cf_input);
     2757
     2758        Gauss* gauss=this->NewGauss(1); gauss->GaussPoint(0);
     2759        dist_gl_input->GetInputValue(&dist_gl,gauss);
     2760        dist_cf_input->GetInputValue(&dist_cf,gauss);
     2761
     2762        rel_dist_gl=dist_gl/(dist_gl+dist_cf);
     2763
     2764        boxid=-1;
     2765        for(i=0;i<boxid_max;i++){
     2766                if(rel_dist_gl>=(1-sqrt((boxid_max-i)/boxid_max)) && rel_dist_gl<=(1-sqrt((boxid_max-i-1)/boxid_max))){
     2767                        boxid=i; break;
     2768                }
     2769        }
     2770        if(boxid==-1){_error_("no boxid found for element" << this->Sid());}
     2771
     2772        this->inputs->AddInput(new IntInput(BasalforcingsPicoBoxIdEnum, boxid));       
     2773
     2774        /*Cleanup & return: */
     2775        delete gauss;
     2776}
     2777/*}}}*/
     2778void       Tria::PicoUpdateFirstBox(){/*{{{*/
     2779
     2780        IssmDouble rhoi, rhow, earth_grav, rho_star, nu, latentheat, c_p_ocean, lambda, a, b, c;
     2781        IssmDouble alpha, Beta, gamma_T, overturning_coeff, t_farocean, s_farocean;
     2782        IssmDouble basinid, boxid, thickness, toc_farocean, soc_farocean, area_box1;
     2783        IssmDouble pressure, T_star, g1, s1, p_coeff, q_coeff, Toc, Soc, potential_pressure_melting_point;
     2784        IssmDouble basalmeltrate_shelf, overturning, maxbox;
     2785
     2786        //Get variables
     2787        rhoi                    = this->GetMaterialParameter(MaterialsRhoIceEnum);
     2788        rhow                    = this->GetMaterialParameter(MaterialsRhoSeawaterEnum);
     2789        earth_grav  = this->GetMaterialParameter(ConstantsGEnum);
     2790        rho_star                = 1033;             //kg/m^3
     2791        nu                              = rhoi/rhow;
     2792        latentheat      = this->GetMaterialParameter(MaterialsLatentheatEnum);
     2793        c_p_ocean       = this->GetMaterialParameter(MaterialsThermalExchangeVelocityEnum);
     2794        lambda          = latentheat/c_p_ocean;
     2795        a                               = -0.0572;          //K/psu
     2796        b                               = 0.0788 + this->GetMaterialParameter(MaterialsMeltingpointEnum);  //K
     2797        c                               = this->GetMaterialParameter(MaterialsBetaEnum);
     2798        alpha                   = 0.000075;         //1/K
     2799        Beta                    = 0.00077;          //K
     2800
     2801        this->parameters->FindParam(&gamma_T,BasalforcingsPicoGammaTEnum);
     2802        this->parameters->FindParam(&overturning_coeff,BasalforcingsPicoOverturningCoeffEnum);
     2803        this->parameters->FindParam(&t_farocean,BasalforcingsPicoFarOceanTemperatureEnum);
     2804        this->parameters->FindParam(&s_farocean,BasalforcingsPicoFarOceanSalinityEnum);
     2805
     2806        this->inputs->GetInputValue(&basinid,BasalforcingsPicoBasinIdEnum);
     2807        this->inputs->GetInputValue(&boxid,BasalforcingsPicoBoxIdEnum);
     2808        this->inputs->GetInputValue(&maxbox,BasalforcingsPicoMaxboxcountEnum);
     2809        this->inputs->GetInputValue(&thickness,ThicknessEnum);
     2810
     2811        toc_farocean = t_farocean[basinid];
     2812        soc_farocean = s_farocean[basinid];
     2813        area_box1 = areas[basinid*maxbox+boxid];
     2814        pressure = (rhoi*earth_grav)*thickness;
     2815        T_star = a*soc_farocean+b-c*pressure-toc_farocean;
     2816        g1 = area_box1*gamma_T;
     2817        s1 = soc_farocean/(nu*lambda);
     2818        p_coeff = g1/(overturning_coeff*rho_star*(Beta*s1-alpha));
     2819        q_coeff = T_star*(g1/(overturning_coeff*rho_star*(Beta*s1-alpha)));
     2820        if ((0.25*(p_coeff)^(2) - q_coeff) < 0)
     2821          {q_coeff = (0.25*(p_coeff)^(2))}
     2822        Toc = toc_farocean-(-0.5*p_coeff+sqrt(0.25*p_coeff^(2)-q_coeff));
     2823        Soc = soc_farocean-(soc_farocean/(nu*lambda))*(toc_farocean-Toc);
     2824        potential_pressure_melting_point = a*Soc+b-c*pressure;
     2825        basalmeltrate_shelf = (-gamma_T/(nu*lambda))*(potential_pressure_melting_point-Toc);
     2826        overturning = overturning_coeff*rho_star*(Beta*(soc_farocean-Soc)-alpha*(toc_farocean-Toc));
     2827
     2828        this->AddInput(BasalforcingsGroundediceMeltingRateEnum,basalmeltingrates,this->GetElementType());
     2829
     2830}
     2831/*}}}*/
    27392832void       Tria::PotentialUngrounding(Vector<IssmDouble>* potential_ungrounding){/*{{{*/
    27402833
    27412834        IssmDouble  h[NUMVERTICES],r[NUMVERTICES],gl[NUMVERTICES];
     
    29673060        /*Get out if this is not an element input*/
    29683061        if(!IsInput(control_enum)) return;
    29693062
    2970         /*Prepare index list*/
     3063        /*hrepare index list*/
    29713064        GradientIndexing(&vertexpidlist[0],control_index);
    29723065
    29733066        /*Get values on vertices*/
Note: See TracBrowser for help on using the repository browser.