ESyS-Particle  2.3.4
RotSubLattice.hpp
Go to the documentation of this file.
1 // //
3 // Copyright (c) 2003-2017 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 // //
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,bool tagged)
57 {
58  bool res;
59 
60  // try interactions defined in the base class
61  res=TSubLattice<T>::doAddPIG(name,type,param_buffer,tagged);
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  bool meanR_scaling = static_cast<bool>(param_buffer.pop_int());
133  double truncated = param_buffer.pop_double();
134 
135  conns = TSubLattice<T>::m_temp_conn[tag];
136 
137  console.XDebug()
138  << "Got RotBondedIG parameters: tag=" << tag
139  << ", name=" << name.c_str()
140  << ", kr=" << kr
141  << ", ks=" << ks
142  << ", kt=" << kt
143  << ", kb=" << kb
144  << ", nFrc=" << max_nForce
145  << ", sFrc=" << max_shForce
146  << ", tMom=" << max_tMoment
147  << ", bMom=" << max_bMoment
148  << ", scaling=" << scaling
149  << "\n";
150  // setup InteractionGroup
151  CRotBondedIGP param;
152  param.tag=tag;
153  param.kr=kr;
154  param.ks=ks;
155  param.kt=kt;
156  param.kb=kb;
157  param.max_nForce = max_nForce ;
158  param.max_shForce = max_shForce ;
159  param.max_tMoment = max_tMoment ;
160  param.max_bMoment = max_bMoment ;
161  param.scaling = scaling;
162  param.meanR_scaling = meanR_scaling;
163  param.truncated = truncated;
166 
167  // recv broadcast connection data
168  // console.XDebug() << "rank=" << this->m_tml_comm.rank() << "TSubLattice<T>::addRotBondedIG(): receiving conn_data.\n";
169  // vector<int> conn_data;
170  // this->m_tml_comm.recv_broadcast_cont(conn_data,0);
171  // console.XDebug() << "rank=" <<this->m_tml_comm.rank() << "TSubLattice<T>::addRotBondedIG(): conn_data.size()=" << conn_data.size() << "\n";
172  vector<int> vi(2,-1);
173  for(size_t i=0;i<conns.size();i+=2){
174  vi[0] = (conns[i]);
175  vi[1] = (conns[i+1]);
176  B_PIS->tryInsert(vi);
177  }
178 
179  // add InteractionGroup to map
180  this->m_bpis.insert(make_pair(name,B_PIS));
181 
182  console.XDebug() << "end TSubLattice<T>::addRotBondedIG()\n";
183 }
184 
189 template <class T>
191 {
192  console.XDebug() << "TRotSubLattice<T>::addRotThermBondedIG()\n";
193  CVarMPIBuffer param_buffer(this->m_comm);
194  vector<int> conns;
195 
196  // get params
197  param_buffer.receiveBroadcast(0);
198  int tag=param_buffer.pop_int();
199  string name=string(param_buffer.pop_string());
200  double kr = param_buffer.pop_double();
201  double ks = param_buffer.pop_double();
202  double kt = param_buffer.pop_double();
203  double kb = param_buffer.pop_double();
204  double max_nForce = param_buffer.pop_double();
205  double max_shForce = param_buffer.pop_double();
206  double max_tMoment = param_buffer.pop_double();
207  double max_bMoment = param_buffer.pop_double();
208  double diffusivity = param_buffer.pop_double();
209 
210  conns = TSubLattice<T>::m_temp_conn[tag];
211 
212  console.XDebug()
213  << "Got RotThermBondedIG parameters: tag=" << tag
214  << ", name=" << name.c_str()
215  << ", kr=" << kr
216  << ", ks=" << ks
217  << ", kt=" << kt
218  << ", kb=" << kb
219  << ", nFrc=" << max_nForce
220  << ", sFrc=" << max_shForce
221  << ", tMom=" << max_tMoment
222  << ", bMom=" << max_bMoment
223  << ", diffusivity=" << diffusivity
224  << "\n";
225  // setup InteractionGroup
226  CRotThermBondedIGP param;
227  param.tag = tag;
228  param.kr=kr;
229  param.ks=ks;
230  param.kt=kt;
231  param.kb=kb;
232  param.max_nForce = max_nForce ;
233  param.max_shForce = max_shForce ;
234  param.max_tMoment = max_tMoment ;
235  param.max_bMoment = max_bMoment ;
236  param.diffusivity = diffusivity ;
239 
240  // recv broadcast connection data
241  // console.XDebug() << "rank=" << this->m_tml_comm.rank() << "TSubLattice<T>::addRotThermBondedIG(): receiving conn_data.\n";
242  // vector<int> conn_data;
243  // this->m_tml_comm.recv_broadcast_cont(conn_data,0);
244  // console.XDebug() << "rank=" <<this->m_tml_comm.rank() << "TSubLattice<T>::addRotThermBondedIG(): conn_data.size()=" << conn_data.size() << "\n";
245  vector<int> vi(2,-1);
246  for(size_t i=0;i<conns.size();i+=2){
247  vi[0] = (conns[i]);
248  vi[1] = (conns[i+1]);
249  B_PIS->tryInsert(vi);
250  }
251 
252  // add InteractionGroup to map
253  this->m_bpis.insert(make_pair(name,B_PIS));
254 
255  console.XDebug() << "end TRotSubLattice<T>::addRotThermBondedIG()\n";
256 }
TSubLattice::doAddDamping
virtual bool doAddDamping(const string &, CVarMPIBuffer &)
Definition: SubLattice.hpp:1417
TRotSubLattice::addRotThermBondedIG
virtual void addRotThermBondedIG()
Definition: RotSubLattice.hpp:190
CVarMPIBuffer::pop_int
virtual int pop_int()
Definition: mpivbuf.cpp:196
TRotSubLattice::addRotBondedIG
virtual void addRotBondedIG()
Definition: RotSubLattice.hpp:113
CVarMPIBuffer
MPI send/recv buffer with automagically adjusted size.
Definition: mpivbuf.h:35
Console::Debug
Console & Debug()
set verbose level of next message to "dbg"
CRotBondedIGP::max_bMoment
double max_bMoment
Definition: RotBondedInteraction.h:78
TSubLattice::doAddPIG
virtual bool doAddPIG(const string &, const string &, CVarMPIBuffer &, bool tagged=false)
Definition: SubLattice.hpp:787
TRotSubLattice::doAddDamping
virtual bool doAddDamping(const string &, CVarMPIBuffer &)
Definition: RotSubLattice.hpp:76
CVarMPIBuffer::receiveBroadcast
virtual void receiveBroadcast(int)
Definition: mpivbuf.cpp:262
CRotBondedIGP::max_shForce
double max_shForce
Definition: RotBondedInteraction.h:78
ParallelInteractionStorage_E
parallel interaction storage array with exchange
Definition: pi_storage_e.h:37
CRotBondedIGP
Interaction parameters for bonded interaction between rotational particles.
Definition: RotBondedInteraction.h:38
AParallelInteractionStorage
abstract base class for parallel interaction storage array
Definition: pi_storage.h:45
CRotBondedIGP::max_nForce
double max_nForce
Definition: RotBondedInteraction.h:78
CRotThermBondedIGP::ks
double ks
Definition: RotThermBondedInteraction.h:51
ParallelInteractionStorage_EB
parallel storage array with exchange for bonded/breakable interactions
Definition: pi_storage_eb.h:30
TSubLattice
Class for a Sublattice.
Definition: SubLattice.h:72
CRotBondedIGP::truncated
double truncated
Definition: RotBondedInteraction.h:82
CRotBondedIGP::kt
double kt
Definition: RotBondedInteraction.h:77
CRotThermBondedIGP::kt
double kt
Definition: RotThermBondedInteraction.h:51
CRotThermBondedIGP::kb
double kb
Definition: RotThermBondedInteraction.h:51
Console::XDebug
Console & XDebug()
set verbose level of next message to "xdg"
CVarMPIBuffer::pop_double
virtual double pop_double()
Definition: mpivbuf.cpp:210
CRotThermBondedIGP
Definition: RotThermBondedInteraction.h:35
NULL
#define NULL
Definition: t_list.h:17
CRotThermBondedIGP::tag
int tag
Definition: RotThermBondedInteraction.h:54
TRotSubLattice::doAddPIG
virtual bool doAddPIG(const string &, const string &, CVarMPIBuffer &, bool tagged=false)
Definition: RotSubLattice.hpp:56
CRotBondedIGP::meanR_scaling
bool meanR_scaling
Definition: RotBondedInteraction.h:81
CRotThermBondedIGP::diffusivity
double diffusivity
Definition: RotThermBondedInteraction.h:53
ParallelInteractionStorage_Single::update
virtual bool update()
Definition: pi_storage_single.hpp:22
Vec3
Definition: vec3.h:47
AMPIBuffer::pop_vector
virtual Vec3 pop_vector()
Definition: mpibuf.cpp:26
CRotBondedIGP::ks
double ks
Definition: RotBondedInteraction.h:77
CRotThermBondedIGP::max_shForce
double max_shForce
Definition: RotThermBondedInteraction.h:52
CRotBondedIGP::tag
int tag
Definition: RotBondedInteraction.h:79
ParallelInteractionStorage_E::tryInsert
virtual void tryInsert(const I &)
TRotSubLattice::TRotSubLattice
TRotSubLattice(const esys::lsm::CLatticeParam &prm, int rank, MPI_Comm comm, MPI_Comm worker_comm)
Definition: RotSubLattice.hpp:21
CRotBondedIGP::kr
double kr
Definition: RotBondedInteraction.h:77
extractDampingIGP
CDampingIGP * extractDampingIGP(AMPIBuffer *B)
Definition: DampingIGP.cpp:64
TRotSubLattice::setParticleAngularVelocity
virtual void setParticleAngularVelocity()
Definition: RotSubLattice.hpp:36
CLocalDampingIGP
Interaction group parameters for CLocalDampingGroup.
Definition: LocalDampingIGP.h:28
extractLocalDampingIGP
CLocalDampingIGP * extractLocalDampingIGP(AMPIBuffer *B)
Definition: LocalDampingIGP.cpp:57
esys::lsm::CLatticeParam
Definition: LatticeParam.h:30
ParallelInteractionStorage_Single
parallel storage array without exchange for dynamically created single particle interactions (i....
Definition: pi_storage_single.h:27
console
Console console
Definition: console.cpp:25
CDampingIGP
Interaction group parameters for CDampingGroup.
Definition: DampingIGP.h:28
CRotThermBondedIGP::kr
double kr
Definition: RotThermBondedInteraction.h:51
CRotBondedIGP::scaling
bool scaling
Definition: RotBondedInteraction.h:80
CRotBondedIGP::max_tMoment
double max_tMoment
Definition: RotBondedInteraction.h:78
CRotBondedIGP::kb
double kb
Definition: RotBondedInteraction.h:77
CRotThermBondedIGP::max_nForce
double max_nForce
Definition: RotThermBondedInteraction.h:52
CRotThermBondedIGP::max_tMoment
double max_tMoment
Definition: RotThermBondedInteraction.h:52
CRotThermBondedIGP::max_bMoment
double max_bMoment
Definition: RotThermBondedInteraction.h:52
CVarMPIBuffer::pop_string
virtual std::string pop_string()
Definition: mpivbuf.cpp:233
TRotSubLattice::~TRotSubLattice
virtual ~TRotSubLattice()
Definition: RotSubLattice.hpp:29