Ignore:
Timestamp:
10/17/19 06:03:43 (5 years ago)
Author:
bdef
Message:

Adding a substeping framework in hydro and part of smb

File:
1 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/c/classes/Inputs/TriaInput.cpp

    r24091 r24240  
    126126        SegInput* outinput=NULL;
    127127
    128         if(this->interpolation_type==P0Enum){ 
     128        if(this->interpolation_type==P0Enum){
    129129                outinput=new SegInput(this->enum_type,&this->values[0],P0Enum);
    130130        }
     
    165165}
    166166/*}}}*/
    167 void TriaInput::GetInputAllTimeAverages(IssmDouble** pvalues,IssmDouble** ptimes, int* pnumtimes){/*{{{*/
     167void TriaInput::GetInputAveragesOnAllTime(IssmDouble** pvalues,IssmDouble** ptimes, int* pnumtimes){/*{{{*/
    168168
    169169        IssmDouble* outvalues=NULL;
     
    224224/*}}}*/
    225225
    226 void TriaInput::GetInputUpToCurrentTimeAverages(IssmDouble** pvalues, IssmDouble** ptimes, int* pnumtimes, IssmDouble currenttime){/*{{{*/
     226void TriaInput::GetInputAveragesUpToCurrentTime(IssmDouble** pvalues, IssmDouble** ptimes, int* pnumtimes, IssmDouble currenttime){/*{{{*/
    227227
    228228        IssmDouble* outvalues=NULL;
     
    320320}
    321321/*}}}*/
     322void TriaInput::PointwiseMult(Input* xinput){/*{{{*/
     323
     324        const int numnodes=this->NumberofNodes(this->interpolation_type);
     325        TriaInput* xtriainput=NULL;
     326
     327
     328        /*xinput is of the same type, so cast it: */
     329        if(xinput->ObjectEnum()!=TriaInputEnum) _error_("Operation not permitted because xinput is of type " << EnumToStringx(xinput->ObjectEnum()));
     330        xtriainput=(TriaInput*)xinput;
     331        if(xtriainput->interpolation_type!=this->interpolation_type) _error_("Operation not permitted because xinput is of type " << EnumToStringx(xtriainput->interpolation_type));
     332
     333        /*Carry out the PointwiseMult operation depending on type:*/
     334        for(int i=0;i<numnodes;i++)this->values[i]=this->values[i]*xtriainput->values[i];
     335
     336}
     337/*}}}*/
     338void TriaInput::Pow(IssmDouble exponent){/*{{{*/
     339
     340        const int numnodes=this->NumberofNodes(this->interpolation_type);
     341        if(exponent==0.0){
     342                /*  Not-a-number left alone Infinity set to one  */
     343                for(int i=0;i<numnodes;i++){
     344                        if (this->values[i]==this->values[i])this->values[i]=1.0;
     345                }
     346        }
     347        else if(exponent==0.5){
     348                for(int i=0;i<numnodes;i++){
     349                        if(this->values[i]>=0){
     350                                this->values[i]=sqrt(this->values[i]);
     351                        }
     352                        else{
     353                                this->values[i]=INFINITY;
     354                        }
     355                }
     356        }
     357        else if(exponent==1.0){
     358                /* do nothing */
     359        }
     360        else if(exponent==-0.5){
     361                for(int i=0;i<numnodes;i++){
     362                        if(this->values[i]>=0){
     363                                this->values[i]=1.0/sqrt(this->values[i]);
     364                        }
     365                        else{
     366                                this->values[i]=INFINITY;
     367                        }
     368                }
     369        }
     370        else if(exponent==-1.0){
     371                for(int i=0;i<numnodes;i++){
     372                        if(this->values[i]!=0.){
     373                                this->values[i]=1.0/this->values[i];
     374                        }
     375                        else{
     376                                this->values[i]=INFINITY;
     377                        }
     378                }
     379        }
     380        else {
     381                for(int i=0;i<numnodes;i++)this->values[i]=pow(this->values[i],exponent);
     382        }
     383}
     384/*}}}*/
    322385void TriaInput::Scale(IssmDouble scale_factor){/*{{{*/
    323386
Note: See TracChangeset for help on using the changeset viewer.