Changeset 20827 for issm/trunk-jpl/src/c/classes/Inputs/TetraInput.cpp
- Timestamp:
- 06/28/16 15:51:32 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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 /*}}}*/
Note:
See TracChangeset
for help on using the changeset viewer.