Changeset 27756


Ignore:
Timestamp:
05/16/23 05:47:13 (22 months ago)
Author:
Mathieu Morlighem
Message:

NEW: added transient control inputs. fully validated

Location:
issm/trunk-jpl/src/c
Files:
24 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/c/classes/Params/BoolParam.h

    r27696 r27756  
    7272                void  SetValue(FILE* fid){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a FILE");}
    7373                void  SetValue(IssmDouble** array, int M, int* mdim_array, int* ndim_array){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold an array of matrices");}
    74                 void  SetGradient(IssmDouble* poutput, int M){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold an IssmDouble");};
     74                void  SetGradient(IssmDouble* poutput, int M, int N){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold an IssmDouble");};
    7575                /*}}}*/
    7676};
  • issm/trunk-jpl/src/c/classes/Params/ControlParam.cpp

    r27730 r27756  
    1717}
    1818/*}}}*/
    19 ControlParam::ControlParam(IssmDouble* in_value, IssmDouble* in_minvalue, IssmDouble* in_maxvalue, IssmDouble* in_savedvalue, IssmDouble* in_gradient, int in_enum_type, int in_M){/*{{{*/
    20 
    21         M=in_M;
    22 
    23         if(M){
    24                 value=xNew<IssmDouble>(M);
    25                 xMemCpy<IssmDouble>(value,in_value,M);
    26                
    27                 minvalue=xNew<IssmDouble>(M);
    28                 xMemCpy<IssmDouble>(minvalue,in_minvalue,M);
    29                
    30                 maxvalue=xNew<IssmDouble>(M);
    31                 xMemCpy<IssmDouble>(maxvalue,in_maxvalue,M);
    32                
    33                 savedvalue=NULL;
    34                 gradient=NULL;
    35                
    36         }
    37         else{
    38                 value=NULL;
    39                 minvalue=NULL;
    40                 maxvalue=NULL;
    41                 savedvalue=NULL;
    42                 gradient=NULL;
    43         }
    44 
    45         enum_type=in_enum_type;
    46 }
    47 /*}}}*/
    48 ControlParam::ControlParam(IssmDouble* in_value, IssmDouble* in_minvalue, IssmDouble* in_maxvalue, int in_enum_type, int in_M){/*{{{*/
    49 
    50         enum_type=in_enum_type;
    51         M=in_M;
    52 
    53         if(M){
    54                 value=xNew<IssmDouble>(M);
    55                 xMemCpy<IssmDouble>(value,in_value,M);
    56                
    57                 minvalue=xNew<IssmDouble>(M);
    58                 xMemCpy<IssmDouble>(minvalue,in_minvalue,M);
    59                
    60                 maxvalue=xNew<IssmDouble>(M);
    61                 xMemCpy<IssmDouble>(maxvalue,in_maxvalue,M);
    62        
    63                 savedvalue=NULL;
    64                 gradient=xNewZeroInit<IssmDouble>(M);
    65         }
    66         else{
    67                 value=NULL;
    68                 minvalue=NULL;
    69                 maxvalue=NULL;
    70                 savedvalue=NULL;
    71                 gradient=NULL;
    72         }
    73 
     19ControlParam::ControlParam(IssmDouble* in_value, IssmDouble* in_minvalue, IssmDouble* in_maxvalue, int in_enum_type, int in_M,int in_N){/*{{{*/
     20
     21        this->enum_type=in_enum_type;
     22        this->M=in_M;
     23        this->N=in_N;
     24
     25        /*Sanity check, can't hurt*/
     26        if(this->N<1) _error_("Parameter is empty");
     27        if(this->M<1) _error_("Parameter is empty");
     28        if(this->M>2) _error_("Cannot handle more than 2 rows (as a TransientParam)");
     29
     30        /*Assign value*/
     31        this->value=xNew<IssmDouble>(M*N);
     32        xMemCpy<IssmDouble>(value,in_value,M*N);
     33
     34        /*Assign other fields*/
     35        this->minvalue=xNew<IssmDouble>(N);
     36        xMemCpy<IssmDouble>(minvalue,in_minvalue,N);
     37        this->maxvalue=xNew<IssmDouble>(N);
     38        xMemCpy<IssmDouble>(maxvalue,in_maxvalue,N);
     39        this->gradient=xNewZeroInit<IssmDouble>(N);
    7440}
    7541/*}}}*/
     
    7945        xDelete<IssmDouble>(maxvalue);
    8046        xDelete<IssmDouble>(gradient);
    81         xDelete<IssmDouble>(savedvalue);
    8247        return;
    8348}
     
    8752Param* ControlParam::copy() {/*{{{*/
    8853
    89         return new ControlParam(this->value,this->minvalue,this->maxvalue,this->savedvalue,this->gradient,this->enum_type,this->M);
     54        ControlParam* output = new ControlParam();
     55        output->enum_type=this->enum_type;
     56        output->M=this->M;
     57        output->N=this->N;
     58        if(value){
     59                output->value=xNew<IssmDouble>(this->M*this->N);
     60                xMemCpy<IssmDouble>(output->value,this->value,this->M*this->N);
     61        }
     62        if(minvalue){
     63                output->minvalue=xNew<IssmDouble>(this->N);
     64                xMemCpy<IssmDouble>(output->minvalue,this->minvalue,this->N);
     65        }
     66        if(maxvalue){
     67                output->maxvalue=xNew<IssmDouble>(this->N);
     68                xMemCpy<IssmDouble>(output->maxvalue,this->maxvalue,this->N);
     69        }
     70        if(gradient){
     71                output->gradient=xNew<IssmDouble>(this->N);
     72                xMemCpy<IssmDouble>(output->gradient,this->gradient,this->N);
     73        }
     74        return output;
    9075
    9176}
     
    9782        for(int i=0;i<this->M;i++) _printf_(" "<< this->value[i]);
    9883        _printf_("]\n");
    99         if (savedvalue) _printf_("---savedvalue: " << this->savedvalue << "\n");
    10084        if (minvalue) _printf_("---minvalue: ");
    10185        for(int i=0;i<this->M;i++) _printf_(" "<< this->minvalue[i]);
     
    119103        marshallhandle->call(this->enum_type);
    120104        marshallhandle->call(this->M);
    121         marshallhandle->call(this->value,this->M);
    122         marshallhandle->call(this->minvalue,this->M);
    123         marshallhandle->call(this->maxvalue,this->M);
    124         marshallhandle->call(this->savedvalue,this->M);
    125         marshallhandle->call(this->gradient,this->M);
     105        marshallhandle->call(this->N);
     106        marshallhandle->call(this->value,this->M*this->N);
     107        marshallhandle->call(this->minvalue,this->N);
     108        marshallhandle->call(this->maxvalue,this->N);
     109        marshallhandle->call(this->gradient,this->N);
    126110
    127111}
     
    134118/*}}}*/
    135119
    136 void  ControlParam::GetParameterValue(IssmDouble** poutput,int* pM, const char* data){/*{{{*/
    137 
    138         IssmDouble* output=xNew<IssmDouble>(M);
     120void  ControlParam::GetParameterValue(IssmDouble** poutput,int* pN, const char* data){/*{{{*/
     121
     122        IssmDouble* output=xNew<IssmDouble>(N);
    139123       
    140124        if(strcmp(data,"value")==0){
    141                 xMemCpy<IssmDouble>(output,value,M);
    142         }
    143         else if(strcmp(data,"savedvalues")==0){
    144                 xMemCpy<IssmDouble>(output,savedvalue,M);
     125                xMemCpy<IssmDouble>(output,value,N);
    145126        }
    146127        else if (strcmp(data,"lowerbound")==0){
    147                 xMemCpy<IssmDouble>(output,minvalue,M);
     128                xMemCpy<IssmDouble>(output,minvalue,N);
    148129        }
    149130        else if (strcmp(data,"upperbound")==0){
    150                 xMemCpy<IssmDouble>(output,maxvalue,M);
     131                xMemCpy<IssmDouble>(output,maxvalue,N);
    151132        }
    152133        else if (strcmp(data,"gradient")==0){
    153                 xMemCpy<IssmDouble>(output,gradient,M);
     134                xMemCpy<IssmDouble>(output,gradient,N);
    154135        }
    155136        else{
     
    158139       
    159140        /*Assign output pointers:*/
    160         if(pM) *pM=M;
     141        if(pN) *pN=N;
    161142        *poutput=output;
    162143}
     
    164145void  ControlParam::GetParameterValue(IssmDouble* poutput){/*{{{*/
    165146
    166         xMemCpy<IssmDouble>(poutput,value,M);
    167        
     147        /*Copy entire vector if M==1, or first row if M==2*/
     148        if(M==1){
     149                xMemCpy<IssmDouble>(poutput,value,N);
     150                return;
     151        }
     152
     153        _error_("STOP");
     154
    168155}
    169156/*}}}*/
    170157void  ControlParam::GetParameterValue(IssmDouble* poutput, IssmDouble time){/*{{{*/
    171158
     159        if(M==1){
     160                *poutput = value[0];
     161                return;
     162        }
     163
     164        IssmDouble *timesteps = &this->value[1*this->N+0];
     165        IssmDouble output;
     166        bool       found;
     167
     168        /*Ok, we have the time, go through the timesteps, and figure out which interval we
     169         *fall within. Then interpolate the values on this interval: */
     170        if(time<timesteps[0]){
     171                /*get values for the first time: */
     172                output=this->value[0];
     173                found=true;
     174        }
     175        else if(time>timesteps[this->N-1]){
     176                /*get values for the last time: */
     177                output=this->value[this->N-1];
     178                found=true;
     179        }
     180        else{
     181                /*Find which interval we fall within: */
     182                for(int i=0;i<this->N;i++){
     183                        if(time==timesteps[i]){
     184                                /*We are right on one step time: */
     185                                output=this->value[i];
     186                                found=true;
     187                                break; //we are done with the time interpolation.
     188                        }
     189                        else{
     190                                if(timesteps[i]<time && time<timesteps[i+1]){
     191                                        /*ok, we have the interval ]i:i+1[. Interpolate linearly for now: */
     192                                        IssmDouble deltat=timesteps[i+1]-timesteps[i];
     193                                        IssmDouble alpha=(time-timesteps[i])/deltat;
     194                                        output=(1.0-alpha)*this->value[i] + alpha*this->value[i+1];
     195                                        found=true;
     196                                        break;
     197                                }
     198                                else continue; //keep looking on the next interval
     199                        }
     200                }
     201        }
     202        if(!found)_error_("did not find time interval on which to interpolate values");
     203        //_printf_("for time = "<<time/31536000.<<" yr, melt = "<<output*31536000.<<" m/yr\n");
     204
     205        *poutput=output;
     206}
     207/*}}}*/
     208void  ControlParam::GetParameterValue(IssmDouble** poutput, int* pN){/*{{{*/
     209
     210        /*This method should be specific to VectorParams, only one tow required*/
     211        _assert_(N>0);
    172212        _assert_(M==1);
    173         *poutput = value[0];
    174 
    175 }
    176 /*}}}*/
    177 void  ControlParam::GetParameterValue(IssmDouble** poutput, int* pM){/*{{{*/
    178 
    179         IssmDouble* output=NULL;
    180 
    181         if(M){
    182                 output=xNew<IssmDouble>(M);
    183                 xMemCpy<IssmDouble>(output,value,M);
    184         }
     213        IssmDouble* output=xNew<IssmDouble>(N);
     214        xMemCpy<IssmDouble>(output,value,N);
    185215       
    186216        /*Assign output pointers:*/
    187         if(pM) *pM=M;
     217        if(pN) *pN=N;
    188218        *poutput=output;
    189        
    190 }
    191 /*}}}*/
    192 void  ControlParam::SetValue(IssmDouble* poutput, int in_M){/*{{{*/
    193 
    194         /*avoid leak: */
    195         xDelete<IssmDouble>(this->value);
    196        
    197         this->value=xNew<IssmDouble>(in_M);
    198         xMemCpy<IssmDouble>(this->value,poutput,in_M);
    199 
    200         this->M=in_M;
    201 }
    202 /*}}}*/
    203 void  ControlParam::SetGradient(IssmDouble* poutput, int in_M){/*{{{*/
    204 
    205         _assert_(in_M==this->M);
    206 
    207         /*avoid leak: */
    208         xDelete<IssmDouble>(this->gradient);
    209        
    210         this->gradient=xNew<IssmDouble>(in_M);
    211         xMemCpy<IssmDouble>(this->gradient,poutput,in_M);
    212 
    213         this->M=in_M;
    214 }
    215 /*}}}*/
    216 void  ControlParam::GetVectorFromControl(Vector<IssmDouble>* vector,int control_index,int N,const char* data,int offset){/*{{{*/
     219}
     220/*}}}*/
     221void  ControlParam::SetValue(IssmDouble* poutput,int in_M, int in_N){/*{{{*/
     222
     223        _assert_(in_N==this->N);
     224        _assert_(in_M==1);
     225        xMemCpy<IssmDouble>(this->value,poutput,in_N);
     226}
     227/*}}}*/
     228void  ControlParam::SetGradient(IssmDouble* poutput,int in_M, int in_N){/*{{{*/
     229
     230        _assert_(in_M==1);
     231        xMemCpy<IssmDouble>(this->gradient,poutput,in_N);
     232}
     233/*}}}*/
     234void  ControlParam::GetVectorFromControl(Vector<IssmDouble>* vector,int control_index,int in_N,const char* data,int offset){/*{{{*/
    217235
    218236        /*Get list of ids for this element and this control*/
    219         _assert_(N==this->M); //FIXME
    220         int* idlist = xNew<int>(this->M);
    221         for(int i=0;i<this->M;i++) idlist[i] = offset+i;
     237        _assert_(in_N==this->N);
     238        int* idlist = xNew<int>(this->N);
     239        for(int i=0;i<this->N;i++) idlist[i] = offset+i;
    222240
    223241        /*Get data*/
     
    226244
    227245        /*Enter data in vector*/
    228         vector->SetValues(this->M,idlist,values,INS_VAL);
     246        vector->SetValues(this->N,idlist,values,INS_VAL);
    229247
    230248        /*Clean up*/
  • issm/trunk-jpl/src/c/classes/Params/ControlParam.h

    r27719 r27756  
    2121
    2222        private:
    23                 IssmDouble* value;
     23                IssmDouble* value;   //Can either be a VecParam or a TransientParam
    2424                IssmDouble* minvalue;
    2525                IssmDouble* maxvalue;
    26                 IssmDouble* savedvalue;
    2726                IssmDouble* gradient;
    2827                int         enum_type;
    29                 int         M;
     28                int         M,N;
    3029
    3130        public:
    3231                /*ControlParam constructors, destructors: {{{*/
    3332                ControlParam();
    34                 ControlParam(IssmDouble* in_value, IssmDouble* in_minvalue, IssmDouble* in_maxvalue, IssmDouble* in_savedvalue, IssmDouble* in_gradient, int in_enum_type, int in_M);
    35                 ControlParam(IssmDouble* in_value, IssmDouble* in_minvalue, IssmDouble* in_maxvalue, int in_enum_type, int in_M);
     33                ControlParam(IssmDouble* in_value, IssmDouble* in_minvalue, IssmDouble* in_maxvalue, int in_enum_type, int in_M, int in_N);
    3634                ~ControlParam();
    3735                /*}}}*/
     
    7068                void  SetValue(char** stringarray,int M){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a string array");}
    7169                void  SetValue(IssmDouble* IssmDoublearray){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a scalar");}
    72                 void  SetValue(IssmDouble* IssmDoublearray,int M);
    73                 void  SetValue(IssmDouble* pIssmDoublearray,int M,int N){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a IssmDouble mat array");}
     70                void  SetValue(IssmDouble* IssmDoublearray,int M){_error_("not implemented");}
     71                void  SetValue(IssmDouble* pIssmDoublearray,int M,int N);
    7472                void  SetValue(int* intarray,int M){_error_("Param "<< EnumToStringx(enum_type) << " cannot return an integer");}
    7573                void  SetValue(int* pintarray,int M,int N){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a int mat array");}
     
    7876                void  SetValue(FILE* fid){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a FILE");}
    7977                void  SetValue(IssmDouble** array, int M, int* mdim_array, int* ndim_array){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold an array of matrices");}
    80                 void  SetGradient(IssmDouble* poutput, int M);
     78                void  SetGradient(IssmDouble* poutput, int M, int N);
    8179                void  GetVectorFromControl(Vector<IssmDouble>* vector,int control_index,int N,const char* data,int offset);
    8280                /*}}}*/
  • issm/trunk-jpl/src/c/classes/Params/DataSetParam.h

    r27696 r27756  
    7474                void  SetValue(DataSet* dataset);
    7575                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");}
    76                 void  SetGradient(IssmDouble* poutput, int M){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold an IssmDouble");};
     76                void  SetGradient(IssmDouble* poutput, int M, int N){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold an IssmDouble");};
    7777                /*}}}*/
    7878};
  • issm/trunk-jpl/src/c/classes/Params/DoubleMatArrayParam.h

    r27696 r27756  
    7575                void  SetValue(FILE* fid){_error_("Bool param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a FILE");}
    7676                void  SetValue(IssmDouble** array, int M, int* mdim_array, int* ndim_array);
    77                 void  SetGradient(IssmDouble* poutput, int M){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold an IssmDouble");};
     77                void  SetGradient(IssmDouble* poutput, int M, int N){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold an IssmDouble");};
    7878                /*}}}*/
    7979};
  • issm/trunk-jpl/src/c/classes/Params/DoubleMatParam.h

    r27696 r27756  
    7474                void  SetValue(IssmDouble** array, int M, int* mdim_array, int* ndim_array){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold an array of matrices");}
    7575                void  SetEnum(int enum_in){this->enum_type = enum_in;};
    76                 void  SetGradient(IssmDouble* poutput, int M){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold an IssmDouble");};
     76                void  SetGradient(IssmDouble* poutput, int M, int N){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold an IssmDouble");};
    7777                /*}}}*/
    7878                /*DoubleMatParam specific routines:{{{*/
  • issm/trunk-jpl/src/c/classes/Params/DoubleParam.h

    r27696 r27756  
    7373                void  SetValue(FILE* fid){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a FILE");}
    7474                void  SetValue(IssmDouble** array, int M, int* mdim_array, int* ndim_array){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold an array of matrices");}
    75                 void  SetGradient(IssmDouble* poutput, int M){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold an IssmDouble");};
     75                void  SetGradient(IssmDouble* poutput, int M, int N){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold an IssmDouble");};
    7676                /*}}}*/
    7777};
  • issm/trunk-jpl/src/c/classes/Params/DoubleVecParam.h

    r27696 r27756  
    7373                void  SetValue(FILE* fid){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a FILE");}
    7474                void  SetValue(IssmDouble** array, int M, int* mdim_array, int* ndim_array){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold an array of matrices");}
    75                 void  SetGradient(IssmDouble* poutput, int M){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold an IssmDouble");};
     75                void  SetGradient(IssmDouble* poutput, int M, int N){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold an IssmDouble");};
    7676                /*}}}*/
    7777                /*DoubleVecParam specific routines:{{{*/
  • issm/trunk-jpl/src/c/classes/Params/FileParam.h

    r27696 r27756  
    7272                void  SetValue(FILE* fid){_error_("File param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a FILE");}
    7373                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");}
    74                 void  SetGradient(IssmDouble* poutput, int M){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold an IssmDouble");};
     74                void  SetGradient(IssmDouble* poutput, int M, int N){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold an IssmDouble");};
    7575                /*}}}*/
    7676};
  • issm/trunk-jpl/src/c/classes/Params/GenericParam.h

    r27696 r27756  
    9999                void  SetValue(FILE* fid){_error_("Param "<< EnumToStringx(myEnumVal) << " cannot hold a FILE");}
    100100                void  SetValue(IssmDouble** array, int M, int* mdim_array, int* ndim_array){_error_("Param "<< EnumToStringx(myEnumVal) << " cannot hold an array of matrices");}
    101                                          void  SetGradient(IssmDouble* poutput, int M){_error_("Param "<< EnumToStringx(myEnumVal) << " cannot hold an IssmDouble");};
     101                                         void  SetGradient(IssmDouble* poutput, int M, int N){_error_("Param "<< EnumToStringx(myEnumVal) << " cannot hold an IssmDouble");};
    102102
    103103                /*}}}*/
  • issm/trunk-jpl/src/c/classes/Params/IntMatParam.h

    r27696 r27756  
    7474                void  SetValue(FILE* fid){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a FILE");}
    7575                void  SetValue(IssmDouble** array, int M, int* mdim_array, int* ndim_array){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold an array of matrices");}
    76                 void  SetGradient(IssmDouble* poutput, int M){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold an IssmDouble");};
     76                void  SetGradient(IssmDouble* poutput, int M, int N){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold an IssmDouble");};
    7777                /*}}}*/
    7878};
  • issm/trunk-jpl/src/c/classes/Params/IntParam.h

    r27696 r27756  
    7373                void  SetValue(FILE* fid){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a FILE");}
    7474                void  SetValue(IssmDouble** array, int M, int* mdim_array, int* ndim_array){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold an array of matrices");}
    75                 void  SetGradient(IssmDouble* poutput, int M){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold an IssmDouble");};
     75                void  SetGradient(IssmDouble* poutput, int M, int N){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold an IssmDouble");};
    7676                /*}}}*/
    7777};
  • issm/trunk-jpl/src/c/classes/Params/IntVecParam.h

    r27696 r27756  
    7474                void  SetValue(FILE* fid){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a FILE");}
    7575                void  SetValue(IssmDouble** array, int M, int* mdim_array, int* ndim_array){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold an array of matrices");}
    76                 void  SetGradient(IssmDouble* poutput, int M){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold an IssmDouble");};
     76                void  SetGradient(IssmDouble* poutput, int M, int N){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold an IssmDouble");};
    7777                /*}}}*/
    7878};
  • issm/trunk-jpl/src/c/classes/Params/MatrixParam.h

    r27696 r27756  
    7373                void  SetValue(FILE* fid){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a FILE");}
    7474                void  SetValue(IssmDouble** array, int M, int* mdim_array, int* ndim_array){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold an array of matrices");}
    75                 void  SetGradient(IssmDouble* poutput, int M){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold an IssmDouble");};
     75                void  SetGradient(IssmDouble* poutput, int M, int N){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold an IssmDouble");};
    7676                /*}}}*/
    7777};
  • issm/trunk-jpl/src/c/classes/Params/Param.h

    r27719 r27756  
    6565                virtual void  SetValue(FILE* fid)=0;
    6666                virtual void  SetValue(IssmDouble** array, int M, int* mdim_array, int* ndim_array)=0;
    67                 virtual void  SetGradient(IssmDouble* poutput, int M)=0;
     67                virtual void  SetGradient(IssmDouble* poutput, int M, int N)=0;
    6868                virtual void  GetVectorFromControl(Vector<IssmDouble>* vector,int control_index,int N,const char* data,int offset){_error_("not implemented yet");};
    6969};
  • issm/trunk-jpl/src/c/classes/Params/Parameters.cpp

    r27724 r27756  
    655655        param=xDynamicCast<Param*>(this->FindParamObject(enum_type));
    656656
    657         if(param) param->SetValue(&vector[offset], M);
     657        if(param) param->SetValue(&vector[offset], M, N);
    658658        else _error_("Param "<< EnumToStringx(enum_type) << " cannot setValue");
    659659}
     
    665665        param=xDynamicCast<Param*>(this->FindParamObject(enum_type));
    666666
    667         if(param) param->SetGradient(&vector[offset], M);
     667        if(param) param->SetGradient(&vector[offset], M, N);
    668668        else _error_("Param "<< EnumToStringx(enum_type) << " cannot setValue");
    669 }
    670 /*}}}*/
    671 void   Parameters::ControlParamSetGradient(IssmDouble* IssmDoublearray, int M, int enum_type){/*{{{*/
    672 
    673         Param* param=NULL;
    674 
    675         /*first, figure out if the param has already been created: */
    676         param=xDynamicCast<Param*>(this->FindParamObject(enum_type));
    677         if(param) param->SetGradient(IssmDoublearray,M); //already exists, just set it.
    678         else _error_("Param "<< EnumToStringx(enum_type) << " cannot setValue");
    679 
    680          //this->AddObject(new ControlParam(enum_type,IssmDoublearray,M,N)); //just add the new parameter.
    681669}
    682670/*}}}*/
  • issm/trunk-jpl/src/c/classes/Params/Parameters.h

    r27724 r27756  
    7676                void  SetControlFromVector(IssmDouble* array, int enum_type, int M, int N, int offset);
    7777                void  SetGradientFromVector(IssmDouble* array, int enum_type, int M, int N, int offset);
    78                 void  ControlParamSetGradient(IssmDouble* IssmDoublearray, int M, int enum_type);
    7978                void  GetVectorFromControl(Vector<IssmDouble>* vector,int control_enum,int control_index,int N,const char* data,int offset);
    8079                Param* FindParamObject(int enum_type);
  • issm/trunk-jpl/src/c/classes/Params/StringArrayParam.h

    r27696 r27756  
    7373                void  SetValue(FILE* fid){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a FILE");}
    7474                void  SetValue(IssmDouble** array, int M, int* mdim_array, int* ndim_array){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold an array of matrices");}
    75                 void  SetGradient(IssmDouble* poutput, int M){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold an IssmDouble");};
     75                void  SetGradient(IssmDouble* poutput, int M, int N){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold an IssmDouble");};
    7676                /*}}}*/
    7777};
  • issm/trunk-jpl/src/c/classes/Params/StringParam.h

    r27696 r27756  
    7373                void  SetValue(FILE* fid){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a FILE");}
    7474                void  SetValue(IssmDouble** array, int M, int* mdim_array, int* ndim_array){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold an array of matrices");}
    75                 void  SetGradient(IssmDouble* poutput, int M){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold an IssmDouble");};
     75                void  SetGradient(IssmDouble* poutput, int M, int N){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold an IssmDouble");};
    7676                /*}}}*/
    7777};
  • issm/trunk-jpl/src/c/classes/Params/TransientArrayParam.h

    r27696 r27756  
    7878                void  SetValue(FILE* fid){_error_("Parameter " <<EnumToStringx(enum_type) << " cannot hold a FILE");}
    7979                void  SetValue(IssmDouble** array, int M, int* mdim_array, int* ndim_array){_error_("Parameter " <<EnumToStringx(enum_type) << " cannot hold an array of matrices");}
    80                 void  SetGradient(IssmDouble* poutput, int M){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold an IssmDouble");};
     80                void  SetGradient(IssmDouble* poutput, int M, int N){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold an IssmDouble");};
    8181                /*}}}*/
    8282};
  • issm/trunk-jpl/src/c/classes/Params/TransientParam.h

    r27696 r27756  
    7676                void  SetValue(FILE* fid){_error_("Parameter " <<EnumToStringx(enum_type) << " cannot hold a FILE");}
    7777                void  SetValue(IssmDouble** array, int M, int* mdim_array, int* ndim_array){_error_("Parameter " <<EnumToStringx(enum_type) << " cannot hold an array of matrices");}
    78                 void  SetGradient(IssmDouble* poutput, int M){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold an IssmDouble");};
     78                void  SetGradient(IssmDouble* poutput, int M, int N){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold an IssmDouble");};
    7979                /*}}}*/
    8080};
  • issm/trunk-jpl/src/c/classes/Params/VectorParam.h

    r27696 r27756  
    7373                void  SetValue(FILE* fid){_error_("Vector of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a FILE");}
    7474                void  SetValue(IssmDouble** array, int M, int* mdim_array, int* ndim_array){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold an array of matrices");}
    75                 void  SetGradient(IssmDouble* poutput, int M){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold an IssmDouble");};
     75                void  SetGradient(IssmDouble* poutput, int M, int N){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold an IssmDouble");};
    7676                /*}}}*/
    7777};
  • issm/trunk-jpl/src/c/cores/controladm1qn3_core.cpp

    r27732 r27756  
    662662        }
    663663        else{
     664                //FIXME: merge with code above?
    664665                femmodel->results->AddObject(new GenericExternalResult<IssmPDouble*>(femmodel->results->Size()+1,JEnum,mystruct.Jlist,(*mystruct.i),mystruct.N,0,0));
    665 
    666666                femmodel->OutputControlsx(&femmodel->results);
    667667        }
  • issm/trunk-jpl/src/c/modules/ModelProcessorx/Control/UpdateElementsAndMaterialsControl.cpp

    r27731 r27756  
    117117        for(int i=0;i<num_controls;i++){
    118118                control = control_enums[i];
     119                if(!IsInputEnum(control)) _error_("Only inputs can be parameters except if you use AD");
    119120                scale   = 1.;
    120121
     
    264265                                }
    265266                        }
    266                         if(N!=1) M_all[i]=M-1;
    267267
    268268                        if(IsInputEnum(input_enum)){
     269
     270                                /*remove last row if time series*/
     271                                if(N!=1) M_all[i]=M-1;
     272
    269273                                if(M_all[i]==iomodel->numberofvertices){
    270274                                        Interp_all[i] = P1Enum;
     
    284288                        else if(IsParamEnum(input_enum)){
    285289                                //_error_("not supported yet");
    286                                 Interp_all[i] = P0Enum;
    287                                 parameters->AddObject(new ControlParam(independent,independents_min,independents_max,input_enum,M_all[i]));
    288 
     290                                Interp_all[i] = DummyEnum; //Placeholder
     291                                parameters->AddObject(new ControlParam(independent,independents_min,independents_max,input_enum,M_all[i],N_all[i]));
     292
     293                                if(M!=1){
     294                                        _assert_(M==2); //TransientParam
     295                                        M_all[i]=M-1;
     296                                }
    289297                        }
    290298                        xDelete<IssmDouble>(independent);
Note: See TracChangeset for help on using the changeset viewer.