ESyS-Particle  2.2.2
SubLattice.hpp
Go to the documentation of this file.
1 // //
3 // Copyright (c) 2003-2013 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 
13 // -- project includes -
14 
15 #include "Parallel/SubLattice.h"
16 #include "Parallel/MpiInfo.h"
17 #include "Parallel/mpivbuf.h"
18 #include "Parallel/mpisgvbuf.h"
19 #include "Parallel/mpibarrier.h"
20 #include "Parallel/mpia2abuf.h"
24 #include "Model/DampingIGP.h"
25 #include "Model/Damping.h"
26 #include "Model/RotDamping.h"
27 #include "Model/ABCDampingIGP.h"
28 #include "Model/ABCDamping.h"
29 #include "Model/LocalDampingIGP.h"
30 #include "Model/LocalDamping.h"
31 #include "Model/RotLocalDamping.h"
33 #include "Model/FractalFriction.h"
34 #include "Model/AdhesiveFriction.h"
45 #include "Model/MeshData.h"
46 #include "Model/MeshData2D.h"
51 
52 // --- parallel storage includes ---
53 #include "ppa/src/pp_array.h"
54 #include "pis/pi_storage_eb.h"
55 #include "pis/pi_storage_ed.h"
56 #include "pis/pi_storage_ed_t.h"
57 #include "pis/pi_storage_ne.h"
58 #include "pis/pi_storage_ne_t.h"
59 #include "pis/pi_storage_single.h"
60 #include "pis/trimesh_pis.h"
61 #include "pis/trimesh_pis_ne.h"
62 #include "pis/trimesh_pis_eb.h"
63 #include "pis/mesh2d_pis_eb.h"
64 #include "pis/mesh2d_pis_ne.h"
65 
66 // --- field includes ---
77 
78 #include "Model/BodyForceGroup.h"
79 
80 #include <mpi.h>
81 #include <stdlib.h>
82 #include <stdexcept>
83 
84 // -- STL includes --
85 #include <algorithm>
86 #include <stdexcept>
87 #include <boost/limits.hpp>
88 using std::runtime_error;
89 
90 // -- IO includes --
91 #include <iostream>
92 using std::cerr;
93 using std::flush;
94 using std::endl;
96 
97 //----------------------------------------------
98 // TSubLattice functions
99 //----------------------------------------------
100 
108 template <class T>
110  const CLatticeParam &param,
111  int rank,
112  MPI_Comm comm,
113  MPI_Comm worker_comm
114 )
115  : m_ppa(NULL),
116  m_dpis(),
117  m_bpis(),
118  m_singleParticleInteractions(),
119  m_damping(),
120  m_WIG(),
121  m_mesh(),
122  m_mesh2d(),
123  m_dt(0),
124  m_nrange(0),
125  m_alpha(0),
126  m_last_ns(0),
127  m_temp_conn(),
128  m_rank(0),
129  m_comm(MPI_COMM_NULL),
130  m_tml_comm(MPI_COMM_NULL),
131  m_worker_comm(MPI_COMM_NULL),
132  m_tml_worker_comm(MPI_COMM_NULL),
133  m_dims(3, 0),
134  packtime(0),
135  unpacktime(0),
136  commtime(0.0),
137  forcetime(0.0),
138  m_field_slaves(),
139  m_pTimers(NULL)
140 {
141  // cout << "TSubLattice<T>::TSubLattice at " << rank << endl << flush;
142  // -- MPI stuff --
143  m_rank=rank;
144 
145  // set global communicator
146  m_comm=comm;
148 
149  m_dims = param.processDims();
150 
151  m_worker_comm=worker_comm;
152  // MPI_Comm_size(m_worker_comm,&m_num_workers);
154 
155 
156  // -- set parameters
157  m_alpha=param.alpha();
158  m_nrange=param.nrange();
159  // cout << "dt,nrange,alpha : " << m_dt << " , " << m_nrange << " , " << m_alpha << "\n";
160 
161  commtime=0.0;
162  packtime=0.0;
163  unpacktime=0.0;
164  forcetime=0.0;
165 
166  m_last_ns=-1;
167 }
168 
169 template <class T>
171 {
172  console.Debug() << "TSubLattice<T>::~TSubLattice(): enter\n";
173  console.Debug()
174  << "TSubLattice<T>::~TSubLattice():"
175  << " deleting wall interaction groups...\n";
176  for(
177  typename map<string,AWallInteractionGroup<T>*>::iterator vit=m_WIG.begin();
178  vit!=m_WIG.end();
179  vit++
180  )
181  {
182  delete vit->second;
183  }
184  console.Debug()
185  << "TSubLattice<T>::~TSubLattice():"
186  << " deleting particle array...\n";
187  if (m_ppa != NULL) delete m_ppa;
188  console.Debug() << "TSubLattice<T>::~TSubLattice(): exit\n";
189 }
190 
197 template <class T>
198 void TSubLattice<T>::initNeighborTable(const Vec3& min,const Vec3& max)
199 {
200  console.XDebug() << "TSubLattice<T>::initNeighborTable(" << min << "," << max << ")\n";
201  // make size fit range
202  double xsize=max.X()-min.X();
203  xsize=m_nrange*ceil(xsize/m_nrange);
204  double ysize=max.Y()-min.Y();
205  ysize=m_nrange*ceil(ysize/m_nrange);
206  double zsize=max.Z()-min.Z();
207  zsize=m_nrange*ceil(zsize/m_nrange);
208  Vec3 grow=Vec3(xsize,ysize,zsize)-(max-min); // size increase
209  Vec3 nmin=min-0.5*grow; // distribute symmetrically
210  Vec3 nmax=max+0.5*grow;
211  console.XDebug() << "range=" << m_nrange << ", new min,max: " << nmin << ", " << nmax << "\n";
212 
213  // construct particle array
214  TML_Comm *ntcomm=new TML_Comm(m_worker_comm);
215  m_ppa=new ParallelParticleArray<T>(ntcomm,m_dims,nmin,nmax,m_nrange,m_alpha);
216  //m_ppa=new ParallelParticleArray<T>(ntcomm,3,nmin,nmax,m_nrange);
217 
218  // makeFields(); // put here to make sure ppa is initialized before makeFields
219 
220  console.XDebug() << "end TSubLattice<T>::initNeighborTable\n";
221 }
222 
223 template <class T>
225 {
226  T::setDo2dCalculations(do2d);
227 }
228 
229 template <class T>
231 {
232  return m_ppa->getInnerSize();
233 }
234 
242 template <class T>
243 void TSubLattice<T>::initNeighborTable(const Vec3& min,const Vec3& max,const vector<bool>& circ)
244 {
245  console.XDebug() << "TSubLattice<T>::initNeighborTable(" << min << "," << max << ") circ\n";
246  double xsize,ysize,zsize;
247  // if dimension is circular, check if size fits range, otherwise make it fit
248  // x - dim
249  if(circ[0])
250  {
251  xsize=max.X()-min.X();
252  if(fabs(xsize/m_nrange-lrint(xsize/m_nrange))>1e-6)
253  {
254  //console.Critical() << "circular x-dimension doesn't fit range !\n";
255  console.Info() << "Circular x-size incompatible with range, adjusting...\n";
256  m_nrange = xsize/floor(xsize/m_nrange);
257  console.Info() << "New range = " << m_nrange << "\n";
258  }
259  //xsize+=2.0*m_nrange; // padding on the circular ends
260  }
261  else
262  {
263  xsize=max.X()-min.X();
264  xsize=m_nrange*ceil(xsize/m_nrange);
265  }
266  // y - dim
267  if(circ[1])
268  {
269  ysize=max.Y()-min.Y();
270  if(fabs(ysize/m_nrange-lrint(ysize/m_nrange))>1e-6)
271  {
272  console.Critical() << "circular y-dimension doesn't fit range !\n";
273  }
274  ysize+=2.0*m_nrange; // padding on the circular ends
275  }
276  else
277  {
278  ysize=max.Y()-min.Y();
279  ysize=m_nrange*ceil(ysize/m_nrange);
280  }
281  // z - dim
282  if(circ[2])
283  {
284  zsize=max.Z()-min.Z();
285  if(fabs(zsize/m_nrange-lrint(zsize/m_nrange))>1e-6)
286  {
287  console.Critical() << "circular z-dimension doesn't fit range !\n";
288  }
289  zsize+=2.0*m_nrange; // padding on the circular ends
290  }
291  else
292  {
293  zsize=max.Z()-min.Z();
294  zsize=m_nrange*ceil(zsize/m_nrange);
295  }
296  Vec3 grow=Vec3(xsize,ysize,zsize)-(max-min); // size increase
297  Vec3 nmin=min-0.5*grow; // distribute symmetrically
298  Vec3 nmax=max+0.5*grow;
299  console.XDebug() << "range, new min, max: " << m_nrange << " " << nmin << nmax << "\n";
300  // construct particle array
301  TML_Comm *ntcomm=new TML_Comm(m_worker_comm);
302  m_ppa=new ParallelParticleArray<T>(ntcomm,m_dims,circ,nmin,nmax,m_nrange,m_alpha);
303 
304  // makeFields(); // put here to make sure ppa is initialized before makeFields
305 
306  console.XDebug() << "end TSubLattice<T>::initNeighborTable (circ)\n";
307 }
308 
315 template <class T>
317 {
318  console.XDebug() << "TSubLattice<T>::receiveParticles: enter\n";
319 
320  vector<T> recv_buffer;
321  CMPIBarrier barrier(m_comm);
322 
323  m_tml_comm.recv_broadcast_cont_packed(recv_buffer,0);
324  console.XDebug() << "recvd " << recv_buffer.size() << " particles \n";
325  m_ppa->insert(recv_buffer);
326 
327  barrier.wait("TSubLattice<T>::receiveParticles");
328 
329  console.XDebug() << "TSubLattice<T>::receiveParticles: exit\n";
330 }
331 
332 
338 template <class T>
340 {
341  console.XDebug() << "TSubLattice<T>::receiveConnections: enter\n";
342 
343  vector<int> recv_buffer;
344  CMPIBarrier barrier(m_comm);
345 
346  m_tml_comm.recv_broadcast_cont_packed(recv_buffer,0);
347  console.XDebug() << "recvd " << recv_buffer.size() << " connections \n";
348  vector<int>::iterator it;
349  for (it = recv_buffer.begin(); it != recv_buffer.end(); it+=3)
350  {
351  if ( (m_ppa->getParticlePtrByIndex( *(it+1)) == NULL ) ||
352  (m_ppa->getParticlePtrByIndex( *(it+2)) == NULL ) )
353  {
354  continue;
355  }
356  m_temp_conn[*(it)].push_back(*(it+1));
357  m_temp_conn[*(it)].push_back(*(it+2));
358  }
359 
360  barrier.wait("TSubLattice<T>::receiveConnections");
361 
362  console.XDebug() << "TSubLattice<T>::receiveConnections: exit\n";
363 }
364 
365 
369 template <class T>
371 {
372  console.XDebug() << "TSubLattice<T>::addWall: enter\n" ;
373  CVarMPIBuffer param_buffer(m_comm);
374  param_buffer.receiveBroadcast(0);
375 
376  string name=param_buffer.pop_string();
377  Vec3 ipos=param_buffer.pop_vector();
378  Vec3 inorm=param_buffer.pop_vector();
379 
380  m_walls[name]=new CWall(ipos,inorm);
381 
382  console.XDebug() << "TSubLattice<T>::addWall: exit\n" ;
383 }
384 
388 template <class T>
390 {
391  console.XDebug() << "TSubLattice<T>::addElasticWIG: enter\n" ;
392  CVarMPIBuffer param_buffer(m_comm);
393 
394  // receive params from master
395  param_buffer.receiveBroadcast(0);
396 
397  CEWallIGP* wigp=extractEWallIGP(&param_buffer);
398 
399  string wallname=wigp->getWallName();
400  map<string,CWall*>::iterator iter=m_walls.find(wallname);
401  if(iter!=m_walls.end()){
402  AWallInteractionGroup<T>* newCEWIG =
404  &m_tml_worker_comm,
405  m_walls[wallname],
406  wigp
407  );
408  newCEWIG->Update(m_ppa);
409  m_WIG.insert(make_pair(wigp->getName(),newCEWIG));
410  } else {
411  std::stringstream msg;
412  msg << "wall name '" << wallname << "' not found in map of walls";
413  throw std::runtime_error(msg.str().c_str());
414  }
415 
416  delete wigp;
417  console.XDebug() << "TSubLattice<T>::addElasticWIG: exit\n" ;
418 }
419 
420 
424 template <class T>
426 {
427  console.XDebug() << "TSubLattice<T>::addBondedWIG: enter\n" ;
428  CVarMPIBuffer param_buffer(m_comm);
429 
430  // receive params from master
431  param_buffer.receiveBroadcast(0);
432 
433  CBWallIGP* wigp=extractBWallIGP(&param_buffer);
434 
435  string wallname=wigp->getWallName();
436  map<string,CWall*>::iterator iter=m_walls.find(wallname);
437  if(iter!=m_walls.end()){
438  AWallInteractionGroup<T>* newCBWIG=new CBWallInteractionGroup<T>(&m_tml_worker_comm,m_walls[wallname],wigp);
439  newCBWIG->Update(m_ppa);
440  m_WIG.insert(make_pair(wigp->getName(),newCBWIG));
441  } else {
442  console.Error() << "wall name " << wallname << " not found in map of walls\n";
443  }
444 
445  delete wigp;
446  console.XDebug() << "TSubLattice<T>::addBondedWIG: exit\n" ;
447 }
448 
452 template <class T>
454 {
455  console.XDebug() << "TSubLattice<T>::addDirBondedWIG: enter\n" ;
456  CVarMPIBuffer param_buffer(m_comm);
457 
458  // receive params from master
459  param_buffer.receiveBroadcast(0);
460 
461  CSoftBWallIGP* wigp=extractSoftBWallIGP(&param_buffer);
462 
463  string wallname=wigp->getWallName();
464  map<string,CWall*>::iterator iter=m_walls.find(wallname);
465  if(iter!=m_walls.end()){
466  AWallInteractionGroup<T>* newCDWIG=new CSoftBWallInteractionGroup<T>(&m_tml_worker_comm,m_walls[wallname],wigp);
467  newCDWIG->Update(m_ppa);
468  m_WIG.insert(make_pair(wigp->getName(),newCDWIG));
469  } else {
470  console.Error() << "wall name " << wallname << " not found in map of walls\n";
471  }
472 
473  delete wigp;
474  console.XDebug() << "TSubLattice<T>::addDirBondedWIG: exit\n" ;
475 }
476 
480 template <class T>
482 {
483  console.XDebug() << "TSubLattice<T>::getWallPosition: enter\n" ;
484  CVarMPIBuffer param_buffer(m_comm);
485  Vec3 pos;
486 
487  // receive params from master
488  param_buffer.receiveBroadcast(0);
489 
490  std::string wname=param_buffer.pop_string();
491  console.XDebug() << "Wall name: " << wname << "\n";
492 
493  // find wall
494  map<string,CWall*>::iterator iter=m_walls.find(wname);
495  if(iter!=m_walls.end()){
496  pos=(iter->second)->getPos();
497  console.XDebug() << "Wall pos: " << pos << "\n";
498  } else {
499  pos=Vec3(0.0,0.0,0.0);
500  }
501 
502  vector<Vec3> vpos;
503  vpos.push_back(pos);
504  m_tml_comm.send_gather(vpos,0);
505  console.XDebug() << "TSubLattice<T>::getWallPosition: exit\n" ;
506 }
507 
511 template <class T>
513 {
514  console.XDebug() << "TSubLattice<T>::getWallForce: enter\n" ;
515  CVarMPIBuffer param_buffer(m_comm);
516  Vec3 force;
517 
518  // receive params from master
519  param_buffer.receiveBroadcast(0);
520 
521  std::string wname=param_buffer.pop_string();
522  console.XDebug() << "Wall name: " << wname << "\n";
523 
524  // find wall
525  map<string,CWall*>::iterator iter=m_walls.find(wname);
526  if(iter!=m_walls.end()){
527  force=(iter->second)->getForce();
528  console.XDebug() << "Wall force: " << force << "\n";
529  } else {
530  force=Vec3(0.0,0.0,0.0);
531  }
532 
533  vector<Vec3> vforce;
534  vforce.push_back(force);
535  m_tml_comm.send_gather(vforce,0);
536  console.XDebug() << "TSubLattice<T>::getWallForce: exit\n" ;
537 }
538 
542 template <class T>
544 {
545  console.XDebug() << "TSubLattice<T>::addViscWIG: enter\n" ;
546  CVarMPIBuffer param_buffer(m_comm);
547 
548  // receive params from master
549  param_buffer.receiveBroadcast(0);
550 
551  CVWallIGP* wigp=extractVWallIGP(&param_buffer);
552 
553  string wallname=wigp->getWallName();
554  map<string,CWall*>::iterator iter=m_walls.find(wallname);
555  if(iter!=m_walls.end()){
556  AWallInteractionGroup<T>* newCVWIG=new CViscWallIG<T>(&m_tml_worker_comm,m_walls[wallname],wigp);
557  newCVWIG->Update(m_ppa);
558  m_WIG.insert(make_pair(wigp->getName(),newCVWIG));
559  } else {
560  console.Error() << "wall name " << wallname << " not found in map of walls\n";
561  }
562 
563  delete wigp;
564  console.XDebug() << "TSubLattice<T>::addViscWIG: exit\n" ;
565 }
566 
570 template <class T>
572 {
573  console.XDebug() << "TSubLattice<T>::addPairIG()\n";
574  CVarMPIBuffer param_buffer(m_comm,2000);
575 
576  // get params
577  param_buffer.receiveBroadcast(0);
578  string type = param_buffer.pop_string();
579  console.XDebug()<< "PIG type: " << type.c_str() << "\n";
580  string name = param_buffer.pop_string();
581  console.XDebug()<< "PIG name: " << name.c_str() << "\n";
582 
583  doAddPIG(name,type,param_buffer,false);
584 
585  console.XDebug() << "end TSubLattice<T>::addPairIG()\n";
586 }
587 
591 template <class T>
593 {
594  console.XDebug() << "TSubLattice<T>::addTaggedPairIG()\n";
595  CVarMPIBuffer param_buffer(m_comm,2000);
596 
597  // get params
598  param_buffer.receiveBroadcast(0);
599  string type = param_buffer.pop_string();
600  console.XDebug()<< "PIG type: " << type.c_str() << "\n";
601  string name = param_buffer.pop_string();
602  console.XDebug()<< "PIG name: " << name.c_str() << "\n";
603 
604  doAddPIG(name,type,param_buffer,true);
605 
606  console.XDebug() << "end TSubLattice<T>::addTaggedPairIG()\n";
607 }
608 
616 template <class T>
617 bool TSubLattice<T>::doAddPIG(const string& name,const string& type,CVarMPIBuffer& param_buffer, bool tagged)
618 {
619  bool res=false;
621 
622  if(type=="Elastic") {
623  CElasticIGP eigp;
624  eigp.m_k=param_buffer.pop_double();
625  eigp.m_scaling=static_cast<bool>(param_buffer.pop_int());
626  if(tagged){
627  int tag1=param_buffer.pop_int();
628  int mask1=param_buffer.pop_int();
629  int tag2=param_buffer.pop_int();
630  int mask2=param_buffer.pop_int();
631  console.XDebug() << "tag1, mask1, tag2, mask2 "
632  << tag1 << " , " << mask1 << " , "
633  << tag2 << " , " << mask2 << "\n";
634  new_pis=new ParallelInteractionStorage_NE_T<T,CElasticInteraction>(m_ppa,eigp,tag1,mask1,tag2,mask2);
635  }else{
637  }
638  res=true;
639  } else if (type=="Friction") {
640  CFrictionIGP figp;
641  figp.k=param_buffer.pop_double();
642  figp.mu=param_buffer.pop_double();
643  figp.k_s=param_buffer.pop_double();
644  figp.dt=param_buffer.pop_double();
645  figp.m_scaling=static_cast<bool>(param_buffer.pop_int());
646  console.XDebug() << "k,mu,k_s,dt: " << figp.k << " , " << figp.mu << " , "
647  << figp.k_s << " , " << figp.dt << "\n";
649  res=true;
650  } else if (type=="AdhesiveFriction") {
652  figp.k=param_buffer.pop_double();
653  figp.mu=param_buffer.pop_double();
654  figp.k_s=param_buffer.pop_double();
655  figp.dt=param_buffer.pop_double();
656  figp.r_cut=param_buffer.pop_double();
657  console.XDebug()
658  << "k,mu,k_s,dt,r_cut: " << figp.k << " , " << figp.mu << " , "
659  << figp.k_s << " , " << figp.dt << " " << figp.r_cut << "\n";
661  res=true;
662  } else if (type=="FractalFriction") {
663  FractalFrictionIGP figp;
664  figp.k=param_buffer.pop_double();
665  figp.mu_0=param_buffer.pop_double();
666  figp.k_s=param_buffer.pop_double();
667  figp.dt=param_buffer.pop_double();
668  console.XDebug() << "k,mu_0,k_s,dt: " << figp.k << " , " << figp.mu_0 << " , "
669  << figp.k_s << " , " << figp.dt << "\n";
670  figp.x0=param_buffer.pop_double();
671  figp.y0=param_buffer.pop_double();
672  figp.dx=param_buffer.pop_double();
673  figp.dy=param_buffer.pop_double();
674  figp.nx=param_buffer.pop_int();
675  figp.ny=param_buffer.pop_int();
676  console.XDebug()
677  <<"x0,y0,dx,dy,nx,ny: "
678  << figp.x0 << " , " << figp.y0 << " , "
679  << figp.dx << " , " << figp.dy << " ,"
680  << figp.nx << " , " << figp.ny << "\n";
681  figp.mu = boost::shared_ptr<double>(new double[figp.nx*figp.ny]);
682 
683  for(int i=0;i<figp.nx*figp.ny;i++)
684  {
685  (figp.mu.get())[i]=param_buffer.pop_double();
686  // console.XDebug() << i << " , " << figp.mu[i] << "\n";
687  }
688  new_pis = new ParallelInteractionStorage_ED<T,CFractalFriction>(m_ppa,figp);
689  res=true;
690  } else if(type=="VWFriction") {
691  VWFrictionIGP figp;
692 
693  figp.k=param_buffer.pop_double();
694  figp.mu=param_buffer.pop_double();
695  figp.k_s=param_buffer.pop_double();
696  figp.dt=param_buffer.pop_double();
697  figp.m_alpha=param_buffer.pop_double();
698  console.XDebug()
699  << "k,mu,k_s,dt,alpha: " << figp.k << " , " << figp.mu << " , "
700  << figp.k_s << " , " << figp.dt << "\n";
701  new_pis=new ParallelInteractionStorage_ED<T,CVWFriction>(m_ppa,figp);
702  res=true;
703  } else if(type=="RotElastic"){
704  CRotElasticIGP reigp;
705  reigp.m_kr=param_buffer.pop_double();
707  res=true;
708  } else if (type=="RotFriction"){
709  CRotFrictionIGP rfigp;
710  rfigp.k=param_buffer.pop_double();
711  rfigp.mu_s=param_buffer.pop_double();
712  rfigp.mu_d=param_buffer.pop_double();
713  rfigp.k_s=param_buffer.pop_double();
714  rfigp.dt=param_buffer.pop_double();
715  rfigp.scaling=static_cast<bool>(param_buffer.pop_int());
716  rfigp.meanR_scaling=static_cast<bool>(param_buffer.pop_int());
717  console.XDebug()
718  << "k,mu_s,mu_d,k_s,dt,scaling: " << rfigp.k << " , "
719  << rfigp.mu_s << " , " << rfigp.mu_d << " , "
720  << rfigp.k_s << " , " << rfigp.dt << " , " << rfigp.scaling << "\n";
721  if(tagged){
722  int tag1=param_buffer.pop_int();
723  int mask1=param_buffer.pop_int();
724  int tag2=param_buffer.pop_int();
725  int mask2=param_buffer.pop_int();
726  console.XDebug() << "tag1, mask1, tag2, mask2 "
727  << tag1 << " , " << mask1 << " , "
728  << tag2 << " , " << mask2 << "\n";
729  new_pis=new ParallelInteractionStorage_ED_T<CRotParticle,CRotFrictionInteraction>(m_ppa,rfigp,tag1,mask1,tag2,mask2);
730  } else {
732  }
733  res=true;
734  } else if (type == "RotThermElastic") {
735  CRotThermElasticIGP eigp;
736  eigp.m_kr = param_buffer.pop_double();
737  eigp.diffusivity = param_buffer.pop_double();
738  console.XDebug()
739  << "k=" << eigp.m_kr << " , "
740  << "diffusivity=" << eigp.diffusivity << "\n";
741 
742  new_pis =
746  >(
747  m_ppa,
748  eigp
749  );
750  res=true;
751  } else if (type == "RotThermFriction") {
752  CRotThermFrictionIGP rfigp;
753  rfigp.k=param_buffer.pop_double();
754  rfigp.mu_s=param_buffer.pop_double();
755  rfigp.mu_d=param_buffer.pop_double();
756  rfigp.k_s=param_buffer.pop_double();
757  rfigp.diffusivity=param_buffer.pop_double();
758  rfigp.dt=param_buffer.pop_double();
759  console.XDebug()
760  << "k=" << rfigp.k << " , "
761  << "mu_d=" << rfigp.mu_d << " , "
762  << "mu_s=" << rfigp.mu_s << " , "
763  << "k_s=" << rfigp.k_s << " , "
764  << "diffusivity=" << rfigp.diffusivity << " , "
765  << "dt=" << rfigp.dt << "\n";
766 
767  new_pis =
771  >(
772  m_ppa,
773  rfigp
774  );
775  res=true;
776  } else if(type=="HertzianElastic") {
777  CHertzianElasticIGP heigp;
778  heigp.m_E=param_buffer.pop_double();
779  heigp.m_nu=param_buffer.pop_double();
780  if(tagged){
781  int tag1=param_buffer.pop_int();
782  int mask1=param_buffer.pop_int();
783  int tag2=param_buffer.pop_int();
784  int mask2=param_buffer.pop_int();
785  new_pis=new ParallelInteractionStorage_NE_T<T,CHertzianElasticInteraction>(m_ppa,heigp,tag1,mask1,tag2,mask2);
786  }else{
788  }
789  res=true;
790  } else if(type=="HertzianViscoElasticFriction") {
792  hvefigp.m_A=param_buffer.pop_double();
793  hvefigp.m_E=param_buffer.pop_double();
794  hvefigp.m_nu=param_buffer.pop_double();
795  hvefigp.mu=param_buffer.pop_double();
796  hvefigp.k_s=param_buffer.pop_double();
797  hvefigp.dt=param_buffer.pop_double();
798  if(tagged){
799  int tag1=param_buffer.pop_int();
800  int mask1=param_buffer.pop_int();
801  int tag2=param_buffer.pop_int();
802  int mask2=param_buffer.pop_int();
803  new_pis=new ParallelInteractionStorage_NE_T<T,CHertzianViscoElasticFrictionInteraction>(m_ppa,hvefigp,tag1,mask1,tag2,mask2);
804  }else{
806  }
807  res=true;
808  } else if(type=="HertzianViscoElastic") {
810  hveigp.m_A=param_buffer.pop_double();
811  hveigp.m_E=param_buffer.pop_double();
812  hveigp.m_nu=param_buffer.pop_double();
813  if(tagged){
814  int tag1=param_buffer.pop_int();
815  int mask1=param_buffer.pop_int();
816  int tag2=param_buffer.pop_int();
817  int mask2=param_buffer.pop_int();
818  new_pis=new ParallelInteractionStorage_NE_T<T,CHertzianViscoElasticInteraction>(m_ppa,hveigp,tag1,mask1,tag2,mask2);
819  }else{
821  }
822  res=true;
823  } else if(type=="LinearDashpot") {
824  CLinearDashpotIGP heigp;
825  heigp.m_damp=param_buffer.pop_double();
826  heigp.m_cutoff=param_buffer.pop_double();
827  if(tagged){
828  int tag1=param_buffer.pop_int();
829  int mask1=param_buffer.pop_int();
830  int tag2=param_buffer.pop_int();
831  int mask2=param_buffer.pop_int();
832  new_pis=new ParallelInteractionStorage_NE_T<T,CLinearDashpotInteraction>(m_ppa,heigp,tag1,mask1,tag2,mask2);
833  }else{
835  }
836  res=true;
837  } else {
838  cerr << "Unknown interaction group name "
839  << type
840  << " in TSubLattice<T>::addPairIG()" << endl;
841  }
842 
843  // add InteractionGroup to map
844  if(res) m_dpis.insert(make_pair(name,new_pis));
845 
846  return res;
847 }
848 
849 
853 template <class T>
855 {
856  console.XDebug() << "TSubLattice<T>::addTriMesh()\n";
857 
858  // MPI buffer
859  CVarMPIBuffer param_buffer(m_comm);
860  // data buffers
861  vector<MeshNodeData> node_recv_buffer;
862  vector<MeshTriData> tri_recv_buffer;
863 
864  // receive params
865  param_buffer.receiveBroadcast(0);
866 
867  // extract name
868  string name = param_buffer.pop_string();
869  console.XDebug()<< "TriMesh name: " << name.c_str() << "\n";
870 
871  // receive nodes
872  m_tml_comm.recv_broadcast_cont_packed(node_recv_buffer,0);
873  console.XDebug() << "recvd " << node_recv_buffer.size() << " nodes \n";
874 
875  // receive triangles
876  m_tml_comm.recv_broadcast_cont_packed(tri_recv_buffer,0);
877  console.XDebug() << "recvd " << tri_recv_buffer.size() << " triangles \n";
878 
879  // load mesh into new TriMesh
880  TriMesh* new_tm=new TriMesh();
881  new_tm->LoadMesh(node_recv_buffer,tri_recv_buffer);
882 
883  m_mesh.insert(make_pair(name,new_tm));
884 
885  console.XDebug() << "end TSubLattice<T>::addTriMesh()\n";
886 }
887 
891 template <class T>
893 {
894  console.XDebug() << "TSubLattice<T>::addTriMeshIG()\n";
895 
896  // MPI buffer
897  CVarMPIBuffer param_buffer(m_comm);
898 
899  // receive params
900  param_buffer.receiveBroadcast(0);
901 
902  // extract name & type
903  string type = param_buffer.pop_string();
904  console.XDebug()<< "TriMeshIG type: " << type.c_str() << "\n";
905  string name = param_buffer.pop_string();
906  console.XDebug()<< "TriMeshIG name: " << name.c_str() << "\n";
907  string meshname = param_buffer.pop_string();
908  console.XDebug()<< "TriMeshIG mesh name: " << meshname.c_str() << "\n";
909 
910  // get pointer to mesh
911  TriMesh* tmp=NULL;
912  if (m_mesh.find(meshname) != m_mesh.end())
913  {
914  tmp = m_mesh[meshname];
915  }
916  if(tmp==NULL){
917  throw runtime_error("unknown mesh name in TSubLattice<T>::addTriMeshIG:" + meshname);
918  }
919  // switch on type,extract params & construc new TriMeshIG
920  if(type=="Elastic")
921  {
923  ETriMeshIP tmi;
924  tmi.k=param_buffer.pop_double();
925  new_pis = new TriMesh_PIS_NE<T,ETriMeshInteraction>(tmp,m_ppa,tmi);
926  m_dpis.insert(make_pair(name,new_pis));
927  } else { // unknown type-> throw
928  throw runtime_error("unknown type in TSubLattice<T>::addTriMeshIG:" + type);
929  }
930 
931 
932  console.XDebug() << "end TSubLattice<T>::addTriMeshIG()\n";
933 }
934 
938 template <class T>
940 {
941  console.XDebug() << "TSubLattice<T>::addBondedTriMeshIG()\n";
942 
943  // MPI buffer
944  CVarMPIBuffer param_buffer(m_comm);
945 
946  // receive params
947  BTriMeshIP param;
948  param_buffer.receiveBroadcast(0);
949 
950  // extract name.meshname & params
951  string name = param_buffer.pop_string();
952  console.XDebug()<< "BTriMeshIG name: " << name.c_str() << "\n";
953  string meshname = param_buffer.pop_string();
954  console.XDebug()<< "BTriMeshIG mesh name: " << meshname.c_str() << "\n";
955  param.k = param_buffer.pop_double();
956  console.XDebug()<< "BTriMeshIG k : " << param.k << "\n";
957  param.brk = param_buffer.pop_double();
958  console.XDebug()<< "BTriMeshIG r_break: " << param.brk << "\n";
959  string buildtype = param_buffer.pop_string();
960  console.XDebug()<< "BTriMeshIG build type: " << buildtype.c_str() << "\n";
961 
962  // get pointer to mesh
963  TriMesh* tmp=NULL;
964  if (m_mesh.find(meshname) != m_mesh.end())
965  {
966  tmp = m_mesh[meshname];
967  }
968  if(tmp==NULL){
969  throw runtime_error("unknown mesh name in TSubLattice<T>::addTriMeshIG:" + meshname);
970  }
971 
972  // setup new interaction storage
974  // switch on buildtype, extract buildparam & build
975  if(buildtype=="BuildByTag"){
976  int tag=param_buffer.pop_int();
977  int mask=param_buffer.pop_int();
978  new_pis->buildFromPPATagged(tag,mask);
979  m_bpis.insert(make_pair(name,new_pis));
980  } else if(buildtype=="BuildByGap"){
981  double max_gap=param_buffer.pop_double();
982  new_pis->buildFromPPAByGap(max_gap);
983  m_bpis.insert(make_pair(name,new_pis));
984  } else { // unknown type-> throw
985  throw runtime_error("unknown build type in TSubLattice<T>::addBondedTriMeshIG:" + buildtype);
986  }
987 
988  console.XDebug() << "end TSubLattice<T>::addBondedTriMeshIG()\n";
989 }
990 
994 template <class T>
996 {
997  console.XDebug() << "TSubLattice<T>::addMesh2D()\n";
998 
999  // MPI buffer
1000  CVarMPIBuffer param_buffer(m_comm);
1001  // data buffers
1002  vector<MeshNodeData2D> node_recv_buffer;
1003  vector<MeshEdgeData2D> edge_recv_buffer;
1004 
1005  // receive params
1006  param_buffer.receiveBroadcast(0);
1007 
1008  // extract name
1009  string name = param_buffer.pop_string();
1010  console.XDebug()<< "Mesh2D name: " << name.c_str() << "\n";
1011 
1012  // receive nodes
1013  m_tml_comm.recv_broadcast_cont_packed(node_recv_buffer,0);
1014  console.XDebug() << "recvd " << node_recv_buffer.size() << " nodes \n";
1015 
1016  // receive edges
1017  m_tml_comm.recv_broadcast_cont_packed(edge_recv_buffer,0);
1018  console.XDebug() << "recvd " << edge_recv_buffer.size() << " edges \n";
1019 
1020  // load mesh into new 2D Mesh
1021  Mesh2D* new_tm=new Mesh2D();
1022  new_tm->LoadMesh(node_recv_buffer,edge_recv_buffer);
1023 
1024  m_mesh2d.insert(make_pair(name,new_tm));
1025 
1026  console.XDebug() << "end TSubLattice<T>::addMesh2D()\n";
1027 }
1028 
1033 template <class T>
1035 {
1036 console.XDebug() << "TSubLattice<T>::addMesh2DIG()\n";
1037 
1038  // MPI buffer
1039  CVarMPIBuffer param_buffer(m_comm);
1040 
1041  // receive params
1042  param_buffer.receiveBroadcast(0);
1043 
1044  // extract name & type
1045  string type = param_buffer.pop_string();
1046  console.XDebug()<< "Mesh2DIG type: " << type.c_str() << "\n";
1047  string name = param_buffer.pop_string();
1048  console.XDebug()<< "Mesh2DIG name: " << name.c_str() << "\n";
1049  string meshname = param_buffer.pop_string();
1050  console.XDebug()<< "Mesh2DIG mesh name: " << meshname.c_str() << "\n";
1051 
1052  // get pointer to mesh
1053  Mesh2D* tmp=NULL;
1054  if (m_mesh2d.find(meshname) != m_mesh2d.end())
1055  {
1056  tmp = m_mesh2d[meshname];
1057  }
1058  if(tmp==NULL){
1059  throw runtime_error("unknown mesh name in TSubLattice<T>::addMesh2DIG:" + meshname);
1060  }
1061  // switch on type,extract params & construc new Mesh2DIG
1062  if(type=="Elastic")
1063  {
1064  AParallelInteractionStorage* new_pis;
1065  ETriMeshIP tmi;
1066  tmi.k=param_buffer.pop_double();
1067  new_pis = new Mesh2D_PIS_NE<T,EMesh2DInteraction>(tmp,m_ppa,tmi);
1068  m_dpis.insert(make_pair(name,new_pis));
1069  } else { // unknown type-> throw
1070  throw runtime_error("unknown type in TSubLattice<T>::addMesh2DIG:" + type);
1071  }
1072 
1073 
1074  console.XDebug() << "end TSubLattice<T>::addTriMeshIG()\n";
1075 }
1076 
1081 template <class T>
1083 {
1084  console.XDebug() << "TSubLattice<T>::addBondedMesh2DIG()\n";
1085 
1086  // MPI buffer
1087  CVarMPIBuffer param_buffer(m_comm);
1088 
1089  // receive params
1090  BMesh2DIP param;
1091  param_buffer.receiveBroadcast(0);
1092 
1093  // extract name.meshname & params
1094  string name = param_buffer.pop_string();
1095  console.XDebug() << "BMesh2DIG name: " << name.c_str() << "\n";
1096  string meshname = param_buffer.pop_string();
1097  console.XDebug() << "BMesh2DIG mesh name: " << meshname.c_str() << "\n";
1098  param.k = param_buffer.pop_double();
1099  console.XDebug() << "BMesh2DIG k : " << param.k << "\n";
1100  param.brk = param_buffer.pop_double();
1101  console.XDebug() << "BMesh2DIG r_break: " << param.brk << "\n";
1102  string buildtype = param_buffer.pop_string();
1103  console.XDebug() << "BMesh2DIG build type: " << buildtype.c_str() << "\n";
1104 
1105  // get pointer to mesh
1106  Mesh2D* tmp=NULL;
1107  if (m_mesh2d.find(meshname) != m_mesh2d.end())
1108  {
1109  tmp = m_mesh2d[meshname];
1110  }
1111  if(tmp==NULL){
1112  throw runtime_error("unknown mesh name in TSubLattice<T>::addBondedMesh2DIG:" + meshname);
1113  }
1114 
1115  // setup new interaction storage
1117  // switch on buildtype, extract buildparam & build
1118  if(buildtype=="BuildByTag"){
1119  int tag=param_buffer.pop_int();
1120  int mask=param_buffer.pop_int();
1121  new_pis->buildFromPPATagged(tag,mask);
1122  m_bpis.insert(make_pair(name,new_pis));
1123  } else if(buildtype=="BuildByGap"){
1124  double max_gap=param_buffer.pop_double();
1125  new_pis->buildFromPPAByGap(max_gap);
1126  m_bpis.insert(make_pair(name,new_pis));
1127  } else { // unknown type-> throw
1128  throw runtime_error("unknown build type in TSubLattice<T>::addBondedMesh2DIG:" + buildtype);
1129  }
1130 
1131  console.XDebug() << "end TSubLattice<T>::addBonded2DMeshIG()\n";
1132 }
1133 
1134 
1140 template <class T>
1142 {
1143  console.XDebug() << "TSubLattice<T>::addSingleIG()\n";
1144  CVarMPIBuffer param_buffer(m_comm);
1145 
1146  // get params
1147  param_buffer.receiveBroadcast(0);
1148 
1149  string type = param_buffer.pop_string();
1150  console.XDebug()<< "SIG type: " << type.c_str() << "\n";
1151 
1152  // setup InteractionGroup
1153  if(type=="Gravity"){
1155 
1156  // add to map
1157  m_singleParticleInteractions.insert(
1158  std::pair<string,AInteractionGroup<T>*>(
1159  prms.Name(),
1160  new esys::lsm::BodyForceGroup<T>(prms, *m_ppa)
1161  )
1162  );
1163  }
1164  else if (type=="Buoyancy"){
1166 
1167  // add to map
1168  m_singleParticleInteractions.insert(
1169  std::pair<string,AInteractionGroup<T>*>(
1170  prms.Name(),
1171  new esys::lsm::BuoyancyForceGroup<T>(prms, *m_ppa)
1172  )
1173  );
1174  }
1175  else {
1176  throw std::runtime_error(
1177  std::string("Trying to setup SIG of unknown type: ")
1178  +
1179  type
1180  );
1181  }
1182 
1183  console.XDebug() << "end TSubLattice<T>::addSingleIG()\n";
1184 }
1185 
1186 
1190 template <class T>
1192 {
1193  console.XDebug() << "TSubLattice<T>::addDamping()\n";
1194  CVarMPIBuffer param_buffer(m_comm);
1195  // get params
1196  param_buffer.receiveBroadcast(0);
1197 
1198  string type = param_buffer.pop_string();
1199  console.XDebug()<< "Damping type: " << type.c_str() << "\n";
1200 
1201  // setup InteractionGroup
1202  doAddDamping(type,param_buffer);
1203 
1204  console.XDebug() << "end TSubLattice<T>::addDamping()\n";
1205 }
1206 
1213 template <class T>
1214 bool TSubLattice<T>::doAddDamping(const string& type,CVarMPIBuffer& param_buffer)
1215 {
1217  string damping_name;
1218  bool res;
1219 
1220  if(type=="Damping")
1221  {
1222  CDampingIGP *params=extractDampingIGP(&param_buffer);
1223  DG=new ParallelInteractionStorage_Single<T,CDamping<T> >(m_ppa,*params);
1224  damping_name="Damping";
1225  res=true;
1226  } else if (type=="ABCDamping"){
1227  ABCDampingIGP *params=extractABCDampingIGP(&param_buffer);
1228  DG=new ParallelInteractionStorage_Single<T,ABCDamping<T> >(m_ppa,*params);
1229  damping_name=params->getName();
1230  res=true;
1231  } else if (type=="LocalDamping"){
1232  CLocalDampingIGP *params=extractLocalDampingIGP(&param_buffer);
1234  damping_name=params->getName();
1235  res=true;
1236  }else {
1237  std::stringstream msg;
1238  msg << "Trying to setup Damping of unknown type: " << type;
1239  console.Error() << msg.str() << "\n";
1240  throw std::runtime_error(msg.str());
1241  res=false;
1242  }
1243 
1244  // add to map
1245  if(res) {
1246  m_damping.insert(make_pair(damping_name,DG));
1247  m_damping[damping_name]->update();
1248  }
1249  return res;
1250 }
1251 
1256 template <class T>
1258 {
1259  console.XDebug() << "TSubLattice<T>::addBondedIG()\n";
1260  CVarMPIBuffer param_buffer(m_comm);
1261 
1262  // get params
1263  CBondedIGP param;
1264  param_buffer.receiveBroadcast(0);
1265  param.tag=param_buffer.pop_int();
1266  string name = param_buffer.pop_string();
1267  param.k=param_buffer.pop_double();
1268  param.rbreak=param_buffer.pop_double();
1269  param.m_scaling=static_cast<bool>(param_buffer.pop_int());
1270 
1271  console.XDebug()
1272  << "Got BondedIG parameters: " << param.tag
1273  << " " << name.c_str() << " "
1274  << param.k << " " << param.rbreak << "\n";
1275  // setup InteractionGroup
1278 
1279  // set unbreakable if rbeak<0
1280  if(param.rbreak<0){
1281  B_PIS->setUnbreakable(true);
1282  console.XDebug() << "set bpis unbreakable\"n";
1283  }
1284 
1285  vector<int> vi(2,-1);
1286  for(size_t i=0;i<m_temp_conn[param.tag].size();i+=2)
1287  {
1288  vi[0] = (m_temp_conn[param.tag][i]);
1289  vi[1] = (m_temp_conn[param.tag][i+1]);
1290  B_PIS->tryInsert(vi);
1291  }
1292 
1293  // add InteractionGroup to map
1294  m_bpis.insert(make_pair(name,B_PIS));
1295 
1296  console.XDebug() << "end TSubLattice<T>::addBondedIG()\n";
1297 }
1298 
1303 template <class T>
1305 {
1306  console.XDebug() << "TSubLattice<T>::addCappedBondedIG()\n";
1307  CVarMPIBuffer param_buffer(m_comm);
1308 
1309  // get params
1310  param_buffer.receiveBroadcast(0);
1311  int tag=param_buffer.pop_int();
1312  string name = param_buffer.pop_string();
1313  double k=param_buffer.pop_double();
1314  double rbreak=param_buffer.pop_double();
1315  double maxforce=param_buffer.pop_double();
1316 
1317  console.XDebug()
1318  << "Got CappedBondedIG parameters: " << tag
1319  << " " << name.c_str() << " "
1320  << k << " " << rbreak << " " << maxforce << "\n";
1321  // setup InteractionGroup
1322  CCappedBondedIGP param;
1323  param.k=k;
1324  param.rbreak=rbreak;
1325  param.tag = tag;
1326  param.m_force_limit=maxforce;
1329 
1330  // set unbreakable if rbeak<0
1331  if(rbreak<0){
1332  B_PIS->setUnbreakable(true);
1333  console.XDebug() << "set bpis unbreakable\"n";
1334  }
1335  // recv broadcast connection data
1336  /*console.XDebug()
1337  << "rank=" << m_tml_comm.rank()
1338  << "TSubLattice<T>::addCappedBondedIG(): receiving conn_data.\n";
1339 
1340  vector<int> conn_data;
1341  m_tml_comm.recv_broadcast_cont(conn_data,0);
1342  console.XDebug()
1343  << "rank=" << m_tml_comm.rank()
1344  << "TSubLattice<T>::addBondedIG(): conn_data.size()="
1345  << conn_data.size() << "\n";
1346  */
1347  vector<int> vi(2,-1);
1348  for(size_t i=0;i<m_temp_conn[tag].size();i+=2)
1349  {
1350  vi[0] = (m_temp_conn[tag][i]);
1351  vi[1] = (m_temp_conn[tag][i+1]);
1352  B_PIS->tryInsert(vi);
1353  }
1354 
1355  // add InteractionGroup to map
1356  m_bpis.insert(make_pair(name,B_PIS));
1357 
1358  console.XDebug() << "end TSubLattice<T>::addCappedBondedIG()\n";
1359 }
1360 
1361 template <class T>
1363 {
1364  console.Error() << "TSubLattice<T>::addRotBondedIG() => trying to add rotational bonded IG to nonrotational model\n";
1365 }
1366 
1367 template <class T>
1369 {
1370  console.Error() << "TSubLattice<T>::addRotThermBondedIG() => trying to add rotational thermal bonded IG to nonrotational model\n";
1371 }
1372 
1377 template <class T>
1379 {
1380  console.XDebug() << "TSubLattice<T>::addShortBondedIG()\n";
1381  CVarMPIBuffer param_buffer(m_comm);
1382 
1383  // get params
1384  param_buffer.receiveBroadcast(0);
1385  int tag=param_buffer.pop_int();
1386  string name = param_buffer.pop_string();
1387  double k=param_buffer.pop_double();
1388  double rbreak=param_buffer.pop_double();
1389 
1390  console.XDebug()
1391  << "Got ShortBondedIG parameters: " << tag
1392  << " " << name.c_str() << " "
1393  << k << " " << rbreak << "\n";
1394  // setup InteractionGroup
1395  CBondedIGP param;
1396  param.k=k;
1397  param.rbreak=rbreak;
1398  param.tag = tag;
1401 
1402  // recv broadcast connection data
1403  /*console.XDebug()
1404  << "rank=" << m_tml_comm.rank()
1405  << "TSubLattice<T>::addShortBondedIG(): receiving conn_data.\n";
1406 
1407  vector<int> conn_data;
1408  m_tml_comm.recv_broadcast_cont(conn_data,0);
1409  console.XDebug()
1410  << "rank=" << m_tml_comm.rank()
1411  << "TSubLattice<T>::addShortBondedIG(): conn_data.size()="
1412  << conn_data.size() << "\n";*/
1413 
1414  vector<int> vi(2,-1);
1415  for(size_t i=0;i<m_temp_conn[param.tag].size();i+=2)
1416  {
1417  vi[0] = (m_temp_conn[param.tag][i]);
1418  vi[1] = (m_temp_conn[param.tag][i+1]);
1419  B_PIS->tryInsert(vi);
1420  }
1421 
1422  // add InteractionGroup to map
1423  m_bpis.insert(make_pair(name,B_PIS));
1424 
1425  console.XDebug() << "end TSubLattice<T>::addShortBondedIG()\n";
1426 }
1427 
1433 template <class T>
1435 {
1436  console.XDebug() << "TSubLattice<T>::addExIG()\n";
1437  CVarMPIBuffer pbuffer(m_comm);
1438 
1439  // get params
1440  pbuffer.receiveBroadcast(0);
1441  string s1 = pbuffer.pop_string();
1442  string s2 = pbuffer.pop_string();
1443 
1444  //console.XDebug()<< s1.c_str() << " " << s2.c_str() << "\n";
1445  map<string,AParallelInteractionStorage*>::iterator bonded_ig=m_bpis.find(s1);
1446  map<string,AParallelInteractionStorage*>::iterator dynamic_ig=m_dpis.find(s2);
1447  if((bonded_ig!=m_bpis.end())&&(dynamic_ig!=m_dpis.end()))
1448  {
1449  // map iterators point to [key,value] pairs, therefore it->second
1450  // is the pointer to the PIS here
1451  dynamic_ig->second->addExIG(bonded_ig->second);
1452  }
1453  else
1454  {
1455  console.Error() << "TSubLattice<T>::setExIG() - nonexisting interaction group \n";
1456  }
1457 
1458  console.XDebug() << "end TSubLattice<T>::addExIG()\n";
1459 }
1460 
1466 template <class T>
1468 {
1469  console.XDebug() << "TSubLattice<T>::removeIG()\n";
1470  CVarMPIBuffer pbuffer(m_comm);
1471  bool found=false;
1472 
1473  // get params
1474  pbuffer.receiveBroadcast(0);
1475  string igname = pbuffer.pop_string();
1476  // look for name in map of non-bondend particle pair interactions
1477  map<string,AParallelInteractionStorage*>::iterator iter=m_dpis.find(igname);
1478  // if found, remove interaction
1479  if(iter!=m_dpis.end()){
1480  found=true;
1481  delete m_dpis[igname];
1482  m_dpis.erase(iter);
1483  } else {
1484  // if not found, look in unbonded wall interactions
1485  typename map<string,AWallInteractionGroup<T>*>::iterator it2=m_WIG.find(igname);
1486  if(it2!=m_WIG.end()){
1487  found=true;
1488  delete m_WIG[igname];
1489  m_WIG.erase(it2);
1490  }
1491  }
1492 
1493  if(!found) {
1494  console.Error() << "TSubLattice<T>::removeIG() - nonexisting interaction group - ignore removal\n";
1495  }
1496 }
1497 
1498 
1502 template <class T>
1504 {
1505  console.XDebug() << "TSubLattice<T>::exchangePos() \n" ;
1506 
1507  m_ppa->exchange(&T::getExchangeValues,&T::setExchangeValues);
1508 
1509  console.XDebug() << "end TSubLattice<T>::exchangePos()\n" ;
1510 }
1511 
1515 template <class T>
1517 {
1518  console.XDebug() << "TSubLattice<T>::zeroForces()\n";
1519 
1520  // particles
1521  m_ppa->forAllParticles(&T::zeroForce);
1522  // trimeshes
1523  for(map<string,TriMesh*>::iterator iter=m_mesh.begin();
1524  iter!=m_mesh.end();
1525  iter++){
1526  (iter->second)->zeroForces();
1527  }
1528 
1529  // 2d meshes
1530  for(map<string,Mesh2D*>::iterator iter=m_mesh2d.begin();
1531  iter!=m_mesh2d.end();
1532  iter++){
1533  (iter->second)->zeroForces();
1534  }
1535  // walls
1536  for(typename map<string,CWall*>::iterator iter=m_walls.begin();
1537  iter!=m_walls.end();
1538  iter++)
1539  {
1540  (iter->second)->zeroForce();
1541  }
1542  console.XDebug() << "end TSubLattice<T>::zeroForces() \n";
1543 }
1544 
1551 template <class T>
1553 {
1554  console.XDebug() << "TSubLattice<T>::calcForces() \n";
1555 
1556  // the walls
1557  for(typename map<string,AWallInteractionGroup<T>*>::iterator it=m_WIG.begin();it!=m_WIG.end();it++)
1558  {
1559  (it->second)->calcForces();
1560  }
1561  // single particle IGs
1562  for(
1563  typename NameIGroupMap::iterator siter=this->m_singleParticleInteractions.begin();
1564  siter != m_singleParticleInteractions.end();
1565  siter++
1566  )
1567  {
1568  (siter->second)->calcForces();
1569  }
1570  // dynamically created IGs
1571  for(typename map<string,AParallelInteractionStorage*>::iterator iter=m_dpis.begin();iter!=m_dpis.end();iter++)
1572  {
1573  (iter->second)->calcForces();
1574  }
1575  // bonded IGs
1576  for(typename map<string,AParallelInteractionStorage*>::iterator iter=m_bpis.begin();iter!=m_bpis.end();iter++)
1577  {
1578  (iter->second)->calcForces();
1579  }
1580  // last, but not least - damping
1581  for(typename map<string,AParallelInteractionStorage*>::iterator iter=m_damping.begin();iter!=m_damping.end();iter++)
1582  {
1583  (iter->second)->calcForces();
1584  }
1585 
1586  console.XDebug() << "end TSubLattice<T>::calcForces() \n";
1587 }
1588 
1595 template <class T>
1597 {
1598  m_dt = dt;
1599  console.XDebug() << "TSubLattice<T>::setTimeStepSize() \n";
1600 
1601  // the walls
1602  for(typename map<string,AWallInteractionGroup<T>*>::iterator it=m_WIG.begin();it!=m_WIG.end();it++)
1603  {
1604  (it->second)->setTimeStepSize(dt);
1605  }
1606  // single particle IGs
1607  for(
1608  typename NameIGroupMap::iterator siter=this->m_singleParticleInteractions.begin();
1609  siter != m_singleParticleInteractions.end();
1610  siter++
1611  )
1612  {
1613  (siter->second)->setTimeStepSize(dt);
1614  }
1615  // dynamically created IGs
1616  for(typename map<string,AParallelInteractionStorage*>::iterator iter=m_dpis.begin();iter!=m_dpis.end();iter++)
1617  {
1618  (iter->second)->setTimeStepSize(dt);
1619  }
1620  // bonded IGs
1621  for(typename map<string,AParallelInteractionStorage*>::iterator iter=m_bpis.begin();iter!=m_bpis.end();iter++)
1622  {
1623  (iter->second)->setTimeStepSize(dt);
1624  }
1625  // last, but not least - damping
1626  for(typename map<string,AParallelInteractionStorage*>::iterator iter=m_damping.begin();iter!=m_damping.end();iter++)
1627  {
1628  (iter->second)->setTimeStepSize(dt);
1629  }
1630 
1631  console.XDebug() << "end TSubLattice<T>::setTimeStepSize() \n";
1632 }
1633 
1639 template <class T>
1641 {
1642  console.XDebug() << "TSubLattice<T>::integrate \n";
1643  m_ppa->forAllParticles(&T::integrate,dt);
1644  m_ppa->forAllParticles(&T::rescale) ;
1645  console.XDebug() << "end TSubLattice<T>::integrate \n";
1646 }
1647 
1651 template <class T>
1653 {
1654  zeroForces();
1655  calcForces();
1656  integrate(m_dt);
1657 
1658  if (this->getParticleType() == "RotTherm")
1659  {
1660  this->oneStepTherm();
1661  }
1662 }
1663 
1667 template <class T>
1669 {
1670  zeroHeat(); // ???? combine?
1671  calcHeatFrict();
1672  calcHeatTrans();
1673  integrateTherm(m_dt);
1674  thermExpansion() ;
1675 }
1676 
1682 template <class T>
1684 {
1685  console.XDebug() << "TSubLattice<T>::integrateTherm \n";
1686  m_ppa->forAllParticles(&T::integrateTherm,dt);
1687 // m_ppa->forAllParticles(&T::rescale) ;
1688  console.XDebug() << "end TSubLattice<T>::integrateTherm \n";
1689 }
1690 
1691 template <class T>
1693 {
1694  console.XDebug() << "TSubLattice<T>::thermExpansion() \n";
1695  m_ppa->forAllParticles(&T::thermExpansion);
1696 // m_ppa->forAllParticles(&T::rescale) ;
1697  console.XDebug() << "end TSubLattice<T>::thermExpansion() \n";
1698 }
1699 
1703 template <class T>
1705 {
1706  console.XDebug() << "TSubLattice<T>::zeroHeat()\n";
1707 
1708  // particles
1709  m_ppa->forAllParticles(&T::zeroHeat);
1710 
1711 /*
1712 // walls
1713  for(typename vector<AWallInteractionGroup<T>*>::iterator iter=m_WIG.begin();iter!=m_WIG.end();iter++)
1714  {
1715  (*iter)->zeroForce();
1716  }
1717 */
1718  console.XDebug() << "end TSubLattice<T>::zeroHeat() \n";
1719 }
1720 
1727 template <class T>
1729 {
1730  console.XDebug() << "TSubLattice<T>::calcHeatFrict() \n";
1731 
1732  // dynamically created IGs
1733  for(
1734  typename map<string,AParallelInteractionStorage*>::iterator iter=m_dpis.begin();
1735  iter!=m_dpis.end();
1736  iter++
1737  )
1738  {
1739  (iter->second)->calcHeatFrict();
1740  }
1741 
1742  console.XDebug() << "end TSubLattice<T>::calcHeatFrict() \n";
1743 }
1744 
1745 template <class T>
1747 {
1748  console.XDebug() << "TSubLattice<T>::calcHeatTrans() \n";
1749 
1750 
1751  // dynamically created IGs
1752  for(
1753  typename map<string,AParallelInteractionStorage*>::iterator iter=m_dpis.begin();
1754  iter!=m_dpis.end();
1755  iter++
1756  )
1757  {
1758  (iter->second)->calcHeatTrans();
1759  }
1760  // bonded IGs
1761  for(
1762  typename map<string,AParallelInteractionStorage*>::iterator iter=m_bpis.begin();
1763  iter!=m_bpis.end();
1764  iter++
1765  )
1766  {
1767  (iter->second)->calcHeatTrans();
1768  }
1769 
1770  console.XDebug() << "end TSubLattice<T>::calcHeatTrans() \n";
1771 }
1772 
1776 template <class T>
1778 {
1779  m_ppa->rebuild();
1780 }
1781 
1785 template <class T>
1787 {
1788  CMPIBarrier barrier(m_worker_comm);
1789  m_pTimers->start("RebuildInteractions");
1790  m_pTimers->resume("NeighbourSearch");
1791  for(typename map<string,AParallelInteractionStorage*>::iterator iter=m_bpis.begin();
1792  iter!=m_bpis.end();
1793  iter++)
1794  {
1795  console.Debug() << "exchg & rebuild BPIS " << iter->first << " at node " << m_rank << "\n";
1796  (iter->second)->exchange();
1797  (iter->second)->rebuild();
1798  }
1799 
1800  for(typename map<string,AParallelInteractionStorage*>::iterator iter=m_dpis.begin();
1801  iter!=m_dpis.end();
1802  iter++)
1803  {
1804  console.Debug() << "exchg & rebuild DPIS " << iter->first << " at node " << m_rank << "\n";
1805  (iter->second)->exchange();
1806  m_pTimers->pause("RebuildInteractions");
1807  m_pTimers->pause("NeighbourSearch");
1808  barrier.wait("dpis::exchange");
1809  m_pTimers->resume("RebuildInteractions");
1810  m_pTimers->resume("NeighbourSearch");
1811  (iter->second)->rebuild();
1812  }
1813  resetDisplacements();
1814  m_pTimers->stop("RebuildInteractions");
1815 }
1816 
1820 template <class T>
1822 {
1823  console.Debug() << "CSubLattice<T>::searchNeighbors()\n";
1824  CMPIBarrier barrier(getWorkerComm());
1825  m_pTimers->start("NeighbourSearch");
1826  m_pTimers->start("RebuildParticleArray");
1827  rebuildParticleArray();
1828  m_pTimers->stop("RebuildParticleArray");
1829  m_pTimers->pause("NeighbourSearch");
1830  barrier.wait("PPA rebuild");
1831  rebuildInteractions();
1832  m_pTimers->stop("NeighbourSearch");
1833  console.Debug() << "end CSubLattice<T>::searchNeighbors()\n";
1834 }
1835 
1841 template <class T>
1843 {
1844  console.Debug() << "updateInteractions() \n";
1845  console.Debug() << "m_ppa->getTimeStamp() " << m_ppa->getTimeStamp() << " m_last_ns " << m_last_ns << "\n";
1846  bool need_update=false;
1847 
1848  m_pTimers->start("UpdateBondedInteractions");
1849  for(typename map<string,AParallelInteractionStorage*>::iterator iter=m_bpis.begin();
1850  iter!=m_bpis.end();
1851  iter++)
1852  {
1853  bool n=(iter->second)->update();
1854  need_update=need_update || n;
1855  }
1856  m_pTimers->stop("UpdateBondedInteractions");
1857  if((m_ppa->getTimeStamp() > m_last_ns) || need_update)
1858  {
1859  m_pTimers->start("UpdateDynamicInteractions");
1860  for(typename map<string,AParallelInteractionStorage*>::iterator iter=m_dpis.begin();
1861  iter!=m_dpis.end();
1862  iter++)
1863  {
1864  bool n=(iter->second)->update();
1865  need_update=need_update || n;
1866  }
1867  m_pTimers->stop("UpdateDynamicInteractions");
1868  for(typename map<string,AWallInteractionGroup<T>*>::iterator it=m_WIG.begin();
1869  it!=m_WIG.end();
1870  it++)
1871  {
1872  (it->second)->Update(m_ppa);
1873  }
1874  for(typename map<string,AParallelInteractionStorage*>::iterator iter=m_damping.begin();
1875  iter!=m_damping.end();
1876  iter++){
1877  (iter->second)->update();
1878  }
1879  m_last_ns=m_ppa->getTimeStamp();
1880  }
1881 
1882  console.Debug() << "end TSubLattice<T>::updateInteractions()\n";
1883 }
1884 
1889 template <class T>
1891 {
1892  console.Debug() << "TSubLattice<T>::checkNeighbors()\n";
1893  CMPISGBufferLeaf buffer(m_comm,0,8);
1894  double mdsqr=0; // squared max. displacement
1895  double alpha=0.5*m_alpha;
1896  double srsqr=alpha*alpha; // squared search range
1897  vector<Vec3> displ; // displacements
1898  int res; // result 0/1
1899 
1900  // --- particles ---
1901  // get displacement data
1902  m_ppa->forAllParticlesGet(displ,&T::getDisplacement);
1903 
1904  // find maximum particle displacement
1905  vector<Vec3>::iterator it=displ.begin();
1906  while((it!=displ.end())&&(mdsqr<srsqr))
1907  {
1908  double sqdisp=(*it)*(*it);
1909  mdsqr = ((mdsqr < sqdisp) ? sqdisp : mdsqr);
1910  it++;
1911  //console.XDebug() << "sq. disp: " << sqdisp << "\n";
1912  }
1913  console.XDebug() << "max squared displacement " << mdsqr << "alpha^2 = " << srsqr << "\n";
1914  if (mdsqr>srsqr){
1915  res=1;
1916  } else {
1917  res=0;
1918  }
1919 
1920  // --- mesh ---
1921  // only needed if res==0
1922  if(res==0){
1923  for(map<string,TriMesh*>::iterator iter=m_mesh.begin();
1924  iter!=m_mesh.end();
1925  iter++){
1926  //std::cerr << "check mesh " << iter->first << std::endl;
1927  if(iter->second->hasMovedBy(alpha)){
1928  res=1;
1929  }
1930  }
1931  }
1932  buffer.append(res);
1933  buffer.send();
1934  console.Debug() << "end TSubLattice<T>::checkNeighbors()\n";
1935 }
1936 
1937 
1941 template <class T>
1943 {
1944  console.Debug() << "slave " << m_rank << " resetDisplacements()\n";
1945  m_ppa->forAllParticles(&T::resetDisplacement);
1946  for(map<string,TriMesh*>::iterator iter=m_mesh.begin();
1947  iter!=m_mesh.end();
1948  iter++){
1949  iter->second->resetCurrentDisplacement();
1950  }
1951  console.Debug() << "slave " << m_rank << " end resetDisplacements()\n";
1952 }
1953 
1958 template <class T>
1960 {
1961  console.Debug() << "TSubLattice<T>::moveParticleTo()\n";
1962  CVarMPIBuffer buffer(m_comm);
1963 
1964  buffer.receiveBroadcast(0); // get data from master
1965  int tag=buffer.pop_int();
1966  Vec3 mv=buffer.pop_vector();
1967  m_ppa->forParticleTag(tag,(void (T::*)(Vec3))(&T::moveToRel),mv);
1968  console.Debug() << "end TSubLattice<T>::moveParticleTo()\n";
1969 }
1970 
1975 template <class T>
1977 {
1978  console.Debug() << "TSubLattice<T>::moveTaggedParticlesBy()\n";
1979  CVarMPIBuffer buffer(m_comm);
1980 
1981  buffer.receiveBroadcast(0); // get data from master
1982  const int tag = buffer.pop_int();
1983  const Vec3 dx = buffer.pop_vector();
1984  m_ppa->forParticleTag(tag, (void (T::*)(Vec3))(&T::moveBy),dx);
1985  console.Debug() << "end TSubLattice<T>::moveTaggedParticlesBy()\n";
1986 }
1987 
1988 
1989 template <class T>
1990 void TSubLattice<T>::moveSingleParticleTo(int particleId, const Vec3 &posn)
1991 {
1992  m_ppa->forParticle(particleId, (void (T::*)(Vec3))(&T::moveTo), posn);
1993 }
1994 
1999 template <class T>
2001 {
2002  console.Debug() << "TSubLattice<T>::moveSingleNode()\n";
2003  CVarMPIBuffer buffer(m_comm);
2004 
2005  buffer.receiveBroadcast(0); // get data from master
2006  string name=string(buffer.pop_string());
2007  int id=buffer.pop_int();
2008  Vec3 disp=buffer.pop_vector();
2009 
2010  console.XDebug() << "name :" << name << " id : " << id << " disp " << disp << "\n";
2011 
2012  map<string,TriMesh*>::iterator tm=m_mesh.find(name);
2013  if (tm!=m_mesh.end()){
2014  (tm->second)->moveNode(id,disp);
2015  } else {
2016  map<string,Mesh2D*>::iterator m2d=m_mesh2d.find(name);
2017  if(m2d!=m_mesh2d.end()){
2018  (m2d->second)->moveNode(id,disp);
2019  }
2020  }
2021  console.Debug() << "end TSubLattice<T>::moveSingleNode()\n";
2022 }
2023 
2028 template <class T>
2030 {
2031  console.Error() << "TSubLattice<T>::moveTaggedNodes() NOT IMPLEMENTED\n";
2032  throw
2033  std::runtime_error(
2034  "TSubLattice<T>::moveTaggedNodes() NOT IMPLEMENTED\n"
2035  );
2036 #if 0
2037  CVarMPIBuffer buffer(m_comm);
2038 
2039  buffer.receiveBroadcast(0); // get data from master
2040  string name=string(buffer.pop_string());
2041  int tag=buffer.pop_int();
2042  Vec3 disp=buffer.pop_vector();
2043 #endif
2044 }
2045 
2052 template <class T>
2053 void TSubLattice<T>::translateMeshBy(const std::string &meshName, const Vec3 &translation)
2054 {
2055  map<string,TriMesh*>::iterator tm=m_mesh.find(meshName);
2056  if (tm != m_mesh.end()){
2057  (tm->second)->translateBy(translation);
2058  }
2059  map<string,Mesh2D*>::iterator m2d=m_mesh2d.find(meshName);
2060  if(m2d!=m_mesh2d.end()){
2061  (m2d->second)->translateBy(translation);
2062  }
2063 }
2064 
2065 template <class T>
2066 std::pair<double, int> TSubLattice<T>::findParticleNearestTo(const Vec3 &pt)
2067 {
2068  console.Debug() << "TSubLattice<T>::findParticleNearestTo: enter\n";
2069  const T *pClosest = NULL;
2070  double minDistSqrd = std::numeric_limits<double>::max();
2071 
2072  typename ParticleArray::ParticleIterator it =
2073  m_ppa->getInnerParticleIterator();
2074  while (it.hasNext())
2075  {
2076  const T &p = it.next();
2077  const double distSqrd = (pt - p.getPos()).norm2();
2078  if (distSqrd < minDistSqrd)
2079  {
2080  minDistSqrd = distSqrd;
2081  pClosest = &p;
2082  }
2083  }
2084  console.Debug() << "TSubLattice<T>::findParticleNearestTo: exit\n";
2085  return
2086  (
2087  (pClosest != NULL)
2088  ?
2089  std::make_pair(sqrt(minDistSqrd), pClosest->getID())
2090  :
2091  std::make_pair(std::numeric_limits<double>::max(), -1)
2092  );
2093 }
2094 
2098 template <class T>
2099 std::pair<int, Vec3> TSubLattice<T>::getParticlePosn(int particleId)
2100 {
2101  const T *particle = NULL;
2102  typename ParticleArray::ParticleIterator it =
2103  m_ppa->getInnerParticleIterator();
2104  while (it.hasNext())
2105  {
2106  const T &p = it.next();
2107  if (p.getID() == particleId)
2108  {
2109  particle = &p;
2110  }
2111  }
2112  if (particle != NULL)
2113  {
2114  return std::make_pair(particleId, particle->getPos());
2115  }
2116  return std::make_pair(-1,Vec3::ZERO);
2117 }
2118 
2122 template <class T>
2123 void TSubLattice<T>::getParticleData(const IdVector &particleIdVector)
2124 {
2125  console.Debug()
2126  << "TSubLattice<T>::getParticleData: enter\n";
2127  typedef std::set<int> IdSet;
2128  typedef std::vector<T> ParticleVector;
2129 
2130  ParticleVector particleVector;
2131  typename ParticleArray::ParticleIterator it =
2132  m_ppa->getInnerParticleIterator();
2133  if (particleIdVector.size() > 0)
2134  {
2135  IdSet idSet(particleIdVector.begin(), particleIdVector.end());
2136  console.Debug()
2137  << "TSubLattice<T>::getParticleData: iterating over particles\n";
2138  while (it.hasNext())
2139  {
2140  const T &p = it.next();
2141  if (idSet.find(p.getID()) != idSet.end())
2142  {
2143  particleVector.push_back(p);
2144  }
2145  }
2146  }
2147  else
2148  {
2149  m_ppa->getAllInnerParticles(particleVector);
2150  }
2151  console.Debug()
2152  << "TSubLattice<T>::getParticleData:"
2153  << " sending particle data of size " << particleVector.size() << "\n";
2154  m_tml_comm.send_gather_packed(particleVector, 0);
2155  console.Debug()
2156  << "TSubLattice<T>::getParticleData: exit\n";
2157 }
2158 
2162 template <class T>
2164 {
2165  console.Debug() << "TSubLattice<T>::tagParticleNearestTo()\n";
2166  CVarMPIBuffer buffer(m_comm);
2167 
2168  buffer.receiveBroadcast(0); // get data from master
2169  int tag=buffer.pop_int();
2170  int mask=buffer.pop_int();
2171  Vec3 pos=buffer.pop_vector();
2172 
2173  // warning - this is ugly
2174  T* part_ptr=m_ppa->getParticlePtrByPosition(pos);
2175  if(part_ptr!=NULL){
2176  int old_tag=part_ptr->getTag();
2177  int new_tag=(old_tag & (~mask)) | (tag & mask);
2178  part_ptr->setTag(new_tag);
2179 
2180  cout << "pos, realpos: " << pos << " " << part_ptr->getPos() << " old tag, new tag " << old_tag << " " << part_ptr->getTag() << endl;
2181  }
2182  console.Debug() << "end TSubLattice<T>::tagParticleNearestTo()\n";
2183 }
2184 
2189 template <class T>
2191 {
2192  console.Debug() << "TSubLattice<T>::setParticleNonDynamic()\n";
2193  CVarMPIBuffer buffer(m_comm);
2194 
2195  buffer.receiveBroadcast(0); // get data from master
2196  int tag=buffer.pop_int();
2197  m_ppa->forParticleTag(tag,(void (T::*)())(&T::setNonDynamic));
2198  console.Debug() << "end TSubLattice<T>::setParticleNonDynamic()\n";
2199 }
2200 
2205 template <class T>
2207 {
2208  console.Debug() << "TSubLattice<T>::setParticleNonRot()\n";
2209  CVarMPIBuffer buffer(m_comm);
2210 
2211  buffer.receiveBroadcast(0); // get data from master
2212  int tag=buffer.pop_int();
2213  m_ppa->forParticleTag(tag,(void (T::*)())(&T::setNonDynamicRot));
2214  console.Debug() << "end TSubLattice<T>::setParticleNonRot()\n";
2215 }
2216 
2221 template <class T>
2223 {
2224  console.Debug() << "TSubLattice<T>::setParticleNonTrans()\n";
2225  CVarMPIBuffer buffer(m_comm);
2226 
2227  buffer.receiveBroadcast(0); // get data from master
2228  int tag=buffer.pop_int();
2229  m_ppa->forParticleTag(tag,(void (T::*)())(&T::setNonDynamicLinear));
2230  console.Debug() << "end TSubLattice<T>::setParticleNonTrans()\n";
2231 }
2232 
2236 template <class T>
2238 {
2239  console.Debug() << "TSubLattice<T>::setTaggedParticleVel()\n";
2240  CVarMPIBuffer buffer(m_comm);
2241 
2242  buffer.receiveBroadcast(0); // get data from master
2243  int tag=buffer.pop_int();
2244  Vec3 v=buffer.pop_vector();
2245  m_ppa->forParticleTag(tag,(void (T::*)(Vec3))(&T::setVel),v);
2246  console.XDebug() << "end TSubLattice<T>::setTaggedParticleVel()\n";
2247 }
2248 
2252 template <class T>
2254 {
2255  console.XDebug() << "TSubLattice<T>::moveWallBy()\n";
2256  CVarMPIBuffer buffer(m_comm);
2257 
2258  buffer.receiveBroadcast(0); // get data from master
2259  string wname=buffer.pop_string();
2260  Vec3 mv=buffer.pop_vector();
2261  typename map<string,CWall*>::iterator iter=m_walls.find(wname);
2262  if(iter!=m_walls.end())
2263  {
2264  (iter->second)->moveBy(mv);
2265  }
2266 }
2267 
2271 template <class T>
2273 {
2274  console.XDebug() << "TSubLattice<T>::setWallNormal()\n";
2275  CVarMPIBuffer buffer(m_comm);
2276 
2277  buffer.receiveBroadcast(0); // get data from master
2278  string wname=buffer.pop_string();
2279  Vec3 wn=buffer.pop_vector();
2280  typename map<string,CWall*>::iterator iter=m_walls.find(wname);
2281  if(iter!=m_walls.end())
2282  {
2283  (iter->second)->setNormal(wn);
2284  }
2285 }
2286 
2290 template <class T>
2292 {
2293  console.XDebug() << "TSubLattice<T>::applyForceToWall()\n";
2294  CVarMPIBuffer buffer(m_comm);
2295 
2296  buffer.receiveBroadcast(0); // get data from master
2297  string wname=buffer.pop_string();
2298  Vec3 f=buffer.pop_vector();
2299  typename map<string,AWallInteractionGroup<T>*>::iterator iter=m_WIG.find(wname);
2300  if(iter!=m_WIG.end())
2301  {
2302  (iter->second)->applyForce(f);
2303  }
2304 }
2305 
2310 template <class T>
2312 {
2313  console.XDebug() << "TSubLattice<T>::setVelocityOfWall()\n";
2314  CVarMPIBuffer buffer(m_comm);
2315 
2316  buffer.receiveBroadcast(0); // get data from master
2317  string wname=buffer.pop_string();
2318  Vec3 v=buffer.pop_vector();
2319  typename map<string,AWallInteractionGroup<T>*>::iterator iter=m_WIG.find(wname);
2320  if(iter!=m_WIG.end())
2321  {
2322  (iter->second)->setVelocity(v);
2323  }
2324 }
2325 
2329 template <class T>
2331 {
2332  console.Debug() << "TSubLattice<T>::setParticleVelocity()\n";
2333  CVarMPIBuffer buffer(m_comm);
2334 
2335  buffer.receiveBroadcast(0); // get data from master
2336  int id=buffer.pop_int();
2337  Vec3 mv=buffer.pop_vector();
2338  m_ppa->forParticle(id,(void (T::*)(Vec3))(&T::setVel),mv);
2339  console.XDebug() << "end TSubLattice<T>::setParticleVelocity()\n";
2340 }
2341 
2345 template <class T>
2347 {
2348  console.Debug() << "TSubLattice<T>::setParticleDensity()\n";
2349  CVarMPIBuffer buffer(m_comm);
2350 
2351  buffer.receiveBroadcast(0); // get data from master
2352  int tag=buffer.pop_int();
2353  int mask=buffer.pop_int();
2354  double rho=buffer.pop_double();
2355  m_ppa->forParticleTagMask(tag,mask,(void (T::*)(double))(&T::setDensity),rho);
2356  console.XDebug() << "end TSubLattice<T>::setParticleVelocity()\n";
2357 }
2358 
2359 
2363 template <class T>
2365 {
2366  console.Debug() << "TSubLattice<T>::sendDataToMaster()\n";
2367  vector<Vec3> positions;
2368  vector<double> radii;
2369  vector<int> ids;
2370 
2371  m_ppa->forAllParticlesGet(positions,(Vec3 (T::*)() const)(&T::getPos));
2372  m_ppa->forAllParticlesGet(radii,(double (T::*)() const)(&T::getRad));
2373  m_ppa->forAllParticlesGet(ids,(int (T::*)() const)(&T::getID));
2374 
2375  m_tml_comm.send_gather(positions,0);
2376  m_tml_comm.send_gather(radii,0);
2377  m_tml_comm.send_gather(ids,0);
2378 
2379  console.Debug() << "end TSubLattice<T>::sendDataToMaster()\n";
2380 }
2381 
2385 template <class T>
2387 {
2388  console.Debug()<<"TSubLattice<T>::countParticles()\n";
2389  CMPIVarSGBufferLeaf buffer(m_comm,0);
2390  //-- pack particles into buffer
2391  buffer.append(m_ppa->size());
2392  // send
2393  buffer.send();
2394 }
2395 
2399 template <class T>
2401 {
2402  cout<< "My Rank : " << m_rank << "\n" ;
2403  if(m_ppa!=NULL)
2404  {
2405  cout << *m_ppa << endl;
2406  }
2407 }
2408 
2409 template <class T>
2411 {
2412  cout << "Data: my rank : " << m_rank << "particles : \n" ;
2413  m_ppa->forAllParticles((void (T::*)())(&T::print));
2414 }
2415 
2416 template <class T>
2418 {
2419  console.Debug() << "time spent calculating force : " << forcetime << " sec\n";
2420  console.Debug() << "time spent communicating : " << commtime << " sec\n";
2421  console.Debug() << "time spent packing : " << packtime << " sec\n";
2422  console.Debug() << "time spent unpacking : " << unpacktime << " sec\n";
2423 }
2424 
2425 //-------------- FIELD FUNCTIONS ----------------
2426 
2427 
2428 
2432 template <class T>
2434 {
2435  // cout << "TSubLattice<T>::addScalarParticleField\n";
2436  string fieldname;
2437  int id,is_tagged;
2438 
2439  m_tml_comm.recv_broadcast_cont(fieldname,0);
2440  //cout << "recvd. fieldname: " << fieldname << "\n";
2441  m_tml_comm.recv_broadcast(id,0);
2442  //cout << "recvd. id: " << id << "\n";
2443  m_tml_comm.recv_broadcast(is_tagged,0);
2444  //cout << "recvd. is_tagged: " << is_tagged << "\n";
2445 
2446  typename T::ScalarFieldFunction rdf=T::getScalarFieldFunction(fieldname);
2447  ScalarParticleFieldSlave<T> *new_spfs;
2448  if(is_tagged==0)
2449  {
2450  new_spfs=new ScalarParticleFieldSlave<T>(&m_tml_comm,m_ppa,rdf);
2451  }
2452  else
2453  {
2454  int tag,mask;
2455  m_tml_comm.recv_broadcast(tag,0);
2456  console.XDebug() << "recvd. tag: " << tag << "\n";
2457  m_tml_comm.recv_broadcast(mask,0);
2458  console.XDebug() << "recvd. mask: " << mask << "\n";
2459  new_spfs=new ScalarParticleFieldSlaveTagged<T>(&m_tml_comm,m_ppa,rdf,tag,mask);
2460  }
2461  m_field_slaves.insert(make_pair(id,new_spfs));
2462 }
2463 
2467 template <class T>
2469 {
2470  console.XDebug() << "TSubLattice<T>::addVectorParticleField\n";
2471  string fieldname;
2472  int id,is_tagged;
2473 
2474  m_tml_comm.recv_broadcast_cont(fieldname,0);
2475  console.XDebug() << "recvd. fieldname: " << fieldname << "\n";
2476  m_tml_comm.recv_broadcast(id,0);
2477  console.XDebug() << "recvd. id: " << id << "\n";
2478  m_tml_comm.recv_broadcast(is_tagged,0);
2479  console.XDebug() << "recvd. is_tagged: " << is_tagged << "\n";
2480 
2481  typename T::VectorFieldFunction rdf=T::getVectorFieldFunction(fieldname);
2482  VectorParticleFieldSlave<T> *new_vpfs;
2483  if(is_tagged==0)
2484  {
2485  new_vpfs=new VectorParticleFieldSlave<T>(&m_tml_comm,m_ppa,rdf);
2486  }
2487  else
2488  {
2489  int tag,mask;
2490  m_tml_comm.recv_broadcast(tag,0);
2491  console.XDebug() << "recvd. tag: " << tag << "\n";
2492  m_tml_comm.recv_broadcast(mask,0);
2493  console.XDebug() << "recvd. mask: " << mask << "\n";
2494  new_vpfs=new VectorParticleFieldSlaveTagged<T>(&m_tml_comm,m_ppa,rdf,tag,mask);
2495  }
2496  m_field_slaves.insert(make_pair(id,new_vpfs));
2497 
2498  console.Debug() << "end TSubLattice<T>::addVectorParticleField\n";
2499 }
2500 
2501 
2505 template <class T>
2507 {
2508  console.XDebug() << "TSubLattice<T>::addScalarInteractionField\n";
2509  string fieldname;
2510  string igname;
2511  string igtype;
2512  int id,is_tagged,tag,mask,is_checked;
2513 
2514  m_tml_comm.recv_broadcast_cont(fieldname,0);
2515  console.XDebug() << "recvd. fieldname: " << fieldname << "\n";
2516  m_tml_comm.recv_broadcast(id,0);
2517  console.XDebug() << "recvd. id: " << id << "\n";
2518  m_tml_comm.recv_broadcast_cont(igname,0);
2519  console.XDebug() << "recvd. interaction group name: " << igname << "\n";
2520  m_tml_comm.recv_broadcast_cont(igtype,0);
2521  console.XDebug() << "recvd. interaction group name: " << igtype << "\n";
2522  m_tml_comm.recv_broadcast(is_tagged,0);
2523  console.XDebug() << "recvd. is_tagged: " << is_tagged << "\n";
2524 
2525  // get interaction group
2526  map<string,AParallelInteractionStorage*>::iterator it=m_dpis.find(igname);
2527  if(is_tagged==1)
2528  {
2529  m_tml_comm.recv_broadcast(tag,0);
2530  m_tml_comm.recv_broadcast(mask,0);
2531  }
2532  m_tml_comm.recv_broadcast(is_checked,0);
2533  console.XDebug() << "recvd. is_checked: " << is_checked << "\n";
2534 
2535  if(it!=m_dpis.end())
2536  {
2537  console.XDebug() << "found interaction group in dynamic\n";
2538  AFieldSlave* new_sifs;
2539  new_sifs=(it->second)->generateNewScalarFieldSlave(&m_tml_comm,fieldname,is_checked,is_tagged,tag,mask);
2540  m_field_slaves.insert(make_pair(id,new_sifs));
2541  }
2542  else
2543  {
2544  it=m_bpis.find(igname);
2545  if(it!=m_bpis.end()){
2546  console.XDebug() << "found interaction group in bonded\n";
2547  AFieldSlave* new_sifs;
2548  new_sifs=(it->second)->generateNewScalarFieldSlave(&m_tml_comm,fieldname,is_checked,is_tagged,tag,mask);
2549  m_field_slaves.insert(make_pair(id,new_sifs));
2550  }
2551  else // not in dynamic or bonded -> try damping
2552  {
2553  //typename map<string,CDampingGroup<T>*>::iterator it2=m_damping.find(igname);
2554  it=m_damping.find(igname);
2555  if(it!=m_damping.end()) // found it in damping
2556  {
2557  AFieldSlave* new_sifs;
2558  new_sifs=(it->second)->generateNewScalarFieldSlave(&m_tml_comm,fieldname,is_checked,is_tagged,tag,mask);
2559  m_field_slaves.insert(make_pair(id,new_sifs));
2560  }
2561  else // still not found -> unknown name -> error
2562  {
2563  cerr << "ERROR : unknown interaction group name in addScalarInteractionField " << endl;
2564  }
2565  }
2566  }
2567 
2568  console.XDebug() << "end TSubLattice<T>::addScalarInteractionField\n";
2569 }
2570 
2574 template <class T>
2576 {
2577  console.Debug() << "TSubLattice<T>::addVectorInteractionField\n";
2578  string fieldname;
2579  string igname;
2580  string igtype;
2581  int id,is_tagged,tag,mask,is_checked;
2582 
2583  m_tml_comm.recv_broadcast_cont(fieldname,0);
2584  console.XDebug() << "recvd. fieldname: " << fieldname << "\n";
2585  m_tml_comm.recv_broadcast(id,0);
2586  console.XDebug() << "recvd. id: " << id << "\n";
2587  m_tml_comm.recv_broadcast_cont(igname,0);
2588  console.XDebug() << "recvd. interaction group name: " << igname << "\n";
2589  m_tml_comm.recv_broadcast_cont(igtype,0);
2590  console.XDebug() << "recvd. interaction group type: " << igtype << "\n";
2591  m_tml_comm.recv_broadcast(is_tagged,0);
2592  console.XDebug() << "recvd. is_tagged: " << is_tagged << "\n";
2593 
2594  // get interaction group
2595  map<string,AParallelInteractionStorage*>::iterator it=m_dpis.find(igname);
2596  if(is_tagged==1)
2597  {
2598  m_tml_comm.recv_broadcast(tag,0);
2599  m_tml_comm.recv_broadcast(mask,0);
2600  }
2601  m_tml_comm.recv_broadcast(is_checked,0);
2602  console.XDebug() << "recvd. is_checked: " << is_checked << "\n";
2603 
2604  if(it!=m_dpis.end())
2605  {
2606  console.XDebug() << "found interaction group in dynamic\n";
2607  AFieldSlave* new_sifs;
2608  new_sifs=(it->second)->generateNewVectorFieldSlave(&m_tml_comm,fieldname,is_checked,is_tagged,tag,mask);
2609  if(new_sifs!=NULL){
2610  m_field_slaves.insert(make_pair(id,new_sifs));
2611  } else {
2612  console.Error()<<"ERROR: could not generate Field Slave for field " << fieldname << "\n";
2613  }
2614  }
2615  else
2616  {
2617  it=m_bpis.find(igname);
2618  if(it!=m_bpis.end()){
2619  console.XDebug() << "found interaction group in bonded\n";
2620  AFieldSlave* new_sifs;
2621  new_sifs=(it->second)->generateNewVectorFieldSlave(&m_tml_comm,fieldname,is_checked,is_tagged,tag,mask);
2622  m_field_slaves.insert(make_pair(id,new_sifs));
2623  }
2624  else // not in dynamic or bonded -> try damping
2625  {
2626  //typename map<string,CDampingGroup<T>*>::iterator it2=m_damping.find(igname);
2627  it=m_damping.find(igname);
2628  if(it!=m_damping.end()) // found it in damping
2629  {
2630  AFieldSlave* new_sifs;
2631  new_sifs=(it->second)->generateNewVectorFieldSlave(&m_tml_comm,fieldname,is_checked,is_tagged,tag,mask);
2632  m_field_slaves.insert(make_pair(id,new_sifs));
2633  }
2634  else // still not found -> unknown name -> error
2635  {
2636  cerr << "ERROR : unknown interaction group name in addScalarInteractionField " << endl;
2637  }
2638  }
2639  }
2640 
2641  console.Debug() << "end TSubLattice<T>::addVectorInteractionField\n";
2642 }
2643 
2648 template <class T>
2650 {
2651  console.Debug() << "TSubLattice<T>::addVectorTriangleField()\n";
2652  string fieldname;
2653  string meshname;
2654  int id;
2655 
2656  // receive params
2657  m_tml_comm.recv_broadcast_cont(fieldname,0);
2658  console.XDebug() << "recvd. fieldname: " << fieldname << "\n";
2659  m_tml_comm.recv_broadcast_cont(meshname,0);
2660  console.XDebug() << "recvd. meshname: " << meshname << "\n";
2661  m_tml_comm.recv_broadcast(id,0);
2662  console.XDebug() << "recvd. id: " << id << "\n";
2663 
2664  map<string,TriMesh*>::iterator tm=m_mesh.find(meshname);
2665  // if meshname is in trimesh map
2666  if (tm!=m_mesh.end()){
2667  // get reader function
2669  // check it
2670  if(rdf==NULL){
2671  console.Critical() << "NULL rdf !!!\n";
2672  }
2673  VectorTriangleFieldSlave* new_vfs=new VectorTriangleFieldSlave(&m_tml_comm,tm->second,rdf);
2674  m_field_slaves.insert(make_pair(id,new_vfs));
2675  } else {
2676  map<string,Mesh2D*>::iterator m2d=m_mesh2d.find(meshname);
2677  if(m2d!=m_mesh2d.end()){
2679  // check it
2680  if(rdf==NULL){
2681  console.Critical() << "NULL rdf !!!\n";
2682  }
2683  VectorEdge2DFieldSlave* new_efs= new VectorEdge2DFieldSlave(&m_tml_comm,m2d->second,rdf);
2684  m_field_slaves.insert(make_pair(id,new_efs));
2685  }
2686  }
2687  console.Debug() << "end TSubLattice<T>::addVectorTriangleField()\n";
2688 }
2689 
2693 template <class T>
2695 {
2696  console.Debug() << "TSubLattice<T>::addScalarTriangleField()\n";
2697  string fieldname;
2698  string meshname;
2699  int id;
2700 
2701  // receive params
2702  m_tml_comm.recv_broadcast_cont(fieldname,0);
2703  console.XDebug() << "recvd. fieldname: " << fieldname << "\n";
2704  m_tml_comm.recv_broadcast_cont(meshname,0);
2705  console.XDebug() << "recvd. meshname: " << meshname << "\n";
2706  m_tml_comm.recv_broadcast(id,0);
2707  console.XDebug() << "recvd. id: " << id << "\n";
2708 
2709  // get reader function
2711  // check it
2712  if(rdf==NULL){
2713  console.Critical() << "NULL rdf !!!\n";
2714  }
2715  ScalarTriangleFieldSlave* new_vtfs=new ScalarTriangleFieldSlave(&m_tml_comm,m_mesh[meshname],rdf);
2716  m_field_slaves.insert(make_pair(id,new_vtfs));
2717  console.Debug() << "end TSubLattice<T>::addScalarTriangleField()\n";
2718 }
2719 
2723 template <class T>
2725 {
2726  console.XDebug() << "begin TSubLattice<T>::addVectorWallField()\n";
2727  string fieldname;
2728  string tmp_wallname;
2729  vector<string> wallnames;
2730  int nwall;
2731  int id;
2732 
2733  // receive params
2734  m_tml_comm.recv_broadcast_cont(fieldname,0);
2735  console.XDebug() << "recvd. fieldname: " << fieldname << "\n";
2736  m_tml_comm.recv_broadcast(nwall,0);
2737  console.XDebug() << "recvd. nwall: " << nwall << "\n";
2738  for(int i=0;i<nwall;i++){
2739  m_tml_comm.recv_broadcast_cont(tmp_wallname,0);
2740  wallnames.push_back(tmp_wallname);
2741  console.XDebug() << "recvd. wallname: " << tmp_wallname << "\n";
2742  tmp_wallname.clear();
2743  }
2744  m_tml_comm.recv_broadcast(id,0);
2745  console.XDebug() << "recvd. id: " << id << "\n";
2746 
2747  // check validity of 1st wall name
2748  map<string,CWall*>::iterator cwalliter=m_walls.find(*(wallnames.begin()));
2749  if(cwalliter==m_walls.end()){ // 1st wall name invalid -> exit
2750  std::stringstream msg;
2751  msg
2752  << "ERROR in addVectorWallField: wallname '"
2753  << *(wallnames.begin()) << " 'invalid. Valid wall names: ";
2754  for (map<string,CWall*>::const_iterator it = m_walls.begin(); it != m_walls.end(); it++)
2755  {
2756  msg << "'" << it->first << "' ";
2757  }
2758  console.Error() << msg.str() << "\n";
2759  throw std::runtime_error(msg.str());
2760  } else { // first wall valid -> try to get slave
2761  // get summation flag from wall
2762  int sumflag=(cwalliter->second)->getFieldSummationFlag(fieldname);
2763  // if process 1, send summation flag back to master
2764  if(m_tml_comm.rank()==1){
2765  m_tml_comm.send(sumflag,0);
2766  }
2767  m_tml_comm.barrier();
2768 
2769  //field slave
2770  AWallFieldSlave* new_fs=(cwalliter->second)->generateVectorFieldSlave(&m_tml_comm,fieldname);
2771 
2772  // try to insert other walls
2773  vector<string>::iterator niter=wallnames.begin();
2774  if(niter!=wallnames.end()) niter++ ; // jump past 1st wall - already got it
2775  while(niter!=wallnames.end()){
2776  string wname=*niter;
2777  map<string,CWall*>::iterator iter=m_walls.find(wname);
2778  if(iter==m_walls.end()){ // wall name invalid -> exit
2779  std::stringstream msg;
2780  msg
2781  << "ERROR in addVectorWallField: wallname '"
2782  << wname << " 'invalid";
2783  for (map<string,CWall*>::const_iterator it = m_walls.begin(); it != m_walls.end(); it++)
2784  {
2785  msg << "'" << it->first << "' ";
2786  }
2787 
2788  console.Error() << msg.str() << "\n";
2789  throw std::runtime_error(msg.str());
2790  } else {
2791  new_fs->addWall(iter->second);
2792  }
2793  niter++;
2794  }
2795  if(new_fs!=NULL){
2796  m_field_slaves.insert(make_pair(id,new_fs));
2797  } else {
2798  console.Error() << "ERROR in addVectorWallField: got NULL Slave\n";
2799  }
2800  }
2801 
2802  console.XDebug() << "end TSubLattice<T>::addVectorWallField()\n";
2803 }
2804 
2808 template <class T>
2810 {
2811  console.Debug() << "TSubLattice<T>::sendFieldData()\n";
2812  // receive id's of field to send
2813  int id;
2814  m_tml_comm.recv_broadcast(id,0);
2815  console.Debug() << "received field id " << id << " for data collection\n" ;
2816  if(m_field_slaves[id] != NULL)
2817  {
2818  m_field_slaves[id]->sendData();
2819  }
2820  else
2821  { // can not happen
2822  cerr << "NULL pointer in m_field_slaves!" << endl;
2823  }
2824  // call the sending function of the field
2825  console.Debug() << "end TSubLattice<T>::sendFieldData()\n";
2826 }
2827 
2828 
2829 // ---- Checkpointing ----------
2833 template <class T>
2834 void TSubLattice<T>::saveSnapShotData(std::ostream &oStream)
2835 {
2836  // get precision of output stream and set it to 9 significant digits
2837  std::streamsize oldprec=oStream.precision(9);
2838 
2839  //
2840  // Save particle check-point data
2841  //
2842  ParticleArray &particleArray = dynamic_cast<ParticleArray &>(*m_ppa);
2844  particleIt(particleArray.getInnerParticleIterator());
2845 
2846  const std::string delim = "\n";
2847 
2848  oStream << particleIt.getNumRemaining() << delim;
2849  while (particleIt.hasNext()) {
2850  particleIt.next().saveSnapShotData(oStream);
2851  oStream << delim;
2852  }
2853 
2854  //
2855  // Save Bonded interaction check-point data.
2856  //
2857  typedef std::map<string,AParallelInteractionStorage*> NameBondedInteractionsMap;
2858  typename NameBondedInteractionsMap::iterator it;
2859  oStream << m_bpis.size() << delim;
2860  for (it = m_bpis.begin(); it != m_bpis.end(); it++) {
2861  it->second->saveSnapShotData(oStream);
2862  oStream << delim;
2863  }
2864 
2865  // dump trimeshdata (if exists)
2866  oStream << "TMIG " << m_mesh.size() << delim;
2867  for(typename map<string,TriMesh*>::iterator tm_iter=m_mesh.begin();
2868  tm_iter!=m_mesh.end();
2869  tm_iter++){
2870  oStream << tm_iter->first << delim;
2871  tm_iter->second->writeCheckPoint(oStream,delim);
2872  }
2873 
2874  // restore output stream to old precision
2875  oStream.precision(oldprec);
2876 }
2877 
2881 template <class T>
2882 void TSubLattice<T>::saveCheckPointData(std::ostream &oStream)
2883 {
2884  const std::string delim = "\n";
2885  //
2886  // Save particle check-point data
2887  //
2888  m_ppa->saveCheckPointData(oStream);
2889 
2890  //
2891  // Save Bonded interaction check-point data.
2892  //
2893  typedef std::map<string,AParallelInteractionStorage*> NameBondedInteractionsMap;
2894  typename NameBondedInteractionsMap::iterator it;
2895  oStream << m_bpis.size() << delim;
2896  for (it = m_bpis.begin(); it != m_bpis.end(); it++) {
2897  it->second->saveCheckPointData(oStream);
2898  oStream << delim;
2899  }
2900 
2901  //
2902  // Save Non-bonded interaction check-point data
2903  //
2904  int count_save=0;
2905  for(std::map<string,AParallelInteractionStorage*>::iterator iter=m_dpis.begin();
2906  iter!=m_dpis.end();
2907  iter++){
2908  if(iter->second->willSave()) count_save++;
2909  }
2910  oStream << count_save << delim;
2911  for(std::map<string,AParallelInteractionStorage*>::iterator iter=m_dpis.begin();
2912  iter!=m_dpis.end();
2913  iter++){
2914  if(iter->second->willSave()) {
2915  iter->second->saveCheckPointData(oStream);
2916  oStream << delim;
2917  }
2918  }
2919 
2920  // Save walls (name, pos, normal)
2921  oStream << "Walls " << m_walls.size() << delim;
2922  for(map<string,CWall*>::iterator w_iter=m_walls.begin();
2923  w_iter!=m_walls.end();
2924  w_iter++){
2925  oStream << w_iter->first << delim;
2926  w_iter->second->writeCheckPoint(oStream,delim);
2927  }
2928 
2929  // dump trimeshdata (if exists)
2930  oStream << "TriMesh " << m_mesh.size() << delim;
2931  for(typename map<string,TriMesh*>::iterator tm_iter=m_mesh.begin();
2932  tm_iter!=m_mesh.end();
2933  tm_iter++){
2934  oStream << tm_iter->first << delim;
2935  tm_iter->second->writeCheckPoint(oStream,delim);
2936  }
2937  // dump 2D mesh data (if exists)
2938  oStream << "Mesh2D " << m_mesh2d.size() << delim;
2939  for(typename map<string,Mesh2D*>::iterator tm_iter=m_mesh2d.begin();
2940  tm_iter!=m_mesh2d.end();
2941  tm_iter++){
2942  oStream << tm_iter->first << delim;
2943  tm_iter->second->writeCheckPoint(oStream,delim);
2944  }
2945 }
2946 
2947 template <class T>
2948 void TSubLattice<T>::loadCheckPointData(std::istream &iStream)
2949 {
2950  // get particles
2951  m_ppa->loadCheckPointData(iStream);
2952 
2953  // rebuild neighbor table
2954  CMPIBarrier barrier(getWorkerComm());
2955  m_ppa->rebuild();
2956  barrier.wait("PPA rebuild");
2957 
2958  //-- get bonds --
2959  // get nr. of bonded interaction group in the checkpoint file
2960  unsigned int nr_bonded_ig;
2961  iStream >> nr_bonded_ig;
2962 
2963  // compare with existing bonded particle interaction storage (bpis)
2964  // barf if not equal
2965  if(nr_bonded_ig!=m_bpis.size()){
2966  std::cerr << "number of bonded interaction groups differ between snapshot and script!" << std::endl;
2967  } else { // numbers fit -> read data
2968  for (map<string,AParallelInteractionStorage*>::iterator it = m_bpis.begin();
2969  it != m_bpis.end();
2970  it++) { // for all interaction groups
2971  it->second->loadCheckPointData(iStream);
2972  }
2973  }
2974  //-- get nonbonded interactions --
2975  // get nr. of non-bonded interaction group in the checkpoint file
2976  unsigned int nr_nonbonded_ig;
2977  iStream >> nr_nonbonded_ig;
2978 
2979  // compare with existing non-bonded (dynamic) particle interaction storage (dpis)
2980  // barf if not equal
2981  if(nr_nonbonded_ig!=m_dpis.size()){
2982  std::cerr << "number of dynamic interaction groups differ between snapshot and script!" << std::endl;
2983  } else { // numbers fit -> read data
2984  for (map<string,AParallelInteractionStorage*>::iterator it = m_dpis.begin();
2985  it != m_dpis.end();
2986  it++) { // for all interaction groups
2987  it->second->loadCheckPointData(iStream);
2988  }
2989  }
2990  //--- load walls ---
2991  string token;
2992  iStream >> token;
2993  if(token!="Walls") { // found wrong token -> barf
2994  std::cerr << "expected Walls , got " << token << std::endl;
2995  }
2996  // nr. of walls
2997  int nwalls;
2998  iStream >> nwalls;
2999  // read wall names & data
3000  string wname;
3001  for(int i=0;i<nwalls;i++){
3002  CWall* new_wall = new CWall();
3003  iStream >> wname;
3004  new_wall->loadCheckPoint(iStream);
3005  m_walls[wname]=new_wall;
3006  }
3007  // --- load meshes --
3008  int nmesh;
3009  string mname;
3010  // Trimesh (3D)
3011  iStream >> token;
3012  if(token!="TriMesh") { // found wrong token -> barf
3013  std::cerr << "expected TriMesh , got " << token << std::endl;
3014  }
3015  // nr. of meshes
3016  iStream >> nmesh;
3017  // read wall names & data
3018  for(int i=0;i<nmesh;i++){
3019  TriMesh* new_tm=new TriMesh();
3020  iStream >> mname;
3021  new_tm->loadCheckPoint(iStream);
3022  m_mesh.insert(make_pair(mname,new_tm));
3023  }
3024  // Mesh2D
3025  iStream >> token;
3026  if(token!="Mesh2D") { // found wrong token -> barf
3027  std::cerr << "expected Mesh2D , got " << token << std::endl;
3028  }
3029  // nr. of meshes
3030  iStream >> nmesh;
3031  // read wall names & data
3032  for(int i=0;i<nmesh;i++){
3033  Mesh2D* new_m2d=new Mesh2D();
3034  iStream >> mname;
3035  new_m2d->loadCheckPoint(iStream);
3036  m_mesh2d.insert(make_pair(mname,new_m2d));
3037  }
3038 }
3039 
3040 // -- mesh data exchange functions --
3041 
3045 template <class T>
3047 {
3048  console.XDebug() << "TSubLattice<T>::getMeshNodeRef()\n";
3049  vector<int> ref_vec;
3050 
3051  // MPI buffer
3052  CVarMPIBuffer param_buffer(m_comm);
3053  // receive mesh name
3054  param_buffer.receiveBroadcast(0);
3055  string meshname=param_buffer.pop_string();
3056  console.XDebug() << "Mesh name: " << meshname << "\n";
3057 
3058  // find mesh & collect node ids into array
3059  map<string,TriMesh*>::iterator tm=m_mesh.find(meshname);
3060  if (tm!=m_mesh.end()){
3061  for(TriMesh::corner_iterator iter=(tm->second)->corners_begin();
3062  iter!=(tm->second)->corners_end();
3063  iter++){
3064  ref_vec.push_back(iter->getID());
3065  }
3066  } else {
3067  map<string,Mesh2D*>::iterator m2d=m_mesh2d.find(meshname);
3068  if(m2d!=m_mesh2d.end()){
3069  for(Mesh2D::corner_iterator iter=(m2d->second)->corners_begin();
3070  iter!=(m2d->second)->corners_end();
3071  iter++){
3072  ref_vec.push_back(iter->getID());
3073  }
3074  } else {
3075  console.Critical() << "ERROR - WRONG MESH NAME IN getMeshNodeRef() !! \n";
3076  }
3077  }
3078  // send back to master
3079  m_tml_comm.send_gather(ref_vec,0);
3080 
3081  console.XDebug() << "end TSubLattice<T>::getMeshNodeRef()\n";
3082 }
3083 
3087 template <class T>
3089 {
3090  console.XDebug() << "TSubLattice<T>::getMeshFaceRef()\n";
3091  vector<int> ref_vec;
3092 
3093  // MPI buffer
3094  CVarMPIBuffer param_buffer(m_comm);
3095  // receive mesh name
3096  param_buffer.receiveBroadcast(0);
3097  string meshname=param_buffer.pop_string();
3098  console.XDebug() << "Mesh name: " << meshname << "\n";
3099 
3100  // find mesh & collect node ids into array
3101  map<string,TriMesh*>::iterator tm=m_mesh.find(meshname);
3102  if (tm!=m_mesh.end()){
3103  for(TriMesh::triangle_iterator iter=(tm->second)->triangles_begin();
3104  iter!=(tm->second)->triangles_end();
3105  iter++){
3106  ref_vec.push_back(iter->getID());
3107  }
3108  } else {
3109  map<string,Mesh2D*>::iterator m2d=m_mesh2d.find(meshname);
3110  if(m2d!=m_mesh2d.end()){
3111  for(Mesh2D::edge_iterator iter=(m2d->second)->edges_begin();
3112  iter!=(m2d->second)->edges_end();
3113  iter++){
3114  ref_vec.push_back(iter->getID());
3115  }
3116  } else {
3117  console.Critical() << "ERROR - WRONG MESH NAME IN getMeshNodeRef() !! \n";
3118  }
3119  }
3120  // send back to master
3121  m_tml_comm.send_gather(ref_vec,0);
3122 
3123  console.XDebug() << "end TSubLattice<T>::getMeshNodeRef()\n";
3124 }
3125 
3129 template <class T>
3131 {
3132  console.XDebug() << "TSubLattice<T>::getMesh2DStress()\n";
3133  // receive mesh name
3134  // MPI buffer
3135  CVarMPIBuffer param_buffer(m_comm);
3136  param_buffer.receiveBroadcast(0);
3137  string meshname=param_buffer.pop_string();
3138  console.XDebug() << "Mesh name: " << meshname << "\n";
3139 
3140  // find mesh & collect data
3141  map<string,Mesh2D*>::iterator m2d=m_mesh2d.find(meshname);
3142  if(m2d!=m_mesh2d.end()){
3143  vector<pair<int,Vec3> > data_vec;
3144  // get data
3145  data_vec=(m2d->second)->forAllEdgesGetIndexed(&Edge2D::getForceDensity);
3146 
3147  // send data to master
3148  m_tml_comm.send_gather(data_vec,0);
3149  } else {
3150  console.Critical() << "ERROR - WRONG MESH NAME IN getMesh2DStress() !! \n";
3151  }
3152 
3153  console.XDebug() << "end TSubLattice<T>::getMesh2DStress()\n";
3154 }
3155 
3159 template <class T>
3161 {
3162  console.XDebug() << "TSubLattice<T>::getTriMeshStress(): enter\n";
3163  // receive mesh name
3164  // MPI buffers
3165  CVarMPIBuffer param_buffer(m_comm);
3166  param_buffer.receiveBroadcast(0);
3167  const std::string meshName = param_buffer.pop_string();
3168  console.XDebug() << "Mesh name: " << meshName << "\n";
3169 
3170  // find mesh & collect data
3171  map<string,TriMesh*>::iterator m=m_mesh.find(meshName);
3172  if(m != m_mesh.end()){
3173  vector<pair<int,Vec3> > data_vec;
3174  // get data
3175  data_vec=(m->second)->forAllTrianglesGetIndexed(&Triangle::getForce);
3176 
3177  // send data to master
3178  m_tml_comm.send_gather(data_vec,0);
3179  } else {
3180  std::stringstream msg;
3181  msg << "Invalid mesh name: " << meshName << ". No such triangular mesh.";
3182  throw std::runtime_error(msg.str().c_str());
3183  }
3184 
3185  console.XDebug() << "TSubLattice<T>::getTriMeshStress(): exit\n";
3186 }
virtual void addBondedWIG()
Definition: SubLattice.hpp:425
virtual void loadCheckPoint(istream &)
Definition: TriMesh.cpp:285
virtual void moveSingleNode()
Definition: SubLattice.hpp:2000
Definition: LatticeParam.h:29
virtual void printData()
Definition: SubLattice.hpp:2410
virtual Vec3 pop_vector()
Definition: mpibuf.cpp:26
double x0
Definition: FractalFriction.h:40
virtual void addScalarParticleField()
Definition: SubLattice.hpp:2433
double k
Definition: BTriMeshIP.h:21
virtual void printTimes()
Definition: SubLattice.hpp:2417
A convenience class encapsulating an MPI barrier. Includes timing of the wait and a debug message ( v...
Definition: mpibarrier.h:30
virtual void addDirBondedWIG()
Definition: SubLattice.hpp:453
virtual void addScalarTriangleField()
Definition: SubLattice.hpp:2694
virtual void getWallForce()
Definition: SubLattice.hpp:512
void buildFromPPATagged(int, int)
Definition: mesh2d_pis_eb.hpp:357
double k_s
Definition: RotThermFricInteraction.h:51
virtual void addSingleIG()
Definition: SubLattice.hpp:1141
double m_alpha
Definition: SubLattice.h:93
virtual ~TSubLattice()
Definition: SubLattice.hpp:170
double y0
Definition: FractalFriction.h:40
Definition: RotThermParticle.h:54
int m_last_ns
Definition: SubLattice.h:95
virtual int getNumParticles()
Definition: SubLattice.hpp:230
Definition: vec3.h:46
double m_kr
Definition: RotThermElasticInteraction.h:35
double k
Definition: BMesh2DIP.h:19
static const Vec3 ZERO
Definition: vec3.h:52
Definition: RotThermFricInteraction.h:69
void wait(const char *)
Definition: mpibarrier.cpp:32
double dt
Definition: FrictionInteraction.h:41
Interaction parameters for frictional interaction.
Definition: FrictionInteraction.h:27
void setUnbreakable(bool)
Definition: pi_storage_eb.hpp:168
double diffusivity
Definition: RotThermElasticInteraction.h:36
Interaction parameters for bonded interaction.
Definition: BondedInteraction.h:39
TML_Comm m_tml_comm
Definition: SubLattice.h:103
Interaction group parameters for CRotElasticInteractionGroups.
Definition: RotElasticInteraction.h:24
VEC3_INLINE double & Z()
Definition: vec3.h:121
virtual void addScalarInteractionField()
Definition: SubLattice.hpp:2506
double commtime
Definition: SubLattice.h:116
int getNumRemaining() const
Definition: pp_array.hpp:678
VEC3_INLINE double & Y()
Definition: vec3.h:120
Vec3(Edge2D::* VectorFieldFunction)() const
Definition: Edge2D.h:41
void resetDisplacements()
Definition: SubLattice.hpp:1942
bool m_scaling
Definition: FrictionInteraction.h:42
double k_s
Definition: RotFricInteraction.h:75
double m_damp
Definition: LinearDashpotInteraction.h:27
virtual void addShortBondedIG()
Definition: SubLattice.hpp:1378
Slave part for saving a vector field defined on the triangles in a given TriMesh. ...
Definition: VectorTriangleFieldSlave.h:35
virtual void addVectorWallField()
Definition: SubLattice.hpp:2724
CDampingIGP * extractDampingIGP(AMPIBuffer *B)
Definition: DampingIGP.cpp:64
Definition: BodyForceGroup.h:143
int tag
Definition: BondedInteraction.h:53
virtual void receiveBroadcast(int)
Definition: mpivbuf.cpp:262
static ScalarFieldFunction getScalarFieldFunction(const string &)
Definition: Triangle.cpp:296
virtual bool doAddPIG(const string &, const string &, CVarMPIBuffer &, bool tagged=false)
Definition: SubLattice.hpp:617
virtual void exchangePos()
Definition: SubLattice.hpp:1503
virtual void moveParticleTo()
Definition: SubLattice.hpp:1959
double dx
Definition: FractalFriction.h:40
void integrate(double)
Definition: SubLattice.hpp:1640
double mu
Definition: HertzianViscoElasticFrictionInteraction.h:52
Definition: BodyForceGroup.h:99
boost::python::object iter(const boost::python::object &pyOb)
Definition: Util.h:25
Definition: BodyForceGroup.h:26
MPI_Comm m_comm
Definition: SubLattice.h:102
Definition: RotThermFricInteraction.h:34
double mu_0
Definition: FractalFriction.h:36
TSubLattice(const esys::lsm::CLatticeParam &prm, int rank, MPI_Comm comm, MPI_Comm worker_comm)
Definition: SubLattice.hpp:109
virtual void addMesh2D()
Definition: SubLattice.hpp:995
double k_s
Definition: FrictionInteraction.h:40
Interaction parameters for frictional interaction between rotational particles.
Definition: RotFricInteraction.h:37
Definition: pi_storage_ed_t.h:30
double dt
Definition: FractalFriction.h:38
virtual void send()
Definition: mpisgbuf.cpp:221
double mu_s
Definition: RotThermFricInteraction.h:50
bool m_scaling
Definition: BondedInteraction.h:54
double m_A
Definition: HertzianViscoElasticFrictionInteraction.h:49
double packtime
Definition: SubLattice.h:114
double m_force_limit
Definition: CappedBondedInteraction.h:44
class for variable size scatter/gather buffer, leaf component
Definition: mpisgvbuf.h:68
Definition: BodyForceGroup.h:67
Interaction parameters for adhesive frictional interaction.
Definition: AdhesiveFriction.h:21
double mu
Definition: AdhesiveFriction.h:32
BasicCon & Error(bool h=true)
set verbose level of next message to &quot;err&quot;
Definition: console.cpp:261
virtual void setParticleNonTrans()
Definition: SubLattice.hpp:2222
base class for all walls
Definition: Wall.h:39
virtual void addCappedBondedIG()
Definition: SubLattice.hpp:1304
virtual void rebuildParticleArray()
Definition: SubLattice.hpp:1777
bool hasNext() const
Definition: pp_array.hpp:663
virtual void addElasticWIG()
Definition: SubLattice.hpp:389
virtual void checkNeighbors()
Definition: SubLattice.hpp:1890
Interaction group parameters for Hertzian elastic interactions.
Definition: HertzianElasticInteraction.h:24
double k_s
Definition: HertzianViscoElasticFrictionInteraction.h:53
vector< Corner2D >::iterator corner_iterator
Definition: Mesh2D.h:58
vector< Corner >::iterator corner_iterator
Definition: TriMesh.h:66
virtual void addVectorParticleField()
Definition: SubLattice.hpp:2468
Interaction group parameters for CBWallInteractionGroups.
Definition: BWallInteractionGroup.h:38
Definition: ABCDampingIGP.h:23
parrallel particle storage array with neighborsearch and variable exchange
Definition: SubLattice.h:61
double r_cut
Definition: AdhesiveFriction.h:35
virtual void setVelocityOfWall()
Definition: SubLattice.hpp:2311
parallel storage array with exchange for dynamically created interactions (friction etc...
Definition: pi_storage_ed.h:30
Abstract Base class for a group of interactions between particles and a wall.
Definition: WallIG.h:30
CSoftBWallIGP * extractSoftBWallIGP(AMPIBuffer *B)
Definition: SoftBWallInteractionGroup.cpp:64
void thermExpansion()
Definition: SubLattice.hpp:1692
virtual void setTaggedParticleVel()
Definition: SubLattice.hpp:2237
virtual void setParticleDensity()
Definition: SubLattice.hpp:2346
Interaction parameters for velocity weakening frictional interaction.
Definition: VWFrictionInteraction.h:22
int nx
Definition: FractalFriction.h:41
double mu_s
Definition: RotFricInteraction.h:74
double brk
Definition: BMesh2DIP.h:20
Interaction group parameters for CEWallInteractionGroups.
Definition: brokenEWallInteractionGroup.h:32
virtual void receiveParticles()
Definition: SubLattice.hpp:316
virtual void getMeshNodeRef()
Definition: SubLattice.hpp:3046
Con console & cout
Definition: console.cpp:30
double brk
Definition: BTriMeshIP.h:22
virtual double pop_double()
Definition: mpivbuf.cpp:210
double k_s
Definition: AdhesiveFriction.h:33
virtual void setParticleNonRot()
Definition: SubLattice.hpp:2206
virtual void applyForceToWall()
Definition: SubLattice.hpp:2291
bool meanR_scaling
Definition: RotFricInteraction.h:79
double m_k
Definition: ElasticInteraction.h:28
virtual void setTimeStepSize(double dt)
Definition: SubLattice.hpp:1596
class for slave part of scalar field defined on tagged particles
Definition: ScalarParticleFieldSlaveTagged.h:32
MPI_Comm m_worker_comm
MPI communicator between workers (excl. master)
Definition: SubLattice.h:104
boost::shared_ptr< double > mu
pointer to the array of friction coeff.
Definition: FractalFriction.h:39
virtual void loadCheckPoint(istream &)
Definition: Mesh2D.cpp:230
virtual std::string pop_string()
Definition: mpivbuf.cpp:233
static VectorFieldFunction getVectorFieldFunction(const string &)
Definition: Triangle.cpp:276
virtual void addTriMesh()
Definition: SubLattice.hpp:854
virtual void initNeighborTable(const Vec3 &, const Vec3 &)
Definition: SubLattice.hpp:198
double unpacktime
Definition: SubLattice.h:115
Particle & next()
Definition: pp_array.hpp:669
void calcHeatTrans()
Definition: SubLattice.hpp:1746
Definition: BMesh2DIP.h:16
bool scaling
Definition: RotFricInteraction.h:77
virtual void addPairIG()
Definition: SubLattice.hpp:571
double m_cutoff
Definition: LinearDashpotInteraction.h:28
virtual void sendDataToMaster()
Definition: SubLattice.hpp:2364
double k
Definition: RotFricInteraction.h:72
virtual void moveWallBy()
Definition: SubLattice.hpp:2253
static VectorFieldFunction getVectorFieldFunction(const string &)
Definition: Edge2D.cpp:101
Interaction group parameters for CElasticInteractionGroups.
Definition: ElasticInteraction.h:24
void buildFromPPATagged(int, int)
Definition: trimesh_pis_eb.hpp:261
virtual void addTaggedPairIG()
Definition: SubLattice.hpp:592
Abstract base class for a group of interactions.
Definition: InteractionGroup.h:34
int ny
array size
Definition: FractalFriction.h:41
abstract base class for parallel interaction storage array
Definition: pi_storage.h:44
Class for parallel storage of interactions between a triangle mesh and particles which doesn&#39;t requir...
Definition: trimesh_pis_ne.h:30
void LoadMesh(const vector< MeshNodeData2D > &, const vector< MeshEdgeData2D > &)
Definition: Mesh2D.cpp:35
virtual void translateMeshBy(const std::string &meshName, const Vec3 &translation)
Definition: SubLattice.hpp:2053
CBWallIGP * extractBWallIGP(AMPIBuffer *B)
Definition: BWallInteractionGroup.cpp:56
double mu_d
Definition: RotThermFricInteraction.h:49
Class for parallel storage of interactions between a 2D mesh and particles which doesn&#39;t require exch...
Definition: mesh2d_pis_ne.h:29
virtual void addRotThermBondedIG()
Definition: SubLattice.hpp:1368
std::string getWallName() const
Definition: brokenEWallInteractionGroup.h:40
virtual void countParticles()
Definition: SubLattice.hpp:2386
double m_E
Definition: HertzianViscoElasticInteraction.h:28
double diffusivity
Definition: RotThermFricInteraction.h:53
virtual void getTriMeshForce()
Definition: SubLattice.hpp:3160
virtual void addBondedMesh2DIG()
Definition: SubLattice.hpp:1082
Interaction parameters for bonded interaction with a force limit.
Definition: CappedBondedInteraction.h:40
virtual int pop_int()
Definition: mpivbuf.cpp:196
#define NULL
Definition: t_list.h:17
double nrange() const
Definition: LatticeParam.h:42
double m_nu
Definition: HertzianViscoElasticInteraction.h:29
double k
Definition: ETriMeshIP.h:66
virtual void addBondedTriMeshIG()
Definition: SubLattice.hpp:939
Interaction group parameters for CLocalDampingGroup.
Definition: LocalDampingIGP.h:27
virtual void saveCheckPointData(std::ostream &oStream)
Definition: SubLattice.hpp:2882
Interaction group parameters for CDampingGroup.
Definition: DampingIGP.h:27
double k_s
Definition: FractalFriction.h:37
abstract base class for communicator
Definition: comm.h:46
vector< Edge2D >::iterator edge_iterator
Definition: Mesh2D.h:57
Slave part for saving a scalar field defined on the triangles in a given TriMesh. ...
Definition: ScalarTriangleFieldSlave.h:35
class for slave part of scalar field defined on the particles
Definition: VectorParticleFieldSlaveTagged.h:32
virtual void addMesh2DIG()
Definition: SubLattice.hpp:1034
class for slave part of scalar field defined on the particles
Definition: VectorParticleFieldSlave.h:31
void zeroHeat()
Definition: SubLattice.hpp:1704
double dt
Definition: AdhesiveFriction.h:34
BasicCon & Info(bool h=true)
set verbose level of next message to &quot;inf&quot;
Definition: console.cpp:294
ABCDampingIGP * extractABCDampingIGP(AMPIBuffer *B)
Definition: ABCDampingIGP.cpp:49
MPI send/recv buffer with automagically adjusted size.
Definition: mpivbuf.h:34
virtual void removeIG()
Definition: SubLattice.hpp:1467
BasicCon & XDebug(bool h=true)
set verbose level of next message to &quot;xdg&quot;
Definition: console.cpp:316
double mu
Definition: FrictionInteraction.h:39
double m_alpha
Definition: VWFrictionInteraction.h:25
double forcetime
Definition: SubLattice.h:117
Buffer for MPI scatter/gather, leaf component.
Definition: mpisgbuf.h:124
virtual void oneStepTherm()
Definition: SubLattice.hpp:1668
Slave part for saving a vector field defined on the edges in a given Mesh2D.
Definition: VectorEdge2DFieldSlave.h:34
const ProcessDims & processDims() const
Definition: LatticeParam.h:44
Definition: BTriMeshIP.h:18
virtual void tryInsert(const I &)
virtual void searchNeighbors()
Definition: SubLattice.hpp:1821
static BuoyancyIGP extract(CVarMPIBuffer *pBuffer)
Definition: BodyForceGroup.cpp:92
BasicCon & Debug(bool h=true)
set verbose level of next message to &quot;dbg&quot;
Definition: console.cpp:305
void calcForces()
Definition: SubLattice.hpp:1552
CEWallIGP * extractEWallIGP(AMPIBuffer *)
Definition: EWallInteractionGroup.cpp:53
const std::string & Name() const
Definition: IGParam.h:44
virtual void send()
Definition: mpisgvbuf.cpp:287
void integrateTherm(double dt)
Definition: SubLattice.hpp:1683
virtual void sendFieldData()
Definition: SubLattice.hpp:2809
CVWallIGP * extractVWallIGP(AMPIBuffer *B)
Definition: ViscWallIG.cpp:54
void buildFromPPAByGap(double)
Definition: mesh2d_pis_eb.hpp:405
virtual void addDamping()
Definition: SubLattice.hpp:1191
virtual void saveSnapShotData(std::ostream &oStream)
Definition: SubLattice.hpp:2834
parallel storage array with exchange for bonded/breakable interactions
Definition: pi_storage_eb.h:29
double rbreak
Breaking strain.
Definition: BondedInteraction.h:52
virtual void loadCheckPoint(istream &)
Definition: Wall.cpp:128
Con console
virtual void receiveConnections()
Definition: SubLattice.hpp:339
double(Triangle::* ScalarFieldFunction)() const
Definition: Triangle.h:51
virtual void addRotBondedIG()
Definition: SubLattice.hpp:1362
TML_Comm m_tml_worker_comm
TML version of the communicator between workers (excl. master)
Definition: SubLattice.h:105
virtual void updateInteractions()
Definition: SubLattice.hpp:1842
virtual void addBondedIG()
Definition: SubLattice.hpp:1257
double dy
origin and grid spacing of the array
Definition: FractalFriction.h:40
const std::string & getName() const
Definition: IGParam.h:42
Class for parallel storage of interactions between a triangle mesh and particles which does require e...
Definition: trimesh_pis_eb.h:29
double mu_d
Definition: RotFricInteraction.h:73
virtual void addWall()
Definition: SubLattice.hpp:370
double k
Definition: RotThermFricInteraction.h:48
Interaction group parameters for CSoftBWallInteractionGroups.
Definition: SoftBWallInteractionGroup.h:31
double m_E
Definition: HertzianElasticInteraction.h:27
esys::lsm::CLatticeParam::ProcessDims m_dims
Definition: SubLattice.h:111
Definition: pi_storage_ne_t.h:30
parallel storage array without exchange for dynamically created single particle interactions (i...
Definition: pi_storage_single.h:26
BasicCon & Critical(bool h=true)
set verbose level of next message to &quot;crt&quot;
Definition: console.cpp:250
static BodyForceIGP extract(CVarMPIBuffer *pBuffer)
Definition: BodyForceGroup.cpp:52
virtual void rebuildInteractions()
Definition: SubLattice.hpp:1786
double alpha() const
Definition: LatticeParam.h:43
virtual void addTriMeshIG()
Definition: SubLattice.hpp:892
virtual void append(int)
Definition: mpisgbuf.cpp:239
CLocalDampingIGP * extractLocalDampingIGP(AMPIBuffer *B)
Definition: LocalDampingIGP.cpp:57
virtual void loadCheckPointData(std::istream &iStream)
Definition: SubLattice.hpp:2948
Definition: pp_array.h:143
Abstract base class for slave part of field defined on a Wall.
Definition: WallFieldSlave.h:33
virtual void getMesh2DStress()
Definition: SubLattice.hpp:3130
void calcHeatFrict()
Definition: SubLattice.hpp:1728
virtual void do2dCalculations(bool do2d)
Definition: SubLattice.hpp:224
double k
Definition: FrictionInteraction.h:38
VEC3_INLINE double & X()
Definition: vec3.h:119
Vec3 getForce() const
Definition: Triangle.h:91
virtual void setWallNormal()
Definition: SubLattice.hpp:2272
vector< Triangle >::iterator triangle_iterator
Definition: TriMesh.h:64
int m_rank
rank in m_comm
Definition: SubLattice.h:101
double m_nu
Definition: HertzianElasticInteraction.h:28
virtual void addVectorInteractionField()
Definition: SubLattice.hpp:2575
virtual void moveTaggedNodes()
Definition: SubLattice.hpp:2029
double m_kr
Definition: RotElasticInteraction.h:31
std::pair< int, Vec3 > getParticlePosn(int particleId)
Definition: SubLattice.hpp:2099
Abstract base class for slave part of field.
Definition: FieldSlave.h:22
virtual void setExIG()
Definition: SubLattice.hpp:1434
Vec3(Triangle::* VectorFieldFunction)() const
Definition: Triangle.h:50
Interaction group parameters for Hertzian viscoelastic interactions with friction.
Definition: HertzianViscoElasticFrictionInteraction.h:27
double m_A
Definition: HertzianViscoElasticInteraction.h:27
class for a triangle mesh
Definition: TriMesh.h:50
virtual void getMeshFaceRef()
Definition: SubLattice.hpp:3088
Class for a group of bonded, elastic interactions with per-direction spring constants between particl...
Definition: SoftBWallInteractionGroup.h:49
double m_E
Definition: HertzianViscoElasticFrictionInteraction.h:50
virtual void printStruct()
Definition: SubLattice.hpp:2400
Interaction parameters for frictional interaction with a fractal distribution of the coefficient of f...
Definition: FractalFriction.h:25
double k
Definition: AdhesiveFriction.h:31
Interaction group parameters for Hertzian viscoelastic interactions.
Definition: HertzianViscoElasticInteraction.h:24
double dt
Definition: RotThermFricInteraction.h:52
void buildFromPPAByGap(double)
Definition: trimesh_pis_eb.hpp:306
void LoadMesh(const vector< MeshNodeData > &, const vector< MeshTriData > &)
Definition: TriMesh.cpp:31
Class for a group of bonded,elastic interactions between particles and a wall.
Definition: BWallInteractionGroup.h:56
parallel storage array without exchange for dynamically created interactions (elastic) ...
Definition: pi_storage_ne.h:28
virtual void setParticleNonDynamic()
Definition: SubLattice.hpp:2190
void setComm(MPI_Comm)
Definition: comm.cpp:43
Class for a group of unbonded,elastic interactions between particles and a wall.
Definition: brokenEWallInteractionGroup.h:48
virtual void addVectorTriangleField()
Definition: SubLattice.hpp:2649
Definition: Mesh2D.h:46
virtual void Update(ParallelParticleArray< T > *)=0
virtual void addViscWIG()
Definition: SubLattice.hpp:543
Definition: RotThermElasticInteraction.h:61
Vec3 getForceDensity() const
Definition: Edge2D.h:70
ParticleIterator getInnerParticleIterator()
Definition: pp_array.hpp:684
double dt
Definition: HertzianViscoElasticFrictionInteraction.h:54
std::pair< double, int > findParticleNearestTo(const Vec3 &pt)
Definition: SubLattice.hpp:2066
Class for parallel storage of interactions between a 2D mesh and particles which does require exchang...
Definition: mesh2d_pis_eb.h:26
double k
Definition: FractalFriction.h:35
Interaction group parameters for CBWallInteractionGroups.
Definition: ViscWallIG.h:32
Interaction group parameters for Linear Dashpot interactions.
Definition: LinearDashpotInteraction.h:24
std::vector< int > IdVector
Definition: ASubLattice.h:48
virtual void moveTaggedParticlesBy()
Definition: SubLattice.hpp:1976
double m_nu
Definition: HertzianViscoElasticFrictionInteraction.h:51
void zeroForces()
Definition: SubLattice.hpp:1516
virtual bool doAddDamping(const string &, CVarMPIBuffer &)
Definition: SubLattice.hpp:1214
double m_nrange
Definition: SubLattice.h:91
double k
Spring constant.
Definition: BondedInteraction.h:51
virtual void oneStep()
Definition: SubLattice.hpp:1652
bool m_scaling
Definition: ElasticInteraction.h:29
Class for a group of viscous and elastic interactions between particles and a wall.
Definition: ViscWallIG.h:52
virtual void append(int)
Definition: mpisgvbuf.cpp:319
class for slave part of scalar field defined on the particles
Definition: ScalarParticleFieldSlave.h:31
virtual void moveSingleParticleTo(int particleId, const Vec3 &posn)
Definition: SubLattice.hpp:1990
virtual void setParticleVelocity()
Definition: SubLattice.hpp:2330
virtual void tagParticleNearestTo()
Definition: SubLattice.hpp:2163
double dt
Definition: RotFricInteraction.h:76
std::vector< SimpleParticle > ParticleVector
Definition: SimpleNTable3D.h:22
virtual void getParticleData(const IdVector &particleIdVector)
Definition: SubLattice.hpp:2123
virtual void getWallPos()
Definition: SubLattice.hpp:481
Definition: ETriMeshIP.h:17
void addWall(CWall *)
Definition: WallFieldSlave.cpp:31
Definition: RotThermElasticInteraction.h:23