Changeset 27703
- Timestamp:
- 04/24/23 08:10:27 (2 years ago)
- Location:
- issm/trunk-jpl/src/c/classes/Inputs
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/c/classes/Inputs/ControlInput.cpp
r26468 r27703 227 227 } 228 228 /*}}}*/ 229 void ControlInput::AverageAndReplace(void){/*{{{*/ 230 this->values->AverageAndReplace(); 231 } 232 /*}}}*/ 229 233 TriaInput* ControlInput::GetTriaInput(){/*{{{*/ 230 234 -
issm/trunk-jpl/src/c/classes/Inputs/ControlInput.h
r25508 r27703 48 48 TriaInput* GetTriaInput(); 49 49 PentaInput* GetPentaInput(); 50 void AverageAndReplace(void); 50 51 }; 51 52 #endif /* _CONTROLINPUT_H */ -
issm/trunk-jpl/src/c/classes/Inputs/TriaInput.cpp
r27691 r27703 408 408 void TriaInput::AverageAndReplace(void){/*{{{*/ 409 409 410 if(this->M!=this->numberofelements_local) _error_("not implemented for P1"); 411 410 412 /*Get local sum and local size*/ 411 413 IssmDouble sum = 0.; 414 int weight; 412 415 for(int i=0;i<this->M*this->N;i++) sum += this->values[i]; 413 sum = sum/(this->M*this->N);416 weight = this->M*this->N; 414 417 415 418 /*Get sum across all procs*/ 416 419 IssmDouble all_sum; 420 int all_weight; 417 421 ISSM_MPI_Allreduce((void*)&sum,(void*)&all_sum,1,ISSM_MPI_DOUBLE,ISSM_MPI_SUM,IssmComm::GetComm()); 422 ISSM_MPI_Allreduce((void*)&weight,(void*)&all_weight,1,ISSM_MPI_INT,ISSM_MPI_SUM,IssmComm::GetComm()); 418 423 419 424 /*Divide by number of procs*/ 420 int num_procs = IssmComm::GetSize(); 421 IssmDouble newvalue = all_sum/num_procs; 425 IssmDouble newvalue = all_sum/reCast<IssmPDouble>(all_weight); 422 426 423 427 /*Now replace existing input*/
Note:
See TracChangeset
for help on using the changeset viewer.