Changeset 26197


Ignore:
Timestamp:
04/16/21 11:33:10 (4 years ago)
Author:
Mathieu Morlighem
Message:

CHG: added cycling inputs

File:
1 edited

Legend:

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

    r26196 r26197  
    420420        this->parameters->FindParam(&cycle,TimesteppingCycleForcingEnum);
    421421
    422         if(cycle) _error_("not implemented yet");
     422        /*Change input time if we cycle through the forcing*/
     423        IssmDouble time0 = this->timesteps[0];
     424        IssmDouble time1 = this->timesteps[this->numtimesteps - 1];
     425        if(cycle && (time<time0 || time>time1)){
     426
     427                /*See by how many intervals we have to offset time*/
     428                IssmDouble deltat = time1-time0;
     429
     430                //int num_intervals = floor((time-time0)/deltat); //Cannot do that because of AD!
     431                int num_intervals = reCast<int,IssmDouble>(fabs(time-time0)/deltat);
     432                if(time<time0) num_intervals = -num_intervals-1;
     433
     434                /*Now offset time so that we do the right interpolation below*/
     435                time = time - num_intervals*deltat;
     436        }
    423437
    424438        /*Figure step out*/
     
    480494                this->current_input->AXPY(input2,alpha2);
    481495        }
    482 
    483496}/*}}}*/
    484497void TransientInput::SetAverageAsCurrentTimeInput(IssmDouble start_time,IssmDouble end_time, int averaging_method){/*{{{*/
Note: See TracChangeset for help on using the changeset viewer.