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 00026 #include "Foundation/quadtuple.h" 00027 #include "pis/pi_storage.h" 00028 00036 template <typename T> 00037 ScalarInteractionFieldSlave<T>::ScalarInteractionFieldSlave(TML_Comm* comm,TParallelInteractionStorage<T>* pis,typename T::ScalarFieldFunction rdf):InteractionFieldSlave<T>(comm,pis) 00038 { 00039 m_rdf=rdf; 00040 } 00041 00045 template <typename T> 00046 void ScalarInteractionFieldSlave<T>::SendDataFull() 00047 { 00048 vector<pair<Vec3,double> > data; 00049 00050 data=this->m_pis->forAllInnerInteractionsGetWithPos(m_rdf); 00051 00052 // send data to master 00053 this->m_comm->send_gather(data,0); 00054 } 00055 00059 template <typename T> 00060 void ScalarInteractionFieldSlave<T>::SendDataFull2() 00061 { 00062 vector<pair<esys::lsm::quintuple<Vec3,double,Vec3,double,Vec3>,double> > data; 00063 00064 data=this->m_pis->forAllInnerInteractionsGetRaw2(m_rdf); 00065 00066 // send data to master 00067 this->m_comm->send_gather(data,0); 00068 } 00069 00073 template <typename T> 00074 void ScalarInteractionFieldSlave<T>::SendDataSum() 00075 { 00076 vector<double> data_vec; 00077 00078 // get data from interactions 00079 this->m_pis->forAllInnerInteractionsGet(data_vec,m_rdf); 00080 00081 // sum data 00082 double sum=0.0; 00083 for(vector<double>::iterator iter=data_vec.begin(); 00084 iter!=data_vec.end(); 00085 iter++){ 00086 sum+=*iter; 00087 } 00088 00089 vector<double> sum_vec; 00090 sum_vec.push_back(sum); 00091 this->m_comm->send_gather(sum_vec,0); 00092 } 00093 00097 template <typename T> 00098 void ScalarInteractionFieldSlave<T>::SendDataWithID() 00099 { 00100 vector<pair<esys::lsm::triplet<int,int,Vec3>, double> > data; 00101 00102 // debug output 00103 console.XDebug() << "ScalarInteractionFieldSlave<T>::SendDataWithID()\n"; 00104 00105 data=this->m_pis->forAllInnerInteractionsGetDataWithID(m_rdf); 00106 00107 // debug output 00108 console.XDebug() << "sending " << data.size() << " data\n"; 00109 00110 // send data to master 00111 this->m_comm->send_gather(data,0); 00112 } 00113 00114 00118 template <typename T> 00119 void ScalarInteractionFieldSlave<T>::SendDataMax() 00120 { 00121 vector<double> data_vec; 00122 00123 // get data from interactions 00124 this->m_pis->forAllInnerInteractionsGet(data_vec,m_rdf); 00125 00126 // sum data 00127 double max=*(data_vec.begin()); 00128 for(vector<double>::iterator iter=data_vec.begin(); 00129 iter!=data_vec.end(); 00130 iter++){ 00131 max=(*iter > max) ? *iter : max; 00132 } 00133 00134 vector<double> max_vec; 00135 max_vec.push_back(max); 00136 this->m_comm->send_gather(max_vec,0); 00137 }