1
/////////////////////////////////////////////////////////////
3
// Copyright (c) 2003-2014 by The University of Queensland //
4
// Centre for Geoscience Computing //
5
// http://earth.uq.edu.au/centre-geoscience-computing //
7
// Primary Business: Brisbane, Queensland, Australia //
8
// Licensed under the Open Software License version 3.0 //
9
// http://www.apache.org/licenses/LICENSE-2.0 //
11
/////////////////////////////////////////////////////////////
26
#include "Foundation/triplet.h"
27
#include "pis/pi_storage_f.h"
32
\param comm the TML communicator used for sending the data back to the master
33
\param pis a pointer to the fluid interaction storage
34
\param rdf the fluid interaction member function to access the data
37
ScalarFluidInteractionFieldSlave<T>::ScalarFluidInteractionFieldSlave(TML_Comm* comm,ParallelInteractionStorage_F<T>* pis,CFluidInteraction::ScalarFieldFunction rdf):AFieldSlave(comm)
44
Send data back to master. Determine the type of data (full/sum) to send back from
45
the received coll_type and call the according send function.
48
void ScalarFluidInteractionFieldSlave<T>::sendData()
51
console.XDebug() << "InteractionFieldSlave<T>::sendData()\n";
54
m_comm->recv_broadcast(coll_type,0);
57
console.XDebug() << "received coll_type=" << coll_type << "\n";
60
case COLL_TYPE_FULL_WITH_POS : SendDataWithPos();break;
61
case COLL_TYPE_FULL_WITH_ID : SendDataWithID();break;
62
case COLL_TYPE_FULL_WITH_ID_POS : SendDataWithIDPos();break;
63
case COLL_TYPE_FULL_WITH_PARTICLE : SendDataWithParticle();break;
64
case COLL_TYPE_SUM : SendDataSum();break;
65
case COLL_TYPE_MAX : SendDataMax();break;
67
default: std::cerr << "unknown collection type" << std::endl;
73
send full field data and position of the interaction
76
void ScalarFluidInteractionFieldSlave<T>::SendDataWithPos()
78
vector<pair<Vec3,double> > data;
80
data=this->m_pis->forAllInnerInteractionsGetDataWithPos(m_rdf);
82
// send data to master
83
this->m_comm->send_gather(data,0);
87
send full field data and id of the particle
90
void ScalarFluidInteractionFieldSlave<T>::SendDataWithID()
92
vector<pair<int,double> > data;
94
data=this->m_pis->forAllInnerInteractionsGetDataWithID(m_rdf);
96
// send data to master
97
this->m_comm->send_gather(data,0);
102
send full field data and id, position of the particle
104
template <typename T>
105
void ScalarFluidInteractionFieldSlave<T>::SendDataWithIDPos()
107
vector<pair<pair<int,Vec3>,double> > data;
109
data=this->m_pis->forAllInnerInteractionsGetDataWithIDPos(m_rdf);
111
// send data to master
112
this->m_comm->send_gather(data,0);
116
send full field data and id, position and radius of the particle
118
template <typename T>
119
void ScalarFluidInteractionFieldSlave<T>::SendDataWithParticle()
121
vector<pair<esys::lsm::triplet<int,Vec3,double>,double> > data;
123
data=this->m_pis->forAllInnerInteractionsGetDataWithParticle(m_rdf);
125
// send data to master
126
this->m_comm->send_gather(data,0);
132
template <typename T>
133
void ScalarFluidInteractionFieldSlave<T>::SendDataSum()
135
vector<double> data_vec;
137
// get data from interactions
138
this->m_pis->forAllInnerInteractionsGet(data_vec,m_rdf);
142
for(vector<double>::iterator iter=data_vec.begin();
143
iter!=data_vec.end();
148
vector<double> sum_vec;
149
sum_vec.push_back(sum);
150
this->m_comm->send_gather(sum_vec,0);
157
template <typename T>
158
void ScalarFluidInteractionFieldSlave<T>::SendDataMax()
160
vector<double> data_vec;
162
// get data from interactions
163
this->m_pis->forAllInnerInteractionsGet(data_vec,m_rdf);
166
double max=*(data_vec.begin());
167
for(vector<double>::iterator iter=data_vec.begin();
168
iter!=data_vec.end();
170
max=(*iter > max) ? *iter : max;
173
vector<double> max_vec;
174
max_vec.push_back(max);
175
this->m_comm->send_gather(max_vec,0);