Ignore:
Timestamp:
06/28/16 15:51:32 (9 years ago)
Author:
agscott1
Message:

CHG: Alphabetized all function names under classes

File:
1 edited

Legend:

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

    r18521 r20827  
    2929
    3030/*Object management*/
    31 void Inputs::GetInputValue(bool* pvalue,int enum_type){/*{{{*/
     31int  Inputs::AddInput(Input* in_input){/*{{{*/
     32
     33        /*First, go through dataset of inputs and check whether any input
     34         * with the same name is already in. If so, erase the corresponding
     35         * object before adding this new one: */
     36        vector<Object*>::iterator object;
     37        Input* input=NULL;
     38
     39        /*In debugging mode, check that the input is not a NULL pointer*/
     40        _assert_(in_input);
     41
     42        for ( object=objects.begin() ; object < objects.end(); object++ ){
     43
     44                input=xDynamicCast<Input*>(*object);
     45
     46                if (input->InstanceEnum()==in_input->InstanceEnum()){
     47                        this->DeleteObject(input);
     48                        break;
     49                }
     50        }
     51        this->AddObject(in_input);
     52
     53        return 1;
     54}
     55/*}}}*/
     56void  Inputs::AXPY(int inputy_enum, IssmDouble scalar, int inputx_enum){/*{{{*/
     57
     58        /*Find x and y inputs: */
     59        Input* xinput=xDynamicCast<Input*>(this->GetInput(inputx_enum));
     60        Input* yinput=xDynamicCast<Input*>(this->GetInput(inputy_enum));
     61
     62        /*some checks: */
     63        if(!xinput) _error_("input " << EnumToStringx(inputx_enum) << " could not be found!");
     64        if(!yinput) _error_("input " << EnumToStringx(inputy_enum) << " could not be found!");
     65
     66        /*Apply AXPY: */
     67        yinput->AXPY(xinput,scalar);
     68}
     69/*}}}*/
     70void  Inputs::ChangeEnum(int oldenumtype,int newenumtype){/*{{{*/
     71
     72        /*Go through dataset of inputs and look for input with
     73         * same enum as input enum, once found, just change its name */
     74        vector<Object*>::iterator object;
     75        Input* input=NULL;
     76
     77        /*Delete existing input of newenumtype if it exists*/
     78        for ( object=objects.begin() ; object < objects.end(); object++ ){
     79                input=xDynamicCast<Input*>(*object);
     80
     81                if (input->InstanceEnum()==newenumtype){
     82                        this->DeleteObject(input);
     83                        break;
     84                }
     85        }
     86
     87        /*Change enum_type of input of oldenumtype*/
     88        for ( object=objects.begin() ; object < objects.end(); object++ ){
     89
     90                input=xDynamicCast<Input*>(*object);
     91
     92                if (input->InstanceEnum()==oldenumtype){
     93                        input->ChangeEnum(newenumtype);
     94                        break;
     95                }
     96        }
     97}
     98/*}}}*/
     99void Inputs::Configure(Parameters* parameters){/*{{{*/
     100
     101        vector<Object*>::iterator object;
     102        Input* input=NULL;
     103
     104        for ( object=objects.begin() ; object < objects.end(); object++ ){
     105
     106                input=xDynamicCast<Input*>(*object);
     107                input->Configure(parameters);
     108
     109        }
     110
     111}
     112/*}}}*/
     113void  Inputs::ConstrainMin(int constrain_enum, IssmDouble minimum){/*{{{*/
     114
     115        /*Find x and y inputs: */
     116        Input* constrain_input=xDynamicCast<Input*>(this->GetInput(constrain_enum));
     117
     118        /*some checks: */
     119        if(!constrain_input) _error_("input " << EnumToStringx(constrain_enum) << " could not be found!");
     120
     121        /*Apply ContrainMin: */
     122        constrain_input->ConstrainMin(minimum);
     123}
     124/*}}}*/
     125int  Inputs::DeleteInput(int enum_type){/*{{{*/
     126
     127        vector<Object*>::iterator object;
     128        Input* input=NULL;
     129
     130        for ( object=objects.begin() ; object < objects.end(); object++ ){
     131
     132                input=xDynamicCast<Input*>(*object);
     133
     134                if (input->InstanceEnum()==enum_type){
     135                        this->DeleteObject(input);
     136                        break;
     137                }
     138        }
     139
     140        return 1;
     141
     142}
     143/*}}}*/
     144void  Inputs::DuplicateInput(int original_enum,int new_enum){/*{{{*/
     145
     146        /*Make a copy of the original input: */
     147        Input* original=xDynamicCast<Input*>(this->GetInput(original_enum));
     148        if(!original)_error_("could not find input with enum: " << EnumToStringx(original_enum));
     149        Input* copy=xDynamicCast<Input*>(original->copy());
     150
     151        /*Change copy enum to reinitialized_enum: */
     152        copy->ChangeEnum(new_enum);
     153
     154        /*Add copy into inputs, it will wipe off the one already there: */
     155        this->AddInput(xDynamicCast<Input*>(copy));
     156}
     157/*}}}*/
     158Input* Inputs::GetInput(int enum_name){/*{{{*/
     159
     160        vector<Object*>::iterator object;
     161        Input* input=NULL;
     162
     163        for ( object=objects.begin() ; object < objects.end(); object++ ){
     164
     165                input=xDynamicCast<Input*>(*object);
     166
     167                if (input->InstanceEnum()==enum_name){
     168                        return input;
     169                }
     170        }
     171        return NULL;
     172}
     173/*}}}*/
     174void Inputs::GetInputAverage(IssmDouble* pvalue,int enum_type){/*{{{*/
    32175
    33176        vector<Object*>::iterator object;
     
    52195
    53196        /*Ok, we have an input if we made it here, request the input to return the value: */
    54         input->GetInputValue(pvalue);
    55 
    56 }
    57 /*}}}*/
    58 void Inputs::GetInputValue(int* pvalue,int enum_type){/*{{{*/
     197        input->GetInputAverage(pvalue);
     198
     199}
     200/*}}}*/
     201void Inputs::GetInputValue(bool* pvalue,int enum_type){/*{{{*/
    59202
    60203        vector<Object*>::iterator object;
     
    83226}
    84227/*}}}*/
    85 void Inputs::GetInputValue(IssmDouble* pvalue,int enum_type){/*{{{*/
     228void Inputs::GetInputValue(int* pvalue,int enum_type){/*{{{*/
    86229
    87230        vector<Object*>::iterator object;
     
    92235        for ( object=objects.begin() ; object < objects.end(); object++ ){
    93236
    94                 input=xDynamicCast<Input*>(*object); 
     237                input=xDynamicCast<Input*>(*object);
    95238                if (input->InstanceEnum()==enum_type){
    96239                        found=true;
     
    110253}
    111254/*}}}*/
    112 void Inputs::GetInputAverage(IssmDouble* pvalue,int enum_type){/*{{{*/
     255void Inputs::GetInputValue(IssmDouble* pvalue,int enum_type){/*{{{*/
    113256
    114257        vector<Object*>::iterator object;
     
    119262        for ( object=objects.begin() ; object < objects.end(); object++ ){
    120263
    121                 input=xDynamicCast<Input*>(*object);
     264                input=xDynamicCast<Input*>(*object); 
    122265                if (input->InstanceEnum()==enum_type){
    123266                        found=true;
     
    133276
    134277        /*Ok, we have an input if we made it here, request the input to return the value: */
    135         input->GetInputAverage(pvalue);
    136 
    137 }
    138 /*}}}*/
    139 int  Inputs::AddInput(Input* in_input){/*{{{*/
    140 
    141         /*First, go through dataset of inputs and check whether any input
    142          * with the same name is already in. If so, erase the corresponding
    143          * object before adding this new one: */
    144         vector<Object*>::iterator object;
    145         Input* input=NULL;
    146 
    147         /*In debugging mode, check that the input is not a NULL pointer*/
    148         _assert_(in_input);
    149 
    150         for ( object=objects.begin() ; object < objects.end(); object++ ){
    151 
    152                 input=xDynamicCast<Input*>(*object);
    153 
    154                 if (input->InstanceEnum()==in_input->InstanceEnum()){
    155                         this->DeleteObject(input);
    156                         break;
    157                 }
    158         }
    159         this->AddObject(in_input);
    160 
    161         return 1;
    162 }
    163 /*}}}*/
    164 void  Inputs::ChangeEnum(int oldenumtype,int newenumtype){/*{{{*/
    165 
    166         /*Go through dataset of inputs and look for input with
    167          * same enum as input enum, once found, just change its name */
    168         vector<Object*>::iterator object;
    169         Input* input=NULL;
    170 
    171         /*Delete existing input of newenumtype if it exists*/
    172         for ( object=objects.begin() ; object < objects.end(); object++ ){
    173                 input=xDynamicCast<Input*>(*object);
    174 
    175                 if (input->InstanceEnum()==newenumtype){
    176                         this->DeleteObject(input);
    177                         break;
    178                 }
    179         }
    180 
    181         /*Change enum_type of input of oldenumtype*/
    182         for ( object=objects.begin() ; object < objects.end(); object++ ){
    183 
    184                 input=xDynamicCast<Input*>(*object);
    185 
    186                 if (input->InstanceEnum()==oldenumtype){
    187                         input->ChangeEnum(newenumtype);
    188                         break;
    189                 }
    190         }
    191 }
    192 /*}}}*/
    193 void  Inputs::ConstrainMin(int constrain_enum, IssmDouble minimum){/*{{{*/
    194 
    195         /*Find x and y inputs: */
    196         Input* constrain_input=xDynamicCast<Input*>(this->GetInput(constrain_enum));
    197 
    198         /*some checks: */
    199         if(!constrain_input) _error_("input " << EnumToStringx(constrain_enum) << " could not be found!");
    200 
    201         /*Apply ContrainMin: */
    202         constrain_input->ConstrainMin(minimum);
     278        input->GetInputValue(pvalue);
     279
    203280}
    204281/*}}}*/
     
    303380}
    304381/*}}}*/
    305 Input* Inputs::GetInput(int enum_name){/*{{{*/
    306 
    307         vector<Object*>::iterator object;
    308         Input* input=NULL;
    309 
    310         for ( object=objects.begin() ; object < objects.end(); object++ ){
    311 
    312                 input=xDynamicCast<Input*>(*object);
    313 
    314                 if (input->InstanceEnum()==enum_name){
    315                         return input;
    316                 }
    317         }
    318         return NULL;
    319 }
    320 /*}}}*/
    321 int  Inputs::DeleteInput(int enum_type){/*{{{*/
    322 
    323         vector<Object*>::iterator object;
    324         Input* input=NULL;
    325 
    326         for ( object=objects.begin() ; object < objects.end(); object++ ){
    327 
    328                 input=xDynamicCast<Input*>(*object);
    329 
    330                 if (input->InstanceEnum()==enum_type){
    331                         this->DeleteObject(input);
    332                         break;
    333                 }
    334         }
    335 
    336         return 1;
    337 
    338 }
    339 /*}}}*/
    340 void  Inputs::DuplicateInput(int original_enum,int new_enum){/*{{{*/
    341 
    342         /*Make a copy of the original input: */
    343         Input* original=xDynamicCast<Input*>(this->GetInput(original_enum));
    344         if(!original)_error_("could not find input with enum: " << EnumToStringx(original_enum));
    345         Input* copy=xDynamicCast<Input*>(original->copy());
    346 
    347         /*Change copy enum to reinitialized_enum: */
    348         copy->ChangeEnum(new_enum);
    349 
    350         /*Add copy into inputs, it will wipe off the one already there: */
    351         this->AddInput(xDynamicCast<Input*>(copy));
     382Inputs* Inputs::SpawnSegInputs(int index1,int index2){/*{{{*/
     383
     384        /*Intermediary*/
     385        vector<Object*>::iterator object;
     386        Input* inputin=NULL;
     387        Input* inputout=NULL;
     388
     389        /*Output*/
     390        Inputs* newinputs=new Inputs();
     391
     392        /*Go through inputs and call Spawn function*/
     393        for ( object=objects.begin() ; object < objects.end(); object++ ){
     394
     395                /*Create new input*/
     396                inputin=xDynamicCast<Input*>(*object);
     397                inputout=inputin->SpawnSegInput(index1,index2);
     398
     399                /*Add input to new inputs*/
     400                newinputs->AddObject(inputout);
     401        }
     402
     403        /*Assign output pointer*/
     404        return newinputs;
    352405}
    353406/*}}}*/
     
    377430}
    378431/*}}}*/
    379 Inputs* Inputs::SpawnSegInputs(int index1,int index2){/*{{{*/
    380 
    381         /*Intermediary*/
    382         vector<Object*>::iterator object;
    383         Input* inputin=NULL;
    384         Input* inputout=NULL;
    385 
    386         /*Output*/
    387         Inputs* newinputs=new Inputs();
    388 
    389         /*Go through inputs and call Spawn function*/
    390         for ( object=objects.begin() ; object < objects.end(); object++ ){
    391 
    392                 /*Create new input*/
    393                 inputin=xDynamicCast<Input*>(*object);
    394                 inputout=inputin->SpawnSegInput(index1,index2);
    395 
    396                 /*Add input to new inputs*/
    397                 newinputs->AddObject(inputout);
    398         }
    399 
    400         /*Assign output pointer*/
    401         return newinputs;
    402 }
    403 /*}}}*/
    404 void  Inputs::AXPY(int inputy_enum, IssmDouble scalar, int inputx_enum){/*{{{*/
    405 
    406         /*Find x and y inputs: */
    407         Input* xinput=xDynamicCast<Input*>(this->GetInput(inputx_enum));
    408         Input* yinput=xDynamicCast<Input*>(this->GetInput(inputy_enum));
    409 
    410         /*some checks: */
    411         if(!xinput) _error_("input " << EnumToStringx(inputx_enum) << " could not be found!");
    412         if(!yinput) _error_("input " << EnumToStringx(inputy_enum) << " could not be found!");
    413 
    414         /*Apply AXPY: */
    415         yinput->AXPY(xinput,scalar);
    416 }
    417 /*}}}*/
    418 void Inputs::Configure(Parameters* parameters){/*{{{*/
    419 
    420         vector<Object*>::iterator object;
    421         Input* input=NULL;
    422 
    423         for ( object=objects.begin() ; object < objects.end(); object++ ){
    424 
    425                 input=xDynamicCast<Input*>(*object);
    426                 input->Configure(parameters);
    427 
    428         }
    429 
    430 }
    431 /*}}}*/
Note: See TracChangeset for help on using the changeset viewer.