[26740] | 1 | Index: ../trunk-jpl/src/c/classes/Inputs/TransientInput.cpp
|
---|
| 2 | ===================================================================
|
---|
| 3 | --- ../trunk-jpl/src/c/classes/Inputs/TransientInput.cpp (revision 26196)
|
---|
| 4 | +++ ../trunk-jpl/src/c/classes/Inputs/TransientInput.cpp (revision 26197)
|
---|
| 5 | @@ -419,8 +419,22 @@
|
---|
| 6 | this->parameters->FindParam(&linear_interp,TimesteppingInterpForcingsEnum);
|
---|
| 7 | this->parameters->FindParam(&cycle,TimesteppingCycleForcingEnum);
|
---|
| 8 |
|
---|
| 9 | - if(cycle) _error_("not implemented yet");
|
---|
| 10 | + /*Change input time if we cycle through the forcing*/
|
---|
| 11 | + IssmDouble time0 = this->timesteps[0];
|
---|
| 12 | + IssmDouble time1 = this->timesteps[this->numtimesteps - 1];
|
---|
| 13 | + if(cycle && (time<time0 || time>time1)){
|
---|
| 14 |
|
---|
| 15 | + /*See by how many intervals we have to offset time*/
|
---|
| 16 | + IssmDouble deltat = time1-time0;
|
---|
| 17 | +
|
---|
| 18 | + //int num_intervals = floor((time-time0)/deltat); //Cannot do that because of AD!
|
---|
| 19 | + int num_intervals = reCast<int,IssmDouble>(fabs(time-time0)/deltat);
|
---|
| 20 | + if(time<time0) num_intervals = -num_intervals-1;
|
---|
| 21 | +
|
---|
| 22 | + /*Now offset time so that we do the right interpolation below*/
|
---|
| 23 | + time = time - num_intervals*deltat;
|
---|
| 24 | + }
|
---|
| 25 | +
|
---|
| 26 | /*Figure step out*/
|
---|
| 27 | int offset;
|
---|
| 28 | if(!binary_search(&offset,time,this->timesteps,this->numtimesteps)){
|
---|
| 29 | @@ -479,7 +493,6 @@
|
---|
| 30 | this->current_input->Scale(alpha1);
|
---|
| 31 | this->current_input->AXPY(input2,alpha2);
|
---|
| 32 | }
|
---|
| 33 | -
|
---|
| 34 | }/*}}}*/
|
---|
| 35 | void TransientInput::SetAverageAsCurrentTimeInput(IssmDouble start_time,IssmDouble end_time, int averaging_method){/*{{{*/
|
---|
| 36 |
|
---|