Ignore:
Timestamp:
07/24/12 10:36:19 (13 years ago)
Author:
Mathieu Morlighem
Message:

merged trunk-jpl and trunk for revision 12703

File:
1 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk/src/c/objects/Inputs/TransientInput.cpp

    r12358 r12706  
    4646/*FUNCTION TransientInput::~TransientInput{{{*/
    4747TransientInput::~TransientInput(){
    48         xfree((void**)&this->timesteps);
     48        xDelete<IssmDouble>(this->timesteps);
    4949        this->timesteps=NULL;
    5050        this->numtimesteps=0;
     
    6666        int i;
    6767
    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: ");
    7272        for(i=0;i<this->numtimesteps;i++){
    73                 printf("   time: %g  \n",this->timesteps[i]);
     73                _printLine_("   time: " << this->timesteps[i] << "  ");
    7474                ((Input*)this->inputs->GetObjectByOffset(i))->Echo();
    7575        }
     
    100100        output->enum_type=this->enum_type;
    101101        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));
    104104        output->inputs=(Inputs*)this->inputs->Copy();
    105105        output->parameters=this->parameters;
     
    128128        outinput->enum_type=this->enum_type;
    129129        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));
    132132        outinput->inputs=(Inputs*)this->inputs->SpawnTriaInputs(indices);
    133133        outinput->parameters=this->parameters;
     
    139139/*}}}*/
    140140/*FUNCTION TransientInput::SpawnResult{{{*/
    141 ElementResult* TransientInput::SpawnResult(int step, double time){
     141ElementResult* TransientInput::SpawnResult(int step, IssmDouble time){
    142142
    143143        ElementResult* elementresult=NULL;
     
    156156
    157157/*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){{{*/
     159void TransientInput::GetInputValue(IssmDouble* pvalue,GaussTria* gauss){
     160        IssmDouble time;
    161161
    162162        /*First, recover current time from parameters: */
     
    172172}
    173173/*}}}*/
    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){{{*/
     175void TransientInput::GetInputValue(IssmDouble* pvalue,GaussPenta* gauss){
     176        IssmDouble time;
    177177
    178178        /*First, recover current time from parameters: */
     
    188188}
    189189/*}}}*/
    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){{{*/
     191void TransientInput::GetInputValue(IssmDouble* pvalue,GaussTria* gauss,IssmDouble time){
    192192
    193193        /*Retrieve interpolated values for this time step: */
     
    200200}
    201201/*}}}*/
    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){{{*/
     203void TransientInput::GetInputValue(IssmDouble* pvalue,GaussPenta* gauss,IssmDouble time){
    204204
    205205        /*Retrieve interpolated values for this time step: */
     
    212212}
    213213/*}}}*/
    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){{{*/
     215void TransientInput::GetInputDerivativeValue(IssmDouble* p, IssmDouble* xyz_list, GaussTria* gauss){
     216
     217        IssmDouble time;
    218218
    219219        /*First, recover current time from parameters: */
     
    236236/*}}}*/
    237237/*FUNCTION TransientInput::GetInputAverage{{{*/
    238 void TransientInput::GetInputAverage(double* pvalue){
     238void TransientInput::GetInputAverage(IssmDouble* pvalue){
    239239       
    240         double time;
     240        IssmDouble time;
    241241
    242242        /*First, recover current time from parameters: */
     
    256256/*Intermediary*/
    257257/*FUNCTION TransientInput::AddTimeInput{{{*/
    258 void TransientInput::AddTimeInput(Input* input,double time){
     258void TransientInput::AddTimeInput(Input* input,IssmDouble time){
    259259
    260260        /*insert values at time step: */
     
    262262
    263263        //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;
    265265
    266266        if (this->numtimesteps > 0){
    267                 old_timesteps=(double*)xmalloc(this->numtimesteps*sizeof(double));
    268                 memcpy(old_timesteps,this->timesteps,this->numtimesteps*sizeof(double));
    269                 xfree((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);
    270270        }
    271271
    272272        this->numtimesteps=this->numtimesteps+1;
    273         this->timesteps=(double*)xmalloc(this->numtimesteps*sizeof(double));
     273        this->timesteps=xNew<IssmDouble>(this->numtimesteps);
    274274
    275275        if (this->numtimesteps > 1){
    276                 memcpy(this->timesteps,old_timesteps,(this->numtimesteps-1)*sizeof(double));
    277                 xfree((void**)&old_timesteps);
     276                memcpy(this->timesteps,old_timesteps,(this->numtimesteps-1)*sizeof(IssmDouble));
     277                xDelete<IssmDouble>(old_timesteps);
    278278        }
    279279
     
    285285/*}}}*/
    286286/*FUNCTION TransientInput::SquareMin{{{*/
    287 void TransientInput::SquareMin(double* psquaremin, bool process_units,Parameters* parameters){
    288 
    289         double time;
     287void TransientInput::SquareMin(IssmDouble* psquaremin, bool process_units,Parameters* parameters){
     288
     289        IssmDouble time;
    290290
    291291        /*First, recover current time from parameters: */
     
    303303/*}}}*/
    304304/*FUNCTION TransientInput::InfinityNorm{{{*/
    305 double TransientInput::InfinityNorm(void){
    306 
    307         double time;
    308         double infnorm;
     305IssmDouble TransientInput::InfinityNorm(void){
     306
     307        IssmDouble time;
     308        IssmDouble infnorm;
    309309
    310310        /*First, recover current time from parameters: */
     
    323323/*}}}*/
    324324/*FUNCTION TransientInput::Max{{{*/
    325 double TransientInput::Max(void){
    326 
    327         double time;
    328         double max;
     325IssmDouble TransientInput::Max(void){
     326
     327        IssmDouble time;
     328        IssmDouble max;
    329329
    330330        /*First, recover current time from parameters: */
     
    343343/*}}}*/
    344344/*FUNCTION TransientInput::MaxAbs{{{*/
    345 double TransientInput::MaxAbs(void){
    346 
    347         double time;
    348         double maxabs;
     345IssmDouble TransientInput::MaxAbs(void){
     346
     347        IssmDouble time;
     348        IssmDouble maxabs;
    349349
    350350        /*First, recover current time from parameters: */
     
    364364/*}}}*/
    365365/*FUNCTION TransientInput::Min{{{*/
    366 double TransientInput::Min(void){
    367 
    368         double time;
    369         double min;
     366IssmDouble TransientInput::Min(void){
     367
     368        IssmDouble time;
     369        IssmDouble min;
    370370
    371371        /*First, recover current time from parameters: */
     
    385385/*}}}*/
    386386/*FUNCTION TransientInput::MinAbs{{{*/
    387 double TransientInput::MinAbs(void){
    388 
    389         double time;
    390         double minabs;
     387IssmDouble TransientInput::MinAbs(void){
     388
     389        IssmDouble time;
     390        IssmDouble minabs;
    391391
    392392        /*First, recover current time from parameters: */
     
    407407void TransientInput::GetVectorFromInputs(Vector* vector,int* doflist){
    408408
    409         double time;
     409        IssmDouble time;
    410410
    411411        /*First, recover current time from parameters: */
     
    422422} /*}}}*/
    423423/*FUNCTION TransientInput::GetTimeInput{{{*/
    424 Input* TransientInput::GetTimeInput(double intime){
     424Input* TransientInput::GetTimeInput(IssmDouble intime){
    425425
    426426        int     i,j;
    427         double  deltat;
    428         double  alpha1,alpha2;
     427        IssmDouble  deltat;
     428        IssmDouble  alpha1,alpha2;
    429429        bool    found=false;
    430430        Input*  input=NULL;
     
    474474                }
    475475        }
    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!");
    477477
    478478        /*Assign output pointer*/
Note: See TracChangeset for help on using the changeset viewer.