Changeset 27232 for issm/trunk/src/c/classes/Inputs/TransientInput.cpp
- Timestamp:
- 08/25/22 16:50:29 (3 years ago)
- Location:
- issm/trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk
-
issm/trunk/src
- Property svn:mergeinfo changed
-
issm/trunk/src/c/classes/Inputs/TransientInput.cpp
r27035 r27232 9 9 #endif 10 10 11 #include <numeric> 11 12 #include "./TransientInput.h" 12 13 #include "./TriaInput.h" … … 208 209 209 210 /*This is a new time step! we need to add it to the list*/ 210 if(this->numtimesteps>0 && time<this->timesteps[this->numtimesteps-1]) _error_("timestep values must increase sequentially ");211 if(this->numtimesteps>0 && time<this->timesteps[this->numtimesteps-1]) _error_("timestep values must increase sequentially, here " << this->timesteps[this->numtimesteps-1] <<" is the last step but smaller than the preceding "<< time<<"\n"); 211 212 212 213 IssmDouble *old_timesteps = NULL; … … 433 434 434 435 /*First, recover current time from parameters: */ 435 bool linear_interp, cycle;436 bool linear_interp,average,cycle; 436 437 IssmDouble dt; 437 438 this->parameters->FindParam(&linear_interp,TimesteppingInterpForcingEnum); 439 this->parameters->FindParam(&average,TimesteppingAverageForcingEnum); 438 440 this->parameters->FindParam(&cycle,TimesteppingCycleForcingEnum); 439 441 this->parameters->FindParam(&dt,TimesteppingTimeStepEnum); /*transient core time step*/ … … 471 473 472 474 /*Figure step out*/ 473 int offset ;475 int offset, prevoffset; 474 476 if(!binary_search(&offset,time,this->timesteps,this->numtimesteps)){ 477 _error_("Input not found (is TransientInput sorted ?)"); 478 } 479 if(!binary_search(&prevoffset,reCast<IssmDouble>(time-dt),this->timesteps,this->numtimesteps)){ 475 480 _error_("Input not found (is TransientInput sorted ?)"); 476 481 } … … 488 493 this->current_step = 0.; 489 494 this->current_input = this->inputs[0]->copy(); 495 496 } 497 else if(offset-prevoffset>1 && prevoffset >=0 && average){ 498 /*get values for the last time: */ 499 _assert_(time>=this->timesteps[offset]); 500 501 /*If already processed return*/ 502 if(this->current_step==reCast<IssmDouble>(offset)) return; 503 504 /*Prepare input*/ 505 if(this->current_input) delete this->current_input; 506 this->current_step = reCast<IssmDouble>(offset); 507 508 this->current_input = this->inputs[prevoffset]->copy(); 509 for(int i=prevoffset+1;i<offset;i++) { 510 this->current_input->AXPY(this->inputs[i],+1.0); 511 } 512 this->current_input->Scale(1./(offset-prevoffset)); 490 513 491 514 } … … 535 558 IssmDouble timespan,mid_step; 536 559 int found,start_offset,end_offset,input_offset; 560 537 561 538 562 /*go through the timesteps, and grab offset for start and end*/ … … 573 597 _assert_(dt>0.); 574 598 } 575 Input* stepinput=this->inputs[offset+1]; 576 599 Input* stepinput=this->inputs[offset+1]->copy(); 577 600 switch(averaging_method){ 578 601 case 0: /*Arithmetic mean*/ … … 608 631 _error_("averaging method is not recognised"); 609 632 } 633 delete stepinput; 610 634 dtsum+=dt; 611 635 offset+=1;
Note:
See TracChangeset
for help on using the changeset viewer.