ESyS-Particle  4.0.1
RotSubLattice.hpp
1 
2 // //
3 // Copyright (c) 2003-2011 by The University of Queensland //
4 // Earth Systems Science Computational Centre (ESSCC) //
5 // http://www.uq.edu.au/esscc //
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 
20 template <class T>
21 TRotSubLattice<T>::TRotSubLattice(const esys::lsm::CLatticeParam &prm, int rank, MPI_Comm comm, MPI_Comm worker_comm):
22  TSubLattice<T>(prm,rank,comm,worker_comm)
23 {}
24 
28 template <class T>
30 {}
31 
35 template <class T>
37 {
38  console.Debug() << "TSubLattice<T>::setParticleAngularVelocity()\n";
39  CVarMPIBuffer buffer(this->m_comm);
40 
41  buffer.receiveBroadcast(0); // get data from master
42  int id=buffer.pop_int();
43  Vec3 mv=buffer.pop_vector();
44  this->m_ppa->forParticle(id,(void (T::*)(Vec3))(&T::setAngVel),mv);
45  console.XDebug() << "end TSubLattice<T>::setParticleAngularVelocity()\n";
46 }
47 
55 template <class T>
56 bool TRotSubLattice<T>::doAddPIG(const string& name,const string& type,CVarMPIBuffer& param_buffer)
57 {
58  bool res;
59 
60  // try interactions defined in the base class
61  res=TSubLattice<T>::doAddPIG(name,type,param_buffer);
62  if(!res){ // if not successfull, try interactions defined here
63 
64  }
65  return res;
66 
67 }
68 
75 template <class T>
76 bool TRotSubLattice<T>::doAddDamping(const string& type,CVarMPIBuffer& param_buffer)
77 {
78  bool res=false;
79 
81  string damping_name;
82  if (type=="RotDamping") {
83  CDampingIGP *params=extractDampingIGP(&param_buffer);
84  console.Debug() << "add rotational damping\n";
85  DG=new ParallelInteractionStorage_Single<T,CRotDamping<T> >(this->m_ppa,*params); // dodgy
86  damping_name="RotDamping";
87  res=true;
88  // add to map
89  this->m_damping.insert(make_pair(damping_name,DG));
90  this->m_damping[damping_name]->update();
91  }
92  else if (type=="RotLocalDamping") {
93  CLocalDampingIGP *params=extractLocalDampingIGP(&param_buffer);
94  console.Debug() << "add rotational damping\n";
95  DG=new ParallelInteractionStorage_Single<T,CRotLocalDamping<T> >(this->m_ppa,*params); // dodgy
96  damping_name="RotLocalDamping";
97  res=true;
98  // add to map
99  this->m_damping.insert(make_pair(damping_name,DG));
100  this->m_damping[damping_name]->update();
101  } else {
102  res=TSubLattice<T>::doAddDamping(type,param_buffer);
103  }
104 
105  return res;
106 }
107 
112 template <class T>
114 {
115  console.XDebug() << "TSubLattice<T>::addRotBondedIG()\n";
116  CVarMPIBuffer param_buffer(this->m_comm);
117  vector<int> conns;
118 
119  // get params
120  param_buffer.receiveBroadcast(0);
121  int tag=param_buffer.pop_int();
122  string name=string(param_buffer.pop_string());
123  double kr = param_buffer.pop_double();
124  double ks = param_buffer.pop_double();
125  double kt = param_buffer.pop_double();
126  double kb = param_buffer.pop_double();
127  double max_nForce = param_buffer.pop_double();
128  double max_shForce = param_buffer.pop_double();
129  double max_tMoment = param_buffer.pop_double();
130  double max_bMoment = param_buffer.pop_double();
131  bool scaling = static_cast<bool>(param_buffer.pop_int());
132 
133  conns = TSubLattice<T>::m_temp_conn[tag];
134 
135  console.XDebug()
136  << "Got RotBondedIG parameters: tag=" << tag
137  << ", name=" << name.c_str()
138  << ", kr=" << kr
139  << ", ks=" << ks
140  << ", kt=" << kt
141  << ", kb=" << kb
142  << ", nFrc=" << max_nForce
143  << ", sFrc=" << max_shForce
144  << ", tMom=" << max_tMoment
145  << ", bMom=" << max_bMoment
146  << ", scaling=" << scaling
147  << "\n";
148  // setup InteractionGroup
149  CRotBondedIGP param;
150  param.tag=tag;
151  param.kr=kr;
152  param.ks=ks;
153  param.kt=kt;
154  param.kb=kb;
155  param.max_nForce = max_nForce ;
156  param.max_shForce = max_shForce ;
157  param.max_tMoment = max_tMoment ;
158  param.max_bMoment = max_bMoment ;
159  param.scaling = scaling;
162 
163  // recv broadcast connection data
164  // console.XDebug() << "rank=" << this->m_tml_comm.rank() << "TSubLattice<T>::addRotBondedIG(): receiving conn_data.\n";
165  // vector<int> conn_data;
166  // this->m_tml_comm.recv_broadcast_cont(conn_data,0);
167  // console.XDebug() << "rank=" <<this->m_tml_comm.rank() << "TSubLattice<T>::addRotBondedIG(): conn_data.size()=" << conn_data.size() << "\n";
168  vector<int> vi(2,-1);
169  for(size_t i=0;i<conns.size();i+=2){
170  vi[0] = (conns[i]);
171  vi[1] = (conns[i+1]);
172  B_PIS->tryInsert(vi);
173  }
174 
175  // add InteractionGroup to map
176  this->m_bpis.insert(make_pair(name,B_PIS));
177 
178  console.XDebug() << "end TSubLattice<T>::addRotBondedIG()\n";
179 }
180 
185 template <class T>
187 {
188  console.XDebug() << "TRotSubLattice<T>::addRotThermBondedIG()\n";
189  CVarMPIBuffer param_buffer(this->m_comm);
190  vector<int> conns;
191 
192  // get params
193  param_buffer.receiveBroadcast(0);
194  int tag=param_buffer.pop_int();
195  string name=string(param_buffer.pop_string());
196  double kr = param_buffer.pop_double();
197  double ks = param_buffer.pop_double();
198  double kt = param_buffer.pop_double();
199  double kb = param_buffer.pop_double();
200  double max_nForce = param_buffer.pop_double();
201  double max_shForce = param_buffer.pop_double();
202  double max_tMoment = param_buffer.pop_double();
203  double max_bMoment = param_buffer.pop_double();
204  double diffusivity = param_buffer.pop_double();
205 
206  conns = TSubLattice<T>::m_temp_conn[tag];
207 
208  console.XDebug()
209  << "Got RotThermBondedIG parameters: tag=" << tag
210  << ", name=" << name.c_str()
211  << ", kr=" << kr
212  << ", ks=" << ks
213  << ", kt=" << kt
214  << ", kb=" << kb
215  << ", nFrc=" << max_nForce
216  << ", sFrc=" << max_shForce
217  << ", tMom=" << max_tMoment
218  << ", bMom=" << max_bMoment
219  << ", diffusivity=" << diffusivity
220  << "\n";
221  // setup InteractionGroup
222  CRotThermBondedIGP param;
223  param.tag = tag;
224  param.kr=kr;
225  param.ks=ks;
226  param.kt=kt;
227  param.kb=kb;
228  param.max_nForce = max_nForce ;
229  param.max_shForce = max_shForce ;
230  param.max_tMoment = max_tMoment ;
231  param.max_bMoment = max_bMoment ;
232  param.diffusivity = diffusivity ;
235 
236  // recv broadcast connection data
237  // console.XDebug() << "rank=" << this->m_tml_comm.rank() << "TSubLattice<T>::addRotThermBondedIG(): receiving conn_data.\n";
238  // vector<int> conn_data;
239  // this->m_tml_comm.recv_broadcast_cont(conn_data,0);
240  // console.XDebug() << "rank=" <<this->m_tml_comm.rank() << "TSubLattice<T>::addRotThermBondedIG(): conn_data.size()=" << conn_data.size() << "\n";
241  vector<int> vi(2,-1);
242  for(size_t i=0;i<conns.size();i+=2){
243  vi[0] = (conns[i]);
244  vi[1] = (conns[i+1]);
245  B_PIS->tryInsert(vi);
246  }
247 
248  // add InteractionGroup to map
249  this->m_bpis.insert(make_pair(name,B_PIS));
250 
251  console.XDebug() << "end TRotSubLattice<T>::addRotThermBondedIG()\n";
252 }