Changeset 27703
- Timestamp:
- 04/24/23 08:10:27 (3 years ago)
- Location:
- issm/trunk-jpl/src/c/classes/Inputs
- Files:
- 
      - 3 edited
 
 - 
          
  ControlInput.cpp (modified) (1 diff)
- 
          
  ControlInput.h (modified) (1 diff)
- 
          
  TriaInput.cpp (modified) (1 diff)
 
Legend:
- Unmodified
- Added
- Removed
- 
      issm/trunk-jpl/src/c/classes/Inputs/ControlInput.cppr26468 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.hr25508 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.cppr27691 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.
  ![(please configure the [header_logo] section in trac.ini)](/trac/issm/chrome/common/trac_banner.png)
