Changeset 21974


Ignore:
Timestamp:
08/18/17 14:20:30 (8 years ago)
Author:
Mathieu Morlighem
Message:

CHG: some cleanup

Location:
issm/trunk-jpl/src/c/classes/Inputs
Files:
20 edited

Legend:

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

    r21872 r21974  
    3636                int  GetResultNumberOfNodes(void){return 1;};
    3737                int   InstanceEnum();
    38                 Input* PointwiseDivide(Input* inputB){_error_("not implemented yet");};
    39                 Input* PointwiseMin(Input* inputB){_error_("not implemented yet");};
    40                 Input* PointwiseMax(Input* inputB){_error_("not implemented yet");};
    4138                Input* SpawnSegInput(int index1,int index2);
    4239                Input* SpawnTriaInput(int index1,int index2,int index3);
     
    4643                void AXPY(Input* xinput,IssmDouble scalar);
    4744                void ChangeEnum(int newenumtype);
    48                 void Constrain(IssmDouble cm_min, IssmDouble cm_max){_error_("Constrain not implemented for booleans");};
    49                 void ConstrainMin(IssmDouble minimum){_error_("not implemented yet");};
    5045                void Extrude(int start);
    5146                void GetInputAllTimeAverages(IssmDouble** pvalues,IssmDouble** ptimes, int* pnumtimes){_error_("not implemented yet");};
  • issm/trunk-jpl/src/c/classes/Inputs/ControlInput.cpp

    r21931 r21974  
    147147}
    148148/*}}}*/
    149 void ControlInput::Constrain(void){/*{{{*/
    150 
    151         Input* newvalues=NULL;
    152 
    153         newvalues=this->values->PointwiseMin(maxvalues);
    154         delete values; this->values=newvalues;
    155         newvalues=this->values->PointwiseMax(minvalues);
    156         delete values; this->values=newvalues;
    157 }/*}}}*/
    158 void ControlInput::Constrain(IssmDouble min, IssmDouble max){/*{{{*/
    159            values->Constrain(min,max);
    160 }/*}}}*/
    161149void ControlInput::Extrude(int start){/*{{{*/
    162150        values->Extrude(start);
  • issm/trunk-jpl/src/c/classes/Inputs/ControlInput.h

    r21931 r21974  
    4040                void AddTimeValues(IssmDouble* values,int step,IssmDouble time){_error_("not supported yet");};
    4141                void Configure(Parameters* parameters);
    42                 Input* PointwiseDivide(Input* inputB){_error_("not implemented yet");};
    43                 Input* PointwiseMax(Input* inputB){_error_("not implemented yet");};
    44                 Input* PointwiseMin(Input* inputB){_error_("not implemented yet");};
    4542                int    InstanceEnum();
    4643                Input* SpawnSegInput(int index1,int index2);
     
    4946                /*numerics: {{{*/
    5047                void AXPY(Input* xinput,IssmDouble scalar);
    51                 void Constrain(void);
    52                 void Constrain(IssmDouble min,IssmDouble max);
    53                 void ConstrainMin(IssmDouble minimum){_error_("not implemented yet");};
    5448                void ChangeEnum(int newenumtype){_error_("not implemented yet");};
    5549                void Extrude(int start);
  • issm/trunk-jpl/src/c/classes/Inputs/DatasetInput.h

    r21931 r21974  
    3939                void Configure(Parameters* parameters);
    4040                int    InstanceEnum();
    41                 Input* PointwiseDivide(Input* inputB){_error_("not implemented yet");};
    42                 Input* PointwiseMin(Input* inputB){_error_("not implemented yet");};
    43                 Input* PointwiseMax(Input* inputB){_error_("not implemented yet");};
    4441                Input* SpawnSegInput(int index1,int index2);
    4542                Input* SpawnTriaInput(int index1,int index2,int index3);
     
    4845                void AXPY(Input* xinput,IssmDouble scalar){_error_("not implemented yet");};
    4946                void ChangeEnum(int newenumtype){_error_("not implemented yet");};
    50                 void Constrain(void){_error_("not implemented yet");};
    51                 void Constrain(IssmDouble min,IssmDouble max){_error_("not implemented yet");};
    52                 void ConstrainMin(IssmDouble minimum){_error_("not implemented yet");};
    5347                void Extrude(int start){_error_("not implemented yet");};
    5448                void GetGradient(Vector<IssmDouble>* gradient_vec,int* doflist){_error_("not implemented yet");};
  • issm/trunk-jpl/src/c/classes/Inputs/DoubleArrayInput.h

    r21872 r21974  
    3838                int  GetResultNumberOfNodes(void){return 1;};
    3939                int   InstanceEnum();
    40                 Input* PointwiseDivide(Input* inputB){_error_("not implemented yet");};
    41                 Input* PointwiseMax(Input* inputB){_error_("not implemented yet");};
    42                 Input* PointwiseMin(Input* inputB){_error_("not implemented yet");};
    4340                void ResultToMatrix(IssmDouble* values,int ncols,int sid);
    4441                Input* SpawnSegInput(int index1,int index2){_error_("not implemented yet");};
     
    4845                void AXPY(Input* xinput,IssmDouble scalar){_error_("not implemented yet");};
    4946                void ChangeEnum(int newenumtype);
    50                 void Constrain(IssmDouble cm_min, IssmDouble cm_max){_error_("not implemented yet");};
    51                 void ConstrainMin(IssmDouble minimum){_error_("not implemented yet");};
    5247                void Extrude(int start){_error_("not supported yet");};
    5348                void GetInputAllTimeAverages(IssmDouble** pvalues,IssmDouble** ptimes, int* pnumtimes){_error_("not implemented yet");};
  • issm/trunk-jpl/src/c/classes/Inputs/DoubleInput.cpp

    r21872 r21974  
    127127}
    128128/*}}}*/
    129 void DoubleInput::Constrain(IssmDouble cm_min, IssmDouble cm_max){/*{{{*/
    130 
    131         if(!xIsNan<IssmDouble>(cm_min)) if (this->value<cm_min)this->value=cm_min;
    132         if(!xIsNan<IssmDouble>(cm_max)) if (this->value>cm_max)this->value=cm_max;
    133 
    134 }
    135 /*}}}*/
    136 void DoubleInput::ConstrainMin(IssmDouble minimum){/*{{{*/
    137         if (value<minimum) value=minimum;
    138 }
    139 /*}}}*/
    140129void DoubleInput::GetInputAverage(IssmDouble* pvalue){/*{{{*/
    141130        *pvalue=value;
     
    182171}
    183172/*}}}*/
    184 Input* DoubleInput::PointwiseDivide(Input* inputB){/*{{{*/
    185 
    186         /*Ouput*/
    187         DoubleInput* outinput=NULL;
    188 
    189         /*Intermediaries*/
    190         IssmDouble       Bvalue;
    191 
    192         /*Check that inputB is of the same type*/
    193         inputB->GetInputAverage(&Bvalue);
    194 
    195         /*Create new DoubleInput*/
    196         outinput=new DoubleInput(this->enum_type,this->value/Bvalue);
    197 
    198         /*Return output pointer*/
    199         return outinput;
    200 
    201 }
    202 /*}}}*/
    203 Input* DoubleInput::PointwiseMax(Input* input){/*{{{*/
    204 
    205         /*Ouput*/
    206         DoubleInput* outinput=NULL;
    207 
    208         /*Intermediaries*/
    209         IssmDouble       max;
    210 
    211         /*Check that inputB is of the same type*/
    212         if (input->Max() > this->Max()) max=input->Max();
    213         else max=this->Max();
    214 
    215         /*Create new DoubleInput*/
    216         outinput=new DoubleInput(this->enum_type,max);
    217 
    218         /*Return output pointer*/
    219         return outinput;
    220 
    221 }
    222 /*}}}*/
    223 Input* DoubleInput::PointwiseMin(Input* input){/*{{{*/
    224 
    225         /*Ouput*/
    226         DoubleInput* outinput=NULL;
    227 
    228         /*Intermediaries*/
    229         IssmDouble       min;
    230 
    231         /*Check that inputB is of the same type*/
    232         if (input->Min() < this->Min()) min=input->Min();
    233         else min=this->Min();
    234 
    235         /*Create new DoubleInput*/
    236         outinput=new DoubleInput(this->enum_type,min);
    237 
    238         /*Return output pointer*/
    239         return outinput;
    240 
    241 }
    242 /*}}}*/
    243173void DoubleInput::Scale(IssmDouble scale_factor){/*{{{*/
    244174        value=value*scale_factor;
  • issm/trunk-jpl/src/c/classes/Inputs/DoubleInput.h

    r21872 r21974  
    3939                int  GetResultNumberOfNodes(void){return 1;};
    4040                int   InstanceEnum();
    41                 Input* PointwiseDivide(Input* inputB);
    42                 Input* PointwiseMax(Input* inputB);
    43                 Input* PointwiseMin(Input* inputB);
    4441                void ResultToPatch(IssmDouble* values,int nodesperelement,int sid){_error_("not supported yet");};
    4542                Input* SpawnSegInput(int index1,int index2);
     
    4946                void AXPY(Input* xinput,IssmDouble scalar);
    5047                void ChangeEnum(int newenumtype);
    51                 void Constrain(IssmDouble cm_min, IssmDouble cm_max);
    52                 void ConstrainMin(IssmDouble minimum);
    5348                void Extrude(int start){_error_("not supported yet");};
    5449                void GetInputAllTimeAverages(IssmDouble** pvalues,IssmDouble** ptimes, int* pnumtimes){_error_("not implemented yet");};
  • issm/trunk-jpl/src/c/classes/Inputs/Input.h

    r21872 r21974  
    4242
    4343                virtual void   AXPY(Input* xinput,IssmDouble scalar)=0;
    44                 virtual void   Constrain(IssmDouble cm_min, IssmDouble cm_max)=0;
    45                 virtual void   ConstrainMin(IssmDouble minimum)=0;
    4644                virtual void   Extrude(int start)=0;
    4745                virtual void   GetVectorFromInputs(Vector<IssmDouble>* vector,int* doflist)=0;
     
    5755                virtual int  GetResultInterpolation(void)=0;
    5856                virtual int  GetResultNumberOfNodes(void)=0;
    59                 virtual Input* PointwiseDivide(Input* inputB)=0;
    60                 virtual Input* PointwiseMax(Input* inputmax)=0;
    61                 virtual Input* PointwiseMin(Input* inputmin)=0;
    6257                virtual Input* SpawnSegInput(int index1,int index2)=0;
    6358                virtual Input* SpawnTriaInput(int index1,int index2,int index3)=0;
  • issm/trunk-jpl/src/c/classes/Inputs/Inputs.cpp

    r20827 r21974  
    111111}
    112112/*}}}*/
    113 void  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 /*}}}*/
    125113int  Inputs::DeleteInput(int enum_type){/*{{{*/
    126114
  • issm/trunk-jpl/src/c/classes/Inputs/Inputs.h

    r20827 r21974  
    2626                void        ChangeEnum(int enumtype,int new_enumtype);
    2727                void        Configure(Parameters* parameters);
    28                 void        ConstrainMin(int constrain_enum, IssmDouble minimum);
    2928                int         DeleteInput(int enum_type);
    3029                void        DuplicateInput(int original_enum,int new_enum);
  • issm/trunk-jpl/src/c/classes/Inputs/IntInput.cpp

    r21872 r21974  
    127127}
    128128/*}}}*/
    129 void IntInput::Constrain(IssmDouble cm_min, IssmDouble cm_max){/*{{{*/
    130 
    131         if(!xIsNan<IssmDouble>(cm_min)) if (this->value<cm_min)this->value=reCast<int>(cm_min);
    132         if(!xIsNan<IssmDouble>(cm_max)) if (this->value>cm_max)this->value=reCast<int>(cm_max);
    133 
    134 }
    135 /*}}}*/
    136129void IntInput::GetInputAverage(IssmDouble* pvalue){/*{{{*/
    137130        *pvalue=reCast<IssmDouble>(value);
  • issm/trunk-jpl/src/c/classes/Inputs/IntInput.h

    r21872 r21974  
    4040                int  GetResultNumberOfNodes(void){return 1;};
    4141                int   InstanceEnum();
    42                 Input* PointwiseDivide(Input* inputB){_error_("not implemented yet");};
    43                 Input* PointwiseMax(Input* inputB){_error_("not implemented yet");};
    44                 Input* PointwiseMin(Input* inputB){_error_("not implemented yet");};
    4542                void ResultToPatch(IssmDouble* values,int nodesperelement,int sid){_error_("not supported yet");};
    4643                Input* SpawnSegInput(int index1,int index2);
     
    5047                void AXPY(Input* xinput,IssmDouble scalar);
    5148                void ChangeEnum(int newenumtype);
    52                 void Constrain(IssmDouble cm_min, IssmDouble cm_max);
    53                 void ConstrainMin(IssmDouble minimum){_error_("not implemented yet");};
    5449                void Extrude(int start){_error_("not supported yet");};
    5550                void GetInputAllTimeAverages(IssmDouble** pvalues,IssmDouble** ptimes, int* pnumtimes){_error_("not implemented yet");};
  • issm/trunk-jpl/src/c/classes/Inputs/PentaInput.cpp

    r21894 r21974  
    217217void PentaInput::Configure(Parameters* parameters){/*{{{*/
    218218        /*do nothing: */
    219 }
    220 /*}}}*/
    221 void PentaInput::Constrain(IssmDouble cm_min, IssmDouble cm_max){/*{{{*/
    222 
    223         int i;
    224         const int numnodes=this->NumberofNodes(this->interpolation_type);
    225 
    226         if(!xIsNan<IssmDouble>(cm_min)) for(i=0;i<numnodes;i++)if (this->values[i]<cm_min)this->values[i]=cm_min;
    227         if(!xIsNan<IssmDouble>(cm_max)) for(i=0;i<numnodes;i++)if (this->values[i]>cm_max)this->values[i]=cm_max;
    228 
    229 }
    230 /*}}}*/
    231 void PentaInput::ConstrainMin(IssmDouble minimum){/*{{{*/
    232 
    233         int numnodes = this->NumberofNodes(this->interpolation_type);
    234         for(int i=0;i<numnodes;i++) if (values[i]<minimum) values[i]=minimum;
    235219}
    236220/*}}}*/
     
    321305}
    322306/*}}}*/
    323 Input* PentaInput::PointwiseDivide(Input* inputB){/*{{{*/
    324 
    325         /*Ouput*/
    326         PentaInput* outinput=NULL;
    327 
    328         /*Intermediaries*/
    329         PentaInput *xinputB  = NULL;
    330         const int   numnodes = this->NumberofNodes(this->interpolation_type);
    331 
    332         /*Check that inputB is of the same type*/
    333         if(inputB->ObjectEnum()!=PentaInputEnum)     _error_("Operation not permitted because inputB is of type " << EnumToStringx(inputB->ObjectEnum()));
    334         xinputB=(PentaInput*)inputB;
    335         if(xinputB->interpolation_type!=this->interpolation_type) _error_("Operation not permitted because inputB is of type " << EnumToStringx(xinputB->interpolation_type));
    336 
    337         /*Allocate intermediary*/
    338         IssmDouble* AdotBvalues=xNew<IssmDouble>(numnodes);
    339 
    340         /*Create point wise sum*/
    341         for(int i=0;i<numnodes;i++){
    342                 _assert_(xinputB->values[i]!=0);
    343                 AdotBvalues[i]=this->values[i]/xinputB->values[i];
    344         }
    345 
    346         /*Create new Penta vertex input (copy of current input)*/
    347         outinput=new PentaInput(this->enum_type,AdotBvalues,this->interpolation_type);
    348 
    349         /*Return output pointer*/
    350         xDelete<IssmDouble>(AdotBvalues);
    351         return outinput;
    352 
    353 }
    354 /*}}}*/
    355 Input* PentaInput::PointwiseMax(Input* inputB){/*{{{*/
    356 
    357         /*Ouput*/
    358         PentaInput* outinput=NULL;
    359 
    360         /*Intermediaries*/
    361         int         i;
    362         PentaInput  *xinputB   = NULL;
    363         const int   numnodes  = this->NumberofNodes(this->interpolation_type);
    364         IssmDouble *maxvalues = xNew<IssmDouble>(numnodes);
    365 
    366         /*Check that inputB is of the same type*/
    367         if(inputB->ObjectEnum()!=PentaInputEnum) _error_("Operation not permitted because inputB is of type " << EnumToStringx(inputB->ObjectEnum()));
    368         xinputB=(PentaInput*)inputB;
    369         if(xinputB->interpolation_type!=this->interpolation_type) _error_("Operation not permitted because inputB is of type " << EnumToStringx(xinputB->interpolation_type));
    370 
    371         /*Create point wise max*/
    372         for(i=0;i<numnodes;i++){
    373                 if(this->values[i] < xinputB->values[i]) maxvalues[i]=xinputB->values[i];
    374                 else maxvalues[i]=this->values[i];
    375         }
    376 
    377         /*Create new Penta vertex input (copy of current input)*/
    378         outinput=new PentaInput(this->enum_type,&maxvalues[0],this->interpolation_type);
    379 
    380         /*Return output pointer*/
    381         xDelete<IssmDouble>(maxvalues);
    382         return outinput;
    383 }
    384 /*}}}*/
    385 Input* PentaInput::PointwiseMin(Input* inputB){/*{{{*/
    386 
    387         /*Ouput*/
    388         PentaInput* outinput=NULL;
    389 
    390         /*Intermediaries*/
    391         int         i;
    392         PentaInput  *xinputB   = NULL;
    393         const int   numnodes  = this->NumberofNodes(this->interpolation_type);
    394         IssmDouble *minvalues = xNew<IssmDouble>(numnodes);
    395 
    396         /*Check that inputB is of the same type*/
    397         if(inputB->ObjectEnum()!=PentaInputEnum)       _error_("Operation not permitted because inputB is of type " << EnumToStringx(inputB->ObjectEnum()));
    398         xinputB=(PentaInput*)inputB;
    399         if(xinputB->interpolation_type!=this->interpolation_type) _error_("Operation not permitted because inputB is of type " << EnumToStringx(xinputB->interpolation_type));
    400 
    401         /*Create point wise min*/
    402         for(i=0;i<numnodes;i++){
    403                 if(this->values[i] > xinputB->values[i]) minvalues[i]=xinputB->values[i];
    404                 else minvalues[i]=this->values[i];
    405         }
    406 
    407         /*Create new Penta vertex input (copy of current input)*/
    408         outinput=new PentaInput(this->enum_type,&minvalues[0],this->interpolation_type);
    409 
    410         /*Return output pointer*/
    411         xDelete<IssmDouble>(minvalues);
    412         return outinput;
    413 }
    414 /*}}}*/
    415307void PentaInput::Scale(IssmDouble scale_factor){/*{{{*/
    416308
  • issm/trunk-jpl/src/c/classes/Inputs/PentaInput.h

    r21872 r21974  
    3636                /*PentaInput management*/
    3737                int   InstanceEnum();
    38                 Input* PointwiseDivide(Input* inputB);
    39                 Input* PointwiseMin(Input* inputB);
    40                 Input* PointwiseMax(Input* inputB);
    4138                int  GetResultInterpolation(void);
    4239                int  GetResultNumberOfNodes(void);
     
    4845                void AXPY(Input* xinput,IssmDouble scalar);
    4946                void ChangeEnum(int newenumtype);
    50                 void Constrain(IssmDouble cm_min, IssmDouble cm_max);
    51                 void ConstrainMin(IssmDouble minimum);
    5247                void Extrude(int start);
    5348                void GetInputAllTimeAverages(IssmDouble** pvalues,IssmDouble** ptimes, int* pnumtimes){_error_("not implemented yet");};
  • issm/trunk-jpl/src/c/classes/Inputs/SegInput.h

    r21897 r21974  
    4141                int  GetResultNumberOfNodes(void){_error_("not implemented");};
    4242                int    InstanceEnum();
    43                 Input* PointwiseDivide(Input* inputB){_error_("not supported yet");};
    44                 Input* PointwiseMax(Input* inputB){_error_("not supported yet");};
    45                 Input* PointwiseMin(Input* inputB){_error_("not supported yet");};
    4643                void ResultToPatch(IssmDouble* values,int nodesperelement,int sid){_error_("not supported yet");};
    4744                Input* SpawnSegInput(int index1,int index2){_error_("not implemented yet");};
     
    5148                void AXPY(Input* xinput,IssmDouble scalar){_error_("not implemented yet");};
    5249                void ChangeEnum(int newenumtype){_error_("not implemented yet");};
    53                 void Constrain(IssmDouble cm_min, IssmDouble cm_max){_error_("not implemented yet");};
    54                 void ConstrainMin(IssmDouble minimum){_error_("not implemented yet");};
    5550                void Extrude(int start){_error_("not supported yet");};
    5651                void GetInputAllTimeAverages(IssmDouble** pvalues,IssmDouble** ptimes, int* pnumtimes){_error_("not implemented yet");};
  • issm/trunk-jpl/src/c/classes/Inputs/TetraInput.cpp

    r21872 r21974  
    238238}
    239239/*}}}*/
    240 void TetraInput::Constrain(IssmDouble cm_min, IssmDouble cm_max){/*{{{*/
    241 
    242         int i;
    243         const int numnodes=this->NumberofNodes(this->interpolation_type);
    244 
    245         if(!xIsNan<IssmDouble>(cm_min)) for(i=0;i<numnodes;i++)if (this->values[i]<cm_min)this->values[i]=cm_min;
    246         if(!xIsNan<IssmDouble>(cm_max)) for(i=0;i<numnodes;i++)if (this->values[i]>cm_max)this->values[i]=cm_max;
    247 
    248 }
    249 /*}}}*/
    250 void TetraInput::ConstrainMin(IssmDouble minimum){/*{{{*/
    251 
    252         int numnodes = this->NumberofNodes(this->interpolation_type);
    253         for(int i=0;i<numnodes;i++) if (values[i]<minimum) values[i]=minimum;
    254 }
    255 /*}}}*/
    256240void TetraInput::GetVectorFromInputs(Vector<IssmDouble>* vector,int* doflist){/*{{{*/
    257241        const int numvertices=4;
     
    312296}
    313297/*}}}*/
    314 Input* TetraInput::PointwiseDivide(Input* inputB){/*{{{*/
    315 
    316         /*Ouput*/
    317         TetraInput* outinput=NULL;
    318 
    319         /*Intermediaries*/
    320         TetraInput *xinputB  = NULL;
    321         const int   numnodes = this->NumberofNodes(this->interpolation_type);
    322 
    323         /*Check that inputB is of the same type*/
    324         if(inputB->ObjectEnum()!=TetraInputEnum)     _error_("Operation not permitted because inputB is of type " << EnumToStringx(inputB->ObjectEnum()));
    325         xinputB=(TetraInput*)inputB;
    326         if(xinputB->interpolation_type!=this->interpolation_type) _error_("Operation not permitted because inputB is of type " << EnumToStringx(xinputB->interpolation_type));
    327 
    328         /*Allocate intermediary*/
    329         IssmDouble* AdotBvalues=xNew<IssmDouble>(numnodes);
    330 
    331         /*Create point wise division*/
    332         for(int i=0;i<numnodes;i++){
    333                 _assert_(xinputB->values[i]!=0);
    334                 AdotBvalues[i]=this->values[i]/xinputB->values[i];
    335         }
    336 
    337         /*Create new Tetra vertex input (copy of current input)*/
    338         outinput=new TetraInput(this->enum_type,AdotBvalues,this->interpolation_type);
    339 
    340         /*Return output pointer*/
    341         xDelete<IssmDouble>(AdotBvalues);
    342         return outinput;
    343 
    344 }
    345 /*}}}*/
    346 Input* TetraInput::PointwiseMax(Input* inputB){/*{{{*/
    347 
    348         /*Ouput*/
    349         TetraInput* outinput=NULL;
    350 
    351         /*Intermediaries*/
    352         int         i;
    353         TetraInput  *xinputB   = NULL;
    354         const int   numnodes  = this->NumberofNodes(this->interpolation_type);
    355         IssmDouble *maxvalues = xNew<IssmDouble>(numnodes);
    356 
    357         /*Check that inputB is of the same type*/
    358         if(inputB->ObjectEnum()!=TetraInputEnum) _error_("Operation not permitted because inputB is of type " << EnumToStringx(inputB->ObjectEnum()));
    359         xinputB=(TetraInput*)inputB;
    360         if(xinputB->interpolation_type!=this->interpolation_type) _error_("Operation not permitted because inputB is of type " << EnumToStringx(xinputB->interpolation_type));
    361 
    362         /*Create point wise max*/
    363         for(i=0;i<numnodes;i++){
    364                 if(this->values[i] < xinputB->values[i]) maxvalues[i]=xinputB->values[i];
    365                 else maxvalues[i]=this->values[i];
    366         }
    367 
    368         /*Create new Tetra vertex input (copy of current input)*/
    369         outinput=new TetraInput(this->enum_type,&maxvalues[0],this->interpolation_type);
    370 
    371         /*Return output pointer*/
    372         xDelete<IssmDouble>(maxvalues);
    373         return outinput;
    374 
    375 }
    376 /*}}}*/
    377 Input* TetraInput::PointwiseMin(Input* inputB){/*{{{*/
    378 
    379         /*Ouput*/
    380         TetraInput* outinput=NULL;
    381 
    382         /*Intermediaries*/
    383         int         i;
    384         TetraInput  *xinputB   = NULL;
    385         const int   numnodes  = this->NumberofNodes(this->interpolation_type);
    386         IssmDouble *minvalues = xNew<IssmDouble>(numnodes);
    387 
    388         /*Check that inputB is of the same type*/
    389         if(inputB->ObjectEnum()!=TetraInputEnum)       _error_("Operation not permitted because inputB is of type " << EnumToStringx(inputB->ObjectEnum()));
    390         xinputB=(TetraInput*)inputB;
    391         if(xinputB->interpolation_type!=this->interpolation_type) _error_("Operation not permitted because inputB is of type " << EnumToStringx(xinputB->interpolation_type));
    392 
    393         /*Create point wise min*/
    394         for(i=0;i<numnodes;i++){
    395                 if(this->values[i] > xinputB->values[i]) minvalues[i]=xinputB->values[i];
    396                 else minvalues[i]=this->values[i];
    397         }
    398 
    399         /*Create new Tetra vertex input (copy of current input)*/
    400         outinput=new TetraInput(this->enum_type,&minvalues[0],this->interpolation_type);
    401 
    402         /*Return output pointer*/
    403         xDelete<IssmDouble>(minvalues);
    404         return outinput;
    405 
    406 }
    407 /*}}}*/
    408298void TetraInput::Scale(IssmDouble scale_factor){/*{{{*/
    409299
  • issm/trunk-jpl/src/c/classes/Inputs/TetraInput.h

    r21872 r21974  
    4141                int    GetResultNumberOfNodes(void);
    4242                int    InstanceEnum();
    43                 Input* PointwiseDivide(Input* inputB);
    44                 Input* PointwiseMax(Input* inputB);
    45                 Input* PointwiseMin(Input* inputB);
    4643                void   ResultToPatch(IssmDouble* values,int nodesperelement,int sid);
    4744                Input* SpawnSegInput(int index1,int index2){_error_("not supported yet");};
     
    5148                void AXPY(Input* xinput,IssmDouble scalar);
    5249                void ChangeEnum(int newenumtype);
    53                 void Constrain(IssmDouble cm_min, IssmDouble cm_max);
    54                 void ConstrainMin(IssmDouble minimum);
    5550                void Extrude(int start){_error_("not supported yet");};
    5651                void GetInputAllTimeAverages(IssmDouble** pvalues,IssmDouble** ptimes, int* pnumtimes);
  • issm/trunk-jpl/src/c/classes/Inputs/TransientInput.h

    r21917 r21974  
    4545                int  GetResultNumberOfNodes(void);
    4646                int    InstanceEnum();
    47                 Input* PointwiseDivide(Input* input_in){_error_("not implemented yet");};
    48                 Input* PointwiseMax(Input* input_in){_error_("not implemented yet");};
    49                 Input* PointwiseMin(Input* input_in){_error_("not implemented yet");};
    5047                void ResultToPatch(IssmDouble* values,int nodesperelement,int sid){_error_("not supported yet");};
    5148                Input* SpawnSegInput(int index1,int index2);
     
    5552                void AXPY(Input* xforcing,IssmDouble scalar){_error_("not implemented yet");};
    5653                void ChangeEnum(int newenumtype);
    57                 void Constrain(IssmDouble cm_min, IssmDouble cm_max){_error_("not implemented yet");};
    58                 void ConstrainMin(IssmDouble minimum){_error_("not implemented yet");};
    5954                void Extrude(int start);
    6055                void GetInputAllTimeAverages(IssmDouble** pvalues,IssmDouble** ptimes, int* pnumtimes);
  • issm/trunk-jpl/src/c/classes/Inputs/TriaInput.cpp

    r21872 r21974  
    271271}
    272272/*}}}*/
    273 void TriaInput::Constrain(IssmDouble cm_min, IssmDouble cm_max){/*{{{*/
    274 
    275         int i;
    276         const int numnodes=this->NumberofNodes(this->interpolation_type);
    277 
    278         if(!xIsNan<IssmDouble>(cm_min)) for(i=0;i<numnodes;i++)if (this->values[i]<cm_min)this->values[i]=cm_min;
    279         if(!xIsNan<IssmDouble>(cm_max)) for(i=0;i<numnodes;i++)if (this->values[i]>cm_max)this->values[i]=cm_max;
    280 
    281 }
    282 /*}}}*/
    283 void TriaInput::ConstrainMin(IssmDouble minimum){/*{{{*/
    284 
    285         int numnodes = this->NumberofNodes(this->interpolation_type);
    286         for(int i=0;i<numnodes;i++) if (values[i]<minimum) values[i]=minimum;
    287 }
    288 /*}}}*/
    289273void TriaInput::GetVectorFromInputs(Vector<IssmDouble>* vector,int* doflist){/*{{{*/
    290274        const int numvertices=3;
     
    345329}
    346330/*}}}*/
    347 Input* TriaInput::PointwiseMax(Input* inputB){/*{{{*/
    348 
    349         /*Ouput*/
    350         TriaInput* outinput=NULL;
    351 
    352         /*Intermediaries*/
    353         int         i;
    354         TriaInput  *xinputB   = NULL;
    355         const int   numnodes  = this->NumberofNodes(this->interpolation_type);
    356         IssmDouble *maxvalues = xNew<IssmDouble>(numnodes);
    357 
    358         /*Check that inputB is of the same type*/
    359         if(inputB->ObjectEnum()!=TriaInputEnum) _error_("Operation not permitted because inputB is of type " << EnumToStringx(inputB->ObjectEnum()));
    360         xinputB=(TriaInput*)inputB;
    361         if(xinputB->interpolation_type!=this->interpolation_type) _error_("Operation not permitted because inputB is of type " << EnumToStringx(xinputB->interpolation_type));
    362 
    363         /*Create point wise max*/
    364         for(i=0;i<numnodes;i++){
    365                 if(this->values[i] < xinputB->values[i]) maxvalues[i]=xinputB->values[i];
    366                 else maxvalues[i]=this->values[i];
    367         }
    368 
    369         /*Create new Tria vertex input (copy of current input)*/
    370         outinput=new TriaInput(this->enum_type,&maxvalues[0],this->interpolation_type);
    371 
    372         /*Return output pointer*/
    373         xDelete<IssmDouble>(maxvalues);
    374         return outinput;
    375 
    376 }
    377 /*}}}*/
    378 Input* TriaInput::PointwiseMin(Input* inputB){/*{{{*/
    379 
    380         /*Ouput*/
    381         TriaInput* outinput=NULL;
    382 
    383         /*Intermediaries*/
    384         int         i;
    385         TriaInput  *xinputB   = NULL;
    386         const int   numnodes  = this->NumberofNodes(this->interpolation_type);
    387         IssmDouble *minvalues = xNew<IssmDouble>(numnodes);
    388 
    389         /*Check that inputB is of the same type*/
    390         if(inputB->ObjectEnum()!=TriaInputEnum)       _error_("Operation not permitted because inputB is of type " << EnumToStringx(inputB->ObjectEnum()));
    391         xinputB=(TriaInput*)inputB;
    392         if(xinputB->interpolation_type!=this->interpolation_type) _error_("Operation not permitted because inputB is of type " << EnumToStringx(xinputB->interpolation_type));
    393 
    394         /*Create point wise min*/
    395         for(i=0;i<numnodes;i++){
    396                 if(this->values[i] > xinputB->values[i]) minvalues[i]=xinputB->values[i];
    397                 else minvalues[i]=this->values[i];
    398         }
    399 
    400         /*Create new Tria vertex input (copy of current input)*/
    401         outinput=new TriaInput(this->enum_type,&minvalues[0],this->interpolation_type);
    402 
    403         /*Return output pointer*/
    404         xDelete<IssmDouble>(minvalues);
    405         return outinput;
    406 
    407 }
    408 /*}}}*/
    409 Input* TriaInput::PointwiseDivide(Input* inputB){/*{{{*/
    410 
    411         /*Ouput*/
    412         TriaInput* outinput=NULL;
    413 
    414         /*Intermediaries*/
    415         TriaInput *xinputB  = NULL;
    416         const int   numnodes = this->NumberofNodes(this->interpolation_type);
    417 
    418         /*Check that inputB is of the same type*/
    419         if(inputB->ObjectEnum()!=TriaInputEnum)     _error_("Operation not permitted because inputB is of type " << EnumToStringx(inputB->ObjectEnum()));
    420         xinputB=(TriaInput*)inputB;
    421         if(xinputB->interpolation_type!=this->interpolation_type) _error_("Operation not permitted because inputB is of type " << EnumToStringx(xinputB->interpolation_type));
    422 
    423         /*Allocate intermediary*/
    424         IssmDouble* AdotBvalues=xNew<IssmDouble>(numnodes);
    425 
    426         /*Create point wise division*/
    427         for(int i=0;i<numnodes;i++){
    428                 _assert_(xinputB->values[i]!=0);
    429                 AdotBvalues[i]=this->values[i]/xinputB->values[i];
    430         }
    431 
    432         /*Create new Tria vertex input (copy of current input)*/
    433         outinput=new TriaInput(this->enum_type,AdotBvalues,this->interpolation_type);
    434 
    435         /*Return output pointer*/
    436         xDelete<IssmDouble>(AdotBvalues);
    437         return outinput;
    438 
    439 }
    440 /*}}}*/
    441331void TriaInput::Scale(IssmDouble scale_factor){/*{{{*/
    442332
  • issm/trunk-jpl/src/c/classes/Inputs/TriaInput.h

    r21872 r21974  
    4141                int    GetResultNumberOfNodes(void);
    4242                int    InstanceEnum();
    43                 Input* PointwiseDivide(Input* inputB);
    44                 Input* PointwiseMax(Input* inputB);
    45                 Input* PointwiseMin(Input* inputB);
    4643                void   ResultToPatch(IssmDouble* values,int nodesperelement,int sid);
    4744                Input* SpawnSegInput(int index1,int index2);
     
    5148                void AXPY(Input* xinput,IssmDouble scalar);
    5249                void ChangeEnum(int newenumtype);
    53                 void Constrain(IssmDouble cm_min, IssmDouble cm_max);
    54                 void ConstrainMin(IssmDouble minimum);
    5550                void Extrude(int start){_error_("not supported yet");};
    5651                void GetInputAllTimeAverages(IssmDouble** pvalues,IssmDouble** ptimes, int* pnumtimes);
Note: See TracChangeset for help on using the changeset viewer.