Changeset 20827
- Timestamp:
- 06/28/16 15:51:32 (9 years ago)
- 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 66 66 IssmDouble Min(void){_error_("Min not implemented for booleans");}; 67 67 IssmDouble MinAbs(void){_error_("Min not implemented for booleans");}; 68 void Scale(IssmDouble scale_factor); 68 69 void Set(IssmDouble setvalue){_error_("Set not implemented yet");}; 69 void Scale(IssmDouble scale_factor);70 70 void SquareMin(IssmDouble* psquaremin, Parameters* parameters); 71 71 void VerticallyIntegrate(Input* thickness_input){_error_("not supported yet");}; -
issm/trunk-jpl/src/c/classes/Inputs/ControlInput.cpp
r19254 r20827 56 56 57 57 /*Object virtual functions definitions:*/ 58 void ControlInput::Echo(void){/*{{{*/ 59 this->DeepEcho(); 58 Object* 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; 60 73 } 61 74 /*}}}*/ … … 71 84 } 72 85 /*}}}*/ 86 void ControlInput::Echo(void){/*{{{*/ 87 this->DeepEcho(); 88 } 89 /*}}}*/ 73 90 int 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 }97 91 /*}}}*/ 98 92 void ControlInput::Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ /*{{{*/ … … 130 124 } 131 125 /*}}}*/ 126 int ControlInput::ObjectEnum(void){/*{{{*/ 127 128 return ControlInputEnum; 129 130 } 131 /*}}}*/ 132 132 133 133 /*ControlInput management*/ … … 143 143 values->AXPY(xinput,scalar); 144 144 }/*}}}*/ 145 void ControlInput::Configure(Parameters* parameters){/*{{{*/ 146 /*do nothing: */ 147 } 148 /*}}}*/ 145 149 void ControlInput::Constrain(void){/*{{{*/ 146 150 … … 160 164 //gradient->Extrude(); 161 165 }/*}}}*/ 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 /*}}}*/174 166 void ControlInput::GetGradient(Vector<IssmDouble>* gradient_vec,int* doflist){/*{{{*/ 175 167 if(gradient) gradient->GetVectorFromInputs(gradient_vec,doflist); 168 }/*}}}*/ 169 void ControlInput::GetGradientValue(IssmDouble* pvalue,Gauss* gauss){/*{{{*/ 170 gradient->GetInputValue(pvalue,gauss); 171 }/*}}}*/ 172 void ControlInput::GetInputAverage(IssmDouble* pvalue){/*{{{*/ 173 values->GetInputAverage(pvalue); 174 }/*}}}*/ 175 void ControlInput::GetInputDerivativeValue(IssmDouble* derivativevalues, IssmDouble* xyz_list, Gauss* gauss){/*{{{*/ 176 values->GetInputDerivativeValue(derivativevalues,xyz_list,gauss); 177 }/*}}}*/ 178 void ControlInput::GetInputValue(bool* pvalue){/*{{{*/ 179 values->GetInputValue(pvalue); 180 }/*}}}*/ 181 void ControlInput::GetInputValue(int* pvalue){/*{{{*/ 182 values->GetInputValue(pvalue); 183 }/*}}}*/ 184 void ControlInput::GetInputValue(IssmDouble* pvalue){/*{{{*/ 185 values->GetInputValue(pvalue); 186 }/*}}}*/ 187 void ControlInput::GetInputValue(IssmDouble* pvalue,Gauss* gauss){/*{{{*/ 188 values->GetInputValue(pvalue,gauss); 189 }/*}}}*/ 190 int ControlInput::GetResultInterpolation(void){/*{{{*/ 191 192 return values->GetResultInterpolation(); 193 194 } 195 /*}}}*/ 196 int ControlInput::GetResultNumberOfNodes(void){/*{{{*/ 197 198 return values->GetResultNumberOfNodes(); 199 200 } 201 /*}}}*/ 202 void ControlInput::GetVectorFromInputs(Vector<IssmDouble>* vector,int* doflist){/*{{{*/ 203 values->GetVectorFromInputs(vector,doflist); 204 }/*}}}*/ 205 void 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 }/*}}}*/ 226 IssmDouble ControlInput::Min(void){/*{{{*/ 227 228 return values->Min(); 229 230 } 231 /*}}}*/ 232 void 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()); 176 237 }/*}}}*/ 177 238 void ControlInput::ScaleGradient(IssmDouble scaling_factor){/*{{{*/ … … 207 268 208 269 }/*}}}*/ 270 Input* ControlInput::SpawnSegInput(int index1,int index2){/*{{{*/ 271 return values->SpawnSegInput(index1,index2); 272 }/*}}}*/ 209 273 Input* ControlInput::SpawnTriaInput(int index1,int index2,int index3){/*{{{*/ 210 274 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());271 275 }/*}}}*/ 272 276 void ControlInput::UpdateValue(IssmDouble scalar){/*{{{*/ … … 281 285 values->VerticallyIntegrate(thickness_input); 282 286 }/*}}}*/ 283 void ControlInput::Configure(Parameters* parameters){/*{{{*/284 /*do nothing: */285 }286 /*}}}*/ -
issm/trunk-jpl/src/c/classes/Inputs/ControlInput.h
r19725 r20827 16 16 17 17 public: 18 int control_id; 18 19 int enum_type; 19 int control_id; 20 Input* gradient; 21 Input* maxvalues; 22 Input* minvalues; 23 Input* savedvalues; 20 24 Input* values; 21 Input* savedvalues;22 Input* minvalues;23 Input* maxvalues;24 Input* gradient;25 25 26 26 /*ControlInput constructors, destructors: {{{*/ … … 30 30 /*}}}*/ 31 31 /*Object virtual functions definitions:{{{ */ 32 Object* copy(); 33 void DeepEcho(); 32 34 void Echo(); 33 void DeepEcho();34 35 int Id(); 36 void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction); 35 37 int ObjectEnum(); 36 Object* copy();37 void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);38 38 /*}}}*/ 39 39 /*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");};46 40 void AddTimeValues(IssmDouble* values,int step,IssmDouble time){_error_("not supported yet");}; 47 41 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); 48 48 /*}}}*/ 49 49 /*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); 50 57 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");}; 52 63 void GetInputValue(bool* pvalue); 53 64 void GetInputValue(int* pvalue); … … 56 67 void GetInputValue(IssmDouble* pvalue,Gauss* gauss,IssmDouble time){_error_("not implemented yet");}; 57 68 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); 71 74 IssmDouble InfinityNorm(void){_error_("not implemented yet");}; 72 75 IssmDouble Max(void){_error_("not implemented yet");}; … … 74 77 IssmDouble Min(void); 75 78 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); 77 88 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);89 89 /*}}}*/ 90 90 -
issm/trunk-jpl/src/c/classes/Inputs/DatasetInput.cpp
r19254 r20827 36 36 37 37 /*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 /*}}}*/61 38 Object* DatasetInput::copy() {/*{{{*/ 62 39 … … 73 50 } 74 51 /*}}}*/ 52 void 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 /*}}}*/ 63 void DatasetInput::Echo(void){/*{{{*/ 64 this->DeepEcho(); 65 } 66 /*}}}*/ 67 int DatasetInput::Id(void){ return -1; }/*{{{*/ 68 /*}}}*/ 75 69 void DatasetInput::Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ /*{{{*/ 76 70 … … 85 79 } 86 80 /*}}}*/ 87 Input* DatasetInput::SpawnTriaInput(int index1,int index2,int index3){/*{{{*/81 int DatasetInput::ObjectEnum(void){/*{{{*/ 88 82 89 /*output*/ 90 DatasetInput* outinput=NULL; 83 return DatasetInputEnum; 91 84 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;102 85 } 103 86 /*}}}*/ … … 111 94 outinput->enum_type=this->enum_type; 112 95 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 /*}}}*/ 104 Input* 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)); 113 113 outinput->numids=this->numids; 114 114 outinput->ids=xNew<int>(this->numids); -
issm/trunk-jpl/src/c/classes/Inputs/DatasetInput.h
r19725 r20827 27 27 /*}}}*/ 28 28 /*Object virtual functions definitions:{{{ */ 29 Object* copy(); 30 void DeepEcho(); 29 31 void Echo(); 30 void DeepEcho();31 32 int Id(); 33 void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction); 32 34 int ObjectEnum(); 33 Object* copy();34 void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);35 35 /*}}}*/ 36 36 /*DatasetInput management: {{{*/ 37 37 void AddInput(Input* input,int id); 38 void AddTimeValues(IssmDouble* values,int step,IssmDouble time){_error_("not supported yet");}; 39 void Configure(Parameters* parameters); 38 40 int InstanceEnum(); 39 Input* SpawnTriaInput(int index1,int index2,int index3);40 Input* SpawnSegInput(int index1,int index2);41 41 Input* PointwiseDivide(Input* inputB){_error_("not implemented yet");}; 42 42 Input* PointwiseMin(Input* inputB){_error_("not implemented yet");}; 43 43 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); 46 46 /*}}}*/ 47 47 /*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");}; 48 59 void GetInputValue(bool* pvalue){_error_("not implemented yet");}; 49 60 void GetInputValue(int* pvalue){_error_("not implemented yet");}; … … 52 63 void GetInputValue(IssmDouble* pvalue,Gauss* gauss,IssmDouble time){_error_("not implemented yet");}; 53 64 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");};58 65 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");}; 67 70 IssmDouble InfinityNorm(void){_error_("not implemented yet");}; 68 71 IssmDouble Max(void){_error_("not implemented yet");}; … … 70 73 IssmDouble Min(void){_error_("not implemented yet");}; 71 74 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");}; 73 83 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");};84 84 /*}}}*/ 85 85 -
issm/trunk-jpl/src/c/classes/Inputs/DoubleArrayInput.cpp
r19584 r20827 35 35 36 36 /*Object virtual functions definitions:*/ 37 void DoubleArrayInput::Echo(void){/*{{{*/ 38 this->DeepEcho(); 37 Object* DoubleArrayInput::copy() {/*{{{*/ 38 39 return new DoubleArrayInput(this->enum_type,this->values,this->m); 40 39 41 } 40 42 /*}}}*/ … … 46 48 } 47 49 /*}}}*/ 48 int DoubleArrayInput::Id(void){ return -1; }/*{{{*/ 49 /*}}}*/ 50 int DoubleArrayInput::ObjectEnum(void){/*{{{*/ 51 52 return DoubleArrayInputEnum; 53 50 void DoubleArrayInput::Echo(void){/*{{{*/ 51 this->DeepEcho(); 54 52 } 55 53 /*}}}*/ 56 Object* DoubleArrayInput::copy() {/*{{{*/ 57 58 return new DoubleArrayInput(this->enum_type,this->values,this->m); 59 60 } 54 int DoubleArrayInput::Id(void){ return -1; }/*{{{*/ 61 55 /*}}}*/ 62 56 void DoubleArrayInput::Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ /*{{{*/ … … 69 63 } 70 64 /*}}}*/ 65 int DoubleArrayInput::ObjectEnum(void){/*{{{*/ 66 67 return DoubleArrayInputEnum; 68 69 } 70 /*}}}*/ 71 71 72 72 /*DoubleArrayInput management*/ 73 void 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 /*}}}*/ 73 87 int DoubleArrayInput::InstanceEnum(void){/*{{{*/ 74 88 … … 89 103 } 90 104 /*}}}*/ 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 /*}}}*/105 105 106 106 /*Object functions*/ -
issm/trunk-jpl/src/c/classes/Inputs/DoubleArrayInput.h
r19725 r20827 24 24 /*}}}*/ 25 25 /*Object virtual functions definitions:{{{ */ 26 Object* copy(); 27 void DeepEcho(); 26 28 void Echo(); 27 void DeepEcho();28 29 int Id(); 30 void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction); 29 31 int ObjectEnum(); 30 Object* copy();31 void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);32 32 /*}}}*/ 33 33 /*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;}; 40 37 int GetResultInterpolation(void){return P0ArrayEnum;}; 41 38 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");}; 43 43 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");}; 46 46 /*}}}*/ 47 47 /*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");}; 48 57 void GetInputValue(bool* pvalue){_error_("not implemented yet");}; 49 58 void GetInputValue(int* pvalue){_error_("not implemented yet");}; … … 52 61 void GetInputValue(IssmDouble* pvalue,Gauss* gauss,IssmDouble time){_error_("not implemented yet");}; 53 62 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");};58 63 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");}; 66 65 IssmDouble InfinityNorm(void){_error_("not implemented yet");}; 67 66 IssmDouble Max(void){_error_("not implemented yet");}; … … 69 68 IssmDouble Min(void){_error_("not implemented yet");}; 70 69 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");}; 72 73 void VerticallyIntegrate(Input* thickness_input){_error_("not implemented yet");}; 73 void GetVectorFromInputs(Vector<IssmDouble>* vector,int* doflist){_error_("not implemented yet");};74 74 /*}}}*/ 75 75 -
issm/trunk-jpl/src/c/classes/Inputs/DoubleInput.cpp
r19254 r20827 29 29 30 30 /*Object virtual functions definitions:*/ 31 Object* DoubleInput::copy() {/*{{{*/ 32 33 return new DoubleInput(this->enum_type,this->value); 34 35 } 36 /*}}}*/ 37 void DoubleInput::DeepEcho(void){/*{{{*/ 38 39 _printf_(setw(15)<<" DoubleInput "<<setw(25)<<left<<EnumToStringx(this->enum_type)<<" "<<this->value<<"\n"); 40 } 41 /*}}}*/ 31 42 void DoubleInput::Echo(void){/*{{{*/ 32 43 this->DeepEcho(); 33 44 } 34 45 /*}}}*/ 35 void DoubleInput::DeepEcho(void){/*{{{*/36 37 _printf_(setw(15)<<" DoubleInput "<<setw(25)<<left<<EnumToStringx(this->enum_type)<<" "<<this->value<<"\n");38 }39 /*}}}*/40 46 int 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 }53 47 /*}}}*/ 54 48 void DoubleInput::Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ /*{{{*/ … … 61 55 } 62 56 /*}}}*/ 57 int DoubleInput::ObjectEnum(void){/*{{{*/ 58 59 return DoubleInputEnum; 60 61 } 62 /*}}}*/ 63 63 64 64 /*DoubleInput management*/ … … 69 69 } 70 70 /*}}}*/ 71 Input* DoubleInput::Spawn TriaInput(int index1,int index2,int index3){/*{{{*/71 Input* DoubleInput::SpawnSegInput(int index1,int index2){/*{{{*/ 72 72 73 73 /*output*/ … … 83 83 } 84 84 /*}}}*/ 85 Input* DoubleInput::Spawn SegInput(int index1,int index2){/*{{{*/85 Input* DoubleInput::SpawnTriaInput(int index1,int index2,int index3){/*{{{*/ 86 86 87 87 /*output*/ … … 99 99 100 100 /*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 /*}}}*/137 101 void DoubleInput::AXPY(Input* xinput,IssmDouble scalar){/*{{{*/ 138 102 … … 155 119 } 156 120 /*}}}*/ 121 void DoubleInput::ChangeEnum(int newenumtype){/*{{{*/ 122 this->enum_type=newenumtype; 123 } 124 /*}}}*/ 125 void DoubleInput::Configure(Parameters* parameters){/*{{{*/ 126 /*do nothing: */ 127 } 128 /*}}}*/ 157 129 void DoubleInput::Constrain(IssmDouble cm_min, IssmDouble cm_max){/*{{{*/ 158 130 … … 162 134 } 163 135 /*}}}*/ 136 void DoubleInput::ConstrainMin(IssmDouble minimum){/*{{{*/ 137 if (value<minimum) value=minimum; 138 } 139 /*}}}*/ 140 void DoubleInput::GetInputAverage(IssmDouble* pvalue){/*{{{*/ 141 *pvalue=value; 142 } 143 /*}}}*/ 144 void DoubleInput::GetInputValue(bool* pvalue){/*{{{*/ 145 _error_("Double input of enum " << EnumToStringx(enum_type) << " cannot return a boolean"); 146 147 } 148 /*}}}*/ 149 void DoubleInput::GetInputValue(int* pvalue){/*{{{*/ 150 _error_("Double input of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return an integer"); 151 152 } 153 /*}}}*/ 154 void DoubleInput::GetInputValue(IssmDouble* pvalue){/*{{{*/ 155 156 /*return value*/ 157 *pvalue=value; 158 } 159 /*}}}*/ 160 void DoubleInput::GetInputValue(IssmDouble* pvalue,Gauss* gauss){*pvalue=this->value;}/*{{{*/ 161 /*}}}*/ 162 void DoubleInput::GetVectorFromInputs(Vector<IssmDouble>* vector,int* doflist){/*{{{*/ 163 164 _error_("not supporte yet!"); 165 166 } 167 /*}}}*/ 164 168 IssmDouble DoubleInput::Max(void){/*{{{*/ 165 169 return this->value; … … 178 182 } 179 183 /*}}}*/ 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; 184 Input* DoubleInput::PointwiseDivide(Input* inputB){/*{{{*/ 185 186 /*Ouput*/ 187 DoubleInput* outinput=NULL; 188 189 /*Intermediaries*/ 190 IssmDouble Bvalue; 191 192 /*Check that inputB is of the same type*/ 193 inputB->GetInputAverage(&Bvalue); 194 195 /*Create new DoubleInput*/ 196 outinput=new DoubleInput(this->enum_type,this->value/Bvalue); 197 198 /*Return output pointer*/ 199 return outinput; 200 201 } 202 /*}}}*/ 203 Input* DoubleInput::PointwiseMax(Input* input){/*{{{*/ 204 205 /*Ouput*/ 206 DoubleInput* outinput=NULL; 207 208 /*Intermediaries*/ 209 IssmDouble max; 210 211 /*Check that inputB is of the same type*/ 212 if (input->Max() > this->Max()) max=input->Max(); 213 else max=this->Max(); 214 215 /*Create new DoubleInput*/ 216 outinput=new DoubleInput(this->enum_type,max); 217 218 /*Return output pointer*/ 219 return outinput; 220 221 } 222 /*}}}*/ 223 Input* DoubleInput::PointwiseMin(Input* input){/*{{{*/ 224 225 /*Ouput*/ 226 DoubleInput* outinput=NULL; 227 228 /*Intermediaries*/ 229 IssmDouble min; 230 231 /*Check that inputB is of the same type*/ 232 if (input->Min() < this->Min()) min=input->Min(); 233 else min=this->Min(); 234 235 /*Create new DoubleInput*/ 236 outinput=new DoubleInput(this->enum_type,min); 237 238 /*Return output pointer*/ 239 return outinput; 240 241 } 242 /*}}}*/ 243 void DoubleInput::Scale(IssmDouble scale_factor){/*{{{*/ 244 value=value*scale_factor; 245 } 246 /*}}}*/ 247 void 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); 188 251 } 189 252 /*}}}*/ … … 209 272 } 210 273 /*}}}*/ 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 25 25 /*}}}*/ 26 26 /*Object virtual functions definitions:{{{ */ 27 Object* copy(); 28 void DeepEcho(); 27 29 void Echo(); 28 void DeepEcho();29 30 int Id(); 31 void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction); 30 32 int ObjectEnum(); 31 Object* copy();32 void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);33 33 /*}}}*/ 34 34 /*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;}; 41 38 int GetResultInterpolation(void){return P0Enum;}; 42 39 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); 44 44 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); 47 47 /*}}}*/ 48 48 /*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");}; 49 58 void GetInputValue(bool* pvalue); 50 59 void GetInputValue(int* pvalue); … … 53 62 void GetInputValue(IssmDouble* pvalue,Gauss* gauss,IssmDouble time){_error_("not implemented yet");}; 54 63 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");};59 64 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); 67 66 IssmDouble InfinityNorm(void){_error_("not implemented yet");}; 68 67 IssmDouble Max(void); … … 70 69 IssmDouble Min(void); 71 70 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); 73 74 void VerticallyIntegrate(Input* thickness_input); 74 void GetVectorFromInputs(Vector<IssmDouble>* vector,int* doflist);75 75 /*}}}*/ 76 76 -
issm/trunk-jpl/src/c/classes/Inputs/Input.h
r19725 r20827 25 25 virtual ~Input(){}; 26 26 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; 28 33 virtual void GetInputValue(bool* pvalue)=0; 29 34 virtual void GetInputValue(int* pvalue)=0; … … 32 37 virtual void GetInputValue(IssmDouble* pvalue,Gauss* gauss,IssmDouble time)=0; 33 38 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;38 39 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; 41 41 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;51 42 virtual void AXPY(Input* xinput,IssmDouble scalar)=0; 52 43 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; 54 45 virtual void Extrude(int start)=0; 55 46 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; 56 56 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; 59 60 virtual Input* PointwiseDivide(Input* inputB)=0; 60 61 virtual Input* PointwiseMax(Input* inputmax)=0; 61 62 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");}; 65 66 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");};67 67 }; 68 68 #endif -
issm/trunk-jpl/src/c/classes/Inputs/Inputs.cpp
r18521 r20827 29 29 30 30 /*Object management*/ 31 void Inputs::GetInputValue(bool* pvalue,int enum_type){/*{{{*/ 31 int 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 /*}}}*/ 56 void 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 /*}}}*/ 70 void 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 /*}}}*/ 99 void 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 /*}}}*/ 113 void Inputs::ConstrainMin(int constrain_enum, IssmDouble minimum){/*{{{*/ 114 115 /*Find x and y inputs: */ 116 Input* constrain_input=xDynamicCast<Input*>(this->GetInput(constrain_enum)); 117 118 /*some checks: */ 119 if(!constrain_input) _error_("input " << EnumToStringx(constrain_enum) << " could not be found!"); 120 121 /*Apply ContrainMin: */ 122 constrain_input->ConstrainMin(minimum); 123 } 124 /*}}}*/ 125 int 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 /*}}}*/ 144 void 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 /*}}}*/ 158 Input* 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 /*}}}*/ 174 void Inputs::GetInputAverage(IssmDouble* pvalue,int enum_type){/*{{{*/ 32 175 33 176 vector<Object*>::iterator object; … … 52 195 53 196 /*Ok, we have an input if we made it here, request the input to return the value: */ 54 input->GetInput Value(pvalue);55 56 } 57 /*}}}*/ 58 void Inputs::GetInputValue( int* pvalue,int enum_type){/*{{{*/197 input->GetInputAverage(pvalue); 198 199 } 200 /*}}}*/ 201 void Inputs::GetInputValue(bool* pvalue,int enum_type){/*{{{*/ 59 202 60 203 vector<Object*>::iterator object; … … 83 226 } 84 227 /*}}}*/ 85 void Inputs::GetInputValue( IssmDouble* pvalue,int enum_type){/*{{{*/228 void Inputs::GetInputValue(int* pvalue,int enum_type){/*{{{*/ 86 229 87 230 vector<Object*>::iterator object; … … 92 235 for ( object=objects.begin() ; object < objects.end(); object++ ){ 93 236 94 input=xDynamicCast<Input*>(*object); 237 input=xDynamicCast<Input*>(*object); 95 238 if (input->InstanceEnum()==enum_type){ 96 239 found=true; … … 110 253 } 111 254 /*}}}*/ 112 void Inputs::GetInput Average(IssmDouble* pvalue,int enum_type){/*{{{*/255 void Inputs::GetInputValue(IssmDouble* pvalue,int enum_type){/*{{{*/ 113 256 114 257 vector<Object*>::iterator object; … … 119 262 for ( object=objects.begin() ; object < objects.end(); object++ ){ 120 263 121 input=xDynamicCast<Input*>(*object); 264 input=xDynamicCast<Input*>(*object); 122 265 if (input->InstanceEnum()==enum_type){ 123 266 found=true; … … 133 276 134 277 /*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 203 280 } 204 281 /*}}}*/ … … 303 380 } 304 381 /*}}}*/ 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)); 382 Inputs* 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; 352 405 } 353 406 /*}}}*/ … … 377 430 } 378 431 /*}}}*/ 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 23 23 /*numerics*/ 24 24 int AddInput(Input* in_input); 25 void AXPY(int inputy_enum, IssmDouble scalar, int inputx_enum); 25 26 void ChangeEnum(int enumtype,int new_enumtype); 27 void Configure(Parameters* parameters); 26 28 void ConstrainMin(int constrain_enum, IssmDouble minimum); 27 29 int DeleteInput(int enum_type); 28 30 void DuplicateInput(int original_enum,int new_enum); 29 31 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); 35 37 IssmDouble InfinityNorm(int enumtype); 36 38 IssmDouble Max(int enumtype); … … 38 40 IssmDouble Min(int enumtype); 39 41 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); 46 46 47 47 }; -
issm/trunk-jpl/src/c/classes/Inputs/IntInput.cpp
r19254 r20827 29 29 30 30 /*Object virtual functions definitions:*/ 31 Object* IntInput::copy() {/*{{{*/ 32 33 return new IntInput(this->enum_type,this->value); 34 35 } 36 /*}}}*/ 31 37 void IntInput::DeepEcho(void){/*{{{*/ 32 38 … … 36 42 int IntInput::Id(void){ return -1; }/*{{{*/ 37 43 /*}}}*/ 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 /*}}}*/50 44 void IntInput::Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ /*{{{*/ 51 45 … … 54 48 MARSHALLING(enum_type); 55 49 MARSHALLING(value); 50 51 } 52 /*}}}*/ 53 int IntInput::ObjectEnum(void){/*{{{*/ 54 55 return IntInputEnum; 56 56 57 57 } … … 69 69 } 70 70 /*}}}*/ 71 Input* IntInput::Spawn TriaInput(int index1,int index2,int index3){/*{{{*/71 Input* IntInput::SpawnSegInput(int index1,int index2){/*{{{*/ 72 72 73 73 /*output*/ … … 82 82 } 83 83 /*}}}*/ 84 Input* IntInput::Spawn SegInput(int index1,int index2){/*{{{*/84 Input* IntInput::SpawnTriaInput(int index1,int index2,int index3){/*{{{*/ 85 85 86 86 /*output*/ … … 97 97 98 98 /*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 /*}}}*/126 99 void IntInput::AXPY(Input* xinput,IssmDouble scalar){/*{{{*/ 127 100 … … 146 119 } 147 120 /*}}}*/ 121 void IntInput::ChangeEnum(int newenumtype){/*{{{*/ 122 this->enum_type=newenumtype; 123 } 124 /*}}}*/ 125 void IntInput::Configure(Parameters* parameters){/*{{{*/ 126 /*do nothing: */ 127 } 128 /*}}}*/ 148 129 void IntInput::Constrain(IssmDouble cm_min, IssmDouble cm_max){/*{{{*/ 149 130 … … 153 134 } 154 135 /*}}}*/ 136 void IntInput::GetInputValue(bool* pvalue){_error_("not supported yet!");}/*{{{*/ 137 /*}}}*/ 138 void IntInput::GetInputValue(int* pvalue){/*{{{*/ 139 *pvalue=value; 140 } 141 /*}}}*/ 142 void IntInput::GetInputValue(IssmDouble* pvalue){/*{{{*/ 143 _error_("IntInput cannot return a IssmDouble in parallel"); 144 } 145 /*}}}*/ 146 void IntInput::GetInputValue(IssmDouble* pvalue,Gauss* gauss){_error_("not supported yet!");}/*{{{*/ 147 /*}}}*/ 155 148 void IntInput::GetVectorFromInputs(Vector<IssmDouble>* vector,int* doflist){/*{{{*/ 156 149 … … 159 152 } 160 153 /*}}}*/ 161 void IntInput::Configure(Parameters* parameters){/*{{{*/ 162 /*do nothing: */ 154 void IntInput::Scale(IssmDouble scale_factor){/*{{{*/ 155 IssmDouble dvalue=(IssmDouble)value*scale_factor; 156 value=reCast<int>(dvalue); 163 157 } 164 158 /*}}}*/ 159 void 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 26 26 /*}}}*/ 27 27 /*Object virtual functions definitions:{{{ */ 28 Object* copy(); 29 void DeepEcho(); 28 30 void Echo(); 29 void DeepEcho();30 31 int Id(); 32 void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction); 31 33 int ObjectEnum(); 32 Object* copy();33 void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);34 34 /*}}}*/ 35 35 /*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;}; 42 39 int GetResultInterpolation(void){return P0Enum;}; 43 40 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");}; 45 45 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); 48 48 /*}}}*/ 49 49 /*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");}; 50 59 void GetInputValue(bool* pvalue); 51 60 void GetInputValue(int* pvalue); … … 54 63 void GetInputValue(IssmDouble* pvalue,Gauss* gauss,IssmDouble time){_error_("not implemented yet");}; 55 64 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");};60 65 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); 68 67 IssmDouble InfinityNorm(void){_error_("InfinityNorm not implemented for integers");}; 69 68 IssmDouble Max(void){_error_("Max not implemented for integers");}; … … 71 70 IssmDouble Min(void){_error_("Min not implemented for integers");}; 72 71 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); 74 75 void VerticallyIntegrate(Input* thickness_input){_error_("not supported yet");}; 75 void GetVectorFromInputs(Vector<IssmDouble>* vector,int* doflist);76 76 /*}}}*/ 77 77 -
issm/trunk-jpl/src/c/classes/Inputs/PentaInput.cpp
r19254 r20827 42 42 43 43 /*Object virtual functions definitions:*/ 44 void PentaInput::Echo(void){/*{{{*/ 45 this->DeepEcho(); 44 Object* PentaInput::copy() {/*{{{*/ 45 46 return new PentaInput(this->enum_type,this->values,this->interpolation_type); 47 46 48 } 47 49 /*}}}*/ … … 53 55 } 54 56 /*}}}*/ 57 void PentaInput::Echo(void){/*{{{*/ 58 this->DeepEcho(); 59 } 60 /*}}}*/ 55 61 int 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 }68 62 /*}}}*/ 69 63 void PentaInput::Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ /*{{{*/ … … 81 75 } 82 76 /*}}}*/ 77 int PentaInput::ObjectEnum(void){/*{{{*/ 78 79 return PentaInputEnum; 80 81 } 82 /*}}}*/ 83 83 84 84 /*PentaInput management*/ 85 int PentaInput::GetResultInterpolation(void){/*{{{*/ 86 87 if(this->interpolation_type==P0Enum){ 88 return P0Enum; 89 } 90 return P1Enum; 91 92 } 93 /*}}}*/ 94 int PentaInput::GetResultNumberOfNodes(void){/*{{{*/ 95 96 return this->NumberofNodes(this->interpolation_type);; 97 98 } 99 /*}}}*/ 85 100 int PentaInput::InstanceEnum(void){/*{{{*/ 86 101 87 102 return this->enum_type; 88 103 104 } 105 /*}}}*/ 106 void 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 /*}}}*/ 118 Input* PentaInput::SpawnSegInput(int index1,int index2){/*{{{*/ 119 120 _error_("not supported"); 89 121 } 90 122 /*}}}*/ … … 119 151 } 120 152 /*}}}*/ 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 /*}}}*/153 153 154 154 /*Object functions*/ 155 void PentaInput::ChangeEnum(int newenumtype){/*{{{*/ 156 this->enum_type=newenumtype; 157 } 158 /*}}}*/ 159 void 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 /*}}}*/ 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 /*}}}*/ 155 178 void PentaInput::GetInputValue(IssmDouble* pvalue){/*{{{*/ 156 179 … … 169 192 } 170 193 /*}}}*/ 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 /*}}}*/194 194 195 195 /*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 /*}}}*/276 196 void PentaInput::AXPY(Input* xinput,IssmDouble scalar){/*{{{*/ 277 197 … … 295 215 } 296 216 /*}}}*/ 217 void PentaInput::Configure(Parameters* parameters){/*{{{*/ 218 /*do nothing: */ 219 } 220 /*}}}*/ 297 221 void PentaInput::Constrain(IssmDouble cm_min, IssmDouble cm_max){/*{{{*/ 298 222 … … 303 227 if(!xIsNan<IssmDouble>(cm_max)) for(i=0;i<numnodes;i++)if (this->values[i]>cm_max)this->values[i]=cm_max; 304 228 229 } 230 /*}}}*/ 231 void PentaInput::ConstrainMin(IssmDouble minimum){/*{{{*/ 232 233 int numnodes = this->NumberofNodes(this->interpolation_type); 234 for(int i=0;i<numnodes;i++) if (values[i]<minimum) values[i]=minimum; 305 235 } 306 236 /*}}}*/ … … 319 249 _error_("not supported yet for type "<<EnumToStringx(this->interpolation_type)); 320 250 } 251 } 252 /*}}}*/ 253 void PentaInput::GetVectorFromInputs(Vector<IssmDouble>* vector,int* doflist){/*{{{*/ 254 const int numvertices=6; 255 vector->SetValues(numvertices,doflist,this->values,INS_VAL); 256 } /*}}}*/ 257 IssmDouble 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 /*}}}*/ 267 IssmDouble 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 /*}}}*/ 278 IssmDouble 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 /*}}}*/ 289 IssmDouble 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 /*}}}*/ 300 IssmDouble 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 /*}}}*/ 311 Input* 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 /*}}}*/ 343 Input* 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 /*}}}*/ 373 Input* 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 /*}}}*/ 403 void 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 /*}}}*/ 409 void 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; 321 421 } 322 422 /*}}}*/ … … 351 451 } 352 452 /*}}}*/ 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 27 27 28 28 /*Object virtual functions definitions */ 29 Object *copy(); 30 void DeepEcho(); 29 31 void Echo(); 30 void DeepEcho();31 32 int Id(); 33 void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction); 32 34 int ObjectEnum(); 33 Object *copy();34 void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);35 35 36 36 /*PentaInput management*/ 37 37 int InstanceEnum(); 38 Input* SpawnTriaInput(int index1,int index2,int index3);39 Input* SpawnSegInput(int index1,int index2);40 38 Input* PointwiseDivide(Input* inputB); 41 39 Input* PointwiseMin(Input* inputB); … … 48 46 void Configure(Parameters* parameters); 49 47 /*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); 50 57 void GetInputValue(bool* pvalue){_error_("not implemented yet");}; 51 58 void GetInputValue(int* pvalue){_error_("not implemented yet");}; … … 54 61 void GetInputValue(IssmDouble* pvalue,Gauss* gauss,IssmDouble time){_error_("not implemented yet");}; 55 62 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");};60 63 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); 68 65 IssmDouble InfinityNorm(void); 69 66 IssmDouble Max(void); … … 71 68 IssmDouble Min(void); 72 69 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); 74 75 void VerticallyIntegrate(Input* thickness_input); 75 void GetVectorFromInputs(Vector<IssmDouble>* vector,int* doflist);76 76 77 77 }; -
issm/trunk-jpl/src/c/classes/Inputs/SegInput.cpp
r19254 r20827 34 34 35 35 /*Object virtual functions definitions:*/ 36 void SegInput::Echo(void){/*{{{*/ 37 this->DeepEcho(); 36 Object* SegInput::copy() {/*{{{*/ 37 38 return new SegInput(this->enum_type,this->values,this->interpolation_type); 39 38 40 } 39 41 /*}}}*/ … … 45 47 } 46 48 /*}}}*/ 47 int SegInput::Id(void){ return -1; }/*{{{*/ 48 /*}}}*/ 49 int SegInput::ObjectEnum(void){/*{{{*/ 50 51 return SegInputEnum; 52 49 void SegInput::Echo(void){/*{{{*/ 50 this->DeepEcho(); 53 51 } 54 52 /*}}}*/ 55 Object* SegInput::copy() {/*{{{*/ 56 57 return new SegInput(this->enum_type,this->values,this->interpolation_type); 58 59 } 53 int SegInput::Id(void){ return -1; }/*{{{*/ 60 54 /*}}}*/ 61 55 void SegInput::Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ /*{{{*/ … … 73 67 } 74 68 /*}}}*/ 69 int SegInput::ObjectEnum(void){/*{{{*/ 70 71 return SegInputEnum; 72 73 } 74 /*}}}*/ 75 75 76 76 /*SegInput management*/ … … 83 83 84 84 /*Object functions*/ 85 void SegInput::Configure(Parameters* parameters){/*{{{*/ 86 /*do nothing: */ 87 } 88 /*}}}*/ 85 89 void SegInput::GetInputAverage(IssmDouble* pvalue){/*{{{*/ 86 90 … … 95 99 } 96 100 /*}}}*/ 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 /*}}}*/105 101 void SegInput::GetInputDerivativeValue(IssmDouble* p, IssmDouble* xyz_list,Gauss* gauss){/*{{{*/ 106 102 … … 110 106 } 111 107 /*}}}*/ 112 void SegInput::Configure(Parameters* parameters){/*{{{*/ 113 /*do nothing: */ 108 void 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 114 114 } 115 115 /*}}}*/ -
issm/trunk-jpl/src/c/classes/Inputs/SegInput.h
r19725 r20827 27 27 28 28 /*Object virtual functions definitions*/ 29 Object *copy(); 30 void DeepEcho(); 29 31 void Echo(); 30 void DeepEcho();31 32 int Id(); 33 void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction); 32 34 int ObjectEnum(); 33 Object *copy();34 void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);35 35 36 36 /*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");}; 43 40 int GetResultInterpolation(void){_error_("not implemented");}; 44 41 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");}; 46 46 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");}; 49 49 50 50 /*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); 51 60 void GetInputValue(bool* pvalue){_error_("not implemented yet");} 52 61 void GetInputValue(int* pvalue){_error_("not implemented yet");} … … 55 64 void GetInputValue(IssmDouble* pvalue,Gauss* gauss,IssmDouble time){_error_("not implemented yet");}; 56 65 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");};61 66 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");}; 69 68 IssmDouble InfinityNorm(void){_error_("not implemented yet");}; 70 69 IssmDouble Max(void){_error_("not implemented yet");}; … … 72 71 IssmDouble Min(void); 73 72 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");}; 75 76 void VerticallyIntegrate(Input* thickness_input){_error_("not supported yet");}; 76 void GetVectorFromInputs(Vector<IssmDouble>* vector,int* doflist){_error_("not implemented yet");};77 77 78 78 }; -
issm/trunk-jpl/src/c/classes/Inputs/TetraInput.cpp
r19254 r20827 42 42 43 43 /*Object virtual functions definitions:*/ 44 void TetraInput::Echo(void){/*{{{*/ 45 this->DeepEcho(); 44 Object* TetraInput::copy() {/*{{{*/ 45 46 return new TetraInput(this->enum_type,this->values,this->interpolation_type); 47 46 48 } 47 49 /*}}}*/ … … 53 55 } 54 56 /*}}}*/ 57 void TetraInput::Echo(void){/*{{{*/ 58 this->DeepEcho(); 59 } 60 /*}}}*/ 55 61 int 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 }68 62 /*}}}*/ 69 63 void TetraInput::Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ /*{{{*/ … … 81 75 } 82 76 /*}}}*/ 77 int TetraInput::ObjectEnum(void){/*{{{*/ 78 79 return TetraInputEnum; 80 81 } 82 /*}}}*/ 83 83 84 84 /*TetraInput management*/ … … 118 118 119 119 /*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 /*}}}*/135 120 void TetraInput::ChangeEnum(int newenumtype){/*{{{*/ 136 121 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;149 122 } 150 123 /*}}}*/ … … 168 141 } 169 142 /*}}}*/ 143 void 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 /*}}}*/ 155 void 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 /*}}}*/ 170 162 void TetraInput::GetInputUpToCurrentTimeAverages(IssmDouble** pvalues, IssmDouble** ptimes, int* pnumtimes, IssmDouble currenttime){/*{{{*/ 171 163 … … 185 177 *ptimes=times; 186 178 *pnumtimes=numtimes; 179 } 180 /*}}}*/ 181 void 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 187 187 } 188 188 /*}}}*/ … … 219 219 220 220 /*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 /*}}}*/307 221 void TetraInput::AXPY(Input* xinput,IssmDouble scalar){/*{{{*/ 308 222 … … 320 234 } 321 235 /*}}}*/ 236 void TetraInput::Configure(Parameters* parameters){/*{{{*/ 237 /*do nothing: */ 238 } 239 /*}}}*/ 322 240 void TetraInput::Constrain(IssmDouble cm_min, IssmDouble cm_max){/*{{{*/ 323 241 … … 328 246 if(!xIsNan<IssmDouble>(cm_max)) for(i=0;i<numnodes;i++)if (this->values[i]>cm_max)this->values[i]=cm_max; 329 247 248 } 249 /*}}}*/ 250 void TetraInput::ConstrainMin(IssmDouble minimum){/*{{{*/ 251 252 int numnodes = this->NumberofNodes(this->interpolation_type); 253 for(int i=0;i<numnodes;i++) if (values[i]<minimum) values[i]=minimum; 330 254 } 331 255 /*}}}*/ … … 334 258 vector->SetValues(numvertices,doflist,this->values,INS_VAL); 335 259 } /*}}}*/ 260 IssmDouble 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 /*}}}*/ 270 IssmDouble 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 /*}}}*/ 281 IssmDouble 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 /*}}}*/ 292 IssmDouble 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 /*}}}*/ 303 IssmDouble 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 /*}}}*/ 314 Input* TetraInput::PointwiseDivide(Input* inputB){/*{{{*/ 315 316 /*Ouput*/ 317 TetraInput* outinput=NULL; 318 319 /*Intermediaries*/ 320 TetraInput *xinputB = NULL; 321 const int numnodes = this->NumberofNodes(this->interpolation_type); 322 323 /*Check that inputB is of the same type*/ 324 if(inputB->ObjectEnum()!=TetraInputEnum) _error_("Operation not permitted because inputB is of type " << EnumToStringx(inputB->ObjectEnum())); 325 xinputB=(TetraInput*)inputB; 326 if(xinputB->interpolation_type!=this->interpolation_type) _error_("Operation not permitted because inputB is of type " << EnumToStringx(xinputB->interpolation_type)); 327 328 /*Allocate intermediary*/ 329 IssmDouble* AdotBvalues=xNew<IssmDouble>(numnodes); 330 331 /*Create point wise division*/ 332 for(int i=0;i<numnodes;i++){ 333 _assert_(xinputB->values[i]!=0); 334 AdotBvalues[i]=this->values[i]/xinputB->values[i]; 335 } 336 337 /*Create new Tetra vertex input (copy of current input)*/ 338 outinput=new TetraInput(this->enum_type,AdotBvalues,this->interpolation_type); 339 340 /*Return output pointer*/ 341 xDelete<IssmDouble>(AdotBvalues); 342 return outinput; 343 344 } 345 /*}}}*/ 346 Input* TetraInput::PointwiseMax(Input* inputB){/*{{{*/ 347 348 /*Ouput*/ 349 TetraInput* outinput=NULL; 350 351 /*Intermediaries*/ 352 int i; 353 TetraInput *xinputB = NULL; 354 const int numnodes = this->NumberofNodes(this->interpolation_type); 355 IssmDouble *maxvalues = xNew<IssmDouble>(numnodes); 356 357 /*Check that inputB is of the same type*/ 358 if(inputB->ObjectEnum()!=TetraInputEnum) _error_("Operation not permitted because inputB is of type " << EnumToStringx(inputB->ObjectEnum())); 359 xinputB=(TetraInput*)inputB; 360 if(xinputB->interpolation_type!=this->interpolation_type) _error_("Operation not permitted because inputB is of type " << EnumToStringx(xinputB->interpolation_type)); 361 362 /*Create point wise max*/ 363 for(i=0;i<numnodes;i++){ 364 if(this->values[i] < xinputB->values[i]) maxvalues[i]=xinputB->values[i]; 365 else maxvalues[i]=this->values[i]; 366 } 367 368 /*Create new Tetra vertex input (copy of current input)*/ 369 outinput=new TetraInput(this->enum_type,&maxvalues[0],this->interpolation_type); 370 371 /*Return output pointer*/ 372 xDelete<IssmDouble>(maxvalues); 373 return outinput; 374 375 } 376 /*}}}*/ 336 377 Input* TetraInput::PointwiseMin(Input* inputB){/*{{{*/ 337 378 … … 365 406 } 366 407 /*}}}*/ 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 /*}}}*/ 408 void 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 /*}}}*/ 414 void 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 /*}}}*/ 420 void 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 27 27 28 28 /*Object virtual functions definitions*/ 29 Object *copy(); 30 void DeepEcho(); 29 31 void Echo(); 30 void DeepEcho();31 32 int Id(); 33 void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction); 32 34 int ObjectEnum(); 33 Object *copy();34 void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);35 35 36 36 /*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;}; 43 40 int GetResultInterpolation(void); 44 41 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); 46 46 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); 49 49 50 50 /*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); 51 60 void GetInputValue(bool* pvalue){_error_("not implemented yet");} 52 61 void GetInputValue(int* pvalue){_error_("not implemented yet");} … … 55 64 void GetInputValue(IssmDouble* pvalue,Gauss* gauss,IssmDouble time){_error_("not implemented yet");}; 56 65 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);61 66 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); 69 68 IssmDouble InfinityNorm(void); 70 69 IssmDouble Max(void); … … 72 71 IssmDouble Min(void); 73 72 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); 75 76 void VerticallyIntegrate(Input* thickness_input){_error_("not supported yet");}; 76 void GetVectorFromInputs(Vector<IssmDouble>* vector,int* doflist);77 77 78 78 }; -
issm/trunk-jpl/src/c/classes/Inputs/TransientInput.cpp
r19554 r20827 62 62 63 63 /*Object virtual functions definitions:*/ 64 void TransientInput::Echo(void){/*{{{*/ 65 this->DeepEcho(); 64 Object* 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 66 78 } 67 79 /*}}}*/ … … 80 92 } 81 93 /*}}}*/ 94 void TransientInput::Echo(void){/*{{{*/ 95 this->DeepEcho(); 96 } 97 /*}}}*/ 82 98 int 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 }105 99 /*}}}*/ 106 100 void TransientInput::Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ /*{{{*/ … … 116 110 } 117 111 /*}}}*/ 112 int TransientInput::ObjectEnum(void){/*{{{*/ 113 114 return TransientInputEnum; 115 116 } 117 /*}}}*/ 118 118 119 119 /*TransientInput management*/ … … 121 121 122 122 return this->enum_type; 123 124 } 125 /*}}}*/ 126 Input* 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; 123 142 124 143 } … … 143 162 } 144 163 /*}}}*/ 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 /*}}}*/164 164 165 165 /*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 /*}}}*/208 166 void TransientInput::ChangeEnum(int newenumtype){/*{{{*/ 209 167 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 227 168 } 228 169 /*}}}*/ … … 246 187 *ptimes=times; 247 188 *pnumtimes=numtimesteps; 189 } 190 /*}}}*/ 191 void 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 /*}}}*/ 208 void 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 /*}}}*/ 224 void 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 /*}}}*/ 239 void 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; 248 248 } 249 249 /*}}}*/ … … 327 327 } 328 328 /*}}}*/ 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; 329 void TransientInput::Configure(Parameters* parameters){/*{{{*/ 330 this->parameters=parameters; 362 331 } 363 332 /*}}}*/ … … 369 338 } 370 339 /*}}}*/ 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 } /*}}}*/ 340 int TransientInput::GetResultArraySize(void){/*{{{*/ 341 342 return 1; 343 } 344 /*}}}*/ 345 int 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 /*}}}*/ 360 int 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 /*}}}*/ 501 375 Input* TransientInput::GetTimeInput(IssmDouble intime){/*{{{*/ 502 376 … … 548 422 } 549 423 /*}}}*/ 550 void TransientInput::Configure(Parameters* parameters){/*{{{*/ 551 this->parameters=parameters; 552 } 553 /*}}}*/ 424 void 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 } /*}}}*/ 440 IssmDouble 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 /*}}}*/ 459 IssmDouble 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 /*}}}*/ 478 IssmDouble 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 /*}}}*/ 498 IssmDouble 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 /*}}}*/ 518 IssmDouble 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 /*}}}*/ 537 void 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 32 32 /*}}}*/ 33 33 /*Object virtual functions definitions:{{{*/ 34 Object* copy(); 35 void DeepEcho(); 34 36 void Echo(); 35 void DeepEcho();36 37 int Id(); 38 void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction); 37 39 int ObjectEnum(); 38 Object* copy();39 void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);40 40 /*}}}*/ 41 41 /*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); 48 44 int GetResultInterpolation(void); 49 45 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");}; 51 50 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); 53 53 /*}}}*/ 54 54 /*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); 55 64 void GetInputValue(bool* pvalue){_error_("not implemented yet");}; 56 65 void GetInputValue(int* pvalue){_error_("not implemented yet");}; … … 59 68 void GetInputValue(IssmDouble* pvalue,Gauss* gauss,IssmDouble time); 60 69 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);65 70 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); 73 74 IssmDouble InfinityNorm(void); 74 75 IssmDouble Max(void); … … 76 77 IssmDouble Min(void); 77 78 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); 79 82 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);83 83 /*}}}*/ 84 84 -
issm/trunk-jpl/src/c/classes/Inputs/TriaInput.cpp
r19725 r20827 41 41 42 42 /*Object virtual functions definitions:*/ 43 void TriaInput::Echo(void){/*{{{*/ 44 this->DeepEcho(); 43 Object* TriaInput::copy() {/*{{{*/ 44 45 return new TriaInput(this->enum_type,this->values,this->interpolation_type); 46 45 47 } 46 48 /*}}}*/ … … 52 54 } 53 55 /*}}}*/ 56 void TriaInput::Echo(void){/*{{{*/ 57 this->DeepEcho(); 58 } 59 /*}}}*/ 54 60 int 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 }67 61 /*}}}*/ 68 62 void TriaInput::Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ /*{{{*/ … … 80 74 } 81 75 /*}}}*/ 76 int TriaInput::ObjectEnum(void){/*{{{*/ 77 78 return TriaInputEnum; 79 80 } 81 /*}}}*/ 82 82 83 83 /*TriaInput management*/ … … 88 88 } 89 89 /*}}}*/ 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 90 int TriaInput::GetResultArraySize(void){/*{{{*/ 91 92 return 1; 93 94 } 95 /*}}}*/ 96 int TriaInput::GetResultInterpolation(void){/*{{{*/ 97 98 if(this->interpolation_type==P0Enum){ 99 return P0Enum; 100 } 101 return P1Enum; 102 103 } 104 /*}}}*/ 105 int TriaInput::GetResultNumberOfNodes(void){/*{{{*/ 106 107 return this->NumberofNodes(this->interpolation_type); 108 109 } 110 /*}}}*/ 111 void 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]; 101 121 } 102 122 /*}}}*/ … … 126 146 } 127 147 /*}}}*/ 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]; 148 Input* 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 159 159 } 160 160 /*}}}*/ 161 161 162 162 /*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 /*}}}*/178 163 void TriaInput::ChangeEnum(int newenumtype){/*{{{*/ 179 164 this->enum_type=newenumtype; 165 } 166 /*}}}*/ 167 void 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; 180 184 } 181 185 /*}}}*/ … … 212 216 } 213 217 /*}}}*/ 214 void TriaInput::GetInputAllTimeAverages(IssmDouble** pvalues,IssmDouble** ptimes, int* pnumtimes){/*{{{*/ 218 void 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 /*}}}*/ 225 void TriaInput::GetInputUpToCurrentTimeAverages(IssmDouble** pvalues, IssmDouble** ptimes, int* pnumtimes, IssmDouble currenttime){/*{{{*/ 215 226 216 227 IssmDouble* outvalues=NULL; … … 224 235 225 236 this->GetInputAverage(&outvalues[0]); 226 times[0]= 0.; /*we don't have a time*/237 times[0]=currenttime; /*we don't have a time*/ 227 238 228 239 *pvalues=outvalues; … … 231 242 } 232 243 /*}}}*/ 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; 244 void 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 250 250 } 251 251 /*}}}*/ 252 252 253 253 /*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 /*}}}*/340 254 void TriaInput::AXPY(Input* xinput,IssmDouble scalar){/*{{{*/ 341 255 … … 353 267 } 354 268 /*}}}*/ 269 void TriaInput::Configure(Parameters* parameters){/*{{{*/ 270 /*do nothing: */ 271 } 272 /*}}}*/ 355 273 void TriaInput::Constrain(IssmDouble cm_min, IssmDouble cm_max){/*{{{*/ 356 274 … … 361 279 if(!xIsNan<IssmDouble>(cm_max)) for(i=0;i<numnodes;i++)if (this->values[i]>cm_max)this->values[i]=cm_max; 362 280 281 } 282 /*}}}*/ 283 void TriaInput::ConstrainMin(IssmDouble minimum){/*{{{*/ 284 285 int numnodes = this->NumberofNodes(this->interpolation_type); 286 for(int i=0;i<numnodes;i++) if (values[i]<minimum) values[i]=minimum; 363 287 } 364 288 /*}}}*/ … … 367 291 vector->SetValues(numvertices,doflist,this->values,INS_VAL); 368 292 } /*}}}*/ 293 IssmDouble 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 /*}}}*/ 303 IssmDouble 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 /*}}}*/ 314 IssmDouble 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 /*}}}*/ 325 IssmDouble 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 /*}}}*/ 336 IssmDouble 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 /*}}}*/ 347 Input* TriaInput::PointwiseMax(Input* inputB){/*{{{*/ 348 349 /*Ouput*/ 350 TriaInput* outinput=NULL; 351 352 /*Intermediaries*/ 353 int i; 354 TriaInput *xinputB = NULL; 355 const int numnodes = this->NumberofNodes(this->interpolation_type); 356 IssmDouble *maxvalues = xNew<IssmDouble>(numnodes); 357 358 /*Check that inputB is of the same type*/ 359 if(inputB->ObjectEnum()!=TriaInputEnum) _error_("Operation not permitted because inputB is of type " << EnumToStringx(inputB->ObjectEnum())); 360 xinputB=(TriaInput*)inputB; 361 if(xinputB->interpolation_type!=this->interpolation_type) _error_("Operation not permitted because inputB is of type " << EnumToStringx(xinputB->interpolation_type)); 362 363 /*Create point wise max*/ 364 for(i=0;i<numnodes;i++){ 365 if(this->values[i] < xinputB->values[i]) maxvalues[i]=xinputB->values[i]; 366 else maxvalues[i]=this->values[i]; 367 } 368 369 /*Create new Tria vertex input (copy of current input)*/ 370 outinput=new TriaInput(this->enum_type,&maxvalues[0],this->interpolation_type); 371 372 /*Return output pointer*/ 373 xDelete<IssmDouble>(maxvalues); 374 return outinput; 375 376 } 377 /*}}}*/ 369 378 Input* TriaInput::PointwiseMin(Input* inputB){/*{{{*/ 370 379 … … 398 407 } 399 408 /*}}}*/ 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 /*}}}*/431 409 Input* TriaInput::PointwiseDivide(Input* inputB){/*{{{*/ 432 410 … … 461 439 } 462 440 /*}}}*/ 463 void TriaInput::Configure(Parameters* parameters){/*{{{*/ 464 /*do nothing: */ 465 } 466 /*}}}*/ 441 void 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 /*}}}*/ 447 void 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 /*}}}*/ 453 void 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 27 27 28 28 /*Object virtual functions definitions*/ 29 Object *copy(); 30 void DeepEcho(); 29 31 void Echo(); 30 void DeepEcho();31 32 int Id(); 33 void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction); 32 34 int ObjectEnum(); 33 Object *copy();34 void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);35 35 36 36 /*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); 43 40 int GetResultInterpolation(void); 44 41 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); 46 46 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); 49 49 50 50 /*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); 51 60 void GetInputValue(bool* pvalue){_error_("not implemented yet");} 52 61 void GetInputValue(int* pvalue){_error_("not implemented yet");} … … 55 64 void GetInputValue(IssmDouble* pvalue,Gauss* gauss,IssmDouble time){_error_("not implemented yet");}; 56 65 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);61 66 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); 69 68 IssmDouble InfinityNorm(void); 70 69 IssmDouble Max(void); … … 72 71 IssmDouble Min(void); 73 72 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); 75 76 void VerticallyIntegrate(Input* thickness_input){_error_("not supported yet");}; 76 void GetVectorFromInputs(Vector<IssmDouble>* vector,int* doflist);77 77 78 78 }; -
issm/trunk-jpl/src/c/classes/Loads/Friction.cpp
r20616 r20827 57 57 58 58 }/*}}}*/ 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 /*}}}*/122 59 void Friction::GetAlphaHydroComplement(IssmDouble* palpha_complement, Gauss* gauss){/*{{{*/ 123 60 … … 220 157 *palpha_complement=alpha_complement; 221 158 }/*}}}*/ 159 void 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 /*}}}*/ 222 222 void Friction::GetAlpha2(IssmDouble* palpha2, Gauss* gauss){/*{{{*/ 223 223 … … 402 402 *palpha2=alpha2; 403 403 }/*}}}*/ 404 void 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 /*}}}*/ 404 438 void Friction::GetAlpha2Temp(IssmDouble* palpha2, Gauss* gauss){/*{{{*/ 405 439 /*Here, we want to parameterize the friction as a function of temperature … … 624 658 *palpha2=alpha2; 625 659 }/*}}}*/ 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 30 30 void Echo(void); 31 31 void GetAlphaComplement(IssmDouble* alpha_complement,Gauss* gauss); 32 void GetAlphaViscousComplement(IssmDouble* alpha_complement,Gauss* gauss);33 32 void GetAlphaHydroComplement(IssmDouble* alpha_complement,Gauss* gauss); 34 33 void GetAlphaTempComplement(IssmDouble* alpha_complement,Gauss* gauss); 34 void GetAlphaViscousComplement(IssmDouble* alpha_complement,Gauss* gauss); 35 35 void GetAlpha2(IssmDouble* palpha2,Gauss* gauss); 36 36 void GetAlpha2Coulomb(IssmDouble* palpha2,Gauss* gauss); 37 37 void GetAlpha2Hydro(IssmDouble* palpha2,Gauss* gauss); 38 void GetAlpha2Sommers(IssmDouble* palpha2,Gauss* gauss); 38 39 void GetAlpha2Temp(IssmDouble* palpha2,Gauss* gauss); 39 40 void GetAlpha2Viscous(IssmDouble* palpha2,Gauss* gauss); … … 41 42 void GetAlpha2Weertman(IssmDouble* palpha2,Gauss* gauss); 42 43 void GetAlpha2WeertmanTemp(IssmDouble* palpha2,Gauss* gauss); 43 void GetAlpha2Sommers(IssmDouble* palpha2,Gauss* gauss);44 44 }; 45 45 -
issm/trunk-jpl/src/c/classes/Loads/Moulin.cpp
r19744 r20827 97 97 } 98 98 /*}}}*/ 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 /*}}}*/124 99 void Moulin::DeepEcho(void){/*{{{*/ 125 100 … … 139 114 /*}}}*/ 140 115 int Moulin::Id(void){ return id; }/*{{{*/ 116 /*}}}*/ 117 void 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 } 141 141 /*}}}*/ 142 142 int Moulin::ObjectEnum(void){/*{{{*/ -
issm/trunk-jpl/src/c/classes/Loads/Moulin.h
r19744 r20827 46 46 /*}}}*/ 47 47 /*Object virtual functions definitions:{{{ */ 48 Object* copy(); 49 void DeepEcho(); 48 50 void Echo(); 49 void DeepEcho();50 51 int Id(); 52 void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction); 51 53 int ObjectEnum(); 52 Object* copy();53 void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);54 54 /*}}}*/ 55 55 /*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);59 56 void InputUpdateFromConstant(IssmDouble constant, int name); 60 57 void InputUpdateFromConstant(int constant, int name); 61 58 void InputUpdateFromConstant(bool constant, int name); 62 59 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); 63 63 /*}}}*/ 64 64 /*Load virtual functions definitions: {{{*/ 65 65 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");}; 68 67 void CreateKMatrix(Matrix<IssmDouble>* Kff, Matrix<IssmDouble>* Kfs); 69 68 void CreatePVector(Vector<IssmDouble>* pf); 70 void CreateJacobianMatrix(Matrix<IssmDouble>* Jff){_error_("Not implemented yet");};71 69 void GetNodesSidList(int* sidlist); 72 70 void GetNodesLidList(int* lidlist); 73 71 int GetNumberOfNodes(void); 72 bool InAnalysis(int analysis_type); 74 73 bool IsPenalty(void); 75 74 void PenaltyCreateJacobianMatrix(Matrix<IssmDouble>* Jff,IssmDouble kmax){_error_("Not implemented yet");}; 76 75 void PenaltyCreateKMatrix(Matrix<IssmDouble>* Kff, Matrix<IssmDouble>* kfs, IssmDouble kmax); 77 76 void PenaltyCreatePVector(Vector<IssmDouble>* pf, IssmDouble kmax); 77 void SetCurrentConfiguration(Elements* elements,Loads* loads,Nodes* nodes,Vertices* vertices,Materials* materials,Parameters* parameters); 78 78 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(); 80 80 /*}}}*/ 81 81 -
issm/trunk-jpl/src/c/classes/Loads/Neumannflux.cpp
r19749 r20827 99 99 100 100 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 127 101 } 128 102 /*}}}*/ … … 154 128 int Neumannflux::Id(void){/*{{{*/ 155 129 return id; 130 } 131 /*}}}*/ 132 void 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 156 156 } 157 157 /*}}}*/ -
issm/trunk-jpl/src/c/classes/Loads/Neumannflux.h
r19749 r20827 43 43 void Echo(); 44 44 int Id(); 45 void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction); 45 46 int ObjectEnum(); 46 void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);47 47 /*}}}*/ 48 48 /*Update virtual functions resolution: {{{*/ … … 69 69 void PenaltyCreatePVector(Vector<IssmDouble>* pf, IssmDouble kmax); 70 70 void ResetHooks(); 71 void SetCurrentConfiguration(Elements* elements,Loads* loads,Nodes* nodes,Vertices* vertices,Materials* materials,Parameters* parameters); 71 72 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);73 73 /*}}}*/ 74 74 /*Neumannflux management:{{{*/ -
issm/trunk-jpl/src/c/classes/Loads/Numericalflux.cpp
r19254 r20827 156 156 157 157 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 185 158 } 186 159 /*}}}*/ … … 214 187 int Numericalflux::Id(void){/*{{{*/ 215 188 return id; 189 } 190 /*}}}*/ 191 void 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 216 216 } 217 217 /*}}}*/ -
issm/trunk-jpl/src/c/classes/Loads/Numericalflux.h
r19254 r20827 44 44 void Echo(); 45 45 int Id(); 46 void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction); 46 47 int ObjectEnum(); 47 void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);48 48 /*}}}*/ 49 49 /*Update virtual functions resolution: {{{*/ … … 70 70 void PenaltyCreatePVector(Vector<IssmDouble>* pf, IssmDouble kmax); 71 71 void ResetHooks(); 72 void SetCurrentConfiguration(Elements* elements,Loads* loads,Nodes* nodes,Vertices* vertices,Materials* materials,Parameters* parameters); 72 73 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);74 74 /*}}}*/ 75 75 /*Numericalflux management:{{{*/ -
issm/trunk-jpl/src/c/classes/Loads/Pengrid.cpp
r19258 r20827 109 109 110 110 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);140 111 141 112 } … … 160 131 /*}}}*/ 161 132 int Pengrid::Id(void){ return id; }/*{{{*/ 133 /*}}}*/ 134 void 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 } 162 162 /*}}}*/ 163 163 int Pengrid::ObjectEnum(void){/*{{{*/ -
issm/trunk-jpl/src/c/classes/Loads/Pengrid.h
r19254 r20827 50 50 /*}}}*/ 51 51 /*Object virtual functions definitions:{{{ */ 52 Object* copy(); 53 void DeepEcho(); 52 54 void Echo(); 53 void DeepEcho();54 55 int Id(); 56 void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction); 55 57 int ObjectEnum(); 56 Object* copy();57 void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);58 58 /*}}}*/ 59 59 /*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);63 60 void InputUpdateFromConstant(IssmDouble constant, int name); 64 61 void InputUpdateFromConstant(int constant, int name); 65 62 void InputUpdateFromConstant(bool constant, int name); 66 63 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); 67 67 /*}}}*/ 68 68 /*Load virtual functions definitions: {{{*/ 69 69 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");}; 72 71 void CreateKMatrix(Matrix<IssmDouble>* Kff, Matrix<IssmDouble>* Kfs); 73 72 void CreatePVector(Vector<IssmDouble>* pf); 74 void CreateJacobianMatrix(Matrix<IssmDouble>* Jff){_error_("Not implemented yet");};73 void GetNodesLidList(int* lidlist); 75 74 void GetNodesSidList(int* sidlist); 76 void GetNodesLidList(int* lidlist);77 75 int GetNumberOfNodes(void); 76 bool InAnalysis(int analysis_type); 78 77 bool IsPenalty(void); 79 78 void PenaltyCreateJacobianMatrix(Matrix<IssmDouble>* Jff,IssmDouble kmax){_error_("Not implemented yet");}; 80 79 void PenaltyCreateKMatrix(Matrix<IssmDouble>* Kff, Matrix<IssmDouble>* kfs, IssmDouble kmax); 81 80 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); 82 83 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);84 84 /*}}}*/ 85 85 /*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); 86 92 ElementMatrix* PenaltyCreateKMatrixThermal(IssmDouble kmax); 87 ElementMatrix* PenaltyCreateKMatrixMelting(IssmDouble kmax); 93 ElementVector* PenaltyCreatePVectorHydrologyDCInefficient(IssmDouble kmax); 94 ElementVector* PenaltyCreatePVectorMelting(IssmDouble kmax); 88 95 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);96 96 void ResetConstraint(void); 97 97 /*}}}*/ -
issm/trunk-jpl/src/c/classes/Loads/Penpair.cpp
r20660 r20827 66 66 } 67 67 /*}}}*/ 68 void 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 /*}}}*/ 78 void 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 /*}}}*/ 88 int Penpair::Id(void){ return id; }/*{{{*/ 89 /*}}}*/ 68 90 void Penpair::Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ /*{{{*/ 69 91 … … 85 107 } 86 108 /*}}}*/ 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 /*}}}*/109 109 int Penpair::ObjectEnum(void){/*{{{*/ 110 110 … … 146 146 } 147 147 /*}}}*/ 148 void 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 /*}}}*/ 148 156 void Penpair::GetNodesSidList(int* sidlist){/*{{{*/ 149 157 … … 152 160 153 161 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();162 162 } 163 163 /*}}}*/ -
issm/trunk-jpl/src/c/classes/Loads/Penpair.h
r19254 r20827 35 35 void Echo(); 36 36 int Id(); 37 void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction); 37 38 int ObjectEnum(); 38 void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);39 39 /*}}}*/ 40 40 /*Update virtual functions resolution: {{{*/ -
issm/trunk-jpl/src/c/classes/Loads/Riftfront.cpp
r20690 r20827 150 150 151 151 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);195 152 196 153 } … … 235 192 /*}}}*/ 236 193 int Riftfront::Id(void){ return id; }/*{{{*/ 194 /*}}}*/ 195 void 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 } 237 237 /*}}}*/ 238 238 int Riftfront::ObjectEnum(void){/*{{{*/ -
issm/trunk-jpl/src/c/classes/Loads/Riftfront.h
r19254 r20827 61 61 void Echo(); 62 62 int Id(); 63 void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction); 63 64 int ObjectEnum(); 64 void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);65 65 /*}}}*/ 66 66 /*Update virtual functions resolution: {{{*/ -
issm/trunk-jpl/src/c/classes/Materials/Material.h
r20608 r20827 25 25 26 26 /*Numerics*/ 27 virtual void Configure(Elements* elements)=0; 27 28 virtual Material* copy2(Element* element)=0; 28 virtual void Configure(Elements* elements)=0;29 29 virtual IssmDouble GetA()=0; 30 30 virtual IssmDouble GetAbar()=0; -
issm/trunk-jpl/src/c/classes/Materials/Matestar.cpp
r20687 r20827 106 106 int Matestar::Id(void){ return mid; }/*{{{*/ 107 107 /*}}}*/ 108 int Matestar::ObjectEnum(void){/*{{{*/109 110 return MatestarEnum;111 112 }113 /*}}}*/114 108 void Matestar::Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ /*{{{*/ 115 109 … … 123 117 } 124 118 /*}}}*/ 119 int Matestar::ObjectEnum(void){/*{{{*/ 120 121 return MatestarEnum; 122 123 } 124 /*}}}*/ 125 125 126 126 /*Matestar management*/ … … 133 133 } 134 134 /*}}}*/ 135 void Matestar::SetCurrentConfiguration(Elements* elementsin,Loads* loadsin,Nodes* nodesin,Vertices* verticesin,Materials* materialsin,Parameters* parametersin){/*{{{*/136 137 }138 /*}}}*/139 135 IssmDouble Matestar::GetA(){/*{{{*/ 140 136 _error_("not implemented yet"); … … 154 150 } 155 151 /*}}}*/ 152 IssmDouble Matestar::GetD(){/*{{{*/ 153 _error_("not implemented yet"); 154 } 155 /*}}}*/ 156 IssmDouble Matestar::GetDbar(){/*{{{*/ 157 158 _error_("not implemented yet"); 159 } 160 /*}}}*/ 156 161 IssmDouble 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 171 162 _error_("not implemented yet"); 172 163 } … … 221 212 } 222 213 /*}}}*/ 214 void Matestar::GetViscosityBar(IssmDouble* pviscosity,IssmDouble eps_eff){/*{{{*/ 215 _error_("not implemented yet"); 216 } 217 /*}}}*/ 218 void Matestar::GetViscosityComplement(IssmDouble* pviscosity_complement, IssmDouble* epsilon){/*{{{*/ 219 _error_("not implemented yet"); 220 } 221 /*}}}*/ 222 void Matestar::GetViscosityDComplement(IssmDouble* pviscosity_complement, IssmDouble* epsilon){/*{{{*/ 223 _error_("not implemented yet"); 224 } 225 /*}}}*/ 226 void Matestar::GetViscosityDerivativeEpsSquare(IssmDouble* pmu_prime, IssmDouble* epsilon){/*{{{*/ 227 _error_("not implemented yet"); 228 } 229 /*}}}*/ 230 IssmDouble 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 /*}}}*/ 223 267 void Matestar::GetViscosity_B(IssmDouble* pdmudB,IssmDouble eps_eff){/*{{{*/ 224 268 _error_("not implemented yet"); … … 229 273 } 230 274 /*}}}*/ 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 /*}}}*/247 275 void Matestar::GetViscosity2dDerivativeEpsSquare(IssmDouble* pmu_prime, IssmDouble* epsilon){/*{{{*/ 248 276 _error_("not implemented yet"); 249 277 } 250 278 /*}}}*/ 251 void Matestar::InputUpdateFromVector(IssmDouble* vector, int name, int type){/*{{{*/ 252 253 } 254 /*}}}*/ 255 void Matestar::InputUpdateFromVectorDakota(IssmDouble* vector, int name, int type){/*{{{*/ 256 279 void Matestar::InputUpdateFromConstant(IssmDouble constant, int name){/*{{{*/ 280 /*Nothing updated yet*/ 281 } 282 /*}}}*/ 283 void Matestar::InputUpdateFromConstant(int constant, int name){/*{{{*/ 284 /*Nothing updated yet*/ 285 } 286 /*}}}*/ 287 void Matestar::InputUpdateFromConstant(bool constant, int name){/*{{{*/ 288 /*Nothing updated yet*/ 257 289 } 258 290 /*}}}*/ … … 261 293 } 262 294 /*}}}*/ 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*/ 295 void Matestar::InputUpdateFromVector(IssmDouble* vector, int name, int type){/*{{{*/ 296 297 } 298 /*}}}*/ 299 void Matestar::InputUpdateFromVectorDakota(IssmDouble* vector, int name, int type){/*{{{*/ 300 301 } 302 /*}}}*/ 303 bool Matestar::IsDamage(){/*{{{*/ 304 305 _error_("not implemented yet"); 306 } 307 /*}}}*/ 308 void Matestar::ResetHooks(){/*{{{*/ 309 310 this->element=NULL; 311 312 /*Get Element type*/ 313 this->helement->reset(); 314 315 } 316 /*}}}*/ 317 void Matestar::SetCurrentConfiguration(Elements* elementsin,Loads* loadsin,Nodes* nodesin,Vertices* verticesin,Materials* materialsin,Parameters* parametersin){/*{{{*/ 318 273 319 } 274 320 /*}}}*/ … … 394 440 _error_("not implemented yet"); 395 441 }/*}}}*/ 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 36 36 /*}}}*/ 37 37 /*Object virtual functions definitions:{{{ */ 38 Object* copy(); 39 void DeepEcho(); 38 40 void Echo(); 39 void DeepEcho();40 41 int Id(); 42 void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction); 41 43 int ObjectEnum(); 42 Object* copy();43 void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);44 44 /*}}}*/ 45 45 /*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);49 46 void InputUpdateFromConstant(IssmDouble constant, int name); 50 47 void InputUpdateFromConstant(int constant, int name); 51 48 void InputUpdateFromConstant(bool constant, int name); 52 49 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); 53 53 /*}}}*/ 54 54 /*Material virtual functions resolution: {{{*/ 55 55 void Configure(Elements* elements); 56 56 Material* copy2(Element* element); 57 void SetCurrentConfiguration(Elements* elements,Loads* loads,Nodes* nodes,Vertices* vertices,Materials* materials,Parameters* parameters);58 57 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);61 58 void GetViscosityBar(IssmDouble* pviscosity, IssmDouble eps_eff); 62 59 void GetViscosityComplement(IssmDouble* pviscosity_complement, IssmDouble* pepsilon); 63 60 void GetViscosityDComplement(IssmDouble*, IssmDouble*); 64 61 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); 65 64 void GetViscosity2dDerivativeEpsSquare(IssmDouble* pmu_prime, IssmDouble* pepsilon); 66 65 IssmDouble GetA(); … … 73 72 bool IsDamage(); 74 73 void ResetHooks(); 74 void SetCurrentConfiguration(Elements* elements,Loads* loads,Nodes* nodes,Vertices* vertices,Materials* materials,Parameters* parameters); 75 75 76 76 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 117 117 int Matice::Id(void){ return mid; }/*{{{*/ 118 118 /*}}}*/ 119 int Matice::ObjectEnum(void){/*{{{*/120 121 return MaticeEnum;122 123 }124 /*}}}*/125 119 void Matice::Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ /*{{{*/ 126 120 … … 135 129 } 136 130 /*}}}*/ 131 int Matice::ObjectEnum(void){/*{{{*/ 132 133 return MaticeEnum; 134 135 } 136 /*}}}*/ 137 137 138 138 /*Matice management*/ … … 145 145 } 146 146 /*}}}*/ 147 void Matice::SetCurrentConfiguration(Elements* elementsin,Loads* loadsin,Nodes* nodesin,Vertices* verticesin,Materials* materialsin,Parameters* parametersin){/*{{{*/148 149 }150 /*}}}*/151 147 IssmDouble Matice::GetA(){/*{{{*/ 152 148 /* … … 191 187 element->inputs->GetInputAverage(&Bbar,MaterialsRheologyBbarEnum); 192 188 return Bbar; 193 }194 /*}}}*/195 IssmDouble Matice::GetN(){/*{{{*/196 197 /*Output*/198 IssmDouble n;199 200 element->inputs->GetInputAverage(&n,MaterialsRheologyNEnum);201 return n;202 189 } 203 190 /*}}}*/ … … 218 205 if(this->isdamaged)element->inputs->GetInputAverage(&Dbar,DamageDbarEnum); 219 206 return Dbar; 207 } 208 /*}}}*/ 209 IssmDouble Matice::GetN(){/*{{{*/ 210 211 /*Output*/ 212 IssmDouble n; 213 214 element->inputs->GetInputAverage(&n,MaterialsRheologyNEnum); 215 return n; 220 216 } 221 217 /*}}}*/ … … 275 271 /*Return: */ 276 272 *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;331 273 } 332 274 /*}}}*/ … … 527 469 } 528 470 /*}}}*/ 471 void 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 /*}}}*/ 499 void 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 /*}}}*/ 529 525 void Matice::GetViscosity2dDerivativeEpsSquare(IssmDouble* pmu_prime, IssmDouble* epsilon){/*{{{*/ 530 526 … … 555 551 } 556 552 /*}}}*/ 557 void Matice::InputUpdateFromVector(IssmDouble* vector, int name, int type){/*{{{*/ 558 559 } 560 /*}}}*/ 561 void Matice::InputUpdateFromVectorDakota(IssmDouble* vector, int name, int type){/*{{{*/ 562 553 void Matice::InputUpdateFromConstant(IssmDouble constant, int name){/*{{{*/ 554 /*Nothing updated yet*/ 555 } 556 /*}}}*/ 557 void Matice::InputUpdateFromConstant(int constant, int name){/*{{{*/ 558 /*Nothing updated yet*/ 559 } 560 /*}}}*/ 561 void Matice::InputUpdateFromConstant(bool constant, int name){/*{{{*/ 562 /*Nothing updated yet*/ 563 563 } 564 564 /*}}}*/ … … 567 567 } 568 568 /*}}}*/ 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*/ 569 void Matice::InputUpdateFromVector(IssmDouble* vector, int name, int type){/*{{{*/ 570 571 } 572 /*}}}*/ 573 void Matice::InputUpdateFromVectorDakota(IssmDouble* vector, int name, int type){/*{{{*/ 574 575 } 576 /*}}}*/ 577 void Matice::ResetHooks(){/*{{{*/ 578 579 this->element=NULL; 580 581 /*Get Element type*/ 582 this->helement->reset(); 583 584 } 585 /*}}}*/ 586 void Matice::SetCurrentConfiguration(Elements* elementsin,Loads* loadsin,Nodes* nodesin,Vertices* verticesin,Materials* materialsin,Parameters* parametersin){/*{{{*/ 587 579 588 } 580 589 /*}}}*/ … … 737 746 this->GetViscosity2dDerivativeEpsSquare(pmu_prime,epsilon); 738 747 }/*}}}*/ 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 37 37 /*}}}*/ 38 38 /*Object virtual functions definitions:{{{ */ 39 Object* copy(); 40 void DeepEcho(); 39 41 void Echo(); 40 void DeepEcho();41 42 int Id(); 43 void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction); 42 44 int ObjectEnum(); 43 Object* copy();44 void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);45 45 /*}}}*/ 46 46 /*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);50 47 void InputUpdateFromConstant(IssmDouble constant, int name); 51 48 void InputUpdateFromConstant(int constant, int name); 52 49 void InputUpdateFromConstant(bool constant, int name); 53 50 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); 54 54 /*}}}*/ 55 55 /*Material virtual functions resolution: {{{*/ 56 56 void Configure(Elements* elements); 57 57 Material* copy2(Element* element); 58 void SetCurrentConfiguration(Elements* elements,Loads* loads,Nodes* nodes,Vertices* vertices,Materials* materials,Parameters* parameters);59 58 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);62 59 void GetViscosityBar(IssmDouble* pviscosity, IssmDouble eps_eff); 63 60 void GetViscosityComplement(IssmDouble* pviscosity_complement, IssmDouble* pepsilon); 64 61 void GetViscosityDComplement(IssmDouble*, IssmDouble*); 65 62 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); 66 65 void GetViscosity2dDerivativeEpsSquare(IssmDouble* pmu_prime, IssmDouble* pepsilon); 67 66 IssmDouble GetA(); … … 74 73 bool IsDamage(); 75 74 void ResetHooks(); 75 void SetCurrentConfiguration(Elements* elements,Loads* loads,Nodes* nodes,Vertices* vertices,Materials* materials,Parameters* parameters); 76 76 77 77 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 179 179 180 180 /*Object virtual functions definitions:*/ 181 Object* 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 /*}}}*/ 232 void Matpar::DeepEcho(void){/*{{{*/ 233 234 this->Echo(); 235 } 236 /*}}}*/ 181 237 void Matpar::Echo(void){/*{{{*/ 182 238 … … 204 260 } 205 261 /*}}}*/ 206 void Matpar::DeepEcho(void){/*{{{*/207 208 this->Echo();209 }210 /*}}}*/211 262 int 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 }269 263 /*}}}*/ 270 264 void Matpar::Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ /*{{{*/ … … 328 322 } 329 323 /*}}}*/ 324 int Matpar::ObjectEnum(void){/*{{{*/ 325 326 return MatparEnum; 327 328 } 329 /*}}}*/ 330 330 331 331 /*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 /*}}}*/344 332 void Matpar::InputUpdateFromConstant(IssmDouble constant, int name){/*{{{*/ 345 333 … … 410 398 /*}}}*/ 411 399 void Matpar::InputUpdateFromConstant(bool constant, int name){/*{{{*/ 400 /*Nothing updated yet*/ 401 } 402 /*}}}*/ 403 void Matpar::InputUpdateFromMatrixDakota(IssmDouble* matrix, int nrows, int ncols,int name, int type){/*{{{*/ 404 /*Nothing updated yet*/ 405 } 406 /*}}}*/ 407 void Matpar::InputUpdateFromVector(IssmDouble* vector, int name, int type){/*{{{*/ 408 /*Nothing updated yet*/ 409 } 410 /*}}}*/ 411 void Matpar::InputUpdateFromVectorDakota(IssmDouble* vector, int name, int type){/*{{{*/ 412 412 /*Nothing updated yet*/ 413 413 } -
issm/trunk-jpl/src/c/classes/Materials/Matpar.h
r20608 r20827 79 79 80 80 /*Object virtual functions definitions:{{{ */ 81 Object *copy(); 82 void DeepEcho(); 81 83 void Echo(); 82 void DeepEcho();83 84 int Id(); 85 void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction); 84 86 int ObjectEnum(); 85 Object *copy();86 void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);87 87 /*}}}*/ 88 88 /*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);92 89 void InputUpdateFromConstant(IssmDouble constant, int name); 93 90 void InputUpdateFromConstant(int constant, int name); 94 91 void InputUpdateFromConstant(bool constant, int name); 95 92 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); 96 96 /*}}}*/ 97 97 /*Material virtual functions resolution: {{{*/ … … 99 99 void Configure(Elements* elements); 100 100 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");};103 101 void GetViscosityBar(IssmDouble* pviscosity,IssmDouble eps_eff){_error_("not supported");}; 104 102 void GetViscosityComplement(IssmDouble* pviscosity_complement, IssmDouble* pepsilon){_error_("not supported");}; 105 103 void GetViscosityDComplement(IssmDouble* pviscosity_complement, IssmDouble* pepsilon){_error_("not supported");}; 106 104 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");}; 107 107 void GetViscosity2dDerivativeEpsSquare(IssmDouble* pmu_prime, IssmDouble* pepsilon){_error_("not supported");}; 108 108 IssmDouble GetA(){_error_("not supported");}; … … 110 110 IssmDouble GetB(){_error_("not supported");}; 111 111 IssmDouble GetBbar(){_error_("not supported");}; 112 IssmDouble GetN(){_error_("not supported");};113 112 IssmDouble GetD(){_error_("not supported");}; 114 113 IssmDouble GetDbar(){_error_("not supported");}; 114 IssmDouble GetN(){_error_("not supported");}; 115 115 bool IsDamage(){_error_("not supported");}; 116 116 void ResetHooks(); -
issm/trunk-jpl/src/c/classes/Options/GenericOption.h
r18918 r20827 48 48 49 49 /*Object virtual functions definitions:*/ 50 void Echo(){ /*{{{*/ 51 52 this->DeepEcho(); 53 54 } /*}}}*/ 50 Object* copy(){/*{{{*/ 51 _error_("Not implemented yet"); 52 };/*}}}*/ 55 53 void DeepEcho(){ /*{{{*/ 56 54 … … 74 72 _printf_(indent << " value: " << value << "\n");; 75 73 } /*}}}*/ 74 void Echo(){ /*{{{*/ 75 76 this->DeepEcho(); 77 78 } /*}}}*/ 76 79 int Id(){/*{{{*/ 77 80 _error_("Not implemented yet"); … … 80 83 return GenericOptionEnum; 81 84 };/*}}}*/ 82 Object* copy(){/*{{{*/83 _error_("Not implemented yet");84 };/*}}}*/85 85 86 86 /*GenericOption functions: */ 87 void Get(OptionType* pvalue){/*{{{*/ 88 *pvalue=value; 89 };/*}}}*/ 87 90 char* Name(){/*{{{*/ 88 91 return name; 92 };/*}}}*/ 93 int NDims(){/*{{{*/ 94 return ndims; 89 95 };/*}}}*/ 90 96 int NumEl(){/*{{{*/ 91 97 return numel; 92 98 };/*}}}*/ 93 int NDims(){/*{{{*/94 return ndims;95 };/*}}}*/96 99 int* Size(){/*{{{*/ 97 100 return size; 98 };/*}}}*/99 void Get(OptionType* pvalue){/*{{{*/100 *pvalue=value;101 101 };/*}}}*/ 102 102 }; -
issm/trunk-jpl/src/c/classes/Options/Option.h
r19198 r20827 20 20 21 21 /*Object virtual functions definitions*/ 22 virtual void Echo()= 0;22 Object *copy(){_error_("Not implemented yet"); }; 23 23 virtual void DeepEcho()= 0; 24 24 virtual void DeepEcho(char *indent)=0; 25 virtual void Echo()= 0; 25 26 int Id(){_error_("Not implemented yet"); }; 27 void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ _error_("not implemented yet!"); }; 26 28 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!"); };29 29 30 30 31 31 /*virtual functions: */ 32 32 virtual char* Name()=0; 33 virtual int NDims()=0; 33 34 virtual int NumEl()=0; 34 virtual int NDims()=0;35 35 virtual int* Size()=0; 36 36 -
issm/trunk-jpl/src/c/classes/Options/OptionUtilities.cpp
r18064 r20827 51 51 return(index); 52 52 }/*}}}*/ 53 int 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 }/*}}}*/ 53 71 int RowWiseDimsFromIndex(int* dims, int index, int* size, int ndims) {/*{{{*/ 54 72 … … 69 87 return(0); 70 88 }/*}}}*/ 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 }/*}}}*/89 89 int StringFromDims(char* cstr, int* dims, int ndims) {/*{{{*/ 90 90 -
issm/trunk-jpl/src/c/classes/Options/OptionUtilities.h
r15012 r20827 15 15 int ColumnWiseDimsFromIndex(int* dims, int index, int* size, int ndims); 16 16 int IndexFromColumnWiseDims(int* dims, int* size, int ndims); 17 int IndexFromRowWiseDims(int* dims, int* size, int ndims); 17 18 int RowWiseDimsFromIndex(int* dims, int index, int* size, int ndims); 18 int IndexFromRowWiseDims(int* dims, int* size, int ndims);19 19 int StringFromDims(char* cstr, int* dims, int ndims); 20 20 int StringFromSize(char* cstr, int* size, int ndims); -
issm/trunk-jpl/src/c/classes/Params/BoolParam.cpp
r20635 r20827 32 32 33 33 /*Object virtual functions definitions:*/ 34 void BoolParam::Echo(void){/*{{{*/ 35 this->DeepEcho(); 34 Param* BoolParam::copy() {/*{{{*/ 35 36 return new BoolParam(this->enum_type,this->value); 37 36 38 } 37 39 /*}}}*/ … … 40 42 } 41 43 /*}}}*/ 42 int BoolParam::Id(void){ return -1; }/*{{{*/ 43 /*}}}*/ 44 int BoolParam::ObjectEnum(void){/*{{{*/ 45 46 return BoolParamEnum; 47 44 void BoolParam::Echo(void){/*{{{*/ 45 this->DeepEcho(); 48 46 } 49 47 /*}}}*/ 50 Param* BoolParam::copy() {/*{{{*/ 51 52 return new BoolParam(this->enum_type,this->value); 53 54 } 48 int BoolParam::Id(void){ return -1; }/*{{{*/ 55 49 /*}}}*/ 56 50 void BoolParam::Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ /*{{{*/ … … 63 57 } 64 58 /*}}}*/ 59 int BoolParam::ObjectEnum(void){/*{{{*/ 60 61 return BoolParamEnum; 62 63 } 64 /*}}}*/ 65 65 -
issm/trunk-jpl/src/c/classes/Params/BoolParam.h
r20690 r20827 31 31 /*}}}*/ 32 32 /*Object virtual functions definitions:{{{ */ 33 Param* copy(); 34 void DeepEcho(); 33 35 void Echo(); 34 void DeepEcho();35 36 int Id(); 37 void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction); 36 38 int ObjectEnum(); 37 Param* copy();38 void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);39 39 /*}}}*/ 40 40 /*Param vritual function definitions: {{{*/ 41 int InstanceEnum(){return enum_type;}42 41 void GetParameterValue(bool* pbool){*pbool=value;} 43 42 void GetParameterValue(int* pinteger){_error_("Param "<< EnumToStringx(enum_type) << " cannot return an integer");} … … 55 54 void GetParameterValue(FILE** pfid){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a FILE");} 56 55 void GetParameterValue(DataSet** pdataset){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a DataSet");} 56 int InstanceEnum(){return enum_type;} 57 57 58 void SetEnum(int enum_in){this->enum_type = enum_in;}; 58 59 void SetValue(bool boolean){this->value=boolean;} 59 60 void SetValue(int integer){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold an int");} … … 69 70 void SetValue(FILE* fid){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a FILE");} 70 71 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;};72 72 /*}}}*/ 73 73 }; -
issm/trunk-jpl/src/c/classes/Params/DataSetParam.cpp
r20635 r20827 33 33 34 34 /*Object virtual functions definitions:*/ 35 void DataSetParam::Echo(void){/*{{{*/ 36 this->DeepEcho(); 35 Param* DataSetParam::copy() {/*{{{*/ 36 37 return new DataSetParam(this->enum_type,this->value); 38 37 39 } 38 40 /*}}}*/ … … 44 46 } 45 47 /*}}}*/ 46 int DataSetParam::Id(void){ return -1; }/*{{{*/ 47 /*}}}*/ 48 int DataSetParam::ObjectEnum(void){/*{{{*/ 49 50 return DataSetParamEnum; 51 48 void DataSetParam::Echo(void){/*{{{*/ 49 this->DeepEcho(); 52 50 } 53 51 /*}}}*/ 54 Param* DataSetParam::copy() {/*{{{*/ 55 56 return new DataSetParam(this->enum_type,this->value); 57 58 } 52 int DataSetParam::Id(void){ return -1; }/*{{{*/ 59 53 /*}}}*/ 60 54 void DataSetParam::Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ /*{{{*/ … … 68 62 } 69 63 /*}}}*/ 64 int DataSetParam::ObjectEnum(void){/*{{{*/ 65 66 return DataSetParamEnum; 67 68 } 69 /*}}}*/ 70 70 71 71 /*DataSetParam virtual functions definitions: */ -
issm/trunk-jpl/src/c/classes/Params/DataSetParam.h
r20690 r20827 32 32 /*}}}*/ 33 33 /*Object virtual functions definitions:{{{ */ 34 Param* copy(); 35 void DeepEcho(); 34 36 void Echo(); 35 void DeepEcho();36 37 int Id(); 38 void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction); 37 39 int ObjectEnum(); 38 Param* copy();39 void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);40 40 /*}}}*/ 41 41 /*Param vritual function definitions: {{{*/ 42 int InstanceEnum(){return enum_type;}43 42 void GetParameterValue(bool* pbool){ _error_("Param "<< EnumToStringx(enum_type) << " cannot return a bool");} 44 43 void GetParameterValue(int* pinteger){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a IssmDouble");} … … 56 55 void GetParameterValue(Matrix<IssmDouble>** pmat){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a Mat");} 57 56 void GetParameterValue(DataSet** pdataset); 57 int InstanceEnum(){return enum_type;} 58 58 59 void SetEnum(int enum_in){this->enum_type = enum_in;}; 59 60 void SetValue(bool boolean){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a string");} 60 61 void SetValue(int integer){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a string");} … … 71 72 void SetValue(DataSet* dataset){_error_("DataSet param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a DataSet yet");} 72 73 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;};74 74 /*}}}*/ 75 75 }; -
issm/trunk-jpl/src/c/classes/Params/DoubleMatArrayParam.cpp
r20635 r20827 76 76 77 77 /*Object virtual functions definitions:*/ 78 Param* DoubleMatArrayParam::copy() {/*{{{*/ 79 80 return new DoubleMatArrayParam(this->enum_type,this->array, this->M, this->mdim_array,this->ndim_array); 81 82 } 83 /*}}}*/ 84 void 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 /*}}}*/ 78 107 void DoubleMatArrayParam::Echo(void){/*{{{*/ 79 108 … … 85 114 } 86 115 /*}}}*/ 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 /*}}}*/110 116 int 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 }123 117 /*}}}*/ 124 118 void DoubleMatArrayParam::Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ /*{{{*/ … … 144 138 } 145 139 /*}}}*/ 140 int DoubleMatArrayParam::ObjectEnum(void){/*{{{*/ 141 142 return DoubleMatArrayParamEnum; 143 144 } 145 /*}}}*/ 146 146 147 147 /*DoubleMatArrayParam virtual functions definitions: */ -
issm/trunk-jpl/src/c/classes/Params/DoubleMatArrayParam.h
r20690 r20827 34 34 /*}}}*/ 35 35 /*Object virtual functions definitions:{{{ */ 36 Param* copy(); 37 void DeepEcho(); 36 38 void Echo(); 37 void DeepEcho();38 39 int Id(); 40 void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction); 39 41 int ObjectEnum(); 40 Param* copy();41 void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);42 42 /*}}}*/ 43 43 /*Param vritual function definitions: {{{*/ 44 int InstanceEnum(){return enum_type;}45 44 void GetParameterValue(bool* pbool){_error_("Param "<< EnumToStringx(enum_type) << "cannot return a bool");} 46 45 void GetParameterValue(int* pinteger){_error_("Param "<< EnumToStringx(enum_type) << "cannot return an integer");} … … 58 57 void GetParameterValue(FILE** pfid){_error_("Param "<< EnumToStringx(enum_type) << "cannot return a FILE");} 59 58 void GetParameterValue(DataSet** pdataset){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a DataSet");} 59 int InstanceEnum(){return enum_type;} 60 60 61 void SetEnum(int enum_in){this->enum_type = enum_in;}; 61 62 void SetValue(bool boolean){_error_("Param "<< EnumToStringx(enum_type) << "cannot hold a boolean");} 62 63 void SetValue(int integer){_error_("Param "<< EnumToStringx(enum_type) << "cannot hold an integer");} … … 72 73 void SetValue(FILE* fid){_error_("Bool param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a FILE");} 73 74 void SetValue(IssmDouble** array, int M, int* mdim_array, int* ndim_array); 74 void SetEnum(int enum_in){this->enum_type = enum_in;};75 75 /*}}}*/ 76 76 }; -
issm/trunk-jpl/src/c/classes/Params/DoubleParam.cpp
r20635 r20827 29 29 30 30 /*Object virtual functions definitions:*/ 31 void DoubleParam::Echo(void){/*{{{*/ 32 this->DeepEcho(); 31 Param* DoubleParam::copy() {/*{{{*/ 32 33 return new DoubleParam(this->enum_type,this->value); 34 33 35 } 34 36 /*}}}*/ … … 38 40 } 39 41 /*}}}*/ 40 int DoubleParam::Id(void){ return -1; }/*{{{*/ 41 /*}}}*/ 42 int DoubleParam::ObjectEnum(void){/*{{{*/ 43 44 return DoubleParamEnum; 45 42 void DoubleParam::Echo(void){/*{{{*/ 43 this->DeepEcho(); 46 44 } 47 45 /*}}}*/ 48 Param* DoubleParam::copy() {/*{{{*/ 49 50 return new DoubleParam(this->enum_type,this->value); 51 52 } 46 int DoubleParam::Id(void){ return -1; }/*{{{*/ 53 47 /*}}}*/ 54 48 void DoubleParam::Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ /*{{{*/ … … 58 52 MARSHALLING(enum_type); 59 53 MARSHALLING(value); 54 55 } 56 /*}}}*/ 57 int DoubleParam::ObjectEnum(void){/*{{{*/ 58 59 return DoubleParamEnum; 60 60 61 61 } -
issm/trunk-jpl/src/c/classes/Params/DoubleParam.h
r20690 r20827 32 32 /*}}}*/ 33 33 /*Object virtual functions definitions:{{{ */ 34 Param* copy(); 35 void DeepEcho(); 34 36 void Echo(); 35 void DeepEcho();36 37 int Id(); 38 void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction); 37 39 int ObjectEnum(); 38 Param* copy();39 void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);40 40 /*}}}*/ 41 41 /*Param vritual function definitions: {{{*/ 42 int InstanceEnum(){return enum_type;}43 42 void GetParameterValue(bool* pbool); 44 43 void GetParameterValue(int* pinteger); … … 56 55 void GetParameterValue(FILE** pfid){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a FILE");} 57 56 void GetParameterValue(DataSet** pdataset){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a DataSet");} 57 int InstanceEnum(){return enum_type;} 58 58 59 void SetEnum(int enum_in){this->enum_type = enum_in;}; 59 60 void SetValue(bool boolean){this->value=(IssmDouble)boolean;} 60 61 void SetValue(int integer){this->value=(IssmDouble)integer;} … … 70 71 void SetValue(FILE* fid){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a FILE");} 71 72 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;};73 73 /*}}}*/ 74 74 }; -
issm/trunk-jpl/src/c/classes/Params/DoubleVecParam.cpp
r20635 r20827 39 39 40 40 /*Object virtual functions definitions:*/ 41 void DoubleVecParam::Echo(void){/*{{{*/41 Param* DoubleVecParam::copy() {/*{{{*/ 42 42 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); 44 44 45 45 } … … 51 51 } 52 52 /*}}}*/ 53 int DoubleVecParam::Id(void){ return -1; }/*{{{*/ 54 /*}}}*/ 55 int DoubleVecParam::ObjectEnum(void){/*{{{*/ 53 void DoubleVecParam::Echo(void){/*{{{*/ 56 54 57 return DoubleVecParamEnum;55 _printf_(setw(22)<<" DoubleVecParam "<<setw(35)<<left<<EnumToStringx(this->enum_type)<<" size: "<<this->M<<"\n"); 58 56 59 57 } 60 58 /*}}}*/ 61 Param* DoubleVecParam::copy() {/*{{{*/ 62 63 return new DoubleVecParam(this->enum_type,this->values,this->M); 64 65 } 59 int DoubleVecParam::Id(void){ return -1; }/*{{{*/ 66 60 /*}}}*/ 67 61 void DoubleVecParam::Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ /*{{{*/ … … 72 66 MARSHALLING(M); 73 67 MARSHALLING_DYNAMIC(values,IssmDouble,M); 68 69 } 70 /*}}}*/ 71 int DoubleVecParam::ObjectEnum(void){/*{{{*/ 72 73 return DoubleVecParamEnum; 74 74 75 75 } -
issm/trunk-jpl/src/c/classes/Params/DoubleVecParam.h
r20690 r20827 32 32 /*}}}*/ 33 33 /*Object virtual functions definitions:{{{ */ 34 Param* copy(); 35 void DeepEcho(); 34 36 void Echo(); 35 void DeepEcho();36 37 int Id(); 38 void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction); 37 39 int ObjectEnum(); 38 Param* copy();39 void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);40 40 /*}}}*/ 41 41 /*Param virtual functions definitions: {{{*/ 42 int InstanceEnum(){return enum_type;}43 42 void GetParameterValue(bool* pbool){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a bool");} 44 43 void GetParameterValue(int* pinteger){_error_("Param "<< EnumToStringx(enum_type) << " cannot return an integer");} … … 56 55 void GetParameterValue(FILE** pfid){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a FILE");} 57 56 void GetParameterValue(DataSet** pdataset){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a DataSet");} 57 int InstanceEnum(){return enum_type;} 58 58 59 void SetEnum(int enum_in){this->enum_type = enum_in;}; 59 60 void SetValue(bool boolean){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a boolean");} 60 61 void SetValue(int integer){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold an integer");} … … 70 71 void SetValue(FILE* fid){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a FILE");} 71 72 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;};73 73 /*}}}*/ 74 74 /*DoubleVecParam specific routines:{{{*/ -
issm/trunk-jpl/src/c/classes/Params/FileParam.cpp
r20635 r20827 32 32 33 33 /*Object virtual functions definitions:*/ 34 void FileParam::Echo(void){/*{{{*/ 35 this->DeepEcho(); 34 Param* FileParam::copy() {/*{{{*/ 35 36 return new FileParam(this->enum_type,this->value); 37 36 38 } 37 39 /*}}}*/ … … 41 43 } 42 44 /*}}}*/ 43 int FileParam::Id(void){ return -1; }/*{{{*/ 44 /*}}}*/ 45 int FileParam::ObjectEnum(void){/*{{{*/ 46 47 return FileParamEnum; 48 45 void FileParam::Echo(void){/*{{{*/ 46 this->DeepEcho(); 49 47 } 50 48 /*}}}*/ 51 Param* FileParam::copy() {/*{{{*/ 52 53 return new FileParam(this->enum_type,this->value); 54 55 } 49 int FileParam::Id(void){ return -1; }/*{{{*/ 56 50 /*}}}*/ 57 51 void FileParam::Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ /*{{{*/ … … 65 59 } 66 60 /*}}}*/ 61 int FileParam::ObjectEnum(void){/*{{{*/ 62 63 return FileParamEnum; 64 65 } 66 /*}}}*/ -
issm/trunk-jpl/src/c/classes/Params/FileParam.h
r20690 r20827 31 31 /*}}}*/ 32 32 /*Object virtual functions definitions:{{{ */ 33 Param* copy(); 34 void DeepEcho(); 33 35 void Echo(); 34 void DeepEcho();35 36 int Id(); 37 void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction); 36 38 int ObjectEnum(); 37 Param* copy();38 void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);39 39 /*}}}*/ 40 40 /*Param vritual function definitions: {{{*/ 41 int InstanceEnum(){return enum_type;}42 41 void GetParameterValue(bool* pbool){ _error_("Param "<< EnumToStringx(enum_type) << " cannot return a bool");} 43 42 void GetParameterValue(int* pinteger){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a IssmDouble");} … … 55 54 void GetParameterValue(FILE** pfid){*pfid=value;}; 56 55 void GetParameterValue(DataSet** pdataset){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a DataSet");} 56 int InstanceEnum(){return enum_type;} 57 57 58 void SetEnum(int enum_in){this->enum_type = enum_in;}; 58 59 void SetValue(bool boolean){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a string");} 59 60 void SetValue(int integer){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a string");} … … 69 70 void SetValue(FILE* fid){_error_("File param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a FILE");} 70 71 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;};72 72 /*}}}*/ 73 73 }; -
issm/trunk-jpl/src/c/classes/Params/GenericParam.h
r20690 r20827 39 39 // unfortunately, having to implement such a printer method implies 40 40 // that any structured P must provide the friend << operator 41 Param* copy() { return new GenericParam<P>(*this); }; 41 42 void DeepEcho() { 42 43 _printf_("GenericParam:\n"); … … 46 47 void Echo() {DeepEcho();}; 47 48 int Id(){ return -1; }; 48 int ObjectEnum() {return GenericParamEnum;};49 49 50 50 // the "copy" has to implement the base class abstract function … … 52 52 // it does not clarify ownership of the newed up instance... 53 53 // use the default copy constructor instead 54 Param* copy() { return new GenericParam<P>(*this); };55 54 void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ 56 55 _printf_(" WARNING: parameter "<<EnumToStringx(this->myEnumVal)<<" is a GenericParam and cannot be marshalled\n"); 57 56 /*Nothing for now*/ 58 57 } 58 int ObjectEnum() {return GenericParamEnum;}; 59 59 60 60 /*}}}*/ 61 61 /*Param vritual function definitions: {{{*/ 62 int InstanceEnum(){return myEnumVal;}63 62 P& GetParameterValue() { return myP;} 64 63 const P& GetParameterValue()const { return myP;}; 64 int InstanceEnum(){return myEnumVal;} 65 65 66 66 // none of these apply ... … … 81 81 void GetParameterValue(DataSet** pdataset){_error_("Param "<< EnumToStringx(myEnumVal) << " cannot return a DataSet");} 82 82 83 void SetEnum(int enum_in){this->myEnumVal = enum_in;}; 83 84 void SetValue(bool boolean){_error_("Param "<< EnumToStringx(myEnumVal) << " cannot hold a bool");} 84 85 void SetValue(int integer){_error_("Param "<< EnumToStringx(myEnumVal) << " cannot hold an integer");} … … 94 95 void SetValue(FILE* fid){_error_("Param "<< EnumToStringx(myEnumVal) << " cannot hold a FILE");} 95 96 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;};97 97 98 98 /*}}}*/ -
issm/trunk-jpl/src/c/classes/Params/IntMatParam.cpp
r20635 r20827 37 37 38 38 /*Object virtual functions definitions:*/ 39 void IntMatParam::Echo(void){/*{{{*/39 Param* IntMatParam::copy() {/*{{{*/ 40 40 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); 44 42 45 43 } … … 59 57 } 60 58 /*}}}*/ 61 int IntMatParam::Id(void){ return -1; }/*{{{*/ 62 /*}}}*/ 63 int IntMatParam::ObjectEnum(void){/*{{{*/ 59 void IntMatParam::Echo(void){/*{{{*/ 64 60 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"); 66 64 67 65 } 68 66 /*}}}*/ 69 Param* IntMatParam::copy() {/*{{{*/ 70 71 return new IntMatParam(this->enum_type,this->value,this->M,this->N); 72 73 } 67 int IntMatParam::Id(void){ return -1; }/*{{{*/ 74 68 /*}}}*/ 75 69 void IntMatParam::Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ /*{{{*/ … … 81 75 MARSHALLING(N); 82 76 MARSHALLING_DYNAMIC(value,int,M*N); 77 } 78 /*}}}*/ 79 int IntMatParam::ObjectEnum(void){/*{{{*/ 80 81 return IntMatParamEnum; 82 83 83 } 84 84 /*}}}*/ -
issm/trunk-jpl/src/c/classes/Params/IntMatParam.h
r20690 r20827 33 33 /*}}}*/ 34 34 /*Object virtual functions definitions:{{{ */ 35 Param* copy(); 36 void DeepEcho(); 35 37 void Echo(); 36 void DeepEcho();37 38 int Id(); 39 void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction); 38 40 int ObjectEnum(); 39 Param* copy();40 void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);41 41 /*}}}*/ 42 42 /*Param vritual function definitions: {{{*/ 43 int InstanceEnum(){return enum_type;}44 43 void GetParameterValue(bool* pbool){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a bool");} 45 44 void GetParameterValue(int* pinteger){_error_("Param "<< EnumToStringx(enum_type) << " cannot return an integer");} … … 57 56 void GetParameterValue(FILE** pfid){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a FILE");} 58 57 void GetParameterValue(DataSet** pdataset){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a DataSet");} 58 int InstanceEnum(){return enum_type;} 59 59 60 void SetEnum(int enum_in){this->enum_type = enum_in;}; 60 61 void SetValue(bool boolean){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a boolean");} 61 62 void SetValue(int integer){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold an integer");} … … 71 72 void SetValue(FILE* fid){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a FILE");} 72 73 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;};74 74 /*}}}*/ 75 75 }; -
issm/trunk-jpl/src/c/classes/Params/IntParam.cpp
r20635 r20827 32 32 33 33 /*Object virtual functions definitions:*/ 34 void IntParam::Echo(void){/*{{{*/ 35 this->DeepEcho(); 34 Param* IntParam::copy() {/*{{{*/ 35 36 return new IntParam(this->enum_type,this->value); 37 36 38 } 37 39 /*}}}*/ … … 41 43 } 42 44 /*}}}*/ 43 int IntParam::Id(void){ return -1; }/*{{{*/ 44 /*}}}*/ 45 int IntParam::ObjectEnum(void){/*{{{*/ 46 47 return IntParamEnum; 48 45 void IntParam::Echo(void){/*{{{*/ 46 this->DeepEcho(); 49 47 } 50 48 /*}}}*/ 51 Param* IntParam::copy() {/*{{{*/ 52 53 return new IntParam(this->enum_type,this->value); 54 55 } 49 int IntParam::Id(void){ return -1; }/*{{{*/ 56 50 /*}}}*/ 57 51 void IntParam::Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ /*{{{*/ … … 64 58 } 65 59 /*}}}*/ 60 int IntParam::ObjectEnum(void){/*{{{*/ 66 61 62 return IntParamEnum; 63 64 } 65 /*}}}*/ 66 -
issm/trunk-jpl/src/c/classes/Params/IntParam.h
r20690 r20827 32 32 /*}}}*/ 33 33 /*Object virtual functions definitions:{{{ */ 34 Param* copy(); 35 void DeepEcho(); 34 36 void Echo(); 35 void DeepEcho();36 37 int Id(); 38 void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction); 37 39 int ObjectEnum(); 38 Param* copy();39 void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);40 40 /*}}}*/ 41 41 /*Param vritual function definitions: {{{*/ 42 int InstanceEnum(){return enum_type;}43 42 void GetParameterValue(bool* pbool){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a bool");} 44 43 void GetParameterValue(int* pinteger){*pinteger=value;} … … 56 55 void GetParameterValue(FILE** pfid){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a FILE");} 57 56 void GetParameterValue(DataSet** pdataset){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a DataSet");} 57 int InstanceEnum(){return enum_type;} 58 58 59 void SetEnum(int enum_in){this->enum_type = enum_in;}; 59 60 void SetValue(bool boolean){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a bool");} 60 61 void SetValue(int integer){this->value=integer;} … … 70 71 void SetValue(FILE* fid){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a FILE");} 71 72 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;};73 73 /*}}}*/ 74 74 }; -
issm/trunk-jpl/src/c/classes/Params/IntVecParam.cpp
r20635 r20827 51 51 52 52 /*Object virtual functions definitions:*/ 53 void IntVecParam::Echo(void){/*{{{*/53 Param* IntVecParam::copy() {/*{{{*/ 54 54 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); 58 56 59 57 } … … 71 69 } 72 70 /*}}}*/ 73 int IntVecParam::Id(void){ return -1; }/*{{{*/ 74 /*}}}*/ 75 int IntVecParam::ObjectEnum(void){/*{{{*/ 71 void IntVecParam::Echo(void){/*{{{*/ 76 72 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"); 78 76 79 77 } 80 78 /*}}}*/ 81 Param* IntVecParam::copy() {/*{{{*/ 82 83 return new IntVecParam(this->enum_type,this->values,this->M); 84 85 } 79 int IntVecParam::Id(void){ return -1; }/*{{{*/ 86 80 /*}}}*/ 87 81 void IntVecParam::Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ /*{{{*/ … … 95 89 } 96 90 else values=NULL; 91 92 } 93 /*}}}*/ 94 int IntVecParam::ObjectEnum(void){/*{{{*/ 95 96 return IntVecParamEnum; 97 97 98 98 } -
issm/trunk-jpl/src/c/classes/Params/IntVecParam.h
r20690 r20827 33 33 /*}}}*/ 34 34 /*Object virtual functions definitions:{{{ */ 35 Param* copy(); 36 void DeepEcho(); 35 37 void Echo(); 36 void DeepEcho();37 38 int Id(); 39 void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction); 38 40 int ObjectEnum(); 39 Param* copy();40 void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);41 41 /*}}}*/ 42 42 /*Param virtual functions definitions: {{{*/ 43 int InstanceEnum(){return enum_type;}44 43 void GetParameterValue(bool* pbool){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a bool");} 45 44 void GetParameterValue(int* pinteger){_error_("Param "<< EnumToStringx(enum_type) << " cannot return an integer");} … … 57 56 void GetParameterValue(FILE** pfid){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a FILE");} 58 57 void GetParameterValue(DataSet** pdataset){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a DataSet");} 58 int InstanceEnum(){return enum_type;} 59 59 60 void SetEnum(int enum_in){this->enum_type = enum_in;}; 60 61 void SetValue(bool boolean){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a boolean");} 61 62 void SetValue(int integer){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold an integer");} … … 71 72 void SetValue(FILE* fid){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a FILE");} 72 73 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;};74 74 /*}}}*/ 75 75 }; -
issm/trunk-jpl/src/c/classes/Params/MatrixParam.cpp
r20635 r20827 36 36 37 37 /*Object virtual functions definitions:*/ 38 void MatrixParam::Echo(void){/*{{{*/38 Param* MatrixParam::copy() {/*{{{*/ 39 39 40 _printf_("MatrixParam:\n"); 41 _printf_(" enum: " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")\n"); 40 return new MatrixParam(this->enum_type,this->value); 42 41 43 42 } … … 50 49 } 51 50 /*}}}*/ 51 void MatrixParam::Echo(void){/*{{{*/ 52 53 _printf_("MatrixParam:\n"); 54 _printf_(" enum: " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")\n"); 55 56 } 57 /*}}}*/ 52 58 int MatrixParam::Id(void){ return -1; }/*{{{*/ 53 59 /*}}}*/ … … 55 61 56 62 return MatrixParamEnum; 57 58 }59 /*}}}*/60 Param* MatrixParam::copy() {/*{{{*/61 62 return new MatrixParam(this->enum_type,this->value);63 63 64 64 } -
issm/trunk-jpl/src/c/classes/Params/MatrixParam.h
r20690 r20827 32 32 /*}}}*/ 33 33 /*Object virtual functions definitions:{{{ */ 34 Param* copy(); 35 void DeepEcho(); 34 36 void Echo(); 35 void DeepEcho();36 37 int Id(); 38 void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ _error_("not implemented yet!"); }; 37 39 int ObjectEnum(); 38 Param* copy();39 void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ _error_("not implemented yet!"); };40 40 /*}}}*/ 41 41 /*Param vritual function definitions: {{{*/ 42 int InstanceEnum(){return enum_type;}43 42 void GetParameterValue(bool* pbool){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a bool");} 44 43 void GetParameterValue(int* pinteger){_error_("Param "<< EnumToStringx(enum_type) << " cannot return an integer");} … … 56 55 void GetParameterValue(FILE** pfid){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a FILE");} 57 56 void GetParameterValue(DataSet** pdataset){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a DataSet");} 57 int InstanceEnum(){return enum_type;} 58 58 59 void SetEnum(int enum_in){this->enum_type = enum_in;}; 59 60 void SetValue(bool boolean){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a boolean");} 60 61 void SetValue(int integer){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold an integer");} … … 70 71 void SetValue(FILE* fid){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a FILE");} 71 72 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;};73 73 /*}}}*/ 74 74 }; -
issm/trunk-jpl/src/c/classes/Params/Param.h
r20690 r20827 25 25 26 26 /*Virtual functions:*/ 27 virtual Param* copy()=0; 27 28 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;32 29 virtual void GetParameterValue(bool* pbool)=0; 33 30 virtual void GetParameterValue(int* pinteger)=0; … … 45 42 virtual void GetParameterValue(FILE** pfid)=0; 46 43 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; 47 47 48 virtual void SetEnum(int enum_in)=0; 48 49 virtual void SetValue(bool boolean)=0; 49 50 virtual void SetValue(int integer)=0; … … 59 60 virtual void SetValue(FILE* fid)=0; 60 61 virtual void SetValue(IssmDouble** array, int M, int* mdim_array, int* ndim_array)=0; 61 virtual void SetEnum(int enum_in)=0;62 62 }; 63 63 #endif -
issm/trunk-jpl/src/c/classes/Params/Parameters.cpp
r20638 r20827 89 89 } 90 90 /*}}}*/ 91 void Parameters::DeepEcho(void){/*{{{*/ 92 _error_("not implemented yet"); 93 } 94 /*}}}*/ 95 void Parameters::Echo(void){/*{{{*/ 96 _error_("not implemented yet"); 97 } 98 /*}}}*/ 91 99 void Parameters::Marshall(char** pmarshalled_data, int* pmarshalled_data_size, int marshall_direction){/*{{{*/ 92 100 … … 209 217 } 210 218 } 211 }212 /*}}}*/213 void Parameters::Echo(void){/*{{{*/214 _error_("not implemented yet");215 }216 /*}}}*/217 void Parameters::DeepEcho(void){/*{{{*/218 _error_("not implemented yet");219 219 } 220 220 /*}}}*/ -
issm/trunk-jpl/src/c/classes/Params/Parameters.h
r20635 r20827 28 28 29 29 /*numerics*/ 30 bool Exist(int enum_type);31 30 void AddObject(Param* newparam); 32 31 Parameters* Copy(void); 32 void DeepEcho(); 33 void Echo(); 34 bool Exist(int enum_type); 33 35 void Marshall(char** pmarshalled_data, int* pmarshalled_data_size, int marshall_direction); 34 void Echo();35 void DeepEcho();36 36 37 37 void FindParam(bool* pinteger,int enum_type); -
issm/trunk-jpl/src/c/classes/Params/StringArrayParam.cpp
r20690 r20827 56 56 57 57 /*Object virtual functions definitions:*/ 58 void StringArrayParam::Echo(void){/*{{{*/ 59 this->DeepEcho(); 58 Param* StringArrayParam::copy() {/*{{{*/ 59 60 return new StringArrayParam(this->enum_type,this->value,this->numstrings); 61 60 62 } 61 63 /*}}}*/ … … 67 69 } 68 70 /*}}}*/ 69 int StringArrayParam::Id(void){ return -1; }/*{{{*/ 70 /*}}}*/ 71 int StringArrayParam::ObjectEnum(void){/*{{{*/ 72 73 return StringArrayParamEnum; 74 71 void StringArrayParam::Echo(void){/*{{{*/ 72 this->DeepEcho(); 75 73 } 76 74 /*}}}*/ 77 Param* StringArrayParam::copy() {/*{{{*/ 78 79 return new StringArrayParam(this->enum_type,this->value,this->numstrings); 80 81 } 75 int StringArrayParam::Id(void){ return -1; }/*{{{*/ 82 76 /*}}}*/ 83 77 void StringArrayParam::Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ /*{{{*/ … … 104 98 //cleanup sizes array 105 99 if(sizes) xDelete<int>(sizes); 100 101 } 102 /*}}}*/ 103 int StringArrayParam::ObjectEnum(void){/*{{{*/ 104 105 return StringArrayParamEnum; 106 106 107 107 } -
issm/trunk-jpl/src/c/classes/Params/StringArrayParam.h
r20690 r20827 32 32 /*}}}*/ 33 33 /*Object virtual functions definitions:{{{ */ 34 Param* copy(); 35 void DeepEcho(); 34 36 void Echo(); 35 void DeepEcho();36 37 int Id(); 38 void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction); 37 39 int ObjectEnum(); 38 Param* copy();39 void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);40 40 /*}}}*/ 41 41 /*Param vritual function definitions: {{{*/ 42 int InstanceEnum(){return enum_type;}43 42 void GetParameterValue(bool* pbool){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a bool");} 44 43 void GetParameterValue(int* pinteger){_error_("Param "<< EnumToStringx(enum_type) << " cannot return an integer");} … … 56 55 void GetParameterValue(FILE** pfid){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a FILE");} 57 56 void GetParameterValue(DataSet** pdataset){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a DataSet");} 57 int InstanceEnum(){return enum_type;} 58 58 59 void SetEnum(int enum_in){this->enum_type = enum_in;}; 59 60 void SetValue(bool boolean){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a boolean");} 60 61 void SetValue(int integer){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold an integer");} … … 70 71 void SetValue(FILE* fid){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a FILE");} 71 72 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;};73 73 /*}}}*/ 74 74 }; -
issm/trunk-jpl/src/c/classes/Params/StringParam.cpp
r20635 r20827 34 34 35 35 /*Object virtual functions definitions:*/ 36 void StringParam::Echo(void){/*{{{*/ 37 this->DeepEcho(); 36 Param* StringParam::copy() {/*{{{*/ 37 38 return new StringParam(this->enum_type,this->value); 39 38 40 } 39 41 /*}}}*/ … … 42 44 } 43 45 /*}}}*/ 44 int StringParam::Id(void){ return -1; }/*{{{*/ 45 /*}}}*/ 46 int StringParam::ObjectEnum(void){/*{{{*/ 47 48 return StringParamEnum; 49 46 void StringParam::Echo(void){/*{{{*/ 47 this->DeepEcho(); 50 48 } 51 49 /*}}}*/ 52 Param* StringParam::copy() {/*{{{*/ 53 54 return new StringParam(this->enum_type,this->value); 55 56 } 50 int StringParam::Id(void){ return -1; }/*{{{*/ 57 51 /*}}}*/ 58 52 void StringParam::Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ /*{{{*/ … … 66 60 MARSHALLING(size); 67 61 MARSHALLING_DYNAMIC(value,char,size); 62 63 } 64 /*}}}*/ 65 int StringParam::ObjectEnum(void){/*{{{*/ 66 67 return StringParamEnum; 68 68 69 69 } -
issm/trunk-jpl/src/c/classes/Params/StringParam.h
r20690 r20827 32 32 /*}}}*/ 33 33 /*Object virtual functions definitions:{{{ */ 34 Param* copy(); 35 void DeepEcho(); 34 36 void Echo(); 35 void DeepEcho();36 37 int Id(); 38 void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction); 37 39 int ObjectEnum(); 38 Param* copy();39 void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);40 40 /*}}}*/ 41 41 /*Param vritual function definitions: {{{*/ 42 int InstanceEnum(){return enum_type;}43 42 void GetParameterValue(bool* pbool){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a bool");} 44 43 void GetParameterValue(int* pinteger){_error_("Param "<< EnumToStringx(enum_type) << " cannot return an integer");} … … 56 55 void GetParameterValue(FILE** pfid){_error_("Bool param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a FILE");} 57 56 void GetParameterValue(DataSet** pdataset){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a DataSet");} 57 int InstanceEnum(){return enum_type;} 58 58 59 void SetEnum(int enum_in){this->enum_type = enum_in;}; 59 60 void SetValue(bool boolean){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a boolean");} 60 61 void SetValue(int integer){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold an integer");} … … 70 71 void SetValue(FILE* fid){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a FILE");} 71 72 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;};73 73 /*}}}*/ 74 74 }; -
issm/trunk-jpl/src/c/classes/Params/TransientParam.cpp
r20635 r20827 42 42 43 43 /*Object virtual functions definitions:*/ 44 void TransientParam::Echo(void){/*{{{*/44 Param* TransientParam::copy() {/*{{{*/ 45 45 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); 49 47 50 48 } … … 60 58 } 61 59 /*}}}*/ 62 int TransientParam::Id(void){ return -1; }/*{{{*/ 63 /*}}}*/ 64 int TransientParam::ObjectEnum(void){/*{{{*/ 60 void TransientParam::Echo(void){/*{{{*/ 65 61 66 return TransientParamEnum; 62 _printf_("TransientParam:\n"); 63 _printf_(" enum: " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")\n"); 64 _printf_(" size: " << this->N << "\n"); 67 65 68 66 } 69 67 /*}}}*/ 70 Param* TransientParam::copy() {/*{{{*/ 71 72 return new TransientParam(this->enum_type,this->values,this->timesteps,this->interpolation,this->N); 73 74 } 68 int TransientParam::Id(void){ return -1; }/*{{{*/ 75 69 /*}}}*/ 76 70 void TransientParam::Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ /*{{{*/ … … 87 81 MARSHALLING_ARRAY(values,IssmDouble,N); 88 82 MARSHALLING_ARRAY(timesteps,IssmDouble,N); 83 84 } 85 /*}}}*/ 86 int TransientParam::ObjectEnum(void){/*{{{*/ 87 88 return TransientParamEnum; 89 89 90 90 } -
issm/trunk-jpl/src/c/classes/Params/TransientParam.h
r20690 r20827 34 34 /*}}}*/ 35 35 /*Object virtual functions definitions:{{{ */ 36 Param* copy(); 37 void DeepEcho(); 36 38 void Echo(); 37 void DeepEcho();38 39 int Id(); 40 void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction); 39 41 int ObjectEnum(); 40 Param* copy();41 void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);42 42 /*}}}*/ 43 43 /*Param vritual function definitions: {{{*/ 44 int InstanceEnum(){return enum_type;}45 44 void GetParameterValue(bool* pbool){_error_("Parameter " <<EnumToStringx(enum_type) << " cannot return a bool");} 46 45 void GetParameterValue(int* pinteger){_error_("Parameter " <<EnumToStringx(enum_type) << " cannot return an integer");} … … 58 57 void GetParameterValue(FILE** pfid){_error_("Parameter " <<EnumToStringx(enum_type) << " cannot return a FILE");} 59 58 void GetParameterValue(DataSet** pdataset){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a DataSet");} 59 int InstanceEnum(){return enum_type;} 60 60 61 void SetEnum(int enum_in){this->enum_type = enum_in;}; 61 62 void SetValue(bool boolean){_error_("Parameter " <<EnumToStringx(enum_type) << " cannot hold a boolean");} 62 63 void SetValue(int integer){_error_("Parameter " <<EnumToStringx(enum_type) << " cannot hold an integer");} … … 72 73 void SetValue(FILE* fid){_error_("Parameter " <<EnumToStringx(enum_type) << " cannot hold a FILE");} 73 74 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;};75 75 /*}}}*/ 76 76 }; -
issm/trunk-jpl/src/c/classes/Params/VectorParam.cpp
r20635 r20827 38 38 39 39 /*Object virtual functions definitions:*/ 40 void VectorParam::Echo(void){/*{{{*/40 Param* VectorParam::copy() {/*{{{*/ 41 41 42 _printf_("VectorParam:\n"); 43 _printf_(" enum: " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")\n"); 42 return new VectorParam(this->enum_type,this->value); 44 43 45 44 } … … 52 51 } 53 52 /*}}}*/ 53 void VectorParam::Echo(void){/*{{{*/ 54 55 _printf_("VectorParam:\n"); 56 _printf_(" enum: " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")\n"); 57 58 } 59 /*}}}*/ 54 60 int VectorParam::Id(void){ return -1; }/*{{{*/ 55 61 /*}}}*/ … … 57 63 58 64 return VectorParamEnum; 59 60 }61 /*}}}*/62 Param* VectorParam::copy() {/*{{{*/63 64 return new VectorParam(this->enum_type,this->value);65 65 66 66 } -
issm/trunk-jpl/src/c/classes/Params/VectorParam.h
r20690 r20827 32 32 /*}}}*/ 33 33 /*Object virtual functions definitions:{{{ */ 34 Param* copy(); 35 void DeepEcho(); 34 36 void Echo(); 35 void DeepEcho();36 37 int Id(); 38 void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ _error_("not implemented yet!"); }; 37 39 int ObjectEnum(); 38 Param* copy();39 void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ _error_("not implemented yet!"); };40 40 /*}}}*/ 41 41 /*Param vritual function definitions: {{{*/ 42 int InstanceEnum(){return enum_type;}43 42 void GetParameterValue(bool* pbool){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a bool");} 44 43 void GetParameterValue(int* pinteger){_error_("Param "<< EnumToStringx(enum_type) << " cannot return an integer");} … … 56 55 void GetParameterValue(FILE** pfid){_error_("Vector of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a FILE");} 57 56 void GetParameterValue(DataSet** pdataset){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a DataSet");} 57 int InstanceEnum(){return enum_type;} 58 58 59 void SetEnum(int enum_in){this->enum_type = enum_in;}; 59 60 void SetValue(bool boolean){_error_("Vector of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a boolean");} 60 61 void SetValue(int integer){_error_("Vector of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold an integer");} … … 70 71 void SetValue(FILE* fid){_error_("Vector of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a FILE");} 71 72 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;};73 73 /*}}}*/ 74 74 }; -
issm/trunk-jpl/src/c/classes/gauss/Gauss.h
r16892 r20827 13 13 virtual ~Gauss(){}; 14 14 virtual int begin(void)=0; 15 virtual void Echo(void)=0; 15 16 virtual int end(void)=0; 16 virtual void Echo(void)=0;17 17 virtual int Enum(void)=0; 18 virtual void GaussNode(int finitelement,int iv)=0; 18 19 virtual void GaussPoint(int ig)=0; 19 20 virtual void GaussVertex(int iv)=0; 20 virtual void GaussNode(int finitelement,int iv)=0;21 21 virtual void SynchronizeGaussBase(Gauss* gauss)=0; 22 22 -
issm/trunk-jpl/src/c/classes/gauss/GaussPenta.cpp
r20215 r20827 443 443 444 444 /*Methods*/ 445 int 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 /*}}}*/ 445 459 void GaussPenta::Echo(void){/*{{{*/ 446 460 … … 487 501 } 488 502 /*}}}*/ 503 int 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 /*}}}*/ 489 517 int GaussPenta::Enum(void){/*{{{*/ 490 518 return GaussPentaEnum; 519 } 520 /*}}}*/ 521 void 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 491 536 } 492 537 /*}}}*/ … … 502 547 coord3=coords3[ig]; 503 548 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 }540 549 541 550 } … … 720 729 } 721 730 /*}}}*/ 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; 731 void 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 748 748 } 749 749 /*}}}*/ -
issm/trunk-jpl/src/c/classes/gauss/GaussPenta.h
r16892 r20827 41 41 /*Methods*/ 42 42 int begin(void); 43 void Echo(void); 43 44 int end(void); 44 void Echo(void);45 45 int Enum(void); 46 void GaussFaceTria(int index1, int index2, int index3, int order); 47 void GaussNode(int finitelement,int iv); 46 48 void GaussPoint(int ig); 47 49 void GaussVertex(int iv); 48 void GaussNode(int finitelement,int iv);49 void GaussFaceTria(int index1, int index2, int index3, int order);50 50 void SynchronizeGaussBase(Gauss* gauss); 51 51 }; -
issm/trunk-jpl/src/c/classes/gauss/GaussSeg.cpp
r18064 r20827 74 74 75 75 /*Methods*/ 76 int 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 /*}}}*/ 76 87 void GaussSeg::Echo(void){/*{{{*/ 77 88 … … 95 106 } 96 107 /*}}}*/ 108 int 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 /*}}}*/ 97 119 int GaussSeg::Enum(void){/*{{{*/ 98 120 return GaussSegEnum; … … 107 129 weight=weights[ig]; 108 130 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 }122 131 } 123 132 /*}}}*/ … … 141 150 } 142 151 /*}}}*/ 143 int GaussSeg::begin(void){/*{{{*/152 void GaussSeg::GaussVertex(int iv){/*{{{*/ 144 153 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); 149 156 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 } 163 163 } 164 164 /*}}}*/ -
issm/trunk-jpl/src/c/classes/gauss/GaussSeg.h
r17310 r20827 30 30 /*Methods*/ 31 31 int begin(void); 32 void Echo(void); 32 33 int end(void); 33 void Echo(void);34 34 int Enum(void); 35 35 void GaussPoint(int ig); 36 void GaussNode(int finitelement,int iv); 36 37 void GaussVertex(int iv); 37 void GaussNode(int finitelement,int iv);38 38 void SynchronizeGaussBase(Gauss* gauss); 39 39 }; -
issm/trunk-jpl/src/c/classes/gauss/GaussTetra.cpp
r18064 r20827 94 94 95 95 /*Methods*/ 96 int 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 /*}}}*/ 96 110 void GaussTetra::Echo(void){/*{{{*/ 97 111 … … 136 150 _printf_(" coord4 = " << coord4 << "\n"); 137 151 152 } 153 /*}}}*/ 154 int 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; 138 166 } 139 167 /*}}}*/ … … 153 181 coord3=coords3[ig]; 154 182 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 }172 183 173 184 } … … 220 231 } 221 232 /*}}}*/ 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; 233 void 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 248 248 } 249 249 /*}}}*/ -
issm/trunk-jpl/src/c/classes/gauss/GaussTetra.h
r17472 r20827 36 36 /*Methods*/ 37 37 int begin(void); 38 void Echo(void); 38 39 int end(void); 39 void Echo(void);40 40 int Enum(void); 41 41 void GaussPoint(int ig); 42 void GaussNode(int finitelement,int iv); 42 43 void GaussVertex(int iv); 43 void GaussNode(int finitelement,int iv);44 44 void SynchronizeGaussBase(Gauss* gauss); 45 45 }; -
issm/trunk-jpl/src/c/classes/gauss/GaussTria.cpp
r18170 r20827 297 297 298 298 /*Methods*/ 299 int 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 /*}}}*/ 299 312 void GaussTria::Echo(void){/*{{{*/ 300 313 … … 334 347 } 335 348 /*}}}*/ 349 int 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 /*}}}*/ 336 362 int GaussTria::Enum(void){/*{{{*/ 337 363 return GaussTriaEnum; … … 368 394 } 369 395 /*}}}*/ 396 void 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 /*}}}*/ 370 422 void GaussTria::GaussPoint(int ig){/*{{{*/ 371 423 … … 378 430 coord2=coords2[ig]; 379 431 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 }421 432 422 433 } … … 480 491 } 481 492 /*}}}*/ 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; 493 void 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 506 506 } 507 507 /*}}}*/ -
issm/trunk-jpl/src/c/classes/gauss/GaussTria.h
r16892 r20827 36 36 /*Methods*/ 37 37 int begin(void); 38 void Echo(void); 38 39 int end(void); 39 void Echo(void);40 40 int Enum(void); 41 void GaussEdgeCenter(int index1,int index2); 41 42 void GaussFromCoords(IssmDouble x1,IssmDouble y1,IssmDouble* xyz_list); 42 43 void GaussPoint(int ig); 44 void GaussNode(int finitelement,int iv); 43 45 void GaussVertex(int iv); 44 void GaussNode(int finitelement,int iv);45 void GaussEdgeCenter(int index1,int index2);46 46 void SynchronizeGaussBase(Gauss* gauss); 47 47 }; -
issm/trunk-jpl/src/c/classes/kriging/Covertree.cpp
r19153 r20827 31 31 32 32 /*Methods*/ 33 std::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 }/*}}}*/ 46 int Covertree::get_numberofobs(){/*{{{*/ 47 return _numNodes; 48 }/*}}}*/ 49 void 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 }/*}}}*/ 69 bool 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 }/*}}}*/ 33 108 std::vector<Covertree::CoverTreeNode*> Covertree::kNearestNodes(const Observation& p, const unsigned int& k) const{/*{{{*/ 34 109 if(_root==NULL) return std::vector<CoverTreeNode*>(); … … 78 153 return kNN; 79 154 }/*}}}*/ 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; 155 std::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 }/*}}}*/ 167 void 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 }/*}}}*/ 194 void 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; 114 210 } 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; 117 230 } 118 231 }/*}}}*/ … … 219 332 } 220 333 }/*}}}*/ 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 way244 //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 with250 //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 root259 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 }/*}}}*/334 334 335 Covertree::CoverTreeNode* Covertree::getRoot() const{/*{{{*/ 336 return _root; 335 void Covertree::CoverTreeNode::addChild(int level, CoverTreeNode* p){/*{{{*/ 336 _childMap[level].push_back(p); 337 }/*}}}*/ 338 void Covertree::CoverTreeNode::addObservation(const Observation& p){/*{{{*/ 339 if(find(_observations.begin(), _observations.end(), p) == _observations.end()) 340 _observations.push_back(p); 337 341 }/*}}}*/ 338 342 Covertree::CoverTreeNode::CoverTreeNode(const Observation& p) {/*{{{*/ 339 343 _observations.push_back(p); 344 }/*}}}*/ 345 double Covertree::CoverTreeNode::distance(const CoverTreeNode& p) const{/*{{{*/ 346 return _observations[0].distance(p.getObservation()); 347 }/*}}}*/ 348 std::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; 340 355 }/*}}}*/ 341 356 std::vector<Covertree::CoverTreeNode*> Covertree::CoverTreeNode::getChildren(int level) const{/*{{{*/ … … 347 362 return std::vector<CoverTreeNode*>(); 348 363 }/*}}}*/ 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()); 364 const Observation& Covertree::CoverTreeNode::getObservation() const{/*{{{*/ 365 return _observations[0]; 366 }/*}}}*/ 367 Covertree::CoverTreeNode* Covertree::getRoot() const{/*{{{*/ 368 return _root; 369 }/*}}}*/ 370 bool Covertree::CoverTreeNode::hasObservation(const Observation& p) const{/*{{{*/ 371 return find(_observations.begin(), _observations.end(), p) != _observations.end(); 374 372 }/*}}}*/ 375 373 bool Covertree::CoverTreeNode::isSingle() const{/*{{{*/ 376 374 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;391 375 }/*}}}*/ 392 376 bool Covertree::isValidTree() const {/*{{{*/ … … 429 413 return true; 430 414 }/*}}}*/ 415 void 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 }/*}}}*/ 425 void 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 25 25 * has itself as a child in a cover tree. 26 26 */ 27 std::vector<CoverTreeNode*> getChildren(int level) const;28 27 void addChild(int level, CoverTreeNode* p); 29 void removeChild(int level, CoverTreeNode* p);30 28 void addObservation(const Observation& o); 31 void removeObservation(const Observation& o);32 const std::vector<Observation>& getObservations() { return _observations; }33 29 double distance(const CoverTreeNode& p) const; 34 30 bool isSingle() const; 35 31 bool hasObservation(const Observation& o) const; 32 std::vector<CoverTreeNode*> getChildren(int level) const; 36 33 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); 37 37 38 38 /** … … 51 51 int _minLevel; //A level beneath which there are no more new nodes. 52 52 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); 54 56 /** 55 57 * Recursive implementation of the insert algorithm (see paper). … … 57 59 bool insert_rec(const Observation& p, const std::vector<distNodePair>& Qi,const int& level); 58 60 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; 64 62 void remove_rec(const Observation& p, std::map<int,std::vector<distNodePair> >& coverSets, int level, bool& multi); 65 63 … … 80 78 81 79 /** 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 /** 82 89 * Just for testing/debugging. Returns true iff the cover tree satisfies the 83 90 * the covering tree invariants (every node in level i is greater than base^i … … 88 95 bool isValidTree() const; 89 96 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 tree93 * is unchanged. If p.distance(newPoint)==0.0 but newPoint!=p, then94 * newPoint WILL be inserted and both points may be returned in k-nearest-95 * neighbor searches.96 */97 void insert(const Observation& newObservation);98 97 99 98 /** -
issm/trunk-jpl/src/c/classes/kriging/ExponentialVariogram.cpp
r18237 r20827 42 42 43 43 /*Object virtual functions definitions:*/ 44 Object* ExponentialVariogram::copy(void){/*{{{*/ 45 return new ExponentialVariogram(*this); 46 } 47 /*}}}*/ 44 48 void ExponentialVariogram::Echo(void){/*{{{*/ 45 49 _printf_("ExponentialVariogram\n"); … … 47 51 _printf_(" sill : " << this->sill << "\n"); 48 52 _printf_(" range : " << this->range << "\n"); 49 }50 /*}}}*/51 Object* ExponentialVariogram::copy(void){/*{{{*/52 return new ExponentialVariogram(*this);53 53 } 54 54 /*}}}*/ -
issm/trunk-jpl/src/c/classes/kriging/ExponentialVariogram.h
r19198 r20827 22 22 23 23 /*Object virtual functions definitions*/ 24 Object* copy(); 25 void DeepEcho(){_error_("Not implemented yet");}; 24 26 void Echo(); 25 void DeepEcho(){_error_("Not implemented yet");};26 27 int Id(){_error_("Not implemented yet");}; 28 void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ _error_("not implemented yet!"); }; 27 29 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!"); };30 30 31 31 32 32 /*Variogram functions*/ 33 double Covariance(double deltax,double deltay); 33 34 double SemiVariogram(double deltax,double deltay); 34 double Covariance(double deltax,double deltay);35 35 }; 36 36 #endif /* _EXPONENTIALVARIOGRAM_H */ -
issm/trunk-jpl/src/c/classes/kriging/GaussianVariogram.cpp
r18237 r20827 42 42 43 43 /*Object virtual functions definitions:*/ 44 Object* GaussianVariogram::copy(void){/*{{{*/ 45 return new GaussianVariogram(*this); 46 } 47 /*}}}*/ 44 48 void GaussianVariogram::Echo(void){/*{{{*/ 45 49 _printf_("GaussianVariogram\n"); … … 47 51 _printf_(" sill : " << this->sill << "\n"); 48 52 _printf_(" range : " << this->range << "\n"); 49 }50 /*}}}*/51 Object* GaussianVariogram::copy(void){/*{{{*/52 return new GaussianVariogram(*this);53 53 } 54 54 /*}}}*/ -
issm/trunk-jpl/src/c/classes/kriging/GaussianVariogram.h
r19198 r20827 23 23 24 24 /*Object virtual functions definitions*/ 25 Object* copy(); 26 void DeepEcho(){_error_("Not implemented yet");}; 25 27 void Echo(); 26 void DeepEcho(){_error_("Not implemented yet");};27 28 int Id(){_error_("Not implemented yet");}; 29 void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ _error_("not implemented yet!"); }; 28 30 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!"); };31 31 32 32 /*Variogram functions*/ 33 double Covariance(double deltax,double deltay); 33 34 double SemiVariogram(double deltax,double deltay); 34 double Covariance(double deltax,double deltay);35 35 }; 36 36 #endif /* _GAUSSIANVARIOGRAM_H */ -
issm/trunk-jpl/src/c/classes/kriging/Observation.cpp
r18914 r20827 41 41 42 42 /*Object virtual functions definitions:*/ 43 Object* 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 /*}}}*/ 43 53 void Observation::Echo(void){/*{{{*/ 44 54 … … 53 63 } 54 64 /*}}}*/ 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 /*}}}*/65 65 66 66 /*Observations functions*/ … … 73 73 74 74 /*Covertree*/ 75 bool Observation::operator==(const Observation& ob) const{/*{{{*/ 76 return (ob.x == this->x && ob.y == this->y && ob.value == this->value); 77 }/*}}}*/ 78 double 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 /*}}}*/ 75 82 void Observation::print(void) const{/*{{{*/ 76 83 … … 81 88 } 82 89 /*}}}*/ 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){ 90 void Observation::WriteXYObs(const Observation& ob, double* px, double* py, double* pobs){/*{{{*/ 94 91 *px = ob.x; 95 92 *py = ob.y; 96 93 *pobs = ob.value; 97 } 94 }/*}}}*/ -
issm/trunk-jpl/src/c/classes/kriging/Observation.h
r19198 r20827 24 24 25 25 /*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"); };33 26 bool operator==(const Observation& ob) const; 34 27 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; 35 33 void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ _error_("not implemented yet!");}; 36 34 int ObjectEnum(){_error_("Not implemented yet"); }; 37 35 38 36 /*Management*/ -
issm/trunk-jpl/src/c/classes/kriging/Observations.cpp
r19156 r20827 77 77 78 78 /*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 /*}}}*/154 79 void Observations::InitCovertree(IssmPDouble* observations_list,IssmPDouble* x,IssmPDouble* y,int n,Options* options){/*{{{*/ 155 80 … … 208 133 } 209 134 /*}}}*/ 135 void 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 /*}}}*/ 210 210 211 211 /*Methods*/ … … 222 222 _error_("Tree type "<<this->treetype<<" not supported yet (1: quadtree, 2: covertree)"); 223 223 } 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);275 224 276 225 }/*}}}*/ … … 297 246 *pobs = UNDEF; 298 247 }/*}}}*/ 248 void 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 }/*}}}*/ 299 299 void Observations::Distances(IssmPDouble* distances,IssmPDouble *x,IssmPDouble *y,int n,IssmPDouble radius){/*{{{*/ 300 300 … … 350 350 _error_("Tree type "<<this->treetype<<" not supported yet (1: quadtree, 2: covertree)"); 351 351 } 352 }/*}}}*/ 353 void 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(); 352 395 }/*}}}*/ 353 396 void Observations::ObservationListQuadtree(IssmPDouble **px,IssmPDouble **py,IssmPDouble **pobs,int* pnobs,IssmPDouble x_interp,IssmPDouble y_interp,IssmPDouble radius,int maxdata){/*{{{*/ … … 433 476 *pnobs=nobs; 434 477 }/*}}}*/ 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 neighbor447 //searches for the first neighbor that is out of radius448 //deletes and resizes the kNN vector449 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 }/*}}}*/478 478 void Observations::InterpolationIDW(IssmPDouble *pprediction,IssmPDouble x_interp,IssmPDouble y_interp,IssmPDouble radius,int mindata,int maxdata,IssmPDouble power){/*{{{*/ 479 479 -
issm/trunk-jpl/src/c/classes/kriging/Observations.h
r19153 r20827 29 29 30 30 /*Initialize data structures*/ 31 void InitCovertree(IssmDouble* observations_list,IssmDouble* x,IssmDouble* y,int n,Options* options); 31 32 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);33 33 34 34 /*Methods*/ 35 35 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); 36 37 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);38 38 void Distances(IssmPDouble* distances,IssmPDouble *x,IssmPDouble *y,int n,IssmPDouble radius); 39 39 void InterpolationIDW(IssmDouble *pprediction,IssmDouble x_interp,IssmDouble y_interp,IssmDouble radius,int mindata,int maxdata,IssmDouble power); … … 43 43 void ObservationList(IssmDouble **px,IssmDouble **py,IssmDouble **pobs,int* pnobs); 44 44 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); 45 46 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);47 47 void QuadtreeColoring(IssmDouble* A,IssmDouble *x,IssmDouble *y,int n); 48 48 void Variomap(IssmDouble* gamma,IssmDouble *x,int n); -
issm/trunk-jpl/src/c/classes/kriging/PowerVariogram.cpp
r18237 r20827 43 43 44 44 /*Object virtual functions definitions:*/ 45 Object* PowerVariogram::copy(void){/*{{{*/ 46 return new PowerVariogram(*this); 47 } 48 /*}}}*/ 45 49 void PowerVariogram::Echo(void){/*{{{*/ 46 50 _printf_("PowerVariogram\n"); … … 48 52 _printf_(" slope : " << this->slope << "\n"); 49 53 _printf_(" power : " << this->power << "\n"); 50 }51 /*}}}*/52 Object* PowerVariogram::copy(void){/*{{{*/53 return new PowerVariogram(*this);54 54 } 55 55 /*}}}*/ -
issm/trunk-jpl/src/c/classes/kriging/PowerVariogram.h
r19198 r20827 22 22 23 23 /*Object virtual functions definitions*/ 24 Object* copy(); 25 void DeepEcho(){_error_("Not implemented yet");}; 24 26 void Echo(); 25 void DeepEcho(){_error_("Not implemented yet");};26 27 int Id(){_error_("Not implemented yet");}; 28 void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ _error_("not implemented yet!"); }; 27 29 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!"); };30 30 31 31 32 32 /*Variogram functions*/ 33 double Covariance(double deltax,double deltay); 33 34 double SemiVariogram(double deltax,double deltay); 34 double Covariance(double deltax,double deltay);35 35 }; 36 36 #endif /* _POWERVARIOGRAM_H */ -
issm/trunk-jpl/src/c/classes/kriging/Quadtree.cpp
r20634 r20827 282 282 *pindex=index; 283 283 }/*}}}*/ 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 }/*}}}*/293 284 void Quadtree::DeepEcho(void){/*{{{*/ 294 285 … … 299 290 _printf_(" root = " << this->root << "\n"); 300 291 boxcontainer->Echo(); 292 293 }/*}}}*/ 294 void 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"); 301 301 302 302 }/*}}}*/ … … 391 391 return newbox; 392 392 }/*}}}*/ 393 void 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 }/*}}}*/ 393 410 void Quadtree::QuadtreeDepth(int* A,int xi,int yi){/*{{{*/ 394 411 … … 470 487 *A=level; 471 488 }/*}}}*/ 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 }/*}}}*/489 489 490 490 /*QuadtreeBox methos*/ 491 Object* 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 /*}}}*/ 491 507 void Quadtree::QuadtreeBox::Echo(void){/*{{{*/ 492 508 … … 498 514 499 515 }/*}}}*/ 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 /*}}}*/516 516 int Quadtree::QuadtreeBox::IsWithinRange(double x,double y,double range){/*{{{*/ 517 517 -
issm/trunk-jpl/src/c/classes/kriging/Quadtree.h
r19198 r20827 26 26 27 27 /*Object functions (Needed because the Quadtree uses a Container*/ 28 Object *copy(); 29 void DeepEcho() {_error_("not implemented yet"); }; 28 30 void Echo(); 29 void DeepEcho() {_error_("not implemented yet"); };30 31 int Id() {_error_("not implemented yet"); }; 32 void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ _error_("not implemented yet!");}; 31 33 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!");};34 34 35 35 -
issm/trunk-jpl/src/c/classes/kriging/SphericalVariogram.cpp
r18237 r20827 42 42 43 43 /*Object virtual functions definitions:*/ 44 Object* SphericalVariogram::copy(void){/*{{{*/ 45 return new SphericalVariogram(*this); 46 } 47 /*}}}*/ 44 48 void SphericalVariogram::Echo(void){/*{{{*/ 45 49 _printf_("SphericalVariogram\n"); … … 47 51 _printf_(" sill : " << this->sill << "\n"); 48 52 _printf_(" range : " << this->range << "\n"); 49 }50 /*}}}*/51 Object* SphericalVariogram::copy(void){/*{{{*/52 return new SphericalVariogram(*this);53 53 } 54 54 /*}}}*/ -
issm/trunk-jpl/src/c/classes/kriging/SphericalVariogram.h
r19198 r20827 22 22 23 23 /*Object virtual functions definitions*/ 24 Object* copy(); 25 void DeepEcho(){_error_("Not implemented yet");}; 24 26 void Echo(); 25 void DeepEcho(){_error_("Not implemented yet");};26 27 int Id(){_error_("Not implemented yet");}; 28 void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ _error_("not implemented yet!"); }; 27 29 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!"); };30 30 31 31 32 32 /*Variogram functions*/ 33 double Covariance(double deltax,double deltay); 33 34 double SemiVariogram(double deltax,double deltay); 34 double Covariance(double deltax,double deltay);35 35 }; 36 36 #endif /* _SPHERICALVARIOGRAM_H */ -
issm/trunk-jpl/src/c/classes/kriging/Variogram.h
r15067 r20827 12 12 public: 13 13 virtual ~Variogram(){}; 14 virtual double Covariance(double deltax,double deltay)=0; 14 15 virtual double SemiVariogram(double deltax,double deltay)=0; 15 virtual double Covariance(double deltax,double deltay)=0;16 16 17 17 }; -
issm/trunk-jpl/src/c/classes/matrix/ElementMatrix.cpp
r20669 r20827 236 236 237 237 /*ElementMatrix specific routines: */ 238 void 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 /*}}}*/ 238 271 void ElementMatrix::AddToGlobal(Matrix<IssmDouble>* Kff, Matrix<IssmDouble>* Kfs){/*{{{*/ 239 272 … … 322 355 } 323 356 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 }357 357 } 358 358 else{ … … 373 373 } 374 374 #endif 375 } 376 /*}}}*/ 377 void 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 /*}}}*/ 422 void 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 } 375 484 } 376 485 /*}}}*/ … … 516 625 } 517 626 /*}}}*/ 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 58 58 59 59 /*ElementMatrix specific routines*/ 60 void AddDiagonalToGlobal(Vector<IssmDouble>* pf); 60 61 void AddToGlobal(Matrix<IssmDouble>* Kff, Matrix<IssmDouble>* Kfs); 61 62 void AddToGlobal(Matrix<IssmDouble>* Jff); 62 void AddDiagonalToGlobal(Vector<IssmDouble>* pf);63 void CheckConsistency(void); 63 64 void Echo(void); 64 void CheckConsistency(void); 65 void Init(ElementMatrix* Ke); 66 void Lump(void); 65 67 void StaticCondensation(int numindices,int* indices); 66 void Lump(void);67 68 void Transpose(void); 68 void Init(ElementMatrix* Ke);69 69 }; 70 70 #endif //#ifndef _ELEMENT_MATRIX_H_ -
issm/trunk-jpl/src/c/classes/matrix/ElementVector.cpp
r20669 r20827 176 176 } 177 177 /*}}}*/ 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 /*}}}*/198 178 void ElementVector::CheckConsistency(void){/*{{{*/ 199 179 /*Check element matrix values, only in debugging mode*/ … … 254 234 this->fglobaldoflist=NULL; 255 235 } 236 } 237 /*}}}*/ 238 void 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 256 256 } 257 257 /*}}}*/ -
issm/trunk-jpl/src/c/classes/matrix/ElementVector.h
r15688 r20827 41 41 /*ElementVector specific routines*/ 42 42 void AddToGlobal(Vector<IssmDouble>* pf); 43 void CheckConsistency(void); 44 void Echo(void); 45 void Init(ElementVector* pe); 43 46 void InsertIntoGlobal(Vector<IssmDouble>* pf); 44 void Echo(void);45 void CheckConsistency(void);46 void Init(ElementVector* pe);47 47 void SetValue(IssmDouble scalar); 48 48 void StaticCondensation(ElementMatrix* Ke,int numindices,int* indices);
Note:
See TracChangeset
for help on using the changeset viewer.