Changeset 24023


Ignore:
Timestamp:
06/17/19 02:41:45 (6 years ago)
Author:
Mathieu Morlighem
Message:

CHG: fixing some memory leaks and extrude melt rate

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

Legend:

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

    r24014 r24023  
    21722172void       Element::Ismip6FloatingiceMeltingRate(){/*{{{*/
    21732173
    2174         if(!this->IsIceInElement() || !this->IsFloating()) return;
    2175 
    2176         const int NUM_VERTICES = this->GetNumberOfVertices();
     2174        if(!this->IsIceInElement() || !this->IsFloating() || !this->IsOnBase()) return;
    21772175
    21782176        int         basinid,num_basins,M,N;
    21792177        IssmDouble  tf,gamma0,base,delta_t_basin,mean_tf_basin,absval;
    2180         IssmDouble* basalmeltrate = xNew<IssmDouble>(NUM_VERTICES);
    21812178        bool        islocal;
    21822179        IssmDouble* delta_t = NULL;
    21832180        IssmDouble* mean_tf = NULL;
    21842181        IssmDouble* depths  = NULL;
     2182
     2183        /*Allocate some arrays*/
     2184        const int numvertices = this->GetNumberOfVertices();
     2185        IssmDouble* basalmeltrate = xNew<IssmDouble>(numvertices);
    21852186
    21862187        /*Get variables*/
     
    22082209        /*Compute melt rate for Local and Nonlocal parameterizations*/
    22092210        Gauss* gauss=this->NewGauss();
    2210         for(int i=0;i<NUM_VERTICES;i++){
     2211        for(int i=0;i<numvertices;i++){
    22112212                gauss->GaussVertex(i);
    22122213                tf_input->GetInputValue(&tf,gauss);
     
    22142215                        absval = mean_tf_basin+delta_t_basin;
    22152216                        if (absval<0) {absval = -1.*absval;}
    2216                         basalmeltrate[i] = gamma0*pow((rhow*cp)/(rhoi*lf),2)*(tf+delta_t_basin)*absval;}
    2217                 else {basalmeltrate[i] = gamma0*pow((rhow*cp)/(rhoi*lf),2)*pow(max(tf+delta_t_basin,0.),2);}
     2217                        basalmeltrate[i] = gamma0*pow((rhow*cp)/(rhoi*lf),2)*(tf+delta_t_basin)*absval;
     2218                }
     2219                else{
     2220                        basalmeltrate[i] = gamma0*pow((rhow*cp)/(rhoi*lf),2)*pow(max(tf+delta_t_basin,0.),2);
     2221                }
    22182222        }
    22192223
     
    22262230        xDelete<IssmDouble>(mean_tf);
    22272231        xDelete<IssmDouble>(depths);
     2232        xDelete<IssmDouble>(basalmeltrate);
    22282233
    22292234}/*}}}*/
  • issm/trunk-jpl/src/c/cores/bmb_core.cpp

    r23460 r24023  
    3535        /*Call module now*/
    3636        FloatingiceMeltingRatex(femmodel);
     37
     38        /*Extrude basal melt*/
     39        femmodel->parameters->SetParam(BasalforcingsFloatingiceMeltingRateEnum,InputToExtrudeEnum);
     40        extrudefrombase_core(femmodel);
    3741}
  • issm/trunk-jpl/src/c/modules/FloatingiceMeltingRatex/FloatingiceMeltingRatex.cpp

    r24022 r24023  
    154154                for(int i=0;i<femmodel->elements->Size();i++){
    155155                        Element* element=xDynamicCast<Element*>(femmodel->elements->GetObjectByOffset(i));
    156                         if(!element->IsOnBase()) continue;
     156                        if(!element->IsOnBase() || !element->IsIceInElement() || !element->IsFloating()) continue;
    157157                        /*Spawn basal element if on base to compute element area*/
    158158                        Element* basalelement = element->SpawnBasalElement();
    159                         if(!basalelement->IsIceInElement() || !basalelement->IsFloating()) continue;
    160159                        Input* tf_input=basalelement->GetInput(BasalforcingsIsmp6TfShelfEnum); _assert_(tf_input);
    161160                        basalelement->inputs->GetInputValue(&basinid,BasalforcingsIsmp6BasinIdEnum);
Note: See TracChangeset for help on using the changeset viewer.