Changeset 24373


Ignore:
Timestamp:
11/20/19 17:37:35 (5 years ago)
Author:
Mathieu Morlighem
Message:

BUG: fixed problem with calving rate

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

Legend:

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

    r24335 r24373  
    11#ifdef HAVE_CONFIG_H
    2    #include <config.h>
     2#include <config.h>
    33#else
    44#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
     
    435435
    436436                        case CalvingDev2Enum:
    437                                 {
    438                                 lsf_slopex_input->GetInputValue(&dlsf[0],gauss);
    439                                 if(dim==2) lsf_slopey_input->GetInputValue(&dlsf[1],gauss);
    440                                 calvingrate_input->GetInputValue(&calvingrate,gauss);
    441                                 meltingrate_input->GetInputValue(&meltingrate,gauss);
    442                                 gr_input->GetInputValue(&groundedice,gauss);
    443 
    444                                 //idea: no retreat on ice above critical calving height "calvinghaf" . Limit using regularized Heaviside function.
    445                                 vel=sqrt(v[0]*v[0] + v[1]*v[1]);
    446                                 haf_eps=10.;
    447                                 if(groundedice-calvinghaf<=-haf_eps){
    448                                         // ice floats freely below calvinghaf: calve freely
    449                                         // undercutting has no effect:
    450                                         meltingrate=0.;
    451                                 }
    452                                 else if(groundedice-calvinghaf>=haf_eps){
    453                                         // ice is well above calvinghaf -> no calving back, i.e. limit calving rate to ice velocity
    454                                         calvingrate=min(calvingrate,vel);
    455                                         // ice is almost grounded: frontal undercutting has maximum effect (do nothing).
    456                                 }
    457                                 else{ // ice is close to calvinghaf: smooth transition between limitation and free calving.
    458                                         //heaviside: 0 for floating, 1 for grounded
    459                                         heaviside=(groundedice-calvinghaf+haf_eps)/(2.*haf_eps) + sin(PI*(groundedice-calvinghaf)/haf_eps)/(2.*PI);
    460                                         calvingrate=heaviside*(min(calvingrate,vel)-calvingrate)+calvingrate;
    461                                         meltingrate=heaviside*meltingrate+0.;
    462                                 }
    463 
    464                                 norm_dlsf=0.;
    465                                 for(i=0;i<dim;i++) norm_dlsf+=pow(dlsf[i],2);
    466                                 norm_dlsf=sqrt(norm_dlsf);
    467 
    468                                 if(norm_dlsf>1.e-10)
    469                                 for(i=0;i<dim;i++){
    470                                         c[i]=calvingrate*dlsf[i]/norm_dlsf;
    471                                         m[i]=meltingrate*dlsf[i]/norm_dlsf;
    472                                 }
    473                                 else
    474                                 for(i=0;i<dim;i++){
    475                                         c[i]=0.;
    476                                         m[i]=0.;
    477                                 }
    478                                 break;
    479                                 }
     437                                  {
     438                                        lsf_slopex_input->GetInputValue(&dlsf[0],gauss);
     439                                        if(dim==2) lsf_slopey_input->GetInputValue(&dlsf[1],gauss);
     440                                        calvingrate_input->GetInputValue(&calvingrate,gauss);
     441                                        meltingrate_input->GetInputValue(&meltingrate,gauss);
     442                                        gr_input->GetInputValue(&groundedice,gauss);
     443
     444                                        //idea: no retreat on ice above critical calving height "calvinghaf" . Limit using regularized Heaviside function.
     445                                        vel=sqrt(v[0]*v[0] + v[1]*v[1]);
     446                                        haf_eps=10.;
     447                                        if(groundedice-calvinghaf<=-haf_eps){
     448                                                // ice floats freely below calvinghaf: calve freely
     449                                                // undercutting has no effect:
     450                                                meltingrate=0.;
     451                                        }
     452                                        else if(groundedice-calvinghaf>=haf_eps){
     453                                                // ice is well above calvinghaf -> no calving back, i.e. limit calving rate to ice velocity
     454                                                calvingrate=min(calvingrate,vel);
     455                                                // ice is almost grounded: frontal undercutting has maximum effect (do nothing).
     456                                        }
     457                                        else{ // ice is close to calvinghaf: smooth transition between limitation and free calving.
     458                                                //heaviside: 0 for floating, 1 for grounded
     459                                                heaviside=(groundedice-calvinghaf+haf_eps)/(2.*haf_eps) + sin(PI*(groundedice-calvinghaf)/haf_eps)/(2.*PI);
     460                                                calvingrate=heaviside*(min(calvingrate,vel)-calvingrate)+calvingrate;
     461                                                meltingrate=heaviside*meltingrate+0.;
     462                                        }
     463
     464                                        norm_dlsf=0.;
     465                                        for(i=0;i<dim;i++) norm_dlsf+=pow(dlsf[i],2);
     466                                        norm_dlsf=sqrt(norm_dlsf);
     467
     468                                        if(norm_dlsf>1.e-10)
     469                                        for(i=0;i<dim;i++){
     470                                                c[i]=calvingrate*dlsf[i]/norm_dlsf;
     471                                                m[i]=meltingrate*dlsf[i]/norm_dlsf;
     472                                        }
     473                                        else
     474                                        for(i=0;i<dim;i++){
     475                                                c[i]=0.;
     476                                                m[i]=0.;
     477                                        }
     478                                        break;
     479                                  }
    480480
    481481                        default:
     
    518518                        case 2:
    519519                                  {
    520                                 /* Streamline Upwinding */
    521                                 basalelement->ElementSizes(&hx,&hy,&hz);
    522                                 h=sqrt( pow(hx*w[0]/vel,2) + pow(hy*w[1]/vel,2) );
    523                                 IssmDouble D[9];
    524                                 for(row=0;row<dim;row++)
    525                                         for(col=0;col<dim;col++)
    526                                                 D[row*dim+col] = D_scalar*h/(2.*vel)*w[row]*w[col];
    527                                 GetBprime(Bprime,basalelement,xyz_list,gauss);
    528 
    529                                 TripleMultiply(Bprime,dim,numnodes,1,
    530                                                         &D[0],dim,dim,0,
    531                                                         Bprime,dim,numnodes,0,
    532                                                         &Ke->values[0],1);
     520                                        /* Streamline Upwinding */
     521                                        basalelement->ElementSizes(&hx,&hy,&hz);
     522                                        h=sqrt( pow(hx*w[0]/vel,2) + pow(hy*w[1]/vel,2) );
     523                                        IssmDouble D[9];
     524                                        for(row=0;row<dim;row++)
     525                                         for(col=0;col<dim;col++)
     526                                          D[row*dim+col] = D_scalar*h/(2.*vel)*w[row]*w[col];
     527                                        GetBprime(Bprime,basalelement,xyz_list,gauss);
     528
     529                                        TripleMultiply(Bprime,dim,numnodes,1,
     530                                                                &D[0],dim,dim,0,
     531                                                                Bprime,dim,numnodes,0,
     532                                                                &Ke->values[0],1);
    533533                                  }
    534534                                break;
     
    669669        norm_b=0.;
    670670        for(i=0;i<dim;i++)
    671                 norm_b+=b[i]*b[i];
     671         norm_b+=b[i]*b[i];
    672672        norm_b=sqrt(norm_b);
    673673        _assert_(norm_b>0.);
  • issm/trunk-jpl/src/c/classes/Elements/Penta.cpp

    r24368 r24373  
    170170        if(!IsOnBase()) return;
    171171        else{
    172                 if(interpolation_enum==P1Enum){
     172                if(interpolation_enum==P1Enum || interpolation_enum==P1DGEnum){
    173173                        IssmDouble extrudedvalues[NUMVERTICES];
    174174                        for(int i=0;i<NUMVERTICES2D;i++){
     
    178178                        Penta* penta=this;
    179179                        for(;;){
    180                                 penta->AddInput2(input_enum,&extrudedvalues[0],P1Enum);
     180                                penta->AddInput2(input_enum,&extrudedvalues[0],interpolation_enum);
    181181                                if (penta->IsOnSurface()) break;
    182182                                penta=penta->GetUpperPenta(); _assert_(penta->Id()!=this->id);
     
    382382
    383383        /*Add input*/
    384         this->AddInput2(CalvingratexEnum,&calvingratex[0],P1DGEnum);
    385         this->AddInput2(CalvingrateyEnum,&calvingratey[0],P1DGEnum);
    386         this->AddInput2(CalvingCalvingrateEnum,&calvingrate[0],P1DGEnum);
    387         this->AddInput2(SigmaVMEnum,&sigma_vm[0],P1DGEnum);
     384        this->AddBasalInput2(CalvingratexEnum,&calvingratex[0],P1DGEnum);
     385        this->AddBasalInput2(CalvingrateyEnum,&calvingratey[0],P1DGEnum);
     386        this->AddBasalInput2(CalvingCalvingrateEnum,&calvingrate[0],P1DGEnum);
     387        this->AddBasalInput2(SigmaVMEnum,&sigma_vm[0],P1DGEnum);
    388388
    389389        this->InputExtrude(CalvingratexEnum,-1);
     
    441441
    442442        /*Add input*/
    443         this->AddInput2(CalvingratexEnum,&calvingratex[0],P1DGEnum);
    444         this->AddInput2(CalvingrateyEnum,&calvingratey[0],P1DGEnum);
    445         this->AddInput2(CalvingCalvingrateEnum,&calvingrate[0],P1DGEnum);
     443        this->AddBasalInput2(CalvingratexEnum,&calvingratex[0],P1DGEnum);
     444        this->AddBasalInput2(CalvingrateyEnum,&calvingratey[0],P1DGEnum);
     445        this->AddBasalInput2(CalvingCalvingrateEnum,&calvingrate[0],P1DGEnum);
    446446
    447447        /*Clean up and return*/
  • issm/trunk-jpl/src/c/classes/Inputs2/PentaInput2.cpp

    r24335 r24373  
    110110        if(isserved){
    111111                _printf_("   current values:      ");
    112                 _printf_("[ ");
    113                 for(int i=0;i<6;i++) _printf_(" "<<this->element_values[i]);
    114                 _printf_("] ("<<EnumToStringx(this->interpolation)<<")\n");
     112                if(isserved_collapsed){
     113                        _printf_("[ ");
     114                        for(int i=0;i<6;i++) _printf_(" "<<this->element_values[i]);
     115                        _printf_("] ("<<EnumToStringx(this->interpolation)<<")\n");
     116                }
     117                else{
     118                        _printf_("[ ");
     119                        for(int i=0;i<3;i++) _printf_(" "<<this->element_values[i]);
     120                        _printf_("] ("<<EnumToStringx(this->interpolation)<<")\n");
     121                }
    115122        }
    116123}
     
    240247        if(state==1){
    241248                for(int i=0;i<3;i++) this->element_values[i] = this->values[row*this->N+i];
     249                for(int i=3;i<6;i++) this->element_values[i] = 0.;
    242250        }
    243251        else if(state==2){
    244252                for(int i=0;i<3;i++) this->element_values[i] = this->values[row*this->N+3+i];
     253                for(int i=3;i<6;i++) this->element_values[i] = 0.;
    245254        }
    246255        else{
Note: See TracChangeset for help on using the changeset viewer.