ESyS-Particle  2.3.2
CheckedScalarInteractionFieldSlave.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 using std::make_pair;
20 
21 // -- IO includes --
22 #include <iostream>
23 
24 using std::cout;
25 using std::endl;
26 using std::cerr;
27 
28 // --- project includes ---
29 #include "Foundation/triplet.h"
30 #include "Foundation/console.h"
31 
32 using esys::lsm::triplet;
33 
41 template <typename T>
43 {
44  this->m_rdf=rdf;
45 }
46 
52 template <typename T>
54 {
55  vector<pair<Vec3,pair<bool,double> > > raw_data; // position, [valid ?, data]
56  vector<pair<Vec3,double> > data; // position, data
57 
58  // get raw data
59  raw_data=this->m_pis->forAllInnerInteractionsGetWithPos(this->m_rdf);
60 
61  // filter data
62  for(vector<pair<Vec3,pair<bool,double> > >::iterator iter=raw_data.begin();
63  iter!=raw_data.end();
64  iter++){
65  if(iter->second.first){
66  data.push_back(make_pair(iter->first,iter->second.second));
67  }
68  }
69 
70  // send data to master
71  this->m_comm->send_gather(data,0);
72 }
73 
79 template <typename T>
81 {
82  vector<pair<esys::lsm::quintuple<Vec3,double,Vec3,double,Vec3>,pair<bool,double> > > raw_data;
83  vector<pair<esys::lsm::quintuple<Vec3,double,Vec3,double,Vec3>,double> > data;
84 
85  // get raw data
86  raw_data=this->m_pis->forAllInnerInteractionsGetRaw2(this->m_rdf);
87 
88  // filter data
89  for(vector<pair<esys::lsm::quintuple<Vec3,double,Vec3,double,Vec3>,pair<bool,double> > >::iterator iter=raw_data.begin();
90  iter!=raw_data.end();
91  iter++){
92  if(iter->second.first){
93  data.push_back(make_pair(iter->first,iter->second.second));
94  }
95  }
96 
97  // send data to master
98  this->m_comm->send_gather(data,0);
99 }
100 
101 
102 
106 template <typename T>
108 {
109  vector<pair<bool,double> > data_vec;
110 
111  // get data from interactions
112  this->m_pis->forAllInnerInteractionsGet(data_vec,this->m_rdf);
113 
114  // sum data
115  double sum=0.0;
116  for(vector<pair<bool,double> >::iterator iter=data_vec.begin();
117  iter!=data_vec.end();
118  iter++){
119  if(iter->first) sum+=iter->second;
120  }
121 
122  vector<double> sum_vec;
123  sum_vec.push_back(sum);
124  this->m_comm->send_gather(sum_vec,0);
125 }
126 
130 template <typename T>
132 {
133  vector<pair<bool,double> > data_vec;
134 
135  // get data from interactions
136  this->m_pis->forAllInnerInteractionsGet(data_vec,this->m_rdf);
137 
138  // sum data
139  double max;
140  bool is_set=false;
141  for(vector<pair<bool,double> >::iterator iter=data_vec.begin();
142  iter!=data_vec.end();
143  iter++){
144  if(iter->first) {
145  if(is_set){
146  max=(iter->second > max) ? iter->second : max;
147  } else {
148  max=iter->second;
149  is_set=true;
150  }
151  }
152  }
153 
154  vector<double> max_vec;
155  max_vec.push_back(max);
156  this->m_comm->send_gather(max_vec,0);
157 }
158 
162 template <typename T>
164 {
165  vector<pair<triplet<int,int,Vec3>, pair<bool,double> > > raw_data;
166  vector<pair<triplet<int,int,Vec3>, double> > data;
167 
168  // get raw data
169  raw_data=this->m_pis->forAllInnerInteractionsGetDataWithID(this->m_rdf);
170 
171  console.XDebug() << "got " << raw_data.size() << " raw data\n";
172 
173  // filter data
174  for(vector<pair<triplet<int,int,Vec3>, pair<bool,double> > >::iterator iter=raw_data.begin();
175  iter!=raw_data.end();
176  iter++){
177  if(iter->second.first){
178  data.push_back(make_pair(iter->first,iter->second.second));
179  }
180  }
181 
182  console.XDebug() << "got " << data.size() << " filtered data\n";
183 
184  // send data to master
185  this->m_comm->send_gather(data,0);
186 }