Changeset 27691
- Timestamp:
- 04/13/23 19:29:17 (2 years ago)
- Location:
- issm/trunk-jpl/src/c/classes/Inputs
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/c/classes/Inputs/Input.h
r26121 r27691 48 48 virtual void Pow(IssmDouble scale_factor){_error_("Not implemented yet");}; 49 49 virtual void Scale(IssmDouble scale_factor){_error_("Not implemented yet");}; 50 virtual void AverageAndReplace(void){_error_("Not implemented yet");}; 50 51 51 52 virtual int GetResultArraySize(void){_error_("Not implemented yet");}; -
issm/trunk-jpl/src/c/classes/Inputs/Inputs.cpp
r27128 r27691 302 302 } 303 303 /*}}}*/ 304 void 304 void Inputs::Shift(int xenum, IssmDouble alpha){/*{{{*/ 305 305 306 306 _assert_(this); … … 314 314 /*Shift: */ 315 315 this->inputs[index_x]->Shift(alpha); 316 } 317 /*}}}*/ 318 void Inputs::AverageAndReplace(int inputenum){/*{{{*/ 319 320 _assert_(this); 321 322 /*Get indices from enums*/ 323 int index = EnumToIndex(inputenum); 324 if(!this->inputs[index]) _error_("Input "<<EnumToStringx(inputenum)<<" not found"); 325 326 this->inputs[index]->AverageAndReplace(); 316 327 } 317 328 /*}}}*/ -
issm/trunk-jpl/src/c/classes/Inputs/Inputs.h
r27128 r27691 50 50 void AXPY(IssmDouble alpha, int xenum, int yenum); 51 51 void Shift(int inputenum, IssmDouble alpha); 52 void AverageAndReplace(int inputenum); 52 53 void DeepEcho(void); 53 54 void DeepEcho(int enum_in); -
issm/trunk-jpl/src/c/classes/Inputs/TriaInput.cpp
r26121 r27691 406 406 } 407 407 /*}}}*/ 408 void TriaInput::AverageAndReplace(void){/*{{{*/ 409 410 /*Get local sum and local size*/ 411 IssmDouble sum = 0.; 412 for(int i=0;i<this->M*this->N;i++) sum += this->values[i]; 413 sum = sum/(this->M*this->N); 414 415 /*Get sum across all procs*/ 416 IssmDouble all_sum; 417 ISSM_MPI_Allreduce((void*)&sum,(void*)&all_sum,1,ISSM_MPI_DOUBLE,ISSM_MPI_SUM,IssmComm::GetComm()); 418 419 /*Divide by number of procs*/ 420 int num_procs = IssmComm::GetSize(); 421 IssmDouble newvalue = all_sum/num_procs; 422 423 /*Now replace existing input*/ 424 this->Reset(P0Enum); 425 for(int i=0;i<this->M*this->N;i++) this->values[i] = newvalue; 426 } 427 /*}}}*/ 408 428 409 429 /*Object functions*/ -
issm/trunk-jpl/src/c/classes/Inputs/TriaInput.h
r26121 r27691 41 41 void AXPY(Input* xinput,IssmDouble scalar); 42 42 void Shift(IssmDouble scalar); 43 void AverageAndReplace(void); 43 44 void PointWiseMult(Input* xinput); 44 45 void Serve(int numindices,int* indices);
Note:
See TracChangeset
for help on using the changeset viewer.