Changeset 22758 for issm/trunk/src/c/classes/Inputs/TetraInput.cpp
- Timestamp:
- 05/10/18 10:24:27 (7 years ago)
- Location:
- issm/trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk
- Property svn:mergeinfo changed
-
issm/trunk/src
- Property svn:mergeinfo changed
-
issm/trunk/src/c
- Property svn:ignore
-
old new 20 20 kriging 21 21 issm_slr 22 issm_ocean 23 lnb_param.mod 24 lovenb_sub.mod 25 model.mod 26 util.mod
-
- Property svn:ignore
-
issm/trunk/src/c/classes/Inputs/TetraInput.cpp
r21341 r22758 238 238 } 239 239 /*}}}*/ 240 void TetraInput::Constrain(IssmDouble cm_min, IssmDouble cm_max){/*{{{*/241 242 int i;243 const int numnodes=this->NumberofNodes(this->interpolation_type);244 245 if(!xIsNan<IssmDouble>(cm_min)) for(i=0;i<numnodes;i++)if (this->values[i]<cm_min)this->values[i]=cm_min;246 if(!xIsNan<IssmDouble>(cm_max)) for(i=0;i<numnodes;i++)if (this->values[i]>cm_max)this->values[i]=cm_max;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;254 }255 /*}}}*/256 240 void TetraInput::GetVectorFromInputs(Vector<IssmDouble>* vector,int* doflist){/*{{{*/ 257 241 const int numvertices=4; 258 242 vector->SetValues(numvertices,doflist,this->values,INS_VAL); 259 243 } /*}}}*/ 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 244 IssmDouble TetraInput::MinAbs(void){/*{{{*/ 271 245 … … 312 286 } 313 287 /*}}}*/ 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 /*}}}*/377 Input* TetraInput::PointwiseMin(Input* inputB){/*{{{*/378 379 /*Ouput*/380 TetraInput* outinput=NULL;381 382 /*Intermediaries*/383 int i;384 TetraInput *xinputB = NULL;385 const int numnodes = this->NumberofNodes(this->interpolation_type);386 IssmDouble *minvalues = xNew<IssmDouble>(numnodes);387 388 /*Check that inputB is of the same type*/389 if(inputB->ObjectEnum()!=TetraInputEnum) _error_("Operation not permitted because inputB is of type " << EnumToStringx(inputB->ObjectEnum()));390 xinputB=(TetraInput*)inputB;391 if(xinputB->interpolation_type!=this->interpolation_type) _error_("Operation not permitted because inputB is of type " << EnumToStringx(xinputB->interpolation_type));392 393 /*Create point wise min*/394 for(i=0;i<numnodes;i++){395 if(this->values[i] > xinputB->values[i]) minvalues[i]=xinputB->values[i];396 else minvalues[i]=this->values[i];397 }398 399 /*Create new Tetra vertex input (copy of current input)*/400 outinput=new TetraInput(this->enum_type,&minvalues[0],this->interpolation_type);401 402 /*Return output pointer*/403 xDelete<IssmDouble>(minvalues);404 return outinput;405 406 }407 /*}}}*/408 288 void TetraInput::Scale(IssmDouble scale_factor){/*{{{*/ 409 289 … … 418 298 } 419 299 /*}}}*/ 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.