Changeset 27756
- Timestamp:
- 05/16/23 05:47:13 (22 months ago)
- Location:
- issm/trunk-jpl/src/c
- Files:
-
- 24 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/c/classes/Params/BoolParam.h
r27696 r27756 72 72 void SetValue(FILE* fid){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a FILE");} 73 73 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");}; 75 75 /*}}}*/ 76 76 }; -
issm/trunk-jpl/src/c/classes/Params/ControlParam.cpp
r27730 r27756 17 17 } 18 18 /*}}}*/ 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 19 ControlParam::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); 74 40 } 75 41 /*}}}*/ … … 79 45 xDelete<IssmDouble>(maxvalue); 80 46 xDelete<IssmDouble>(gradient); 81 xDelete<IssmDouble>(savedvalue);82 47 return; 83 48 } … … 87 52 Param* ControlParam::copy() {/*{{{*/ 88 53 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; 90 75 91 76 } … … 97 82 for(int i=0;i<this->M;i++) _printf_(" "<< this->value[i]); 98 83 _printf_("]\n"); 99 if (savedvalue) _printf_("---savedvalue: " << this->savedvalue << "\n");100 84 if (minvalue) _printf_("---minvalue: "); 101 85 for(int i=0;i<this->M;i++) _printf_(" "<< this->minvalue[i]); … … 119 103 marshallhandle->call(this->enum_type); 120 104 marshallhandle->call(this->M); 121 marshallhandle->call(this-> value,this->M);122 marshallhandle->call(this-> minvalue,this->M);123 marshallhandle->call(this->m axvalue,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); 126 110 127 111 } … … 134 118 /*}}}*/ 135 119 136 void ControlParam::GetParameterValue(IssmDouble** poutput,int* p M, const char* data){/*{{{*/137 138 IssmDouble* output=xNew<IssmDouble>( M);120 void ControlParam::GetParameterValue(IssmDouble** poutput,int* pN, const char* data){/*{{{*/ 121 122 IssmDouble* output=xNew<IssmDouble>(N); 139 123 140 124 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); 145 126 } 146 127 else if (strcmp(data,"lowerbound")==0){ 147 xMemCpy<IssmDouble>(output,minvalue, M);128 xMemCpy<IssmDouble>(output,minvalue,N); 148 129 } 149 130 else if (strcmp(data,"upperbound")==0){ 150 xMemCpy<IssmDouble>(output,maxvalue, M);131 xMemCpy<IssmDouble>(output,maxvalue,N); 151 132 } 152 133 else if (strcmp(data,"gradient")==0){ 153 xMemCpy<IssmDouble>(output,gradient, M);134 xMemCpy<IssmDouble>(output,gradient,N); 154 135 } 155 136 else{ … … 158 139 159 140 /*Assign output pointers:*/ 160 if(p M) *pM=M;141 if(pN) *pN=N; 161 142 *poutput=output; 162 143 } … … 164 145 void ControlParam::GetParameterValue(IssmDouble* poutput){/*{{{*/ 165 146 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 168 155 } 169 156 /*}}}*/ 170 157 void ControlParam::GetParameterValue(IssmDouble* poutput, IssmDouble time){/*{{{*/ 171 158 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 /*}}}*/ 208 void ControlParam::GetParameterValue(IssmDouble** poutput, int* pN){/*{{{*/ 209 210 /*This method should be specific to VectorParams, only one tow required*/ 211 _assert_(N>0); 172 212 _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); 185 215 186 216 /*Assign output pointers:*/ 187 if(p M) *pM=M;217 if(pN) *pN=N; 188 218 *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 /*}}}*/ 221 void 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 /*}}}*/ 228 void 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 /*}}}*/ 234 void ControlParam::GetVectorFromControl(Vector<IssmDouble>* vector,int control_index,int in_N,const char* data,int offset){/*{{{*/ 217 235 218 236 /*Get list of ids for this element and this control*/ 219 _assert_( N==this->M); //FIXME220 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; 222 240 223 241 /*Get data*/ … … 226 244 227 245 /*Enter data in vector*/ 228 vector->SetValues(this-> M,idlist,values,INS_VAL);246 vector->SetValues(this->N,idlist,values,INS_VAL); 229 247 230 248 /*Clean up*/ -
issm/trunk-jpl/src/c/classes/Params/ControlParam.h
r27719 r27756 21 21 22 22 private: 23 IssmDouble* value; 23 IssmDouble* value; //Can either be a VecParam or a TransientParam 24 24 IssmDouble* minvalue; 25 25 IssmDouble* maxvalue; 26 IssmDouble* savedvalue;27 26 IssmDouble* gradient; 28 27 int enum_type; 29 int M ;28 int M,N; 30 29 31 30 public: 32 31 /*ControlParam constructors, destructors: {{{*/ 33 32 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); 36 34 ~ControlParam(); 37 35 /*}}}*/ … … 70 68 void SetValue(char** stringarray,int M){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a string array");} 71 69 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); 74 72 void SetValue(int* intarray,int M){_error_("Param "<< EnumToStringx(enum_type) << " cannot return an integer");} 75 73 void SetValue(int* pintarray,int M,int N){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a int mat array");} … … 78 76 void SetValue(FILE* fid){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a FILE");} 79 77 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); 81 79 void GetVectorFromControl(Vector<IssmDouble>* vector,int control_index,int N,const char* data,int offset); 82 80 /*}}}*/ -
issm/trunk-jpl/src/c/classes/Params/DataSetParam.h
r27696 r27756 74 74 void SetValue(DataSet* dataset); 75 75 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");}; 77 77 /*}}}*/ 78 78 }; -
issm/trunk-jpl/src/c/classes/Params/DoubleMatArrayParam.h
r27696 r27756 75 75 void SetValue(FILE* fid){_error_("Bool param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a FILE");} 76 76 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");}; 78 78 /*}}}*/ 79 79 }; -
issm/trunk-jpl/src/c/classes/Params/DoubleMatParam.h
r27696 r27756 74 74 void SetValue(IssmDouble** array, int M, int* mdim_array, int* ndim_array){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold an array of matrices");} 75 75 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");}; 77 77 /*}}}*/ 78 78 /*DoubleMatParam specific routines:{{{*/ -
issm/trunk-jpl/src/c/classes/Params/DoubleParam.h
r27696 r27756 73 73 void SetValue(FILE* fid){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a FILE");} 74 74 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");}; 76 76 /*}}}*/ 77 77 }; -
issm/trunk-jpl/src/c/classes/Params/DoubleVecParam.h
r27696 r27756 73 73 void SetValue(FILE* fid){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a FILE");} 74 74 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");}; 76 76 /*}}}*/ 77 77 /*DoubleVecParam specific routines:{{{*/ -
issm/trunk-jpl/src/c/classes/Params/FileParam.h
r27696 r27756 72 72 void SetValue(FILE* fid){_error_("File param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a FILE");} 73 73 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");}; 75 75 /*}}}*/ 76 76 }; -
issm/trunk-jpl/src/c/classes/Params/GenericParam.h
r27696 r27756 99 99 void SetValue(FILE* fid){_error_("Param "<< EnumToStringx(myEnumVal) << " cannot hold a FILE");} 100 100 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");}; 102 102 103 103 /*}}}*/ -
issm/trunk-jpl/src/c/classes/Params/IntMatParam.h
r27696 r27756 74 74 void SetValue(FILE* fid){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a FILE");} 75 75 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");}; 77 77 /*}}}*/ 78 78 }; -
issm/trunk-jpl/src/c/classes/Params/IntParam.h
r27696 r27756 73 73 void SetValue(FILE* fid){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a FILE");} 74 74 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");}; 76 76 /*}}}*/ 77 77 }; -
issm/trunk-jpl/src/c/classes/Params/IntVecParam.h
r27696 r27756 74 74 void SetValue(FILE* fid){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a FILE");} 75 75 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");}; 77 77 /*}}}*/ 78 78 }; -
issm/trunk-jpl/src/c/classes/Params/MatrixParam.h
r27696 r27756 73 73 void SetValue(FILE* fid){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a FILE");} 74 74 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");}; 76 76 /*}}}*/ 77 77 }; -
issm/trunk-jpl/src/c/classes/Params/Param.h
r27719 r27756 65 65 virtual void SetValue(FILE* fid)=0; 66 66 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; 68 68 virtual void GetVectorFromControl(Vector<IssmDouble>* vector,int control_index,int N,const char* data,int offset){_error_("not implemented yet");}; 69 69 }; -
issm/trunk-jpl/src/c/classes/Params/Parameters.cpp
r27724 r27756 655 655 param=xDynamicCast<Param*>(this->FindParamObject(enum_type)); 656 656 657 if(param) param->SetValue(&vector[offset], M );657 if(param) param->SetValue(&vector[offset], M, N); 658 658 else _error_("Param "<< EnumToStringx(enum_type) << " cannot setValue"); 659 659 } … … 665 665 param=xDynamicCast<Param*>(this->FindParamObject(enum_type)); 666 666 667 if(param) param->SetGradient(&vector[offset], M );667 if(param) param->SetGradient(&vector[offset], M, N); 668 668 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.681 669 } 682 670 /*}}}*/ -
issm/trunk-jpl/src/c/classes/Params/Parameters.h
r27724 r27756 76 76 void SetControlFromVector(IssmDouble* array, int enum_type, int M, int N, int offset); 77 77 void SetGradientFromVector(IssmDouble* array, int enum_type, int M, int N, int offset); 78 void ControlParamSetGradient(IssmDouble* IssmDoublearray, int M, int enum_type);79 78 void GetVectorFromControl(Vector<IssmDouble>* vector,int control_enum,int control_index,int N,const char* data,int offset); 80 79 Param* FindParamObject(int enum_type); -
issm/trunk-jpl/src/c/classes/Params/StringArrayParam.h
r27696 r27756 73 73 void SetValue(FILE* fid){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a FILE");} 74 74 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");}; 76 76 /*}}}*/ 77 77 }; -
issm/trunk-jpl/src/c/classes/Params/StringParam.h
r27696 r27756 73 73 void SetValue(FILE* fid){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a FILE");} 74 74 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");}; 76 76 /*}}}*/ 77 77 }; -
issm/trunk-jpl/src/c/classes/Params/TransientArrayParam.h
r27696 r27756 78 78 void SetValue(FILE* fid){_error_("Parameter " <<EnumToStringx(enum_type) << " cannot hold a FILE");} 79 79 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");}; 81 81 /*}}}*/ 82 82 }; -
issm/trunk-jpl/src/c/classes/Params/TransientParam.h
r27696 r27756 76 76 void SetValue(FILE* fid){_error_("Parameter " <<EnumToStringx(enum_type) << " cannot hold a FILE");} 77 77 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");}; 79 79 /*}}}*/ 80 80 }; -
issm/trunk-jpl/src/c/classes/Params/VectorParam.h
r27696 r27756 73 73 void SetValue(FILE* fid){_error_("Vector of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a FILE");} 74 74 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");}; 76 76 /*}}}*/ 77 77 }; -
issm/trunk-jpl/src/c/cores/controladm1qn3_core.cpp
r27732 r27756 662 662 } 663 663 else{ 664 //FIXME: merge with code above? 664 665 femmodel->results->AddObject(new GenericExternalResult<IssmPDouble*>(femmodel->results->Size()+1,JEnum,mystruct.Jlist,(*mystruct.i),mystruct.N,0,0)); 665 666 666 femmodel->OutputControlsx(&femmodel->results); 667 667 } -
issm/trunk-jpl/src/c/modules/ModelProcessorx/Control/UpdateElementsAndMaterialsControl.cpp
r27731 r27756 117 117 for(int i=0;i<num_controls;i++){ 118 118 control = control_enums[i]; 119 if(!IsInputEnum(control)) _error_("Only inputs can be parameters except if you use AD"); 119 120 scale = 1.; 120 121 … … 264 265 } 265 266 } 266 if(N!=1) M_all[i]=M-1;267 267 268 268 if(IsInputEnum(input_enum)){ 269 270 /*remove last row if time series*/ 271 if(N!=1) M_all[i]=M-1; 272 269 273 if(M_all[i]==iomodel->numberofvertices){ 270 274 Interp_all[i] = P1Enum; … … 284 288 else if(IsParamEnum(input_enum)){ 285 289 //_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 } 289 297 } 290 298 xDelete<IssmDouble>(independent);
Note:
See TracChangeset
for help on using the changeset viewer.