ESyS-Particle  2.3.2
ScalarInteractionFieldSlaveTagged.hpp
Go to the documentation of this file.
1 
2 // //
3 // Copyright (c) 2003-2014 by The University of Queensland //
4 // Centre for Geoscience Computing //
5 // http://earth.uq.edu.au/centre-geoscience-computing //
6 // //
7 // Primary Business: Brisbane, Queensland, Australia //
8 // Licensed under the Open Software License version 3.0 //
9 // http://www.opensource.org/licenses/osl-3.0.php //
10 // //
12 
13 //-- STL includes --
14 #include <vector>
15 #include <utility>
16 
17 using std::vector;
18 using std::pair;
19 
20 // -- IO includes --
21 #include <iostream>
22 
23 using std::cout;
24 using std::endl;
25 
33 template <typename T>
35 {
36  m_tag=tag;
37  m_mask=mask;
38 }
39 
43 template <typename T>
45 {
46  vector<pair<Vec3,double> > data;
47 
48  // get data
49  data=this->m_pis->forAllTaggedInnerInteractionsGetWithPos(this->m_rdf,m_tag,m_mask);
50 
51  // send data to master
52  this->m_comm->send_gather(data,0);
53 }
54 
58 template <typename T>
60 {
61  vector<double> data_vec;
62 
63  // get data from interactions
64  this->m_pis->forAllTaggedInnerInteractionsGet(data_vec,this->m_rdf,m_tag,m_mask);
65 
66  // sum data
67  double sum=0.0;
68  for(vector<double>::iterator iter=data_vec.begin();
69  iter!=data_vec.end();
70  iter++){
71  sum+=*iter;
72  }
73 
74  vector<double> sum_vec;
75  sum_vec.push_back(sum);
76  this->m_comm->send_gather(sum_vec,0);
77 }
78 
79 
83 template <typename T>
85 {
86  vector<double> data_vec;
87 
88  // get data from interactions
89  this->m_pis->forAllTaggedInnerInteractionsGet(data_vec,this->m_rdf,m_tag,m_mask);
90 
91  // sum data
92  double max=*(data_vec.begin());
93  for(vector<double>::iterator iter=data_vec.begin();
94  iter!=data_vec.end();
95  iter++){
96  max=(*iter > max) ? *iter : max;
97  }
98 
99  vector<double> max_vec;
100  max_vec.push_back(max);
101  this->m_comm->send_gather(max_vec,0);
102 }
103 
104