Changeset 20827


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

CHG: Alphabetized all function names under classes

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

Legend:

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

    r20810 r20827  
    6666                IssmDouble Min(void){_error_("Min not implemented for booleans");};
    6767                IssmDouble MinAbs(void){_error_("Min not implemented for booleans");};
     68                void Scale(IssmDouble scale_factor);
    6869                void Set(IssmDouble setvalue){_error_("Set not implemented yet");};
    69                 void Scale(IssmDouble scale_factor);
    7070                void SquareMin(IssmDouble* psquaremin, Parameters* parameters);
    7171                void VerticallyIntegrate(Input* thickness_input){_error_("not supported yet");};
  • issm/trunk-jpl/src/c/classes/Inputs/ControlInput.cpp

    r19254 r20827  
    5656
    5757/*Object virtual functions definitions:*/
    58 void ControlInput::Echo(void){/*{{{*/
    59         this->DeepEcho();
     58Object* ControlInput::copy() {/*{{{*/
     59
     60        ControlInput* output=NULL;
     61
     62        output = new ControlInput();
     63        output->enum_type=this->enum_type;
     64        output->control_id=this->control_id;
     65
     66        if(values)      output->values      = xDynamicCast<Input*>(this->values->copy());
     67        if(savedvalues) output->savedvalues = xDynamicCast<Input*>(this->savedvalues->copy());
     68        if(minvalues)   output->minvalues   = xDynamicCast<Input*>(this->minvalues->copy());
     69        if(maxvalues)   output->maxvalues   = xDynamicCast<Input*>(this->maxvalues->copy());
     70        if(gradient)    output->gradient    = xDynamicCast<Input*>(this->gradient->copy());
     71
     72        return output;
    6073}
    6174/*}}}*/
     
    7184}
    7285/*}}}*/
     86void ControlInput::Echo(void){/*{{{*/
     87        this->DeepEcho();
     88}
     89/*}}}*/
    7390int  ControlInput::Id(void){ return -1; }/*{{{*/
    74 /*}}}*/
    75 int  ControlInput::ObjectEnum(void){/*{{{*/
    76 
    77         return ControlInputEnum;
    78 
    79 }
    80 /*}}}*/
    81 Object* ControlInput::copy() {/*{{{*/
    82 
    83         ControlInput* output=NULL;
    84 
    85         output = new ControlInput();
    86         output->enum_type=this->enum_type;
    87         output->control_id=this->control_id;
    88 
    89         if(values)      output->values      = xDynamicCast<Input*>(this->values->copy());
    90         if(savedvalues) output->savedvalues = xDynamicCast<Input*>(this->savedvalues->copy());
    91         if(minvalues)   output->minvalues   = xDynamicCast<Input*>(this->minvalues->copy());
    92         if(maxvalues)   output->maxvalues   = xDynamicCast<Input*>(this->maxvalues->copy());
    93         if(gradient)    output->gradient    = xDynamicCast<Input*>(this->gradient->copy());
    94 
    95         return output;
    96 }
    9791/*}}}*/
    9892void ControlInput::Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ /*{{{*/
     
    130124}
    131125/*}}}*/
     126int  ControlInput::ObjectEnum(void){/*{{{*/
     127
     128        return ControlInputEnum;
     129
     130}
     131/*}}}*/
    132132
    133133/*ControlInput management*/
     
    143143        values->AXPY(xinput,scalar);
    144144}/*}}}*/
     145void ControlInput::Configure(Parameters* parameters){/*{{{*/
     146        /*do nothing: */
     147}
     148/*}}}*/
    145149void ControlInput::Constrain(void){/*{{{*/
    146150
     
    160164        //gradient->Extrude();
    161165}/*}}}*/
    162 int  ControlInput::GetResultInterpolation(void){/*{{{*/
    163 
    164         return values->GetResultInterpolation();
    165 
    166 }
    167 /*}}}*/
    168 int  ControlInput::GetResultNumberOfNodes(void){/*{{{*/
    169 
    170         return values->GetResultNumberOfNodes();
    171 
    172 }
    173 /*}}}*/
    174166void ControlInput::GetGradient(Vector<IssmDouble>* gradient_vec,int* doflist){/*{{{*/
    175167        if(gradient) gradient->GetVectorFromInputs(gradient_vec,doflist);
     168}/*}}}*/
     169void ControlInput::GetGradientValue(IssmDouble* pvalue,Gauss* gauss){/*{{{*/
     170        gradient->GetInputValue(pvalue,gauss);
     171}/*}}}*/
     172void ControlInput::GetInputAverage(IssmDouble* pvalue){/*{{{*/
     173        values->GetInputAverage(pvalue);
     174}/*}}}*/
     175void ControlInput::GetInputDerivativeValue(IssmDouble* derivativevalues, IssmDouble* xyz_list, Gauss* gauss){/*{{{*/
     176        values->GetInputDerivativeValue(derivativevalues,xyz_list,gauss);
     177}/*}}}*/
     178void ControlInput::GetInputValue(bool* pvalue){/*{{{*/
     179        values->GetInputValue(pvalue);
     180}/*}}}*/
     181void ControlInput::GetInputValue(int* pvalue){/*{{{*/
     182        values->GetInputValue(pvalue);
     183}/*}}}*/
     184void ControlInput::GetInputValue(IssmDouble* pvalue){/*{{{*/
     185        values->GetInputValue(pvalue);
     186}/*}}}*/
     187void ControlInput::GetInputValue(IssmDouble* pvalue,Gauss* gauss){/*{{{*/
     188        values->GetInputValue(pvalue,gauss);
     189}/*}}}*/
     190int  ControlInput::GetResultInterpolation(void){/*{{{*/
     191
     192        return values->GetResultInterpolation();
     193
     194}
     195/*}}}*/
     196int  ControlInput::GetResultNumberOfNodes(void){/*{{{*/
     197
     198        return values->GetResultNumberOfNodes();
     199
     200}
     201/*}}}*/
     202void ControlInput::GetVectorFromInputs(Vector<IssmDouble>* vector,int* doflist){/*{{{*/
     203        values->GetVectorFromInputs(vector,doflist);
     204}/*}}}*/
     205void ControlInput::GetVectorFromInputs(Vector<IssmDouble>* vector,int* doflist,const char* data){/*{{{*/
     206         if(strcmp(data,"value")==0){
     207                 _assert_(values);
     208                 values->GetVectorFromInputs(vector,doflist);
     209         }
     210         else if (strcmp(data,"lowerbound")==0){
     211                 _assert_(minvalues);
     212                 minvalues->GetVectorFromInputs(vector,doflist);
     213         }
     214         else if (strcmp(data,"upperbound")==0){
     215                 _assert_(maxvalues);
     216                 maxvalues->GetVectorFromInputs(vector,doflist);
     217         }
     218         else if (strcmp(data,"gradient")==0){
     219                 _assert_(gradient);
     220                 gradient->GetVectorFromInputs(vector,doflist);
     221         }
     222         else{
     223                 _error_("Data " << data << " not supported yet");
     224         }
     225}/*}}}*/
     226IssmDouble ControlInput::Min(void){/*{{{*/
     227
     228        return values->Min();
     229
     230}
     231/*}}}*/
     232void ControlInput::SaveValue(void){/*{{{*/
     233        if(!values) _error_("Values of " << EnumToStringx(this->enum_type) << " not found");
     234
     235        if(savedvalues) delete this->savedvalues;
     236        this->savedvalues=xDynamicCast<Input*>(this->values->copy());
    176237}/*}}}*/
    177238void ControlInput::ScaleGradient(IssmDouble scaling_factor){/*{{{*/
     
    207268
    208269}/*}}}*/
     270Input* ControlInput::SpawnSegInput(int index1,int index2){/*{{{*/
     271        return values->SpawnSegInput(index1,index2);
     272}/*}}}*/
    209273Input* ControlInput::SpawnTriaInput(int index1,int index2,int index3){/*{{{*/
    210274        return values->SpawnTriaInput(index1,index2,index3);
    211 }/*}}}*/
    212 Input* ControlInput::SpawnSegInput(int index1,int index2){/*{{{*/
    213         return values->SpawnSegInput(index1,index2);
    214 }/*}}}*/
    215 void ControlInput::GetVectorFromInputs(Vector<IssmDouble>* vector,int* doflist){/*{{{*/
    216         values->GetVectorFromInputs(vector,doflist);
    217 }/*}}}*/
    218 void ControlInput::GetVectorFromInputs(Vector<IssmDouble>* vector,int* doflist,const char* data){/*{{{*/
    219          if(strcmp(data,"value")==0){
    220                  _assert_(values);
    221                  values->GetVectorFromInputs(vector,doflist);
    222          }
    223          else if (strcmp(data,"lowerbound")==0){
    224                  _assert_(minvalues);
    225                  minvalues->GetVectorFromInputs(vector,doflist);
    226          }
    227          else if (strcmp(data,"upperbound")==0){
    228                  _assert_(maxvalues);
    229                  maxvalues->GetVectorFromInputs(vector,doflist);
    230          }
    231          else if (strcmp(data,"gradient")==0){
    232                  _assert_(gradient);
    233                  gradient->GetVectorFromInputs(vector,doflist);
    234          }
    235          else{
    236                  _error_("Data " << data << " not supported yet");
    237          }
    238 }/*}}}*/
    239 void ControlInput::GetInputAverage(IssmDouble* pvalue){/*{{{*/
    240         values->GetInputAverage(pvalue);
    241 }/*}}}*/
    242 void ControlInput::GetInputValue(bool* pvalue){/*{{{*/
    243         values->GetInputValue(pvalue);
    244 }/*}}}*/
    245 void ControlInput::GetInputValue(int* pvalue){/*{{{*/
    246         values->GetInputValue(pvalue);
    247 }/*}}}*/
    248 void ControlInput::GetInputValue(IssmDouble* pvalue){/*{{{*/
    249         values->GetInputValue(pvalue);
    250 }/*}}}*/
    251 void ControlInput::GetInputValue(IssmDouble* pvalue,Gauss* gauss){/*{{{*/
    252         values->GetInputValue(pvalue,gauss);
    253 }/*}}}*/
    254 void ControlInput::GetGradientValue(IssmDouble* pvalue,Gauss* gauss){/*{{{*/
    255         gradient->GetInputValue(pvalue,gauss);
    256 }/*}}}*/
    257 void ControlInput::GetInputDerivativeValue(IssmDouble* derivativevalues, IssmDouble* xyz_list, Gauss* gauss){/*{{{*/
    258         values->GetInputDerivativeValue(derivativevalues,xyz_list,gauss);
    259 }/*}}}*/
    260 IssmDouble ControlInput::Min(void){/*{{{*/
    261 
    262         return values->Min();
    263 
    264 }
    265 /*}}}*/
    266 void ControlInput::SaveValue(void){/*{{{*/
    267         if(!values) _error_("Values of " << EnumToStringx(this->enum_type) << " not found");
    268 
    269         if(savedvalues) delete this->savedvalues;
    270         this->savedvalues=xDynamicCast<Input*>(this->values->copy());
    271275}/*}}}*/
    272276void ControlInput::UpdateValue(IssmDouble scalar){/*{{{*/
     
    281285        values->VerticallyIntegrate(thickness_input);
    282286}/*}}}*/
    283 void ControlInput::Configure(Parameters* parameters){/*{{{*/
    284         /*do nothing: */
    285 }
    286 /*}}}*/
  • issm/trunk-jpl/src/c/classes/Inputs/ControlInput.h

    r19725 r20827  
    1616
    1717        public:
     18                int    control_id;
    1819                int    enum_type;
    19                 int    control_id;
     20                Input* gradient;
     21                Input* maxvalues;
     22                Input* minvalues;
     23                Input* savedvalues;
    2024                Input* values;
    21                 Input* savedvalues;
    22                 Input* minvalues;
    23                 Input* maxvalues;
    24                 Input* gradient;
    2525
    2626                /*ControlInput constructors, destructors: {{{*/
     
    3030                /*}}}*/
    3131                /*Object virtual functions definitions:{{{ */
     32                Object* copy();
     33                void  DeepEcho();
    3234                void  Echo();
    33                 void  DeepEcho();
    3435                int   Id();
     36                void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);
    3537                int   ObjectEnum();
    36                 Object* copy();
    37                 void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);
    3838                /*}}}*/
    3939                /*ControlInput management: {{{*/
    40                 int    InstanceEnum();
    41                 Input* SpawnTriaInput(int index1,int index2,int index3);
    42                 Input* SpawnSegInput(int index1,int index2);
    43                 Input* PointwiseDivide(Input* inputB){_error_("not implemented yet");};
    44                 Input* PointwiseMin(Input* inputB){_error_("not implemented yet");};
    45                 Input* PointwiseMax(Input* inputB){_error_("not implemented yet");};
    4640                void AddTimeValues(IssmDouble* values,int step,IssmDouble time){_error_("not supported yet");};
    4741                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");};
     45                int    InstanceEnum();
     46                Input* SpawnSegInput(int index1,int index2);
     47                Input* SpawnTriaInput(int index1,int index2,int index3);
    4848                /*}}}*/
    4949                /*numerics: {{{*/
     50                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");};
     54                void ChangeEnum(int newenumtype){_error_("not implemented yet");};
     55                void Extrude(int start);
     56                void GetGradient(Vector<IssmDouble>* gradient_vec,int* doflist);
    5057                void GetGradientValue(IssmDouble* pvalue,Gauss* gauss);
    51                 void SetInput(Input* in_input);
     58                void GetInputAllTimeAverages(IssmDouble** pvalues,IssmDouble** ptimes, int* pnumtimes){_error_("not implemented yet");};
     59                void GetInputAverage(IssmDouble* pvalue);
     60                void GetInputDerivativeValue(IssmDouble* derivativevalues, IssmDouble* xyz_list,Gauss* gauss);
     61                void GetInputDerivativeAverageValue(IssmDouble* derivativevalues, IssmDouble* xyz_list){_error_("not implemented yet");};
     62                void GetInputUpToCurrentTimeAverages(IssmDouble** pvalues, IssmDouble** ptimes, int* pnumtimes, IssmDouble currenttime){_error_("not implemented yet");};
    5263                void GetInputValue(bool* pvalue);
    5364                void GetInputValue(int* pvalue);
     
    5667                void GetInputValue(IssmDouble* pvalue,Gauss* gauss,IssmDouble time){_error_("not implemented yet");};
    5768                void GetInputValue(IssmDouble* pvalue,Gauss* gauss ,int index){_error_("not implemented yet");};
    58                 void GetInputDerivativeValue(IssmDouble* derivativevalues, IssmDouble* xyz_list,Gauss* gauss);
    59                 void GetInputAverage(IssmDouble* pvalue);
    60                 void GetInputDerivativeAverageValue(IssmDouble* derivativevalues, IssmDouble* xyz_list){_error_("not implemented yet");};
    61                 void GetInputAllTimeAverages(IssmDouble** pvalues,IssmDouble** ptimes, int* pnumtimes){_error_("not implemented yet");};
    62                 void GetInputUpToCurrentTimeAverages(IssmDouble** pvalues, IssmDouble** ptimes, int* pnumtimes, IssmDouble currenttime){_error_("not implemented yet");};
    63                 void ChangeEnum(int newenumtype){_error_("not implemented yet");};
    64                 void SquareMin(IssmDouble* psquaremin,Parameters* parameters){_error_("not implemented yet");};
    65                 void ConstrainMin(IssmDouble minimum){_error_("not implemented yet");};
    66                 void Set(IssmDouble setvalue){_error_("Set not implemented yet");};
    67                 void Scale(IssmDouble scale_factor){_error_("not implemented yet");};
    68                 void AXPY(Input* xinput,IssmDouble scalar);
    69                 void Constrain(void);
    70                 void Constrain(IssmDouble min,IssmDouble max);
     69                int  GetResultArraySize(void){return 1;};
     70                int  GetResultInterpolation(void);
     71                int  GetResultNumberOfNodes(void);
     72                void GetVectorFromInputs(Vector<IssmDouble>* vector,int* doflist,const char* data);
     73                void GetVectorFromInputs(Vector<IssmDouble>* vector,int* doflist);
    7174                IssmDouble InfinityNorm(void){_error_("not implemented yet");};
    7275                IssmDouble Max(void){_error_("not implemented yet");};
     
    7477                IssmDouble Min(void);
    7578                IssmDouble MinAbs(void){_error_("not implemented yet");};
    76                 void Extrude(int start);
     79                void ResultToPatch(IssmDouble* values,int nodesperelement,int sid){_error_("not supported yet");};
     80                void SaveValue(void);
     81                void Scale(IssmDouble scale_factor){_error_("not implemented yet");};
     82                void ScaleGradient(IssmDouble scale);
     83                void Set(IssmDouble setvalue){_error_("Set not implemented yet");};
     84                void SetGradient(Input* gradient_in);
     85                void SetInput(Input* in_input);
     86                void SquareMin(IssmDouble* psquaremin,Parameters* parameters){_error_("not implemented yet");};
     87                void UpdateValue(IssmDouble scalar);
    7788                void VerticallyIntegrate(Input* thickness_input);
    78                 void GetVectorFromInputs(Vector<IssmDouble>* vector,int* doflist,const char* data);
    79                 void GetVectorFromInputs(Vector<IssmDouble>* vector,int* doflist);
    80                 int  GetResultInterpolation(void);
    81                 int  GetResultNumberOfNodes(void);
    82                 int  GetResultArraySize(void){return 1;};
    83                 void ResultToPatch(IssmDouble* values,int nodesperelement,int sid){_error_("not supported yet");};
    84                 void GetGradient(Vector<IssmDouble>* gradient_vec,int* doflist);
    85                 void ScaleGradient(IssmDouble scale);
    86                 void SetGradient(Input* gradient_in);
    87                 void UpdateValue(IssmDouble scalar);
    88                 void SaveValue(void);
    8989                /*}}}*/
    9090
  • issm/trunk-jpl/src/c/classes/Inputs/DatasetInput.cpp

    r19254 r20827  
    3636
    3737/*Object virtual functions definitions:*/
    38 void DatasetInput::Echo(void){/*{{{*/
    39         this->DeepEcho();
    40 }
    41 /*}}}*/
    42 void DatasetInput::DeepEcho(void){/*{{{*/
    43 
    44         _printf_("DatasetInput:\n");
    45         _printf_("   enum: " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")\n");
    46         _printf_("   numids:"<< this->numids<< "\n");
    47         _printf_("      ids: ");
    48         for(int i=0;i<this->numids;i++) _printf_(this->ids[i]<<" ");
    49         _printf_("\n");
    50         _printf_("   inputs: \n"); inputs->Echo();
    51 }
    52 /*}}}*/
    53 int    DatasetInput::Id(void){ return -1; }/*{{{*/
    54 /*}}}*/
    55 int DatasetInput::ObjectEnum(void){/*{{{*/
    56 
    57         return DatasetInputEnum;
    58 
    59 }
    60 /*}}}*/
    6138Object* DatasetInput::copy() {/*{{{*/
    6239
     
    7350}
    7451/*}}}*/
     52void DatasetInput::DeepEcho(void){/*{{{*/
     53
     54        _printf_("DatasetInput:\n");
     55        _printf_("   enum: " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")\n");
     56        _printf_("   numids:"<< this->numids<< "\n");
     57        _printf_("      ids: ");
     58        for(int i=0;i<this->numids;i++) _printf_(this->ids[i]<<" ");
     59        _printf_("\n");
     60        _printf_("   inputs: \n"); inputs->Echo();
     61}
     62/*}}}*/
     63void DatasetInput::Echo(void){/*{{{*/
     64        this->DeepEcho();
     65}
     66/*}}}*/
     67int    DatasetInput::Id(void){ return -1; }/*{{{*/
     68/*}}}*/
    7569void DatasetInput::Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ /*{{{*/
    7670
     
    8579}
    8680/*}}}*/
    87 Input* DatasetInput::SpawnTriaInput(int index1,int index2,int index3){/*{{{*/
     81int DatasetInput::ObjectEnum(void){/*{{{*/
    8882
    89         /*output*/
    90         DatasetInput* outinput=NULL;
     83        return DatasetInputEnum;
    9184
    92         /*Create new Datasetinput (copy of current input)*/
    93         outinput=new DatasetInput();
    94         outinput->enum_type=this->enum_type;
    95         outinput->inputs=xDynamicCast<Inputs*>(this->inputs->SpawnTriaInputs(index1,index2,index3));
    96         outinput->numids=this->numids;
    97         outinput->ids=xNew<int>(this->numids);
    98         xMemCpy(outinput->ids,this->ids,this->numids);
    99 
    100         /*Assign output*/
    101         return outinput;
    10285}
    10386/*}}}*/
     
    11194        outinput->enum_type=this->enum_type;
    11295        outinput->inputs=xDynamicCast<Inputs*>(this->inputs->SpawnSegInputs(index1,index2));
     96        outinput->numids=this->numids;
     97        outinput->ids=xNew<int>(this->numids);
     98        xMemCpy(outinput->ids,this->ids,this->numids);
     99
     100        /*Assign output*/
     101        return outinput;
     102}
     103/*}}}*/
     104Input* DatasetInput::SpawnTriaInput(int index1,int index2,int index3){/*{{{*/
     105
     106        /*output*/
     107        DatasetInput* outinput=NULL;
     108
     109        /*Create new Datasetinput (copy of current input)*/
     110        outinput=new DatasetInput();
     111        outinput->enum_type=this->enum_type;
     112        outinput->inputs=xDynamicCast<Inputs*>(this->inputs->SpawnTriaInputs(index1,index2,index3));
    113113        outinput->numids=this->numids;
    114114        outinput->ids=xNew<int>(this->numids);
  • issm/trunk-jpl/src/c/classes/Inputs/DatasetInput.h

    r19725 r20827  
    2727                /*}}}*/
    2828                /*Object virtual functions definitions:{{{ */
     29                Object* copy();
     30                void  DeepEcho();
    2931                void  Echo();
    30                 void  DeepEcho();
    3132                int   Id();
     33                void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);
    3234                int   ObjectEnum();
    33                 Object* copy();
    34                 void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);
    3535                /*}}}*/
    3636                /*DatasetInput management: {{{*/
    3737                void   AddInput(Input* input,int id);
     38                void AddTimeValues(IssmDouble* values,int step,IssmDouble time){_error_("not supported yet");};
     39                void Configure(Parameters* parameters);
    3840                int    InstanceEnum();
    39                 Input* SpawnTriaInput(int index1,int index2,int index3);
    40                 Input* SpawnSegInput(int index1,int index2);
    4141                Input* PointwiseDivide(Input* inputB){_error_("not implemented yet");};
    4242                Input* PointwiseMin(Input* inputB){_error_("not implemented yet");};
    4343                Input* PointwiseMax(Input* inputB){_error_("not implemented yet");};
    44                 void AddTimeValues(IssmDouble* values,int step,IssmDouble time){_error_("not supported yet");};
    45                 void Configure(Parameters* parameters);
     44                Input* SpawnSegInput(int index1,int index2);
     45                Input* SpawnTriaInput(int index1,int index2,int index3);
    4646                /*}}}*/
    4747                /*numerics: {{{*/
     48                void AXPY(Input* xinput,IssmDouble scalar){_error_("not implemented yet");};
     49                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");};
     53                void Extrude(int start){_error_("not implemented yet");};
     54                void GetGradient(Vector<IssmDouble>* gradient_vec,int* doflist){_error_("not implemented yet");};
     55                void GetInputAllTimeAverages(IssmDouble** pvalues,IssmDouble** ptimes, int* pnumtimes){_error_("not implemented yet");};
     56                void GetInputAverage(IssmDouble* pvalue){_error_("not implemented yet");};
     57                void GetInputDerivativeAverageValue(IssmDouble* derivativevalues, IssmDouble* xyz_list){_error_("not implemented yet");};
     58                void GetInputDerivativeValue(IssmDouble* derivativevalues, IssmDouble* xyz_list,Gauss* gauss){_error_("not implemented yet");};
    4859                void GetInputValue(bool* pvalue){_error_("not implemented yet");};
    4960                void GetInputValue(int* pvalue){_error_("not implemented yet");};
     
    5263                void GetInputValue(IssmDouble* pvalue,Gauss* gauss,IssmDouble time){_error_("not implemented yet");};
    5364                void GetInputValue(IssmDouble* pvalue,Gauss* gauss ,int index);
    54                 void GetInputDerivativeValue(IssmDouble* derivativevalues, IssmDouble* xyz_list,Gauss* gauss){_error_("not implemented yet");};
    55                 void GetInputAverage(IssmDouble* pvalue){_error_("not implemented yet");};
    56                 void GetInputDerivativeAverageValue(IssmDouble* derivativevalues, IssmDouble* xyz_list){_error_("not implemented yet");};
    57                 void GetInputAllTimeAverages(IssmDouble** pvalues,IssmDouble** ptimes, int* pnumtimes){_error_("not implemented yet");};
    5865                void GetInputUpToCurrentTimeAverages(IssmDouble** pvalues, IssmDouble** ptimes, int* pnumtimes, IssmDouble currenttime){_error_("not implemented yet");};
    59                 void ChangeEnum(int newenumtype){_error_("not implemented yet");};
    60                 void SquareMin(IssmDouble* psquaremin,Parameters* parameters){_error_("not implemented yet");};
    61                 void ConstrainMin(IssmDouble minimum){_error_("not implemented yet");};
    62                 void Set(IssmDouble setvalue){_error_("Set not implemented yet");};
    63                 void Scale(IssmDouble scale_factor){_error_("not implemented yet");};
    64                 void AXPY(Input* xinput,IssmDouble scalar){_error_("not implemented yet");};
    65                 void Constrain(void){_error_("not implemented yet");};
    66                 void Constrain(IssmDouble min,IssmDouble max){_error_("not implemented yet");};
     66                int GetResultArraySize(void){_error_("not implemented yet");};
     67                int GetResultInterpolation(void){_error_("not implemented yet");};
     68                int GetResultNumberOfNodes(void){_error_("not implemented yet");};
     69                void GetVectorFromInputs(Vector<IssmDouble>* vector,int* doflist){_error_("not implemented yet");};
    6770                IssmDouble InfinityNorm(void){_error_("not implemented yet");};
    6871                IssmDouble Max(void){_error_("not implemented yet");};
     
    7073                IssmDouble Min(void){_error_("not implemented yet");};
    7174                IssmDouble MinAbs(void){_error_("not implemented yet");};
    72                 void Extrude(int start){_error_("not implemented yet");};
     75                void ResultToPatch(IssmDouble* values,int nodesperelement,int sid){_error_("not supported yet");};
     76                void SaveValue(void){_error_("not implemented yet");};
     77                void Scale(IssmDouble scale_factor){_error_("not implemented yet");};
     78                void ScaleGradient(IssmDouble scale){_error_("not implemented yet");};
     79                void Set(IssmDouble setvalue){_error_("Set not implemented yet");};
     80                void SetGradient(Input* gradient_in){_error_("not implemented yet");};
     81                void SquareMin(IssmDouble* psquaremin,Parameters* parameters){_error_("not implemented yet");};
     82                void UpdateValue(IssmDouble scalar){_error_("not implemented yet");};
    7383                void VerticallyIntegrate(Input* thickness_input){_error_("not implemented yet");};
    74                 void GetVectorFromInputs(Vector<IssmDouble>* vector,int* doflist){_error_("not implemented yet");};
    75                 int GetResultInterpolation(void){_error_("not implemented yet");};
    76                 int GetResultNumberOfNodes(void){_error_("not implemented yet");};
    77                 int GetResultArraySize(void){_error_("not implemented yet");};
    78                 void ResultToPatch(IssmDouble* values,int nodesperelement,int sid){_error_("not supported yet");};
    79                 void GetGradient(Vector<IssmDouble>* gradient_vec,int* doflist){_error_("not implemented yet");};
    80                 void ScaleGradient(IssmDouble scale){_error_("not implemented yet");};
    81                 void SetGradient(Input* gradient_in){_error_("not implemented yet");};
    82                 void UpdateValue(IssmDouble scalar){_error_("not implemented yet");};
    83                 void SaveValue(void){_error_("not implemented yet");};
    8484                /*}}}*/
    8585
  • issm/trunk-jpl/src/c/classes/Inputs/DoubleArrayInput.cpp

    r19584 r20827  
    3535
    3636/*Object virtual functions definitions:*/
    37 void DoubleArrayInput::Echo(void){/*{{{*/
    38         this->DeepEcho();
     37Object* DoubleArrayInput::copy() {/*{{{*/
     38
     39        return new DoubleArrayInput(this->enum_type,this->values,this->m);
     40
    3941}
    4042/*}}}*/
     
    4648}
    4749/*}}}*/
    48 int DoubleArrayInput::Id(void){ return -1; }/*{{{*/
    49 /*}}}*/
    50 int DoubleArrayInput::ObjectEnum(void){/*{{{*/
    51 
    52         return DoubleArrayInputEnum;
    53 
     50void DoubleArrayInput::Echo(void){/*{{{*/
     51        this->DeepEcho();
    5452}
    5553/*}}}*/
    56 Object* DoubleArrayInput::copy() {/*{{{*/
    57 
    58         return new DoubleArrayInput(this->enum_type,this->values,this->m);
    59 
    60 }
     54int DoubleArrayInput::Id(void){ return -1; }/*{{{*/
    6155/*}}}*/
    6256void DoubleArrayInput::Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ /*{{{*/
     
    6963}
    7064/*}}}*/
     65int DoubleArrayInput::ObjectEnum(void){/*{{{*/
     66
     67        return DoubleArrayInputEnum;
     68
     69}
     70/*}}}*/
    7171
    7272/*DoubleArrayInput management*/
     73void DoubleArrayInput::GetValues(IssmDouble** pvalues, int *pm){ /*{{{*/
     74
     75        /*output: */
     76        IssmDouble*  outvalues= NULL;
     77
     78        outvalues=xNew<IssmDouble>(m);
     79
     80        xMemCpy<IssmDouble>(outvalues,values,m);
     81
     82        /*assign output pointers: */
     83        *pm=m;
     84        *pvalues=outvalues;
     85}
     86/*}}}*/
    7387int DoubleArrayInput::InstanceEnum(void){/*{{{*/
    7488
     
    89103}
    90104/*}}}*/
    91 void DoubleArrayInput::GetValues(IssmDouble** pvalues, int *pm){ /*{{{*/
    92 
    93         /*output: */
    94         IssmDouble*  outvalues= NULL;
    95 
    96         outvalues=xNew<IssmDouble>(m);
    97 
    98         xMemCpy<IssmDouble>(outvalues,values,m);
    99 
    100         /*assign output pointers: */
    101         *pm=m;
    102         *pvalues=outvalues;
    103 }
    104 /*}}}*/
    105105
    106106/*Object functions*/
  • issm/trunk-jpl/src/c/classes/Inputs/DoubleArrayInput.h

    r19725 r20827  
    2424                /*}}}*/
    2525                /*Object virtual functions definitions:{{{ */
     26                Object* copy();
     27                void  DeepEcho();
    2628                void  Echo();
    27                 void  DeepEcho();
    2829                int   Id();
     30                void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);
    2931                int   ObjectEnum();
    30                 Object* copy();
    31                 void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);
    3232                /*}}}*/
    3333                /*DoubleArrayInput management: {{{*/
    34                 int   InstanceEnum();
    35                 Input* SpawnTriaInput(int index1,int index2,int index3){_error_("not implemented yet");};
    36                 Input* SpawnSegInput(int index1,int index2){_error_("not implemented yet");};
    37                 Input* PointwiseDivide(Input* inputB){_error_("not implemented yet");};
    38                 Input* PointwiseMin(Input* inputB){_error_("not implemented yet");};
    39                 Input* PointwiseMax(Input* inputB){_error_("not implemented yet");};
     34                void Configure(Parameters* parameters);
     35                void GetValues(IssmDouble** pvalues,int* pm);
     36                int  GetResultArraySize(void){return m;};
    4037                int  GetResultInterpolation(void){return P0ArrayEnum;};
    4138                int  GetResultNumberOfNodes(void){return 1;};
    42                 int  GetResultArraySize(void){return m;};
     39                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");};
    4343                void ResultToMatrix(IssmDouble* values,int ncols,int sid);
    44                 void Configure(Parameters* parameters);
    45                 void GetValues(IssmDouble** pvalues,int* pm);
     44                Input* SpawnSegInput(int index1,int index2){_error_("not implemented yet");};
     45                Input* SpawnTriaInput(int index1,int index2,int index3){_error_("not implemented yet");};
    4646                /*}}}*/
    4747                /*numerics: {{{*/
     48                void AXPY(Input* xinput,IssmDouble scalar){_error_("not implemented yet");};
     49                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");};
     52                void Extrude(int start){_error_("not supported yet");};
     53                void GetInputAllTimeAverages(IssmDouble** pvalues,IssmDouble** ptimes, int* pnumtimes){_error_("not implemented yet");};
     54                void GetInputAverage(IssmDouble* pvalue){_error_("not implemented yet");};
     55                void GetInputDerivativeAverageValue(IssmDouble* derivativevalues, IssmDouble* xyz_list){_error_("not implemented yet");};
     56                void GetInputDerivativeValue(IssmDouble* derivativevalues, IssmDouble* xyz_list,Gauss* gauss){_error_("not implemented yet");};
    4857                void GetInputValue(bool* pvalue){_error_("not implemented yet");};
    4958                void GetInputValue(int* pvalue){_error_("not implemented yet");};
     
    5261                void GetInputValue(IssmDouble* pvalue,Gauss* gauss,IssmDouble time){_error_("not implemented yet");};
    5362                void GetInputValue(IssmDouble* pvalue,Gauss* gauss ,int index){_error_("not implemented yet");};
    54                 void GetInputDerivativeValue(IssmDouble* derivativevalues, IssmDouble* xyz_list,Gauss* gauss){_error_("not implemented yet");};
    55                 void GetInputAverage(IssmDouble* pvalue){_error_("not implemented yet");};
    56                 void GetInputDerivativeAverageValue(IssmDouble* derivativevalues, IssmDouble* xyz_list){_error_("not implemented yet");};
    57                 void GetInputAllTimeAverages(IssmDouble** pvalues,IssmDouble** ptimes, int* pnumtimes){_error_("not implemented yet");};
    5863                void GetInputUpToCurrentTimeAverages(IssmDouble** pvalues, IssmDouble** ptimes, int* pnumtimes, IssmDouble currenttime){_error_("not implemented yet");};
    59                 void SquareMin(IssmDouble* psquaremin,Parameters* parameters){_error_("not implemented yet");};
    60                 void ConstrainMin(IssmDouble minimum){_error_("not implemented yet");};
    61                 void Set(IssmDouble setvalue){_error_("Set not implemented yet");};
    62                 void Scale(IssmDouble scale_factor){_error_("not implemented yet");};
    63                 void AXPY(Input* xinput,IssmDouble scalar){_error_("not implemented yet");};
    64                 void Constrain(IssmDouble cm_min, IssmDouble cm_max){_error_("not implemented yet");};
    65                 void ChangeEnum(int newenumtype);
     64                void GetVectorFromInputs(Vector<IssmDouble>* vector,int* doflist){_error_("not implemented yet");};
    6665                IssmDouble InfinityNorm(void){_error_("not implemented yet");};
    6766                IssmDouble Max(void){_error_("not implemented yet");};
     
    6968                IssmDouble Min(void){_error_("not implemented yet");};
    7069                IssmDouble MinAbs(void){_error_("not implemented yet");};
    71                 void Extrude(int start){_error_("not supported yet");};
     70                void Scale(IssmDouble scale_factor){_error_("not implemented yet");};
     71                void Set(IssmDouble setvalue){_error_("Set not implemented yet");};
     72                void SquareMin(IssmDouble* psquaremin,Parameters* parameters){_error_("not implemented yet");};
    7273                void VerticallyIntegrate(Input* thickness_input){_error_("not implemented yet");};
    73                 void GetVectorFromInputs(Vector<IssmDouble>* vector,int* doflist){_error_("not implemented yet");};
    7474                /*}}}*/
    7575
  • issm/trunk-jpl/src/c/classes/Inputs/DoubleInput.cpp

    r19254 r20827  
    2929
    3030/*Object virtual functions definitions:*/
     31Object* DoubleInput::copy() {/*{{{*/
     32
     33        return new DoubleInput(this->enum_type,this->value);
     34
     35}
     36/*}}}*/
     37void DoubleInput::DeepEcho(void){/*{{{*/
     38
     39        _printf_(setw(15)<<"   DoubleInput "<<setw(25)<<left<<EnumToStringx(this->enum_type)<<" "<<this->value<<"\n");
     40}
     41/*}}}*/
    3142void DoubleInput::Echo(void){/*{{{*/
    3243        this->DeepEcho();
    3344}
    3445/*}}}*/
    35 void DoubleInput::DeepEcho(void){/*{{{*/
    36 
    37         _printf_(setw(15)<<"   DoubleInput "<<setw(25)<<left<<EnumToStringx(this->enum_type)<<" "<<this->value<<"\n");
    38 }
    39 /*}}}*/
    4046int    DoubleInput::Id(void){ return -1; }/*{{{*/
    41 /*}}}*/
    42 int DoubleInput::ObjectEnum(void){/*{{{*/
    43 
    44         return DoubleInputEnum;
    45 
    46 }
    47 /*}}}*/
    48 Object* DoubleInput::copy() {/*{{{*/
    49 
    50         return new DoubleInput(this->enum_type,this->value);
    51 
    52 }
    5347/*}}}*/
    5448void DoubleInput::Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ /*{{{*/
     
    6155}
    6256/*}}}*/
     57int DoubleInput::ObjectEnum(void){/*{{{*/
     58
     59        return DoubleInputEnum;
     60
     61}
     62/*}}}*/
    6363
    6464/*DoubleInput management*/
     
    6969}
    7070/*}}}*/
    71 Input* DoubleInput::SpawnTriaInput(int index1,int index2,int index3){/*{{{*/
     71Input* DoubleInput::SpawnSegInput(int index1,int index2){/*{{{*/
    7272
    7373        /*output*/
     
    8383}
    8484/*}}}*/
    85 Input* DoubleInput::SpawnSegInput(int index1,int index2){/*{{{*/
     85Input* DoubleInput::SpawnTriaInput(int index1,int index2,int index3){/*{{{*/
    8686
    8787        /*output*/
     
    9999
    100100/*Object functions*/
    101 void DoubleInput::GetInputValue(bool* pvalue){/*{{{*/
    102         _error_("Double input of enum " << EnumToStringx(enum_type) << " cannot return a boolean");
    103 
    104 }
    105 /*}}}*/
    106 void DoubleInput::GetInputValue(int* pvalue){/*{{{*/
    107         _error_("Double input of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return an integer");
    108 
    109 }
    110 /*}}}*/
    111 void DoubleInput::GetInputValue(IssmDouble* pvalue){/*{{{*/
    112 
    113         /*return value*/
    114         *pvalue=value;
    115 }
    116 /*}}}*/
    117 void DoubleInput::GetInputValue(IssmDouble* pvalue,Gauss* gauss){*pvalue=this->value;}/*{{{*/
    118 /*}}}*/
    119 void DoubleInput::ChangeEnum(int newenumtype){/*{{{*/
    120         this->enum_type=newenumtype;
    121 }
    122 /*}}}*/
    123 void DoubleInput::SquareMin(IssmDouble* psquaremin,Parameters* parameters){/*{{{*/
    124 
    125         /*square min of a IssmDouble is the square of the IssmDouble itself: */
    126         *psquaremin=pow(value,2);
    127 }
    128 /*}}}*/
    129 void DoubleInput::Scale(IssmDouble scale_factor){/*{{{*/
    130         value=value*scale_factor;
    131 }
    132 /*}}}*/
    133 void DoubleInput::ConstrainMin(IssmDouble minimum){/*{{{*/
    134         if (value<minimum) value=minimum;
    135 }
    136 /*}}}*/
    137101void DoubleInput::AXPY(Input* xinput,IssmDouble scalar){/*{{{*/
    138102
     
    155119}
    156120/*}}}*/
     121void DoubleInput::ChangeEnum(int newenumtype){/*{{{*/
     122        this->enum_type=newenumtype;
     123}
     124/*}}}*/
     125void DoubleInput::Configure(Parameters* parameters){/*{{{*/
     126        /*do nothing: */
     127}
     128/*}}}*/
    157129void DoubleInput::Constrain(IssmDouble cm_min, IssmDouble cm_max){/*{{{*/
    158130
     
    162134}
    163135/*}}}*/
     136void DoubleInput::ConstrainMin(IssmDouble minimum){/*{{{*/
     137        if (value<minimum) value=minimum;
     138}
     139/*}}}*/
     140void DoubleInput::GetInputAverage(IssmDouble* pvalue){/*{{{*/
     141        *pvalue=value;
     142}
     143/*}}}*/
     144void DoubleInput::GetInputValue(bool* pvalue){/*{{{*/
     145        _error_("Double input of enum " << EnumToStringx(enum_type) << " cannot return a boolean");
     146
     147}
     148/*}}}*/
     149void DoubleInput::GetInputValue(int* pvalue){/*{{{*/
     150        _error_("Double input of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return an integer");
     151
     152}
     153/*}}}*/
     154void DoubleInput::GetInputValue(IssmDouble* pvalue){/*{{{*/
     155
     156        /*return value*/
     157        *pvalue=value;
     158}
     159/*}}}*/
     160void DoubleInput::GetInputValue(IssmDouble* pvalue,Gauss* gauss){*pvalue=this->value;}/*{{{*/
     161/*}}}*/
     162void DoubleInput::GetVectorFromInputs(Vector<IssmDouble>* vector,int* doflist){/*{{{*/
     163
     164        _error_("not supporte yet!");
     165
     166}
     167/*}}}*/
    164168IssmDouble DoubleInput::Max(void){/*{{{*/
    165169        return this->value;
     
    178182}
    179183/*}}}*/
    180 void DoubleInput::GetVectorFromInputs(Vector<IssmDouble>* vector,int* doflist){/*{{{*/
    181 
    182         _error_("not supporte yet!");
    183 
    184 }
    185 /*}}}*/
    186 void DoubleInput::GetInputAverage(IssmDouble* pvalue){/*{{{*/
    187         *pvalue=value;
     184Input* 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/*}}}*/
     203Input* 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/*}}}*/
     223Input* 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/*}}}*/
     243void DoubleInput::Scale(IssmDouble scale_factor){/*{{{*/
     244        value=value*scale_factor;
     245}
     246/*}}}*/
     247void DoubleInput::SquareMin(IssmDouble* psquaremin,Parameters* parameters){/*{{{*/
     248
     249        /*square min of a IssmDouble is the square of the IssmDouble itself: */
     250        *psquaremin=pow(value,2);
    188251}
    189252/*}}}*/
     
    209272}
    210273/*}}}*/
    211 Input* DoubleInput::PointwiseDivide(Input* inputB){/*{{{*/
    212 
    213         /*Ouput*/
    214         DoubleInput* outinput=NULL;
    215 
    216         /*Intermediaries*/
    217         IssmDouble       Bvalue;
    218 
    219         /*Check that inputB is of the same type*/
    220         inputB->GetInputAverage(&Bvalue);
    221 
    222         /*Create new DoubleInput*/
    223         outinput=new DoubleInput(this->enum_type,this->value/Bvalue);
    224 
    225         /*Return output pointer*/
    226         return outinput;
    227 
    228 }
    229 /*}}}*/
    230 Input* DoubleInput::PointwiseMin(Input* input){/*{{{*/
    231 
    232         /*Ouput*/
    233         DoubleInput* outinput=NULL;
    234 
    235         /*Intermediaries*/
    236         IssmDouble       min;
    237 
    238         /*Check that inputB is of the same type*/
    239         if (input->Min() < this->Min()) min=input->Min();
    240         else min=this->Min();
    241 
    242         /*Create new DoubleInput*/
    243         outinput=new DoubleInput(this->enum_type,min);
    244 
    245         /*Return output pointer*/
    246         return outinput;
    247 
    248 }
    249 /*}}}*/
    250 Input* DoubleInput::PointwiseMax(Input* input){/*{{{*/
    251 
    252         /*Ouput*/
    253         DoubleInput* outinput=NULL;
    254 
    255         /*Intermediaries*/
    256         IssmDouble       max;
    257 
    258         /*Check that inputB is of the same type*/
    259         if (input->Max() > this->Max()) max=input->Max();
    260         else max=this->Max();
    261 
    262         /*Create new DoubleInput*/
    263         outinput=new DoubleInput(this->enum_type,max);
    264 
    265         /*Return output pointer*/
    266         return outinput;
    267 
    268 }
    269 /*}}}*/
    270 void DoubleInput::Configure(Parameters* parameters){/*{{{*/
    271         /*do nothing: */
    272 }
    273 /*}}}*/
  • issm/trunk-jpl/src/c/classes/Inputs/DoubleInput.h

    r19725 r20827  
    2525                /*}}}*/
    2626                /*Object virtual functions definitions:{{{ */
     27                Object* copy();
     28                void  DeepEcho();
    2729                void  Echo();
    28                 void  DeepEcho();
    2930                int   Id();
     31                void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);
    3032                int   ObjectEnum();
    31                 Object* copy();
    32                 void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);
    3333                /*}}}*/
    3434                /*DoubleInput management: {{{*/
    35                 int   InstanceEnum();
    36                 Input* SpawnTriaInput(int index1,int index2,int index3);
    37                 Input* SpawnSegInput(int index1,int index2);
    38                 Input* PointwiseDivide(Input* inputB);
    39                 Input* PointwiseMin(Input* inputB);
    40                 Input* PointwiseMax(Input* inputB);
     35                void AddTimeValues(IssmDouble* values,int step,IssmDouble time){_error_("not supported yet");};
     36                void Configure(Parameters* parameters);
     37                int  GetResultArraySize(void){return 1;};
    4138                int  GetResultInterpolation(void){return P0Enum;};
    4239                int  GetResultNumberOfNodes(void){return 1;};
    43                 int  GetResultArraySize(void){return 1;};
     40                int   InstanceEnum();
     41                Input* PointwiseDivide(Input* inputB);
     42                Input* PointwiseMax(Input* inputB);
     43                Input* PointwiseMin(Input* inputB);
    4444                void ResultToPatch(IssmDouble* values,int nodesperelement,int sid){_error_("not supported yet");};
    45                 void AddTimeValues(IssmDouble* values,int step,IssmDouble time){_error_("not supported yet");};
    46                 void Configure(Parameters* parameters);
     45                Input* SpawnSegInput(int index1,int index2);
     46                Input* SpawnTriaInput(int index1,int index2,int index3);
    4747                /*}}}*/
    4848                /*numerics: {{{*/
     49                void AXPY(Input* xinput,IssmDouble scalar);
     50                void ChangeEnum(int newenumtype);
     51                void Constrain(IssmDouble cm_min, IssmDouble cm_max);
     52                void ConstrainMin(IssmDouble minimum);
     53                void Extrude(int start){_error_("not supported yet");};
     54                void GetInputAllTimeAverages(IssmDouble** pvalues,IssmDouble** ptimes, int* pnumtimes){_error_("not implemented yet");};
     55                void GetInputAverage(IssmDouble* pvalue);
     56                void GetInputDerivativeAverageValue(IssmDouble* derivativevalues, IssmDouble* xyz_list){_error_("not implemented yet");};
     57                void GetInputDerivativeValue(IssmDouble* derivativevalues, IssmDouble* xyz_list,Gauss* gauss){_error_("not implemented yet");};
    4958                void GetInputValue(bool* pvalue);
    5059                void GetInputValue(int* pvalue);
     
    5362                void GetInputValue(IssmDouble* pvalue,Gauss* gauss,IssmDouble time){_error_("not implemented yet");};
    5463                void GetInputValue(IssmDouble* pvalue,Gauss* gauss ,int index){_error_("not implemented yet");};
    55                 void GetInputDerivativeValue(IssmDouble* derivativevalues, IssmDouble* xyz_list,Gauss* gauss){_error_("not implemented yet");};
    56                 void GetInputAverage(IssmDouble* pvalue);
    57                 void GetInputDerivativeAverageValue(IssmDouble* derivativevalues, IssmDouble* xyz_list){_error_("not implemented yet");};
    58                 void GetInputAllTimeAverages(IssmDouble** pvalues,IssmDouble** ptimes, int* pnumtimes){_error_("not implemented yet");};
    5964                void GetInputUpToCurrentTimeAverages(IssmDouble** pvalues, IssmDouble** ptimes, int* pnumtimes, IssmDouble currenttime){_error_("not implemented yet");};
    60                 void ChangeEnum(int newenumtype);
    61                 void SquareMin(IssmDouble* psquaremin,Parameters* parameters);
    62                 void ConstrainMin(IssmDouble minimum);
    63                 void Set(IssmDouble setvalue){_error_("Set not implemented yet");};
    64                 void Scale(IssmDouble scale_factor);
    65                 void AXPY(Input* xinput,IssmDouble scalar);
    66                 void Constrain(IssmDouble cm_min, IssmDouble cm_max);
     65                void GetVectorFromInputs(Vector<IssmDouble>* vector,int* doflist);
    6766                IssmDouble InfinityNorm(void){_error_("not implemented yet");};
    6867                IssmDouble Max(void);
     
    7069                IssmDouble Min(void);
    7170                IssmDouble MinAbs(void);
    72                 void Extrude(int start){_error_("not supported yet");};
     71                void Scale(IssmDouble scale_factor);
     72                void Set(IssmDouble setvalue){_error_("Set not implemented yet");};
     73                void SquareMin(IssmDouble* psquaremin,Parameters* parameters);
    7374                void VerticallyIntegrate(Input* thickness_input);
    74                 void GetVectorFromInputs(Vector<IssmDouble>* vector,int* doflist);
    7575                /*}}}*/
    7676
  • issm/trunk-jpl/src/c/classes/Inputs/Input.h

    r19725 r20827  
    2525                virtual        ~Input(){};
    2626
    27                 virtual int  InstanceEnum()=0;
     27                virtual void ChangeEnum(int newenumtype)=0;
     28                virtual void Configure(Parameters* parameters)=0;
     29                virtual void GetInputAllTimeAverages(IssmDouble** pvalues,IssmDouble** ptimes, int* pnumtimes)=0;
     30                virtual void GetInputAverage(IssmDouble* pvalue)=0;
     31                virtual void GetInputDerivativeAverageValue(IssmDouble* derivativevalues, IssmDouble* xyz_list)=0;
     32                virtual void GetInputDerivativeValue(IssmDouble* derivativevalues, IssmDouble* xyz_list, Gauss* gauss)=0;
    2833                virtual void GetInputValue(bool* pvalue)=0;
    2934                virtual void GetInputValue(int* pvalue)=0;
     
    3237                virtual void GetInputValue(IssmDouble* pvalue,Gauss* gauss,IssmDouble time)=0;
    3338                virtual void GetInputValue(IssmDouble* pvalue,Gauss* gauss,int index)=0;
    34                 virtual void GetInputDerivativeValue(IssmDouble* derivativevalues, IssmDouble* xyz_list, Gauss* gauss)=0;
    35                 virtual void GetInputAverage(IssmDouble* pvalue)=0;
    36                 virtual void GetInputDerivativeAverageValue(IssmDouble* derivativevalues, IssmDouble* xyz_list)=0;
    37                 virtual void GetInputAllTimeAverages(IssmDouble** pvalues,IssmDouble** ptimes, int* pnumtimes)=0;
    3839                virtual void GetInputUpToCurrentTimeAverages(IssmDouble** pvalues, IssmDouble** ptimes, int* pnumtimes, IssmDouble currenttime)=0;
    39                 virtual void ChangeEnum(int newenumtype)=0;
    40                 virtual void Configure(Parameters* parameters)=0;
     40                virtual int  InstanceEnum()=0;
    4141
    42                 virtual void   SquareMin(IssmDouble* psquaremin,Parameters* parameters)=0;
    43                 virtual void   ConstrainMin(IssmDouble minimum)=0;
    44                 virtual IssmDouble InfinityNorm(void)=0;
    45                 virtual IssmDouble MaxAbs(void)=0;
    46                 virtual IssmDouble MinAbs(void)=0;
    47                 virtual IssmDouble Max(void)=0;
    48                 virtual IssmDouble Min(void)=0;
    49                 virtual void   Set(IssmDouble setvalue)=0;
    50                 virtual void   Scale(IssmDouble scale_factor)=0;
    5142                virtual void   AXPY(Input* xinput,IssmDouble scalar)=0;
    5243                virtual void   Constrain(IssmDouble cm_min, IssmDouble cm_max)=0;
    53                 virtual void   VerticallyIntegrate(Input* thickness_input)=0;
     44                virtual void   ConstrainMin(IssmDouble minimum)=0;
    5445                virtual void   Extrude(int start)=0;
    5546                virtual void   GetVectorFromInputs(Vector<IssmDouble>* vector,int* doflist)=0;
     47                virtual IssmDouble InfinityNorm(void)=0;
     48                virtual IssmDouble Max(void)=0;
     49                virtual IssmDouble MaxAbs(void)=0;
     50                virtual IssmDouble Min(void)=0;
     51                virtual IssmDouble MinAbs(void)=0;
     52                virtual void   Scale(IssmDouble scale_factor)=0;
     53                virtual void   Set(IssmDouble setvalue)=0;
     54                virtual void   SquareMin(IssmDouble* psquaremin,Parameters* parameters)=0;
     55                virtual void   VerticallyIntegrate(Input* thickness_input)=0;
    5656
    57                 virtual Input* SpawnTriaInput(int index1,int index2,int index3)=0;
    58                 virtual Input* SpawnSegInput(int index1,int index2)=0;
     57                virtual int  GetResultArraySize(void)=0;
     58                virtual int  GetResultInterpolation(void)=0;
     59                virtual int  GetResultNumberOfNodes(void)=0;
    5960                virtual Input* PointwiseDivide(Input* inputB)=0;
    6061                virtual Input* PointwiseMax(Input* inputmax)=0;
    6162                virtual Input* PointwiseMin(Input* inputmin)=0;
    62                 virtual int  GetResultInterpolation(void)=0;
    63                 virtual int  GetResultNumberOfNodes(void)=0;
    64                 virtual int  GetResultArraySize(void)=0;
     63                virtual Input* SpawnSegInput(int index1,int index2)=0;
     64                virtual Input* SpawnTriaInput(int index1,int index2,int index3)=0;
     65                virtual void ResultToMatrix(IssmDouble* values,int ncols,int sid){_error_("not supported yet");};
    6566                virtual void ResultToPatch(IssmDouble* values,int nodesperelement,int sid){_error_("not supported yet");};
    66                 virtual void ResultToMatrix(IssmDouble* values,int ncols,int sid){_error_("not supported yet");};
    6767};
    6868#endif
  • 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 /*}}}*/
  • issm/trunk-jpl/src/c/classes/Inputs/Inputs.h

    r19725 r20827  
    2323                /*numerics*/
    2424                int         AddInput(Input* in_input);
     25                void        AXPY(int inputy_enum, IssmDouble scalar, int inputx_enum);
    2526                void        ChangeEnum(int enumtype,int new_enumtype);
     27                void        Configure(Parameters* parameters);
    2628                void        ConstrainMin(int constrain_enum, IssmDouble minimum);
    2729                int         DeleteInput(int enum_type);
    2830                void        DuplicateInput(int original_enum,int new_enum);
    2931                Input*      GetInput(int enum_name);
    30                 Inputs*     SpawnTriaInputs(int position);//TO BE REMOVED (replaced by the other one)
    31                 Inputs*     SpawnTriaInputs(int index1,int index2,int index3);
    32                 Inputs*     SpawnSegInputs(int index1,int index2);
    33                 Inputs*     SpawnSegInputs(int position);
    34                 void        AXPY(int inputy_enum, IssmDouble scalar, int inputx_enum);
     32                void        GetInputAverage(IssmDouble* pvalue, int enum_type);
     33                void        GetInputDerivativeValue(IssmDouble* derivativevalues, IssmDouble* xyz_list,Gauss* gauss){_error_("not implemented yet");};
     34                void        GetInputValue(bool* pvalue,int enum_type);
     35                void        GetInputValue(int* pvalue,int enum_type);
     36                void        GetInputValue(IssmDouble* pvalue,int enum_type);
    3537                IssmDouble  InfinityNorm(int enumtype);
    3638                IssmDouble  Max(int enumtype);
     
    3840                IssmDouble  Min(int enumtype);
    3941                IssmDouble  MinAbs(int enumtype);
    40                 void        GetInputAverage(IssmDouble* pvalue, int enum_type);
    41                 void        GetInputDerivativeValue(IssmDouble* derivativevalues, IssmDouble* xyz_list,Gauss* gauss){_error_("not implemented yet");};
    42                 void        GetInputValue(bool* pvalue,int enum_type);
    43                 void        GetInputValue(int* pvalue,int enum_type);
    44                 void        GetInputValue(IssmDouble* pvalue,int enum_type);
    45                 void        Configure(Parameters* parameters);
     42                Inputs*     SpawnSegInputs(int index1,int index2);
     43                Inputs*     SpawnSegInputs(int position);
     44                Inputs*     SpawnTriaInputs(int position);//TO BE REMOVED (replaced by the other one)
     45                Inputs*     SpawnTriaInputs(int index1,int index2,int index3);
    4646
    4747};
  • issm/trunk-jpl/src/c/classes/Inputs/IntInput.cpp

    r19254 r20827  
    2929
    3030/*Object virtual functions definitions:*/
     31Object* IntInput::copy() {/*{{{*/
     32
     33        return new IntInput(this->enum_type,this->value);
     34
     35}
     36/*}}}*/
    3137void IntInput::DeepEcho(void){/*{{{*/
    3238
     
    3642int  IntInput::Id(void){ return -1; }/*{{{*/
    3743/*}}}*/
    38 int  IntInput::ObjectEnum(void){/*{{{*/
    39 
    40         return IntInputEnum;
    41 
    42 }
    43 /*}}}*/
    44 Object* IntInput::copy() {/*{{{*/
    45 
    46         return new IntInput(this->enum_type,this->value);
    47 
    48 }
    49 /*}}}*/
    5044void IntInput::Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ /*{{{*/
    5145
     
    5448        MARSHALLING(enum_type);
    5549        MARSHALLING(value);
     50
     51}
     52/*}}}*/
     53int  IntInput::ObjectEnum(void){/*{{{*/
     54
     55        return IntInputEnum;
    5656
    5757}
     
    6969}
    7070/*}}}*/
    71 Input* IntInput::SpawnTriaInput(int index1,int index2,int index3){/*{{{*/
     71Input* IntInput::SpawnSegInput(int index1,int index2){/*{{{*/
    7272
    7373        /*output*/
     
    8282}
    8383/*}}}*/
    84 Input* IntInput::SpawnSegInput(int index1,int index2){/*{{{*/
     84Input* IntInput::SpawnTriaInput(int index1,int index2,int index3){/*{{{*/
    8585
    8686        /*output*/
     
    9797
    9898/*Object functions*/
    99 void IntInput::GetInputValue(bool* pvalue){_error_("not supported yet!");}/*{{{*/
    100 /*}}}*/
    101 void IntInput::GetInputValue(int* pvalue){/*{{{*/
    102         *pvalue=value;
    103 }
    104 /*}}}*/
    105 void IntInput::GetInputValue(IssmDouble* pvalue){/*{{{*/
    106         _error_("IntInput cannot return a IssmDouble in parallel");
    107 }
    108 /*}}}*/
    109 void IntInput::GetInputValue(IssmDouble* pvalue,Gauss* gauss){_error_("not supported yet!");}/*{{{*/
    110 /*}}}*/
    111 void IntInput::ChangeEnum(int newenumtype){/*{{{*/
    112         this->enum_type=newenumtype;
    113 }
    114 /*}}}*/
    115 void IntInput::SquareMin(IssmDouble* psquaremin,Parameters* parameters){/*{{{*/
    116 
    117         /*square min of an integer is the square of the integer itself: */
    118         *psquaremin=pow((IssmDouble)value,2);
    119 }
    120 /*}}}*/
    121 void IntInput::Scale(IssmDouble scale_factor){/*{{{*/
    122         IssmDouble dvalue=(IssmDouble)value*scale_factor;
    123         value=reCast<int>(dvalue);
    124 }
    125 /*}}}*/
    12699void IntInput::AXPY(Input* xinput,IssmDouble scalar){/*{{{*/
    127100
     
    146119}
    147120/*}}}*/
     121void IntInput::ChangeEnum(int newenumtype){/*{{{*/
     122        this->enum_type=newenumtype;
     123}
     124/*}}}*/
     125void IntInput::Configure(Parameters* parameters){/*{{{*/
     126        /*do nothing: */
     127}
     128/*}}}*/
    148129void IntInput::Constrain(IssmDouble cm_min, IssmDouble cm_max){/*{{{*/
    149130
     
    153134}
    154135/*}}}*/
     136void IntInput::GetInputValue(bool* pvalue){_error_("not supported yet!");}/*{{{*/
     137/*}}}*/
     138void IntInput::GetInputValue(int* pvalue){/*{{{*/
     139        *pvalue=value;
     140}
     141/*}}}*/
     142void IntInput::GetInputValue(IssmDouble* pvalue){/*{{{*/
     143        _error_("IntInput cannot return a IssmDouble in parallel");
     144}
     145/*}}}*/
     146void IntInput::GetInputValue(IssmDouble* pvalue,Gauss* gauss){_error_("not supported yet!");}/*{{{*/
     147/*}}}*/
    155148void IntInput::GetVectorFromInputs(Vector<IssmDouble>* vector,int* doflist){/*{{{*/
    156149
     
    159152}
    160153/*}}}*/
    161 void IntInput::Configure(Parameters* parameters){/*{{{*/
    162         /*do nothing: */
     154void IntInput::Scale(IssmDouble scale_factor){/*{{{*/
     155        IssmDouble dvalue=(IssmDouble)value*scale_factor;
     156        value=reCast<int>(dvalue);
    163157}
    164158/*}}}*/
     159void IntInput::SquareMin(IssmDouble* psquaremin,Parameters* parameters){/*{{{*/
     160
     161        /*square min of an integer is the square of the integer itself: */
     162        *psquaremin=pow((IssmDouble)value,2);
     163}
     164/*}}}*/
  • issm/trunk-jpl/src/c/classes/Inputs/IntInput.h

    r19725 r20827  
    2626                /*}}}*/
    2727                /*Object virtual functions definitions:{{{ */
     28                Object* copy();
     29                void  DeepEcho();
    2830                void  Echo();
    29                 void  DeepEcho();
    3031                int   Id();
     32                void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);
    3133                int   ObjectEnum();
    32                 Object* copy();
    33                 void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);
    3434                /*}}}*/
    3535                /*IntInput management: {{{*/
    36                 int   InstanceEnum();
    37                 Input* SpawnTriaInput(int index1,int index2,int index3);
    38                 Input* SpawnSegInput(int index1,int index2);
    39                 Input* PointwiseDivide(Input* inputB){_error_("not implemented yet");};
    40                 Input* PointwiseMin(Input* inputB){_error_("not implemented yet");};
    41                 Input* PointwiseMax(Input* inputB){_error_("not implemented yet");};
     36                void AddTimeValues(IssmDouble* values,int step,IssmDouble time){_error_("not supported yet");};
     37                void Configure(Parameters* parameters);
     38                int  GetResultArraySize(void){return 1;};
    4239                int  GetResultInterpolation(void){return P0Enum;};
    4340                int  GetResultNumberOfNodes(void){return 1;};
    44                 int  GetResultArraySize(void){return 1;};
     41                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");};
    4545                void ResultToPatch(IssmDouble* values,int nodesperelement,int sid){_error_("not supported yet");};
    46                 void AddTimeValues(IssmDouble* values,int step,IssmDouble time){_error_("not supported yet");};
    47                 void Configure(Parameters* parameters);
     46                Input* SpawnSegInput(int index1,int index2);
     47                Input* SpawnTriaInput(int index1,int index2,int index3);
    4848                /*}}}*/
    4949                /*numerics: {{{*/
     50                void AXPY(Input* xinput,IssmDouble scalar);
     51                void ChangeEnum(int newenumtype);
     52                void Constrain(IssmDouble cm_min, IssmDouble cm_max);
     53                void ConstrainMin(IssmDouble minimum){_error_("not implemented yet");};
     54                void Extrude(int start){_error_("not supported yet");};
     55                void GetInputAllTimeAverages(IssmDouble** pvalues,IssmDouble** ptimes, int* pnumtimes){_error_("not implemented yet");};
     56                void GetInputAverage(IssmDouble* pvalue){_error_("not implemented yet");};
     57                void GetInputDerivativeAverageValue(IssmDouble* derivativevalues, IssmDouble* xyz_list){_error_("not implemented yet");};
     58                void GetInputDerivativeValue(IssmDouble* derivativevalues, IssmDouble* xyz_list,Gauss* gauss){_error_("not implemented yet");};
    5059                void GetInputValue(bool* pvalue);
    5160                void GetInputValue(int* pvalue);
     
    5463                void GetInputValue(IssmDouble* pvalue,Gauss* gauss,IssmDouble time){_error_("not implemented yet");};
    5564                void GetInputValue(IssmDouble* pvalue,Gauss* gauss ,int index){_error_("not implemented yet");};
    56                 void GetInputDerivativeValue(IssmDouble* derivativevalues, IssmDouble* xyz_list,Gauss* gauss){_error_("not implemented yet");};
    57                 void GetInputAverage(IssmDouble* pvalue){_error_("not implemented yet");};
    58                 void GetInputDerivativeAverageValue(IssmDouble* derivativevalues, IssmDouble* xyz_list){_error_("not implemented yet");};
    59                 void GetInputAllTimeAverages(IssmDouble** pvalues,IssmDouble** ptimes, int* pnumtimes){_error_("not implemented yet");};
    6065                void GetInputUpToCurrentTimeAverages(IssmDouble** pvalues, IssmDouble** ptimes, int* pnumtimes, IssmDouble currenttime){_error_("not implemented yet");};
    61                 void ChangeEnum(int newenumtype);
    62                 void SquareMin(IssmDouble* psquaremin,Parameters* parameters);
    63                 void ConstrainMin(IssmDouble minimum){_error_("not implemented yet");};
    64                 void Set(IssmDouble setvalue){_error_("Set not implemented yet");};
    65                 void Scale(IssmDouble scale_factor);
    66                 void AXPY(Input* xinput,IssmDouble scalar);
    67                 void Constrain(IssmDouble cm_min, IssmDouble cm_max);
     66                void GetVectorFromInputs(Vector<IssmDouble>* vector,int* doflist);
    6867                IssmDouble InfinityNorm(void){_error_("InfinityNorm not implemented for integers");};
    6968                IssmDouble Max(void){_error_("Max not implemented for integers");};
     
    7170                IssmDouble Min(void){_error_("Min not implemented for integers");};
    7271                IssmDouble MinAbs(void){_error_("Min not implemented for integers");};
    73                 void Extrude(int start){_error_("not supported yet");};
     72                void Scale(IssmDouble scale_factor);
     73                void Set(IssmDouble setvalue){_error_("Set not implemented yet");};
     74                void SquareMin(IssmDouble* psquaremin,Parameters* parameters);
    7475                void VerticallyIntegrate(Input* thickness_input){_error_("not supported yet");};
    75                 void GetVectorFromInputs(Vector<IssmDouble>* vector,int* doflist);
    7676                /*}}}*/
    7777
  • issm/trunk-jpl/src/c/classes/Inputs/PentaInput.cpp

    r19254 r20827  
    4242
    4343/*Object virtual functions definitions:*/
    44 void PentaInput::Echo(void){/*{{{*/
    45         this->DeepEcho();
     44Object* PentaInput::copy() {/*{{{*/
     45
     46        return new PentaInput(this->enum_type,this->values,this->interpolation_type);
     47
    4648}
    4749/*}}}*/
     
    5355}
    5456/*}}}*/
     57void PentaInput::Echo(void){/*{{{*/
     58        this->DeepEcho();
     59}
     60/*}}}*/
    5561int  PentaInput::Id(void){ return -1; }/*{{{*/
    56 /*}}}*/
    57 int  PentaInput::ObjectEnum(void){/*{{{*/
    58 
    59         return PentaInputEnum;
    60 
    61 }
    62 /*}}}*/
    63 Object* PentaInput::copy() {/*{{{*/
    64 
    65         return new PentaInput(this->enum_type,this->values,this->interpolation_type);
    66 
    67 }
    6862/*}}}*/
    6963void PentaInput::Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ /*{{{*/
     
    8175}
    8276/*}}}*/
     77int  PentaInput::ObjectEnum(void){/*{{{*/
     78
     79        return PentaInputEnum;
     80
     81}
     82/*}}}*/
    8383
    8484/*PentaInput management*/
     85int  PentaInput::GetResultInterpolation(void){/*{{{*/
     86
     87        if(this->interpolation_type==P0Enum){
     88                return P0Enum;
     89        }
     90        return P1Enum;
     91
     92}
     93/*}}}*/
     94int  PentaInput::GetResultNumberOfNodes(void){/*{{{*/
     95
     96        return this->NumberofNodes(this->interpolation_type);;
     97
     98}
     99/*}}}*/
    85100int PentaInput::InstanceEnum(void){/*{{{*/
    86101
    87102        return this->enum_type;
    88103
     104}
     105/*}}}*/
     106void PentaInput::ResultToPatch(IssmDouble* values,int nodesperelement,int sid){/*{{{*/
     107
     108        int numnodes = this->NumberofNodes(this->interpolation_type);
     109
     110        /*Some checks*/
     111        _assert_(values);
     112        _assert_(numnodes==nodesperelement);
     113
     114        /*Fill in arrays*/
     115        for(int i=0;i<numnodes;i++) values[sid*numnodes + i] = this->values[i];
     116}
     117/*}}}*/
     118Input* PentaInput::SpawnSegInput(int index1,int index2){/*{{{*/
     119
     120        _error_("not supported");
    89121}
    90122/*}}}*/
     
    119151}
    120152/*}}}*/
    121 Input* PentaInput::SpawnSegInput(int index1,int index2){/*{{{*/
    122 
    123         _error_("not supported");
    124 }
    125 /*}}}*/
    126 int  PentaInput::GetResultInterpolation(void){/*{{{*/
    127 
    128         if(this->interpolation_type==P0Enum){
    129                 return P0Enum;
    130         }
    131         return P1Enum;
    132 
    133 }
    134 /*}}}*/
    135 int  PentaInput::GetResultNumberOfNodes(void){/*{{{*/
    136 
    137         return this->NumberofNodes(this->interpolation_type);;
    138 
    139 }
    140 /*}}}*/
    141 void PentaInput::ResultToPatch(IssmDouble* values,int nodesperelement,int sid){/*{{{*/
    142 
    143         int numnodes = this->NumberofNodes(this->interpolation_type);
    144 
    145         /*Some checks*/
    146         _assert_(values);
    147         _assert_(numnodes==nodesperelement);
    148 
    149         /*Fill in arrays*/
    150         for(int i=0;i<numnodes;i++) values[sid*numnodes + i] = this->values[i];
    151 }
    152 /*}}}*/
    153153
    154154/*Object functions*/
     155void PentaInput::ChangeEnum(int newenumtype){/*{{{*/
     156        this->enum_type=newenumtype;
     157}
     158/*}}}*/
     159void PentaInput::GetInputAverage(IssmDouble* pvalue){/*{{{*/
     160
     161        int        numnodes  = this->NumberofNodes(this->interpolation_type);
     162        IssmDouble numnodesd = reCast<int,IssmDouble>(numnodes);
     163        IssmDouble value     = 0.;
     164
     165        for(int i=0;i<numnodes;i++) value+=values[i];
     166        value = value/numnodesd;
     167
     168        *pvalue=value;
     169}
     170/*}}}*/
     171void PentaInput::GetInputDerivativeValue(IssmDouble* p, IssmDouble* xyz_list,Gauss* gauss){/*{{{*/
     172
     173        /*Call PentaRef function*/
     174        _assert_(gauss->Enum()==GaussPentaEnum);
     175        PentaRef::GetInputDerivativeValue(p,&values[0],xyz_list,(GaussPenta*)gauss,this->interpolation_type);
     176}
     177/*}}}*/
    155178void PentaInput::GetInputValue(IssmDouble* pvalue){/*{{{*/
    156179
     
    169192}
    170193/*}}}*/
    171 void PentaInput::GetInputDerivativeValue(IssmDouble* p, IssmDouble* xyz_list,Gauss* gauss){/*{{{*/
    172 
    173         /*Call PentaRef function*/
    174         _assert_(gauss->Enum()==GaussPentaEnum);
    175         PentaRef::GetInputDerivativeValue(p,&values[0],xyz_list,(GaussPenta*)gauss,this->interpolation_type);
    176 }
    177 /*}}}*/
    178 void PentaInput::ChangeEnum(int newenumtype){/*{{{*/
    179         this->enum_type=newenumtype;
    180 }
    181 /*}}}*/
    182 void PentaInput::GetInputAverage(IssmDouble* pvalue){/*{{{*/
    183 
    184         int        numnodes  = this->NumberofNodes(this->interpolation_type);
    185         IssmDouble numnodesd = reCast<int,IssmDouble>(numnodes);
    186         IssmDouble value     = 0.;
    187 
    188         for(int i=0;i<numnodes;i++) value+=values[i];
    189         value = value/numnodesd;
    190 
    191         *pvalue=value;
    192 }
    193 /*}}}*/
    194194
    195195/*Intermediary*/
    196 void PentaInput::SquareMin(IssmDouble* psquaremin,Parameters* parameters){/*{{{*/
    197 
    198         int        numnodes=this->NumberofNodes(this->interpolation_type);
    199         IssmDouble squaremin;
    200 
    201         /*Now, figure out minimum of valuescopy: */
    202         squaremin=pow(this->values[0],2);
    203         for(int i=1;i<numnodes;i++){
    204                 if(pow(this->values[i],2)<squaremin)squaremin=pow(this->values[i],2);
    205         }
    206         /*Assign output pointers:*/
    207         *psquaremin=squaremin;
    208 }
    209 /*}}}*/
    210 void PentaInput::ConstrainMin(IssmDouble minimum){/*{{{*/
    211 
    212         int numnodes = this->NumberofNodes(this->interpolation_type);
    213         for(int i=0;i<numnodes;i++) if (values[i]<minimum) values[i]=minimum;
    214 }
    215 /*}}}*/
    216 IssmDouble PentaInput::InfinityNorm(void){/*{{{*/
    217 
    218         /*Output*/
    219         IssmDouble norm=0.;
    220         int numnodes=this->NumberofNodes(this->interpolation_type);
    221 
    222         for(int i=0;i<numnodes;i++) if(fabs(values[i])>norm) norm=fabs(values[i]);
    223         return norm;
    224 }
    225 /*}}}*/
    226 IssmDouble PentaInput::Max(void){/*{{{*/
    227 
    228         int  numnodes=this->NumberofNodes(this->interpolation_type);
    229         IssmDouble max=values[0];
    230 
    231         for(int i=1;i<numnodes;i++){
    232                 if(values[i]>max) max=values[i];
    233         }
    234         return max;
    235 }
    236 /*}}}*/
    237 IssmDouble PentaInput::MaxAbs(void){/*{{{*/
    238 
    239         int  numnodes=this->NumberofNodes(this->interpolation_type);
    240         IssmDouble max=fabs(values[0]);
    241 
    242         for(int i=1;i<numnodes;i++){
    243                 if(fabs(values[i])>max) max=fabs(values[i]);
    244         }
    245         return max;
    246 }
    247 /*}}}*/
    248 IssmDouble PentaInput::Min(void){/*{{{*/
    249 
    250         const int  numnodes=this->NumberofNodes(this->interpolation_type);
    251         IssmDouble min=values[0];
    252 
    253         for(int i=1;i<numnodes;i++){
    254                 if(values[i]<min) min=values[i];
    255         }
    256         return min;
    257 }
    258 /*}}}*/
    259 IssmDouble PentaInput::MinAbs(void){/*{{{*/
    260 
    261         const int  numnodes=this->NumberofNodes(this->interpolation_type);
    262         IssmDouble min=fabs(values[0]);
    263 
    264         for(int i=1;i<numnodes;i++){
    265                 if(fabs(values[i])<min) min=fabs(values[i]);
    266         }
    267         return min;
    268 }
    269 /*}}}*/
    270 void PentaInput::Scale(IssmDouble scale_factor){/*{{{*/
    271 
    272         const int numnodes=this->NumberofNodes(this->interpolation_type);
    273         for(int i=0;i<numnodes;i++)values[i]=values[i]*scale_factor;
    274 }
    275 /*}}}*/
    276196void PentaInput::AXPY(Input* xinput,IssmDouble scalar){/*{{{*/
    277197
     
    295215}
    296216/*}}}*/
     217void PentaInput::Configure(Parameters* parameters){/*{{{*/
     218        /*do nothing: */
     219}
     220/*}}}*/
    297221void PentaInput::Constrain(IssmDouble cm_min, IssmDouble cm_max){/*{{{*/
    298222
     
    303227        if(!xIsNan<IssmDouble>(cm_max)) for(i=0;i<numnodes;i++)if (this->values[i]>cm_max)this->values[i]=cm_max;
    304228
     229}
     230/*}}}*/
     231void 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;
    305235}
    306236/*}}}*/
     
    319249                        _error_("not supported yet for type "<<EnumToStringx(this->interpolation_type));
    320250        }
     251}
     252/*}}}*/
     253void PentaInput::GetVectorFromInputs(Vector<IssmDouble>* vector,int* doflist){/*{{{*/
     254        const int numvertices=6;
     255        vector->SetValues(numvertices,doflist,this->values,INS_VAL);
     256} /*}}}*/
     257IssmDouble PentaInput::InfinityNorm(void){/*{{{*/
     258
     259        /*Output*/
     260        IssmDouble norm=0.;
     261        int numnodes=this->NumberofNodes(this->interpolation_type);
     262
     263        for(int i=0;i<numnodes;i++) if(fabs(values[i])>norm) norm=fabs(values[i]);
     264        return norm;
     265}
     266/*}}}*/
     267IssmDouble PentaInput::Max(void){/*{{{*/
     268
     269        int  numnodes=this->NumberofNodes(this->interpolation_type);
     270        IssmDouble max=values[0];
     271
     272        for(int i=1;i<numnodes;i++){
     273                if(values[i]>max) max=values[i];
     274        }
     275        return max;
     276}
     277/*}}}*/
     278IssmDouble PentaInput::MaxAbs(void){/*{{{*/
     279
     280        int  numnodes=this->NumberofNodes(this->interpolation_type);
     281        IssmDouble max=fabs(values[0]);
     282
     283        for(int i=1;i<numnodes;i++){
     284                if(fabs(values[i])>max) max=fabs(values[i]);
     285        }
     286        return max;
     287}
     288/*}}}*/
     289IssmDouble PentaInput::Min(void){/*{{{*/
     290
     291        const int  numnodes=this->NumberofNodes(this->interpolation_type);
     292        IssmDouble min=values[0];
     293
     294        for(int i=1;i<numnodes;i++){
     295                if(values[i]<min) min=values[i];
     296        }
     297        return min;
     298}
     299/*}}}*/
     300IssmDouble PentaInput::MinAbs(void){/*{{{*/
     301
     302        const int  numnodes=this->NumberofNodes(this->interpolation_type);
     303        IssmDouble min=fabs(values[0]);
     304
     305        for(int i=1;i<numnodes;i++){
     306                if(fabs(values[i])<min) min=fabs(values[i]);
     307        }
     308        return min;
     309}
     310/*}}}*/
     311Input* PentaInput::PointwiseDivide(Input* inputB){/*{{{*/
     312
     313        /*Ouput*/
     314        PentaInput* outinput=NULL;
     315
     316        /*Intermediaries*/
     317        PentaInput *xinputB  = NULL;
     318        const int   numnodes = this->NumberofNodes(this->interpolation_type);
     319
     320        /*Check that inputB is of the same type*/
     321        if(inputB->ObjectEnum()!=PentaInputEnum)     _error_("Operation not permitted because inputB is of type " << EnumToStringx(inputB->ObjectEnum()));
     322        xinputB=(PentaInput*)inputB;
     323        if(xinputB->interpolation_type!=this->interpolation_type) _error_("Operation not permitted because inputB is of type " << EnumToStringx(xinputB->interpolation_type));
     324
     325        /*Allocate intermediary*/
     326        IssmDouble* AdotBvalues=xNew<IssmDouble>(numnodes);
     327
     328        /*Create point wise sum*/
     329        for(int i=0;i<numnodes;i++){
     330                _assert_(xinputB->values[i]!=0);
     331                AdotBvalues[i]=this->values[i]/xinputB->values[i];
     332        }
     333
     334        /*Create new Penta vertex input (copy of current input)*/
     335        outinput=new PentaInput(this->enum_type,AdotBvalues,this->interpolation_type);
     336
     337        /*Return output pointer*/
     338        xDelete<IssmDouble>(AdotBvalues);
     339        return outinput;
     340
     341}
     342/*}}}*/
     343Input* PentaInput::PointwiseMax(Input* inputB){/*{{{*/
     344
     345        /*Ouput*/
     346        PentaInput* outinput=NULL;
     347
     348        /*Intermediaries*/
     349        int         i;
     350        PentaInput  *xinputB   = NULL;
     351        const int   numnodes  = this->NumberofNodes(this->interpolation_type);
     352        IssmDouble *maxvalues = xNew<IssmDouble>(numnodes);
     353
     354        /*Check that inputB is of the same type*/
     355        if(inputB->ObjectEnum()!=PentaInputEnum) _error_("Operation not permitted because inputB is of type " << EnumToStringx(inputB->ObjectEnum()));
     356        xinputB=(PentaInput*)inputB;
     357        if(xinputB->interpolation_type!=this->interpolation_type) _error_("Operation not permitted because inputB is of type " << EnumToStringx(xinputB->interpolation_type));
     358
     359        /*Create point wise max*/
     360        for(i=0;i<numnodes;i++){
     361                if(this->values[i] < xinputB->values[i]) maxvalues[i]=xinputB->values[i];
     362                else maxvalues[i]=this->values[i];
     363        }
     364
     365        /*Create new Penta vertex input (copy of current input)*/
     366        outinput=new PentaInput(this->enum_type,&maxvalues[0],this->interpolation_type);
     367
     368        /*Return output pointer*/
     369        xDelete<IssmDouble>(maxvalues);
     370        return outinput;
     371}
     372/*}}}*/
     373Input* PentaInput::PointwiseMin(Input* inputB){/*{{{*/
     374
     375        /*Ouput*/
     376        PentaInput* outinput=NULL;
     377
     378        /*Intermediaries*/
     379        int         i;
     380        PentaInput  *xinputB   = NULL;
     381        const int   numnodes  = this->NumberofNodes(this->interpolation_type);
     382        IssmDouble *minvalues = xNew<IssmDouble>(numnodes);
     383
     384        /*Check that inputB is of the same type*/
     385        if(inputB->ObjectEnum()!=PentaInputEnum)       _error_("Operation not permitted because inputB is of type " << EnumToStringx(inputB->ObjectEnum()));
     386        xinputB=(PentaInput*)inputB;
     387        if(xinputB->interpolation_type!=this->interpolation_type) _error_("Operation not permitted because inputB is of type " << EnumToStringx(xinputB->interpolation_type));
     388
     389        /*Create point wise min*/
     390        for(i=0;i<numnodes;i++){
     391                if(this->values[i] > xinputB->values[i]) minvalues[i]=xinputB->values[i];
     392                else minvalues[i]=this->values[i];
     393        }
     394
     395        /*Create new Penta vertex input (copy of current input)*/
     396        outinput=new PentaInput(this->enum_type,&minvalues[0],this->interpolation_type);
     397
     398        /*Return output pointer*/
     399        xDelete<IssmDouble>(minvalues);
     400        return outinput;
     401}
     402/*}}}*/
     403void PentaInput::Scale(IssmDouble scale_factor){/*{{{*/
     404
     405        const int numnodes=this->NumberofNodes(this->interpolation_type);
     406        for(int i=0;i<numnodes;i++)values[i]=values[i]*scale_factor;
     407}
     408/*}}}*/
     409void PentaInput::SquareMin(IssmDouble* psquaremin,Parameters* parameters){/*{{{*/
     410
     411        int        numnodes=this->NumberofNodes(this->interpolation_type);
     412        IssmDouble squaremin;
     413
     414        /*Now, figure out minimum of valuescopy: */
     415        squaremin=pow(this->values[0],2);
     416        for(int i=1;i<numnodes;i++){
     417                if(pow(this->values[i],2)<squaremin)squaremin=pow(this->values[i],2);
     418        }
     419        /*Assign output pointers:*/
     420        *psquaremin=squaremin;
    321421}
    322422/*}}}*/
     
    351451}
    352452/*}}}*/
    353 Input* PentaInput::PointwiseDivide(Input* inputB){/*{{{*/
    354 
    355         /*Ouput*/
    356         PentaInput* outinput=NULL;
    357 
    358         /*Intermediaries*/
    359         PentaInput *xinputB  = NULL;
    360         const int   numnodes = this->NumberofNodes(this->interpolation_type);
    361 
    362         /*Check that inputB is of the same type*/
    363         if(inputB->ObjectEnum()!=PentaInputEnum)     _error_("Operation not permitted because inputB is of type " << EnumToStringx(inputB->ObjectEnum()));
    364         xinputB=(PentaInput*)inputB;
    365         if(xinputB->interpolation_type!=this->interpolation_type) _error_("Operation not permitted because inputB is of type " << EnumToStringx(xinputB->interpolation_type));
    366 
    367         /*Allocate intermediary*/
    368         IssmDouble* AdotBvalues=xNew<IssmDouble>(numnodes);
    369 
    370         /*Create point wise sum*/
    371         for(int i=0;i<numnodes;i++){
    372                 _assert_(xinputB->values[i]!=0);
    373                 AdotBvalues[i]=this->values[i]/xinputB->values[i];
    374         }
    375 
    376         /*Create new Penta vertex input (copy of current input)*/
    377         outinput=new PentaInput(this->enum_type,AdotBvalues,this->interpolation_type);
    378 
    379         /*Return output pointer*/
    380         xDelete<IssmDouble>(AdotBvalues);
    381         return outinput;
    382 
    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 /*}}}*/
    415 Input* PentaInput::PointwiseMax(Input* inputB){/*{{{*/
    416 
    417         /*Ouput*/
    418         PentaInput* outinput=NULL;
    419 
    420         /*Intermediaries*/
    421         int         i;
    422         PentaInput  *xinputB   = NULL;
    423         const int   numnodes  = this->NumberofNodes(this->interpolation_type);
    424         IssmDouble *maxvalues = xNew<IssmDouble>(numnodes);
    425 
    426         /*Check that inputB is of the same type*/
    427         if(inputB->ObjectEnum()!=PentaInputEnum) _error_("Operation not permitted because inputB is of type " << EnumToStringx(inputB->ObjectEnum()));
    428         xinputB=(PentaInput*)inputB;
    429         if(xinputB->interpolation_type!=this->interpolation_type) _error_("Operation not permitted because inputB is of type " << EnumToStringx(xinputB->interpolation_type));
    430 
    431         /*Create point wise max*/
    432         for(i=0;i<numnodes;i++){
    433                 if(this->values[i] < xinputB->values[i]) maxvalues[i]=xinputB->values[i];
    434                 else maxvalues[i]=this->values[i];
    435         }
    436 
    437         /*Create new Penta vertex input (copy of current input)*/
    438         outinput=new PentaInput(this->enum_type,&maxvalues[0],this->interpolation_type);
    439 
    440         /*Return output pointer*/
    441         xDelete<IssmDouble>(maxvalues);
    442         return outinput;
    443 }
    444 /*}}}*/
    445 void PentaInput::GetVectorFromInputs(Vector<IssmDouble>* vector,int* doflist){/*{{{*/
    446         const int numvertices=6;
    447         vector->SetValues(numvertices,doflist,this->values,INS_VAL);
    448 } /*}}}*/
    449 void PentaInput::Configure(Parameters* parameters){/*{{{*/
    450         /*do nothing: */
    451 }
    452 /*}}}*/
  • issm/trunk-jpl/src/c/classes/Inputs/PentaInput.h

    r19725 r20827  
    2727
    2828                /*Object virtual functions definitions */
     29                Object *copy();
     30                void    DeepEcho();
    2931                void    Echo();
    30                 void    DeepEcho();
    3132                int     Id();
     33                void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);
    3234                int     ObjectEnum();
    33                 Object *copy();
    34                 void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);
    3535
    3636                /*PentaInput management*/
    3737                int   InstanceEnum();
    38                 Input* SpawnTriaInput(int index1,int index2,int index3);
    39                 Input* SpawnSegInput(int index1,int index2);
    4038                Input* PointwiseDivide(Input* inputB);
    4139                Input* PointwiseMin(Input* inputB);
     
    4846                void Configure(Parameters* parameters);
    4947                /*numerics*/
     48                void AXPY(Input* xinput,IssmDouble scalar);
     49                void ChangeEnum(int newenumtype);
     50                void Constrain(IssmDouble cm_min, IssmDouble cm_max);
     51                void ConstrainMin(IssmDouble minimum);
     52                void Extrude(int start);
     53                void GetInputAllTimeAverages(IssmDouble** pvalues,IssmDouble** ptimes, int* pnumtimes){_error_("not implemented yet");};
     54                void GetInputAverage(IssmDouble* pvalue);
     55                void GetInputDerivativeAverageValue(IssmDouble* derivativevalues, IssmDouble* xyz_list){_error_("not implemented yet");};
     56                void GetInputDerivativeValue(IssmDouble* derivativevalues, IssmDouble* xyz_list,Gauss* gauss);
    5057                void GetInputValue(bool* pvalue){_error_("not implemented yet");};
    5158                void GetInputValue(int* pvalue){_error_("not implemented yet");};
     
    5461                void GetInputValue(IssmDouble* pvalue,Gauss* gauss,IssmDouble time){_error_("not implemented yet");};
    5562                void GetInputValue(IssmDouble* pvalue,Gauss* gauss ,int index){_error_("not implemented yet");};
    56                 void GetInputDerivativeValue(IssmDouble* derivativevalues, IssmDouble* xyz_list,Gauss* gauss);
    57                 void GetInputAverage(IssmDouble* pvalue);
    58                 void GetInputDerivativeAverageValue(IssmDouble* derivativevalues, IssmDouble* xyz_list){_error_("not implemented yet");};
    59                 void GetInputAllTimeAverages(IssmDouble** pvalues,IssmDouble** ptimes, int* pnumtimes){_error_("not implemented yet");};
    6063                void GetInputUpToCurrentTimeAverages(IssmDouble** pvalues, IssmDouble** ptimes, int* pnumtimes, IssmDouble currenttime){_error_("not implemented yet");};
    61                 void ChangeEnum(int newenumtype);
    62                 void SquareMin(IssmDouble* psquaremin,Parameters* parameters);
    63                 void ConstrainMin(IssmDouble minimum);
    64                 void Set(IssmDouble setvalue){_error_("Set not implemented yet");};
    65                 void Scale(IssmDouble scale_factor);
    66                 void AXPY(Input* xinput,IssmDouble scalar);
    67                 void Constrain(IssmDouble cm_min, IssmDouble cm_max);
     64                void GetVectorFromInputs(Vector<IssmDouble>* vector,int* doflist);
    6865                IssmDouble InfinityNorm(void);
    6966                IssmDouble Max(void);
     
    7168                IssmDouble Min(void);
    7269                IssmDouble MinAbs(void);
    73                 void Extrude(int start);
     70                void Scale(IssmDouble scale_factor);
     71                void Set(IssmDouble setvalue){_error_("Set not implemented yet");};
     72                Input* SpawnTriaInput(int index1,int index2,int index3);
     73                Input* SpawnSegInput(int index1,int index2);
     74                void SquareMin(IssmDouble* psquaremin,Parameters* parameters);
    7475                void VerticallyIntegrate(Input* thickness_input);
    75                 void GetVectorFromInputs(Vector<IssmDouble>* vector,int* doflist);
    7676
    7777};
  • issm/trunk-jpl/src/c/classes/Inputs/SegInput.cpp

    r19254 r20827  
    3434
    3535/*Object virtual functions definitions:*/
    36 void SegInput::Echo(void){/*{{{*/
    37         this->DeepEcho();
     36Object* SegInput::copy() {/*{{{*/
     37
     38        return new SegInput(this->enum_type,this->values,this->interpolation_type);
     39
    3840}
    3941/*}}}*/
     
    4547}
    4648/*}}}*/
    47 int  SegInput::Id(void){ return -1; }/*{{{*/
    48 /*}}}*/
    49 int  SegInput::ObjectEnum(void){/*{{{*/
    50 
    51         return SegInputEnum;
    52 
     49void SegInput::Echo(void){/*{{{*/
     50        this->DeepEcho();
    5351}
    5452/*}}}*/
    55 Object* SegInput::copy() {/*{{{*/
    56 
    57         return new SegInput(this->enum_type,this->values,this->interpolation_type);
    58 
    59 }
     53int  SegInput::Id(void){ return -1; }/*{{{*/
    6054/*}}}*/
    6155void SegInput::Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ /*{{{*/
     
    7367}
    7468/*}}}*/
     69int  SegInput::ObjectEnum(void){/*{{{*/
     70
     71        return SegInputEnum;
     72
     73}
     74/*}}}*/
    7575
    7676/*SegInput management*/
     
    8383
    8484/*Object functions*/
     85void SegInput::Configure(Parameters* parameters){/*{{{*/
     86        /*do nothing: */
     87}
     88/*}}}*/
    8589void SegInput::GetInputAverage(IssmDouble* pvalue){/*{{{*/
    8690
     
    9599}
    96100/*}}}*/
    97 void SegInput::GetInputValue(IssmDouble* pvalue,Gauss* gauss){/*{{{*/
    98 
    99         /*Call SegRef function*/
    100         _assert_(gauss->Enum()==GaussSegEnum);
    101         SegRef::GetInputValue(pvalue,&values[0],(GaussSeg*)gauss,this->interpolation_type);
    102 
    103 }
    104 /*}}}*/
    105101void SegInput::GetInputDerivativeValue(IssmDouble* p, IssmDouble* xyz_list,Gauss* gauss){/*{{{*/
    106102
     
    110106}
    111107/*}}}*/
    112 void SegInput::Configure(Parameters* parameters){/*{{{*/
    113         /*do nothing: */
     108void SegInput::GetInputValue(IssmDouble* pvalue,Gauss* gauss){/*{{{*/
     109
     110        /*Call SegRef function*/
     111        _assert_(gauss->Enum()==GaussSegEnum);
     112        SegRef::GetInputValue(pvalue,&values[0],(GaussSeg*)gauss,this->interpolation_type);
     113
    114114}
    115115/*}}}*/
  • issm/trunk-jpl/src/c/classes/Inputs/SegInput.h

    r19725 r20827  
    2727
    2828                /*Object virtual functions definitions*/
     29                Object *copy();
     30                void    DeepEcho();
    2931                void    Echo();
    30                 void    DeepEcho();
    3132                int     Id();
     33                void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);
    3234                int     ObjectEnum();
    33                 Object *copy();
    34                 void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);
    3535
    3636                /*SegInput management:*/
    37                 int    InstanceEnum();
    38                 Input* SpawnTriaInput(int index1,int index2,int index3){_error_("not supported yet");};
    39                 Input* SpawnSegInput(int index1,int index2){_error_("not implemented yet");};
    40                 Input* PointwiseDivide(Input* inputB){_error_("not supported yet");};
    41                 Input* PointwiseMin(Input* inputB){_error_("not supported yet");};
    42                 Input* PointwiseMax(Input* inputB){_error_("not supported yet");};
     37                void   AddTimeValues(IssmDouble* values,int step,IssmDouble time){_error_("not supported yet");};
     38                void   Configure(Parameters* parameters);
     39                int  GetResultArraySize(void){_error_("not implemented");};
    4340                int  GetResultInterpolation(void){_error_("not implemented");};
    4441                int  GetResultNumberOfNodes(void){_error_("not implemented");};
    45                 int  GetResultArraySize(void){_error_("not implemented");};
     42                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");};
    4646                void ResultToPatch(IssmDouble* values,int nodesperelement,int sid){_error_("not supported yet");};
    47                 void   AddTimeValues(IssmDouble* values,int step,IssmDouble time){_error_("not supported yet");};
    48                 void   Configure(Parameters* parameters);
     47                Input* SpawnSegInput(int index1,int index2){_error_("not implemented yet");};
     48                Input* SpawnTriaInput(int index1,int index2,int index3){_error_("not supported yet");};
    4949
    5050                /*numerics*/
     51                void AXPY(Input* xinput,IssmDouble scalar){_error_("not implemented yet");};
     52                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");};
     55                void Extrude(int start){_error_("not supported yet");};
     56                void GetInputAllTimeAverages(IssmDouble** pvalues,IssmDouble** ptimes, int* pnumtimes){_error_("not implemented yet");};
     57                void GetInputAverage(IssmDouble* pvalue);
     58                void GetInputDerivativeAverageValue(IssmDouble* derivativevalues, IssmDouble* xyz_list){_error_("not implemented yet");};
     59                void GetInputDerivativeValue(IssmDouble* derivativevalues, IssmDouble* xyz_list,Gauss* gauss);
    5160                void GetInputValue(bool* pvalue){_error_("not implemented yet");}
    5261                void GetInputValue(int* pvalue){_error_("not implemented yet");}
     
    5564                void GetInputValue(IssmDouble* pvalue,Gauss* gauss,IssmDouble time){_error_("not implemented yet");};
    5665                void GetInputValue(IssmDouble* pvalue,Gauss* gauss ,int index){_error_("not implemented yet");};
    57                 void GetInputDerivativeValue(IssmDouble* derivativevalues, IssmDouble* xyz_list,Gauss* gauss);
    58                 void GetInputAverage(IssmDouble* pvalue);
    59                 void GetInputDerivativeAverageValue(IssmDouble* derivativevalues, IssmDouble* xyz_list){_error_("not implemented yet");};
    60                 void GetInputAllTimeAverages(IssmDouble** pvalues,IssmDouble** ptimes, int* pnumtimes){_error_("not implemented yet");};
    6166                void GetInputUpToCurrentTimeAverages(IssmDouble** pvalues, IssmDouble** ptimes, int* pnumtimes, IssmDouble currenttime){_error_("not implemented yet");};
    62                 void ChangeEnum(int newenumtype){_error_("not implemented yet");};
    63                 void SquareMin(IssmDouble* psquaremin,Parameters* parameters){_error_("not implemented yet");};
    64                 void ConstrainMin(IssmDouble minimum){_error_("not implemented yet");};
    65                 void Set(IssmDouble setvalue){_error_("not implemented yet");};
    66                 void Scale(IssmDouble scale_factor){_error_("not implemented yet");};
    67                 void AXPY(Input* xinput,IssmDouble scalar){_error_("not implemented yet");};
    68                 void Constrain(IssmDouble cm_min, IssmDouble cm_max){_error_("not implemented yet");};
     67                void GetVectorFromInputs(Vector<IssmDouble>* vector,int* doflist){_error_("not implemented yet");};
    6968                IssmDouble InfinityNorm(void){_error_("not implemented yet");};
    7069                IssmDouble Max(void){_error_("not implemented yet");};
     
    7271                IssmDouble Min(void);
    7372                IssmDouble MinAbs(void){_error_("not implemented yet");};
    74                 void Extrude(int start){_error_("not supported yet");};
     73                void Scale(IssmDouble scale_factor){_error_("not implemented yet");};
     74                void Set(IssmDouble setvalue){_error_("not implemented yet");};
     75                void SquareMin(IssmDouble* psquaremin,Parameters* parameters){_error_("not implemented yet");};
    7576                void VerticallyIntegrate(Input* thickness_input){_error_("not supported yet");};
    76                 void GetVectorFromInputs(Vector<IssmDouble>* vector,int* doflist){_error_("not implemented yet");};
    7777
    7878};
  • issm/trunk-jpl/src/c/classes/Inputs/TetraInput.cpp

    r19254 r20827  
    4242
    4343/*Object virtual functions definitions:*/
    44 void TetraInput::Echo(void){/*{{{*/
    45         this->DeepEcho();
     44Object* TetraInput::copy() {/*{{{*/
     45
     46        return new TetraInput(this->enum_type,this->values,this->interpolation_type);
     47
    4648}
    4749/*}}}*/
     
    5355}
    5456/*}}}*/
     57void TetraInput::Echo(void){/*{{{*/
     58        this->DeepEcho();
     59}
     60/*}}}*/
    5561int  TetraInput::Id(void){ return -1; }/*{{{*/
    56 /*}}}*/
    57 int  TetraInput::ObjectEnum(void){/*{{{*/
    58 
    59         return TetraInputEnum;
    60 
    61 }
    62 /*}}}*/
    63 Object* TetraInput::copy() {/*{{{*/
    64 
    65         return new TetraInput(this->enum_type,this->values,this->interpolation_type);
    66 
    67 }
    6862/*}}}*/
    6963void TetraInput::Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ /*{{{*/
     
    8175}
    8276/*}}}*/
     77int  TetraInput::ObjectEnum(void){/*{{{*/
     78
     79        return TetraInputEnum;
     80
     81}
     82/*}}}*/
    8383
    8484/*TetraInput management*/
     
    118118
    119119/*Object functions*/
    120 void TetraInput::GetInputValue(IssmDouble* pvalue,Gauss* gauss){/*{{{*/
    121 
    122         /*Call TetraRef function*/
    123         _assert_(gauss->Enum()==GaussTetraEnum);
    124         TetraRef::GetInputValue(pvalue,&values[0],(GaussTetra*)gauss,this->interpolation_type);
    125 
    126 }
    127 /*}}}*/
    128 void TetraInput::GetInputDerivativeValue(IssmDouble* p, IssmDouble* xyz_list, Gauss* gauss){/*{{{*/
    129 
    130         /*Call TetraRef function*/
    131         _assert_(gauss->Enum()==GaussTetraEnum);
    132         TetraRef::GetInputDerivativeValue(p,&values[0],xyz_list,(GaussTetra*)gauss,this->interpolation_type);
    133 }
    134 /*}}}*/
    135120void TetraInput::ChangeEnum(int newenumtype){/*{{{*/
    136121        this->enum_type=newenumtype;
    137 }
    138 /*}}}*/
    139 void TetraInput::GetInputAverage(IssmDouble* pvalue){/*{{{*/
    140 
    141         int        numnodes  = this->NumberofNodes(this->interpolation_type);
    142         IssmDouble numnodesd = reCast<int,IssmDouble>(numnodes);
    143         IssmDouble value     = 0.;
    144 
    145         for(int i=0;i<numnodes;i++) value+=values[i];
    146         value = value/numnodesd;
    147 
    148         *pvalue=value;
    149122}
    150123/*}}}*/
     
    168141}
    169142/*}}}*/
     143void TetraInput::GetInputAverage(IssmDouble* pvalue){/*{{{*/
     144
     145        int        numnodes  = this->NumberofNodes(this->interpolation_type);
     146        IssmDouble numnodesd = reCast<int,IssmDouble>(numnodes);
     147        IssmDouble value     = 0.;
     148
     149        for(int i=0;i<numnodes;i++) value+=values[i];
     150        value = value/numnodesd;
     151
     152        *pvalue=value;
     153}
     154/*}}}*/
     155void TetraInput::GetInputDerivativeValue(IssmDouble* p, IssmDouble* xyz_list, Gauss* gauss){/*{{{*/
     156
     157        /*Call TetraRef function*/
     158        _assert_(gauss->Enum()==GaussTetraEnum);
     159        TetraRef::GetInputDerivativeValue(p,&values[0],xyz_list,(GaussTetra*)gauss,this->interpolation_type);
     160}
     161/*}}}*/
    170162void TetraInput::GetInputUpToCurrentTimeAverages(IssmDouble** pvalues, IssmDouble** ptimes, int* pnumtimes, IssmDouble currenttime){/*{{{*/
    171163
     
    185177        *ptimes=times;
    186178        *pnumtimes=numtimes;
     179}
     180/*}}}*/
     181void TetraInput::GetInputValue(IssmDouble* pvalue,Gauss* gauss){/*{{{*/
     182
     183        /*Call TetraRef function*/
     184        _assert_(gauss->Enum()==GaussTetraEnum);
     185        TetraRef::GetInputValue(pvalue,&values[0],(GaussTetra*)gauss,this->interpolation_type);
     186
    187187}
    188188/*}}}*/
     
    219219
    220220/*Intermediary*/
    221 void TetraInput::SquareMin(IssmDouble* psquaremin,Parameters* parameters){/*{{{*/
    222 
    223         int        numnodes=this->NumberofNodes(this->interpolation_type);
    224         IssmDouble squaremin;
    225 
    226         /*Now, figure out minimum of valuescopy: */
    227         squaremin=pow(this->values[0],2);
    228         for(int i=1;i<numnodes;i++){
    229                 if(pow(this->values[i],2)<squaremin)squaremin=pow(this->values[i],2);
    230         }
    231         /*Assign output pointers:*/
    232         *psquaremin=squaremin;
    233 }
    234 /*}}}*/
    235 void TetraInput::ConstrainMin(IssmDouble minimum){/*{{{*/
    236 
    237         int numnodes = this->NumberofNodes(this->interpolation_type);
    238         for(int i=0;i<numnodes;i++) if (values[i]<minimum) values[i]=minimum;
    239 }
    240 /*}}}*/
    241 IssmDouble TetraInput::InfinityNorm(void){/*{{{*/
    242 
    243         /*Output*/
    244         IssmDouble norm=0.;
    245         int numnodes=this->NumberofNodes(this->interpolation_type);
    246 
    247         for(int i=0;i<numnodes;i++) if(fabs(values[i])>norm) norm=fabs(values[i]);
    248         return norm;
    249 }
    250 /*}}}*/
    251 IssmDouble TetraInput::Max(void){/*{{{*/
    252 
    253         int  numnodes=this->NumberofNodes(this->interpolation_type);
    254         IssmDouble max=values[0];
    255 
    256         for(int i=1;i<numnodes;i++){
    257                 if(values[i]>max) max=values[i];
    258         }
    259         return max;
    260 }
    261 /*}}}*/
    262 IssmDouble TetraInput::MaxAbs(void){/*{{{*/
    263 
    264         int  numnodes=this->NumberofNodes(this->interpolation_type);
    265         IssmDouble max=fabs(values[0]);
    266 
    267         for(int i=1;i<numnodes;i++){
    268                 if(fabs(values[i])>max) max=fabs(values[i]);
    269         }
    270         return max;
    271 }
    272 /*}}}*/
    273 IssmDouble TetraInput::Min(void){/*{{{*/
    274 
    275         const int  numnodes=this->NumberofNodes(this->interpolation_type);
    276         IssmDouble min=values[0];
    277 
    278         for(int i=1;i<numnodes;i++){
    279                 if(values[i]<min) min=values[i];
    280         }
    281         return min;
    282 }
    283 /*}}}*/
    284 IssmDouble TetraInput::MinAbs(void){/*{{{*/
    285 
    286         const int  numnodes=this->NumberofNodes(this->interpolation_type);
    287         IssmDouble min=fabs(values[0]);
    288 
    289         for(int i=1;i<numnodes;i++){
    290                 if(fabs(values[i])<min) min=fabs(values[i]);
    291         }
    292         return min;
    293 }
    294 /*}}}*/
    295 void TetraInput::Scale(IssmDouble scale_factor){/*{{{*/
    296 
    297         const int numnodes=this->NumberofNodes(this->interpolation_type);
    298         for(int i=0;i<numnodes;i++)values[i]=values[i]*scale_factor;
    299 }
    300 /*}}}*/
    301 void TetraInput::Set(IssmDouble setvalue){/*{{{*/
    302 
    303         const int numnodes=this->NumberofNodes(this->interpolation_type);
    304         for(int i=0;i<numnodes;i++)values[i]=setvalue;
    305 }
    306 /*}}}*/
    307221void TetraInput::AXPY(Input* xinput,IssmDouble scalar){/*{{{*/
    308222
     
    320234}
    321235/*}}}*/
     236void TetraInput::Configure(Parameters* parameters){/*{{{*/
     237        /*do nothing: */
     238}
     239/*}}}*/
    322240void TetraInput::Constrain(IssmDouble cm_min, IssmDouble cm_max){/*{{{*/
    323241
     
    328246        if(!xIsNan<IssmDouble>(cm_max)) for(i=0;i<numnodes;i++)if (this->values[i]>cm_max)this->values[i]=cm_max;
    329247
     248}
     249/*}}}*/
     250void 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;
    330254}
    331255/*}}}*/
     
    334258        vector->SetValues(numvertices,doflist,this->values,INS_VAL);
    335259} /*}}}*/
     260IssmDouble TetraInput::InfinityNorm(void){/*{{{*/
     261
     262        /*Output*/
     263        IssmDouble norm=0.;
     264        int numnodes=this->NumberofNodes(this->interpolation_type);
     265
     266        for(int i=0;i<numnodes;i++) if(fabs(values[i])>norm) norm=fabs(values[i]);
     267        return norm;
     268}
     269/*}}}*/
     270IssmDouble TetraInput::MinAbs(void){/*{{{*/
     271
     272        const int  numnodes=this->NumberofNodes(this->interpolation_type);
     273        IssmDouble min=fabs(values[0]);
     274
     275        for(int i=1;i<numnodes;i++){
     276                if(fabs(values[i])<min) min=fabs(values[i]);
     277        }
     278        return min;
     279}
     280/*}}}*/
     281IssmDouble TetraInput::Max(void){/*{{{*/
     282
     283        int  numnodes=this->NumberofNodes(this->interpolation_type);
     284        IssmDouble max=values[0];
     285
     286        for(int i=1;i<numnodes;i++){
     287                if(values[i]>max) max=values[i];
     288        }
     289        return max;
     290}
     291/*}}}*/
     292IssmDouble TetraInput::MaxAbs(void){/*{{{*/
     293
     294        int  numnodes=this->NumberofNodes(this->interpolation_type);
     295        IssmDouble max=fabs(values[0]);
     296
     297        for(int i=1;i<numnodes;i++){
     298                if(fabs(values[i])>max) max=fabs(values[i]);
     299        }
     300        return max;
     301}
     302/*}}}*/
     303IssmDouble TetraInput::Min(void){/*{{{*/
     304
     305        const int  numnodes=this->NumberofNodes(this->interpolation_type);
     306        IssmDouble min=values[0];
     307
     308        for(int i=1;i<numnodes;i++){
     309                if(values[i]<min) min=values[i];
     310        }
     311        return min;
     312}
     313/*}}}*/
     314Input* 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/*}}}*/
     346Input* 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/*}}}*/
    336377Input* TetraInput::PointwiseMin(Input* inputB){/*{{{*/
    337378
     
    365406}
    366407/*}}}*/
    367 Input* TetraInput::PointwiseMax(Input* inputB){/*{{{*/
    368 
    369         /*Ouput*/
    370         TetraInput* outinput=NULL;
    371 
    372         /*Intermediaries*/
    373         int         i;
    374         TetraInput  *xinputB   = NULL;
    375         const int   numnodes  = this->NumberofNodes(this->interpolation_type);
    376         IssmDouble *maxvalues = xNew<IssmDouble>(numnodes);
    377 
    378         /*Check that inputB is of the same type*/
    379         if(inputB->ObjectEnum()!=TetraInputEnum) _error_("Operation not permitted because inputB is of type " << EnumToStringx(inputB->ObjectEnum()));
    380         xinputB=(TetraInput*)inputB;
    381         if(xinputB->interpolation_type!=this->interpolation_type) _error_("Operation not permitted because inputB is of type " << EnumToStringx(xinputB->interpolation_type));
    382 
    383         /*Create point wise max*/
    384         for(i=0;i<numnodes;i++){
    385                 if(this->values[i] < xinputB->values[i]) maxvalues[i]=xinputB->values[i];
    386                 else maxvalues[i]=this->values[i];
    387         }
    388 
    389         /*Create new Tetra vertex input (copy of current input)*/
    390         outinput=new TetraInput(this->enum_type,&maxvalues[0],this->interpolation_type);
    391 
    392         /*Return output pointer*/
    393         xDelete<IssmDouble>(maxvalues);
    394         return outinput;
    395 
    396 }
    397 /*}}}*/
    398 Input* TetraInput::PointwiseDivide(Input* inputB){/*{{{*/
    399 
    400         /*Ouput*/
    401         TetraInput* outinput=NULL;
    402 
    403         /*Intermediaries*/
    404         TetraInput *xinputB  = NULL;
    405         const int   numnodes = this->NumberofNodes(this->interpolation_type);
    406 
    407         /*Check that inputB is of the same type*/
    408         if(inputB->ObjectEnum()!=TetraInputEnum)     _error_("Operation not permitted because inputB is of type " << EnumToStringx(inputB->ObjectEnum()));
    409         xinputB=(TetraInput*)inputB;
    410         if(xinputB->interpolation_type!=this->interpolation_type) _error_("Operation not permitted because inputB is of type " << EnumToStringx(xinputB->interpolation_type));
    411 
    412         /*Allocate intermediary*/
    413         IssmDouble* AdotBvalues=xNew<IssmDouble>(numnodes);
    414 
    415         /*Create point wise division*/
    416         for(int i=0;i<numnodes;i++){
    417                 _assert_(xinputB->values[i]!=0);
    418                 AdotBvalues[i]=this->values[i]/xinputB->values[i];
    419         }
    420 
    421         /*Create new Tetra vertex input (copy of current input)*/
    422         outinput=new TetraInput(this->enum_type,AdotBvalues,this->interpolation_type);
    423 
    424         /*Return output pointer*/
    425         xDelete<IssmDouble>(AdotBvalues);
    426         return outinput;
    427 
    428 }
    429 /*}}}*/
    430 void TetraInput::Configure(Parameters* parameters){/*{{{*/
    431         /*do nothing: */
    432 }
    433 /*}}}*/
     408void TetraInput::Scale(IssmDouble scale_factor){/*{{{*/
     409
     410        const int numnodes=this->NumberofNodes(this->interpolation_type);
     411        for(int i=0;i<numnodes;i++)values[i]=values[i]*scale_factor;
     412}
     413/*}}}*/
     414void TetraInput::Set(IssmDouble setvalue){/*{{{*/
     415
     416        const int numnodes=this->NumberofNodes(this->interpolation_type);
     417        for(int i=0;i<numnodes;i++)values[i]=setvalue;
     418}
     419/*}}}*/
     420void TetraInput::SquareMin(IssmDouble* psquaremin,Parameters* parameters){/*{{{*/
     421
     422        int        numnodes=this->NumberofNodes(this->interpolation_type);
     423        IssmDouble squaremin;
     424
     425        /*Now, figure out minimum of valuescopy: */
     426        squaremin=pow(this->values[0],2);
     427        for(int i=1;i<numnodes;i++){
     428                if(pow(this->values[i],2)<squaremin)squaremin=pow(this->values[i],2);
     429        }
     430        /*Assign output pointers:*/
     431        *psquaremin=squaremin;
     432}
     433/*}}}*/
  • issm/trunk-jpl/src/c/classes/Inputs/TetraInput.h

    r19725 r20827  
    2727
    2828                /*Object virtual functions definitions*/
     29                Object *copy();
     30                void    DeepEcho();
    2931                void    Echo();
    30                 void    DeepEcho();
    3132                int     Id();
     33                void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);
    3234                int     ObjectEnum();
    33                 Object *copy();
    34                 void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);
    3535
    3636                /*TetraInput management:*/
    37                 int    InstanceEnum();
    38                 Input* SpawnTriaInput(int index1,int index2,int index3);
    39                 Input* SpawnSegInput(int index1,int index2){_error_("not supported yet");};
    40                 Input* PointwiseDivide(Input* inputB);
    41                 Input* PointwiseMin(Input* inputB);
    42                 Input* PointwiseMax(Input* inputB);
     37                void   AddTimeValues(IssmDouble* values,int step,IssmDouble time){_error_("not supported yet");};
     38                void   Configure(Parameters* parameters);
     39                int    GetResultArraySize(void){return 1;};
    4340                int    GetResultInterpolation(void);
    4441                int    GetResultNumberOfNodes(void);
    45                 int    GetResultArraySize(void){return 1;};
     42                int    InstanceEnum();
     43                Input* PointwiseDivide(Input* inputB);
     44                Input* PointwiseMax(Input* inputB);
     45                Input* PointwiseMin(Input* inputB);
    4646                void   ResultToPatch(IssmDouble* values,int nodesperelement,int sid);
    47                 void   AddTimeValues(IssmDouble* values,int step,IssmDouble time){_error_("not supported yet");};
    48                 void   Configure(Parameters* parameters);
     47                Input* SpawnSegInput(int index1,int index2){_error_("not supported yet");};
     48                Input* SpawnTriaInput(int index1,int index2,int index3);
    4949
    5050                /*numerics*/
     51                void AXPY(Input* xinput,IssmDouble scalar);
     52                void ChangeEnum(int newenumtype);
     53                void Constrain(IssmDouble cm_min, IssmDouble cm_max);
     54                void ConstrainMin(IssmDouble minimum);
     55                void Extrude(int start){_error_("not supported yet");};
     56                void GetInputAllTimeAverages(IssmDouble** pvalues,IssmDouble** ptimes, int* pnumtimes);
     57                void GetInputAverage(IssmDouble* pvalue);
     58                void GetInputDerivativeAverageValue(IssmDouble* derivativevalues, IssmDouble* xyz_list){_error_("not implemented yet");};
     59                void GetInputDerivativeValue(IssmDouble* derivativevalues, IssmDouble* xyz_list,Gauss* gauss);
    5160                void GetInputValue(bool* pvalue){_error_("not implemented yet");}
    5261                void GetInputValue(int* pvalue){_error_("not implemented yet");}
     
    5564                void GetInputValue(IssmDouble* pvalue,Gauss* gauss,IssmDouble time){_error_("not implemented yet");};
    5665                void GetInputValue(IssmDouble* pvalue,Gauss* gauss,int index){_error_("not implemented yet");};
    57                 void GetInputDerivativeValue(IssmDouble* derivativevalues, IssmDouble* xyz_list,Gauss* gauss);
    58                 void GetInputAverage(IssmDouble* pvalue);
    59                 void GetInputDerivativeAverageValue(IssmDouble* derivativevalues, IssmDouble* xyz_list){_error_("not implemented yet");};
    60                 void GetInputAllTimeAverages(IssmDouble** pvalues,IssmDouble** ptimes, int* pnumtimes);
    6166                void GetInputUpToCurrentTimeAverages(IssmDouble** pvalues, IssmDouble** ptimes, int* pnumtimes, IssmDouble currenttime);
    62                 void ChangeEnum(int newenumtype);
    63                 void SquareMin(IssmDouble* psquaremin,Parameters* parameters);
    64                 void ConstrainMin(IssmDouble minimum);
    65                 void Set(IssmDouble setvalue);
    66                 void Scale(IssmDouble scale_factor);
    67                 void AXPY(Input* xinput,IssmDouble scalar);
    68                 void Constrain(IssmDouble cm_min, IssmDouble cm_max);
     67                void GetVectorFromInputs(Vector<IssmDouble>* vector,int* doflist);
    6968                IssmDouble InfinityNorm(void);
    7069                IssmDouble Max(void);
     
    7271                IssmDouble Min(void);
    7372                IssmDouble MinAbs(void);
    74                 void Extrude(int start){_error_("not supported yet");};
     73                void Scale(IssmDouble scale_factor);
     74                void Set(IssmDouble setvalue);
     75                void SquareMin(IssmDouble* psquaremin,Parameters* parameters);
    7576                void VerticallyIntegrate(Input* thickness_input){_error_("not supported yet");};
    76                 void GetVectorFromInputs(Vector<IssmDouble>* vector,int* doflist);
    7777
    7878};
  • issm/trunk-jpl/src/c/classes/Inputs/TransientInput.cpp

    r19554 r20827  
    6262
    6363/*Object virtual functions definitions:*/
    64 void TransientInput::Echo(void){/*{{{*/
    65         this->DeepEcho();
     64Object* TransientInput::copy() {/*{{{*/
     65
     66        TransientInput* output=NULL;
     67
     68        output = new TransientInput();
     69        output->enum_type=this->enum_type;
     70        output->numtimesteps=this->numtimesteps;
     71        output->timesteps=xNew<IssmDouble>(this->numtimesteps);
     72        xMemCpy(output->timesteps,this->timesteps,this->numtimesteps);
     73        output->inputs=static_cast<Inputs*>(this->inputs->Copy());
     74        output->parameters=this->parameters;
     75
     76        return (Object*)output;
     77
    6678}
    6779/*}}}*/
     
    8092}
    8193/*}}}*/
     94void TransientInput::Echo(void){/*{{{*/
     95        this->DeepEcho();
     96}
     97/*}}}*/
    8298int  TransientInput::Id(void){ return -1; }/*{{{*/
    83 /*}}}*/
    84 int  TransientInput::ObjectEnum(void){/*{{{*/
    85 
    86         return TransientInputEnum;
    87 
    88 }
    89 /*}}}*/
    90 Object* TransientInput::copy() {/*{{{*/
    91 
    92         TransientInput* output=NULL;
    93 
    94         output = new TransientInput();
    95         output->enum_type=this->enum_type;
    96         output->numtimesteps=this->numtimesteps;
    97         output->timesteps=xNew<IssmDouble>(this->numtimesteps);
    98         xMemCpy(output->timesteps,this->timesteps,this->numtimesteps);
    99         output->inputs=static_cast<Inputs*>(this->inputs->Copy());
    100         output->parameters=this->parameters;
    101 
    102         return (Object*)output;
    103 
    104 }
    10599/*}}}*/
    106100void TransientInput::Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ /*{{{*/
     
    116110}
    117111/*}}}*/
     112int  TransientInput::ObjectEnum(void){/*{{{*/
     113
     114        return TransientInputEnum;
     115
     116}
     117/*}}}*/
    118118
    119119/*TransientInput management*/
     
    121121
    122122        return this->enum_type;
     123
     124}
     125/*}}}*/
     126Input* TransientInput::SpawnSegInput(int index1,int index2){/*{{{*/
     127
     128        /*output*/
     129        TransientInput* outinput=NULL;
     130
     131        /*Create new Transientinput (copy of current input)*/
     132        outinput=new TransientInput();
     133        outinput->enum_type=this->enum_type;
     134        outinput->numtimesteps=this->numtimesteps;
     135        outinput->timesteps=xNew<IssmDouble>(this->numtimesteps);
     136        xMemCpy(outinput->timesteps,this->timesteps,this->numtimesteps);
     137        outinput->inputs=(Inputs*)this->inputs->SpawnSegInputs(index1,index2);
     138        outinput->parameters=this->parameters;
     139
     140        /*Assign output*/
     141        return outinput;
    123142
    124143}
     
    143162}
    144163/*}}}*/
    145 Input* TransientInput::SpawnSegInput(int index1,int index2){/*{{{*/
    146 
    147         /*output*/
    148         TransientInput* outinput=NULL;
    149 
    150         /*Create new Transientinput (copy of current input)*/
    151         outinput=new TransientInput();
    152         outinput->enum_type=this->enum_type;
    153         outinput->numtimesteps=this->numtimesteps;
    154         outinput->timesteps=xNew<IssmDouble>(this->numtimesteps);
    155         xMemCpy(outinput->timesteps,this->timesteps,this->numtimesteps);
    156         outinput->inputs=(Inputs*)this->inputs->SpawnSegInputs(index1,index2);
    157         outinput->parameters=this->parameters;
    158 
    159         /*Assign output*/
    160         return outinput;
    161 
    162 }
    163 /*}}}*/
    164164
    165165/*Object functions*/
    166 void TransientInput::GetInputValue(IssmDouble* pvalue,Gauss* gauss){/*{{{*/
    167         IssmDouble time;
    168 
    169         /*First, recover current time from parameters: */
    170         this->parameters->FindParam(&time,TimeEnum);
    171 
    172         /*Retrieve interpolated values for this time step: */
    173         Input* input=GetTimeInput(time);
    174 
    175         /*Call input function*/
    176         input->GetInputValue(pvalue,gauss);
    177 
    178         delete input;
    179 }
    180 /*}}}*/
    181 void TransientInput::GetInputValue(IssmDouble* pvalue,Gauss* gauss,IssmDouble time){/*{{{*/
    182 
    183         /*Retrieve interpolated values for this time step: */
    184         Input* input=GetTimeInput(time);
    185 
    186         /*Call input function*/
    187         input->GetInputValue(pvalue,gauss);
    188 
    189         delete input;
    190 }
    191 /*}}}*/
    192 void TransientInput::GetInputDerivativeValue(IssmDouble* p, IssmDouble* xyz_list, Gauss* gauss){/*{{{*/
    193 
    194         IssmDouble time;
    195 
    196         /*First, recover current time from parameters: */
    197         parameters->FindParam(&time,TimeEnum);
    198 
    199         /*Retrieve interpolated values for this time step: */
    200         Input* input=GetTimeInput(time);
    201 
    202         /*Call input function*/
    203         input->GetInputDerivativeValue(p,xyz_list,gauss);
    204 
    205         delete input;
    206 }
    207 /*}}}*/
    208166void TransientInput::ChangeEnum(int newenumtype){/*{{{*/
    209167        this->enum_type=newenumtype;
    210 }
    211 /*}}}*/
    212 void TransientInput::GetInputAverage(IssmDouble* pvalue){/*{{{*/
    213 
    214         IssmDouble time;
    215 
    216         /*First, recover current time from parameters: */
    217         parameters->FindParam(&time,TimeEnum);
    218 
    219         /*Retrieve interpolated values for this time step: */
    220         Input* input=GetTimeInput(time);
    221 
    222         /*Call input function*/
    223         input->GetInputAverage(pvalue);
    224 
    225         delete input;
    226 
    227168}
    228169/*}}}*/
     
    246187        *ptimes=times;
    247188        *pnumtimes=numtimesteps;
     189}
     190/*}}}*/
     191void TransientInput::GetInputAverage(IssmDouble* pvalue){/*{{{*/
     192
     193        IssmDouble time;
     194
     195        /*First, recover current time from parameters: */
     196        parameters->FindParam(&time,TimeEnum);
     197
     198        /*Retrieve interpolated values for this time step: */
     199        Input* input=GetTimeInput(time);
     200
     201        /*Call input function*/
     202        input->GetInputAverage(pvalue);
     203
     204        delete input;
     205
     206}
     207/*}}}*/
     208void TransientInput::GetInputDerivativeValue(IssmDouble* p, IssmDouble* xyz_list, Gauss* gauss){/*{{{*/
     209
     210        IssmDouble time;
     211
     212        /*First, recover current time from parameters: */
     213        parameters->FindParam(&time,TimeEnum);
     214
     215        /*Retrieve interpolated values for this time step: */
     216        Input* input=GetTimeInput(time);
     217
     218        /*Call input function*/
     219        input->GetInputDerivativeValue(p,xyz_list,gauss);
     220
     221        delete input;
     222}
     223/*}}}*/
     224void TransientInput::GetInputValue(IssmDouble* pvalue,Gauss* gauss){/*{{{*/
     225        IssmDouble time;
     226
     227        /*First, recover current time from parameters: */
     228        this->parameters->FindParam(&time,TimeEnum);
     229
     230        /*Retrieve interpolated values for this time step: */
     231        Input* input=GetTimeInput(time);
     232
     233        /*Call input function*/
     234        input->GetInputValue(pvalue,gauss);
     235
     236        delete input;
     237}
     238/*}}}*/
     239void TransientInput::GetInputValue(IssmDouble* pvalue,Gauss* gauss,IssmDouble time){/*{{{*/
     240
     241        /*Retrieve interpolated values for this time step: */
     242        Input* input=GetTimeInput(time);
     243
     244        /*Call input function*/
     245        input->GetInputValue(pvalue,gauss);
     246
     247        delete input;
    248248}
    249249/*}}}*/
     
    327327}
    328328/*}}}*/
    329 int  TransientInput::GetResultInterpolation(void){/*{{{*/
    330 
    331         IssmDouble time;
    332         int        output;
    333 
    334         parameters->FindParam(&time,TimeEnum);
    335         Input* input=GetTimeInput(time);
    336         output = input->GetResultInterpolation();
    337 
    338         /*Clean up and return*/
    339         delete input;
    340         return output;
    341 
    342 }
    343 /*}}}*/
    344 int  TransientInput::GetResultNumberOfNodes(void){/*{{{*/
    345 
    346         IssmDouble time;
    347         int        output;
    348 
    349         parameters->FindParam(&time,TimeEnum);
    350         Input* input=GetTimeInput(time);
    351         output = input->GetResultNumberOfNodes();
    352 
    353         /*Clean up and return*/
    354         delete input;
    355         return output;
    356 
    357 }
    358 /*}}}*/
    359 int  TransientInput::GetResultArraySize(void){/*{{{*/
    360 
    361         return 1;
     329void TransientInput::Configure(Parameters* parameters){/*{{{*/
     330        this->parameters=parameters;
    362331}
    363332/*}}}*/
     
    369338}
    370339/*}}}*/
    371 void TransientInput::SquareMin(IssmDouble* psquaremin,Parameters* parameters){/*{{{*/
    372 
    373         IssmDouble time;
    374 
    375         /*First, recover current time from parameters: */
    376         parameters->FindParam(&time,TimeEnum);
    377 
    378    /*Retrieve interpolated values for this time step: */
    379         Input* input=GetTimeInput(time);
    380 
    381         /*Call input function*/
    382         input->SquareMin(psquaremin,parameters);
    383 
    384         delete input;
    385 
    386 }
    387 /*}}}*/
    388 IssmDouble TransientInput::InfinityNorm(void){/*{{{*/
    389 
    390         IssmDouble time;
    391         IssmDouble infnorm;
    392 
    393         /*First, recover current time from parameters: */
    394         parameters->FindParam(&time,TimeEnum);
    395 
    396    /*Retrieve interpolated values for this time step: */
    397         Input* input=GetTimeInput(time);
    398 
    399         /*Call input function*/
    400         infnorm=input->InfinityNorm();
    401 
    402         /*Clean-up and return*/
    403         delete input;
    404         return infnorm;
    405 }
    406 /*}}}*/
    407 IssmDouble TransientInput::Max(void){/*{{{*/
    408 
    409         IssmDouble time;
    410         IssmDouble max;
    411 
    412         /*First, recover current time from parameters: */
    413         parameters->FindParam(&time,TimeEnum);
    414 
    415    /*Retrieve interpolated values for this time step: */
    416         Input* input=GetTimeInput(time);
    417 
    418         /*Call input function*/
    419         max=input->Max();
    420 
    421         delete input;
    422 
    423         return max;
    424 }
    425 /*}}}*/
    426 IssmDouble TransientInput::MaxAbs(void){/*{{{*/
    427 
    428         IssmDouble time;
    429         IssmDouble maxabs;
    430 
    431         /*First, recover current time from parameters: */
    432         parameters->FindParam(&time,TimeEnum);
    433 
    434         /*Retrieve interpolated values for this time step: */
    435         Input* input=GetTimeInput(time);
    436 
    437         /*Call input function*/
    438         maxabs=input->MaxAbs();
    439 
    440         /*Clean-up and return*/
    441         delete input;
    442         return maxabs;
    443 
    444 }
    445 /*}}}*/
    446 IssmDouble TransientInput::Min(void){/*{{{*/
    447 
    448         IssmDouble time;
    449         IssmDouble min;
    450 
    451         /*First, recover current time from parameters: */
    452         parameters->FindParam(&time,TimeEnum);
    453 
    454    /*Retrieve interpolated values for this time step: */
    455         Input* input=GetTimeInput(time);
    456 
    457         /*Call input function*/
    458         min=input->Min();
    459 
    460         /*Clean-up and return*/
    461         delete input;
    462         return min;
    463 
    464 }
    465 /*}}}*/
    466 IssmDouble TransientInput::MinAbs(void){/*{{{*/
    467 
    468         IssmDouble time;
    469         IssmDouble minabs;
    470 
    471         /*First, recover current time from parameters: */
    472         parameters->FindParam(&time,TimeEnum);
    473 
    474         /*Retrieve interpolated values for this time step: */
    475         Input* input=GetTimeInput(time);
    476 
    477         /*Call input function*/
    478         minabs=input->MinAbs();
    479 
    480         /*Clean-up and return*/
    481         delete input;
    482         return minabs;
    483 }
    484 /*}}}*/
    485 void TransientInput::GetVectorFromInputs(Vector<IssmDouble>* vector,int* doflist){/*{{{*/
    486 
    487         IssmDouble time;
    488 
    489         /*First, recover current time from parameters: */
    490         parameters->FindParam(&time,TimeEnum);
    491 
    492         /*Retrieve interpolated values for this time step: */
    493         Input* input=GetTimeInput(time);
    494 
    495         /*Call input function*/
    496         input->GetVectorFromInputs(vector,doflist);
    497 
    498         delete input;
    499 
    500 } /*}}}*/
     340int  TransientInput::GetResultArraySize(void){/*{{{*/
     341
     342        return 1;
     343}
     344/*}}}*/
     345int  TransientInput::GetResultInterpolation(void){/*{{{*/
     346
     347        IssmDouble time;
     348        int        output;
     349
     350        parameters->FindParam(&time,TimeEnum);
     351        Input* input=GetTimeInput(time);
     352        output = input->GetResultInterpolation();
     353
     354        /*Clean up and return*/
     355        delete input;
     356        return output;
     357
     358}
     359/*}}}*/
     360int  TransientInput::GetResultNumberOfNodes(void){/*{{{*/
     361
     362        IssmDouble time;
     363        int        output;
     364
     365        parameters->FindParam(&time,TimeEnum);
     366        Input* input=GetTimeInput(time);
     367        output = input->GetResultNumberOfNodes();
     368
     369        /*Clean up and return*/
     370        delete input;
     371        return output;
     372
     373}
     374/*}}}*/
    501375Input* TransientInput::GetTimeInput(IssmDouble intime){/*{{{*/
    502376
     
    548422}
    549423/*}}}*/
    550 void TransientInput::Configure(Parameters* parameters){/*{{{*/
    551         this->parameters=parameters;
    552 }
    553 /*}}}*/
     424void TransientInput::GetVectorFromInputs(Vector<IssmDouble>* vector,int* doflist){/*{{{*/
     425
     426        IssmDouble time;
     427
     428        /*First, recover current time from parameters: */
     429        parameters->FindParam(&time,TimeEnum);
     430
     431        /*Retrieve interpolated values for this time step: */
     432        Input* input=GetTimeInput(time);
     433
     434        /*Call input function*/
     435        input->GetVectorFromInputs(vector,doflist);
     436
     437        delete input;
     438
     439} /*}}}*/
     440IssmDouble TransientInput::InfinityNorm(void){/*{{{*/
     441
     442        IssmDouble time;
     443        IssmDouble infnorm;
     444
     445        /*First, recover current time from parameters: */
     446        parameters->FindParam(&time,TimeEnum);
     447
     448   /*Retrieve interpolated values for this time step: */
     449        Input* input=GetTimeInput(time);
     450
     451        /*Call input function*/
     452        infnorm=input->InfinityNorm();
     453
     454        /*Clean-up and return*/
     455        delete input;
     456        return infnorm;
     457}
     458/*}}}*/
     459IssmDouble TransientInput::Max(void){/*{{{*/
     460
     461        IssmDouble time;
     462        IssmDouble max;
     463
     464        /*First, recover current time from parameters: */
     465        parameters->FindParam(&time,TimeEnum);
     466
     467   /*Retrieve interpolated values for this time step: */
     468        Input* input=GetTimeInput(time);
     469
     470        /*Call input function*/
     471        max=input->Max();
     472
     473        delete input;
     474
     475        return max;
     476}
     477/*}}}*/
     478IssmDouble TransientInput::MaxAbs(void){/*{{{*/
     479
     480        IssmDouble time;
     481        IssmDouble maxabs;
     482
     483        /*First, recover current time from parameters: */
     484        parameters->FindParam(&time,TimeEnum);
     485
     486        /*Retrieve interpolated values for this time step: */
     487        Input* input=GetTimeInput(time);
     488
     489        /*Call input function*/
     490        maxabs=input->MaxAbs();
     491
     492        /*Clean-up and return*/
     493        delete input;
     494        return maxabs;
     495
     496}
     497/*}}}*/
     498IssmDouble TransientInput::Min(void){/*{{{*/
     499
     500        IssmDouble time;
     501        IssmDouble min;
     502
     503        /*First, recover current time from parameters: */
     504        parameters->FindParam(&time,TimeEnum);
     505
     506   /*Retrieve interpolated values for this time step: */
     507        Input* input=GetTimeInput(time);
     508
     509        /*Call input function*/
     510        min=input->Min();
     511
     512        /*Clean-up and return*/
     513        delete input;
     514        return min;
     515
     516}
     517/*}}}*/
     518IssmDouble TransientInput::MinAbs(void){/*{{{*/
     519
     520        IssmDouble time;
     521        IssmDouble minabs;
     522
     523        /*First, recover current time from parameters: */
     524        parameters->FindParam(&time,TimeEnum);
     525
     526        /*Retrieve interpolated values for this time step: */
     527        Input* input=GetTimeInput(time);
     528
     529        /*Call input function*/
     530        minabs=input->MinAbs();
     531
     532        /*Clean-up and return*/
     533        delete input;
     534        return minabs;
     535}
     536/*}}}*/
     537void TransientInput::SquareMin(IssmDouble* psquaremin,Parameters* parameters){/*{{{*/
     538
     539        IssmDouble time;
     540
     541        /*First, recover current time from parameters: */
     542        parameters->FindParam(&time,TimeEnum);
     543
     544   /*Retrieve interpolated values for this time step: */
     545        Input* input=GetTimeInput(time);
     546
     547        /*Call input function*/
     548        input->SquareMin(psquaremin,parameters);
     549
     550        delete input;
     551
     552}
     553/*}}}*/
  • issm/trunk-jpl/src/c/classes/Inputs/TransientInput.h

    r19725 r20827  
    3232                /*}}}*/
    3333                /*Object virtual functions definitions:{{{*/
     34                Object* copy();
     35                void  DeepEcho();
    3436                void  Echo();
    35                 void  DeepEcho();
    3637                int   Id();
     38                void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);
    3739                int   ObjectEnum();
    38                 Object* copy();
    39                 void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);
    4040                /*}}}*/
    4141                /*TransientInput management: {{{*/
    42                 int    InstanceEnum();
    43                 Input* SpawnTriaInput(int index1,int index2,int index3);
    44                 Input* SpawnSegInput(int index1,int index2);
    45                 Input* PointwiseDivide(Input* input_in){_error_("not implemented yet");};
    46                 Input* PointwiseMin(Input* input_in){_error_("not implemented yet");};
    47                 Input* PointwiseMax(Input* input_in){_error_("not implemented yet");};
     42                void Configure(Parameters* parameters);
     43                int  GetResultArraySize(void);
    4844                int  GetResultInterpolation(void);
    4945                int  GetResultNumberOfNodes(void);
    50                 int  GetResultArraySize(void);
     46                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");};
    5150                void ResultToPatch(IssmDouble* values,int nodesperelement,int sid){_error_("not supported yet");};
    52                 void Configure(Parameters* parameters);
     51                Input* SpawnSegInput(int index1,int index2);
     52                Input* SpawnTriaInput(int index1,int index2,int index3);
    5353                /*}}}*/
    5454                /*numerics: {{{*/
     55                void AXPY(Input* xforcing,IssmDouble scalar){_error_("not implemented yet");};
     56                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");};
     59                void Extrude(int start);
     60                void GetInputAllTimeAverages(IssmDouble** pvalues,IssmDouble** ptimes, int* pnumtimes);
     61                void GetInputAverage(IssmDouble* pvalue);
     62                void GetInputDerivativeAverageValue(IssmDouble* derivativevalues, IssmDouble* xyz_list){_error_("not implemented yet");};
     63                void GetInputDerivativeValue(IssmDouble* derivativevalues, IssmDouble* xyz_list,Gauss* gauss);
    5564                void GetInputValue(bool* pvalue){_error_("not implemented yet");};
    5665                void GetInputValue(int* pvalue){_error_("not implemented yet");};
     
    5968                void GetInputValue(IssmDouble* pvalue,Gauss* gauss,IssmDouble time);
    6069                void GetInputValue(IssmDouble* pvalue,Gauss* gauss ,int index){_error_("not implemented yet");};
    61                 void GetInputDerivativeValue(IssmDouble* derivativevalues, IssmDouble* xyz_list,Gauss* gauss);
    62                 void GetInputAverage(IssmDouble* pvalue);
    63                 void GetInputDerivativeAverageValue(IssmDouble* derivativevalues, IssmDouble* xyz_list){_error_("not implemented yet");};
    64                 void GetInputAllTimeAverages(IssmDouble** pvalues,IssmDouble** ptimes, int* pnumtimes);
    6570                void GetInputUpToCurrentTimeAverages(IssmDouble** pvalues, IssmDouble** ptimes, int* pnumtimes, IssmDouble currenttime);
    66                 void ChangeEnum(int newenumtype);
    67                 void SquareMin(IssmDouble* psquaremin,Parameters* parameters);
    68                 void ConstrainMin(IssmDouble minimum){_error_("not implemented yet");};
    69                 void Set(IssmDouble setvalue){_error_("Set not implemented yet");};
    70                 void Scale(IssmDouble scale_factor){_error_("not implemented yet");};
    71                 void AXPY(Input* xforcing,IssmDouble scalar){_error_("not implemented yet");};
    72                 void Constrain(IssmDouble cm_min, IssmDouble cm_max){_error_("not implemented yet");};
     71                Input* GetTimeInput(IssmDouble time);
     72                void GetTimeValues(IssmDouble* values,IssmDouble time){_error_("not implemented yet");};
     73                void GetVectorFromInputs(Vector<IssmDouble>* vector,int* doflist);
    7374                IssmDouble InfinityNorm(void);
    7475                IssmDouble Max(void);
     
    7677                IssmDouble Min(void);
    7778                IssmDouble MinAbs(void);
    78                 void Extrude(int start);
     79                void Scale(IssmDouble scale_factor){_error_("not implemented yet");};
     80                void Set(IssmDouble setvalue){_error_("Set not implemented yet");};
     81                void SquareMin(IssmDouble* psquaremin,Parameters* parameters);
    7982                void VerticallyIntegrate(Input* thickness_forcing){_error_("not supported yet");};
    80                 void GetVectorFromInputs(Vector<IssmDouble>* vector,int* doflist);
    81                 void GetTimeValues(IssmDouble* values,IssmDouble time){_error_("not implemented yet");};
    82                 Input* GetTimeInput(IssmDouble time);
    8383                /*}}}*/
    8484
  • issm/trunk-jpl/src/c/classes/Inputs/TriaInput.cpp

    r19725 r20827  
    4141
    4242/*Object virtual functions definitions:*/
    43 void TriaInput::Echo(void){/*{{{*/
    44         this->DeepEcho();
     43Object* TriaInput::copy() {/*{{{*/
     44
     45        return new TriaInput(this->enum_type,this->values,this->interpolation_type);
     46
    4547}
    4648/*}}}*/
     
    5254}
    5355/*}}}*/
     56void TriaInput::Echo(void){/*{{{*/
     57        this->DeepEcho();
     58}
     59/*}}}*/
    5460int  TriaInput::Id(void){ return -1; }/*{{{*/
    55 /*}}}*/
    56 int  TriaInput::ObjectEnum(void){/*{{{*/
    57 
    58         return TriaInputEnum;
    59 
    60 }
    61 /*}}}*/
    62 Object* TriaInput::copy() {/*{{{*/
    63 
    64         return new TriaInput(this->enum_type,this->values,this->interpolation_type);
    65 
    66 }
    6761/*}}}*/
    6862void TriaInput::Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ /*{{{*/
     
    8074}
    8175/*}}}*/
     76int  TriaInput::ObjectEnum(void){/*{{{*/
     77
     78        return TriaInputEnum;
     79
     80}
     81/*}}}*/
    8282
    8383/*TriaInput management*/
     
    8888}
    8989/*}}}*/
    90 Input* TriaInput::SpawnTriaInput(int index1,int index2,int index3){/*{{{*/
    91 
    92         /*output*/
    93         TriaInput* outinput=NULL;
    94 
    95         /*Create new Tria input (copy of current input)*/
    96         outinput=new TriaInput(this->enum_type,&this->values[0],this->interpolation_type);
    97 
    98         /*Assign output*/
    99         return outinput;
    100 
     90int  TriaInput::GetResultArraySize(void){/*{{{*/
     91
     92        return 1;
     93
     94}
     95/*}}}*/
     96int  TriaInput::GetResultInterpolation(void){/*{{{*/
     97
     98        if(this->interpolation_type==P0Enum){
     99                return P0Enum;
     100        }
     101        return P1Enum;
     102
     103}
     104/*}}}*/
     105int  TriaInput::GetResultNumberOfNodes(void){/*{{{*/
     106
     107        return this->NumberofNodes(this->interpolation_type);
     108
     109}
     110/*}}}*/
     111void TriaInput::ResultToPatch(IssmDouble* values,int nodesperelement,int sid){/*{{{*/
     112
     113        int numnodes = this->NumberofNodes(this->interpolation_type);
     114
     115        /*Some checks*/
     116        _assert_(values);
     117        _assert_(numnodes==nodesperelement);
     118
     119        /*Fill in arrays*/
     120        for(int i=0;i<numnodes;i++) values[sid*numnodes + i] = this->values[i];
    101121}
    102122/*}}}*/
     
    126146}
    127147/*}}}*/
    128 int  TriaInput::GetResultInterpolation(void){/*{{{*/
    129 
    130         if(this->interpolation_type==P0Enum){
    131                 return P0Enum;
    132         }
    133         return P1Enum;
    134 
    135 }
    136 /*}}}*/
    137 int  TriaInput::GetResultNumberOfNodes(void){/*{{{*/
    138 
    139         return this->NumberofNodes(this->interpolation_type);
    140 
    141 }
    142 /*}}}*/
    143 int  TriaInput::GetResultArraySize(void){/*{{{*/
    144 
    145         return 1;
    146 
    147 }
    148 /*}}}*/
    149 void TriaInput::ResultToPatch(IssmDouble* values,int nodesperelement,int sid){/*{{{*/
    150 
    151         int numnodes = this->NumberofNodes(this->interpolation_type);
    152 
    153         /*Some checks*/
    154         _assert_(values);
    155         _assert_(numnodes==nodesperelement);
    156 
    157         /*Fill in arrays*/
    158         for(int i=0;i<numnodes;i++) values[sid*numnodes + i] = this->values[i];
     148Input* TriaInput::SpawnTriaInput(int index1,int index2,int index3){/*{{{*/
     149
     150        /*output*/
     151        TriaInput* outinput=NULL;
     152
     153        /*Create new Tria input (copy of current input)*/
     154        outinput=new TriaInput(this->enum_type,&this->values[0],this->interpolation_type);
     155
     156        /*Assign output*/
     157        return outinput;
     158
    159159}
    160160/*}}}*/
    161161
    162162/*Object functions*/
    163 void TriaInput::GetInputValue(IssmDouble* pvalue,Gauss* gauss){/*{{{*/
    164 
    165         /*Call TriaRef function*/
    166         _assert_(gauss->Enum()==GaussTriaEnum);
    167         TriaRef::GetInputValue(pvalue,&values[0],(GaussTria*)gauss,this->interpolation_type);
    168 
    169 }
    170 /*}}}*/
    171 void TriaInput::GetInputDerivativeValue(IssmDouble* p, IssmDouble* xyz_list, Gauss* gauss){/*{{{*/
    172 
    173         /*Call TriaRef function*/
    174         _assert_(gauss->Enum()==GaussTriaEnum);
    175         TriaRef::GetInputDerivativeValue(p,&values[0],xyz_list,(GaussTria*)gauss,this->interpolation_type);
    176 }
    177 /*}}}*/
    178163void TriaInput::ChangeEnum(int newenumtype){/*{{{*/
    179164        this->enum_type=newenumtype;
     165}
     166/*}}}*/
     167void TriaInput::GetInputAllTimeAverages(IssmDouble** pvalues,IssmDouble** ptimes, int* pnumtimes){/*{{{*/
     168
     169        IssmDouble* outvalues=NULL;
     170        IssmDouble* times=NULL;
     171        int         numtimes;
     172
     173        /*this is not a transient forcing, so we only have 1 value, steady state: */
     174        numtimes=1;
     175        outvalues=xNew<IssmDouble>(1);
     176        times=xNew<IssmDouble>(1);
     177
     178        this->GetInputAverage(&outvalues[0]);
     179        times[0]=0.; /*we don't have a time*/
     180
     181        *pvalues=outvalues;
     182        *ptimes=times;
     183        *pnumtimes=numtimes;
    180184}
    181185/*}}}*/
     
    212216}
    213217/*}}}*/
    214 void TriaInput::GetInputAllTimeAverages(IssmDouble** pvalues,IssmDouble** ptimes, int* pnumtimes){/*{{{*/
     218void TriaInput::GetInputDerivativeValue(IssmDouble* p, IssmDouble* xyz_list, Gauss* gauss){/*{{{*/
     219
     220        /*Call TriaRef function*/
     221        _assert_(gauss->Enum()==GaussTriaEnum);
     222        TriaRef::GetInputDerivativeValue(p,&values[0],xyz_list,(GaussTria*)gauss,this->interpolation_type);
     223}
     224/*}}}*/
     225void TriaInput::GetInputUpToCurrentTimeAverages(IssmDouble** pvalues, IssmDouble** ptimes, int* pnumtimes, IssmDouble currenttime){/*{{{*/
    215226
    216227        IssmDouble* outvalues=NULL;
     
    224235
    225236        this->GetInputAverage(&outvalues[0]);
    226         times[0]=0.; /*we don't have a time*/
     237        times[0]=currenttime; /*we don't have a time*/
    227238
    228239        *pvalues=outvalues;
     
    231242}
    232243/*}}}*/
    233 void TriaInput::GetInputUpToCurrentTimeAverages(IssmDouble** pvalues, IssmDouble** ptimes, int* pnumtimes, IssmDouble currenttime){/*{{{*/
    234 
    235         IssmDouble* outvalues=NULL;
    236         IssmDouble* times=NULL;
    237         int         numtimes;
    238 
    239         /*this is not a transient forcing, so we only have 1 value, steady state: */
    240         numtimes=1;
    241         outvalues=xNew<IssmDouble>(1);
    242         times=xNew<IssmDouble>(1);
    243 
    244         this->GetInputAverage(&outvalues[0]);
    245         times[0]=currenttime; /*we don't have a time*/
    246 
    247         *pvalues=outvalues;
    248         *ptimes=times;
    249         *pnumtimes=numtimes;
     244void TriaInput::GetInputValue(IssmDouble* pvalue,Gauss* gauss){/*{{{*/
     245
     246        /*Call TriaRef function*/
     247        _assert_(gauss->Enum()==GaussTriaEnum);
     248        TriaRef::GetInputValue(pvalue,&values[0],(GaussTria*)gauss,this->interpolation_type);
     249
    250250}
    251251/*}}}*/
    252252
    253253/*Intermediary*/
    254 void TriaInput::SquareMin(IssmDouble* psquaremin,Parameters* parameters){/*{{{*/
    255 
    256         int        numnodes=this->NumberofNodes(this->interpolation_type);
    257         IssmDouble squaremin;
    258 
    259         /*Now, figure out minimum of valuescopy: */
    260         squaremin=pow(this->values[0],2);
    261         for(int i=1;i<numnodes;i++){
    262                 if(pow(this->values[i],2)<squaremin)squaremin=pow(this->values[i],2);
    263         }
    264         /*Assign output pointers:*/
    265         *psquaremin=squaremin;
    266 }
    267 /*}}}*/
    268 void TriaInput::ConstrainMin(IssmDouble minimum){/*{{{*/
    269 
    270         int numnodes = this->NumberofNodes(this->interpolation_type);
    271         for(int i=0;i<numnodes;i++) if (values[i]<minimum) values[i]=minimum;
    272 }
    273 /*}}}*/
    274 IssmDouble TriaInput::InfinityNorm(void){/*{{{*/
    275 
    276         /*Output*/
    277         IssmDouble norm=0.;
    278         int numnodes=this->NumberofNodes(this->interpolation_type);
    279 
    280         for(int i=0;i<numnodes;i++) if(fabs(values[i])>norm) norm=fabs(values[i]);
    281         return norm;
    282 }
    283 /*}}}*/
    284 IssmDouble TriaInput::Max(void){/*{{{*/
    285 
    286         int  numnodes=this->NumberofNodes(this->interpolation_type);
    287         IssmDouble max=values[0];
    288 
    289         for(int i=1;i<numnodes;i++){
    290                 if(values[i]>max) max=values[i];
    291         }
    292         return max;
    293 }
    294 /*}}}*/
    295 IssmDouble TriaInput::MaxAbs(void){/*{{{*/
    296 
    297         int  numnodes=this->NumberofNodes(this->interpolation_type);
    298         IssmDouble max=fabs(values[0]);
    299 
    300         for(int i=1;i<numnodes;i++){
    301                 if(fabs(values[i])>max) max=fabs(values[i]);
    302         }
    303         return max;
    304 }
    305 /*}}}*/
    306 IssmDouble TriaInput::Min(void){/*{{{*/
    307 
    308         const int  numnodes=this->NumberofNodes(this->interpolation_type);
    309         IssmDouble min=values[0];
    310 
    311         for(int i=1;i<numnodes;i++){
    312                 if(values[i]<min) min=values[i];
    313         }
    314         return min;
    315 }
    316 /*}}}*/
    317 IssmDouble TriaInput::MinAbs(void){/*{{{*/
    318 
    319         const int  numnodes=this->NumberofNodes(this->interpolation_type);
    320         IssmDouble min=fabs(values[0]);
    321 
    322         for(int i=1;i<numnodes;i++){
    323                 if(fabs(values[i])<min) min=fabs(values[i]);
    324         }
    325         return min;
    326 }
    327 /*}}}*/
    328 void TriaInput::Scale(IssmDouble scale_factor){/*{{{*/
    329 
    330         const int numnodes=this->NumberofNodes(this->interpolation_type);
    331         for(int i=0;i<numnodes;i++)values[i]=values[i]*scale_factor;
    332 }
    333 /*}}}*/
    334 void TriaInput::Set(IssmDouble setvalue){/*{{{*/
    335 
    336         const int numnodes=this->NumberofNodes(this->interpolation_type);
    337         for(int i=0;i<numnodes;i++)values[i]=setvalue;
    338 }
    339 /*}}}*/
    340254void TriaInput::AXPY(Input* xinput,IssmDouble scalar){/*{{{*/
    341255
     
    353267}
    354268/*}}}*/
     269void TriaInput::Configure(Parameters* parameters){/*{{{*/
     270        /*do nothing: */
     271}
     272/*}}}*/
    355273void TriaInput::Constrain(IssmDouble cm_min, IssmDouble cm_max){/*{{{*/
    356274
     
    361279        if(!xIsNan<IssmDouble>(cm_max)) for(i=0;i<numnodes;i++)if (this->values[i]>cm_max)this->values[i]=cm_max;
    362280
     281}
     282/*}}}*/
     283void 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;
    363287}
    364288/*}}}*/
     
    367291        vector->SetValues(numvertices,doflist,this->values,INS_VAL);
    368292} /*}}}*/
     293IssmDouble TriaInput::InfinityNorm(void){/*{{{*/
     294
     295        /*Output*/
     296        IssmDouble norm=0.;
     297        int numnodes=this->NumberofNodes(this->interpolation_type);
     298
     299        for(int i=0;i<numnodes;i++) if(fabs(values[i])>norm) norm=fabs(values[i]);
     300        return norm;
     301}
     302/*}}}*/
     303IssmDouble TriaInput::Max(void){/*{{{*/
     304
     305        int  numnodes=this->NumberofNodes(this->interpolation_type);
     306        IssmDouble max=values[0];
     307
     308        for(int i=1;i<numnodes;i++){
     309                if(values[i]>max) max=values[i];
     310        }
     311        return max;
     312}
     313/*}}}*/
     314IssmDouble TriaInput::MaxAbs(void){/*{{{*/
     315
     316        int  numnodes=this->NumberofNodes(this->interpolation_type);
     317        IssmDouble max=fabs(values[0]);
     318
     319        for(int i=1;i<numnodes;i++){
     320                if(fabs(values[i])>max) max=fabs(values[i]);
     321        }
     322        return max;
     323}
     324/*}}}*/
     325IssmDouble TriaInput::Min(void){/*{{{*/
     326
     327        const int  numnodes=this->NumberofNodes(this->interpolation_type);
     328        IssmDouble min=values[0];
     329
     330        for(int i=1;i<numnodes;i++){
     331                if(values[i]<min) min=values[i];
     332        }
     333        return min;
     334}
     335/*}}}*/
     336IssmDouble TriaInput::MinAbs(void){/*{{{*/
     337
     338        const int  numnodes=this->NumberofNodes(this->interpolation_type);
     339        IssmDouble min=fabs(values[0]);
     340
     341        for(int i=1;i<numnodes;i++){
     342                if(fabs(values[i])<min) min=fabs(values[i]);
     343        }
     344        return min;
     345}
     346/*}}}*/
     347Input* 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/*}}}*/
    369378Input* TriaInput::PointwiseMin(Input* inputB){/*{{{*/
    370379
     
    398407}
    399408/*}}}*/
    400 Input* TriaInput::PointwiseMax(Input* inputB){/*{{{*/
    401 
    402         /*Ouput*/
    403         TriaInput* outinput=NULL;
    404 
    405         /*Intermediaries*/
    406         int         i;
    407         TriaInput  *xinputB   = NULL;
    408         const int   numnodes  = this->NumberofNodes(this->interpolation_type);
    409         IssmDouble *maxvalues = xNew<IssmDouble>(numnodes);
    410 
    411         /*Check that inputB is of the same type*/
    412         if(inputB->ObjectEnum()!=TriaInputEnum) _error_("Operation not permitted because inputB is of type " << EnumToStringx(inputB->ObjectEnum()));
    413         xinputB=(TriaInput*)inputB;
    414         if(xinputB->interpolation_type!=this->interpolation_type) _error_("Operation not permitted because inputB is of type " << EnumToStringx(xinputB->interpolation_type));
    415 
    416         /*Create point wise max*/
    417         for(i=0;i<numnodes;i++){
    418                 if(this->values[i] < xinputB->values[i]) maxvalues[i]=xinputB->values[i];
    419                 else maxvalues[i]=this->values[i];
    420         }
    421 
    422         /*Create new Tria vertex input (copy of current input)*/
    423         outinput=new TriaInput(this->enum_type,&maxvalues[0],this->interpolation_type);
    424 
    425         /*Return output pointer*/
    426         xDelete<IssmDouble>(maxvalues);
    427         return outinput;
    428 
    429 }
    430 /*}}}*/
    431409Input* TriaInput::PointwiseDivide(Input* inputB){/*{{{*/
    432410
     
    461439}
    462440/*}}}*/
    463 void TriaInput::Configure(Parameters* parameters){/*{{{*/
    464         /*do nothing: */
    465 }
    466 /*}}}*/
     441void TriaInput::Scale(IssmDouble scale_factor){/*{{{*/
     442
     443        const int numnodes=this->NumberofNodes(this->interpolation_type);
     444        for(int i=0;i<numnodes;i++)values[i]=values[i]*scale_factor;
     445}
     446/*}}}*/
     447void TriaInput::Set(IssmDouble setvalue){/*{{{*/
     448
     449        const int numnodes=this->NumberofNodes(this->interpolation_type);
     450        for(int i=0;i<numnodes;i++)values[i]=setvalue;
     451}
     452/*}}}*/
     453void TriaInput::SquareMin(IssmDouble* psquaremin,Parameters* parameters){/*{{{*/
     454
     455        int        numnodes=this->NumberofNodes(this->interpolation_type);
     456        IssmDouble squaremin;
     457
     458        /*Now, figure out minimum of valuescopy: */
     459        squaremin=pow(this->values[0],2);
     460        for(int i=1;i<numnodes;i++){
     461                if(pow(this->values[i],2)<squaremin)squaremin=pow(this->values[i],2);
     462        }
     463        /*Assign output pointers:*/
     464        *psquaremin=squaremin;
     465}
     466/*}}}*/
  • issm/trunk-jpl/src/c/classes/Inputs/TriaInput.h

    r19725 r20827  
    2727
    2828                /*Object virtual functions definitions*/
     29                Object *copy();
     30                void    DeepEcho();
    2931                void    Echo();
    30                 void    DeepEcho();
    3132                int     Id();
     33                void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);
    3234                int     ObjectEnum();
    33                 Object *copy();
    34                 void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);
    3535
    3636                /*TriaInput management:*/
    37                 int    InstanceEnum();
    38                 Input* SpawnTriaInput(int index1,int index2,int index3);
    39                 Input* SpawnSegInput(int index1,int index2);
    40                 Input* PointwiseDivide(Input* inputB);
    41                 Input* PointwiseMin(Input* inputB);
    42                 Input* PointwiseMax(Input* inputB);
     37                void   AddTimeValues(IssmDouble* values,int step,IssmDouble time){_error_("not supported yet");};
     38                void   Configure(Parameters* parameters);
     39                int    GetResultArraySize(void);
    4340                int    GetResultInterpolation(void);
    4441                int    GetResultNumberOfNodes(void);
    45                 int    GetResultArraySize(void);
     42                int    InstanceEnum();
     43                Input* PointwiseDivide(Input* inputB);
     44                Input* PointwiseMax(Input* inputB);
     45                Input* PointwiseMin(Input* inputB);
    4646                void   ResultToPatch(IssmDouble* values,int nodesperelement,int sid);
    47                 void   AddTimeValues(IssmDouble* values,int step,IssmDouble time){_error_("not supported yet");};
    48                 void   Configure(Parameters* parameters);
     47                Input* SpawnSegInput(int index1,int index2);
     48                Input* SpawnTriaInput(int index1,int index2,int index3);
    4949
    5050                /*numerics*/
     51                void AXPY(Input* xinput,IssmDouble scalar);
     52                void ChangeEnum(int newenumtype);
     53                void Constrain(IssmDouble cm_min, IssmDouble cm_max);
     54                void ConstrainMin(IssmDouble minimum);
     55                void Extrude(int start){_error_("not supported yet");};
     56                void GetInputAllTimeAverages(IssmDouble** pvalues,IssmDouble** ptimes, int* pnumtimes);
     57                void GetInputAverage(IssmDouble* pvalue);
     58                void GetInputDerivativeAverageValue(IssmDouble* derivativevalues, IssmDouble* xyz_list);
     59                void GetInputDerivativeValue(IssmDouble* derivativevalues, IssmDouble* xyz_list,Gauss* gauss);
    5160                void GetInputValue(bool* pvalue){_error_("not implemented yet");}
    5261                void GetInputValue(int* pvalue){_error_("not implemented yet");}
     
    5564                void GetInputValue(IssmDouble* pvalue,Gauss* gauss,IssmDouble time){_error_("not implemented yet");};
    5665                void GetInputValue(IssmDouble* pvalue,Gauss* gauss,int index){_error_("not implemented yet");};
    57                 void GetInputDerivativeValue(IssmDouble* derivativevalues, IssmDouble* xyz_list,Gauss* gauss);
    58                 void GetInputAverage(IssmDouble* pvalue);
    59                 void GetInputDerivativeAverageValue(IssmDouble* derivativevalues, IssmDouble* xyz_list);
    60                 void GetInputAllTimeAverages(IssmDouble** pvalues,IssmDouble** ptimes, int* pnumtimes);
    6166                void GetInputUpToCurrentTimeAverages(IssmDouble** pvalues, IssmDouble** ptimes, int* pnumtimes, IssmDouble currenttime);
    62                 void ChangeEnum(int newenumtype);
    63                 void SquareMin(IssmDouble* psquaremin,Parameters* parameters);
    64                 void ConstrainMin(IssmDouble minimum);
    65                 void Set(IssmDouble setvalue);
    66                 void Scale(IssmDouble scale_factor);
    67                 void AXPY(Input* xinput,IssmDouble scalar);
    68                 void Constrain(IssmDouble cm_min, IssmDouble cm_max);
     67                void GetVectorFromInputs(Vector<IssmDouble>* vector,int* doflist);
    6968                IssmDouble InfinityNorm(void);
    7069                IssmDouble Max(void);
     
    7271                IssmDouble Min(void);
    7372                IssmDouble MinAbs(void);
    74                 void Extrude(int start){_error_("not supported yet");};
     73                void Scale(IssmDouble scale_factor);
     74                void Set(IssmDouble setvalue);
     75                void SquareMin(IssmDouble* psquaremin,Parameters* parameters);
    7576                void VerticallyIntegrate(Input* thickness_input){_error_("not supported yet");};
    76                 void GetVectorFromInputs(Vector<IssmDouble>* vector,int* doflist);
    7777
    7878};
  • issm/trunk-jpl/src/c/classes/Loads/Friction.cpp

    r20616 r20827  
    5757
    5858}/*}}}*/
    59 void Friction::GetAlphaViscousComplement(IssmDouble* palpha_complement, Gauss* gauss){/*{{{*/
    60 
    61         /* FrictionGetAlpha2 computes alpha2= drag^2 * Neff ^r * vel ^s, with Neff=rho_ice*g*thickness+rho_ice*g*bed, r=q/p and s=1/p.
    62          * FrictionGetAlphaComplement is used in control methods on drag, and it computes:
    63          * alpha_complement= Neff ^r * vel ^s*/
    64 
    65         /*diverse: */
    66         IssmDouble  r,s;
    67         IssmDouble  vx,vy,vz,vmag;
    68         IssmDouble  drag_p,drag_q;
    69         IssmDouble  Neff;
    70         IssmDouble  drag_coefficient;
    71         IssmDouble  bed,thickness,sealevel;
    72         IssmDouble  alpha_complement;
    73 
    74         /*Recover parameters: */
    75         element->GetInputValue(&drag_p,FrictionPEnum);
    76         element->GetInputValue(&drag_q,FrictionQEnum);
    77         element->GetInputValue(&thickness, gauss,ThicknessEnum);
    78         element->GetInputValue(&bed, gauss,BaseEnum);
    79         element->GetInputValue(&sealevel, gauss,SealevelEnum);
    80         element->GetInputValue(&drag_coefficient, gauss,FrictionCoefficientEnum);
    81         IssmDouble rho_water   = element->GetMaterialParameter(MaterialsRhoSeawaterEnum);
    82         IssmDouble rho_ice     = element->GetMaterialParameter(MaterialsRhoIceEnum);
    83         IssmDouble gravity     = element->GetMaterialParameter(ConstantsGEnum);
    84 
    85         //compute r and q coefficients: */
    86         r=drag_q/drag_p;
    87         s=1./drag_p;
    88 
    89         //From bed and thickness, compute effective pressure when drag is viscous:
    90         Neff=gravity*(rho_ice*thickness+rho_water*(bed-sealevel));
    91         if(Neff<0)Neff=0;
    92 
    93         //We need the velocity magnitude to evaluate the basal stress:
    94         switch(dim){
    95                 case 1:
    96                         element->GetInputValue(&vx,gauss,VxEnum);
    97                         vmag=sqrt(vx*vx);
    98                         break;
    99                 case 2:
    100                         element->GetInputValue(&vx,gauss,VxEnum);
    101                         element->GetInputValue(&vy,gauss,VyEnum);
    102                         vmag=sqrt(vx*vx+vy*vy);
    103                         break;
    104                 case 3:
    105                         element->GetInputValue(&vx,gauss,VxEnum);
    106                         element->GetInputValue(&vy,gauss,VyEnum);
    107                         element->GetInputValue(&vz,gauss,VzEnum);
    108                         vmag=sqrt(vx*vx+vy*vy+vz*vz);
    109                         break;
    110                 default:
    111                         _error_("not supported");
    112         }
    113 
    114         /*Check to prevent dividing by zero if vmag==0*/
    115         if(vmag==0. && (s-1.)<0.) alpha_complement=0.;
    116         else alpha_complement=pow(Neff,r)*pow(vmag,(s-1));_assert_(!xIsNan<IssmDouble>(alpha_complement));
    117 
    118         /*Assign output pointers:*/
    119         *palpha_complement=alpha_complement;
    120 }
    121 /*}}}*/
    12259void Friction::GetAlphaHydroComplement(IssmDouble* palpha_complement, Gauss* gauss){/*{{{*/
    12360
     
    220157        *palpha_complement=alpha_complement;
    221158}/*}}}*/
     159void Friction::GetAlphaViscousComplement(IssmDouble* palpha_complement, Gauss* gauss){/*{{{*/
     160
     161        /* FrictionGetAlpha2 computes alpha2= drag^2 * Neff ^r * vel ^s, with Neff=rho_ice*g*thickness+rho_ice*g*bed, r=q/p and s=1/p.
     162         * FrictionGetAlphaComplement is used in control methods on drag, and it computes:
     163         * alpha_complement= Neff ^r * vel ^s*/
     164
     165        /*diverse: */
     166        IssmDouble  r,s;
     167        IssmDouble  vx,vy,vz,vmag;
     168        IssmDouble  drag_p,drag_q;
     169        IssmDouble  Neff;
     170        IssmDouble  drag_coefficient;
     171        IssmDouble  bed,thickness,sealevel;
     172        IssmDouble  alpha_complement;
     173
     174        /*Recover parameters: */
     175        element->GetInputValue(&drag_p,FrictionPEnum);
     176        element->GetInputValue(&drag_q,FrictionQEnum);
     177        element->GetInputValue(&thickness, gauss,ThicknessEnum);
     178        element->GetInputValue(&bed, gauss,BaseEnum);
     179        element->GetInputValue(&sealevel, gauss,SealevelEnum);
     180        element->GetInputValue(&drag_coefficient, gauss,FrictionCoefficientEnum);
     181        IssmDouble rho_water   = element->GetMaterialParameter(MaterialsRhoSeawaterEnum);
     182        IssmDouble rho_ice     = element->GetMaterialParameter(MaterialsRhoIceEnum);
     183        IssmDouble gravity     = element->GetMaterialParameter(ConstantsGEnum);
     184
     185        //compute r and q coefficients: */
     186        r=drag_q/drag_p;
     187        s=1./drag_p;
     188
     189        //From bed and thickness, compute effective pressure when drag is viscous:
     190        Neff=gravity*(rho_ice*thickness+rho_water*(bed-sealevel));
     191        if(Neff<0)Neff=0;
     192
     193        //We need the velocity magnitude to evaluate the basal stress:
     194        switch(dim){
     195                case 1:
     196                        element->GetInputValue(&vx,gauss,VxEnum);
     197                        vmag=sqrt(vx*vx);
     198                        break;
     199                case 2:
     200                        element->GetInputValue(&vx,gauss,VxEnum);
     201                        element->GetInputValue(&vy,gauss,VyEnum);
     202                        vmag=sqrt(vx*vx+vy*vy);
     203                        break;
     204                case 3:
     205                        element->GetInputValue(&vx,gauss,VxEnum);
     206                        element->GetInputValue(&vy,gauss,VyEnum);
     207                        element->GetInputValue(&vz,gauss,VzEnum);
     208                        vmag=sqrt(vx*vx+vy*vy+vz*vz);
     209                        break;
     210                default:
     211                        _error_("not supported");
     212        }
     213
     214        /*Check to prevent dividing by zero if vmag==0*/
     215        if(vmag==0. && (s-1.)<0.) alpha_complement=0.;
     216        else alpha_complement=pow(Neff,r)*pow(vmag,(s-1));_assert_(!xIsNan<IssmDouble>(alpha_complement));
     217
     218        /*Assign output pointers:*/
     219        *palpha_complement=alpha_complement;
     220}
     221/*}}}*/
    222222void Friction::GetAlpha2(IssmDouble* palpha2, Gauss* gauss){/*{{{*/
    223223
     
    402402        *palpha2=alpha2;
    403403}/*}}}*/
     404void Friction::GetAlpha2Sommers(IssmDouble* palpha2, Gauss* gauss){/*{{{*/
     405
     406        /* FrictionGetAlpha2 computes alpha2= drag^2 * Neff, with Neff=rho_ice*g*thickness+rho_ice*g*(head-bed)*/
     407
     408        /*diverse: */
     409        IssmDouble  pressure_ice,pressure_water;
     410        IssmDouble  Neff;
     411        IssmDouble  drag_coefficient;
     412        IssmDouble  bed,thickness,head,sealevel;
     413        IssmDouble  alpha2;
     414
     415        /*Recover parameters: */
     416        element->GetInputValue(&thickness, gauss,ThicknessEnum);
     417        element->GetInputValue(&bed, gauss,BaseEnum);
     418        element->GetInputValue(&head, gauss,HydrologyHeadEnum);
     419        element->GetInputValue(&sealevel, gauss,SealevelEnum);
     420        element->GetInputValue(&drag_coefficient, gauss,FrictionCoefficientEnum);
     421        IssmDouble rho_water   = element->GetMaterialParameter(MaterialsRhoFreshwaterEnum);
     422        IssmDouble rho_ice     = element->GetMaterialParameter(MaterialsRhoIceEnum);
     423        IssmDouble gravity     = element->GetMaterialParameter(ConstantsGEnum);
     424
     425        //From bed and thickness, compute effective pressure when drag is viscous:
     426        pressure_ice   = rho_ice*gravity*thickness;
     427        pressure_water = rho_water*gravity*(head-bed+sealevel);
     428        Neff=pressure_ice-pressure_water;
     429        if(Neff<0.) Neff=0.;
     430
     431        alpha2=drag_coefficient*drag_coefficient*Neff;
     432        _assert_(!xIsNan<IssmDouble>(alpha2));
     433
     434        /*Assign output pointers:*/
     435        *palpha2=alpha2;
     436}
     437/*}}}*/
    404438void Friction::GetAlpha2Temp(IssmDouble* palpha2, Gauss* gauss){/*{{{*/
    405439        /*Here, we want to parameterize the friction as a function of temperature
     
    624658        *palpha2=alpha2;
    625659}/*}}}*/
    626 void Friction::GetAlpha2Sommers(IssmDouble* palpha2, Gauss* gauss){/*{{{*/
    627 
    628         /* FrictionGetAlpha2 computes alpha2= drag^2 * Neff, with Neff=rho_ice*g*thickness+rho_ice*g*(head-bed)*/
    629 
    630         /*diverse: */
    631         IssmDouble  pressure_ice,pressure_water;
    632         IssmDouble  Neff;
    633         IssmDouble  drag_coefficient;
    634         IssmDouble  bed,thickness,head,sealevel;
    635         IssmDouble  alpha2;
    636 
    637         /*Recover parameters: */
    638         element->GetInputValue(&thickness, gauss,ThicknessEnum);
    639         element->GetInputValue(&bed, gauss,BaseEnum);
    640         element->GetInputValue(&head, gauss,HydrologyHeadEnum);
    641         element->GetInputValue(&sealevel, gauss,SealevelEnum);
    642         element->GetInputValue(&drag_coefficient, gauss,FrictionCoefficientEnum);
    643         IssmDouble rho_water   = element->GetMaterialParameter(MaterialsRhoFreshwaterEnum);
    644         IssmDouble rho_ice     = element->GetMaterialParameter(MaterialsRhoIceEnum);
    645         IssmDouble gravity     = element->GetMaterialParameter(ConstantsGEnum);
    646 
    647         //From bed and thickness, compute effective pressure when drag is viscous:
    648         pressure_ice   = rho_ice*gravity*thickness;
    649         pressure_water = rho_water*gravity*(head-bed+sealevel);
    650         Neff=pressure_ice-pressure_water;
    651         if(Neff<0.) Neff=0.;
    652 
    653         alpha2=drag_coefficient*drag_coefficient*Neff;
    654         _assert_(!xIsNan<IssmDouble>(alpha2));
    655 
    656         /*Assign output pointers:*/
    657         *palpha2=alpha2;
    658 }
    659 /*}}}*/
  • issm/trunk-jpl/src/c/classes/Loads/Friction.h

    r20616 r20827  
    3030                void  Echo(void);
    3131                void  GetAlphaComplement(IssmDouble* alpha_complement,Gauss* gauss);
    32                 void  GetAlphaViscousComplement(IssmDouble* alpha_complement,Gauss* gauss);
    3332                void  GetAlphaHydroComplement(IssmDouble* alpha_complement,Gauss* gauss);
    3433                void  GetAlphaTempComplement(IssmDouble* alpha_complement,Gauss* gauss);
     34                void  GetAlphaViscousComplement(IssmDouble* alpha_complement,Gauss* gauss);
    3535                void  GetAlpha2(IssmDouble* palpha2,Gauss* gauss);
    3636                void  GetAlpha2Coulomb(IssmDouble* palpha2,Gauss* gauss);
    3737                void  GetAlpha2Hydro(IssmDouble* palpha2,Gauss* gauss);
     38                void  GetAlpha2Sommers(IssmDouble* palpha2,Gauss* gauss);
    3839                void  GetAlpha2Temp(IssmDouble* palpha2,Gauss* gauss);
    3940                void  GetAlpha2Viscous(IssmDouble* palpha2,Gauss* gauss);
     
    4142                void  GetAlpha2Weertman(IssmDouble* palpha2,Gauss* gauss);
    4243                void  GetAlpha2WeertmanTemp(IssmDouble* palpha2,Gauss* gauss);
    43                 void  GetAlpha2Sommers(IssmDouble* palpha2,Gauss* gauss);
    4444};
    4545
  • issm/trunk-jpl/src/c/classes/Loads/Moulin.cpp

    r19744 r20827  
    9797}
    9898/*}}}*/
    99 void    Moulin::Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ /*{{{*/
    100 
    101         _assert_(this);
    102 
    103         /*ok, marshall operations: */
    104         MARSHALLING_ENUM(MoulinEnum);
    105         MARSHALLING(id);
    106         MARSHALLING(analysis_type);
    107 
    108         if(marshall_direction==MARSHALLING_BACKWARD){
    109                 this->hnode      = new Hook();
    110                 this->helement   = new Hook();
    111                 this->hmatpar    = new Hook();
    112         }
    113 
    114         this->hnode->Marshall(pmarshalled_data,pmarshalled_data_size,marshall_direction);
    115         this->helement->Marshall(pmarshalled_data,pmarshalled_data_size,marshall_direction);
    116         this->hmatpar->Marshall(pmarshalled_data,pmarshalled_data_size,marshall_direction);
    117 
    118         /*corresponding fields*/
    119         node   =(Node*)this->hnode->delivers();
    120         matpar =(Matpar*)this->hmatpar->delivers();
    121         element=(Element*)this->helement->delivers();
    122 }
    123 /*}}}*/
    12499void    Moulin::DeepEcho(void){/*{{{*/
    125100
     
    139114/*}}}*/
    140115int     Moulin::Id(void){ return id; }/*{{{*/
     116/*}}}*/
     117void    Moulin::Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ /*{{{*/
     118
     119        _assert_(this);
     120
     121        /*ok, marshall operations: */
     122        MARSHALLING_ENUM(MoulinEnum);
     123        MARSHALLING(id);
     124        MARSHALLING(analysis_type);
     125
     126        if(marshall_direction==MARSHALLING_BACKWARD){
     127                this->hnode      = new Hook();
     128                this->helement   = new Hook();
     129                this->hmatpar    = new Hook();
     130        }
     131
     132        this->hnode->Marshall(pmarshalled_data,pmarshalled_data_size,marshall_direction);
     133        this->helement->Marshall(pmarshalled_data,pmarshalled_data_size,marshall_direction);
     134        this->hmatpar->Marshall(pmarshalled_data,pmarshalled_data_size,marshall_direction);
     135
     136        /*corresponding fields*/
     137        node   =(Node*)this->hnode->delivers();
     138        matpar =(Matpar*)this->hmatpar->delivers();
     139        element=(Element*)this->helement->delivers();
     140}
    141141/*}}}*/
    142142int     Moulin::ObjectEnum(void){/*{{{*/
  • issm/trunk-jpl/src/c/classes/Loads/Moulin.h

    r19744 r20827  
    4646                /*}}}*/
    4747                /*Object virtual functions definitions:{{{ */
     48                Object* copy();
     49                void  DeepEcho();
    4850                void  Echo();
    49                 void  DeepEcho();
    5051                int   Id();
     52                void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);
    5153                int   ObjectEnum();
    52                 Object* copy();
    53                 void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);
    5454                /*}}}*/
    5555                /*Update virtual functions resolution: {{{*/
    56                 void  InputUpdateFromVector(IssmDouble* vector, int name, int type);
    57                 void  InputUpdateFromMatrixDakota(IssmDouble* matrix ,int nrows, int ncols, int name, int type);
    58                 void  InputUpdateFromVectorDakota(IssmDouble* vector, int name, int type);
    5956                void  InputUpdateFromConstant(IssmDouble constant, int name);
    6057                void  InputUpdateFromConstant(int constant, int name);
    6158                void  InputUpdateFromConstant(bool constant, int name);
    6259                void  InputUpdateFromIoModel(int index, IoModel* iomodel){_error_("not implemented yet");};
     60                void  InputUpdateFromMatrixDakota(IssmDouble* matrix ,int nrows, int ncols, int name, int type);
     61                void  InputUpdateFromVector(IssmDouble* vector, int name, int type);
     62                void  InputUpdateFromVectorDakota(IssmDouble* vector, int name, int type);
    6363                /*}}}*/
    6464                /*Load virtual functions definitions: {{{*/
    6565                void  Configure(Elements* elements,Loads* loads,Nodes* nodes,Vertices* vertices,Materials* materials,Parameters* parameters);
    66                 void  SetCurrentConfiguration(Elements* elements,Loads* loads,Nodes* nodes,Vertices* vertices,Materials* materials,Parameters* parameters);
    67                 void  ResetHooks();
     66                void  CreateJacobianMatrix(Matrix<IssmDouble>* Jff){_error_("Not implemented yet");};
    6867                void  CreateKMatrix(Matrix<IssmDouble>* Kff, Matrix<IssmDouble>* Kfs);
    6968                void  CreatePVector(Vector<IssmDouble>* pf);
    70                 void  CreateJacobianMatrix(Matrix<IssmDouble>* Jff){_error_("Not implemented yet");};
    7169                void  GetNodesSidList(int* sidlist);
    7270                void  GetNodesLidList(int* lidlist);
    7371                int   GetNumberOfNodes(void);
     72                bool  InAnalysis(int analysis_type);
    7473                bool  IsPenalty(void);
    7574                void  PenaltyCreateJacobianMatrix(Matrix<IssmDouble>* Jff,IssmDouble kmax){_error_("Not implemented yet");};
    7675                void  PenaltyCreateKMatrix(Matrix<IssmDouble>* Kff, Matrix<IssmDouble>* kfs, IssmDouble kmax);
    7776                void  PenaltyCreatePVector(Vector<IssmDouble>* pf, IssmDouble kmax);
     77                void  SetCurrentConfiguration(Elements* elements,Loads* loads,Nodes* nodes,Vertices* vertices,Materials* materials,Parameters* parameters);
    7878                void  SetwiseNodeConnectivity(int* d_nz,int* o_nz,Node* node,bool* flags,int* flagsindices,int set1_enum,int set2_enum);
    79                 bool  InAnalysis(int analysis_type);
     79                void  ResetHooks();
    8080                /*}}}*/
    8181
  • issm/trunk-jpl/src/c/classes/Loads/Neumannflux.cpp

    r19749 r20827  
    9999
    100100        return neumannflux;
    101 }
    102 /*}}}*/
    103 void    Neumannflux::Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ /*{{{*/
    104 
    105         _assert_(this);
    106 
    107         /*ok, marshall operations: */
    108         MARSHALLING_ENUM(NeumannfluxEnum);
    109         MARSHALLING(id);
    110         MARSHALLING(analysis_type);
    111 
    112         if(marshall_direction==MARSHALLING_BACKWARD){
    113                 this->hnodes      = new Hook();
    114                 this->hvertices   = new Hook();
    115                 this->helement    = new Hook();
    116         }
    117 
    118         this->hnodes->Marshall(pmarshalled_data,pmarshalled_data_size,marshall_direction);
    119         this->helement->Marshall(pmarshalled_data,pmarshalled_data_size,marshall_direction);
    120         this->hvertices->Marshall(pmarshalled_data,pmarshalled_data_size,marshall_direction);
    121 
    122         /*corresponding fields*/
    123         nodes    =(Node**)this->hnodes->deliverp();
    124         vertices =(Vertex**)this->hvertices->deliverp();
    125         element  =(Element*)this->helement->delivers();
    126 
    127101}
    128102/*}}}*/
     
    154128int     Neumannflux::Id(void){/*{{{*/
    155129        return id;
     130}
     131/*}}}*/
     132void    Neumannflux::Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ /*{{{*/
     133
     134        _assert_(this);
     135
     136        /*ok, marshall operations: */
     137        MARSHALLING_ENUM(NeumannfluxEnum);
     138        MARSHALLING(id);
     139        MARSHALLING(analysis_type);
     140
     141        if(marshall_direction==MARSHALLING_BACKWARD){
     142                this->hnodes      = new Hook();
     143                this->hvertices   = new Hook();
     144                this->helement    = new Hook();
     145        }
     146
     147        this->hnodes->Marshall(pmarshalled_data,pmarshalled_data_size,marshall_direction);
     148        this->helement->Marshall(pmarshalled_data,pmarshalled_data_size,marshall_direction);
     149        this->hvertices->Marshall(pmarshalled_data,pmarshalled_data_size,marshall_direction);
     150
     151        /*corresponding fields*/
     152        nodes    =(Node**)this->hnodes->deliverp();
     153        vertices =(Vertex**)this->hvertices->deliverp();
     154        element  =(Element*)this->helement->delivers();
     155
    156156}
    157157/*}}}*/
  • issm/trunk-jpl/src/c/classes/Loads/Neumannflux.h

    r19749 r20827  
    4343                void    Echo();
    4444                int     Id();
     45                void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);
    4546                int     ObjectEnum();
    46                 void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);
    4747                /*}}}*/
    4848                /*Update virtual functions resolution: {{{*/
     
    6969                void PenaltyCreatePVector(Vector<IssmDouble>* pf, IssmDouble kmax);
    7070                void ResetHooks();
     71                void SetCurrentConfiguration(Elements* elements,Loads* loads,Nodes* nodes,Vertices* vertices,Materials* materials,Parameters* parameters);
    7172                void SetwiseNodeConnectivity(int* d_nz,int* o_nz,Node* node,bool* flags,int* flagsindices,int set1_enum,int set2_enum);
    72                 void SetCurrentConfiguration(Elements* elements,Loads* loads,Nodes* nodes,Vertices* vertices,Materials* materials,Parameters* parameters);
    7373                /*}}}*/
    7474                /*Neumannflux management:{{{*/
  • issm/trunk-jpl/src/c/classes/Loads/Numericalflux.cpp

    r19254 r20827  
    156156
    157157        return numericalflux;
    158 }
    159 /*}}}*/
    160 void    Numericalflux::Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ /*{{{*/
    161 
    162         _assert_(this);
    163 
    164         /*ok, marshall operations: */
    165         MARSHALLING_ENUM(NumericalfluxEnum);
    166         MARSHALLING(id);
    167         MARSHALLING(analysis_type);
    168         MARSHALLING(flux_type);
    169 
    170         if(marshall_direction==MARSHALLING_BACKWARD){
    171                 this->hnodes      = new Hook();
    172                 this->hvertices   = new Hook();
    173                 this->helement    = new Hook();
    174         }
    175 
    176         this->hnodes->Marshall(pmarshalled_data,pmarshalled_data_size,marshall_direction);
    177         this->helement->Marshall(pmarshalled_data,pmarshalled_data_size,marshall_direction);
    178         this->hvertices->Marshall(pmarshalled_data,pmarshalled_data_size,marshall_direction);
    179 
    180         /*corresponding fields*/
    181         nodes    =(Node**)this->hnodes->deliverp();
    182         vertices =(Vertex**)this->hvertices->deliverp();
    183         element  =(Element*)this->helement->delivers();
    184 
    185158}
    186159/*}}}*/
     
    214187int     Numericalflux::Id(void){/*{{{*/
    215188        return id;
     189}
     190/*}}}*/
     191void    Numericalflux::Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ /*{{{*/
     192
     193        _assert_(this);
     194
     195        /*ok, marshall operations: */
     196        MARSHALLING_ENUM(NumericalfluxEnum);
     197        MARSHALLING(id);
     198        MARSHALLING(analysis_type);
     199        MARSHALLING(flux_type);
     200
     201        if(marshall_direction==MARSHALLING_BACKWARD){
     202                this->hnodes      = new Hook();
     203                this->hvertices   = new Hook();
     204                this->helement    = new Hook();
     205        }
     206
     207        this->hnodes->Marshall(pmarshalled_data,pmarshalled_data_size,marshall_direction);
     208        this->helement->Marshall(pmarshalled_data,pmarshalled_data_size,marshall_direction);
     209        this->hvertices->Marshall(pmarshalled_data,pmarshalled_data_size,marshall_direction);
     210
     211        /*corresponding fields*/
     212        nodes    =(Node**)this->hnodes->deliverp();
     213        vertices =(Vertex**)this->hvertices->deliverp();
     214        element  =(Element*)this->helement->delivers();
     215
    216216}
    217217/*}}}*/
  • issm/trunk-jpl/src/c/classes/Loads/Numericalflux.h

    r19254 r20827  
    4444                void    Echo();
    4545                int     Id();
     46                void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);
    4647                int     ObjectEnum();
    47                 void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);
    4848                /*}}}*/
    4949                /*Update virtual functions resolution: {{{*/
     
    7070                void PenaltyCreatePVector(Vector<IssmDouble>* pf, IssmDouble kmax);
    7171                void ResetHooks();
     72                void SetCurrentConfiguration(Elements* elements,Loads* loads,Nodes* nodes,Vertices* vertices,Materials* materials,Parameters* parameters);
    7273                void SetwiseNodeConnectivity(int* d_nz,int* o_nz,Node* node,bool* flags,int* flagsindices,int set1_enum,int set2_enum);
    73                 void SetCurrentConfiguration(Elements* elements,Loads* loads,Nodes* nodes,Vertices* vertices,Materials* materials,Parameters* parameters);
    7474                /*}}}*/
    7575                /*Numericalflux management:{{{*/
  • issm/trunk-jpl/src/c/classes/Loads/Pengrid.cpp

    r19258 r20827  
    109109
    110110        return pengrid;
    111 
    112 }
    113 /*}}}*/
    114 void    Pengrid::Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ /*{{{*/
    115 
    116         _assert_(this);
    117 
    118         /*ok, marshall operations: */
    119         MARSHALLING_ENUM(PengridEnum);
    120         MARSHALLING(id);
    121         MARSHALLING(analysis_type);
    122 
    123         if(marshall_direction==MARSHALLING_BACKWARD){
    124                 this->hnode      = new Hook();
    125                 this->helement   = new Hook();
    126                 this->hmatpar    = new Hook();
    127         }
    128 
    129         this->hnode->Marshall(pmarshalled_data,pmarshalled_data_size,marshall_direction);
    130         this->helement->Marshall(pmarshalled_data,pmarshalled_data_size,marshall_direction);
    131         this->hmatpar->Marshall(pmarshalled_data,pmarshalled_data_size,marshall_direction);
    132 
    133         /*corresponding fields*/
    134         node   =(Node*)this->hnode->delivers();
    135         matpar =(Matpar*)this->hmatpar->delivers();
    136         element=(Element*)this->helement->delivers();
    137 
    138         MARSHALLING(active);
    139         MARSHALLING(zigzag_counter);
    140111
    141112}
     
    160131/*}}}*/
    161132int     Pengrid::Id(void){ return id; }/*{{{*/
     133/*}}}*/
     134void    Pengrid::Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ /*{{{*/
     135
     136        _assert_(this);
     137
     138        /*ok, marshall operations: */
     139        MARSHALLING_ENUM(PengridEnum);
     140        MARSHALLING(id);
     141        MARSHALLING(analysis_type);
     142
     143        if(marshall_direction==MARSHALLING_BACKWARD){
     144                this->hnode      = new Hook();
     145                this->helement   = new Hook();
     146                this->hmatpar    = new Hook();
     147        }
     148
     149        this->hnode->Marshall(pmarshalled_data,pmarshalled_data_size,marshall_direction);
     150        this->helement->Marshall(pmarshalled_data,pmarshalled_data_size,marshall_direction);
     151        this->hmatpar->Marshall(pmarshalled_data,pmarshalled_data_size,marshall_direction);
     152
     153        /*corresponding fields*/
     154        node   =(Node*)this->hnode->delivers();
     155        matpar =(Matpar*)this->hmatpar->delivers();
     156        element=(Element*)this->helement->delivers();
     157
     158        MARSHALLING(active);
     159        MARSHALLING(zigzag_counter);
     160
     161}
    162162/*}}}*/
    163163int     Pengrid::ObjectEnum(void){/*{{{*/
  • issm/trunk-jpl/src/c/classes/Loads/Pengrid.h

    r19254 r20827  
    5050                /*}}}*/
    5151                /*Object virtual functions definitions:{{{ */
     52                Object* copy();
     53                void  DeepEcho();
    5254                void  Echo();
    53                 void  DeepEcho();
    5455                int   Id();
     56                void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);
    5557                int   ObjectEnum();
    56                 Object* copy();
    57                 void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);
    5858                /*}}}*/
    5959                /*Update virtual functions resolution: {{{*/
    60                 void  InputUpdateFromVector(IssmDouble* vector, int name, int type);
    61                 void  InputUpdateFromMatrixDakota(IssmDouble* matrix ,int nrows, int ncols, int name, int type);
    62                 void  InputUpdateFromVectorDakota(IssmDouble* vector, int name, int type);
    6360                void  InputUpdateFromConstant(IssmDouble constant, int name);
    6461                void  InputUpdateFromConstant(int constant, int name);
    6562                void  InputUpdateFromConstant(bool constant, int name);
    6663                void  InputUpdateFromIoModel(int index, IoModel* iomodel){_error_("not implemented yet");};
     64                void  InputUpdateFromMatrixDakota(IssmDouble* matrix ,int nrows, int ncols, int name, int type);
     65                void  InputUpdateFromVector(IssmDouble* vector, int name, int type);
     66                void  InputUpdateFromVectorDakota(IssmDouble* vector, int name, int type);
    6767                /*}}}*/
    6868                /*Load virtual functions definitions: {{{*/
    6969                void  Configure(Elements* elements,Loads* loads,Nodes* nodes,Vertices* vertices,Materials* materials,Parameters* parameters);
    70                 void  SetCurrentConfiguration(Elements* elements,Loads* loads,Nodes* nodes,Vertices* vertices,Materials* materials,Parameters* parameters);
    71                 void  ResetHooks();
     70                void  CreateJacobianMatrix(Matrix<IssmDouble>* Jff){_error_("Not implemented yet");};
    7271                void  CreateKMatrix(Matrix<IssmDouble>* Kff, Matrix<IssmDouble>* Kfs);
    7372                void  CreatePVector(Vector<IssmDouble>* pf);
    74                 void  CreateJacobianMatrix(Matrix<IssmDouble>* Jff){_error_("Not implemented yet");};
     73                void  GetNodesLidList(int* lidlist);
    7574                void  GetNodesSidList(int* sidlist);
    76                 void  GetNodesLidList(int* lidlist);
    7775                int   GetNumberOfNodes(void);
     76                bool  InAnalysis(int analysis_type);
    7877                bool  IsPenalty(void);
    7978                void  PenaltyCreateJacobianMatrix(Matrix<IssmDouble>* Jff,IssmDouble kmax){_error_("Not implemented yet");};
    8079                void  PenaltyCreateKMatrix(Matrix<IssmDouble>* Kff, Matrix<IssmDouble>* kfs, IssmDouble kmax);
    8180                void  PenaltyCreatePVector(Vector<IssmDouble>* pf, IssmDouble kmax);
     81                void  ResetHooks();
     82                void  SetCurrentConfiguration(Elements* elements,Loads* loads,Nodes* nodes,Vertices* vertices,Materials* materials,Parameters* parameters);
    8283                void  SetwiseNodeConnectivity(int* d_nz,int* o_nz,Node* node,bool* flags,int* flagsindices,int set1_enum,int set2_enum);
    83                 bool  InAnalysis(int analysis_type);
    8484                /*}}}*/
    8585                /*Pengrid management {{{*/
     86                void                            ConstraintActivate(int* punstable);
     87                void           ConstraintActivateHydrologyDCInefficient(int* punstable);
     88                void           ConstraintActivateThermal(int* punstable);
     89                ElementVector* CreatePVectorHydrologyDCInefficient(void);
     90                ElementMatrix* PenaltyCreateKMatrixHydrologyDCInefficient(IssmDouble kmax);
     91                ElementMatrix* PenaltyCreateKMatrixMelting(IssmDouble kmax);
    8692                ElementMatrix* PenaltyCreateKMatrixThermal(IssmDouble kmax);
    87                 ElementMatrix* PenaltyCreateKMatrixMelting(IssmDouble kmax);
     93                ElementVector* PenaltyCreatePVectorHydrologyDCInefficient(IssmDouble kmax);
     94                ElementVector* PenaltyCreatePVectorMelting(IssmDouble kmax);
    8895                ElementVector* PenaltyCreatePVectorThermal(IssmDouble kmax);
    89                 ElementVector* PenaltyCreatePVectorMelting(IssmDouble kmax);
    90                 void           ConstraintActivateThermal(int* punstable);
    91                 ElementMatrix* PenaltyCreateKMatrixHydrologyDCInefficient(IssmDouble kmax);
    92                 ElementVector* PenaltyCreatePVectorHydrologyDCInefficient(IssmDouble kmax);
    93                 void           ConstraintActivateHydrologyDCInefficient(int* punstable);
    94                 void  ConstraintActivate(int* punstable);
    95                 ElementVector* CreatePVectorHydrologyDCInefficient(void);
    9696                void  ResetConstraint(void);
    9797                /*}}}*/
  • issm/trunk-jpl/src/c/classes/Loads/Penpair.cpp

    r20660 r20827  
    6666}
    6767/*}}}*/
     68void    Penpair::DeepEcho(void){/*{{{*/
     69
     70        _printf_("Penpair:\n");
     71        _printf_("   id: " << id << "\n");
     72        _printf_("   analysis_type: " << EnumToStringx(analysis_type) << "\n");
     73        hnodes->DeepEcho();
     74
     75        return;
     76}               
     77/*}}}*/
     78void    Penpair::Echo(void){/*{{{*/
     79
     80        _printf_("Penpair:\n");
     81        _printf_("   id: " << id << "\n");
     82        _printf_("   analysis_type: " << EnumToStringx(analysis_type) << "\n");
     83        hnodes->Echo();
     84
     85        return;
     86}
     87/*}}}*/
     88int     Penpair::Id(void){ return id; }/*{{{*/
     89/*}}}*/
    6890void    Penpair::Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ /*{{{*/
    6991
     
    85107}
    86108/*}}}*/
    87 void    Penpair::DeepEcho(void){/*{{{*/
    88 
    89         _printf_("Penpair:\n");
    90         _printf_("   id: " << id << "\n");
    91         _printf_("   analysis_type: " << EnumToStringx(analysis_type) << "\n");
    92         hnodes->DeepEcho();
    93 
    94         return;
    95 }               
    96 /*}}}*/
    97 void    Penpair::Echo(void){/*{{{*/
    98 
    99         _printf_("Penpair:\n");
    100         _printf_("   id: " << id << "\n");
    101         _printf_("   analysis_type: " << EnumToStringx(analysis_type) << "\n");
    102         hnodes->Echo();
    103 
    104         return;
    105 }
    106 /*}}}*/
    107 int     Penpair::Id(void){ return id; }/*{{{*/
    108 /*}}}*/
    109109int     Penpair::ObjectEnum(void){/*{{{*/
    110110
     
    146146}
    147147/*}}}*/
     148void  Penpair::GetNodesLidList(int* lidlist){/*{{{*/
     149
     150        _assert_(lidlist);
     151        _assert_(nodes);
     152
     153        for(int i=0;i<NUMVERTICES;i++) lidlist[i]=nodes[i]->Lid();
     154}
     155/*}}}*/
    148156void  Penpair::GetNodesSidList(int* sidlist){/*{{{*/
    149157
     
    152160
    153161        for(int i=0;i<NUMVERTICES;i++) sidlist[i]=nodes[i]->Sid();
    154 }
    155 /*}}}*/
    156 void  Penpair::GetNodesLidList(int* lidlist){/*{{{*/
    157 
    158         _assert_(lidlist);
    159         _assert_(nodes);
    160 
    161         for(int i=0;i<NUMVERTICES;i++) lidlist[i]=nodes[i]->Lid();
    162162}
    163163/*}}}*/
  • issm/trunk-jpl/src/c/classes/Loads/Penpair.h

    r19254 r20827  
    3535                void     Echo();
    3636                int      Id();
     37                void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);
    3738                int      ObjectEnum();
    38                 void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);
    3939                /*}}}*/
    4040                /*Update virtual functions resolution: {{{*/
  • issm/trunk-jpl/src/c/classes/Loads/Riftfront.cpp

    r20690 r20827  
    150150
    151151        return riftfront;
    152 
    153 }
    154 /*}}}*/
    155 void    Riftfront::Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ /*{{{*/
    156 
    157         _assert_(this);
    158 
    159         /*ok, marshall operations: */
    160         MARSHALLING_ENUM(RiftfrontEnum);
    161         MARSHALLING(id);
    162         MARSHALLING(analysis_type);
    163         MARSHALLING(type);
    164         MARSHALLING(fill);
    165         MARSHALLING(friction);
    166         MARSHALLING(fractionincrement);
    167         MARSHALLING(shelf);
    168 
    169         if(marshall_direction==MARSHALLING_BACKWARD){
    170                 this->hnodes      = new Hook();
    171                 this->hmatpar     = new Hook();
    172                 this->helements   = new Hook();
    173         }
    174 
    175         this->hnodes->Marshall(pmarshalled_data,pmarshalled_data_size,marshall_direction);
    176         this->hmatpar->Marshall(pmarshalled_data,pmarshalled_data_size,marshall_direction);
    177         this->helements->Marshall(pmarshalled_data,pmarshalled_data_size,marshall_direction);
    178 
    179         /*corresponding fields*/
    180         nodes     =(Node**)this->hnodes->deliverp();
    181         matpar    =(Matpar*)this->hmatpar->delivers();
    182         elements  =(Element**)this->helements->deliverp();
    183 
    184         MARSHALLING(penalty_lock);
    185         MARSHALLING(active);
    186         MARSHALLING(frozen);
    187         MARSHALLING(state);
    188         MARSHALLING(counter);
    189         MARSHALLING(prestable);
    190         MARSHALLING(material_converged);
    191         MARSHALLING(normal[0]);
    192         MARSHALLING(normal[1]);
    193         MARSHALLING(length);
    194         MARSHALLING(fraction);
    195152
    196153}
     
    235192/*}}}*/
    236193int     Riftfront::Id(void){ return id; }/*{{{*/
     194/*}}}*/
     195void    Riftfront::Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ /*{{{*/
     196
     197        _assert_(this);
     198
     199        /*ok, marshall operations: */
     200        MARSHALLING_ENUM(RiftfrontEnum);
     201        MARSHALLING(id);
     202        MARSHALLING(analysis_type);
     203        MARSHALLING(type);
     204        MARSHALLING(fill);
     205        MARSHALLING(friction);
     206        MARSHALLING(fractionincrement);
     207        MARSHALLING(shelf);
     208
     209        if(marshall_direction==MARSHALLING_BACKWARD){
     210                this->hnodes      = new Hook();
     211                this->hmatpar     = new Hook();
     212                this->helements   = new Hook();
     213        }
     214
     215        this->hnodes->Marshall(pmarshalled_data,pmarshalled_data_size,marshall_direction);
     216        this->hmatpar->Marshall(pmarshalled_data,pmarshalled_data_size,marshall_direction);
     217        this->helements->Marshall(pmarshalled_data,pmarshalled_data_size,marshall_direction);
     218
     219        /*corresponding fields*/
     220        nodes     =(Node**)this->hnodes->deliverp();
     221        matpar    =(Matpar*)this->hmatpar->delivers();
     222        elements  =(Element**)this->helements->deliverp();
     223
     224        MARSHALLING(penalty_lock);
     225        MARSHALLING(active);
     226        MARSHALLING(frozen);
     227        MARSHALLING(state);
     228        MARSHALLING(counter);
     229        MARSHALLING(prestable);
     230        MARSHALLING(material_converged);
     231        MARSHALLING(normal[0]);
     232        MARSHALLING(normal[1]);
     233        MARSHALLING(length);
     234        MARSHALLING(fraction);
     235
     236}
    237237/*}}}*/
    238238int     Riftfront::ObjectEnum(void){/*{{{*/
  • issm/trunk-jpl/src/c/classes/Loads/Riftfront.h

    r19254 r20827  
    6161                void     Echo();
    6262                int      Id();
     63                void            Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);
    6364                int      ObjectEnum();
    64                 void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);
    6565                /*}}}*/
    6666                /*Update virtual functions resolution: {{{*/
  • issm/trunk-jpl/src/c/classes/Materials/Material.h

    r20608 r20827  
    2525
    2626                /*Numerics*/
     27                virtual void       Configure(Elements* elements)=0;
    2728                virtual Material*  copy2(Element* element)=0;
    28                 virtual void       Configure(Elements* elements)=0;
    2929                virtual IssmDouble GetA()=0;
    3030                virtual IssmDouble GetAbar()=0;
  • issm/trunk-jpl/src/c/classes/Materials/Matestar.cpp

    r20687 r20827  
    106106int       Matestar::Id(void){ return mid; }/*{{{*/
    107107/*}}}*/
    108 int       Matestar::ObjectEnum(void){/*{{{*/
    109 
    110         return MatestarEnum;
    111 
    112 }
    113 /*}}}*/
    114108void      Matestar::Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ /*{{{*/
    115109
     
    123117}
    124118/*}}}*/
     119int       Matestar::ObjectEnum(void){/*{{{*/
     120
     121        return MatestarEnum;
     122
     123}
     124/*}}}*/
    125125
    126126/*Matestar management*/
     
    133133}
    134134/*}}}*/
    135 void  Matestar::SetCurrentConfiguration(Elements* elementsin,Loads* loadsin,Nodes* nodesin,Vertices* verticesin,Materials* materialsin,Parameters* parametersin){/*{{{*/
    136 
    137 }
    138 /*}}}*/
    139135IssmDouble Matestar::GetA(){/*{{{*/
    140136        _error_("not implemented yet");
     
    154150}
    155151/*}}}*/
     152IssmDouble Matestar::GetD(){/*{{{*/
     153        _error_("not implemented yet");
     154}
     155/*}}}*/
     156IssmDouble Matestar::GetDbar(){/*{{{*/
     157
     158        _error_("not implemented yet");
     159}
     160/*}}}*/
    156161IssmDouble Matestar::GetN(){/*{{{*/
    157         _error_("not implemented yet");
    158 }
    159 /*}}}*/
    160 IssmDouble Matestar::GetD(){/*{{{*/
    161         _error_("not implemented yet");
    162 }
    163 /*}}}*/
    164 IssmDouble Matestar::GetDbar(){/*{{{*/
    165 
    166         _error_("not implemented yet");
    167 }
    168 /*}}}*/
    169 bool Matestar::IsDamage(){/*{{{*/
    170 
    171162        _error_("not implemented yet");
    172163}
     
    221212}
    222213/*}}}*/
     214void  Matestar::GetViscosityBar(IssmDouble* pviscosity,IssmDouble eps_eff){/*{{{*/
     215        _error_("not implemented yet");
     216}
     217/*}}}*/
     218void  Matestar::GetViscosityComplement(IssmDouble* pviscosity_complement, IssmDouble* epsilon){/*{{{*/
     219        _error_("not implemented yet");
     220}
     221/*}}}*/
     222void  Matestar::GetViscosityDComplement(IssmDouble* pviscosity_complement, IssmDouble* epsilon){/*{{{*/
     223        _error_("not implemented yet");
     224}
     225/*}}}*/
     226void  Matestar::GetViscosityDerivativeEpsSquare(IssmDouble* pmu_prime, IssmDouble* epsilon){/*{{{*/
     227        _error_("not implemented yet");
     228}
     229/*}}}*/
     230IssmDouble Matestar::GetViscosityGeneral(IssmDouble ko,IssmDouble Ec, IssmDouble Es,IssmDouble vx,IssmDouble vy,IssmDouble vz,IssmDouble* dvx,IssmDouble* dvy,IssmDouble* dvz){/*{{{*/
     231
     232        /*Intermediaries*/
     233        IssmDouble viscosity;
     234        IssmDouble E,lambdas;
     235        IssmDouble epso,epsprime_norm;
     236        IssmDouble vmag,dvmag[3];
     237
     238        /*Calculate velocity magnitude and its derivative*/
     239        vmag = sqrt(vx*vx+vy*vy+vz*vz);
     240        if(vmag<1e-12){
     241                dvmag[0]=0;
     242                dvmag[1]=0;
     243                dvmag[2]=0;
     244        }
     245        else{
     246                dvmag[0]=1./(2*sqrt(vmag))*(2*vx*dvx[0]+2*vy*dvy[0]+2*vz*dvz[0]);
     247                dvmag[1]=1./(2*sqrt(vmag))*(2*vx*dvx[1]+2*vy*dvy[1]+2*vz*dvz[1]);
     248                dvmag[2]=1./(2*sqrt(vmag))*(2*vx*dvx[2]+2*vy*dvy[2]+2*vz*dvz[2]);
     249        }
     250
     251        EstarStrainrateQuantities(&epso,&epsprime_norm,vx,vy,vz,vmag,dvx,dvy,dvz,&dvmag[0]);
     252        lambdas=EstarLambdaS(epso,epsprime_norm);
     253
     254        /*Get total enhancement factor E(lambdas)*/
     255        E = Ec + (Es-Ec)*lambdas*lambdas;
     256
     257        /*Compute viscosity*/
     258        _assert_(E>0.);
     259        _assert_(ko>0.);
     260        _assert_(epso>0.);
     261        viscosity = 1./(2*pow(ko*E*epso*epso,1./3.));
     262
     263        /*Assign output pointer*/
     264        return viscosity;
     265}
     266/*}}}*/
    223267void  Matestar::GetViscosity_B(IssmDouble* pdmudB,IssmDouble eps_eff){/*{{{*/
    224268        _error_("not implemented yet");
     
    229273}
    230274/*}}}*/
    231 void  Matestar::GetViscosityBar(IssmDouble* pviscosity,IssmDouble eps_eff){/*{{{*/
    232         _error_("not implemented yet");
    233 }
    234 /*}}}*/
    235 void  Matestar::GetViscosityComplement(IssmDouble* pviscosity_complement, IssmDouble* epsilon){/*{{{*/
    236         _error_("not implemented yet");
    237 }
    238 /*}}}*/
    239 void  Matestar::GetViscosityDComplement(IssmDouble* pviscosity_complement, IssmDouble* epsilon){/*{{{*/
    240         _error_("not implemented yet");
    241 }
    242 /*}}}*/
    243 void  Matestar::GetViscosityDerivativeEpsSquare(IssmDouble* pmu_prime, IssmDouble* epsilon){/*{{{*/
    244         _error_("not implemented yet");
    245 }
    246 /*}}}*/
    247275void  Matestar::GetViscosity2dDerivativeEpsSquare(IssmDouble* pmu_prime, IssmDouble* epsilon){/*{{{*/
    248276        _error_("not implemented yet");
    249277}
    250278/*}}}*/
    251 void  Matestar::InputUpdateFromVector(IssmDouble* vector, int name, int type){/*{{{*/
    252 
    253 }
    254 /*}}}*/
    255 void  Matestar::InputUpdateFromVectorDakota(IssmDouble* vector, int name, int type){/*{{{*/
    256 
     279void  Matestar::InputUpdateFromConstant(IssmDouble constant, int name){/*{{{*/
     280        /*Nothing updated yet*/
     281}
     282/*}}}*/
     283void  Matestar::InputUpdateFromConstant(int constant, int name){/*{{{*/
     284        /*Nothing updated yet*/
     285}
     286/*}}}*/
     287void  Matestar::InputUpdateFromConstant(bool constant, int name){/*{{{*/
     288        /*Nothing updated yet*/
    257289}
    258290/*}}}*/
     
    261293}
    262294/*}}}*/
    263 void  Matestar::InputUpdateFromConstant(IssmDouble constant, int name){/*{{{*/
    264         /*Nothing updated yet*/
    265 }
    266 /*}}}*/
    267 void  Matestar::InputUpdateFromConstant(int constant, int name){/*{{{*/
    268         /*Nothing updated yet*/
    269 }
    270 /*}}}*/
    271 void  Matestar::InputUpdateFromConstant(bool constant, int name){/*{{{*/
    272         /*Nothing updated yet*/
     295void  Matestar::InputUpdateFromVector(IssmDouble* vector, int name, int type){/*{{{*/
     296
     297}
     298/*}}}*/
     299void  Matestar::InputUpdateFromVectorDakota(IssmDouble* vector, int name, int type){/*{{{*/
     300
     301}
     302/*}}}*/
     303bool Matestar::IsDamage(){/*{{{*/
     304
     305        _error_("not implemented yet");
     306}
     307/*}}}*/
     308void  Matestar::ResetHooks(){/*{{{*/
     309
     310        this->element=NULL;
     311
     312        /*Get Element type*/
     313        this->helement->reset();
     314
     315}
     316/*}}}*/
     317void  Matestar::SetCurrentConfiguration(Elements* elementsin,Loads* loadsin,Nodes* nodesin,Vertices* verticesin,Materials* materialsin,Parameters* parametersin){/*{{{*/
     318
    273319}
    274320/*}}}*/
     
    394440        _error_("not implemented yet");
    395441}/*}}}*/
    396 void  Matestar::ResetHooks(){/*{{{*/
    397 
    398         this->element=NULL;
    399 
    400         /*Get Element type*/
    401         this->helement->reset();
    402 
    403 }
    404 /*}}}*/
    405 IssmDouble Matestar::GetViscosityGeneral(IssmDouble ko,IssmDouble Ec, IssmDouble Es,IssmDouble vx,IssmDouble vy,IssmDouble vz,IssmDouble* dvx,IssmDouble* dvy,IssmDouble* dvz){/*{{{*/
    406 
    407         /*Intermediaries*/
    408         IssmDouble viscosity;
    409         IssmDouble E,lambdas;
    410         IssmDouble epso,epsprime_norm;
    411         IssmDouble vmag,dvmag[3];
    412 
    413         /*Calculate velocity magnitude and its derivative*/
    414         vmag = sqrt(vx*vx+vy*vy+vz*vz);
    415         if(vmag<1e-12){
    416                 dvmag[0]=0;
    417                 dvmag[1]=0;
    418                 dvmag[2]=0;
    419         }
    420         else{
    421                 dvmag[0]=1./(2*sqrt(vmag))*(2*vx*dvx[0]+2*vy*dvy[0]+2*vz*dvz[0]);
    422                 dvmag[1]=1./(2*sqrt(vmag))*(2*vx*dvx[1]+2*vy*dvy[1]+2*vz*dvz[1]);
    423                 dvmag[2]=1./(2*sqrt(vmag))*(2*vx*dvx[2]+2*vy*dvy[2]+2*vz*dvz[2]);
    424         }
    425 
    426         EstarStrainrateQuantities(&epso,&epsprime_norm,vx,vy,vz,vmag,dvx,dvy,dvz,&dvmag[0]);
    427         lambdas=EstarLambdaS(epso,epsprime_norm);
    428 
    429         /*Get total enhancement factor E(lambdas)*/
    430         E = Ec + (Es-Ec)*lambdas*lambdas;
    431 
    432         /*Compute viscosity*/
    433         _assert_(E>0.);
    434         _assert_(ko>0.);
    435         _assert_(epso>0.);
    436         viscosity = 1./(2*pow(ko*E*epso*epso,1./3.));
    437 
    438         /*Assign output pointer*/
    439         return viscosity;
    440 }
    441 /*}}}*/
  • issm/trunk-jpl/src/c/classes/Materials/Matestar.h

    r20687 r20827  
    3636                /*}}}*/
    3737                /*Object virtual functions definitions:{{{ */
     38                Object* copy();
     39                void  DeepEcho();
    3840                void  Echo();
    39                 void  DeepEcho();
    4041                int   Id();
     42                void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);
    4143                int   ObjectEnum();
    42                 Object* copy();
    43                 void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);
    4444                /*}}}*/
    4545                /*Update virtual funictions definitions: {{{*/
    46                 void  InputUpdateFromVector(IssmDouble* vector, int name, int type);
    47                 void  InputUpdateFromMatrixDakota(IssmDouble* matrix, int nrow, int ncols, int name, int type);
    48                 void  InputUpdateFromVectorDakota(IssmDouble* vector, int name, int type);
    4946                void  InputUpdateFromConstant(IssmDouble constant, int name);
    5047                void  InputUpdateFromConstant(int constant, int name);
    5148                void  InputUpdateFromConstant(bool constant, int name);
    5249                void  InputUpdateFromIoModel(int index, IoModel* iomodel){_error_("not implemented");};
     50                void  InputUpdateFromMatrixDakota(IssmDouble* matrix, int nrow, int ncols, int name, int type);
     51                void  InputUpdateFromVector(IssmDouble* vector, int name, int type);
     52                void  InputUpdateFromVectorDakota(IssmDouble* vector, int name, int type);
    5353                /*}}}*/
    5454                /*Material virtual functions resolution: {{{*/
    5555                void   Configure(Elements* elements);
    5656                Material*  copy2(Element* element);
    57                 void       SetCurrentConfiguration(Elements* elements,Loads* loads,Nodes* nodes,Vertices* vertices,Materials* materials,Parameters* parameters);
    5857                void       GetViscosity(IssmDouble* pviscosity, IssmDouble eps_eff);
    59                 void       GetViscosity_B(IssmDouble* pviscosity, IssmDouble eps_eff);
    60                 void       GetViscosity_D(IssmDouble* pviscosity, IssmDouble eps_eff);
    6158                void       GetViscosityBar(IssmDouble* pviscosity, IssmDouble eps_eff);
    6259                void       GetViscosityComplement(IssmDouble* pviscosity_complement, IssmDouble* pepsilon);
    6360                void       GetViscosityDComplement(IssmDouble*, IssmDouble*);
    6461                void       GetViscosityDerivativeEpsSquare(IssmDouble* pmu_prime, IssmDouble* pepsilon);
     62                void       GetViscosity_B(IssmDouble* pviscosity, IssmDouble eps_eff);
     63                void       GetViscosity_D(IssmDouble* pviscosity, IssmDouble eps_eff);
    6564                void       GetViscosity2dDerivativeEpsSquare(IssmDouble* pmu_prime, IssmDouble* pepsilon);
    6665                IssmDouble GetA();
     
    7372                bool       IsDamage();
    7473                void       ResetHooks();
     74                void       SetCurrentConfiguration(Elements* elements,Loads* loads,Nodes* nodes,Vertices* vertices,Materials* materials,Parameters* parameters);
    7575
    7676                void       ViscosityFS(IssmDouble* pviscosity,int dim,IssmDouble* xyz_list,Gauss* gauss,Input* vx_input,Input* vy_input,Input* vz_input);
  • issm/trunk-jpl/src/c/classes/Materials/Matice.cpp

    r20690 r20827  
    117117int       Matice::Id(void){ return mid; }/*{{{*/
    118118/*}}}*/
    119 int       Matice::ObjectEnum(void){/*{{{*/
    120 
    121         return MaticeEnum;
    122 
    123 }
    124 /*}}}*/
    125119void      Matice::Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ /*{{{*/
    126120
     
    135129}
    136130/*}}}*/
     131int       Matice::ObjectEnum(void){/*{{{*/
     132
     133        return MaticeEnum;
     134
     135}
     136/*}}}*/
    137137
    138138/*Matice management*/
     
    145145}
    146146/*}}}*/
    147 void  Matice::SetCurrentConfiguration(Elements* elementsin,Loads* loadsin,Nodes* nodesin,Vertices* verticesin,Materials* materialsin,Parameters* parametersin){/*{{{*/
    148 
    149 }
    150 /*}}}*/
    151147IssmDouble Matice::GetA(){/*{{{*/
    152148        /*
     
    191187        element->inputs->GetInputAverage(&Bbar,MaterialsRheologyBbarEnum);
    192188        return Bbar;
    193 }
    194 /*}}}*/
    195 IssmDouble Matice::GetN(){/*{{{*/
    196 
    197         /*Output*/
    198         IssmDouble n;
    199 
    200         element->inputs->GetInputAverage(&n,MaterialsRheologyNEnum);
    201         return n;
    202189}
    203190/*}}}*/
     
    218205        if(this->isdamaged)element->inputs->GetInputAverage(&Dbar,DamageDbarEnum);
    219206        return Dbar;
     207}
     208/*}}}*/
     209IssmDouble Matice::GetN(){/*{{{*/
     210
     211        /*Output*/
     212        IssmDouble n;
     213
     214        element->inputs->GetInputAverage(&n,MaterialsRheologyNEnum);
     215        return n;
    220216}
    221217/*}}}*/
     
    275271        /*Return: */
    276272        *pviscosity=viscosity;
    277 }
    278 /*}}}*/
    279 void  Matice::GetViscosity_B(IssmDouble* pdmudB,IssmDouble eps_eff){/*{{{*/
    280 
    281         /*output: */
    282         IssmDouble dmudB;
    283 
    284         /*Intermediary: */
    285         IssmDouble D=0.,n;
    286 
    287         /*Get B and n*/
    288         n=GetN(); _assert_(n>0.);
    289         if(this->isdamaged){
    290                 D=GetD();
    291                 _assert_(D>=0. && D<1.);
    292         }
    293 
    294         if(n==1.){
    295                 /*Linear Viscous behavior (Newtonian fluid) dmudB=B/2: */
    296                 dmudB=(1.-D)/2.;
    297         }
    298         else{
    299                 if(eps_eff==0.) dmudB = 0.;
    300                 else            dmudB = (1.-D)/(2.*pow(eps_eff,(n-1.)/n));
    301         }
    302 
    303         /*Return: */
    304         *pdmudB=dmudB;
    305 }
    306 /*}}}*/
    307 void  Matice::GetViscosity_D(IssmDouble* pdmudD,IssmDouble eps_eff){/*{{{*/
    308 
    309         /*output: */
    310         IssmDouble dmudD;
    311 
    312         /*Intermediary: */
    313         IssmDouble n,B;
    314 
    315         /*Get B and n*/
    316         n=GetN(); _assert_(n>0.);
    317         B=GetBbar();
    318         _assert_(this->isdamaged);
    319 
    320         if(n==1.){
    321                 /*Linear Viscous behavior (Newtonian fluid) dmudB=B/2: */
    322                 dmudD=-B/2.;
    323         }
    324         else{
    325                 if(eps_eff==0.) dmudD = 0.;
    326                 else            dmudD = -B/(2.*pow(eps_eff,(n-1.)/n));
    327         }
    328 
    329         /*Return: */
    330         *pdmudD=dmudD;
    331273}
    332274/*}}}*/
     
    527469}
    528470/*}}}*/
     471void  Matice::GetViscosity_B(IssmDouble* pdmudB,IssmDouble eps_eff){/*{{{*/
     472
     473        /*output: */
     474        IssmDouble dmudB;
     475
     476        /*Intermediary: */
     477        IssmDouble D=0.,n;
     478
     479        /*Get B and n*/
     480        n=GetN(); _assert_(n>0.);
     481        if(this->isdamaged){
     482                D=GetD();
     483                _assert_(D>=0. && D<1.);
     484        }
     485
     486        if(n==1.){
     487                /*Linear Viscous behavior (Newtonian fluid) dmudB=B/2: */
     488                dmudB=(1.-D)/2.;
     489        }
     490        else{
     491                if(eps_eff==0.) dmudB = 0.;
     492                else            dmudB = (1.-D)/(2.*pow(eps_eff,(n-1.)/n));
     493        }
     494
     495        /*Return: */
     496        *pdmudB=dmudB;
     497}
     498/*}}}*/
     499void  Matice::GetViscosity_D(IssmDouble* pdmudD,IssmDouble eps_eff){/*{{{*/
     500
     501        /*output: */
     502        IssmDouble dmudD;
     503
     504        /*Intermediary: */
     505        IssmDouble n,B;
     506
     507        /*Get B and n*/
     508        n=GetN(); _assert_(n>0.);
     509        B=GetBbar();
     510        _assert_(this->isdamaged);
     511
     512        if(n==1.){
     513                /*Linear Viscous behavior (Newtonian fluid) dmudB=B/2: */
     514                dmudD=-B/2.;
     515        }
     516        else{
     517                if(eps_eff==0.) dmudD = 0.;
     518                else            dmudD = -B/(2.*pow(eps_eff,(n-1.)/n));
     519        }
     520
     521        /*Return: */
     522        *pdmudD=dmudD;
     523}
     524/*}}}*/
    529525void  Matice::GetViscosity2dDerivativeEpsSquare(IssmDouble* pmu_prime, IssmDouble* epsilon){/*{{{*/
    530526
     
    555551}
    556552/*}}}*/
    557 void  Matice::InputUpdateFromVector(IssmDouble* vector, int name, int type){/*{{{*/
    558 
    559 }
    560 /*}}}*/
    561 void  Matice::InputUpdateFromVectorDakota(IssmDouble* vector, int name, int type){/*{{{*/
    562 
     553void  Matice::InputUpdateFromConstant(IssmDouble constant, int name){/*{{{*/
     554        /*Nothing updated yet*/
     555}
     556/*}}}*/
     557void  Matice::InputUpdateFromConstant(int constant, int name){/*{{{*/
     558        /*Nothing updated yet*/
     559}
     560/*}}}*/
     561void  Matice::InputUpdateFromConstant(bool constant, int name){/*{{{*/
     562        /*Nothing updated yet*/
    563563}
    564564/*}}}*/
     
    567567}
    568568/*}}}*/
    569 void  Matice::InputUpdateFromConstant(IssmDouble constant, int name){/*{{{*/
    570         /*Nothing updated yet*/
    571 }
    572 /*}}}*/
    573 void  Matice::InputUpdateFromConstant(int constant, int name){/*{{{*/
    574         /*Nothing updated yet*/
    575 }
    576 /*}}}*/
    577 void  Matice::InputUpdateFromConstant(bool constant, int name){/*{{{*/
    578         /*Nothing updated yet*/
     569void  Matice::InputUpdateFromVector(IssmDouble* vector, int name, int type){/*{{{*/
     570
     571}
     572/*}}}*/
     573void  Matice::InputUpdateFromVectorDakota(IssmDouble* vector, int name, int type){/*{{{*/
     574
     575}
     576/*}}}*/
     577void  Matice::ResetHooks(){/*{{{*/
     578
     579        this->element=NULL;
     580
     581        /*Get Element type*/
     582        this->helement->reset();
     583
     584}
     585/*}}}*/
     586void  Matice::SetCurrentConfiguration(Elements* elementsin,Loads* loadsin,Nodes* nodesin,Vertices* verticesin,Materials* materialsin,Parameters* parametersin){/*{{{*/
     587
    579588}
    580589/*}}}*/
     
    737746        this->GetViscosity2dDerivativeEpsSquare(pmu_prime,epsilon);
    738747}/*}}}*/
    739 void  Matice::ResetHooks(){/*{{{*/
    740 
    741         this->element=NULL;
    742 
    743         /*Get Element type*/
    744         this->helement->reset();
    745 
    746 }
    747 /*}}}*/
  • issm/trunk-jpl/src/c/classes/Materials/Matice.h

    r20608 r20827  
    3737                /*}}}*/
    3838                /*Object virtual functions definitions:{{{ */
     39                Object* copy();
     40                void  DeepEcho();
    3941                void  Echo();
    40                 void  DeepEcho();
    4142                int   Id();
     43                void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);
    4244                int   ObjectEnum();
    43                 Object* copy();
    44                 void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);
    4545                /*}}}*/
    4646                /*Update virtual funictions definitions: {{{*/
    47                 void  InputUpdateFromVector(IssmDouble* vector, int name, int type);
    48                 void  InputUpdateFromMatrixDakota(IssmDouble* matrix, int nrow, int ncols, int name, int type);
    49                 void  InputUpdateFromVectorDakota(IssmDouble* vector, int name, int type);
    5047                void  InputUpdateFromConstant(IssmDouble constant, int name);
    5148                void  InputUpdateFromConstant(int constant, int name);
    5249                void  InputUpdateFromConstant(bool constant, int name);
    5350                void  InputUpdateFromIoModel(int index, IoModel* iomodel){_error_("not implemented");};
     51                void  InputUpdateFromMatrixDakota(IssmDouble* matrix, int nrow, int ncols, int name, int type);
     52                void  InputUpdateFromVector(IssmDouble* vector, int name, int type);
     53                void  InputUpdateFromVectorDakota(IssmDouble* vector, int name, int type);
    5454                /*}}}*/
    5555                /*Material virtual functions resolution: {{{*/
    5656                void   Configure(Elements* elements);
    5757                Material*  copy2(Element* element);
    58                 void       SetCurrentConfiguration(Elements* elements,Loads* loads,Nodes* nodes,Vertices* vertices,Materials* materials,Parameters* parameters);
    5958                void       GetViscosity(IssmDouble* pviscosity, IssmDouble eps_eff);
    60                 void       GetViscosity_B(IssmDouble* pviscosity, IssmDouble eps_eff);
    61                 void       GetViscosity_D(IssmDouble* pviscosity, IssmDouble eps_eff);
    6259                void       GetViscosityBar(IssmDouble* pviscosity, IssmDouble eps_eff);
    6360                void       GetViscosityComplement(IssmDouble* pviscosity_complement, IssmDouble* pepsilon);
    6461                void       GetViscosityDComplement(IssmDouble*, IssmDouble*);
    6562                void       GetViscosityDerivativeEpsSquare(IssmDouble* pmu_prime, IssmDouble* pepsilon);
     63                void       GetViscosity_B(IssmDouble* pviscosity, IssmDouble eps_eff);
     64                void       GetViscosity_D(IssmDouble* pviscosity, IssmDouble eps_eff);
    6665                void       GetViscosity2dDerivativeEpsSquare(IssmDouble* pmu_prime, IssmDouble* pepsilon);
    6766                IssmDouble GetA();
     
    7473                bool       IsDamage();
    7574                void       ResetHooks();
     75                void       SetCurrentConfiguration(Elements* elements,Loads* loads,Nodes* nodes,Vertices* vertices,Materials* materials,Parameters* parameters);
    7676
    7777                void       ViscosityFS(IssmDouble* pviscosity,int dim,IssmDouble* xyz_list,Gauss* gauss,Input* vx_input,Input* vy_input,Input* vz_input);
  • issm/trunk-jpl/src/c/classes/Materials/Matpar.cpp

    r20690 r20827  
    179179
    180180/*Object virtual functions definitions:*/
     181Object* Matpar::copy() {/*{{{*/
     182
     183        /*Output*/
     184        Matpar* matpar;
     185
     186        /*Initialize output*/
     187        matpar=new Matpar(*this);
     188
     189        /*copy fields: */
     190        matpar->mid=this->mid;
     191        matpar->rho_ice=this->rho_ice;
     192        matpar->rho_water=this->rho_water;
     193        matpar->rho_freshwater=this->rho_freshwater;
     194        matpar->mu_water=this->mu_water;
     195        matpar->heatcapacity=this->heatcapacity;
     196        matpar->thermalconductivity=this->thermalconductivity;
     197        matpar->temperateiceconductivity=this->temperateiceconductivity;
     198        matpar->latentheat=this->latentheat;
     199        matpar->beta=this->beta;
     200        matpar->meltingpoint=this->meltingpoint;
     201        matpar->referencetemperature=this->referencetemperature;
     202        matpar->mixed_layer_capacity=this->mixed_layer_capacity;
     203        matpar->thermal_exchange_velocity=this->thermal_exchange_velocity;
     204        matpar->g=this->g;
     205        matpar->desfac=this->desfac;
     206        matpar->rlaps=this->rlaps;
     207        matpar->rlapslgm=this->rlapslgm;
     208        matpar->dpermil=this->dpermil;
     209
     210        matpar->sediment_compressibility=this->sediment_compressibility;
     211        matpar->sediment_porosity=this->sediment_porosity;
     212        matpar->sediment_thickness=this->sediment_thickness;
     213        matpar->water_compressibility=this->water_compressibility;
     214
     215        matpar->epl_compressibility=this->epl_compressibility;
     216        matpar->epl_porosity=this->epl_porosity;
     217        matpar->epl_init_thickness=this->epl_init_thickness;
     218        matpar->epl_colapse_thickness=this->epl_colapse_thickness;
     219        matpar->epl_max_thickness=this->epl_max_thickness;
     220        matpar->epl_conductivity=this->epl_conductivity;
     221
     222        matpar->lithosphere_shear_modulus=this->lithosphere_shear_modulus;
     223        matpar->lithosphere_density=this->lithosphere_density;
     224        matpar->mantle_shear_modulus=this->mantle_shear_modulus;
     225        matpar->mantle_density=this->mantle_density;
     226       
     227        matpar->earth_density=this->earth_density;
     228
     229        return matpar;
     230}
     231/*}}}*/
     232void Matpar::DeepEcho(void){/*{{{*/
     233
     234        this->Echo();
     235}               
     236/*}}}*/
    181237void Matpar::Echo(void){/*{{{*/
    182238
     
    204260}
    205261/*}}}*/
    206 void Matpar::DeepEcho(void){/*{{{*/
    207 
    208         this->Echo();
    209 }               
    210 /*}}}*/
    211262int  Matpar::Id(void){ return mid; }/*{{{*/
    212 /*}}}*/
    213 int  Matpar::ObjectEnum(void){/*{{{*/
    214 
    215         return MatparEnum;
    216 
    217 }
    218 /*}}}*/
    219 Object* Matpar::copy() {/*{{{*/
    220 
    221         /*Output*/
    222         Matpar* matpar;
    223 
    224         /*Initialize output*/
    225         matpar=new Matpar(*this);
    226 
    227         /*copy fields: */
    228         matpar->mid=this->mid;
    229         matpar->rho_ice=this->rho_ice;
    230         matpar->rho_water=this->rho_water;
    231         matpar->rho_freshwater=this->rho_freshwater;
    232         matpar->mu_water=this->mu_water;
    233         matpar->heatcapacity=this->heatcapacity;
    234         matpar->thermalconductivity=this->thermalconductivity;
    235         matpar->temperateiceconductivity=this->temperateiceconductivity;
    236         matpar->latentheat=this->latentheat;
    237         matpar->beta=this->beta;
    238         matpar->meltingpoint=this->meltingpoint;
    239         matpar->referencetemperature=this->referencetemperature;
    240         matpar->mixed_layer_capacity=this->mixed_layer_capacity;
    241         matpar->thermal_exchange_velocity=this->thermal_exchange_velocity;
    242         matpar->g=this->g;
    243         matpar->desfac=this->desfac;
    244         matpar->rlaps=this->rlaps;
    245         matpar->rlapslgm=this->rlapslgm;
    246         matpar->dpermil=this->dpermil;
    247 
    248         matpar->sediment_compressibility=this->sediment_compressibility;
    249         matpar->sediment_porosity=this->sediment_porosity;
    250         matpar->sediment_thickness=this->sediment_thickness;
    251         matpar->water_compressibility=this->water_compressibility;
    252 
    253         matpar->epl_compressibility=this->epl_compressibility;
    254         matpar->epl_porosity=this->epl_porosity;
    255         matpar->epl_init_thickness=this->epl_init_thickness;
    256         matpar->epl_colapse_thickness=this->epl_colapse_thickness;
    257         matpar->epl_max_thickness=this->epl_max_thickness;
    258         matpar->epl_conductivity=this->epl_conductivity;
    259 
    260         matpar->lithosphere_shear_modulus=this->lithosphere_shear_modulus;
    261         matpar->lithosphere_density=this->lithosphere_density;
    262         matpar->mantle_shear_modulus=this->mantle_shear_modulus;
    263         matpar->mantle_density=this->mantle_density;
    264        
    265         matpar->earth_density=this->earth_density;
    266 
    267         return matpar;
    268 }
    269263/*}}}*/
    270264void Matpar::Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ /*{{{*/
     
    328322}
    329323/*}}}*/
     324int  Matpar::ObjectEnum(void){/*{{{*/
     325
     326        return MatparEnum;
     327
     328}
     329/*}}}*/
    330330
    331331/*Update virtual functions definitions:*/
    332 void   Matpar::InputUpdateFromVector(IssmDouble* vector, int name, int type){/*{{{*/
    333         /*Nothing updated yet*/
    334 }
    335 /*}}}*/
    336 void   Matpar::InputUpdateFromVectorDakota(IssmDouble* vector, int name, int type){/*{{{*/
    337         /*Nothing updated yet*/
    338 }
    339 /*}}}*/
    340 void  Matpar::InputUpdateFromMatrixDakota(IssmDouble* matrix, int nrows, int ncols,int name, int type){/*{{{*/
    341         /*Nothing updated yet*/
    342 }
    343 /*}}}*/
    344332void   Matpar::InputUpdateFromConstant(IssmDouble constant, int name){/*{{{*/
    345333
     
    410398/*}}}*/
    411399void   Matpar::InputUpdateFromConstant(bool constant, int name){/*{{{*/
     400        /*Nothing updated yet*/
     401}
     402/*}}}*/
     403void  Matpar::InputUpdateFromMatrixDakota(IssmDouble* matrix, int nrows, int ncols,int name, int type){/*{{{*/
     404        /*Nothing updated yet*/
     405}
     406/*}}}*/
     407void   Matpar::InputUpdateFromVector(IssmDouble* vector, int name, int type){/*{{{*/
     408        /*Nothing updated yet*/
     409}
     410/*}}}*/
     411void   Matpar::InputUpdateFromVectorDakota(IssmDouble* vector, int name, int type){/*{{{*/
    412412        /*Nothing updated yet*/
    413413}
  • issm/trunk-jpl/src/c/classes/Materials/Matpar.h

    r20608 r20827  
    7979
    8080                /*Object virtual functions definitions:{{{ */
     81                Object *copy();
     82                void    DeepEcho();
    8183                void    Echo();
    82                 void    DeepEcho();
    8384                int     Id();
     85                void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);
    8486                int     ObjectEnum();
    85                 Object *copy();
    86                 void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);
    8787                /*}}}*/
    8888                /*Update virtual functions resolution: {{{*/
    89                 void   InputUpdateFromVector(IssmDouble* vector, int name, int type);
    90                 void   InputUpdateFromMatrixDakota(IssmDouble* matrix,int nrows,int ncols, int name, int type);
    91                 void   InputUpdateFromVectorDakota(IssmDouble* vector, int name, int type);
    9289                void   InputUpdateFromConstant(IssmDouble constant, int name);
    9390                void   InputUpdateFromConstant(int constant, int name);
    9491                void   InputUpdateFromConstant(bool constant, int name);
    9592                void   InputUpdateFromIoModel(int index, IoModel* iomodel){_error_("not implemented");};
     93                void   InputUpdateFromMatrixDakota(IssmDouble* matrix,int nrows,int ncols, int name, int type);
     94                void   InputUpdateFromVector(IssmDouble* vector, int name, int type);
     95                void   InputUpdateFromVectorDakota(IssmDouble* vector, int name, int type);
    9696                /*}}}*/
    9797                /*Material virtual functions resolution: {{{*/
     
    9999                void       Configure(Elements* elements);
    100100                void       GetViscosity(IssmDouble* pviscosity,IssmDouble eps_eff){_error_("not supported");};
    101                 void       GetViscosity_B(IssmDouble* pviscosity,IssmDouble eps_eff){_error_("not supported");};
    102                 void       GetViscosity_D(IssmDouble* pviscosity,IssmDouble eps_eff){_error_("not supported");};
    103101                void       GetViscosityBar(IssmDouble* pviscosity,IssmDouble eps_eff){_error_("not supported");};
    104102                void       GetViscosityComplement(IssmDouble* pviscosity_complement, IssmDouble* pepsilon){_error_("not supported");};
    105103                void       GetViscosityDComplement(IssmDouble* pviscosity_complement, IssmDouble* pepsilon){_error_("not supported");};
    106104                void       GetViscosityDerivativeEpsSquare(IssmDouble* pmu_prime, IssmDouble* pepsilon){_error_("not supported");};
     105                void       GetViscosity_B(IssmDouble* pviscosity,IssmDouble eps_eff){_error_("not supported");};
     106                void       GetViscosity_D(IssmDouble* pviscosity,IssmDouble eps_eff){_error_("not supported");};
    107107                void       GetViscosity2dDerivativeEpsSquare(IssmDouble* pmu_prime, IssmDouble* pepsilon){_error_("not supported");};
    108108                IssmDouble GetA(){_error_("not supported");};
     
    110110                IssmDouble GetB(){_error_("not supported");};
    111111                IssmDouble GetBbar(){_error_("not supported");};
    112                 IssmDouble GetN(){_error_("not supported");};
    113112                IssmDouble GetD(){_error_("not supported");};
    114113                IssmDouble GetDbar(){_error_("not supported");};
     114                IssmDouble GetN(){_error_("not supported");};
    115115                bool       IsDamage(){_error_("not supported");};
    116116                void       ResetHooks();
  • issm/trunk-jpl/src/c/classes/Options/GenericOption.h

    r18918 r20827  
    4848
    4949                /*Object virtual functions definitions:*/
    50                 void Echo(){ /*{{{*/
    51 
    52                         this->DeepEcho();
    53 
    54                 } /*}}}*/
     50                Object* copy(){/*{{{*/
     51                        _error_("Not implemented yet");
     52                };/*}}}*/
    5553                void DeepEcho(){ /*{{{*/
    5654
     
    7472                        _printf_(indent << "         value: " << value << "\n");;
    7573                } /*}}}*/
     74                void Echo(){ /*{{{*/
     75
     76                        this->DeepEcho();
     77
     78                } /*}}}*/
    7679                int  Id(){/*{{{*/
    7780                        _error_("Not implemented yet");
     
    8083                        return GenericOptionEnum;
    8184                };/*}}}*/
    82                 Object* copy(){/*{{{*/
    83                         _error_("Not implemented yet");
    84                 };/*}}}*/
    8585
    8686                /*GenericOption functions: */
     87                void  Get(OptionType* pvalue){/*{{{*/
     88                        *pvalue=value;
     89                };/*}}}*/
    8790                char* Name(){/*{{{*/
    8891                        return name;
     92                };/*}}}*/
     93                int   NDims(){/*{{{*/
     94                        return ndims;
    8995                };/*}}}*/
    9096                int   NumEl(){/*{{{*/
    9197                        return numel;
    9298                };/*}}}*/
    93                 int   NDims(){/*{{{*/
    94                         return ndims;
    95                 };/*}}}*/
    9699                int*  Size(){/*{{{*/
    97100                        return size;
    98                 };/*}}}*/
    99                 void  Get(OptionType* pvalue){/*{{{*/
    100                         *pvalue=value;
    101101                };/*}}}*/
    102102};
  • issm/trunk-jpl/src/c/classes/Options/Option.h

    r19198 r20827  
    2020
    2121                /*Object virtual functions definitions*/
    22                 virtual void  Echo()= 0;
     22                Object       *copy(){_error_("Not implemented yet"); };
    2323                virtual void  DeepEcho()= 0;
    2424                virtual void  DeepEcho(char  *indent)=0;
     25                virtual void  Echo()= 0;
    2526                int           Id(){_error_("Not implemented yet"); };
     27                void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ _error_("not implemented yet!"); };
    2628                int           ObjectEnum(){return OptionEnum;              };
    27                 Object       *copy(){_error_("Not implemented yet"); };
    28                 void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ _error_("not implemented yet!"); };
    2929
    3030
    3131                /*virtual functions: */
    3232                virtual char* Name()=0;
     33                virtual int   NDims()=0;
    3334                virtual int   NumEl()=0;
    34                 virtual int   NDims()=0;
    3535                virtual int*  Size()=0;
    3636
  • issm/trunk-jpl/src/c/classes/Options/OptionUtilities.cpp

    r18064 r20827  
    5151        return(index);
    5252}/*}}}*/
     53int IndexFromRowWiseDims(int* dims, int* size, int ndims) {/*{{{*/
     54
     55        int   i;
     56        int   index=0;
     57
     58        /*check for any dimension too large  */
     59        for (i=0; i<ndims; i++){
     60                if (dims[i] >= size[i]) _error_("Dimension " << i << " of " << dims[i] << " exceeds size of " << size[i] << ".");
     61        }
     62
     63        /*calculate the index  */
     64        for (i=0; i<ndims; i++) {
     65                index*=size[i];
     66                index+=dims[i];
     67        }
     68
     69        return(index);
     70}/*}}}*/
    5371int RowWiseDimsFromIndex(int* dims, int index, int* size, int ndims) {/*{{{*/
    5472
     
    6987        return(0);
    7088}/*}}}*/
    71 int IndexFromRowWiseDims(int* dims, int* size, int ndims) {/*{{{*/
    72 
    73         int   i;
    74         int   index=0;
    75 
    76         /*check for any dimension too large  */
    77         for (i=0; i<ndims; i++){
    78                 if (dims[i] >= size[i]) _error_("Dimension " << i << " of " << dims[i] << " exceeds size of " << size[i] << ".");
    79         }
    80 
    81         /*calculate the index  */
    82         for (i=0; i<ndims; i++) {
    83                 index*=size[i];
    84                 index+=dims[i];
    85         }
    86 
    87         return(index);
    88 }/*}}}*/
    8989int StringFromDims(char* cstr, int* dims, int ndims) {/*{{{*/
    9090
  • issm/trunk-jpl/src/c/classes/Options/OptionUtilities.h

    r15012 r20827  
    1515int ColumnWiseDimsFromIndex(int* dims, int index, int* size, int ndims);
    1616int IndexFromColumnWiseDims(int* dims, int* size, int ndims);
     17int IndexFromRowWiseDims(int* dims, int* size, int ndims);
    1718int RowWiseDimsFromIndex(int* dims, int index, int* size, int ndims);
    18 int IndexFromRowWiseDims(int* dims, int* size, int ndims);
    1919int StringFromDims(char* cstr, int* dims, int ndims);
    2020int StringFromSize(char* cstr, int* size, int ndims);
  • issm/trunk-jpl/src/c/classes/Params/BoolParam.cpp

    r20635 r20827  
    3232
    3333/*Object virtual functions definitions:*/
    34 void BoolParam::Echo(void){/*{{{*/
    35         this->DeepEcho();
     34Param* BoolParam::copy() {/*{{{*/
     35
     36        return new BoolParam(this->enum_type,this->value);
     37
    3638}
    3739/*}}}*/
     
    4042}
    4143/*}}}*/
    42 int    BoolParam::Id(void){ return -1; }/*{{{*/
    43 /*}}}*/
    44 int BoolParam::ObjectEnum(void){/*{{{*/
    45 
    46         return BoolParamEnum;
    47 
     44void BoolParam::Echo(void){/*{{{*/
     45        this->DeepEcho();
    4846}
    4947/*}}}*/
    50 Param* BoolParam::copy() {/*{{{*/
    51 
    52         return new BoolParam(this->enum_type,this->value);
    53 
    54 }
     48int    BoolParam::Id(void){ return -1; }/*{{{*/
    5549/*}}}*/
    5650void BoolParam::Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ /*{{{*/
     
    6357}
    6458/*}}}*/
     59int BoolParam::ObjectEnum(void){/*{{{*/
     60
     61        return BoolParamEnum;
     62
     63}
     64/*}}}*/
    6565               
  • issm/trunk-jpl/src/c/classes/Params/BoolParam.h

    r20690 r20827  
    3131                /*}}}*/
    3232                /*Object virtual functions definitions:{{{ */
     33                Param* copy();
     34                void  DeepEcho();
    3335                void  Echo();
    34                 void  DeepEcho();
    3536                int   Id();
     37                void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);
    3638                int   ObjectEnum();
    37                 Param* copy();
    38                 void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);
    3939                /*}}}*/
    4040                /*Param vritual function definitions: {{{*/
    41                 int   InstanceEnum(){return enum_type;}
    4241                void  GetParameterValue(bool* pbool){*pbool=value;}
    4342                void  GetParameterValue(int* pinteger){_error_("Param "<< EnumToStringx(enum_type) << " cannot return an integer");}
     
    5554                void  GetParameterValue(FILE** pfid){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a FILE");}
    5655                void  GetParameterValue(DataSet** pdataset){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a DataSet");}
     56                int   InstanceEnum(){return enum_type;}
    5757
     58                void  SetEnum(int enum_in){this->enum_type = enum_in;};
    5859                void  SetValue(bool boolean){this->value=boolean;}
    5960                void  SetValue(int integer){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold an int");}
     
    6970                void  SetValue(FILE* fid){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a FILE");}
    7071                void  SetValue(IssmDouble** array, int M, int* mdim_array, int* ndim_array){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold an array of matrices");}
    71                 void  SetEnum(int enum_in){this->enum_type = enum_in;};
    7272                /*}}}*/
    7373};
  • issm/trunk-jpl/src/c/classes/Params/DataSetParam.cpp

    r20635 r20827  
    3333
    3434/*Object virtual functions definitions:*/
    35 void DataSetParam::Echo(void){/*{{{*/
    36         this->DeepEcho();
     35Param* DataSetParam::copy() {/*{{{*/
     36
     37        return new DataSetParam(this->enum_type,this->value);
     38
    3739}
    3840/*}}}*/
     
    4446}
    4547/*}}}*/
    46 int    DataSetParam::Id(void){ return -1; }/*{{{*/
    47 /*}}}*/
    48 int DataSetParam::ObjectEnum(void){/*{{{*/
    49 
    50         return DataSetParamEnum;
    51 
     48void DataSetParam::Echo(void){/*{{{*/
     49        this->DeepEcho();
    5250}
    5351/*}}}*/
    54 Param* DataSetParam::copy() {/*{{{*/
    55 
    56         return new DataSetParam(this->enum_type,this->value);
    57 
    58 }
     52int    DataSetParam::Id(void){ return -1; }/*{{{*/
    5953/*}}}*/
    6054void DataSetParam::Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ /*{{{*/
     
    6862}
    6963/*}}}*/
     64int DataSetParam::ObjectEnum(void){/*{{{*/
     65
     66        return DataSetParamEnum;
     67
     68}
     69/*}}}*/
    7070
    7171/*DataSetParam virtual functions definitions: */
  • issm/trunk-jpl/src/c/classes/Params/DataSetParam.h

    r20690 r20827  
    3232                /*}}}*/
    3333                /*Object virtual functions definitions:{{{ */
     34                Param* copy();
     35                void  DeepEcho();
    3436                void  Echo();
    35                 void  DeepEcho();
    3637                int   Id();
     38                void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);
    3739                int   ObjectEnum();
    38                 Param* copy();
    39                 void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);
    4040                /*}}}*/
    4141                /*Param vritual function definitions: {{{*/
    42                 int   InstanceEnum(){return enum_type;}
    4342                void  GetParameterValue(bool* pbool){  _error_("Param "<< EnumToStringx(enum_type) << " cannot return a bool");}
    4443                void  GetParameterValue(int* pinteger){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a IssmDouble");}
     
    5655                void  GetParameterValue(Matrix<IssmDouble>** pmat){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a Mat");}
    5756                void  GetParameterValue(DataSet** pdataset);
     57                int   InstanceEnum(){return enum_type;}
    5858
     59                void  SetEnum(int enum_in){this->enum_type = enum_in;};
    5960                void  SetValue(bool boolean){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a string");}
    6061                void  SetValue(int integer){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a string");}
     
    7172                void  SetValue(DataSet* dataset){_error_("DataSet param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a DataSet yet");}
    7273                void  SetValue(IssmDouble** array, int M, int* mdim_array, int* ndim_array){_error_("DataSet param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold an array of matrices");}
    73                 void  SetEnum(int enum_in){this->enum_type = enum_in;};
    7474                /*}}}*/
    7575};
  • issm/trunk-jpl/src/c/classes/Params/DoubleMatArrayParam.cpp

    r20635 r20827  
    7676
    7777/*Object virtual functions definitions:*/
     78Param* DoubleMatArrayParam::copy() {/*{{{*/
     79
     80        return new DoubleMatArrayParam(this->enum_type,this->array, this->M, this->mdim_array,this->ndim_array);
     81
     82}
     83/*}}}*/
     84void DoubleMatArrayParam::DeepEcho(void){/*{{{*/
     85
     86        int i,j,k;
     87        int m,n;
     88        IssmDouble* matrix=NULL;
     89
     90        _printf_("DoubleMatArrayParam:\n");
     91        _printf_("   enum: " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")\n");
     92        _printf_("   array size: " << this->M << "\n");
     93        for(i=0;i<M;i++){
     94                _printf_("   array " << i << " (" << mdim_array[i] << "x" << ndim_array[i] << "):\n");
     95                matrix=array[i];
     96                m=mdim_array[i];
     97                n=ndim_array[i];
     98
     99                for(j=0;j<m;j++){
     100                        _printf_("   ");
     101                        for(k=0;k<n;k++)_printf_(*(matrix+n*j+k) << " ");
     102                        _printf_("\n");
     103                }
     104        }
     105}
     106/*}}}*/
    78107void DoubleMatArrayParam::Echo(void){/*{{{*/
    79108
     
    85114}
    86115/*}}}*/
    87 void DoubleMatArrayParam::DeepEcho(void){/*{{{*/
    88 
    89         int i,j,k;
    90         int m,n;
    91         IssmDouble* matrix=NULL;
    92 
    93         _printf_("DoubleMatArrayParam:\n");
    94         _printf_("   enum: " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")\n");
    95         _printf_("   array size: " << this->M << "\n");
    96         for(i=0;i<M;i++){
    97                 _printf_("   array " << i << " (" << mdim_array[i] << "x" << ndim_array[i] << "):\n");
    98                 matrix=array[i];
    99                 m=mdim_array[i];
    100                 n=ndim_array[i];
    101 
    102                 for(j=0;j<m;j++){
    103                         _printf_("   ");
    104                         for(k=0;k<n;k++)_printf_(*(matrix+n*j+k) << " ");
    105                         _printf_("\n");
    106                 }
    107         }
    108 }
    109 /*}}}*/
    110116int    DoubleMatArrayParam::Id(void){ return -1; }/*{{{*/
    111 /*}}}*/
    112 int DoubleMatArrayParam::ObjectEnum(void){/*{{{*/
    113 
    114         return DoubleMatArrayParamEnum;
    115 
    116 }
    117 /*}}}*/
    118 Param* DoubleMatArrayParam::copy() {/*{{{*/
    119 
    120         return new DoubleMatArrayParam(this->enum_type,this->array, this->M, this->mdim_array,this->ndim_array);
    121 
    122 }
    123117/*}}}*/
    124118void DoubleMatArrayParam::Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ /*{{{*/
     
    144138}
    145139/*}}}*/
     140int DoubleMatArrayParam::ObjectEnum(void){/*{{{*/
     141
     142        return DoubleMatArrayParamEnum;
     143
     144}
     145/*}}}*/
    146146
    147147/*DoubleMatArrayParam virtual functions definitions: */
  • issm/trunk-jpl/src/c/classes/Params/DoubleMatArrayParam.h

    r20690 r20827  
    3434                /*}}}*/
    3535                /*Object virtual functions definitions:{{{ */
     36                Param* copy();
     37                void  DeepEcho();
    3638                void  Echo();
    37                 void  DeepEcho();
    3839                int   Id();
     40                void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);
    3941                int   ObjectEnum();
    40                 Param* copy();
    41                 void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);
    4242                /*}}}*/
    4343                /*Param vritual function definitions: {{{*/
    44                 int   InstanceEnum(){return enum_type;}
    4544                void  GetParameterValue(bool* pbool){_error_("Param "<< EnumToStringx(enum_type) << "cannot return a bool");}
    4645                void  GetParameterValue(int* pinteger){_error_("Param "<< EnumToStringx(enum_type) << "cannot return an integer");}
     
    5857                void  GetParameterValue(FILE** pfid){_error_("Param "<< EnumToStringx(enum_type) << "cannot return a FILE");}
    5958                void  GetParameterValue(DataSet** pdataset){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a DataSet");}
     59                int   InstanceEnum(){return enum_type;}
    6060
     61                void  SetEnum(int enum_in){this->enum_type = enum_in;};
    6162                void  SetValue(bool boolean){_error_("Param "<< EnumToStringx(enum_type) << "cannot hold a boolean");}
    6263                void  SetValue(int integer){_error_("Param "<< EnumToStringx(enum_type) << "cannot hold an integer");}
     
    7273                void  SetValue(FILE* fid){_error_("Bool param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a FILE");}
    7374                void  SetValue(IssmDouble** array, int M, int* mdim_array, int* ndim_array);
    74                 void  SetEnum(int enum_in){this->enum_type = enum_in;};
    7575                /*}}}*/
    7676};
  • issm/trunk-jpl/src/c/classes/Params/DoubleParam.cpp

    r20635 r20827  
    2929
    3030/*Object virtual functions definitions:*/
    31 void DoubleParam::Echo(void){/*{{{*/
    32         this->DeepEcho();
     31Param* DoubleParam::copy() {/*{{{*/
     32
     33        return new DoubleParam(this->enum_type,this->value);
     34
    3335}
    3436/*}}}*/
     
    3840}
    3941/*}}}*/
    40 int  DoubleParam::Id(void){ return -1; }/*{{{*/
    41 /*}}}*/
    42 int  DoubleParam::ObjectEnum(void){/*{{{*/
    43 
    44         return DoubleParamEnum;
    45 
     42void DoubleParam::Echo(void){/*{{{*/
     43        this->DeepEcho();
    4644}
    4745/*}}}*/
    48 Param* DoubleParam::copy() {/*{{{*/
    49 
    50         return new DoubleParam(this->enum_type,this->value);
    51 
    52 }
     46int  DoubleParam::Id(void){ return -1; }/*{{{*/
    5347/*}}}*/
    5448void DoubleParam::Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ /*{{{*/
     
    5852        MARSHALLING(enum_type);
    5953        MARSHALLING(value);
     54
     55}
     56/*}}}*/
     57int  DoubleParam::ObjectEnum(void){/*{{{*/
     58
     59        return DoubleParamEnum;
    6060
    6161}
  • issm/trunk-jpl/src/c/classes/Params/DoubleParam.h

    r20690 r20827  
    3232                /*}}}*/
    3333                /*Object virtual functions definitions:{{{ */
     34                Param* copy();
     35                void  DeepEcho();
    3436                void  Echo();
    35                 void  DeepEcho();
    3637                int   Id();
     38                void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);
    3739                int   ObjectEnum();
    38                 Param* copy();
    39                 void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);
    4040                /*}}}*/
    4141                /*Param vritual function definitions: {{{*/
    42                 int   InstanceEnum(){return enum_type;}
    4342                void  GetParameterValue(bool* pbool);
    4443                void  GetParameterValue(int* pinteger);
     
    5655                void  GetParameterValue(FILE** pfid){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a FILE");}
    5756                void  GetParameterValue(DataSet** pdataset){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a DataSet");}
     57                int   InstanceEnum(){return enum_type;}
    5858
     59                void  SetEnum(int enum_in){this->enum_type = enum_in;};
    5960                void  SetValue(bool boolean){this->value=(IssmDouble)boolean;}
    6061                void  SetValue(int integer){this->value=(IssmDouble)integer;}
     
    7071                void  SetValue(FILE* fid){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a FILE");}
    7172                void  SetValue(IssmDouble** array, int M, int* mdim_array, int* ndim_array){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold an array of matrices");}
    72                 void  SetEnum(int enum_in){this->enum_type = enum_in;};
    7373                /*}}}*/
    7474};
  • issm/trunk-jpl/src/c/classes/Params/DoubleVecParam.cpp

    r20635 r20827  
    3939
    4040/*Object virtual functions definitions:*/
    41 void DoubleVecParam::Echo(void){/*{{{*/
     41Param* DoubleVecParam::copy() {/*{{{*/
    4242
    43         _printf_(setw(22)<<"   DoubleVecParam "<<setw(35)<<left<<EnumToStringx(this->enum_type)<<" size: "<<this->M<<"\n");
     43        return new DoubleVecParam(this->enum_type,this->values,this->M);
    4444
    4545}
     
    5151}
    5252/*}}}*/
    53 int    DoubleVecParam::Id(void){ return -1; }/*{{{*/
    54 /*}}}*/
    55 int DoubleVecParam::ObjectEnum(void){/*{{{*/
     53void DoubleVecParam::Echo(void){/*{{{*/
    5654
    57         return DoubleVecParamEnum;
     55        _printf_(setw(22)<<"   DoubleVecParam "<<setw(35)<<left<<EnumToStringx(this->enum_type)<<" size: "<<this->M<<"\n");
    5856
    5957}
    6058/*}}}*/
    61 Param* DoubleVecParam::copy() {/*{{{*/
    62 
    63         return new DoubleVecParam(this->enum_type,this->values,this->M);
    64 
    65 }
     59int    DoubleVecParam::Id(void){ return -1; }/*{{{*/
    6660/*}}}*/
    6761void DoubleVecParam::Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ /*{{{*/
     
    7266        MARSHALLING(M);
    7367        MARSHALLING_DYNAMIC(values,IssmDouble,M);
     68
     69}
     70/*}}}*/
     71int DoubleVecParam::ObjectEnum(void){/*{{{*/
     72
     73        return DoubleVecParamEnum;
    7474
    7575}
  • issm/trunk-jpl/src/c/classes/Params/DoubleVecParam.h

    r20690 r20827  
    3232                /*}}}*/
    3333                /*Object virtual functions definitions:{{{ */
     34                Param* copy();
     35                void  DeepEcho();
    3436                void  Echo();
    35                 void  DeepEcho();
    3637                int   Id();
     38                void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);
    3739                int   ObjectEnum();
    38                 Param* copy();
    39                 void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);
    4040                /*}}}*/
    4141                /*Param virtual functions definitions: {{{*/
    42                 int   InstanceEnum(){return enum_type;}
    4342                void  GetParameterValue(bool* pbool){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a bool");}
    4443                void  GetParameterValue(int* pinteger){_error_("Param "<< EnumToStringx(enum_type) << " cannot return an integer");}
     
    5655                void  GetParameterValue(FILE** pfid){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a FILE");}
    5756                void  GetParameterValue(DataSet** pdataset){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a DataSet");}
     57                int   InstanceEnum(){return enum_type;}
    5858
     59                void  SetEnum(int enum_in){this->enum_type = enum_in;};
    5960                void  SetValue(bool boolean){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a boolean");}
    6061                void  SetValue(int integer){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold an integer");}
     
    7071                void  SetValue(FILE* fid){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a FILE");}
    7172                void  SetValue(IssmDouble** array, int M, int* mdim_array, int* ndim_array){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold an array of matrices");}
    72                 void  SetEnum(int enum_in){this->enum_type = enum_in;};
    7373                /*}}}*/
    7474                /*DoubleVecParam specific routines:{{{*/
  • issm/trunk-jpl/src/c/classes/Params/FileParam.cpp

    r20635 r20827  
    3232
    3333/*Object virtual functions definitions:*/
    34 void FileParam::Echo(void){/*{{{*/
    35         this->DeepEcho();
     34Param* FileParam::copy() {/*{{{*/
     35
     36        return new FileParam(this->enum_type,this->value);
     37
    3638}
    3739/*}}}*/
     
    4143}
    4244/*}}}*/
    43 int  FileParam::Id(void){ return -1; }/*{{{*/
    44 /*}}}*/
    45 int  FileParam::ObjectEnum(void){/*{{{*/
    46 
    47         return FileParamEnum;
    48 
     45void FileParam::Echo(void){/*{{{*/
     46        this->DeepEcho();
    4947}
    5048/*}}}*/
    51 Param* FileParam::copy() {/*{{{*/
    52 
    53         return new FileParam(this->enum_type,this->value);
    54 
    55 }
     49int  FileParam::Id(void){ return -1; }/*{{{*/
    5650/*}}}*/
    5751void FileParam::Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ /*{{{*/
     
    6559}
    6660/*}}}*/
     61int  FileParam::ObjectEnum(void){/*{{{*/
     62
     63        return FileParamEnum;
     64
     65}
     66/*}}}*/
  • issm/trunk-jpl/src/c/classes/Params/FileParam.h

    r20690 r20827  
    3131                /*}}}*/
    3232                /*Object virtual functions definitions:{{{ */
     33                Param* copy();
     34                void  DeepEcho();
    3335                void  Echo();
    34                 void  DeepEcho();
    3536                int   Id();
     37                void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);
    3638                int   ObjectEnum();
    37                 Param* copy();
    38                 void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);
    3939                /*}}}*/
    4040                /*Param vritual function definitions: {{{*/
    41                 int   InstanceEnum(){return enum_type;}
    4241                void  GetParameterValue(bool* pbool){  _error_("Param "<< EnumToStringx(enum_type) << " cannot return a bool");}
    4342                void  GetParameterValue(int* pinteger){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a IssmDouble");}
     
    5554                void  GetParameterValue(FILE** pfid){*pfid=value;};
    5655                void  GetParameterValue(DataSet** pdataset){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a DataSet");}
     56                int   InstanceEnum(){return enum_type;}
    5757
     58                void  SetEnum(int enum_in){this->enum_type = enum_in;};
    5859                void  SetValue(bool boolean){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a string");}
    5960                void  SetValue(int integer){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a string");}
     
    6970                void  SetValue(FILE* fid){_error_("File param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a FILE");}
    7071                void  SetValue(IssmDouble** array, int M, int* mdim_array, int* ndim_array){_error_("File param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold an array of matrices");}
    71                 void  SetEnum(int enum_in){this->enum_type = enum_in;};
    7272                /*}}}*/
    7373};
  • issm/trunk-jpl/src/c/classes/Params/GenericParam.h

    r20690 r20827  
    3939                // unfortunately,  having to implement such a printer method implies
    4040                // that any structured P must provide the friend << operator
     41                Param* copy() { return new GenericParam<P>(*this); };
    4142                void  DeepEcho() {
    4243                  _printf_("GenericParam:\n");
     
    4647                void  Echo() {DeepEcho();};
    4748                int   Id(){ return -1; };
    48                 int   ObjectEnum() {return GenericParamEnum;};
    4949
    5050                // the "copy"  has to implement the base class abstract function
     
    5252                // it does not clarify  ownership of the newed up instance...
    5353                // use the default copy constructor instead
    54                 Param* copy() { return new GenericParam<P>(*this); };
    5554                                         void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){
    5655                                                 _printf_("   WARNING: parameter "<<EnumToStringx(this->myEnumVal)<<" is a GenericParam and cannot be marshalled\n");
    5756                                                 /*Nothing for now*/
    5857                                         }
     58                int   ObjectEnum() {return GenericParamEnum;};
    5959
    6060                /*}}}*/
    6161                /*Param vritual function definitions: {{{*/
    62                 int   InstanceEnum(){return myEnumVal;}
    6362                P& GetParameterValue() { return myP;}
    6463                const P& GetParameterValue()const { return myP;};
     64                int   InstanceEnum(){return myEnumVal;}
    6565
    6666                // none of these apply ...
     
    8181                                void  GetParameterValue(DataSet** pdataset){_error_("Param "<< EnumToStringx(myEnumVal) << " cannot return a DataSet");}
    8282
     83                                         void  SetEnum(int enum_in){this->myEnumVal = enum_in;};
    8384                void  SetValue(bool boolean){_error_("Param "<< EnumToStringx(myEnumVal) << " cannot hold a bool");}
    8485                void  SetValue(int integer){_error_("Param "<< EnumToStringx(myEnumVal) << " cannot hold an integer");}
     
    9495                void  SetValue(FILE* fid){_error_("Param "<< EnumToStringx(myEnumVal) << " cannot hold a FILE");}
    9596                void  SetValue(IssmDouble** array, int M, int* mdim_array, int* ndim_array){_error_("Param "<< EnumToStringx(myEnumVal) << " cannot hold an array of matrices");}
    96                                          void  SetEnum(int enum_in){this->myEnumVal = enum_in;};
    9797
    9898                /*}}}*/
  • issm/trunk-jpl/src/c/classes/Params/IntMatParam.cpp

    r20635 r20827  
    3737
    3838/*Object virtual functions definitions:*/
    39 void IntMatParam::Echo(void){/*{{{*/
     39Param* IntMatParam::copy() {/*{{{*/
    4040
    41         _printf_("IntMatParam:\n");
    42         _printf_("   enum: " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")\n");
    43         _printf_("   matrix size: " << this->M << "x" << this->N << "\n");
     41        return new IntMatParam(this->enum_type,this->value,this->M,this->N);
    4442
    4543}
     
    5957}
    6058/*}}}*/
    61 int  IntMatParam::Id(void){ return -1; }/*{{{*/
    62 /*}}}*/
    63 int  IntMatParam::ObjectEnum(void){/*{{{*/
     59void IntMatParam::Echo(void){/*{{{*/
    6460
    65         return IntMatParamEnum;
     61        _printf_("IntMatParam:\n");
     62        _printf_("   enum: " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")\n");
     63        _printf_("   matrix size: " << this->M << "x" << this->N << "\n");
    6664
    6765}
    6866/*}}}*/
    69 Param* IntMatParam::copy() {/*{{{*/
    70 
    71         return new IntMatParam(this->enum_type,this->value,this->M,this->N);
    72 
    73 }
     67int  IntMatParam::Id(void){ return -1; }/*{{{*/
    7468/*}}}*/
    7569void IntMatParam::Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ /*{{{*/
     
    8175        MARSHALLING(N);
    8276        MARSHALLING_DYNAMIC(value,int,M*N);
     77}
     78/*}}}*/
     79int  IntMatParam::ObjectEnum(void){/*{{{*/
     80
     81        return IntMatParamEnum;
     82
    8383}
    8484/*}}}*/
  • issm/trunk-jpl/src/c/classes/Params/IntMatParam.h

    r20690 r20827  
    3333                /*}}}*/
    3434                /*Object virtual functions definitions:{{{ */
     35                Param* copy();
     36                void  DeepEcho();
    3537                void  Echo();
    36                 void  DeepEcho();
    3738                int   Id();
     39                void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);
    3840                int   ObjectEnum();
    39                 Param* copy();
    40                 void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);
    4141                /*}}}*/
    4242                /*Param vritual function definitions: {{{*/
    43                 int   InstanceEnum(){return enum_type;}
    4443                void  GetParameterValue(bool* pbool){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a bool");}
    4544                void  GetParameterValue(int* pinteger){_error_("Param "<< EnumToStringx(enum_type) << " cannot return an integer");}
     
    5756                void  GetParameterValue(FILE** pfid){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a FILE");}
    5857                void  GetParameterValue(DataSet** pdataset){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a DataSet");}
     58                int   InstanceEnum(){return enum_type;}
    5959
     60                void  SetEnum(int enum_in){this->enum_type = enum_in;};
    6061                void  SetValue(bool boolean){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a boolean");}
    6162                void  SetValue(int integer){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold an integer");}
     
    7172                void  SetValue(FILE* fid){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a FILE");}
    7273                void  SetValue(IssmDouble** array, int M, int* mdim_array, int* ndim_array){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold an array of matrices");}
    73                 void  SetEnum(int enum_in){this->enum_type = enum_in;};
    7474                /*}}}*/
    7575};
  • issm/trunk-jpl/src/c/classes/Params/IntParam.cpp

    r20635 r20827  
    3232
    3333/*Object virtual functions definitions:*/
    34 void IntParam::Echo(void){/*{{{*/
    35         this->DeepEcho();
     34Param* IntParam::copy() {/*{{{*/
     35
     36        return new IntParam(this->enum_type,this->value);
     37
    3638}
    3739/*}}}*/
     
    4143}
    4244/*}}}*/
    43 int  IntParam::Id(void){ return -1; }/*{{{*/
    44 /*}}}*/
    45 int  IntParam::ObjectEnum(void){/*{{{*/
    46 
    47         return IntParamEnum;
    48 
     45void IntParam::Echo(void){/*{{{*/
     46        this->DeepEcho();
    4947}
    5048/*}}}*/
    51 Param* IntParam::copy() {/*{{{*/
    52 
    53         return new IntParam(this->enum_type,this->value);
    54 
    55 }
     49int  IntParam::Id(void){ return -1; }/*{{{*/
    5650/*}}}*/
    5751void IntParam::Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ /*{{{*/
     
    6458}
    6559/*}}}*/
     60int  IntParam::ObjectEnum(void){/*{{{*/
    6661
     62        return IntParamEnum;
     63
     64}
     65/*}}}*/
     66
  • issm/trunk-jpl/src/c/classes/Params/IntParam.h

    r20690 r20827  
    3232                /*}}}*/
    3333                /*Object virtual functions definitions:{{{ */
     34                Param* copy();
     35                void  DeepEcho();
    3436                void  Echo();
    35                 void  DeepEcho();
    3637                int   Id();
     38                void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);
    3739                int   ObjectEnum();
    38                 Param* copy();
    39                 void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);
    4040                /*}}}*/
    4141                /*Param vritual function definitions: {{{*/
    42                 int   InstanceEnum(){return enum_type;}
    4342                void  GetParameterValue(bool* pbool){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a bool");}
    4443                void  GetParameterValue(int* pinteger){*pinteger=value;}
     
    5655                void  GetParameterValue(FILE** pfid){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a FILE");}
    5756                void  GetParameterValue(DataSet** pdataset){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a DataSet");}
     57                int   InstanceEnum(){return enum_type;}
    5858
     59                void  SetEnum(int enum_in){this->enum_type = enum_in;};
    5960                void  SetValue(bool boolean){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a bool");}
    6061                void  SetValue(int integer){this->value=integer;}
     
    7071                void  SetValue(FILE* fid){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a FILE");}
    7172                void  SetValue(IssmDouble** array, int M, int* mdim_array, int* ndim_array){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold an array of matrices");}
    72                 void  SetEnum(int enum_in){this->enum_type = enum_in;};
    7373                /*}}}*/
    7474};
  • issm/trunk-jpl/src/c/classes/Params/IntVecParam.cpp

    r20635 r20827  
    5151
    5252/*Object virtual functions definitions:*/
    53 void IntVecParam::Echo(void){/*{{{*/
     53Param* IntVecParam::copy() {/*{{{*/
    5454
    55         _printf_("IntVecParam:\n");
    56         _printf_("   enum: " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")\n");
    57         _printf_("   vector size: " << this->M << "\n");
     55        return new IntVecParam(this->enum_type,this->values,this->M);
    5856
    5957}
     
    7169}
    7270/*}}}*/
    73 int  IntVecParam::Id(void){ return -1; }/*{{{*/
    74 /*}}}*/
    75 int  IntVecParam::ObjectEnum(void){/*{{{*/
     71void IntVecParam::Echo(void){/*{{{*/
    7672
    77         return IntVecParamEnum;
     73        _printf_("IntVecParam:\n");
     74        _printf_("   enum: " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")\n");
     75        _printf_("   vector size: " << this->M << "\n");
    7876
    7977}
    8078/*}}}*/
    81 Param* IntVecParam::copy() {/*{{{*/
    82 
    83         return new IntVecParam(this->enum_type,this->values,this->M);
    84 
    85 }
     79int  IntVecParam::Id(void){ return -1; }/*{{{*/
    8680/*}}}*/
    8781void IntVecParam::Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ /*{{{*/
     
    9589        }
    9690        else values=NULL;
     91
     92}
     93/*}}}*/
     94int  IntVecParam::ObjectEnum(void){/*{{{*/
     95
     96        return IntVecParamEnum;
    9797
    9898}
  • issm/trunk-jpl/src/c/classes/Params/IntVecParam.h

    r20690 r20827  
    3333                /*}}}*/
    3434                /*Object virtual functions definitions:{{{ */
     35                Param* copy();
     36                void  DeepEcho();
    3537                void  Echo();
    36                 void  DeepEcho();
    3738                int   Id();
     39                void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);
    3840                int   ObjectEnum();
    39                 Param* copy();
    40                 void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);
    4141                /*}}}*/
    4242                /*Param virtual functions definitions: {{{*/
    43                 int   InstanceEnum(){return enum_type;}
    4443                void  GetParameterValue(bool* pbool){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a bool");}
    4544                void  GetParameterValue(int* pinteger){_error_("Param "<< EnumToStringx(enum_type) << " cannot return an integer");}
     
    5756                void  GetParameterValue(FILE** pfid){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a FILE");}
    5857                void  GetParameterValue(DataSet** pdataset){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a DataSet");}
     58                int   InstanceEnum(){return enum_type;}
    5959
     60                void  SetEnum(int enum_in){this->enum_type = enum_in;};
    6061                void  SetValue(bool boolean){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a boolean");}
    6162                void  SetValue(int integer){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold an integer");}
     
    7172                void  SetValue(FILE* fid){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a FILE");}
    7273                void  SetValue(IssmDouble** array, int M, int* mdim_array, int* ndim_array){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold an array of matrices");}
    73                 void  SetEnum(int enum_in){this->enum_type = enum_in;};
    7474                /*}}}*/
    7575};
  • issm/trunk-jpl/src/c/classes/Params/MatrixParam.cpp

    r20635 r20827  
    3636
    3737/*Object virtual functions definitions:*/
    38 void MatrixParam::Echo(void){/*{{{*/
     38Param* MatrixParam::copy() {/*{{{*/
    3939
    40         _printf_("MatrixParam:\n");
    41         _printf_("   enum: " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")\n");
     40        return new MatrixParam(this->enum_type,this->value);
    4241
    4342}
     
    5049}
    5150/*}}}*/
     51void MatrixParam::Echo(void){/*{{{*/
     52
     53        _printf_("MatrixParam:\n");
     54        _printf_("   enum: " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")\n");
     55
     56}
     57/*}}}*/
    5258int  MatrixParam::Id(void){ return -1; }/*{{{*/
    5359/*}}}*/
     
    5561
    5662        return MatrixParamEnum;
    57 
    58 }
    59 /*}}}*/
    60 Param* MatrixParam::copy() {/*{{{*/
    61 
    62         return new MatrixParam(this->enum_type,this->value);
    6363
    6464}
  • issm/trunk-jpl/src/c/classes/Params/MatrixParam.h

    r20690 r20827  
    3232                /*}}}*/
    3333                /*Object virtual functions definitions:{{{ */
     34                Param* copy();
     35                void  DeepEcho();
    3436                void  Echo();
    35                 void  DeepEcho();
    3637                int   Id();
     38                void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ _error_("not implemented yet!"); };
    3739                int   ObjectEnum();
    38                 Param* copy();
    39                 void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ _error_("not implemented yet!"); };
    4040                /*}}}*/
    4141                /*Param vritual function definitions: {{{*/
    42                 int   InstanceEnum(){return enum_type;}
    4342                void  GetParameterValue(bool* pbool){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a bool");}
    4443                void  GetParameterValue(int* pinteger){_error_("Param "<< EnumToStringx(enum_type) << " cannot return an integer");}
     
    5655                void  GetParameterValue(FILE** pfid){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a FILE");}
    5756                void  GetParameterValue(DataSet** pdataset){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a DataSet");}
     57                int   InstanceEnum(){return enum_type;}
    5858
     59                void  SetEnum(int enum_in){this->enum_type = enum_in;};
    5960                void  SetValue(bool boolean){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a boolean");}
    6061                void  SetValue(int integer){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold an integer");}
     
    7071                void  SetValue(FILE* fid){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a FILE");}
    7172                void  SetValue(IssmDouble** array, int M, int* mdim_array, int* ndim_array){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold an array of matrices");}
    72                 void  SetEnum(int enum_in){this->enum_type = enum_in;};
    7373                /*}}}*/
    7474};
  • issm/trunk-jpl/src/c/classes/Params/Param.h

    r20690 r20827  
    2525
    2626                /*Virtual functions:*/
     27                virtual Param* copy()=0;
    2728                virtual void  Echo()=0;
    28                 virtual int   ObjectEnum()=0;
    29                 virtual Param* copy()=0;
    30                 virtual void Marshall(char** pmarshalled_data, int* pmarshalled_data_size, int marshall_direction)=0;
    31                 virtual int   InstanceEnum()=0;
    3229                virtual void  GetParameterValue(bool* pbool)=0;
    3330                virtual void  GetParameterValue(int* pinteger)=0;
     
    4542                virtual void  GetParameterValue(FILE** pfid)=0;
    4643                virtual void  GetParameterValue(DataSet** pdataset)=0;
     44                virtual int   InstanceEnum()=0;
     45                virtual void Marshall(char** pmarshalled_data, int* pmarshalled_data_size, int marshall_direction)=0;
     46                virtual int   ObjectEnum()=0;
    4747
     48                virtual void  SetEnum(int enum_in)=0;
    4849                virtual void  SetValue(bool boolean)=0;
    4950                virtual void  SetValue(int integer)=0;
     
    5960                virtual void  SetValue(FILE* fid)=0;
    6061                virtual void  SetValue(IssmDouble** array, int M, int* mdim_array, int* ndim_array)=0;
    61                 virtual void  SetEnum(int enum_in)=0;
    6262};
    6363#endif
  • issm/trunk-jpl/src/c/classes/Params/Parameters.cpp

    r20638 r20827  
    8989}
    9090/*}}}*/
     91void Parameters::DeepEcho(void){/*{{{*/
     92        _error_("not implemented yet");
     93}
     94/*}}}*/
     95void Parameters::Echo(void){/*{{{*/
     96        _error_("not implemented yet");
     97}
     98/*}}}*/
    9199void Parameters::Marshall(char** pmarshalled_data, int* pmarshalled_data_size, int marshall_direction){/*{{{*/
    92100
     
    209217                }
    210218        }
    211 }
    212 /*}}}*/
    213 void Parameters::Echo(void){/*{{{*/
    214         _error_("not implemented yet");
    215 }
    216 /*}}}*/
    217 void Parameters::DeepEcho(void){/*{{{*/
    218         _error_("not implemented yet");
    219219}
    220220/*}}}*/
  • issm/trunk-jpl/src/c/classes/Params/Parameters.h

    r20635 r20827  
    2828
    2929                /*numerics*/
    30                 bool  Exist(int enum_type);
    3130                void  AddObject(Param* newparam);
    3231                Parameters* Copy(void);
     32                void  DeepEcho();
     33                void  Echo();
     34                bool  Exist(int enum_type);
    3335                void  Marshall(char** pmarshalled_data, int* pmarshalled_data_size, int marshall_direction);
    34                 void  Echo();
    35                 void  DeepEcho();
    3636
    3737                void  FindParam(bool* pinteger,int enum_type);
  • issm/trunk-jpl/src/c/classes/Params/StringArrayParam.cpp

    r20690 r20827  
    5656
    5757/*Object virtual functions definitions:*/
    58 void StringArrayParam::Echo(void){/*{{{*/
    59         this->DeepEcho();
     58Param* StringArrayParam::copy() {/*{{{*/
     59
     60        return new StringArrayParam(this->enum_type,this->value,this->numstrings);
     61
    6062}
    6163/*}}}*/
     
    6769}
    6870/*}}}*/
    69 int    StringArrayParam::Id(void){ return -1; }/*{{{*/
    70 /*}}}*/
    71 int StringArrayParam::ObjectEnum(void){/*{{{*/
    72 
    73         return StringArrayParamEnum;
    74 
     71void StringArrayParam::Echo(void){/*{{{*/
     72        this->DeepEcho();
    7573}
    7674/*}}}*/
    77 Param* StringArrayParam::copy() {/*{{{*/
    78 
    79         return new StringArrayParam(this->enum_type,this->value,this->numstrings);
    80 
    81 }
     75int    StringArrayParam::Id(void){ return -1; }/*{{{*/
    8276/*}}}*/
    8377void StringArrayParam::Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ /*{{{*/
     
    10498        //cleanup sizes array
    10599        if(sizes) xDelete<int>(sizes);
     100
     101}
     102/*}}}*/
     103int StringArrayParam::ObjectEnum(void){/*{{{*/
     104
     105        return StringArrayParamEnum;
    106106
    107107}
  • issm/trunk-jpl/src/c/classes/Params/StringArrayParam.h

    r20690 r20827  
    3232                /*}}}*/
    3333                /*Object virtual functions definitions:{{{ */
     34                Param* copy();
     35                void  DeepEcho();
    3436                void  Echo();
    35                 void  DeepEcho();
    3637                int   Id();
     38                void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);
    3739                int   ObjectEnum();
    38                 Param* copy();
    39                 void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);
    4040                /*}}}*/
    4141                /*Param vritual function definitions: {{{*/
    42                 int   InstanceEnum(){return enum_type;}
    4342                void  GetParameterValue(bool* pbool){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a bool");}
    4443                void  GetParameterValue(int* pinteger){_error_("Param "<< EnumToStringx(enum_type) << " cannot return an integer");}
     
    5655                void  GetParameterValue(FILE** pfid){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a FILE");}
    5756                void  GetParameterValue(DataSet** pdataset){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a DataSet");}
     57                int   InstanceEnum(){return enum_type;}
    5858
     59                void  SetEnum(int enum_in){this->enum_type = enum_in;};
    5960                void  SetValue(bool boolean){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a boolean");}
    6061                void  SetValue(int integer){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold an integer");}
     
    7071                void  SetValue(FILE* fid){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a FILE");}
    7172                void  SetValue(IssmDouble** array, int M, int* mdim_array, int* ndim_array){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold an array of matrices");}
    72                 void  SetEnum(int enum_in){this->enum_type = enum_in;};
    7373                /*}}}*/
    7474};
  • issm/trunk-jpl/src/c/classes/Params/StringParam.cpp

    r20635 r20827  
    3434
    3535/*Object virtual functions definitions:*/
    36 void StringParam::Echo(void){/*{{{*/
    37         this->DeepEcho();
     36Param* StringParam::copy() {/*{{{*/
     37
     38        return new StringParam(this->enum_type,this->value);
     39
    3840}
    3941/*}}}*/
     
    4244}
    4345/*}}}*/
    44 int    StringParam::Id(void){ return -1; }/*{{{*/
    45 /*}}}*/
    46 int StringParam::ObjectEnum(void){/*{{{*/
    47 
    48         return StringParamEnum;
    49 
     46void StringParam::Echo(void){/*{{{*/
     47        this->DeepEcho();
    5048}
    5149/*}}}*/
    52 Param* StringParam::copy() {/*{{{*/
    53 
    54         return new StringParam(this->enum_type,this->value);
    55 
    56 }
     50int    StringParam::Id(void){ return -1; }/*{{{*/
    5751/*}}}*/
    5852void StringParam::Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ /*{{{*/
     
    6660        MARSHALLING(size);
    6761        MARSHALLING_DYNAMIC(value,char,size);
     62
     63}
     64/*}}}*/
     65int StringParam::ObjectEnum(void){/*{{{*/
     66
     67        return StringParamEnum;
    6868
    6969}
  • issm/trunk-jpl/src/c/classes/Params/StringParam.h

    r20690 r20827  
    3232                /*}}}*/
    3333                /*Object virtual functions definitions:{{{ */
     34                Param* copy();
     35                void  DeepEcho();
    3436                void  Echo();
    35                 void  DeepEcho();
    3637                int   Id();
     38                void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);
    3739                int   ObjectEnum();
    38                 Param* copy();
    39                 void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);
    4040                /*}}}*/
    4141                /*Param vritual function definitions: {{{*/
    42                 int   InstanceEnum(){return enum_type;}
    4342                void  GetParameterValue(bool* pbool){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a bool");}
    4443                void  GetParameterValue(int* pinteger){_error_("Param "<< EnumToStringx(enum_type) << " cannot return an integer");}
     
    5655                void  GetParameterValue(FILE** pfid){_error_("Bool param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a FILE");}
    5756                void  GetParameterValue(DataSet** pdataset){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a DataSet");}
     57                int   InstanceEnum(){return enum_type;}
    5858
     59                void  SetEnum(int enum_in){this->enum_type = enum_in;};
    5960                void  SetValue(bool boolean){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a boolean");}
    6061                void  SetValue(int integer){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold an integer");}
     
    7071                void  SetValue(FILE* fid){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a FILE");}
    7172                void  SetValue(IssmDouble** array, int M, int* mdim_array, int* ndim_array){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold an array of matrices");}
    72                 void  SetEnum(int enum_in){this->enum_type = enum_in;};
    7373                /*}}}*/
    7474};
  • issm/trunk-jpl/src/c/classes/Params/TransientParam.cpp

    r20635 r20827  
    4242
    4343/*Object virtual functions definitions:*/
    44 void TransientParam::Echo(void){/*{{{*/
     44Param* TransientParam::copy() {/*{{{*/
    4545
    46         _printf_("TransientParam:\n");
    47         _printf_("   enum: " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")\n");
    48         _printf_("   size: " << this->N << "\n");
     46        return new TransientParam(this->enum_type,this->values,this->timesteps,this->interpolation,this->N);
    4947
    5048}
     
    6058}
    6159/*}}}*/
    62 int  TransientParam::Id(void){ return -1; }/*{{{*/
    63 /*}}}*/
    64 int  TransientParam::ObjectEnum(void){/*{{{*/
     60void TransientParam::Echo(void){/*{{{*/
    6561
    66         return TransientParamEnum;
     62        _printf_("TransientParam:\n");
     63        _printf_("   enum: " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")\n");
     64        _printf_("   size: " << this->N << "\n");
    6765
    6866}
    6967/*}}}*/
    70 Param* TransientParam::copy() {/*{{{*/
    71 
    72         return new TransientParam(this->enum_type,this->values,this->timesteps,this->interpolation,this->N);
    73 
    74 }
     68int  TransientParam::Id(void){ return -1; }/*{{{*/
    7569/*}}}*/
    7670void TransientParam::Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ /*{{{*/
     
    8781        MARSHALLING_ARRAY(values,IssmDouble,N);
    8882        MARSHALLING_ARRAY(timesteps,IssmDouble,N);
     83
     84}
     85/*}}}*/
     86int  TransientParam::ObjectEnum(void){/*{{{*/
     87
     88        return TransientParamEnum;
    8989
    9090}
  • issm/trunk-jpl/src/c/classes/Params/TransientParam.h

    r20690 r20827  
    3434                /*}}}*/
    3535                /*Object virtual functions definitions:{{{ */
     36                Param* copy();
     37                void  DeepEcho();
    3638                void  Echo();
    37                 void  DeepEcho();
    3839                int   Id();
     40                void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);
    3941                int   ObjectEnum();
    40                 Param* copy();
    41                 void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);
    4242                /*}}}*/
    4343                /*Param vritual function definitions: {{{*/
    44                 int   InstanceEnum(){return enum_type;}
    4544                void  GetParameterValue(bool* pbool){_error_("Parameter " <<EnumToStringx(enum_type) << " cannot return a bool");}
    4645                void  GetParameterValue(int* pinteger){_error_("Parameter " <<EnumToStringx(enum_type) << " cannot return an integer");}
     
    5857                void  GetParameterValue(FILE** pfid){_error_("Parameter " <<EnumToStringx(enum_type) << " cannot return a FILE");}
    5958                void  GetParameterValue(DataSet** pdataset){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a DataSet");}
     59                int   InstanceEnum(){return enum_type;}
    6060
     61                void  SetEnum(int enum_in){this->enum_type = enum_in;};
    6162                void  SetValue(bool boolean){_error_("Parameter " <<EnumToStringx(enum_type) << " cannot hold a boolean");}
    6263                void  SetValue(int integer){_error_("Parameter " <<EnumToStringx(enum_type) << " cannot hold an integer");}
     
    7273                void  SetValue(FILE* fid){_error_("Parameter " <<EnumToStringx(enum_type) << " cannot hold a FILE");}
    7374                void  SetValue(IssmDouble** array, int M, int* mdim_array, int* ndim_array){_error_("Parameter " <<EnumToStringx(enum_type) << " cannot hold an array of matrices");}
    74                 void  SetEnum(int enum_in){this->enum_type = enum_in;};
    7575                /*}}}*/
    7676};
  • issm/trunk-jpl/src/c/classes/Params/VectorParam.cpp

    r20635 r20827  
    3838
    3939/*Object virtual functions definitions:*/
    40 void VectorParam::Echo(void){/*{{{*/
     40Param* VectorParam::copy() {/*{{{*/
    4141
    42         _printf_("VectorParam:\n");
    43         _printf_("   enum: " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")\n");
     42        return new VectorParam(this->enum_type,this->value);
    4443
    4544}
     
    5251}
    5352/*}}}*/
     53void VectorParam::Echo(void){/*{{{*/
     54
     55        _printf_("VectorParam:\n");
     56        _printf_("   enum: " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")\n");
     57
     58}
     59/*}}}*/
    5460int    VectorParam::Id(void){ return -1; }/*{{{*/
    5561/*}}}*/
     
    5763
    5864        return VectorParamEnum;
    59 
    60 }
    61 /*}}}*/
    62 Param* VectorParam::copy() {/*{{{*/
    63 
    64         return new VectorParam(this->enum_type,this->value);
    6565
    6666}
  • issm/trunk-jpl/src/c/classes/Params/VectorParam.h

    r20690 r20827  
    3232                /*}}}*/
    3333                /*Object virtual functions definitions:{{{ */
     34                Param* copy();
     35                void  DeepEcho();
    3436                void  Echo();
    35                 void  DeepEcho();
    3637                int   Id();
     38                void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ _error_("not implemented yet!"); };
    3739                int   ObjectEnum();
    38                 Param* copy();
    39                 void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ _error_("not implemented yet!"); };
    4040                /*}}}*/
    4141                /*Param vritual function definitions: {{{*/
    42                 int   InstanceEnum(){return enum_type;}
    4342                void  GetParameterValue(bool* pbool){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a bool");}
    4443                void  GetParameterValue(int* pinteger){_error_("Param "<< EnumToStringx(enum_type) << " cannot return an integer");}
     
    5655                void  GetParameterValue(FILE** pfid){_error_("Vector of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a FILE");}
    5756                void  GetParameterValue(DataSet** pdataset){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a DataSet");}
     57                int   InstanceEnum(){return enum_type;}
    5858
     59                void  SetEnum(int enum_in){this->enum_type = enum_in;};
    5960                void  SetValue(bool boolean){_error_("Vector of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a boolean");}
    6061                void  SetValue(int integer){_error_("Vector of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold an integer");}
     
    7071                void  SetValue(FILE* fid){_error_("Vector of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a FILE");}
    7172                void  SetValue(IssmDouble** array, int M, int* mdim_array, int* ndim_array){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold an array of matrices");}
    72                 void  SetEnum(int enum_in){this->enum_type = enum_in;};
    7373                /*}}}*/
    7474};
  • issm/trunk-jpl/src/c/classes/gauss/Gauss.h

    r16892 r20827  
    1313                virtual        ~Gauss(){};
    1414                virtual int  begin(void)=0;
     15                virtual void Echo(void)=0;
    1516                virtual int  end(void)=0;
    16                 virtual void Echo(void)=0;
    1717                virtual int  Enum(void)=0;
     18                virtual void GaussNode(int finitelement,int iv)=0;
    1819                virtual void GaussPoint(int ig)=0;
    1920                virtual void GaussVertex(int iv)=0;
    20                 virtual void GaussNode(int finitelement,int iv)=0;
    2121                virtual void SynchronizeGaussBase(Gauss* gauss)=0;
    2222
  • issm/trunk-jpl/src/c/classes/gauss/GaussPenta.cpp

    r20215 r20827  
    443443
    444444/*Methods*/
     445int GaussPenta::begin(void){/*{{{*/
     446
     447        /*Check that this has been initialized*/
     448        _assert_(numgauss>0);
     449        _assert_(weights);
     450        _assert_(coords1);
     451        _assert_(coords2);
     452        _assert_(coords3);
     453        _assert_(coords4);
     454
     455        /*return first gauss index*/
     456        return 0;
     457}
     458/*}}}*/
    445459void GaussPenta::Echo(void){/*{{{*/
    446460
     
    487501}
    488502/*}}}*/
     503int GaussPenta::end(void){/*{{{*/
     504
     505        /*Check that this has been initialized*/
     506        _assert_(numgauss>0);
     507        _assert_(weights);
     508        _assert_(coords1);
     509        _assert_(coords2);
     510        _assert_(coords3);
     511        _assert_(coords4);
     512
     513        /*return last gauss index +1*/
     514        return numgauss;
     515}
     516/*}}}*/
    489517int GaussPenta::Enum(void){/*{{{*/
    490518        return GaussPentaEnum;
     519}
     520/*}}}*/
     521void GaussPenta::GaussFaceTria(int index1, int index2, int index3, int order){/*{{{*/
     522
     523        /*in debugging mode: check that the default constructor has been called*/
     524        _assert_(numgauss==-1);
     525
     526        /*Basal Tria*/
     527        if(index1==0 && index2==1 && index3==2){
     528                GaussLegendreTria(&numgauss,&coords1,&coords2,&coords3,&weights,order);
     529                coords4=xNew<IssmDouble>(numgauss);
     530                for(int i=0;i<numgauss;i++) coords4[i]=-1.0;
     531        }
     532        else{
     533                _error_("Tria not supported yet");
     534        }
     535
    491536}
    492537/*}}}*/
     
    502547         coord3=coords3[ig];
    503548         coord4=coords4[ig];
    504 
    505 }
    506 /*}}}*/
    507 void GaussPenta::GaussVertex(int iv){/*{{{*/
    508 
    509         /*in debugging mode: check that the default constructor has been called*/
    510         _assert_(numgauss==-1);
    511 
    512         /*update static arrays*/
    513         switch(iv){
    514                 case 0: coord1=1.; coord2=0.; coord3=0.; coord4= -1.; break;
    515                 case 1: coord1=0.; coord2=1.; coord3=0.; coord4= -1.; break;
    516                 case 2: coord1=0.; coord2=0.; coord3=1.; coord4= -1.; break;
    517                 case 3: coord1=1.; coord2=0.; coord3=0.; coord4= +1.; break;
    518                 case 4: coord1=0.; coord2=1.; coord3=0.; coord4= +1.; break;
    519                 case 5: coord1=0.; coord2=0.; coord3=1.; coord4= +1.; break;
    520                 default: _error_("vertex index should be in [0 5]");
    521 
    522         }
    523 
    524 }
    525 /*}}}*/
    526 void GaussPenta::GaussFaceTria(int index1, int index2, int index3, int order){/*{{{*/
    527 
    528         /*in debugging mode: check that the default constructor has been called*/
    529         _assert_(numgauss==-1);
    530 
    531         /*Basal Tria*/
    532         if(index1==0 && index2==1 && index3==2){
    533                 GaussLegendreTria(&numgauss,&coords1,&coords2,&coords3,&weights,order);
    534                 coords4=xNew<IssmDouble>(numgauss);
    535                 for(int i=0;i<numgauss;i++) coords4[i]=-1.0;
    536         }
    537         else{
    538                 _error_("Tria not supported yet");
    539         }
    540549
    541550}
     
    720729}
    721730/*}}}*/
    722 int GaussPenta::begin(void){/*{{{*/
    723 
    724         /*Check that this has been initialized*/
    725         _assert_(numgauss>0);
    726         _assert_(weights);
    727         _assert_(coords1);
    728         _assert_(coords2);
    729         _assert_(coords3);
    730         _assert_(coords4);
    731 
    732         /*return first gauss index*/
    733         return 0;
    734 }
    735 /*}}}*/
    736 int GaussPenta::end(void){/*{{{*/
    737 
    738         /*Check that this has been initialized*/
    739         _assert_(numgauss>0);
    740         _assert_(weights);
    741         _assert_(coords1);
    742         _assert_(coords2);
    743         _assert_(coords3);
    744         _assert_(coords4);
    745 
    746         /*return last gauss index +1*/
    747         return numgauss;
     731void GaussPenta::GaussVertex(int iv){/*{{{*/
     732
     733        /*in debugging mode: check that the default constructor has been called*/
     734        _assert_(numgauss==-1);
     735
     736        /*update static arrays*/
     737        switch(iv){
     738                case 0: coord1=1.; coord2=0.; coord3=0.; coord4= -1.; break;
     739                case 1: coord1=0.; coord2=1.; coord3=0.; coord4= -1.; break;
     740                case 2: coord1=0.; coord2=0.; coord3=1.; coord4= -1.; break;
     741                case 3: coord1=1.; coord2=0.; coord3=0.; coord4= +1.; break;
     742                case 4: coord1=0.; coord2=1.; coord3=0.; coord4= +1.; break;
     743                case 5: coord1=0.; coord2=0.; coord3=1.; coord4= +1.; break;
     744                default: _error_("vertex index should be in [0 5]");
     745
     746        }
     747
    748748}
    749749/*}}}*/
  • issm/trunk-jpl/src/c/classes/gauss/GaussPenta.h

    r16892 r20827  
    4141                /*Methods*/
    4242                int  begin(void);
     43                void Echo(void);
    4344                int  end(void);
    44                 void Echo(void);
    4545                int  Enum(void);
     46                void GaussFaceTria(int index1, int index2, int index3, int order);
     47                void GaussNode(int finitelement,int iv);
    4648                void GaussPoint(int ig);
    4749                void GaussVertex(int iv);
    48                 void GaussNode(int finitelement,int iv);
    49                 void GaussFaceTria(int index1, int index2, int index3, int order);
    5050                void SynchronizeGaussBase(Gauss* gauss);
    5151};
  • issm/trunk-jpl/src/c/classes/gauss/GaussSeg.cpp

    r18064 r20827  
    7474
    7575/*Methods*/
     76int GaussSeg::begin(void){/*{{{*/
     77
     78        /*Check that this has been initialized*/
     79        _assert_(numgauss>0);
     80        _assert_(weights);
     81        _assert_(coords1);
     82
     83        /*return first gauss index*/
     84        return 0;
     85}
     86/*}}}*/
    7687void GaussSeg::Echo(void){/*{{{*/
    7788
     
    95106}
    96107/*}}}*/
     108int GaussSeg::end(void){/*{{{*/
     109
     110        /*Check that this has been initialized*/
     111        _assert_(numgauss>0);
     112        _assert_(weights);
     113        _assert_(coords1);
     114
     115        /*return last gauss index +1*/
     116        return numgauss;
     117}
     118/*}}}*/
    97119int GaussSeg::Enum(void){/*{{{*/
    98120        return GaussSegEnum;
     
    107129         weight=weights[ig];
    108130         coord1=coords1[ig];
    109 }
    110 /*}}}*/
    111 void GaussSeg::GaussVertex(int iv){/*{{{*/
    112 
    113         /*in debugging mode: check that the default constructor has been called*/
    114         _assert_(numgauss==-1);
    115 
    116         /*update static arrays*/
    117         switch(iv){
    118                 case 0: coord1=-1.; break;
    119                 case 1: coord1=+1.; break;
    120                 default: _error_("vertex index should be in [0 1]");
    121         }
    122131}
    123132/*}}}*/
     
    141150}
    142151/*}}}*/
    143 int GaussSeg::begin(void){/*{{{*/
     152void GaussSeg::GaussVertex(int iv){/*{{{*/
    144153
    145         /*Check that this has been initialized*/
    146         _assert_(numgauss>0);
    147         _assert_(weights);
    148         _assert_(coords1);
     154        /*in debugging mode: check that the default constructor has been called*/
     155        _assert_(numgauss==-1);
    149156
    150         /*return first gauss index*/
    151         return 0;
    152 }
    153 /*}}}*/
    154 int GaussSeg::end(void){/*{{{*/
    155 
    156         /*Check that this has been initialized*/
    157         _assert_(numgauss>0);
    158         _assert_(weights);
    159         _assert_(coords1);
    160 
    161         /*return last gauss index +1*/
    162         return numgauss;
     157        /*update static arrays*/
     158        switch(iv){
     159                case 0: coord1=-1.; break;
     160                case 1: coord1=+1.; break;
     161                default: _error_("vertex index should be in [0 1]");
     162        }
    163163}
    164164/*}}}*/
  • issm/trunk-jpl/src/c/classes/gauss/GaussSeg.h

    r17310 r20827  
    3030                /*Methods*/
    3131                int  begin(void);
     32                void Echo(void);
    3233                int  end(void);
    33                 void Echo(void);
    3434                int  Enum(void);
    3535                void GaussPoint(int ig);
     36                void GaussNode(int finitelement,int iv);
    3637                void GaussVertex(int iv);
    37                 void GaussNode(int finitelement,int iv);
    3838                void SynchronizeGaussBase(Gauss* gauss);
    3939};
  • issm/trunk-jpl/src/c/classes/gauss/GaussTetra.cpp

    r18064 r20827  
    9494
    9595/*Methods*/
     96int GaussTetra::begin(void){/*{{{*/
     97
     98        /*Check that this has been initialized*/
     99        _assert_(numgauss>0);
     100        _assert_(weights);
     101        _assert_(coords1);
     102        _assert_(coords2);
     103        _assert_(coords3);
     104        _assert_(coords4);
     105
     106        /*return first gauss index*/
     107        return 0;
     108}
     109/*}}}*/
    96110void GaussTetra::Echo(void){/*{{{*/
    97111
     
    136150        _printf_("   coord4 = " << coord4 << "\n");
    137151
     152}
     153/*}}}*/
     154int GaussTetra::end(void){/*{{{*/
     155
     156        /*Check that this has been initialized*/
     157        _assert_(numgauss>0);
     158        _assert_(weights);
     159        _assert_(coords1);
     160        _assert_(coords2);
     161        _assert_(coords3);
     162        _assert_(coords4);
     163
     164        /*return last gauss index +1*/
     165        return numgauss;
    138166}
    139167/*}}}*/
     
    153181         coord3=coords3[ig];
    154182         coord4=coords4[ig];
    155 
    156 }
    157 /*}}}*/
    158 void GaussTetra::GaussVertex(int iv){/*{{{*/
    159 
    160         /*in debugging mode: check that the default constructor has been called*/
    161         _assert_(numgauss==-1);
    162 
    163         /*update static arrays*/
    164         switch(iv){
    165                 case 0: coord1=1.; coord2=0.; coord3=0.; coord4=0.; break;
    166                 case 1: coord1=0.; coord2=1.; coord3=0.; coord4=0.; break;
    167                 case 2: coord1=0.; coord2=0.; coord3=1.; coord4=0.; break;
    168                 case 3: coord1=0.; coord2=0.; coord3=0.; coord4=1.; break;
    169                 default: _error_("vertex index should be in [0 3]");
    170 
    171         }
    172183
    173184}
     
    220231}
    221232/*}}}*/
    222 int GaussTetra::begin(void){/*{{{*/
    223 
    224         /*Check that this has been initialized*/
    225         _assert_(numgauss>0);
    226         _assert_(weights);
    227         _assert_(coords1);
    228         _assert_(coords2);
    229         _assert_(coords3);
    230         _assert_(coords4);
    231 
    232         /*return first gauss index*/
    233         return 0;
    234 }
    235 /*}}}*/
    236 int GaussTetra::end(void){/*{{{*/
    237 
    238         /*Check that this has been initialized*/
    239         _assert_(numgauss>0);
    240         _assert_(weights);
    241         _assert_(coords1);
    242         _assert_(coords2);
    243         _assert_(coords3);
    244         _assert_(coords4);
    245 
    246         /*return last gauss index +1*/
    247         return numgauss;
     233void GaussTetra::GaussVertex(int iv){/*{{{*/
     234
     235        /*in debugging mode: check that the default constructor has been called*/
     236        _assert_(numgauss==-1);
     237
     238        /*update static arrays*/
     239        switch(iv){
     240                case 0: coord1=1.; coord2=0.; coord3=0.; coord4=0.; break;
     241                case 1: coord1=0.; coord2=1.; coord3=0.; coord4=0.; break;
     242                case 2: coord1=0.; coord2=0.; coord3=1.; coord4=0.; break;
     243                case 3: coord1=0.; coord2=0.; coord3=0.; coord4=1.; break;
     244                default: _error_("vertex index should be in [0 3]");
     245
     246        }
     247
    248248}
    249249/*}}}*/
  • issm/trunk-jpl/src/c/classes/gauss/GaussTetra.h

    r17472 r20827  
    3636                /*Methods*/
    3737                int  begin(void);
     38                void Echo(void);
    3839                int  end(void);
    39                 void Echo(void);
    4040                int  Enum(void);
    4141                void GaussPoint(int ig);
     42                void GaussNode(int finitelement,int iv);
    4243                void GaussVertex(int iv);
    43                 void GaussNode(int finitelement,int iv);
    4444                void SynchronizeGaussBase(Gauss* gauss);
    4545};
  • issm/trunk-jpl/src/c/classes/gauss/GaussTria.cpp

    r18170 r20827  
    297297
    298298/*Methods*/
     299int GaussTria::begin(void){/*{{{*/
     300
     301        /*Check that this has been initialized*/
     302        _assert_(numgauss>0);
     303        _assert_(weights);
     304        _assert_(coords1);
     305        _assert_(coords2);
     306        _assert_(coords3);
     307
     308        /*return first gauss index*/
     309        return 0;
     310}
     311/*}}}*/
    299312void GaussTria::Echo(void){/*{{{*/
    300313
     
    334347}
    335348/*}}}*/
     349int GaussTria::end(void){/*{{{*/
     350
     351        /*Check that this has been initialized*/
     352        _assert_(numgauss>0);
     353        _assert_(weights);
     354        _assert_(coords1);
     355        _assert_(coords2);
     356        _assert_(coords3);
     357
     358        /*return last gauss index +1*/
     359        return numgauss;
     360}
     361/*}}}*/
    336362int GaussTria::Enum(void){/*{{{*/
    337363        return GaussTriaEnum;
     
    368394}
    369395/*}}}*/
     396void GaussTria::GaussFromCoords(IssmDouble x,IssmDouble y,IssmDouble* xyz_list){/*{{{*/
     397
     398        /*Intermediaries*/
     399        IssmDouble    area = 0;
     400        IssmDouble    x1,y1,x2,y2,x3,y3;
     401
     402        /*in debugging mode: check that the default constructor has been called*/
     403        _assert_(numgauss==-1);
     404
     405        x1=*(xyz_list+3*0+0); y1=*(xyz_list+3*0+1);
     406        x2=*(xyz_list+3*1+0); y2=*(xyz_list+3*1+1);
     407        x3=*(xyz_list+3*2+0); y3=*(xyz_list+3*2+1);
     408
     409        area=(x2*y3 - y2*x3 + x1*y2 - y1*x2 + x3*y1 - y3*x1)/2;
     410
     411        /*Get first area coordinate = det(x-x3  x2-x3 ; y-y3   y2-y3)/area*/
     412        coord1=((x-x3)*(y2-y3)-(x2-x3)*(y-y3))/area;
     413
     414        /*Get second area coordinate = det(x1-x3  x-x3 ; y1-y3   y-y3)/area*/
     415        coord2=((x1-x3)*(y-y3)-(x-x3)*(y1-y3))/area;
     416
     417        /*Get third  area coordinate 1-area1-area2: */
     418        coord3=1-coord1-coord2;
     419
     420}
     421/*}}}*/
    370422void GaussTria::GaussPoint(int ig){/*{{{*/
    371423
     
    378430         coord2=coords2[ig];
    379431         coord3=coords3[ig];
    380 
    381 }
    382 /*}}}*/
    383 void GaussTria::GaussFromCoords(IssmDouble x,IssmDouble y,IssmDouble* xyz_list){/*{{{*/
    384 
    385         /*Intermediaries*/
    386         IssmDouble    area = 0;
    387         IssmDouble    x1,y1,x2,y2,x3,y3;
    388 
    389         /*in debugging mode: check that the default constructor has been called*/
    390         _assert_(numgauss==-1);
    391 
    392         x1=*(xyz_list+3*0+0); y1=*(xyz_list+3*0+1);
    393         x2=*(xyz_list+3*1+0); y2=*(xyz_list+3*1+1);
    394         x3=*(xyz_list+3*2+0); y3=*(xyz_list+3*2+1);
    395 
    396         area=(x2*y3 - y2*x3 + x1*y2 - y1*x2 + x3*y1 - y3*x1)/2;
    397 
    398         /*Get first area coordinate = det(x-x3  x2-x3 ; y-y3   y2-y3)/area*/
    399         coord1=((x-x3)*(y2-y3)-(x2-x3)*(y-y3))/area;
    400 
    401         /*Get second area coordinate = det(x1-x3  x-x3 ; y1-y3   y-y3)/area*/
    402         coord2=((x1-x3)*(y-y3)-(x-x3)*(y1-y3))/area;
    403 
    404         /*Get third  area coordinate 1-area1-area2: */
    405         coord3=1-coord1-coord2;
    406 
    407 }
    408 /*}}}*/
    409 void GaussTria::GaussVertex(int iv){/*{{{*/
    410 
    411         /*in debugging mode: check that the default constructor has been called*/
    412         _assert_(numgauss==-1);
    413 
    414         /*update static arrays*/
    415         switch(iv){
    416                 case 0: coord1=1.; coord2=0.; coord3=0.; break;
    417                 case 1: coord1=0.; coord2=1.; coord3=0.; break;
    418                 case 2: coord1=0.; coord2=0.; coord3=1.; break;
    419                 default: _error_("vertex index should be in [0 2]");
    420         }
    421432
    422433}
     
    480491}
    481492/*}}}*/
    482 int GaussTria::begin(void){/*{{{*/
    483 
    484         /*Check that this has been initialized*/
    485         _assert_(numgauss>0);
    486         _assert_(weights);
    487         _assert_(coords1);
    488         _assert_(coords2);
    489         _assert_(coords3);
    490 
    491         /*return first gauss index*/
    492         return 0;
    493 }
    494 /*}}}*/
    495 int GaussTria::end(void){/*{{{*/
    496 
    497         /*Check that this has been initialized*/
    498         _assert_(numgauss>0);
    499         _assert_(weights);
    500         _assert_(coords1);
    501         _assert_(coords2);
    502         _assert_(coords3);
    503 
    504         /*return last gauss index +1*/
    505         return numgauss;
     493void GaussTria::GaussVertex(int iv){/*{{{*/
     494
     495        /*in debugging mode: check that the default constructor has been called*/
     496        _assert_(numgauss==-1);
     497
     498        /*update static arrays*/
     499        switch(iv){
     500                case 0: coord1=1.; coord2=0.; coord3=0.; break;
     501                case 1: coord1=0.; coord2=1.; coord3=0.; break;
     502                case 2: coord1=0.; coord2=0.; coord3=1.; break;
     503                default: _error_("vertex index should be in [0 2]");
     504        }
     505
    506506}
    507507/*}}}*/
  • issm/trunk-jpl/src/c/classes/gauss/GaussTria.h

    r16892 r20827  
    3636                /*Methods*/
    3737                int  begin(void);
     38                void Echo(void);
    3839                int  end(void);
    39                 void Echo(void);
    4040                int  Enum(void);
     41                void GaussEdgeCenter(int index1,int index2);
    4142                void GaussFromCoords(IssmDouble x1,IssmDouble y1,IssmDouble* xyz_list);
    4243                void GaussPoint(int ig);
     44                void GaussNode(int finitelement,int iv);
    4345                void GaussVertex(int iv);
    44                 void GaussNode(int finitelement,int iv);
    45                 void GaussEdgeCenter(int index1,int index2);
    4646                void SynchronizeGaussBase(Gauss* gauss);
    4747};
  • issm/trunk-jpl/src/c/classes/kriging/Covertree.cpp

    r19153 r20827  
    3131
    3232        /*Methods*/
     33std::pair<double, Covertree::CoverTreeNode*>            Covertree::distance(const Observation& p, const std::vector<CoverTreeNode*>& Q){/*{{{*/
     34        double minDist = 1.e+50;
     35        CoverTreeNode* minNode;
     36        std::vector<CoverTreeNode*>::const_iterator it;
     37        for(it=Q.begin();it!=Q.end();++it) {
     38                double dist = p.distance((*it)->getObservation());
     39                if(dist < minDist) {
     40                        minDist = dist;
     41                        minNode = *it;
     42                }
     43        }
     44        return std::make_pair(minDist,minNode); 
     45}/*}}}*/
     46int Covertree::get_numberofobs(){/*{{{*/
     47        return _numNodes;
     48}/*}}}*/
     49void   Covertree::insert(const Observation& newObservation){/*{{{*/
     50        if(_root==NULL) {
     51                _root = new CoverTreeNode(newObservation);
     52                _numNodes=1;
     53                return;
     54        }
     55        //TODO: this is pretty inefficient, there may be a better way
     56        //to check if the node already exists...
     57        CoverTreeNode* n = kNearestNodes(newObservation,1)[0];
     58        if(newObservation.distance(n->getObservation())==0.0) {
     59                n->addObservation(newObservation);
     60        } else {
     61                //insert_rec acts under the assumption that there are no nodes with
     62                //distance 0 to newObservation in the cover tree (the previous lines check it)
     63                insert_rec(newObservation,
     64                                        std::vector<distNodePair>
     65                                        (1,std::make_pair(_root->distance(newObservation),_root)),
     66                                        _maxLevel);
     67        }
     68}/*}}}*/
     69bool            Covertree::insert_rec(const Observation& p, const std::vector<distNodePair>& Qi, const int& level){/*{{{*/
     70        std::vector<std::pair<double, CoverTreeNode*> > Qj;
     71        double sep = pow(base,level);
     72        double minDist = 1.e+50;
     73        std::pair<double,CoverTreeNode*> minQiDist(1.e+50,NULL);
     74        std::vector<std::pair<double, CoverTreeNode*> >::const_iterator it;
     75        for(it=Qi.begin(); it!=Qi.end(); ++it) {
     76                if(it->first<minQiDist.first) minQiDist = *it;
     77                if(it->first<minDist) minDist=it->first;
     78                if(it->first<=sep) Qj.push_back(*it);
     79                std::vector<CoverTreeNode*> children = it->second->getChildren(level);
     80                std::vector<CoverTreeNode*>::const_iterator it2;
     81                for(it2=children.begin();it2!=children.end();++it2) {
     82                        double d = p.distance((*it2)->getObservation());
     83                        if(d<minDist) minDist = d;
     84                        if(d<=sep) {
     85                                Qj.push_back(std::make_pair(d,*it2));
     86                        }
     87                }
     88        }
     89        //std::cout << "level: " << level << ", sep: " << sep << ", dist: " << minQDist.first << "\n";
     90        if(minDist > sep) {
     91                return true;
     92        } else {
     93                bool found = insert_rec(p,Qj,level-1);
     94                //distNodePair minQiDist = distance(p,Qi);
     95                if(found && minQiDist.first <= sep) {
     96                        if(level-1<_minLevel) _minLevel=level-1;
     97                        minQiDist.second->addChild(level,
     98                                                new CoverTreeNode(p));
     99                        //std::cout << "parent is ";
     100                        //minQiDist.second->getObservation().print();
     101                        _numNodes++;
     102                        return false;
     103                } else {
     104                        return found;
     105                }
     106        }
     107}/*}}}*/
    33108std::vector<Covertree::CoverTreeNode*> Covertree::kNearestNodes(const Observation& p, const unsigned int& k) const{/*{{{*/
    34109        if(_root==NULL) return std::vector<CoverTreeNode*>();
     
    78153        return kNN;
    79154}/*}}}*/
    80 bool   Covertree::insert_rec(const Observation& p, const std::vector<distNodePair>& Qi, const int& level){/*{{{*/
    81         std::vector<std::pair<double, CoverTreeNode*> > Qj;
    82         double sep = pow(base,level);
    83         double minDist = 1.e+50;
    84         std::pair<double,CoverTreeNode*> minQiDist(1.e+50,NULL);
    85         std::vector<std::pair<double, CoverTreeNode*> >::const_iterator it;
    86         for(it=Qi.begin(); it!=Qi.end(); ++it) {
    87                 if(it->first<minQiDist.first) minQiDist = *it;
    88                 if(it->first<minDist) minDist=it->first;
    89                 if(it->first<=sep) Qj.push_back(*it);
    90                 std::vector<CoverTreeNode*> children = it->second->getChildren(level);
    91                 std::vector<CoverTreeNode*>::const_iterator it2;
    92                 for(it2=children.begin();it2!=children.end();++it2) {
    93                         double d = p.distance((*it2)->getObservation());
    94                         if(d<minDist) minDist = d;
    95                         if(d<=sep) {
    96                                 Qj.push_back(std::make_pair(d,*it2));
    97                         }
    98                 }
    99         }
    100         //std::cout << "level: " << level << ", sep: " << sep << ", dist: " << minQDist.first << "\n";
    101         if(minDist > sep) {
    102                 return true;
    103         } else {
    104                 bool found = insert_rec(p,Qj,level-1);
    105                 //distNodePair minQiDist = distance(p,Qi);
    106                 if(found && minQiDist.first <= sep) {
    107                         if(level-1<_minLevel) _minLevel=level-1;
    108                         minQiDist.second->addChild(level,
    109                                                 new CoverTreeNode(p));
    110                         //std::cout << "parent is ";
    111                         //minQiDist.second->getObservation().print();
    112                         _numNodes++;
    113                         return false;
     155std::vector<Observation> Covertree::kNearestNeighbors(const Observation& p, const unsigned int& k) const{/*{{{*/
     156        if(_root==NULL) return std::vector<Observation>();
     157        std::vector<CoverTreeNode*> v = kNearestNodes(p, k);
     158        std::vector<Observation> kNN;
     159        std::vector<CoverTreeNode*>::const_iterator it;
     160        for(it=v.begin();it!=v.end();++it) {
     161                const std::vector<Observation>& p = (*it)->getObservations();
     162                kNN.insert(kNN.end(),p.begin(),p.end());
     163                if(kNN.size() >= k) break;
     164        }
     165        return kNN;
     166}/*}}}*/
     167void   Covertree::print() const{/*{{{*/
     168        int d = _maxLevel-_minLevel+1;
     169        std::vector<CoverTreeNode*> Q;
     170        Q.push_back(_root);
     171        for(int i=0;i<d;i++) {
     172                std::cout << "LEVEL " << _maxLevel-i << "\n";
     173                std::vector<CoverTreeNode*>::const_iterator it;
     174                for(it=Q.begin();it!=Q.end();++it) {
     175                        (*it)->getObservation().print();
     176                        std::vector<CoverTreeNode*>
     177                          children = (*it)->getChildren(_maxLevel-i);
     178                        std::vector<CoverTreeNode*>::const_iterator it2;
     179                        for(it2=children.begin();it2!=children.end();++it2) {
     180                                std::cout << "  ";
     181                                (*it2)->getObservation().print();
     182                        }
     183                }
     184                std::vector<CoverTreeNode*> newQ;
     185                for(it=Q.begin();it!=Q.end();++it) {
     186                        std::vector<CoverTreeNode*>
     187                          children = (*it)->getChildren(_maxLevel-i);
     188                        newQ.insert(newQ.end(),children.begin(),children.end());
     189                }
     190                Q.insert(Q.end(),newQ.begin(),newQ.end());
     191                std::cout << "\n\n";
     192        }
     193}/*}}}*/
     194void   Covertree::remove(const Observation& p){/*{{{*/
     195        //Most of this function's code is for the special case of removing the root
     196        if(_root==NULL) return;
     197        bool removingRoot=_root->hasObservation(p);
     198        if(removingRoot && !_root->isSingle()) {
     199                _root->removeObservation(p);
     200                return;
     201        }
     202        CoverTreeNode* newRoot=NULL;
     203        if(removingRoot) {
     204                if(_numNodes==1) {
     205                        //removing the last node...
     206                        delete _root;
     207                        _numNodes--;
     208                        _root=NULL;
     209                        return;
    114210                } else {
    115                         return found;
    116                 }
     211                        for(int i=_maxLevel;i>_minLevel;i--) {
     212                                if(!(_root->getChildren(i).empty())) {
     213                                        newRoot = _root->getChildren(i).back();
     214                                        _root->removeChild(i,newRoot);
     215                                        break;
     216                                }
     217                        }
     218                }
     219        }
     220        std::map<int, std::vector<distNodePair> > coverSets;
     221        coverSets[_maxLevel].push_back(std::make_pair(_root->distance(p),_root));
     222        if(removingRoot)
     223         coverSets[_maxLevel].push_back(std::make_pair(newRoot->distance(p),newRoot));
     224        bool multi = false;
     225        remove_rec(p,coverSets,_maxLevel,multi);
     226        if(removingRoot) {
     227                delete _root;
     228                _numNodes--;
     229                _root=newRoot;
    117230        }
    118231}/*}}}*/
     
    219332        }
    220333}/*}}}*/
    221 int Covertree::get_numberofobs(){/*{{{*/
    222         return _numNodes;
    223 }/*}}}*/
    224 std::pair<double, Covertree::CoverTreeNode*> Covertree::distance(const Observation& p, const std::vector<CoverTreeNode*>& Q){/*{{{*/
    225         double minDist = 1.e+50;
    226         CoverTreeNode* minNode;
    227         std::vector<CoverTreeNode*>::const_iterator it;
    228         for(it=Q.begin();it!=Q.end();++it) {
    229                 double dist = p.distance((*it)->getObservation());
    230                 if(dist < minDist) {
    231                         minDist = dist;
    232                         minNode = *it;
    233                 }
    234         }
    235         return std::make_pair(minDist,minNode); 
    236 }/*}}}*/
    237 void   Covertree::insert(const Observation& newObservation){/*{{{*/
    238         if(_root==NULL) {
    239                 _root = new CoverTreeNode(newObservation);
    240                 _numNodes=1;
    241                 return;
    242         }
    243         //TODO: this is pretty inefficient, there may be a better way
    244         //to check if the node already exists...
    245         CoverTreeNode* n = kNearestNodes(newObservation,1)[0];
    246         if(newObservation.distance(n->getObservation())==0.0) {
    247                 n->addObservation(newObservation);
    248         } else {
    249                 //insert_rec acts under the assumption that there are no nodes with
    250                 //distance 0 to newObservation in the cover tree (the previous lines check it)
    251                 insert_rec(newObservation,
    252                                         std::vector<distNodePair>
    253                                         (1,std::make_pair(_root->distance(newObservation),_root)),
    254                                         _maxLevel);
    255         }
    256 }/*}}}*/
    257 void   Covertree::remove(const Observation& p){/*{{{*/
    258         //Most of this function's code is for the special case of removing the root
    259         if(_root==NULL) return;
    260         bool removingRoot=_root->hasObservation(p);
    261         if(removingRoot && !_root->isSingle()) {
    262                 _root->removeObservation(p);
    263                 return;
    264         }
    265         CoverTreeNode* newRoot=NULL;
    266         if(removingRoot) {
    267                 if(_numNodes==1) {
    268                         //removing the last node...
    269                         delete _root;
    270                         _numNodes--;
    271                         _root=NULL;
    272                         return;
    273                 } else {
    274                         for(int i=_maxLevel;i>_minLevel;i--) {
    275                                 if(!(_root->getChildren(i).empty())) {
    276                                         newRoot = _root->getChildren(i).back();
    277                                         _root->removeChild(i,newRoot);
    278                                         break;
    279                                 }
    280                         }
    281                 }
    282         }
    283         std::map<int, std::vector<distNodePair> > coverSets;
    284         coverSets[_maxLevel].push_back(std::make_pair(_root->distance(p),_root));
    285         if(removingRoot)
    286          coverSets[_maxLevel].push_back(std::make_pair(newRoot->distance(p),newRoot));
    287         bool multi = false;
    288         remove_rec(p,coverSets,_maxLevel,multi);
    289         if(removingRoot) {
    290                 delete _root;
    291                 _numNodes--;
    292                 _root=newRoot;
    293         }
    294 }/*}}}*/
    295 std::vector<Observation> Covertree::kNearestNeighbors(const Observation& p, const unsigned int& k) const{/*{{{*/
    296         if(_root==NULL) return std::vector<Observation>();
    297         std::vector<CoverTreeNode*> v = kNearestNodes(p, k);
    298         std::vector<Observation> kNN;
    299         std::vector<CoverTreeNode*>::const_iterator it;
    300         for(it=v.begin();it!=v.end();++it) {
    301                 const std::vector<Observation>& p = (*it)->getObservations();
    302                 kNN.insert(kNN.end(),p.begin(),p.end());
    303                 if(kNN.size() >= k) break;
    304         }
    305         return kNN;
    306 }/*}}}*/
    307 void   Covertree::print() const{/*{{{*/
    308         int d = _maxLevel-_minLevel+1;
    309         std::vector<CoverTreeNode*> Q;
    310         Q.push_back(_root);
    311         for(int i=0;i<d;i++) {
    312                 std::cout << "LEVEL " << _maxLevel-i << "\n";
    313                 std::vector<CoverTreeNode*>::const_iterator it;
    314                 for(it=Q.begin();it!=Q.end();++it) {
    315                         (*it)->getObservation().print();
    316                         std::vector<CoverTreeNode*>
    317                           children = (*it)->getChildren(_maxLevel-i);
    318                         std::vector<CoverTreeNode*>::const_iterator it2;
    319                         for(it2=children.begin();it2!=children.end();++it2) {
    320                                 std::cout << "  ";
    321                                 (*it2)->getObservation().print();
    322                         }
    323                 }
    324                 std::vector<CoverTreeNode*> newQ;
    325                 for(it=Q.begin();it!=Q.end();++it) {
    326                         std::vector<CoverTreeNode*>
    327                           children = (*it)->getChildren(_maxLevel-i);
    328                         newQ.insert(newQ.end(),children.begin(),children.end());
    329                 }
    330                 Q.insert(Q.end(),newQ.begin(),newQ.end());
    331                 std::cout << "\n\n";
    332         }
    333 }/*}}}*/
    334334
    335 Covertree::CoverTreeNode* Covertree::getRoot() const{/*{{{*/
    336         return _root;
     335void   Covertree::CoverTreeNode::addChild(int level, CoverTreeNode* p){/*{{{*/
     336        _childMap[level].push_back(p);
     337}/*}}}*/
     338void   Covertree::CoverTreeNode::addObservation(const Observation& p){/*{{{*/
     339        if(find(_observations.begin(), _observations.end(), p) == _observations.end())
     340         _observations.push_back(p);
    337341}/*}}}*/
    338342Covertree::CoverTreeNode::CoverTreeNode(const Observation& p) {/*{{{*/
    339343        _observations.push_back(p);
     344}/*}}}*/
     345double Covertree::CoverTreeNode::distance(const CoverTreeNode& p) const{/*{{{*/
     346        return _observations[0].distance(p.getObservation());
     347}/*}}}*/
     348std::vector<Covertree::CoverTreeNode*> Covertree::CoverTreeNode::getAllChildren() const{/*{{{*/
     349        std::vector<CoverTreeNode*> children;
     350        std::map<int,std::vector<CoverTreeNode*> >::const_iterator it;
     351        for(it=_childMap.begin();it!=_childMap.end();++it) {
     352                children.insert(children.end(), it->second.begin(), it->second.end());
     353        }
     354        return children;
    340355}/*}}}*/
    341356std::vector<Covertree::CoverTreeNode*> Covertree::CoverTreeNode::getChildren(int level) const{/*{{{*/
     
    347362        return std::vector<CoverTreeNode*>();
    348363}/*}}}*/
    349 void   Covertree::CoverTreeNode::addChild(int level, CoverTreeNode* p){/*{{{*/
    350         _childMap[level].push_back(p);
    351 }/*}}}*/
    352 void   Covertree::CoverTreeNode::removeChild(int level, CoverTreeNode* p){/*{{{*/
    353         std::vector<CoverTreeNode*>& v = _childMap[level];
    354         for(unsigned int i=0;i<v.size();i++) {
    355                 if(v[i]==p) {
    356                         v[i]=v.back();
    357                         v.pop_back();
    358                         break;
    359                 }
    360         }
    361 }/*}}}*/
    362 void   Covertree::CoverTreeNode::addObservation(const Observation& p){/*{{{*/
    363         if(find(_observations.begin(), _observations.end(), p) == _observations.end())
    364          _observations.push_back(p);
    365 }/*}}}*/
    366 void   Covertree::CoverTreeNode::removeObservation(const Observation& p){/*{{{*/
    367         std::vector<Observation>::iterator it =
    368           find(_observations.begin(), _observations.end(), p);
    369         if(it != _observations.end())
    370          _observations.erase(it);
    371 }/*}}}*/
    372 double Covertree::CoverTreeNode::distance(const CoverTreeNode& p) const{/*{{{*/
    373         return _observations[0].distance(p.getObservation());
     364const Observation& Covertree::CoverTreeNode::getObservation() const{/*{{{*/
     365        return _observations[0];
     366}/*}}}*/
     367Covertree::CoverTreeNode* Covertree::getRoot() const{/*{{{*/
     368        return _root;
     369}/*}}}*/
     370bool   Covertree::CoverTreeNode::hasObservation(const Observation& p) const{/*{{{*/
     371        return find(_observations.begin(), _observations.end(), p) != _observations.end();
    374372}/*}}}*/
    375373bool   Covertree::CoverTreeNode::isSingle() const{/*{{{*/
    376374        return _observations.size() == 1;
    377 }/*}}}*/
    378 bool   Covertree::CoverTreeNode::hasObservation(const Observation& p) const{/*{{{*/
    379         return find(_observations.begin(), _observations.end(), p) != _observations.end();
    380 }/*}}}*/
    381 const Observation& Covertree::CoverTreeNode::getObservation() const{/*{{{*/
    382         return _observations[0];
    383 }/*}}}*/
    384 std::vector<Covertree::CoverTreeNode*> Covertree::CoverTreeNode::getAllChildren() const{/*{{{*/
    385         std::vector<CoverTreeNode*> children;
    386         std::map<int,std::vector<CoverTreeNode*> >::const_iterator it;
    387         for(it=_childMap.begin();it!=_childMap.end();++it) {
    388                 children.insert(children.end(), it->second.begin(), it->second.end());
    389         }
    390         return children;
    391375}/*}}}*/
    392376bool   Covertree::isValidTree() const {/*{{{*/
     
    429413        return true;
    430414}/*}}}*/
     415void   Covertree::CoverTreeNode::removeChild(int level, CoverTreeNode* p){/*{{{*/
     416        std::vector<CoverTreeNode*>& v = _childMap[level];
     417        for(unsigned int i=0;i<v.size();i++) {
     418                if(v[i]==p) {
     419                        v[i]=v.back();
     420                        v.pop_back();
     421                        break;
     422                }
     423        }
     424}/*}}}*/
     425void   Covertree::CoverTreeNode::removeObservation(const Observation& p){/*{{{*/
     426        std::vector<Observation>::iterator it =
     427          find(_observations.begin(), _observations.end(), p);
     428        if(it != _observations.end())
     429         _observations.erase(it);
     430}/*}}}*/
  • issm/trunk-jpl/src/c/classes/kriging/Covertree.h

    r19153 r20827  
    2525                         * has itself as a child in a cover tree.
    2626                         */
    27                         std::vector<CoverTreeNode*> getChildren(int level) const;
    2827                        void addChild(int level, CoverTreeNode* p);
    29                         void removeChild(int level, CoverTreeNode* p);
    3028                        void addObservation(const Observation& o);
    31                         void removeObservation(const Observation& o);
    32                         const std::vector<Observation>& getObservations() { return _observations; }
    3329                        double distance(const CoverTreeNode& p) const;
    3430                        bool   isSingle() const;
    3531                        bool   hasObservation(const Observation& o) const;
     32                        std::vector<CoverTreeNode*> getChildren(int level) const;
    3633                        const Observation& getObservation() const;
     34                        const std::vector<Observation>& getObservations() { return _observations; }
     35                        void removeChild(int level, CoverTreeNode* p);
     36                        void removeObservation(const Observation& o);
    3737
    3838                        /**
     
    5151        int            _minLevel;   //A level beneath which there are no more new nodes.
    5252
    53         std::vector<CoverTreeNode*> kNearestNodes(const Observation& o, const unsigned int& k) const;
     53        /* Finds the node in Q with the minimum distance to p. Returns a pair
     54         * consisting of this node and the distance.  */
     55        distNodePair distance(const Observation& p,const std::vector<CoverTreeNode*>& Q);
    5456        /**
    5557         * Recursive implementation of the insert algorithm (see paper).
     
    5759        bool insert_rec(const Observation& p, const std::vector<distNodePair>& Qi,const int& level);
    5860
    59         /* Finds the node in Q with the minimum distance to p. Returns a pair
    60          * consisting of this node and the distance.  */
    61         distNodePair distance(const Observation& p,const std::vector<CoverTreeNode*>& Q);
    62 
    63 
     61        std::vector<CoverTreeNode*> kNearestNodes(const Observation& o, const unsigned int& k) const;
    6462        void remove_rec(const Observation& p, std::map<int,std::vector<distNodePair> >& coverSets, int level, bool& multi);
    6563
     
    8078
    8179        /**
     80         * Insert newPoint into the cover tree. If newPoint is already present,
     81         * (that is, newPoint==p for some p already in the tree), then the tree
     82         * is unchanged. If p.distance(newPoint)==0.0 but newPoint!=p, then
     83         * newPoint WILL be inserted and both points may be returned in k-nearest-
     84         * neighbor searches.
     85         */
     86        void insert(const Observation& newObservation);
     87
     88        /**
    8289         * Just for testing/debugging. Returns true iff the cover tree satisfies the
    8390         * the covering tree invariants (every node in level i is greater than base^i
     
    8895        bool isValidTree() const;
    8996
    90         /**
    91          * Insert newPoint into the cover tree. If newPoint is already present,
    92          * (that is, newPoint==p for some p already in the tree), then the tree
    93          * is unchanged. If p.distance(newPoint)==0.0 but newPoint!=p, then
    94          * newPoint WILL be inserted and both points may be returned in k-nearest-
    95          * neighbor searches.
    96          */
    97         void insert(const Observation& newObservation);
    9897
    9998        /**
  • issm/trunk-jpl/src/c/classes/kriging/ExponentialVariogram.cpp

    r18237 r20827  
    4242
    4343/*Object virtual functions definitions:*/
     44Object* ExponentialVariogram::copy(void){/*{{{*/
     45           return new ExponentialVariogram(*this);
     46}
     47/*}}}*/
    4448void ExponentialVariogram::Echo(void){/*{{{*/
    4549        _printf_("ExponentialVariogram\n");
     
    4751        _printf_("   sill  : " << this->sill << "\n");
    4852        _printf_("   range : " << this->range << "\n");
    49 }
    50 /*}}}*/
    51 Object* ExponentialVariogram::copy(void){/*{{{*/
    52            return new ExponentialVariogram(*this);
    5353}
    5454/*}}}*/
  • issm/trunk-jpl/src/c/classes/kriging/ExponentialVariogram.h

    r19198 r20827  
    2222
    2323                /*Object virtual functions definitions*/
     24                Object* copy();
     25                void  DeepEcho(){_error_("Not implemented yet");};
    2426                void  Echo();
    25                 void  DeepEcho(){_error_("Not implemented yet");};
    2627                int   Id(){_error_("Not implemented yet");};
     28                void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ _error_("not implemented yet!"); };
    2729                int   ObjectEnum(){_error_("Not implemented yet");};
    28                 Object* copy();
    29                 void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ _error_("not implemented yet!"); };
    3030
    3131
    3232                /*Variogram functions*/
     33                double Covariance(double deltax,double deltay);
    3334                double SemiVariogram(double deltax,double deltay);
    34                 double Covariance(double deltax,double deltay);
    3535};
    3636#endif  /* _EXPONENTIALVARIOGRAM_H */
  • issm/trunk-jpl/src/c/classes/kriging/GaussianVariogram.cpp

    r18237 r20827  
    4242
    4343/*Object virtual functions definitions:*/
     44Object* GaussianVariogram::copy(void){/*{{{*/
     45           return new GaussianVariogram(*this);
     46}
     47/*}}}*/
    4448void GaussianVariogram::Echo(void){/*{{{*/
    4549        _printf_("GaussianVariogram\n");
     
    4751        _printf_("   sill  : " << this->sill << "\n");
    4852        _printf_("   range : " << this->range << "\n");
    49 }
    50 /*}}}*/
    51 Object* GaussianVariogram::copy(void){/*{{{*/
    52            return new GaussianVariogram(*this);
    5353}
    5454/*}}}*/
  • issm/trunk-jpl/src/c/classes/kriging/GaussianVariogram.h

    r19198 r20827  
    2323
    2424                /*Object virtual functions definitions*/
     25                Object* copy();
     26                void  DeepEcho(){_error_("Not implemented yet");};
    2527                void  Echo();
    26                 void  DeepEcho(){_error_("Not implemented yet");};
    2728                int   Id(){_error_("Not implemented yet");};
     29                void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ _error_("not implemented yet!"); };
    2830                int   ObjectEnum(){_error_("Not implemented yet");};
    29                 Object* copy();
    30                 void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ _error_("not implemented yet!"); };
    3131
    3232                /*Variogram functions*/
     33                double Covariance(double deltax,double deltay);
    3334                double SemiVariogram(double deltax,double deltay);
    34                 double Covariance(double deltax,double deltay);
    3535};
    3636#endif  /* _GAUSSIANVARIOGRAM_H */
  • issm/trunk-jpl/src/c/classes/kriging/Observation.cpp

    r18914 r20827  
    4141
    4242/*Object virtual functions definitions:*/
     43Object* Observation::copy(void){/*{{{*/
     44
     45        Observation* observation = new Observation(this->x,this->y,this->xi,this->yi,this->index,this->value);
     46
     47        observation->weight = this->weight;
     48
     49        return (Object*) observation;
     50
     51}
     52/*}}}*/
    4353void Observation::Echo(void){/*{{{*/
    4454
     
    5363}
    5464/*}}}*/
    55 Object* Observation::copy(void){/*{{{*/
    56 
    57         Observation* observation = new Observation(this->x,this->y,this->xi,this->yi,this->index,this->value);
    58 
    59         observation->weight = this->weight;
    60 
    61         return (Object*) observation;
    62 
    63 }
    64 /*}}}*/
    6565
    6666/*Observations functions*/
     
    7373
    7474/*Covertree*/
     75bool Observation::operator==(const Observation& ob) const{/*{{{*/
     76        return (ob.x == this->x && ob.y == this->y && ob.value == this->value);
     77}/*}}}*/
     78double Observation::distance(const Observation& ob) const{/*{{{*/
     79        return std::sqrt( (std::pow( (ob.x - this->x), 2 ) + std::pow((ob.y - this->y), 2) ));
     80}
     81/*}}}*/
    7582void Observation::print(void) const{/*{{{*/
    7683
     
    8188}
    8289/*}}}*/
    83 double Observation::distance(const Observation& ob) const
    84 {
    85         return std::sqrt( (std::pow( (ob.x - this->x), 2 ) + std::pow((ob.y - this->y), 2) ));
    86 }
    87 
    88 bool Observation::operator==(const Observation& ob) const
    89 {
    90         return (ob.x == this->x && ob.y == this->y && ob.value == this->value);
    91 }
    92 
    93 void Observation::WriteXYObs(const Observation& ob, double* px, double* py, double* pobs){
     90void Observation::WriteXYObs(const Observation& ob, double* px, double* py, double* pobs){/*{{{*/
    9491    *px   = ob.x;
    9592    *py   = ob.y;
    9693    *pobs = ob.value;
    97 }
     94}/*}}}*/
  • issm/trunk-jpl/src/c/classes/kriging/Observation.h

    r19198 r20827  
    2424
    2525                /*Object virtual functions definitions*/
    26                 double  distance(const Observation& ob) const;
    27 
    28                 void    Echo();
    29                 void    print() const;
    30                 void    DeepEcho()  {_error_("Not implemented yet"); };
    31                 int     Id()        {_error_("Not implemented yet"); };
    32                 int     ObjectEnum(){_error_("Not implemented yet"); };
    3326                bool operator==(const Observation& ob) const;
    3427                Object *copy();
     28                void    DeepEcho()  {_error_("Not implemented yet"); };
     29                double  distance(const Observation& ob) const;
     30                void    Echo();
     31                int     Id()        {_error_("Not implemented yet"); };
     32                void    print() const;
    3533                void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ _error_("not implemented yet!");};
    36 
     34                int     ObjectEnum(){_error_("Not implemented yet"); };
    3735
    3836                /*Management*/
  • issm/trunk-jpl/src/c/classes/kriging/Observations.cpp

    r19156 r20827  
    7777
    7878/*Initialize data structures*/
    79 void Observations::InitQuadtree(IssmPDouble* observations_list,IssmPDouble* x,IssmPDouble* y,int n,Options* options){/*{{{*/
    80 
    81         /*Intermediaries*/
    82         int          i,maxdepth,level,counter,index;
    83         int          xi,yi;
    84         IssmPDouble  xmin,xmax,ymin,ymax;
    85         IssmPDouble  offset,minlength,minspacing,mintrimming,maxtrimming;
    86         Observation *observation = NULL;
    87 
    88         /*Checks*/
    89         _assert_(n);
    90 
    91         /*Get extrema*/
    92         xmin=x[0]; ymin=y[0];
    93         xmax=x[0]; ymax=y[0];
    94         for(i=1;i<n;i++){
    95                 xmin=min(xmin,x[i]); ymin=min(ymin,y[i]);
    96                 xmax=max(xmax,x[i]); ymax=max(ymax,y[i]);
    97         }
    98         offset=0.05*(xmax-xmin); xmin-=offset; xmax+=offset;
    99         offset=0.05*(ymax-ymin); ymin-=offset; ymax+=offset;
    100 
    101         /*Get trimming limits*/
    102         options->Get(&mintrimming,"mintrimming",-1.e+21);
    103         options->Get(&maxtrimming,"maxtrimming",+1.e+21);
    104         options->Get(&minspacing,"minspacing",0.01);
    105         if(minspacing<=0) _error_("minspacing must > 0");
    106 
    107         /*Get Minimum box size*/
    108         if(options->GetOption("boxlength")){
    109                 options->Get(&minlength,"boxlength");
    110                 if(minlength<=0)_error_("boxlength should be a positive number");
    111                 maxdepth=reCast<int,IssmPDouble>(log(max(xmax-xmin,ymax-ymin)/minlength +1)/log(2.0));
    112         }
    113         else{
    114                 maxdepth = 30;
    115                 minlength=max(xmax-xmin,ymax-ymin)/IssmPDouble((1L<<maxdepth)-1);
    116         }
    117 
    118         /*Initialize Quadtree*/
    119         _printf0_("Generating quadtree with a maximum box size " << minlength << " (depth=" << maxdepth << ")... ");
    120         this->quadtree = new Quadtree(xmin,xmax,ymin,ymax,maxdepth);
    121 
    122         /*Add observations one by one*/
    123         counter = 0;
    124         for(i=0;i<n;i++){
    125 
    126                 /*First check limits*/
    127                 if(observations_list[i]>maxtrimming) continue;
    128                 if(observations_list[i]<mintrimming) continue;
    129 
    130                 /*Second, check that this observation is not too close from another one*/
    131                 this->quadtree->ClosestObs(&index,x[i],y[i]);
    132                 if(index>=0){
    133                         observation=xDynamicCast<Observation*>(this->GetObjectByOffset(index));
    134                         if(pow(observation->x-x[i],2)+pow(observation->y-y[i],2) < minspacing) continue;
    135                 }
    136 
    137                 this->quadtree->IntergerCoordinates(&xi,&yi,x[i],y[i]);
    138                 this->quadtree->QuadtreeDepth2(&level,xi,yi);
    139                 if((int)level <= maxdepth){
    140                         observation = new Observation(x[i],y[i],xi,yi,counter++,observations_list[i]);
    141                         this->quadtree->Add(observation);
    142                         this->AddObject(observation);
    143                 }
    144                 else{
    145                         /*We need to average with the current observations*/
    146                         this->quadtree->AddAndAverage(x[i],y[i],observations_list[i]);
    147                 }
    148         }
    149         _printf0_("done\n");
    150         _printf0_("Initial number of observations: " << n << "\n");
    151         _printf0_("  Final number of observations: " << this->quadtree->NbObs << "\n");
    152 }
    153 /*}}}*/
    15479void Observations::InitCovertree(IssmPDouble* observations_list,IssmPDouble* x,IssmPDouble* y,int n,Options* options){/*{{{*/
    15580
     
    208133}
    209134/*}}}*/
     135void Observations::InitQuadtree(IssmPDouble* observations_list,IssmPDouble* x,IssmPDouble* y,int n,Options* options){/*{{{*/
     136
     137        /*Intermediaries*/
     138        int          i,maxdepth,level,counter,index;
     139        int          xi,yi;
     140        IssmPDouble  xmin,xmax,ymin,ymax;
     141        IssmPDouble  offset,minlength,minspacing,mintrimming,maxtrimming;
     142        Observation *observation = NULL;
     143
     144        /*Checks*/
     145        _assert_(n);
     146
     147        /*Get extrema*/
     148        xmin=x[0]; ymin=y[0];
     149        xmax=x[0]; ymax=y[0];
     150        for(i=1;i<n;i++){
     151                xmin=min(xmin,x[i]); ymin=min(ymin,y[i]);
     152                xmax=max(xmax,x[i]); ymax=max(ymax,y[i]);
     153        }
     154        offset=0.05*(xmax-xmin); xmin-=offset; xmax+=offset;
     155        offset=0.05*(ymax-ymin); ymin-=offset; ymax+=offset;
     156
     157        /*Get trimming limits*/
     158        options->Get(&mintrimming,"mintrimming",-1.e+21);
     159        options->Get(&maxtrimming,"maxtrimming",+1.e+21);
     160        options->Get(&minspacing,"minspacing",0.01);
     161        if(minspacing<=0) _error_("minspacing must > 0");
     162
     163        /*Get Minimum box size*/
     164        if(options->GetOption("boxlength")){
     165                options->Get(&minlength,"boxlength");
     166                if(minlength<=0)_error_("boxlength should be a positive number");
     167                maxdepth=reCast<int,IssmPDouble>(log(max(xmax-xmin,ymax-ymin)/minlength +1)/log(2.0));
     168        }
     169        else{
     170                maxdepth = 30;
     171                minlength=max(xmax-xmin,ymax-ymin)/IssmPDouble((1L<<maxdepth)-1);
     172        }
     173
     174        /*Initialize Quadtree*/
     175        _printf0_("Generating quadtree with a maximum box size " << minlength << " (depth=" << maxdepth << ")... ");
     176        this->quadtree = new Quadtree(xmin,xmax,ymin,ymax,maxdepth);
     177
     178        /*Add observations one by one*/
     179        counter = 0;
     180        for(i=0;i<n;i++){
     181
     182                /*First check limits*/
     183                if(observations_list[i]>maxtrimming) continue;
     184                if(observations_list[i]<mintrimming) continue;
     185
     186                /*Second, check that this observation is not too close from another one*/
     187                this->quadtree->ClosestObs(&index,x[i],y[i]);
     188                if(index>=0){
     189                        observation=xDynamicCast<Observation*>(this->GetObjectByOffset(index));
     190                        if(pow(observation->x-x[i],2)+pow(observation->y-y[i],2) < minspacing) continue;
     191                }
     192
     193                this->quadtree->IntergerCoordinates(&xi,&yi,x[i],y[i]);
     194                this->quadtree->QuadtreeDepth2(&level,xi,yi);
     195                if((int)level <= maxdepth){
     196                        observation = new Observation(x[i],y[i],xi,yi,counter++,observations_list[i]);
     197                        this->quadtree->Add(observation);
     198                        this->AddObject(observation);
     199                }
     200                else{
     201                        /*We need to average with the current observations*/
     202                        this->quadtree->AddAndAverage(x[i],y[i],observations_list[i]);
     203                }
     204        }
     205        _printf0_("done\n");
     206        _printf0_("Initial number of observations: " << n << "\n");
     207        _printf0_("  Final number of observations: " << this->quadtree->NbObs << "\n");
     208}
     209/*}}}*/
    210210
    211211/*Methods*/
     
    222222                        _error_("Tree type "<<this->treetype<<" not supported yet (1: quadtree, 2: covertree)");
    223223        }
    224 
    225 }/*}}}*/
    226 void Observations::ClosestObservationQuadtree(IssmPDouble *px,IssmPDouble *py,IssmPDouble *pobs,IssmPDouble x_interp,IssmPDouble y_interp,IssmPDouble radius){/*{{{*/
    227 
    228         /*Output and Intermediaries*/
    229         int          nobs,i,index;
    230         IssmPDouble  hmin,h2,hmin2;
    231         int         *indices      = NULL;
    232         Observation *observation  = NULL;
    233 
    234         /*If radius is not provided or is 0, return all observations*/
    235         if(radius==0) radius=this->quadtree->root->length;
    236 
    237         /*First, find closest point in Quadtree (fast but might not be the true closest obs)*/
    238         this->quadtree->ClosestObs(&index,x_interp,y_interp);
    239         if(index>=0){
    240                 observation=xDynamicCast<Observation*>(this->GetObjectByOffset(index));
    241                 hmin = sqrt((observation->x-x_interp)*(observation->x-x_interp) + (observation->y-y_interp)*(observation->y-y_interp));
    242                 if(hmin<radius) radius=hmin;
    243         }
    244 
    245         /*Find all observations that are in radius*/
    246         this->quadtree->RangeSearch(&indices,&nobs,x_interp,y_interp,radius);
    247         for (i=0;i<nobs;i++){
    248                 observation=xDynamicCast<Observation*>(this->GetObjectByOffset(indices[i]));
    249                 h2 = (observation->x-x_interp)*(observation->x-x_interp) + (observation->y-y_interp)*(observation->y-y_interp);
    250                 if(i==0){
    251                         hmin2 = h2;
    252                         index = indices[i];
    253                 }
    254                 else{
    255                         if(h2<hmin2){
    256                                 hmin2 = h2;
    257                                 index = indices[i];
    258                         }
    259                 }
    260         } 
    261 
    262         /*Assign output pointer*/
    263         if(nobs || hmin==radius){
    264                 observation=xDynamicCast<Observation*>(this->GetObjectByOffset(index));
    265                 *px   = observation->x;
    266                 *py   = observation->y;
    267                 *pobs = observation->value;
    268         }
    269         else{
    270                 *px   = UNDEF;
    271                 *py   = UNDEF;
    272                 *pobs = UNDEF;
    273         }
    274         xDelete<int>(indices);
    275224
    276225}/*}}}*/
     
    297246        *pobs = UNDEF;
    298247}/*}}}*/
     248void Observations::ClosestObservationQuadtree(IssmPDouble *px,IssmPDouble *py,IssmPDouble *pobs,IssmPDouble x_interp,IssmPDouble y_interp,IssmPDouble radius){/*{{{*/
     249
     250        /*Output and Intermediaries*/
     251        int          nobs,i,index;
     252        IssmPDouble  hmin,h2,hmin2;
     253        int         *indices      = NULL;
     254        Observation *observation  = NULL;
     255
     256        /*If radius is not provided or is 0, return all observations*/
     257        if(radius==0) radius=this->quadtree->root->length;
     258
     259        /*First, find closest point in Quadtree (fast but might not be the true closest obs)*/
     260        this->quadtree->ClosestObs(&index,x_interp,y_interp);
     261        if(index>=0){
     262                observation=xDynamicCast<Observation*>(this->GetObjectByOffset(index));
     263                hmin = sqrt((observation->x-x_interp)*(observation->x-x_interp) + (observation->y-y_interp)*(observation->y-y_interp));
     264                if(hmin<radius) radius=hmin;
     265        }
     266
     267        /*Find all observations that are in radius*/
     268        this->quadtree->RangeSearch(&indices,&nobs,x_interp,y_interp,radius);
     269        for (i=0;i<nobs;i++){
     270                observation=xDynamicCast<Observation*>(this->GetObjectByOffset(indices[i]));
     271                h2 = (observation->x-x_interp)*(observation->x-x_interp) + (observation->y-y_interp)*(observation->y-y_interp);
     272                if(i==0){
     273                        hmin2 = h2;
     274                        index = indices[i];
     275                }
     276                else{
     277                        if(h2<hmin2){
     278                                hmin2 = h2;
     279                                index = indices[i];
     280                        }
     281                }
     282        } 
     283
     284        /*Assign output pointer*/
     285        if(nobs || hmin==radius){
     286                observation=xDynamicCast<Observation*>(this->GetObjectByOffset(index));
     287                *px   = observation->x;
     288                *py   = observation->y;
     289                *pobs = observation->value;
     290        }
     291        else{
     292                *px   = UNDEF;
     293                *py   = UNDEF;
     294                *pobs = UNDEF;
     295        }
     296        xDelete<int>(indices);
     297
     298}/*}}}*/
    299299void Observations::Distances(IssmPDouble* distances,IssmPDouble *x,IssmPDouble *y,int n,IssmPDouble radius){/*{{{*/
    300300
     
    350350                        _error_("Tree type "<<this->treetype<<" not supported yet (1: quadtree, 2: covertree)");
    351351        }
     352}/*}}}*/
     353void Observations::ObservationListCovertree(double **px,double **py,double **pobs,int* pnobs,double x_interp,double y_interp,double radius,int maxdata){/*{{{*/
     354
     355        double *x            = NULL;
     356        double *y            = NULL;
     357        double *obs          = NULL;
     358        Observation observation=Observation(x_interp,y_interp,0.);
     359        std::vector<Observation> kNN;
     360
     361        kNN=(this->covertree->kNearestNeighbors(observation, maxdata));
     362        //cout << "kNN's size: " << kNN.size() << " (maxdata = " <<maxdata<<")"<<endl;
     363
     364        //kNN is sort from closest to farthest neighbor
     365        //searches for the first neighbor that is out of radius
     366        //deletes and resizes the kNN vector
     367        vector<Observation>::iterator it;
     368        if(radius>0.){
     369                for (it = kNN.begin(); it != kNN.end(); ++it) {
     370                        //(*it).print();
     371                        //cout << "\n" << (*it).distance(observation) << endl;
     372                        if ((*it).distance(observation) > radius) {
     373                                break;
     374                        }
     375                }
     376                kNN.erase(it, kNN.end());
     377        }
     378
     379        /*Allocate vectors*/
     380        x   = new double[kNN.size()];
     381        y   = new double[kNN.size()];
     382        obs = new double[kNN.size()];
     383
     384        /*Loop over all observations and fill in x, y and obs*/
     385        int i = 0;
     386        for(it = kNN.begin(); it != kNN.end(); ++it) {
     387                (*it).WriteXYObs((*it), &x[i], &y[i], &obs[i]);
     388                i++;
     389        }
     390
     391        *px=x;
     392        *py=y;
     393        *pobs=obs;
     394        *pnobs = kNN.size();
    352395}/*}}}*/
    353396void Observations::ObservationListQuadtree(IssmPDouble **px,IssmPDouble **py,IssmPDouble **pobs,int* pnobs,IssmPDouble x_interp,IssmPDouble y_interp,IssmPDouble radius,int maxdata){/*{{{*/
     
    433476        *pnobs=nobs;
    434477}/*}}}*/
    435 void Observations::ObservationListCovertree(double **px,double **py,double **pobs,int* pnobs,double x_interp,double y_interp,double radius,int maxdata){/*{{{*/
    436 
    437         double *x            = NULL;
    438         double *y            = NULL;
    439         double *obs          = NULL;
    440         Observation observation=Observation(x_interp,y_interp,0.);
    441         std::vector<Observation> kNN;
    442 
    443         kNN=(this->covertree->kNearestNeighbors(observation, maxdata));
    444         //cout << "kNN's size: " << kNN.size() << " (maxdata = " <<maxdata<<")"<<endl;
    445 
    446         //kNN is sort from closest to farthest neighbor
    447         //searches for the first neighbor that is out of radius
    448         //deletes and resizes the kNN vector
    449         vector<Observation>::iterator it;
    450         if(radius>0.){
    451                 for (it = kNN.begin(); it != kNN.end(); ++it) {
    452                         //(*it).print();
    453                         //cout << "\n" << (*it).distance(observation) << endl;
    454                         if ((*it).distance(observation) > radius) {
    455                                 break;
    456                         }
    457                 }
    458                 kNN.erase(it, kNN.end());
    459         }
    460 
    461         /*Allocate vectors*/
    462         x   = new double[kNN.size()];
    463         y   = new double[kNN.size()];
    464         obs = new double[kNN.size()];
    465 
    466         /*Loop over all observations and fill in x, y and obs*/
    467         int i = 0;
    468         for(it = kNN.begin(); it != kNN.end(); ++it) {
    469                 (*it).WriteXYObs((*it), &x[i], &y[i], &obs[i]);
    470                 i++;
    471         }
    472 
    473         *px=x;
    474         *py=y;
    475         *pobs=obs;
    476         *pnobs = kNN.size();
    477 }/*}}}*/
    478478void Observations::InterpolationIDW(IssmPDouble *pprediction,IssmPDouble x_interp,IssmPDouble y_interp,IssmPDouble radius,int mindata,int maxdata,IssmPDouble power){/*{{{*/
    479479
  • issm/trunk-jpl/src/c/classes/kriging/Observations.h

    r19153 r20827  
    2929
    3030                /*Initialize data structures*/
     31                void InitCovertree(IssmDouble* observations_list,IssmDouble* x,IssmDouble* y,int n,Options* options);
    3132                void InitQuadtree(IssmDouble* observations_list,IssmDouble* x,IssmDouble* y,int n,Options* options);
    32                 void InitCovertree(IssmDouble* observations_list,IssmDouble* x,IssmDouble* y,int n,Options* options);
    3333
    3434                /*Methods*/
    3535                void ClosestObservation(IssmDouble *px,IssmDouble *py,IssmDouble *pobs,IssmDouble x_interp,IssmDouble y_interp,IssmDouble radius);
     36                void ClosestObservationCovertree(IssmDouble *px,IssmDouble *py,IssmDouble *pobs,IssmDouble x_interp,IssmDouble y_interp,IssmDouble radius);
    3637                void ClosestObservationQuadtree(IssmDouble *px,IssmDouble *py,IssmDouble *pobs,IssmDouble x_interp,IssmDouble y_interp,IssmDouble radius);
    37                 void ClosestObservationCovertree(IssmDouble *px,IssmDouble *py,IssmDouble *pobs,IssmDouble x_interp,IssmDouble y_interp,IssmDouble radius);
    3838                void Distances(IssmPDouble* distances,IssmPDouble *x,IssmPDouble *y,int n,IssmPDouble radius);
    3939                void InterpolationIDW(IssmDouble *pprediction,IssmDouble x_interp,IssmDouble y_interp,IssmDouble radius,int mindata,int maxdata,IssmDouble power);
     
    4343                void ObservationList(IssmDouble **px,IssmDouble **py,IssmDouble **pobs,int* pnobs);
    4444                void ObservationList(IssmDouble **px,IssmDouble **py,IssmDouble **pobs,int* pnobs,IssmDouble x_interp,IssmDouble y_interp,IssmDouble radius,int maxdata);
     45                void ObservationListCovertree(IssmDouble **px,IssmDouble **py,IssmDouble **pobs,int* pnobs,IssmDouble x_interp,IssmDouble y_interp,IssmDouble radius,int maxdata);
    4546                void ObservationListQuadtree(IssmDouble **px,IssmDouble **py,IssmDouble **pobs,int* pnobs,IssmDouble x_interp,IssmDouble y_interp,IssmDouble radius,int maxdata);
    46                 void ObservationListCovertree(IssmDouble **px,IssmDouble **py,IssmDouble **pobs,int* pnobs,IssmDouble x_interp,IssmDouble y_interp,IssmDouble radius,int maxdata);
    4747                void QuadtreeColoring(IssmDouble* A,IssmDouble *x,IssmDouble *y,int n);
    4848                void Variomap(IssmDouble* gamma,IssmDouble *x,int n);
  • issm/trunk-jpl/src/c/classes/kriging/PowerVariogram.cpp

    r18237 r20827  
    4343
    4444/*Object virtual functions definitions:*/
     45Object* PowerVariogram::copy(void){/*{{{*/
     46           return new PowerVariogram(*this);
     47}
     48/*}}}*/
    4549void PowerVariogram::Echo(void){/*{{{*/
    4650        _printf_("PowerVariogram\n");
     
    4852        _printf_("   slope : " << this->slope << "\n");
    4953        _printf_("   power : " << this->power << "\n");
    50 }
    51 /*}}}*/
    52 Object* PowerVariogram::copy(void){/*{{{*/
    53            return new PowerVariogram(*this);
    5454}
    5555/*}}}*/
  • issm/trunk-jpl/src/c/classes/kriging/PowerVariogram.h

    r19198 r20827  
    2222
    2323                /*Object virtual functions definitions*/
     24                Object* copy();
     25                void  DeepEcho(){_error_("Not implemented yet");};
    2426                void  Echo();
    25                 void  DeepEcho(){_error_("Not implemented yet");};
    2627                int   Id(){_error_("Not implemented yet");};
     28                void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ _error_("not implemented yet!"); };
    2729                int   ObjectEnum(){_error_("Not implemented yet");};
    28                 Object* copy();
    29                 void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ _error_("not implemented yet!"); };
    3030
    3131
    3232                /*Variogram functions*/
     33                double Covariance(double deltax,double deltay);
    3334                double SemiVariogram(double deltax,double deltay);
    34                 double Covariance(double deltax,double deltay);
    3535};
    3636#endif  /* _POWERVARIOGRAM_H */
  • issm/trunk-jpl/src/c/classes/kriging/Quadtree.cpp

    r20634 r20827  
    282282        *pindex=index;
    283283}/*}}}*/
    284 void  Quadtree::Echo(void){/*{{{*/
    285 
    286         _printf_("Quadtree:\n");
    287         _printf_("   MaxDepth      = " << this->MaxDepth << "\n");
    288         _printf_("   NbQuadtreeBox = " << this->NbQuadtreeBox << "\n");
    289         _printf_("   NbObs         = " << this->NbObs << "\n");
    290         _printf_("   root          = " << this->root << "\n");
    291 
    292 }/*}}}*/
    293284void  Quadtree::DeepEcho(void){/*{{{*/
    294285
     
    299290        _printf_("   root          = " << this->root << "\n");
    300291        boxcontainer->Echo();
     292
     293}/*}}}*/
     294void  Quadtree::Echo(void){/*{{{*/
     295
     296        _printf_("Quadtree:\n");
     297        _printf_("   MaxDepth      = " << this->MaxDepth << "\n");
     298        _printf_("   NbQuadtreeBox = " << this->NbQuadtreeBox << "\n");
     299        _printf_("   NbObs         = " << this->NbObs << "\n");
     300        _printf_("   root          = " << this->root << "\n");
    301301
    302302}/*}}}*/
     
    391391        return newbox;
    392392}/*}}}*/
     393void Quadtree::RangeSearch(int **pindices,int *pnobs,double x,double y,double range){/*{{{*/
     394
     395        /*Intermediaries*/
     396        int  nobs;
     397        int *indices = NULL;
     398
     399        /*Allocate indices (maximum by default*/
     400        if(this->NbObs) indices = xNew<int>(this->NbObs);
     401        nobs = 0;
     402
     403        if(this->root) this->root->RangeSearch(indices,&nobs,x,y,range);
     404
     405        /*Clean-up and return*/
     406        *pnobs=nobs;
     407        *pindices=indices;
     408
     409}/*}}}*/
    393410void Quadtree::QuadtreeDepth(int* A,int xi,int yi){/*{{{*/
    394411
     
    470487        *A=level;
    471488}/*}}}*/
    472 void Quadtree::RangeSearch(int **pindices,int *pnobs,double x,double y,double range){/*{{{*/
    473 
    474         /*Intermediaries*/
    475         int  nobs;
    476         int *indices = NULL;
    477 
    478         /*Allocate indices (maximum by default*/
    479         if(this->NbObs) indices = xNew<int>(this->NbObs);
    480         nobs = 0;
    481 
    482         if(this->root) this->root->RangeSearch(indices,&nobs,x,y,range);
    483 
    484         /*Clean-up and return*/
    485         *pnobs=nobs;
    486         *pindices=indices;
    487 
    488 }/*}}}*/
    489489
    490490/*QuadtreeBox methos*/
     491Object* Quadtree::QuadtreeBox::copy(void){/*{{{*/
     492
     493           QuadtreeBox* qtreebox = new QuadtreeBox(*this);
     494
     495                for (int i=0; i<4; ++i){
     496                        if(this->box[i]) qtreebox->box[i] = reinterpret_cast<QuadtreeBox*>(this->box[i]->copy());
     497                        else qtreebox->box[i] = NULL;
     498                }
     499                for (int i=0; i<4; ++i){
     500                        if(this->obs[i]) qtreebox->obs[i] = reinterpret_cast<Observation*>(this->obs[i]->copy());
     501                        else qtreebox->obs[i] = NULL;
     502                }
     503
     504                return (Object*) qtreebox;
     505}
     506/*}}}*/
    491507void  Quadtree::QuadtreeBox::Echo(void){/*{{{*/
    492508
     
    498514
    499515}/*}}}*/
    500 Object* Quadtree::QuadtreeBox::copy(void){/*{{{*/
    501 
    502            QuadtreeBox* qtreebox = new QuadtreeBox(*this);
    503 
    504                 for (int i=0; i<4; ++i){
    505                         if(this->box[i]) qtreebox->box[i] = reinterpret_cast<QuadtreeBox*>(this->box[i]->copy());
    506                         else qtreebox->box[i] = NULL;
    507                 }
    508                 for (int i=0; i<4; ++i){
    509                         if(this->obs[i]) qtreebox->obs[i] = reinterpret_cast<Observation*>(this->obs[i]->copy());
    510                         else qtreebox->obs[i] = NULL;
    511                 }
    512 
    513                 return (Object*) qtreebox;
    514 }
    515 /*}}}*/
    516516int Quadtree::QuadtreeBox::IsWithinRange(double x,double y,double range){/*{{{*/
    517517
  • issm/trunk-jpl/src/c/classes/kriging/Quadtree.h

    r19198 r20827  
    2626
    2727                                /*Object functions (Needed because the Quadtree uses a Container*/
     28                                Object *copy();
     29                                void    DeepEcho()  {_error_("not implemented yet"); };
    2830                                void    Echo();
    29                                 void    DeepEcho()  {_error_("not implemented yet"); };
    3031                                int     Id()        {_error_("not implemented yet"); };
     32                                void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ _error_("not implemented yet!");};
    3133                                int     ObjectEnum(){_error_("not implemented yet"); };
    32                                 Object *copy();
    33                                 void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ _error_("not implemented yet!");};
    3434
    3535
  • issm/trunk-jpl/src/c/classes/kriging/SphericalVariogram.cpp

    r18237 r20827  
    4242
    4343/*Object virtual functions definitions:*/
     44Object* SphericalVariogram::copy(void){/*{{{*/
     45        return new SphericalVariogram(*this);
     46}
     47/*}}}*/
    4448void SphericalVariogram::Echo(void){/*{{{*/
    4549        _printf_("SphericalVariogram\n");
     
    4751        _printf_("   sill  : " << this->sill << "\n");
    4852        _printf_("   range : " << this->range << "\n");
    49 }
    50 /*}}}*/
    51 Object* SphericalVariogram::copy(void){/*{{{*/
    52         return new SphericalVariogram(*this);
    5353}
    5454/*}}}*/
  • issm/trunk-jpl/src/c/classes/kriging/SphericalVariogram.h

    r19198 r20827  
    2222
    2323                /*Object virtual functions definitions*/
     24                Object* copy();
     25                void  DeepEcho(){_error_("Not implemented yet");};
    2426                void  Echo();
    25                 void  DeepEcho(){_error_("Not implemented yet");};
    2627                int   Id(){_error_("Not implemented yet");};
     28                void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ _error_("not implemented yet!"); };
    2729                int   ObjectEnum(){_error_("Not implemented yet");};
    28                 Object* copy();
    29                 void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ _error_("not implemented yet!"); };
    3030
    3131
    3232                /*Variogram functions*/
     33                double Covariance(double deltax,double deltay);
    3334                double SemiVariogram(double deltax,double deltay);
    34                 double Covariance(double deltax,double deltay);
    3535};
    3636#endif  /* _SPHERICALVARIOGRAM_H */
  • issm/trunk-jpl/src/c/classes/kriging/Variogram.h

    r15067 r20827  
    1212        public:
    1313                virtual ~Variogram(){};
     14                virtual double Covariance(double deltax,double deltay)=0;
    1415                virtual double SemiVariogram(double deltax,double deltay)=0;
    15                 virtual double Covariance(double deltax,double deltay)=0;
    1616
    1717};
  • issm/trunk-jpl/src/c/classes/matrix/ElementMatrix.cpp

    r20669 r20827  
    236236
    237237/*ElementMatrix specific routines: */
     238void ElementMatrix::AddDiagonalToGlobal(Vector<IssmDouble>* pf){/*{{{*/
     239
     240        IssmDouble* localvalues=NULL;
     241
     242        /*Check that pf is not NULL*/
     243        _assert_(pf);
     244
     245        /*In debugging mode, check consistency (no NaN, and values not too big)*/
     246        this->CheckConsistency();
     247
     248        if(this->dofsymmetrical){
     249                /*only use row dofs to add values into global matrices: */
     250
     251                if(this->row_fsize){
     252                        /*first, retrieve values that are in the f-set from the g-set values matrix: */
     253                        localvalues=xNew<IssmDouble>(this->row_fsize);
     254                        for(int i=0;i<this->row_fsize;i++){
     255                                localvalues[i] = this->values[this->ncols*this->row_flocaldoflist[i]+ this->row_flocaldoflist[i]];
     256                        }
     257
     258                        /*add local values into global  matrix, using the fglobaldoflist: */
     259                        pf->SetValues(this->row_fsize,this->row_fglobaldoflist,localvalues,ADD_VAL);
     260
     261                        /*Free ressources:*/
     262                        xDelete<IssmDouble>(localvalues);
     263                }
     264        }
     265        else{
     266                _error_("non dofsymmetrical matrix AddToGlobal routine not support yet!");
     267        }
     268
     269}
     270/*}}}*/
    238271void ElementMatrix::AddToGlobal(Matrix<IssmDouble>* Kff, Matrix<IssmDouble>* Kfs){/*{{{*/
    239272
     
    322355                }
    323356
    324         }
    325         else{
    326                 _error_("non dofsymmetrical matrix AddToGlobal routine not support yet!");
    327         }
    328 
    329 }
    330 /*}}}*/
    331 void ElementMatrix::AddDiagonalToGlobal(Vector<IssmDouble>* pf){/*{{{*/
    332 
    333         IssmDouble* localvalues=NULL;
    334 
    335         /*Check that pf is not NULL*/
    336         _assert_(pf);
    337 
    338         /*In debugging mode, check consistency (no NaN, and values not too big)*/
    339         this->CheckConsistency();
    340 
    341         if(this->dofsymmetrical){
    342                 /*only use row dofs to add values into global matrices: */
    343 
    344                 if(this->row_fsize){
    345                         /*first, retrieve values that are in the f-set from the g-set values matrix: */
    346                         localvalues=xNew<IssmDouble>(this->row_fsize);
    347                         for(int i=0;i<this->row_fsize;i++){
    348                                 localvalues[i] = this->values[this->ncols*this->row_flocaldoflist[i]+ this->row_flocaldoflist[i]];
    349                         }
    350 
    351                         /*add local values into global  matrix, using the fglobaldoflist: */
    352                         pf->SetValues(this->row_fsize,this->row_fglobaldoflist,localvalues,ADD_VAL);
    353 
    354                         /*Free ressources:*/
    355                         xDelete<IssmDouble>(localvalues);
    356                 }
    357357        }
    358358        else{
     
    373373        }
    374374        #endif
     375}
     376/*}}}*/
     377void ElementMatrix::Echo(void){/*{{{*/
     378
     379        int i,j;
     380        _printf_("Element Matrix echo:\n");
     381        _printf_("   nrows: " << this->nrows << "\n");
     382        _printf_("   ncols: " << this->ncols << "\n");
     383        _printf_("   dofsymmetrical: " << (dofsymmetrical?"true":"false") << "\n");
     384
     385        _printf_("   values:\n");
     386        for(i=0;i<nrows;i++){
     387                _printf_(setw(4) << right << i << ": ");
     388                for(j=0;j<ncols;j++) _printf_( " " << setw(11) << setprecision (5) << right << values[i*ncols+j]);
     389                _printf_("\n");
     390        }
     391
     392        _printf_("   gglobaldoflist (" << gglobaldoflist << "): ");
     393        if(gglobaldoflist) for(i=0;i<nrows;i++) _printf_(" " << gglobaldoflist[i]); _printf_("\n");
     394
     395        _printf_("   row_fsize: " << row_fsize << "\n");
     396        _printf_("   row_flocaldoflist  (" << row_flocaldoflist << "): ");
     397        if(row_flocaldoflist) for(i=0;i<row_fsize;i++) _printf_(" " << row_flocaldoflist[i] ); _printf_(" \n");
     398        _printf_("   row_fglobaldoflist  (" << row_fglobaldoflist << "): ");
     399        if(row_fglobaldoflist) for(i=0;i<row_fsize;i++)_printf_(" " << row_fglobaldoflist[i]); _printf_(" \n");
     400
     401        _printf_("   row_ssize: " << row_ssize << "\n");
     402        _printf_("   row_slocaldoflist  (" << row_slocaldoflist << "): ");
     403        if(row_slocaldoflist) for(i=0;i<row_ssize;i++) _printf_(" " << row_slocaldoflist[i] ); _printf_(" \n");
     404        _printf_("   row_sglobaldoflist  (" << row_sglobaldoflist << "): ");
     405        if(row_sglobaldoflist) for(i=0;i<row_ssize;i++)_printf_(" " << row_sglobaldoflist[i]); _printf_(" \n");
     406
     407        if(!dofsymmetrical){
     408                _printf_("   col_fsize: " << col_fsize << "\n");
     409                _printf_("   col_flocaldoflist  (" << col_flocaldoflist << "): ");
     410                if(col_flocaldoflist) for(i=0;i<col_fsize;i++) _printf_(" " << col_flocaldoflist[i] ); _printf_(" \n");
     411                _printf_("   col_fglobaldoflist  (" << col_fglobaldoflist << "): ");
     412                if(col_fglobaldoflist) for(i=0;i<col_fsize;i++)_printf_(" " << col_fglobaldoflist[i]); _printf_(" \n");
     413
     414                _printf_("   col_ssize: " << col_ssize << "\n");
     415                _printf_("   col_slocaldoflist  (" << col_slocaldoflist << "): ");
     416                if(col_slocaldoflist) for(i=0;i<col_ssize;i++) _printf_(" " << col_slocaldoflist[i] ); _printf_(" \n");
     417                _printf_("   col_sglobaldoflist  (" << col_sglobaldoflist << "): ");
     418                if(col_sglobaldoflist) for(i=0;i<col_ssize;i++)_printf_(" " << col_sglobaldoflist[i]); _printf_(" \n");
     419        }
     420}
     421/*}}}*/
     422void ElementMatrix::Init(ElementMatrix* Ke){/*{{{*/
     423
     424        _assert_(Ke);
     425        _assert_(this);
     426
     427        this->nrows =Ke->nrows;
     428        this->ncols =Ke->ncols;
     429        this->dofsymmetrical=Ke->dofsymmetrical;
     430
     431        this->values=xNew<IssmDouble>(this->nrows*this->ncols);
     432        xMemCpy<IssmDouble>(this->values,Ke->values,this->nrows*this->ncols);
     433
     434        this->gglobaldoflist=xNew<int>(this->nrows);
     435        xMemCpy<int>(this->gglobaldoflist,Ke->gglobaldoflist,this->nrows);
     436
     437        this->row_fsize=Ke->row_fsize;
     438        if(this->row_fsize){
     439                this->row_flocaldoflist=xNew<int>(this->row_fsize);
     440                xMemCpy<int>(this->row_flocaldoflist,Ke->row_flocaldoflist,this->row_fsize);
     441                this->row_fglobaldoflist=xNew<int>(this->row_fsize);
     442                xMemCpy<int>(this->row_fglobaldoflist,Ke->row_fglobaldoflist,this->row_fsize);
     443        }
     444        else{
     445                this->row_flocaldoflist=NULL;
     446                this->row_fglobaldoflist=NULL;
     447        }
     448
     449        this->row_ssize=Ke->row_ssize;
     450        if(this->row_ssize){
     451                this->row_slocaldoflist=xNew<int>(this->row_ssize);
     452                xMemCpy<int>(this->row_slocaldoflist,Ke->row_slocaldoflist,this->row_ssize);
     453                this->row_sglobaldoflist=xNew<int>(this->row_ssize);
     454                xMemCpy<int>(this->row_sglobaldoflist,Ke->row_sglobaldoflist,this->row_ssize);
     455        }
     456        else{
     457                this->row_slocaldoflist=NULL;
     458                this->row_sglobaldoflist=NULL;
     459        }
     460
     461        this->col_fsize=Ke->col_fsize;
     462        if(this->col_fsize){
     463                this->col_flocaldoflist=xNew<int>(this->col_fsize);
     464                xMemCpy<int>(this->col_flocaldoflist,Ke->col_flocaldoflist,this->col_fsize);
     465                this->col_fglobaldoflist=xNew<int>(this->col_fsize);
     466                xMemCpy<int>(this->col_fglobaldoflist,Ke->col_fglobaldoflist,this->col_fsize);
     467        }
     468        else{
     469                this->col_flocaldoflist=NULL;
     470                this->col_fglobaldoflist=NULL;
     471        }
     472
     473        this->col_ssize=Ke->col_ssize;
     474        if(this->col_ssize){
     475                this->col_slocaldoflist=xNew<int>(this->col_ssize);
     476                xMemCpy<int>(this->col_slocaldoflist,Ke->col_slocaldoflist,this->col_ssize);
     477                this->col_sglobaldoflist=xNew<int>(this->col_ssize);
     478                xMemCpy<int>(this->col_sglobaldoflist,Ke->col_sglobaldoflist,this->col_ssize);
     479        }
     480        else{
     481                this->col_slocaldoflist=NULL;
     482                this->col_sglobaldoflist=NULL;
     483        }
    375484}
    376485/*}}}*/
     
    516625}
    517626/*}}}*/
    518 void ElementMatrix::Echo(void){/*{{{*/
    519 
    520         int i,j;
    521         _printf_("Element Matrix echo:\n");
    522         _printf_("   nrows: " << this->nrows << "\n");
    523         _printf_("   ncols: " << this->ncols << "\n");
    524         _printf_("   dofsymmetrical: " << (dofsymmetrical?"true":"false") << "\n");
    525 
    526         _printf_("   values:\n");
    527         for(i=0;i<nrows;i++){
    528                 _printf_(setw(4) << right << i << ": ");
    529                 for(j=0;j<ncols;j++) _printf_( " " << setw(11) << setprecision (5) << right << values[i*ncols+j]);
    530                 _printf_("\n");
    531         }
    532 
    533         _printf_("   gglobaldoflist (" << gglobaldoflist << "): ");
    534         if(gglobaldoflist) for(i=0;i<nrows;i++) _printf_(" " << gglobaldoflist[i]); _printf_("\n");
    535 
    536         _printf_("   row_fsize: " << row_fsize << "\n");
    537         _printf_("   row_flocaldoflist  (" << row_flocaldoflist << "): ");
    538         if(row_flocaldoflist) for(i=0;i<row_fsize;i++) _printf_(" " << row_flocaldoflist[i] ); _printf_(" \n");
    539         _printf_("   row_fglobaldoflist  (" << row_fglobaldoflist << "): ");
    540         if(row_fglobaldoflist) for(i=0;i<row_fsize;i++)_printf_(" " << row_fglobaldoflist[i]); _printf_(" \n");
    541 
    542         _printf_("   row_ssize: " << row_ssize << "\n");
    543         _printf_("   row_slocaldoflist  (" << row_slocaldoflist << "): ");
    544         if(row_slocaldoflist) for(i=0;i<row_ssize;i++) _printf_(" " << row_slocaldoflist[i] ); _printf_(" \n");
    545         _printf_("   row_sglobaldoflist  (" << row_sglobaldoflist << "): ");
    546         if(row_sglobaldoflist) for(i=0;i<row_ssize;i++)_printf_(" " << row_sglobaldoflist[i]); _printf_(" \n");
    547 
    548         if(!dofsymmetrical){
    549                 _printf_("   col_fsize: " << col_fsize << "\n");
    550                 _printf_("   col_flocaldoflist  (" << col_flocaldoflist << "): ");
    551                 if(col_flocaldoflist) for(i=0;i<col_fsize;i++) _printf_(" " << col_flocaldoflist[i] ); _printf_(" \n");
    552                 _printf_("   col_fglobaldoflist  (" << col_fglobaldoflist << "): ");
    553                 if(col_fglobaldoflist) for(i=0;i<col_fsize;i++)_printf_(" " << col_fglobaldoflist[i]); _printf_(" \n");
    554 
    555                 _printf_("   col_ssize: " << col_ssize << "\n");
    556                 _printf_("   col_slocaldoflist  (" << col_slocaldoflist << "): ");
    557                 if(col_slocaldoflist) for(i=0;i<col_ssize;i++) _printf_(" " << col_slocaldoflist[i] ); _printf_(" \n");
    558                 _printf_("   col_sglobaldoflist  (" << col_sglobaldoflist << "): ");
    559                 if(col_sglobaldoflist) for(i=0;i<col_ssize;i++)_printf_(" " << col_sglobaldoflist[i]); _printf_(" \n");
    560         }
    561 }
    562 /*}}}*/
    563 void ElementMatrix::Init(ElementMatrix* Ke){/*{{{*/
    564 
    565         _assert_(Ke);
    566         _assert_(this);
    567 
    568         this->nrows =Ke->nrows;
    569         this->ncols =Ke->ncols;
    570         this->dofsymmetrical=Ke->dofsymmetrical;
    571 
    572         this->values=xNew<IssmDouble>(this->nrows*this->ncols);
    573         xMemCpy<IssmDouble>(this->values,Ke->values,this->nrows*this->ncols);
    574 
    575         this->gglobaldoflist=xNew<int>(this->nrows);
    576         xMemCpy<int>(this->gglobaldoflist,Ke->gglobaldoflist,this->nrows);
    577 
    578         this->row_fsize=Ke->row_fsize;
    579         if(this->row_fsize){
    580                 this->row_flocaldoflist=xNew<int>(this->row_fsize);
    581                 xMemCpy<int>(this->row_flocaldoflist,Ke->row_flocaldoflist,this->row_fsize);
    582                 this->row_fglobaldoflist=xNew<int>(this->row_fsize);
    583                 xMemCpy<int>(this->row_fglobaldoflist,Ke->row_fglobaldoflist,this->row_fsize);
    584         }
    585         else{
    586                 this->row_flocaldoflist=NULL;
    587                 this->row_fglobaldoflist=NULL;
    588         }
    589 
    590         this->row_ssize=Ke->row_ssize;
    591         if(this->row_ssize){
    592                 this->row_slocaldoflist=xNew<int>(this->row_ssize);
    593                 xMemCpy<int>(this->row_slocaldoflist,Ke->row_slocaldoflist,this->row_ssize);
    594                 this->row_sglobaldoflist=xNew<int>(this->row_ssize);
    595                 xMemCpy<int>(this->row_sglobaldoflist,Ke->row_sglobaldoflist,this->row_ssize);
    596         }
    597         else{
    598                 this->row_slocaldoflist=NULL;
    599                 this->row_sglobaldoflist=NULL;
    600         }
    601 
    602         this->col_fsize=Ke->col_fsize;
    603         if(this->col_fsize){
    604                 this->col_flocaldoflist=xNew<int>(this->col_fsize);
    605                 xMemCpy<int>(this->col_flocaldoflist,Ke->col_flocaldoflist,this->col_fsize);
    606                 this->col_fglobaldoflist=xNew<int>(this->col_fsize);
    607                 xMemCpy<int>(this->col_fglobaldoflist,Ke->col_fglobaldoflist,this->col_fsize);
    608         }
    609         else{
    610                 this->col_flocaldoflist=NULL;
    611                 this->col_fglobaldoflist=NULL;
    612         }
    613 
    614         this->col_ssize=Ke->col_ssize;
    615         if(this->col_ssize){
    616                 this->col_slocaldoflist=xNew<int>(this->col_ssize);
    617                 xMemCpy<int>(this->col_slocaldoflist,Ke->col_slocaldoflist,this->col_ssize);
    618                 this->col_sglobaldoflist=xNew<int>(this->col_ssize);
    619                 xMemCpy<int>(this->col_sglobaldoflist,Ke->col_sglobaldoflist,this->col_ssize);
    620         }
    621         else{
    622                 this->col_slocaldoflist=NULL;
    623                 this->col_sglobaldoflist=NULL;
    624         }
    625 }
    626 /*}}}*/
  • issm/trunk-jpl/src/c/classes/matrix/ElementMatrix.h

    r18344 r20827  
    5858
    5959                /*ElementMatrix specific routines*/
     60                void AddDiagonalToGlobal(Vector<IssmDouble>* pf);
    6061                void AddToGlobal(Matrix<IssmDouble>* Kff, Matrix<IssmDouble>* Kfs);
    6162                void AddToGlobal(Matrix<IssmDouble>* Jff);
    62                 void AddDiagonalToGlobal(Vector<IssmDouble>* pf);
     63                void CheckConsistency(void);
    6364                void Echo(void);
    64                 void CheckConsistency(void);
     65                void Init(ElementMatrix* Ke);
     66                void Lump(void);
    6567                void StaticCondensation(int numindices,int* indices);
    66                 void Lump(void);
    6768                void Transpose(void);
    68                 void Init(ElementMatrix* Ke);
    6969};
    7070#endif //#ifndef _ELEMENT_MATRIX_H_
  • issm/trunk-jpl/src/c/classes/matrix/ElementVector.cpp

    r20669 r20827  
    176176}
    177177/*}}}*/
    178 void ElementVector::InsertIntoGlobal(Vector<IssmDouble>* pf){/*{{{*/
    179 
    180         int i;
    181         IssmDouble* localvalues=NULL;
    182 
    183         if(this->fsize){
    184                 /*first, retrieve values that are in the f-set from the g-set values vector: */
    185                 localvalues=xNew<IssmDouble>(this->fsize);
    186                 for(i=0;i<this->fsize;i++){
    187                         localvalues[i]=this->values[this->flocaldoflist[i]];
    188                 }
    189                 /*add local values into global  vector, using the fglobaldoflist: */
    190                 pf->SetValues(this->fsize,this->fglobaldoflist,localvalues,INS_VAL);
    191 
    192                 /*Free ressources:*/
    193                 xDelete<IssmDouble>(localvalues);
    194         }
    195 
    196 }
    197 /*}}}*/
    198178void ElementVector::CheckConsistency(void){/*{{{*/
    199179        /*Check element matrix values, only in debugging mode*/
     
    254234                this->fglobaldoflist=NULL;
    255235        }
     236}
     237/*}}}*/
     238void ElementVector::InsertIntoGlobal(Vector<IssmDouble>* pf){/*{{{*/
     239
     240        int i;
     241        IssmDouble* localvalues=NULL;
     242
     243        if(this->fsize){
     244                /*first, retrieve values that are in the f-set from the g-set values vector: */
     245                localvalues=xNew<IssmDouble>(this->fsize);
     246                for(i=0;i<this->fsize;i++){
     247                        localvalues[i]=this->values[this->flocaldoflist[i]];
     248                }
     249                /*add local values into global  vector, using the fglobaldoflist: */
     250                pf->SetValues(this->fsize,this->fglobaldoflist,localvalues,INS_VAL);
     251
     252                /*Free ressources:*/
     253                xDelete<IssmDouble>(localvalues);
     254        }
     255
    256256}
    257257/*}}}*/
  • issm/trunk-jpl/src/c/classes/matrix/ElementVector.h

    r15688 r20827  
    4141                /*ElementVector specific routines*/
    4242                void AddToGlobal(Vector<IssmDouble>* pf);
     43                void CheckConsistency(void);
     44                void Echo(void);
     45                void Init(ElementVector* pe);
    4346                void InsertIntoGlobal(Vector<IssmDouble>* pf);
    44                 void Echo(void);
    45                 void CheckConsistency(void);
    46                 void Init(ElementVector* pe);
    4747                void SetValue(IssmDouble scalar);
    4848                void StaticCondensation(ElementMatrix* Ke,int numindices,int* indices);
Note: See TracChangeset for help on using the changeset viewer.