Changeset 12706 for issm/trunk/src/c/objects/Inputs/TransientInput.cpp
- Timestamp:
- 07/24/12 10:36:19 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk/src/c/objects/Inputs/TransientInput.cpp
r12358 r12706 46 46 /*FUNCTION TransientInput::~TransientInput{{{*/ 47 47 TransientInput::~TransientInput(){ 48 x free((void**)&this->timesteps);48 xDelete<IssmDouble>(this->timesteps); 49 49 this->timesteps=NULL; 50 50 this->numtimesteps=0; … … 66 66 int i; 67 67 68 printf("TransientInput:\n");69 printf(" enum: %i (%s)\n",this->enum_type,EnumToStringx(this->enum_type));70 printf(" numtimesteps: %i\n",this->numtimesteps);71 printf("---inputs: \n");68 _printLine_("TransientInput:"); 69 _printLine_(" enum: " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")"); 70 _printLine_(" numtimesteps: " << this->numtimesteps); 71 _printLine_("---inputs: "); 72 72 for(i=0;i<this->numtimesteps;i++){ 73 printf(" time: %g \n",this->timesteps[i]);73 _printLine_(" time: " << this->timesteps[i] << " "); 74 74 ((Input*)this->inputs->GetObjectByOffset(i))->Echo(); 75 75 } … … 100 100 output->enum_type=this->enum_type; 101 101 output->numtimesteps=this->numtimesteps; 102 output->timesteps= (double*)xmalloc(this->numtimesteps*sizeof(double));103 memcpy(output->timesteps,this->timesteps,this->numtimesteps*sizeof( double));102 output->timesteps=xNew<IssmDouble>(this->numtimesteps); 103 memcpy(output->timesteps,this->timesteps,this->numtimesteps*sizeof(IssmDouble)); 104 104 output->inputs=(Inputs*)this->inputs->Copy(); 105 105 output->parameters=this->parameters; … … 128 128 outinput->enum_type=this->enum_type; 129 129 outinput->numtimesteps=this->numtimesteps; 130 outinput->timesteps= (double*)xmalloc(this->numtimesteps*sizeof(double));131 memcpy(outinput->timesteps,this->timesteps,this->numtimesteps*sizeof( double));130 outinput->timesteps=xNew<IssmDouble>(this->numtimesteps); 131 memcpy(outinput->timesteps,this->timesteps,this->numtimesteps*sizeof(IssmDouble)); 132 132 outinput->inputs=(Inputs*)this->inputs->SpawnTriaInputs(indices); 133 133 outinput->parameters=this->parameters; … … 139 139 /*}}}*/ 140 140 /*FUNCTION TransientInput::SpawnResult{{{*/ 141 ElementResult* TransientInput::SpawnResult(int step, double time){141 ElementResult* TransientInput::SpawnResult(int step, IssmDouble time){ 142 142 143 143 ElementResult* elementresult=NULL; … … 156 156 157 157 /*Object functions*/ 158 /*FUNCTION TransientInput::GetInputValue( double* pvalue,GaussTria* gauss){{{*/159 void TransientInput::GetInputValue( double* pvalue,GaussTria* gauss){160 double time;158 /*FUNCTION TransientInput::GetInputValue(IssmDouble* pvalue,GaussTria* gauss){{{*/ 159 void TransientInput::GetInputValue(IssmDouble* pvalue,GaussTria* gauss){ 160 IssmDouble time; 161 161 162 162 /*First, recover current time from parameters: */ … … 172 172 } 173 173 /*}}}*/ 174 /*FUNCTION TransientInput::GetInputValue( double* pvalue,GaussPenta* gauss){{{*/175 void TransientInput::GetInputValue( double* pvalue,GaussPenta* gauss){176 double time;174 /*FUNCTION TransientInput::GetInputValue(IssmDouble* pvalue,GaussPenta* gauss){{{*/ 175 void TransientInput::GetInputValue(IssmDouble* pvalue,GaussPenta* gauss){ 176 IssmDouble time; 177 177 178 178 /*First, recover current time from parameters: */ … … 188 188 } 189 189 /*}}}*/ 190 /*FUNCTION TransientInput::GetInputValue( double* pvalue,GaussTria* gauss,double time){{{*/191 void TransientInput::GetInputValue( double* pvalue,GaussTria* gauss,double time){190 /*FUNCTION TransientInput::GetInputValue(IssmDouble* pvalue,GaussTria* gauss,IssmDouble time){{{*/ 191 void TransientInput::GetInputValue(IssmDouble* pvalue,GaussTria* gauss,IssmDouble time){ 192 192 193 193 /*Retrieve interpolated values for this time step: */ … … 200 200 } 201 201 /*}}}*/ 202 /*FUNCTION TransientInput::GetInputValue( double* pvalue,GaussPenta* gauss,double time){{{*/203 void TransientInput::GetInputValue( double* pvalue,GaussPenta* gauss,double time){202 /*FUNCTION TransientInput::GetInputValue(IssmDouble* pvalue,GaussPenta* gauss,IssmDouble time){{{*/ 203 void TransientInput::GetInputValue(IssmDouble* pvalue,GaussPenta* gauss,IssmDouble time){ 204 204 205 205 /*Retrieve interpolated values for this time step: */ … … 212 212 } 213 213 /*}}}*/ 214 /*FUNCTION TransientInput::GetInputDerivativeValue( double* p, double* xyz_list, GaussTria* gauss){{{*/215 void TransientInput::GetInputDerivativeValue( double* p, double* xyz_list, GaussTria* gauss){216 217 double time;214 /*FUNCTION TransientInput::GetInputDerivativeValue(IssmDouble* p, IssmDouble* xyz_list, GaussTria* gauss){{{*/ 215 void TransientInput::GetInputDerivativeValue(IssmDouble* p, IssmDouble* xyz_list, GaussTria* gauss){ 216 217 IssmDouble time; 218 218 219 219 /*First, recover current time from parameters: */ … … 236 236 /*}}}*/ 237 237 /*FUNCTION TransientInput::GetInputAverage{{{*/ 238 void TransientInput::GetInputAverage( double* pvalue){238 void TransientInput::GetInputAverage(IssmDouble* pvalue){ 239 239 240 double time;240 IssmDouble time; 241 241 242 242 /*First, recover current time from parameters: */ … … 256 256 /*Intermediary*/ 257 257 /*FUNCTION TransientInput::AddTimeInput{{{*/ 258 void TransientInput::AddTimeInput(Input* input, double time){258 void TransientInput::AddTimeInput(Input* input,IssmDouble time){ 259 259 260 260 /*insert values at time step: */ … … 262 262 263 263 //copy timesteps, add the new time, delete previous timesteps, and add the new input: inputs->AddObject(input); 264 double* old_timesteps=NULL;264 IssmDouble* old_timesteps=NULL; 265 265 266 266 if (this->numtimesteps > 0){ 267 old_timesteps= (double*)xmalloc(this->numtimesteps*sizeof(double));268 memcpy(old_timesteps,this->timesteps,this->numtimesteps*sizeof( double));269 x free((void**)&this->timesteps);267 old_timesteps=xNew<IssmDouble>(this->numtimesteps); 268 memcpy(old_timesteps,this->timesteps,this->numtimesteps*sizeof(IssmDouble)); 269 xDelete<IssmDouble>(this->timesteps); 270 270 } 271 271 272 272 this->numtimesteps=this->numtimesteps+1; 273 this->timesteps= (double*)xmalloc(this->numtimesteps*sizeof(double));273 this->timesteps=xNew<IssmDouble>(this->numtimesteps); 274 274 275 275 if (this->numtimesteps > 1){ 276 memcpy(this->timesteps,old_timesteps,(this->numtimesteps-1)*sizeof( double));277 x free((void**)&old_timesteps);276 memcpy(this->timesteps,old_timesteps,(this->numtimesteps-1)*sizeof(IssmDouble)); 277 xDelete<IssmDouble>(old_timesteps); 278 278 } 279 279 … … 285 285 /*}}}*/ 286 286 /*FUNCTION TransientInput::SquareMin{{{*/ 287 void TransientInput::SquareMin( double* psquaremin, bool process_units,Parameters* parameters){288 289 double time;287 void TransientInput::SquareMin(IssmDouble* psquaremin, bool process_units,Parameters* parameters){ 288 289 IssmDouble time; 290 290 291 291 /*First, recover current time from parameters: */ … … 303 303 /*}}}*/ 304 304 /*FUNCTION TransientInput::InfinityNorm{{{*/ 305 double TransientInput::InfinityNorm(void){306 307 double time;308 double infnorm;305 IssmDouble TransientInput::InfinityNorm(void){ 306 307 IssmDouble time; 308 IssmDouble infnorm; 309 309 310 310 /*First, recover current time from parameters: */ … … 323 323 /*}}}*/ 324 324 /*FUNCTION TransientInput::Max{{{*/ 325 double TransientInput::Max(void){326 327 double time;328 double max;325 IssmDouble TransientInput::Max(void){ 326 327 IssmDouble time; 328 IssmDouble max; 329 329 330 330 /*First, recover current time from parameters: */ … … 343 343 /*}}}*/ 344 344 /*FUNCTION TransientInput::MaxAbs{{{*/ 345 double TransientInput::MaxAbs(void){346 347 double time;348 double maxabs;345 IssmDouble TransientInput::MaxAbs(void){ 346 347 IssmDouble time; 348 IssmDouble maxabs; 349 349 350 350 /*First, recover current time from parameters: */ … … 364 364 /*}}}*/ 365 365 /*FUNCTION TransientInput::Min{{{*/ 366 double TransientInput::Min(void){367 368 double time;369 double min;366 IssmDouble TransientInput::Min(void){ 367 368 IssmDouble time; 369 IssmDouble min; 370 370 371 371 /*First, recover current time from parameters: */ … … 385 385 /*}}}*/ 386 386 /*FUNCTION TransientInput::MinAbs{{{*/ 387 double TransientInput::MinAbs(void){388 389 double time;390 double minabs;387 IssmDouble TransientInput::MinAbs(void){ 388 389 IssmDouble time; 390 IssmDouble minabs; 391 391 392 392 /*First, recover current time from parameters: */ … … 407 407 void TransientInput::GetVectorFromInputs(Vector* vector,int* doflist){ 408 408 409 double time;409 IssmDouble time; 410 410 411 411 /*First, recover current time from parameters: */ … … 422 422 } /*}}}*/ 423 423 /*FUNCTION TransientInput::GetTimeInput{{{*/ 424 Input* TransientInput::GetTimeInput( double intime){424 Input* TransientInput::GetTimeInput(IssmDouble intime){ 425 425 426 426 int i,j; 427 double deltat;428 double alpha1,alpha2;427 IssmDouble deltat; 428 IssmDouble alpha1,alpha2; 429 429 bool found=false; 430 430 Input* input=NULL; … … 474 474 } 475 475 } 476 if(!found)_error _("did not find time interval on which to interpolate forcing values!");476 if(!found)_error2_("did not find time interval on which to interpolate forcing values!"); 477 477 478 478 /*Assign output pointer*/
Note:
See TracChangeset
for help on using the changeset viewer.