ESyS-Particle
4.0.1
|
00001 00002 // // 00003 // Copyright (c) 2003-2011 by The University of Queensland // 00004 // Earth Systems Science Computational Centre (ESSCC) // 00005 // http://www.uq.edu.au/esscc // 00006 // // 00007 // Primary Business: Brisbane, Queensland, Australia // 00008 // Licensed under the Open Software License version 3.0 // 00009 // http://www.opensource.org/licenses/osl-3.0.php // 00010 // // 00012 00013 //-- STL includes -- 00014 #include <vector> 00015 #include <utility> 00016 00017 using std::vector; 00018 using std::pair; 00019 00020 // -- IO includes -- 00021 #include <iostream> 00022 00023 using std::cout; 00024 using std::endl; 00025 00033 template <typename T> 00034 ScalarInteractionFieldSlaveTagged<T>::ScalarInteractionFieldSlaveTagged(TML_Comm* comm,TParallelInteractionStorage<T>* pis,typename T::ScalarFieldFunction rdf,int tag,int mask):ScalarInteractionFieldSlave<T>(comm,pis,rdf) 00035 { 00036 m_tag=tag; 00037 m_mask=mask; 00038 } 00039 00043 template <typename T> 00044 void ScalarInteractionFieldSlaveTagged<T>::SendDataFull() 00045 { 00046 vector<pair<Vec3,double> > data; 00047 00048 // get data 00049 data=this->m_pis->forAllTaggedInnerInteractionsGetWithPos(this->m_rdf,m_tag,m_mask); 00050 00051 // send data to master 00052 this->m_comm->send_gather(data,0); 00053 } 00054 00058 template <typename T> 00059 void ScalarInteractionFieldSlaveTagged<T>::SendDataSum() 00060 { 00061 vector<double> data_vec; 00062 00063 // get data from interactions 00064 this->m_pis->forAllTaggedInnerInteractionsGet(data_vec,this->m_rdf,m_tag,m_mask); 00065 00066 // sum data 00067 double sum=0.0; 00068 for(vector<double>::iterator iter=data_vec.begin(); 00069 iter!=data_vec.end(); 00070 iter++){ 00071 sum+=*iter; 00072 } 00073 00074 vector<double> sum_vec; 00075 sum_vec.push_back(sum); 00076 this->m_comm->send_gather(sum_vec,0); 00077 } 00078 00079 00083 template <typename T> 00084 void ScalarInteractionFieldSlaveTagged<T>::SendDataMax() 00085 { 00086 vector<double> data_vec; 00087 00088 // get data from interactions 00089 this->m_pis->forAllTaggedInnerInteractionsGet(data_vec,this->m_rdf,m_tag,m_mask); 00090 00091 // sum data 00092 double max=*(data_vec.begin()); 00093 for(vector<double>::iterator iter=data_vec.begin(); 00094 iter!=data_vec.end(); 00095 iter++){ 00096 max=(*iter > max) ? *iter : max; 00097 } 00098 00099 vector<double> max_vec; 00100 max_vec.push_back(max); 00101 this->m_comm->send_gather(max_vec,0); 00102 } 00103 00104