~esys-p-dev/esys-particle/esys-darcy

« back to all changes in this revision

Viewing changes to Fields/ScalarFluidFieldSlave.hpp

  • Committer: Qi Shao
  • Date: 2017-08-22 01:18:11 UTC
  • mfrom: (1179.1.4 ESyS-Darcy_clean)
  • Revision ID: q.shao@uq.edu.au-20170822011811-aq63qj2swi99l7w4
Added fluid phase and its forces on solid particles. Flows of fluid are calculated according to the Darcy's Law. The coupling of fluid and DEM is based on the poro-elastic theory.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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.apache.org/licenses/LICENSE-2.0          //
 
10
//                                                         //
 
11
/////////////////////////////////////////////////////////////
 
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
 
 
26
/*!
 
27
  constructor
 
28
 
 
29
  \param comm the TML communicator used for sending the data back to the master
 
30
  \param ppa a pointer to the particle array
 
31
  \param rdf the fluid cell member function to access the data
 
32
*/
 
33
template <typename T>
 
34
ScalarFluidFieldSlave<T>::ScalarFluidFieldSlave(TML_Comm* comm,ParallelParticleArray<T>* ppa,CFluidCell::ScalarFieldFunction rdf):AFieldSlave(comm)
 
35
{
 
36
  m_ppa=ppa;
 
37
  m_rdf=rdf;
 
38
}
 
39
 
 
40
 
 
41
 
 
42
/*!
 
43
  send full field data and position of the fluid cells
 
44
*/
 
45
template <typename T>
 
46
void ScalarFluidFieldSlave<T>::SendDataFull()
 
47
{
 
48
  vector<pair<Vec3,double> > data_vec;
 
49
 
 
50
  data_vec=m_ppa->forAllInnerCellsGet(m_rdf);
 
51
 
 
52
  // send data to master
 
53
  m_comm->send_gather(data_vec,0);
 
54
}
 
55
 
 
56
/*!
 
57
  send sum only
 
58
*/
 
59
template <typename T>
 
60
void ScalarFluidFieldSlave<T>::SendDataSum()
 
61
{
 
62
  vector<double> data_vec;
 
63
 
 
64
  // get data from particles
 
65
  data_vec=m_ppa->forAllInnerCellsGetSum(m_rdf);
 
66
 
 
67
  // sum data
 
68
  double sum=0.0;
 
69
  for(vector<double>::iterator iter=data_vec.begin();
 
70
      iter!=data_vec.end();
 
71
      iter++){
 
72
    sum+=*iter;
 
73
  }
 
74
 
 
75
  vector<double> sum_vec;
 
76
  sum_vec.push_back(sum);
 
77
  m_comm->send_gather(sum_vec,0);
 
78
}
 
79
 
 
80
 
 
81
/*!
 
82
  send maximum only
 
83
*/
 
84
template <typename T>
 
85
void ScalarFluidFieldSlave<T>::SendDataMax()
 
86
{
 
87
  vector<double> data_vec;
 
88
 
 
89
  // get data from particles
 
90
  data_vec=m_ppa->forAllInnerCellsGetSum(m_rdf);
 
91
 
 
92
  // sum data
 
93
  double max=*(data_vec.begin());
 
94
  for(vector<double>::iterator iter=data_vec.begin();
 
95
      iter!=data_vec.end();
 
96
      iter++){
 
97
    max=(*iter > max) ? *iter : max;
 
98
  }
 
99
 
 
100
  vector<double> max_vec;
 
101
  max_vec.push_back(max);
 
102
  m_comm->send_gather(max_vec,0);
 
103
}
 
104
 
 
105
 
 
106
/*!
 
107
  send data back to master
 
108
*/
 
109
template <typename T>
 
110
void ScalarFluidFieldSlave<T>::sendData()
 
111
{
 
112
  int coll_type;
 
113
  m_comm->recv_broadcast(coll_type,0);
 
114
 
 
115
  switch(coll_type){
 
116
  case 1: SendDataFull();break;
 
117
  case 2: SendDataSum();break;
 
118
  case 3: SendDataMax();break;
 
119
  default: std::cerr << "unknown collection type" << std::endl;
 
120
  }
 
121
}