ESyS-Particle  2.3.2
SubLattice.hpp
Go to the documentation of this file.
1 // //
3 // Copyright (c) 2003-2014 by The University of Queensland //
4 // Centre for Geoscience Computing //
5 // http://earth.uq.edu.au/centre-geoscience-computing //
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"
53 
54 // --- parallel storage includes ---
55 #include "ppa/src/pp_array.h"
56 #include "pis/pi_storage_eb.h"
57 #include "pis/pi_storage_ed.h"
58 #include "pis/pi_storage_ed_t.h"
59 #include "pis/pi_storage_ne.h"
60 #include "pis/pi_storage_ne_t.h"
61 #include "pis/pi_storage_single.h"
62 #include "pis/trimesh_pis.h"
63 #include "pis/trimesh_pis_ne.h"
64 #include "pis/trimesh_pis_eb.h"
65 #include "pis/mesh2d_pis_eb.h"
66 #include "pis/mesh2d_pis_ne.h"
67 
68 // --- field includes ---
79 
80 #include "Model/BodyForceGroup.h"
81 
82 #include <mpi.h>
83 #include <stdlib.h>
84 #include <stdexcept>
85 
86 // -- STL includes --
87 #include <algorithm>
88 #include <stdexcept>
89 #include <boost/limits.hpp>
90 using std::runtime_error;
91 
92 // -- IO includes --
93 #include <iostream>
94 using std::cerr;
95 using std::flush;
96 using std::endl;
98 
99 //----------------------------------------------
100 // TSubLattice functions
101 //----------------------------------------------
102 
110 template <class T>
112  const CLatticeParam &param,
113  int rank,
114  MPI_Comm comm,
115  MPI_Comm worker_comm
116 )
117  : m_ppa(NULL),
118  m_dpis(),
119  m_bpis(),
120  m_singleParticleInteractions(),
121  m_damping(),
122  m_WIG(),
123  m_SIG(),
124  m_mesh(),
125  m_mesh2d(),
126  m_dt(0),
127  m_nrange(0),
128  m_alpha(0),
129  m_last_ns(0),
130  m_temp_conn(),
131  m_rank(0),
132  m_comm(MPI_COMM_NULL),
133  m_tml_comm(MPI_COMM_NULL),
134  m_worker_comm(MPI_COMM_NULL),
135  m_tml_worker_comm(MPI_COMM_NULL),
136  m_dims(3, 0),
137  packtime(0),
138  unpacktime(0),
139  commtime(0.0),
140  forcetime(0.0),
141  m_field_slaves(),
142  m_pTimers(NULL)
143 {
144  // cout << "TSubLattice<T>::TSubLattice at " << rank << endl << flush;
145  // -- MPI stuff --
146  m_rank=rank;
147 
148  // set global communicator
149  m_comm=comm;
151 
152  m_dims = param.processDims();
153 
154  m_worker_comm=worker_comm;
155  // MPI_Comm_size(m_worker_comm,&m_num_workers);
157 
158 
159  // -- set parameters
160  m_alpha=param.alpha();
161  m_nrange=param.nrange();
162  // cout << "dt,nrange,alpha : " << m_dt << " , " << m_nrange << " , " << m_alpha << "\n";
163 
164  commtime=0.0;
165  packtime=0.0;
166  unpacktime=0.0;
167  forcetime=0.0;
168 
169  m_last_ns=-1;
170 }
171 
172 template <class T>
174 {
175  console.Debug() << "TSubLattice<T>::~TSubLattice(): enter\n";
176  console.Debug()
177  << "TSubLattice<T>::~TSubLattice():"
178  << " deleting wall interaction groups...\n";
179  for(
180  typename map<string,AWallInteractionGroup<T>*>::iterator vit=m_WIG.begin();
181  vit!=m_WIG.end();
182  vit++
183  )
184  {
185  delete vit->second;
186  }
187  for(
188  typename map<string,ASphereBodyInteractionGroup<T>*>::iterator vit=m_SIG.begin();
189  vit!=m_SIG.end();
190  vit++
191  )
192  {
193  delete vit->second;
194  }
195  console.Debug()
196  << "TSubLattice<T>::~TSubLattice():"
197  << " deleting particle array...\n";
198  if (m_ppa != NULL) delete m_ppa;
199  console.Debug() << "TSubLattice<T>::~TSubLattice(): exit\n";
200 }
201 
208 template <class T>
209 void TSubLattice<T>::initNeighborTable(const Vec3& min,const Vec3& max)
210 {
211  console.XDebug() << "TSubLattice<T>::initNeighborTable(" << min << "," << max << ")\n";
212  // make size fit range
213  double xsize=max.X()-min.X();
214  xsize=m_nrange*ceil(xsize/m_nrange);
215  double ysize=max.Y()-min.Y();
216  ysize=m_nrange*ceil(ysize/m_nrange);
217  double zsize=max.Z()-min.Z();
218  zsize=m_nrange*ceil(zsize/m_nrange);
219  Vec3 grow=Vec3(xsize,ysize,zsize)-(max-min); // size increase
220  Vec3 nmin=min-0.5*grow; // distribute symmetrically
221  Vec3 nmax=max+0.5*grow;
222  console.XDebug() << "range=" << m_nrange << ", new min,max: " << nmin << ", " << nmax << "\n";
223 
224  // construct particle array
225  TML_Comm *ntcomm=new TML_Comm(m_worker_comm);
226  m_ppa=new ParallelParticleArray<T>(ntcomm,m_dims,nmin,nmax,m_nrange,m_alpha);
227  //m_ppa=new ParallelParticleArray<T>(ntcomm,3,nmin,nmax,m_nrange);
228 
229  // makeFields(); // put here to make sure ppa is initialized before makeFields
230 
231  console.XDebug() << "end TSubLattice<T>::initNeighborTable\n";
232 }
233 
234 template <class T>
236 {
237  T::setDo2dCalculations(do2d);
238 }
239 
240 template <class T>
242 {
243  return m_ppa->getInnerSize();
244 }
245 
253 template <class T>
254 void TSubLattice<T>::initNeighborTable(const Vec3& min,const Vec3& max,const vector<bool>& circ)
255 {
256  console.XDebug() << "TSubLattice<T>::initNeighborTable(" << min << "," << max << ") circ\n";
257  double xsize,ysize,zsize;
258  // if dimension is circular, check if size fits range, otherwise make it fit
259  // x - dim
260  if(circ[0])
261  {
262  xsize=max.X()-min.X();
263  if(fabs(xsize/m_nrange-lrint(xsize/m_nrange))>1e-6)
264  {
265  //console.Critical() << "circular x-dimension doesn't fit range !\n";
266  console.Info() << "Circular x-size incompatible with range, adjusting...\n";
267  m_nrange = xsize/floor(xsize/m_nrange);
268  console.Info() << "New range = " << m_nrange << "\n";
269  }
270  //xsize+=2.0*m_nrange; // padding on the circular ends
271  }
272  else
273  {
274  xsize=max.X()-min.X();
275  xsize=m_nrange*ceil(xsize/m_nrange);
276  }
277  // y - dim
278  if(circ[1])
279  {
280  ysize=max.Y()-min.Y();
281  if(fabs(ysize/m_nrange-lrint(ysize/m_nrange))>1e-6)
282  {
283  console.Critical() << "circular y-dimension doesn't fit range !\n";
284  }
285  ysize+=2.0*m_nrange; // padding on the circular ends
286  }
287  else
288  {
289  ysize=max.Y()-min.Y();
290  ysize=m_nrange*ceil(ysize/m_nrange);
291  }
292  // z - dim
293  if(circ[2])
294  {
295  zsize=max.Z()-min.Z();
296  if(fabs(zsize/m_nrange-lrint(zsize/m_nrange))>1e-6)
297  {
298  console.Critical() << "circular z-dimension doesn't fit range !\n";
299  }
300  zsize+=2.0*m_nrange; // padding on the circular ends
301  }
302  else
303  {
304  zsize=max.Z()-min.Z();
305  zsize=m_nrange*ceil(zsize/m_nrange);
306  }
307  Vec3 grow=Vec3(xsize,ysize,zsize)-(max-min); // size increase
308  Vec3 nmin=min-0.5*grow; // distribute symmetrically
309  Vec3 nmax=max+0.5*grow;
310  console.XDebug() << "range, new min, max: " << m_nrange << " " << nmin << nmax << "\n";
311  // construct particle array
312  TML_Comm *ntcomm=new TML_Comm(m_worker_comm);
313  m_ppa=new ParallelParticleArray<T>(ntcomm,m_dims,circ,nmin,nmax,m_nrange,m_alpha);
314 
315  // makeFields(); // put here to make sure ppa is initialized before makeFields
316 
317  console.XDebug() << "end TSubLattice<T>::initNeighborTable (circ)\n";
318 }
319 
326 template <class T>
328 {
329  console.XDebug() << "TSubLattice<T>::receiveParticles: enter\n";
330 
331  vector<T> recv_buffer;
332  CMPIBarrier barrier(m_comm);
333 
334  m_tml_comm.recv_broadcast_cont_packed(recv_buffer,0);
335  console.XDebug() << "recvd " << recv_buffer.size() << " particles \n";
336  m_ppa->insert(recv_buffer);
337 
338  barrier.wait("TSubLattice<T>::receiveParticles");
339 
340  console.XDebug() << "TSubLattice<T>::receiveParticles: exit\n";
341 }
342 
343 
349 template <class T>
351 {
352  console.XDebug() << "TSubLattice<T>::receiveConnections: enter\n";
353 
354  vector<int> recv_buffer;
355  CMPIBarrier barrier(m_comm);
356 
357  m_tml_comm.recv_broadcast_cont_packed(recv_buffer,0);
358  console.XDebug() << "recvd " << recv_buffer.size() << " connections \n";
359  vector<int>::iterator it;
360  for (it = recv_buffer.begin(); it != recv_buffer.end(); it+=3)
361  {
362  if ( (m_ppa->getParticlePtrByIndex( *(it+1)) == NULL ) ||
363  (m_ppa->getParticlePtrByIndex( *(it+2)) == NULL ) )
364  {
365  continue;
366  }
367  m_temp_conn[*(it)].push_back(*(it+1));
368  m_temp_conn[*(it)].push_back(*(it+2));
369  }
370 
371  barrier.wait("TSubLattice<T>::receiveConnections");
372 
373  console.XDebug() << "TSubLattice<T>::receiveConnections: exit\n";
374 }
375 
376 
380 template <class T>
382 {
383  console.XDebug() << "TSubLattice<T>::addWall: enter\n" ;
384  CVarMPIBuffer param_buffer(m_comm);
385  param_buffer.receiveBroadcast(0);
386 
387  string name=param_buffer.pop_string();
388  Vec3 ipos=param_buffer.pop_vector();
389  Vec3 inorm=param_buffer.pop_vector();
390 
391  m_walls[name]=new CWall(ipos,inorm);
392 
393  console.XDebug() << "TSubLattice<T>::addWall: exit\n" ;
394 }
395 
399 template <class T>
401 {
402  console.XDebug() << "TSubLattice<T>::addSphereBody: enter\n" ;
403  CVarMPIBuffer param_buffer(m_comm);
404  param_buffer.receiveBroadcast(0);
405 
406  string name=param_buffer.pop_string();
407  Vec3 ipos=param_buffer.pop_vector();
408  double radius=param_buffer.pop_double();
409 
410  m_spheres[name]=new CSphereBody(ipos,radius);
411 
412  console.XDebug() << "TSubLattice<T>::addSphereBody: exit\n" ;
413 }
414 
418 template <class T>
420 {
421  console.XDebug() << "TSubLattice<T>::addElasticWIG: enter\n" ;
422  CVarMPIBuffer param_buffer(m_comm);
423 
424  // receive params from master
425  param_buffer.receiveBroadcast(0);
426 
427  CEWallIGP* wigp=extractEWallIGP(&param_buffer);
428 
429  string wallname=wigp->getWallName();
430  map<string,CWall*>::iterator iter=m_walls.find(wallname);
431  if(iter!=m_walls.end()){
432  AWallInteractionGroup<T>* newCEWIG =
434  &m_tml_worker_comm,
435  m_walls[wallname],
436  wigp
437  );
438  newCEWIG->Update(m_ppa);
439  m_WIG.insert(make_pair(wigp->getName(),newCEWIG));
440  } else {
441  std::stringstream msg;
442  msg << "wall name '" << wallname << "' not found in map of walls";
443  throw std::runtime_error(msg.str().c_str());
444  }
445 
446  delete wigp;
447  console.XDebug() << "TSubLattice<T>::addElasticWIG: exit\n" ;
448 }
449 
453 template <class T>
455 {
456  console.XDebug() << "TSubLattice<T>::addESphereBodyIG: enter\n" ;
457  CVarMPIBuffer param_buffer(m_comm);
458 
459  // receive params from master
460  param_buffer.receiveBroadcast(0);
461 
462  CESphereBodyIGP* wigp=extractESphereBodyIGP(&param_buffer);
463 
464  string wallname=wigp->getSphereBodyName();
465  map<string,CSphereBody*>::iterator iter=m_spheres.find(wallname);
466  if(iter!=m_spheres.end()){
469  &m_tml_worker_comm,
470  m_spheres[wallname],
471  wigp
472  );
473  newCEWIG->Update(m_ppa);
474  m_SIG.insert(make_pair(wigp->getName(),newCEWIG));
475  } else {
476  std::stringstream msg;
477  msg << "sphere body name '" << wallname << "' not found in map of sphere bodies";
478  throw std::runtime_error(msg.str().c_str());
479  }
480 
481  delete wigp;
482  console.XDebug() << "TSubLattice<T>::addESphereBodyIG: exit\n" ;
483 }
484 
488 template <class T>
490 {
491  console.XDebug() << "TSubLattice<T>::addTaggedElasticWIG: enter\n" ;
492  CVarMPIBuffer param_buffer(m_comm);
493 
494  // receive params from master
495  param_buffer.receiveBroadcast(0);
496 
497  CEWallIGP* wigp=extractEWallIGP(&param_buffer);
498  int tag=param_buffer.pop_int();
499  int mask=param_buffer.pop_int();
500 
501  string wallname=wigp->getWallName();
502 
503  console.XDebug() << wallname << " tag= " << tag << " mask= " << mask <<"\n" ;
504  map<string,CWall*>::iterator iter=m_walls.find(wallname);
505  if(iter!=m_walls.end()){
506  AWallInteractionGroup<T>* newCTEWIG =
508  &m_tml_worker_comm,
509  m_walls[wallname],
510  wigp,
511  tag,
512  mask
513  );
514  newCTEWIG->Update(m_ppa);
515  m_WIG.insert(make_pair(wigp->getName(),newCTEWIG));
516  } else {
517  std::stringstream msg;
518  msg << "wall name '" << wallname << "' not found in map of walls";
519  throw std::runtime_error(msg.str().c_str());
520  }
521 
522  delete wigp;
523  console.XDebug() << "TSubLattice<T>::addTaggedElasticWIG: exit\n" ;
524 }
525 
526 
530 template <class T>
532 {
533  console.XDebug() << "TSubLattice<T>::addBondedWIG: enter\n" ;
534  CVarMPIBuffer param_buffer(m_comm);
535 
536  // receive params from master
537  param_buffer.receiveBroadcast(0);
538 
539  CBWallIGP* wigp=extractBWallIGP(&param_buffer);
540 
541  string wallname=wigp->getWallName();
542  map<string,CWall*>::iterator iter=m_walls.find(wallname);
543  if(iter!=m_walls.end()){
544  AWallInteractionGroup<T>* newCBWIG=new CBWallInteractionGroup<T>(&m_tml_worker_comm,m_walls[wallname],wigp);
545  newCBWIG->Update(m_ppa);
546  m_WIG.insert(make_pair(wigp->getName(),newCBWIG));
547  } else {
548  console.Error() << "wall name " << wallname << " not found in map of walls\n";
549  }
550 
551  delete wigp;
552  console.XDebug() << "TSubLattice<T>::addBondedWIG: exit\n" ;
553 }
554 
558 template <class T>
560 {
561  console.XDebug() << "TSubLattice<T>::addDirBondedWIG: enter\n" ;
562  CVarMPIBuffer param_buffer(m_comm);
563 
564  // receive params from master
565  param_buffer.receiveBroadcast(0);
566 
567  CSoftBWallIGP* wigp=extractSoftBWallIGP(&param_buffer);
568 
569  string wallname=wigp->getWallName();
570  map<string,CWall*>::iterator iter=m_walls.find(wallname);
571  if(iter!=m_walls.end()){
572  AWallInteractionGroup<T>* newCDWIG=new CSoftBWallInteractionGroup<T>(&m_tml_worker_comm,m_walls[wallname],wigp);
573  newCDWIG->Update(m_ppa);
574  m_WIG.insert(make_pair(wigp->getName(),newCDWIG));
575  } else {
576  console.Error() << "wall name " << wallname << " not found in map of walls\n";
577  }
578 
579  delete wigp;
580  console.XDebug() << "TSubLattice<T>::addDirBondedWIG: exit\n" ;
581 }
582 
586 template <class T>
588 {
589  console.XDebug() << "TSubLattice<T>::getWallPosition: enter\n" ;
590  CVarMPIBuffer param_buffer(m_comm);
591  Vec3 pos;
592 
593  // receive params from master
594  param_buffer.receiveBroadcast(0);
595 
596  std::string wname=param_buffer.pop_string();
597  console.XDebug() << "Wall name: " << wname << "\n";
598 
599  // find wall
600  map<string,CWall*>::iterator iter=m_walls.find(wname);
601  if(iter!=m_walls.end()){
602  pos=(iter->second)->getPos();
603  console.XDebug() << "Wall pos: " << pos << "\n";
604  } else {
605  pos=Vec3(0.0,0.0,0.0);
606  }
607 
608  vector<Vec3> vpos;
609  vpos.push_back(pos);
610  m_tml_comm.send_gather(vpos,0);
611  console.XDebug() << "TSubLattice<T>::getWallPosition: exit\n" ;
612 }
613 
617 template <class T>
619 {
620  console.XDebug() << "TSubLattice<T>::getSphereBodyPosition: enter\n" ;
621  CVarMPIBuffer param_buffer(m_comm);
622  Vec3 pos;
623 
624  // receive params from master
625  param_buffer.receiveBroadcast(0);
626 
627  std::string wname=param_buffer.pop_string();
628  console.XDebug() << "Sphere name: " << wname << "\n";
629 
630  // find sphere
631  map<string,CSphereBody*>::iterator iter=m_spheres.find(wname);
632  if(iter!=m_spheres.end()){
633  pos=(iter->second)->getPos();
634  console.XDebug() << "Sphere pos: " << pos << "\n";
635  } else {
636  pos=Vec3(0.0,0.0,0.0);
637  }
638 
639  vector<Vec3> vpos;
640  vpos.push_back(pos);
641  m_tml_comm.send_gather(vpos,0);
642  console.XDebug() << "TSubLattice<T>::getSphereBodyPosition: exit\n" ;
643 }
644 
648 template <class T>
650 {
651  console.XDebug() << "TSubLattice<T>::getWallForce: enter\n" ;
652  CVarMPIBuffer param_buffer(m_comm);
653  Vec3 force;
654 
655  // receive params from master
656  param_buffer.receiveBroadcast(0);
657 
658  std::string wname=param_buffer.pop_string();
659  console.XDebug() << "Wall name: " << wname << "\n";
660 
661  // find wall
662  map<string,CWall*>::iterator iter=m_walls.find(wname);
663  if(iter!=m_walls.end()){
664  force=(iter->second)->getForce();
665  console.XDebug() << "Wall force: " << force << "\n";
666  } else {
667  force=Vec3(0.0,0.0,0.0);
668  }
669 
670  vector<Vec3> vforce;
671  vforce.push_back(force);
672  m_tml_comm.send_gather(vforce,0);
673  console.XDebug() << "TSubLattice<T>::getWallForce: exit\n" ;
674 }
675 
679 template <class T>
681 {
682  console.XDebug() << "TSubLattice<T>::getSphereBodyForce: enter\n" ;
683  CVarMPIBuffer param_buffer(m_comm);
684  Vec3 force;
685 
686  // receive params from master
687  param_buffer.receiveBroadcast(0);
688 
689  std::string wname=param_buffer.pop_string();
690  console.XDebug() << "Sphere name: " << wname << "\n";
691 
692  // find Sphere
693  map<string,CSphereBody*>::iterator iter=m_spheres.find(wname);
694  if(iter!=m_spheres.end()){
695  force=(iter->second)->getForce();
696  console.XDebug() << "Sphere force: " << force << "\n";
697  } else {
698  force=Vec3(0.0,0.0,0.0);
699  }
700 
701  vector<Vec3> vforce;
702  vforce.push_back(force);
703  m_tml_comm.send_gather(vforce,0);
704  console.XDebug() << "TSubLattice<T>::getSphereBodyForce: exit\n" ;
705 }
706 
710 template <class T>
712 {
713  console.XDebug() << "TSubLattice<T>::addViscWIG: enter\n" ;
714  CVarMPIBuffer param_buffer(m_comm);
715 
716  // receive params from master
717  param_buffer.receiveBroadcast(0);
718 
719  CVWallIGP* wigp=extractVWallIGP(&param_buffer);
720 
721  string wallname=wigp->getWallName();
722  map<string,CWall*>::iterator iter=m_walls.find(wallname);
723  if(iter!=m_walls.end()){
724  AWallInteractionGroup<T>* newCVWIG=new CViscWallIG<T>(&m_tml_worker_comm,m_walls[wallname],wigp);
725  newCVWIG->Update(m_ppa);
726  m_WIG.insert(make_pair(wigp->getName(),newCVWIG));
727  } else {
728  console.Error() << "wall name " << wallname << " not found in map of walls\n";
729  }
730 
731  delete wigp;
732  console.XDebug() << "TSubLattice<T>::addViscWIG: exit\n" ;
733 }
734 
738 template <class T>
740 {
741  console.XDebug() << "TSubLattice<T>::addPairIG()\n";
742  CVarMPIBuffer param_buffer(m_comm,2000);
743 
744  // get params
745  param_buffer.receiveBroadcast(0);
746  string type = param_buffer.pop_string();
747  console.XDebug()<< "PIG type: " << type.c_str() << "\n";
748  string name = param_buffer.pop_string();
749  console.XDebug()<< "PIG name: " << name.c_str() << "\n";
750 
751  doAddPIG(name,type,param_buffer,false);
752 
753  console.XDebug() << "end TSubLattice<T>::addPairIG()\n";
754 }
755 
759 template <class T>
761 {
762  console.XDebug() << "TSubLattice<T>::addTaggedPairIG()\n";
763  CVarMPIBuffer param_buffer(m_comm,2000);
764 
765  // get params
766  param_buffer.receiveBroadcast(0);
767  string type = param_buffer.pop_string();
768  console.XDebug()<< "PIG type: " << type.c_str() << "\n";
769  string name = param_buffer.pop_string();
770  console.XDebug()<< "PIG name: " << name.c_str() << "\n";
771 
772  doAddPIG(name,type,param_buffer,true);
773 
774  console.XDebug() << "end TSubLattice<T>::addTaggedPairIG()\n";
775 }
776 
784 template <class T>
785 bool TSubLattice<T>::doAddPIG(const string& name,const string& type,CVarMPIBuffer& param_buffer, bool tagged)
786 {
787  bool res=false;
789 
790  if(type=="Elastic") {
791  CElasticIGP eigp;
792  eigp.m_k=param_buffer.pop_double();
793  eigp.m_scaling=static_cast<bool>(param_buffer.pop_int());
794  if(tagged){
795  int tag1=param_buffer.pop_int();
796  int mask1=param_buffer.pop_int();
797  int tag2=param_buffer.pop_int();
798  int mask2=param_buffer.pop_int();
799  console.XDebug() << "tag1, mask1, tag2, mask2 "
800  << tag1 << " , " << mask1 << " , "
801  << tag2 << " , " << mask2 << "\n";
802  new_pis=new ParallelInteractionStorage_NE_T<T,CElasticInteraction>(m_ppa,eigp,tag1,mask1,tag2,mask2);
803  }else{
805  }
806  res=true;
807  } else if (type=="Friction") {
808  CFrictionIGP figp;
809  figp.k=param_buffer.pop_double();
810  figp.mu=param_buffer.pop_double();
811  figp.k_s=param_buffer.pop_double();
812  figp.dt=param_buffer.pop_double();
813  figp.m_scaling=static_cast<bool>(param_buffer.pop_int());
814  console.XDebug() << "k,mu,k_s,dt: " << figp.k << " , " << figp.mu << " , "
815  << figp.k_s << " , " << figp.dt << "\n";
817  res=true;
818  } else if (type=="AdhesiveFriction") {
820  figp.k=param_buffer.pop_double();
821  figp.mu=param_buffer.pop_double();
822  figp.k_s=param_buffer.pop_double();
823  figp.dt=param_buffer.pop_double();
824  figp.r_cut=param_buffer.pop_double();
825  console.XDebug()
826  << "k,mu,k_s,dt,r_cut: " << figp.k << " , " << figp.mu << " , "
827  << figp.k_s << " , " << figp.dt << " " << figp.r_cut << "\n";
829  res=true;
830  } else if (type=="FractalFriction") {
831  FractalFrictionIGP figp;
832  figp.k=param_buffer.pop_double();
833  figp.mu_0=param_buffer.pop_double();
834  figp.k_s=param_buffer.pop_double();
835  figp.dt=param_buffer.pop_double();
836  console.XDebug() << "k,mu_0,k_s,dt: " << figp.k << " , " << figp.mu_0 << " , "
837  << figp.k_s << " , " << figp.dt << "\n";
838  figp.x0=param_buffer.pop_double();
839  figp.y0=param_buffer.pop_double();
840  figp.dx=param_buffer.pop_double();
841  figp.dy=param_buffer.pop_double();
842  figp.nx=param_buffer.pop_int();
843  figp.ny=param_buffer.pop_int();
844  console.XDebug()
845  <<"x0,y0,dx,dy,nx,ny: "
846  << figp.x0 << " , " << figp.y0 << " , "
847  << figp.dx << " , " << figp.dy << " ,"
848  << figp.nx << " , " << figp.ny << "\n";
849  figp.mu = boost::shared_ptr<double>(new double[figp.nx*figp.ny]);
850 
851  for(int i=0;i<figp.nx*figp.ny;i++)
852  {
853  (figp.mu.get())[i]=param_buffer.pop_double();
854  // console.XDebug() << i << " , " << figp.mu[i] << "\n";
855  }
856  new_pis = new ParallelInteractionStorage_ED<T,CFractalFriction>(m_ppa,figp);
857  res=true;
858  } else if(type=="VWFriction") {
859  VWFrictionIGP figp;
860 
861  figp.k=param_buffer.pop_double();
862  figp.mu=param_buffer.pop_double();
863  figp.k_s=param_buffer.pop_double();
864  figp.dt=param_buffer.pop_double();
865  figp.m_alpha=param_buffer.pop_double();
866  console.XDebug()
867  << "k,mu,k_s,dt,alpha: " << figp.k << " , " << figp.mu << " , "
868  << figp.k_s << " , " << figp.dt << "\n";
869  new_pis=new ParallelInteractionStorage_ED<T,CVWFriction>(m_ppa,figp);
870  res=true;
871  } else if(type=="RotElastic"){
872  CRotElasticIGP reigp;
873  reigp.m_kr=param_buffer.pop_double();
875  res=true;
876  } else if (type=="RotFriction"){
877  CRotFrictionIGP rfigp;
878  rfigp.k=param_buffer.pop_double();
879  rfigp.mu_s=param_buffer.pop_double();
880  rfigp.mu_d=param_buffer.pop_double();
881  rfigp.k_s=param_buffer.pop_double();
882  rfigp.dt=param_buffer.pop_double();
883  rfigp.scaling=static_cast<bool>(param_buffer.pop_int());
884  rfigp.meanR_scaling=static_cast<bool>(param_buffer.pop_int());
885  console.XDebug()
886  << "k,mu_s,mu_d,k_s,dt,scaling: " << rfigp.k << " , "
887  << rfigp.mu_s << " , " << rfigp.mu_d << " , "
888  << rfigp.k_s << " , " << rfigp.dt << " , " << rfigp.scaling << "\n";
889  if(tagged){
890  int tag1=param_buffer.pop_int();
891  int mask1=param_buffer.pop_int();
892  int tag2=param_buffer.pop_int();
893  int mask2=param_buffer.pop_int();
894  console.XDebug() << "tag1, mask1, tag2, mask2 "
895  << tag1 << " , " << mask1 << " , "
896  << tag2 << " , " << mask2 << "\n";
897  new_pis=new ParallelInteractionStorage_ED_T<CRotParticle,CRotFrictionInteraction>(m_ppa,rfigp,tag1,mask1,tag2,mask2);
898  } else {
900  }
901  res=true;
902  } else if (type == "RotThermElastic") {
903  CRotThermElasticIGP eigp;
904  eigp.m_kr = param_buffer.pop_double();
905  eigp.diffusivity = param_buffer.pop_double();
906  console.XDebug()
907  << "k=" << eigp.m_kr << " , "
908  << "diffusivity=" << eigp.diffusivity << "\n";
909 
910  new_pis =
914  >(
915  m_ppa,
916  eigp
917  );
918  res=true;
919  } else if (type == "RotThermFriction") {
920  CRotThermFrictionIGP rfigp;
921  rfigp.k=param_buffer.pop_double();
922  rfigp.mu_s=param_buffer.pop_double();
923  rfigp.mu_d=param_buffer.pop_double();
924  rfigp.k_s=param_buffer.pop_double();
925  rfigp.diffusivity=param_buffer.pop_double();
926  rfigp.dt=param_buffer.pop_double();
927  console.XDebug()
928  << "k=" << rfigp.k << " , "
929  << "mu_d=" << rfigp.mu_d << " , "
930  << "mu_s=" << rfigp.mu_s << " , "
931  << "k_s=" << rfigp.k_s << " , "
932  << "diffusivity=" << rfigp.diffusivity << " , "
933  << "dt=" << rfigp.dt << "\n";
934 
935  new_pis =
939  >(
940  m_ppa,
941  rfigp
942  );
943  res=true;
944  } else if(type=="HertzianElastic") {
945  CHertzianElasticIGP heigp;
946  heigp.m_E=param_buffer.pop_double();
947  heigp.m_nu=param_buffer.pop_double();
948  if(tagged){
949  int tag1=param_buffer.pop_int();
950  int mask1=param_buffer.pop_int();
951  int tag2=param_buffer.pop_int();
952  int mask2=param_buffer.pop_int();
953  new_pis=new ParallelInteractionStorage_NE_T<T,CHertzianElasticInteraction>(m_ppa,heigp,tag1,mask1,tag2,mask2);
954  }else{
956  }
957  res=true;
958  } else if(type=="HertzianViscoElasticFriction") {
960  hvefigp.m_A=param_buffer.pop_double();
961  hvefigp.m_E=param_buffer.pop_double();
962  hvefigp.m_nu=param_buffer.pop_double();
963  hvefigp.mu=param_buffer.pop_double();
964  hvefigp.k_s=param_buffer.pop_double();
965  hvefigp.dt=param_buffer.pop_double();
966  if(tagged){
967  int tag1=param_buffer.pop_int();
968  int mask1=param_buffer.pop_int();
969  int tag2=param_buffer.pop_int();
970  int mask2=param_buffer.pop_int();
971  new_pis=new ParallelInteractionStorage_NE_T<T,CHertzianViscoElasticFrictionInteraction>(m_ppa,hvefigp,tag1,mask1,tag2,mask2);
972  }else{
974  }
975  res=true;
976  } else if(type=="HertzianViscoElastic") {
978  hveigp.m_A=param_buffer.pop_double();
979  hveigp.m_E=param_buffer.pop_double();
980  hveigp.m_nu=param_buffer.pop_double();
981  if(tagged){
982  int tag1=param_buffer.pop_int();
983  int mask1=param_buffer.pop_int();
984  int tag2=param_buffer.pop_int();
985  int mask2=param_buffer.pop_int();
986  new_pis=new ParallelInteractionStorage_NE_T<T,CHertzianViscoElasticInteraction>(m_ppa,hveigp,tag1,mask1,tag2,mask2);
987  }else{
989  }
990  res=true;
991  } else if(type=="LinearDashpot") {
992  CLinearDashpotIGP heigp;
993  heigp.m_damp=param_buffer.pop_double();
994  heigp.m_cutoff=param_buffer.pop_double();
995  if(tagged){
996  int tag1=param_buffer.pop_int();
997  int mask1=param_buffer.pop_int();
998  int tag2=param_buffer.pop_int();
999  int mask2=param_buffer.pop_int();
1000  new_pis=new ParallelInteractionStorage_NE_T<T,CLinearDashpotInteraction>(m_ppa,heigp,tag1,mask1,tag2,mask2);
1001  }else{
1003  }
1004  res=true;
1005  } else {
1006  cerr << "Unknown interaction group name "
1007  << type
1008  << " in TSubLattice<T>::addPairIG()" << endl;
1009  }
1010 
1011  // add InteractionGroup to map
1012  if(res) m_dpis.insert(make_pair(name,new_pis));
1013 
1014  return res;
1015 }
1016 
1017 
1021 template <class T>
1023 {
1024  console.XDebug() << "TSubLattice<T>::addTriMesh()\n";
1025 
1026  // MPI buffer
1027  CVarMPIBuffer param_buffer(m_comm);
1028  // data buffers
1029  vector<MeshNodeData> node_recv_buffer;
1030  vector<MeshTriData> tri_recv_buffer;
1031 
1032  // receive params
1033  param_buffer.receiveBroadcast(0);
1034 
1035  // extract name
1036  string name = param_buffer.pop_string();
1037  console.XDebug()<< "TriMesh name: " << name.c_str() << "\n";
1038 
1039  // receive nodes
1040  m_tml_comm.recv_broadcast_cont_packed(node_recv_buffer,0);
1041  console.XDebug() << "recvd " << node_recv_buffer.size() << " nodes \n";
1042 
1043  // receive triangles
1044  m_tml_comm.recv_broadcast_cont_packed(tri_recv_buffer,0);
1045  console.XDebug() << "recvd " << tri_recv_buffer.size() << " triangles \n";
1046 
1047  // load mesh into new TriMesh
1048  TriMesh* new_tm=new TriMesh();
1049  new_tm->LoadMesh(node_recv_buffer,tri_recv_buffer);
1050 
1051  m_mesh.insert(make_pair(name,new_tm));
1052 
1053  console.XDebug() << "end TSubLattice<T>::addTriMesh()\n";
1054 }
1055 
1059 template <class T>
1061 {
1062  console.XDebug() << "TSubLattice<T>::addTriMeshIG()\n";
1063 
1064  // MPI buffer
1065  CVarMPIBuffer param_buffer(m_comm);
1066 
1067  // receive params
1068  param_buffer.receiveBroadcast(0);
1069 
1070  // extract name & type
1071  string type = param_buffer.pop_string();
1072  console.XDebug()<< "TriMeshIG type: " << type.c_str() << "\n";
1073  string name = param_buffer.pop_string();
1074  console.XDebug()<< "TriMeshIG name: " << name.c_str() << "\n";
1075  string meshname = param_buffer.pop_string();
1076  console.XDebug()<< "TriMeshIG mesh name: " << meshname.c_str() << "\n";
1077 
1078  // get pointer to mesh
1079  TriMesh* tmp=NULL;
1080  if (m_mesh.find(meshname) != m_mesh.end())
1081  {
1082  tmp = m_mesh[meshname];
1083  }
1084  if(tmp==NULL){
1085  throw runtime_error("unknown mesh name in TSubLattice<T>::addTriMeshIG:" + meshname);
1086  }
1087  // switch on type,extract params & construc new TriMeshIG
1088  if(type=="Elastic")
1089  {
1090  AParallelInteractionStorage* new_pis;
1091  ETriMeshIP tmi;
1092  tmi.k=param_buffer.pop_double();
1093  new_pis = new TriMesh_PIS_NE<T,ETriMeshInteraction>(tmp,m_ppa,tmi);
1094  m_dpis.insert(make_pair(name,new_pis));
1095  } else { // unknown type-> throw
1096  throw runtime_error("unknown type in TSubLattice<T>::addTriMeshIG:" + type);
1097  }
1098 
1099 
1100  console.XDebug() << "end TSubLattice<T>::addTriMeshIG()\n";
1101 }
1102 
1106 template <class T>
1108 {
1109  console.XDebug() << "TSubLattice<T>::addBondedTriMeshIG()\n";
1110 
1111  // MPI buffer
1112  CVarMPIBuffer param_buffer(m_comm);
1113 
1114  // receive params
1115  BTriMeshIP param;
1116  param_buffer.receiveBroadcast(0);
1117 
1118  // extract name.meshname & params
1119  string name = param_buffer.pop_string();
1120  console.XDebug()<< "BTriMeshIG name: " << name.c_str() << "\n";
1121  string meshname = param_buffer.pop_string();
1122  console.XDebug()<< "BTriMeshIG mesh name: " << meshname.c_str() << "\n";
1123  param.k = param_buffer.pop_double();
1124  console.XDebug()<< "BTriMeshIG k : " << param.k << "\n";
1125  param.brk = param_buffer.pop_double();
1126  console.XDebug()<< "BTriMeshIG r_break: " << param.brk << "\n";
1127  string buildtype = param_buffer.pop_string();
1128  console.XDebug()<< "BTriMeshIG build type: " << buildtype.c_str() << "\n";
1129 
1130  // get pointer to mesh
1131  TriMesh* tmp=NULL;
1132  if (m_mesh.find(meshname) != m_mesh.end())
1133  {
1134  tmp = m_mesh[meshname];
1135  }
1136  if(tmp==NULL){
1137  throw runtime_error("unknown mesh name in TSubLattice<T>::addTriMeshIG:" + meshname);
1138  }
1139 
1140  // setup new interaction storage
1142  // switch on buildtype, extract buildparam & build
1143  if(buildtype=="BuildByTag"){
1144  int tag=param_buffer.pop_int();
1145  int mask=param_buffer.pop_int();
1146  new_pis->buildFromPPATagged(tag,mask);
1147  m_bpis.insert(make_pair(name,new_pis));
1148  } else if(buildtype=="BuildByGap"){
1149  double max_gap=param_buffer.pop_double();
1150  new_pis->buildFromPPAByGap(max_gap);
1151  m_bpis.insert(make_pair(name,new_pis));
1152  } else { // unknown type-> throw
1153  throw runtime_error("unknown build type in TSubLattice<T>::addBondedTriMeshIG:" + buildtype);
1154  }
1155 
1156  console.XDebug() << "end TSubLattice<T>::addBondedTriMeshIG()\n";
1157 }
1158 
1162 template <class T>
1164 {
1165  console.XDebug() << "TSubLattice<T>::addMesh2D()\n";
1166 
1167  // MPI buffer
1168  CVarMPIBuffer param_buffer(m_comm);
1169  // data buffers
1170  vector<MeshNodeData2D> node_recv_buffer;
1171  vector<MeshEdgeData2D> edge_recv_buffer;
1172 
1173  // receive params
1174  param_buffer.receiveBroadcast(0);
1175 
1176  // extract name
1177  string name = param_buffer.pop_string();
1178  console.XDebug()<< "Mesh2D name: " << name.c_str() << "\n";
1179 
1180  // receive nodes
1181  m_tml_comm.recv_broadcast_cont_packed(node_recv_buffer,0);
1182  console.XDebug() << "recvd " << node_recv_buffer.size() << " nodes \n";
1183 
1184  // receive edges
1185  m_tml_comm.recv_broadcast_cont_packed(edge_recv_buffer,0);
1186  console.XDebug() << "recvd " << edge_recv_buffer.size() << " edges \n";
1187 
1188  // load mesh into new 2D Mesh
1189  Mesh2D* new_tm=new Mesh2D();
1190  new_tm->LoadMesh(node_recv_buffer,edge_recv_buffer);
1191 
1192  m_mesh2d.insert(make_pair(name,new_tm));
1193 
1194  console.XDebug() << "end TSubLattice<T>::addMesh2D()\n";
1195 }
1196 
1201 template <class T>
1203 {
1204 console.XDebug() << "TSubLattice<T>::addMesh2DIG()\n";
1205 
1206  // MPI buffer
1207  CVarMPIBuffer param_buffer(m_comm);
1208 
1209  // receive params
1210  param_buffer.receiveBroadcast(0);
1211 
1212  // extract name & type
1213  string type = param_buffer.pop_string();
1214  console.XDebug()<< "Mesh2DIG type: " << type.c_str() << "\n";
1215  string name = param_buffer.pop_string();
1216  console.XDebug()<< "Mesh2DIG name: " << name.c_str() << "\n";
1217  string meshname = param_buffer.pop_string();
1218  console.XDebug()<< "Mesh2DIG mesh name: " << meshname.c_str() << "\n";
1219 
1220  // get pointer to mesh
1221  Mesh2D* tmp=NULL;
1222  if (m_mesh2d.find(meshname) != m_mesh2d.end())
1223  {
1224  tmp = m_mesh2d[meshname];
1225  }
1226  if(tmp==NULL){
1227  throw runtime_error("unknown mesh name in TSubLattice<T>::addMesh2DIG:" + meshname);
1228  }
1229  // switch on type,extract params & construc new Mesh2DIG
1230  if(type=="Elastic")
1231  {
1232  AParallelInteractionStorage* new_pis;
1233  ETriMeshIP tmi;
1234  tmi.k=param_buffer.pop_double();
1235  new_pis = new Mesh2D_PIS_NE<T,EMesh2DInteraction>(tmp,m_ppa,tmi);
1236  m_dpis.insert(make_pair(name,new_pis));
1237  } else { // unknown type-> throw
1238  throw runtime_error("unknown type in TSubLattice<T>::addMesh2DIG:" + type);
1239  }
1240 
1241 
1242  console.XDebug() << "end TSubLattice<T>::addTriMeshIG()\n";
1243 }
1244 
1249 template <class T>
1251 {
1252  console.XDebug() << "TSubLattice<T>::addBondedMesh2DIG()\n";
1253 
1254  // MPI buffer
1255  CVarMPIBuffer param_buffer(m_comm);
1256 
1257  // receive params
1258  BMesh2DIP param;
1259  param_buffer.receiveBroadcast(0);
1260 
1261  // extract name.meshname & params
1262  string name = param_buffer.pop_string();
1263  console.XDebug() << "BMesh2DIG name: " << name.c_str() << "\n";
1264  string meshname = param_buffer.pop_string();
1265  console.XDebug() << "BMesh2DIG mesh name: " << meshname.c_str() << "\n";
1266  param.k = param_buffer.pop_double();
1267  console.XDebug() << "BMesh2DIG k : " << param.k << "\n";
1268  param.brk = param_buffer.pop_double();
1269  console.XDebug() << "BMesh2DIG r_break: " << param.brk << "\n";
1270  string buildtype = param_buffer.pop_string();
1271  console.XDebug() << "BMesh2DIG build type: " << buildtype.c_str() << "\n";
1272 
1273  // get pointer to mesh
1274  Mesh2D* tmp=NULL;
1275  if (m_mesh2d.find(meshname) != m_mesh2d.end())
1276  {
1277  tmp = m_mesh2d[meshname];
1278  }
1279  if(tmp==NULL){
1280  throw runtime_error("unknown mesh name in TSubLattice<T>::addBondedMesh2DIG:" + meshname);
1281  }
1282 
1283  // setup new interaction storage
1285  // switch on buildtype, extract buildparam & build
1286  if(buildtype=="BuildByTag"){
1287  int tag=param_buffer.pop_int();
1288  int mask=param_buffer.pop_int();
1289  new_pis->buildFromPPATagged(tag,mask);
1290  m_bpis.insert(make_pair(name,new_pis));
1291  } else if(buildtype=="BuildByGap"){
1292  double max_gap=param_buffer.pop_double();
1293  new_pis->buildFromPPAByGap(max_gap);
1294  m_bpis.insert(make_pair(name,new_pis));
1295  } else { // unknown type-> throw
1296  throw runtime_error("unknown build type in TSubLattice<T>::addBondedMesh2DIG:" + buildtype);
1297  }
1298 
1299  console.XDebug() << "end TSubLattice<T>::addBonded2DMeshIG()\n";
1300 }
1301 
1302 
1308 template <class T>
1310 {
1311  console.XDebug() << "TSubLattice<T>::addSingleIG()\n";
1312  CVarMPIBuffer param_buffer(m_comm);
1313 
1314  // get params
1315  param_buffer.receiveBroadcast(0);
1316 
1317  string type = param_buffer.pop_string();
1318  console.XDebug()<< "SIG type: " << type.c_str() << "\n";
1319 
1320  // setup InteractionGroup
1321  if(type=="Gravity"){
1323 
1324  // add to map
1325  m_singleParticleInteractions.insert(
1326  std::pair<string,AInteractionGroup<T>*>(
1327  prms.Name(),
1328  new esys::lsm::BodyForceGroup<T>(prms, *m_ppa)
1329  )
1330  );
1331  }
1332  else if (type=="Buoyancy"){
1334 
1335  // add to map
1336  m_singleParticleInteractions.insert(
1337  std::pair<string,AInteractionGroup<T>*>(
1338  prms.Name(),
1339  new esys::lsm::BuoyancyForceGroup<T>(prms, *m_ppa)
1340  )
1341  );
1342  }
1343  else {
1344  throw std::runtime_error(
1345  std::string("Trying to setup SIG of unknown type: ")
1346  +
1347  type
1348  );
1349  }
1350 
1351  console.XDebug() << "end TSubLattice<T>::addSingleIG()\n";
1352 }
1353 
1354 
1358 template <class T>
1360 {
1361  console.XDebug() << "TSubLattice<T>::addDamping()\n";
1362  CVarMPIBuffer param_buffer(m_comm);
1363  // get params
1364  param_buffer.receiveBroadcast(0);
1365 
1366  string type = param_buffer.pop_string();
1367  console.XDebug()<< "Damping type: " << type.c_str() << "\n";
1368 
1369  // setup InteractionGroup
1370  doAddDamping(type,param_buffer);
1371 
1372  console.XDebug() << "end TSubLattice<T>::addDamping()\n";
1373 }
1374 
1381 template <class T>
1382 bool TSubLattice<T>::doAddDamping(const string& type,CVarMPIBuffer& param_buffer)
1383 {
1385  string damping_name;
1386  bool res;
1387 
1388  if(type=="Damping")
1389  {
1390  CDampingIGP *params=extractDampingIGP(&param_buffer);
1391  DG=new ParallelInteractionStorage_Single<T,CDamping<T> >(m_ppa,*params);
1392  damping_name="Damping";
1393  res=true;
1394  } else if (type=="ABCDamping"){
1395  ABCDampingIGP *params=extractABCDampingIGP(&param_buffer);
1396  DG=new ParallelInteractionStorage_Single<T,ABCDamping<T> >(m_ppa,*params);
1397  damping_name=params->getName();
1398  res=true;
1399  } else if (type=="LocalDamping"){
1400  CLocalDampingIGP *params=extractLocalDampingIGP(&param_buffer);
1402  damping_name=params->getName();
1403  res=true;
1404  }else {
1405  std::stringstream msg;
1406  msg << "Trying to setup Damping of unknown type: " << type;
1407  console.Error() << msg.str() << "\n";
1408  throw std::runtime_error(msg.str());
1409  res=false;
1410  }
1411 
1412  // add to map
1413  if(res) {
1414  m_damping.insert(make_pair(damping_name,DG));
1415  m_damping[damping_name]->update();
1416  }
1417  return res;
1418 }
1419 
1424 template <class T>
1426 {
1427  console.XDebug() << "TSubLattice<T>::addBondedIG()\n";
1428  CVarMPIBuffer param_buffer(m_comm);
1429 
1430  // get params
1431  CBondedIGP param;
1432  param_buffer.receiveBroadcast(0);
1433  param.tag=param_buffer.pop_int();
1434  string name = param_buffer.pop_string();
1435  param.k=param_buffer.pop_double();
1436  param.rbreak=param_buffer.pop_double();
1437  param.m_scaling=static_cast<bool>(param_buffer.pop_int());
1438 
1439  console.XDebug()
1440  << "Got BondedIG parameters: " << param.tag
1441  << " " << name.c_str() << " "
1442  << param.k << " " << param.rbreak << "\n";
1443  // setup InteractionGroup
1446 
1447  // set unbreakable if rbeak<0
1448  if(param.rbreak<0){
1449  B_PIS->setUnbreakable(true);
1450  console.XDebug() << "set bpis unbreakable\"n";
1451  }
1452 
1453  vector<int> vi(2,-1);
1454  for(size_t i=0;i<m_temp_conn[param.tag].size();i+=2)
1455  {
1456  vi[0] = (m_temp_conn[param.tag][i]);
1457  vi[1] = (m_temp_conn[param.tag][i+1]);
1458  B_PIS->tryInsert(vi);
1459  }
1460 
1461  // add InteractionGroup to map
1462  m_bpis.insert(make_pair(name,B_PIS));
1463 
1464  console.XDebug() << "end TSubLattice<T>::addBondedIG()\n";
1465 }
1466 
1471 template <class T>
1473 {
1474  console.XDebug() << "TSubLattice<T>::addCappedBondedIG()\n";
1475  CVarMPIBuffer param_buffer(m_comm);
1476 
1477  // get params
1478  param_buffer.receiveBroadcast(0);
1479  int tag=param_buffer.pop_int();
1480  string name = param_buffer.pop_string();
1481  double k=param_buffer.pop_double();
1482  double rbreak=param_buffer.pop_double();
1483  double maxforce=param_buffer.pop_double();
1484 
1485  console.XDebug()
1486  << "Got CappedBondedIG parameters: " << tag
1487  << " " << name.c_str() << " "
1488  << k << " " << rbreak << " " << maxforce << "\n";
1489  // setup InteractionGroup
1490  CCappedBondedIGP param;
1491  param.k=k;
1492  param.rbreak=rbreak;
1493  param.tag = tag;
1494  param.m_force_limit=maxforce;
1497 
1498  // set unbreakable if rbeak<0
1499  if(rbreak<0){
1500  B_PIS->setUnbreakable(true);
1501  console.XDebug() << "set bpis unbreakable\"n";
1502  }
1503  // recv broadcast connection data
1504  /*console.XDebug()
1505  << "rank=" << m_tml_comm.rank()
1506  << "TSubLattice<T>::addCappedBondedIG(): receiving conn_data.\n";
1507 
1508  vector<int> conn_data;
1509  m_tml_comm.recv_broadcast_cont(conn_data,0);
1510  console.XDebug()
1511  << "rank=" << m_tml_comm.rank()
1512  << "TSubLattice<T>::addBondedIG(): conn_data.size()="
1513  << conn_data.size() << "\n";
1514  */
1515  vector<int> vi(2,-1);
1516  for(size_t i=0;i<m_temp_conn[tag].size();i+=2)
1517  {
1518  vi[0] = (m_temp_conn[tag][i]);
1519  vi[1] = (m_temp_conn[tag][i+1]);
1520  B_PIS->tryInsert(vi);
1521  }
1522 
1523  // add InteractionGroup to map
1524  m_bpis.insert(make_pair(name,B_PIS));
1525 
1526  console.XDebug() << "end TSubLattice<T>::addCappedBondedIG()\n";
1527 }
1528 
1529 template <class T>
1531 {
1532  console.Error() << "TSubLattice<T>::addRotBondedIG() => trying to add rotational bonded IG to nonrotational model\n";
1533 }
1534 
1535 template <class T>
1537 {
1538  console.Error() << "TSubLattice<T>::addRotThermBondedIG() => trying to add rotational thermal bonded IG to nonrotational model\n";
1539 }
1540 
1545 template <class T>
1547 {
1548  console.XDebug() << "TSubLattice<T>::addShortBondedIG()\n";
1549  CVarMPIBuffer param_buffer(m_comm);
1550 
1551  // get params
1552  param_buffer.receiveBroadcast(0);
1553  int tag=param_buffer.pop_int();
1554  string name = param_buffer.pop_string();
1555  double k=param_buffer.pop_double();
1556  double rbreak=param_buffer.pop_double();
1557 
1558  console.XDebug()
1559  << "Got ShortBondedIG parameters: " << tag
1560  << " " << name.c_str() << " "
1561  << k << " " << rbreak << "\n";
1562  // setup InteractionGroup
1563  CBondedIGP param;
1564  param.k=k;
1565  param.rbreak=rbreak;
1566  param.tag = tag;
1569 
1570  // recv broadcast connection data
1571  /*console.XDebug()
1572  << "rank=" << m_tml_comm.rank()
1573  << "TSubLattice<T>::addShortBondedIG(): receiving conn_data.\n";
1574 
1575  vector<int> conn_data;
1576  m_tml_comm.recv_broadcast_cont(conn_data,0);
1577  console.XDebug()
1578  << "rank=" << m_tml_comm.rank()
1579  << "TSubLattice<T>::addShortBondedIG(): conn_data.size()="
1580  << conn_data.size() << "\n";*/
1581 
1582  vector<int> vi(2,-1);
1583  for(size_t i=0;i<m_temp_conn[param.tag].size();i+=2)
1584  {
1585  vi[0] = (m_temp_conn[param.tag][i]);
1586  vi[1] = (m_temp_conn[param.tag][i+1]);
1587  B_PIS->tryInsert(vi);
1588  }
1589 
1590  // add InteractionGroup to map
1591  m_bpis.insert(make_pair(name,B_PIS));
1592 
1593  console.XDebug() << "end TSubLattice<T>::addShortBondedIG()\n";
1594 }
1595 
1601 template <class T>
1603 {
1604  console.XDebug() << "TSubLattice<T>::addExIG()\n";
1605  CVarMPIBuffer pbuffer(m_comm);
1606 
1607  // get params
1608  pbuffer.receiveBroadcast(0);
1609  string s1 = pbuffer.pop_string();
1610  string s2 = pbuffer.pop_string();
1611 
1612  //console.XDebug()<< s1.c_str() << " " << s2.c_str() << "\n";
1613  map<string,AParallelInteractionStorage*>::iterator bonded_ig=m_bpis.find(s1);
1614  map<string,AParallelInteractionStorage*>::iterator dynamic_ig=m_dpis.find(s2);
1615  if((bonded_ig!=m_bpis.end())&&(dynamic_ig!=m_dpis.end()))
1616  {
1617  // map iterators point to [key,value] pairs, therefore it->second
1618  // is the pointer to the PIS here
1619  dynamic_ig->second->addExIG(bonded_ig->second);
1620  }
1621  else
1622  {
1623  console.Error() << "TSubLattice<T>::setExIG() - nonexisting interaction group \n";
1624  }
1625 
1626  console.XDebug() << "end TSubLattice<T>::addExIG()\n";
1627 }
1628 
1634 template <class T>
1636 {
1637  console.XDebug() << "TSubLattice<T>::removeIG()\n";
1638  CVarMPIBuffer pbuffer(m_comm);
1639  bool found=false;
1640 
1641  // get params
1642  pbuffer.receiveBroadcast(0);
1643  string igname = pbuffer.pop_string();
1644  // look for name in map of non-bondend particle pair interactions
1645  map<string,AParallelInteractionStorage*>::iterator iter=m_dpis.find(igname);
1646  // if found, remove interaction
1647  if(iter!=m_dpis.end()){
1648  found=true;
1649  delete m_dpis[igname];
1650  m_dpis.erase(iter);
1651  } else {
1652  // if not found, look in unbonded wall interactions
1653  typename map<string,AWallInteractionGroup<T>*>::iterator it2=m_WIG.find(igname);
1654  if(it2!=m_WIG.end()){
1655  found=true;
1656  delete m_WIG[igname];
1657  m_WIG.erase(it2);
1658  }
1659  }
1660 
1661  if(!found) {
1662  console.Error() << "TSubLattice<T>::removeIG() - nonexisting interaction group - ignore removal\n";
1663  }
1664 }
1665 
1666 
1670 template <class T>
1672 {
1673  console.XDebug() << "TSubLattice<T>::exchangePos() \n" ;
1674 
1675  m_ppa->exchange(&T::getExchangeValues,&T::setExchangeValues);
1676 
1677  console.XDebug() << "end TSubLattice<T>::exchangePos()\n" ;
1678 }
1679 
1683 template <class T>
1685 {
1686  console.XDebug() << "TSubLattice<T>::zeroForces()\n";
1687 
1688  // particles
1689  m_ppa->forAllParticles(&T::zeroForce);
1690  // trimeshes
1691  for(map<string,TriMesh*>::iterator iter=m_mesh.begin();
1692  iter!=m_mesh.end();
1693  iter++){
1694  (iter->second)->zeroForces();
1695  }
1696 
1697  // 2d meshes
1698  for(map<string,Mesh2D*>::iterator iter=m_mesh2d.begin();
1699  iter!=m_mesh2d.end();
1700  iter++){
1701  (iter->second)->zeroForces();
1702  }
1703  // walls
1704  for(typename map<string,CWall*>::iterator iter=m_walls.begin();
1705  iter!=m_walls.end();
1706  iter++)
1707  {
1708  (iter->second)->zeroForce();
1709  }
1710  // sphere bodies
1711  for(typename map<string,CSphereBody*>::iterator iter=m_spheres.begin();
1712  iter!=m_spheres.end();
1713  iter++)
1714  {
1715  (iter->second)->zeroForce();
1716  }
1717  console.XDebug() << "end TSubLattice<T>::zeroForces() \n";
1718 }
1719 
1726 template <class T>
1728 {
1729  console.XDebug() << "TSubLattice<T>::calcForces() \n";
1730 
1731  // the walls
1732  for(typename map<string,AWallInteractionGroup<T>*>::iterator it=m_WIG.begin();it!=m_WIG.end();it++)
1733  {
1734  (it->second)->calcForces();
1735  }
1736  // the sphere bodies
1737  for(typename map<string,ASphereBodyInteractionGroup<T>*>::iterator it=m_SIG.begin();it!=m_SIG.end();it++)
1738  {
1739  (it->second)->calcForces();
1740  }
1741  // single particle IGs
1742  for(
1743  typename NameIGroupMap::iterator siter=this->m_singleParticleInteractions.begin();
1744  siter != m_singleParticleInteractions.end();
1745  siter++
1746  )
1747  {
1748  (siter->second)->calcForces();
1749  }
1750  // dynamically created IGs
1751  for(typename map<string,AParallelInteractionStorage*>::iterator iter=m_dpis.begin();iter!=m_dpis.end();iter++)
1752  {
1753  (iter->second)->calcForces();
1754  }
1755  // bonded IGs
1756  for(typename map<string,AParallelInteractionStorage*>::iterator iter=m_bpis.begin();iter!=m_bpis.end();iter++)
1757  {
1758  (iter->second)->calcForces();
1759  }
1760  // last, but not least - damping
1761  for(typename map<string,AParallelInteractionStorage*>::iterator iter=m_damping.begin();iter!=m_damping.end();iter++)
1762  {
1763  (iter->second)->calcForces();
1764  }
1765 
1766  console.XDebug() << "end TSubLattice<T>::calcForces() \n";
1767 }
1768 
1775 template <class T>
1777 {
1778  m_dt = dt;
1779  console.XDebug() << "TSubLattice<T>::setTimeStepSize() \n";
1780 
1781  // the walls
1782  for(typename map<string,AWallInteractionGroup<T>*>::iterator it=m_WIG.begin();it!=m_WIG.end();it++)
1783  {
1784  (it->second)->setTimeStepSize(dt);
1785  }
1786  // the sphere bodies
1787  for(typename map<string,ASphereBodyInteractionGroup<T>*>::iterator it=m_SIG.begin();it!=m_SIG.end();it++)
1788  {
1789  (it->second)->setTimeStepSize(dt);
1790  }
1791  // single particle IGs
1792  for(
1793  typename NameIGroupMap::iterator siter=this->m_singleParticleInteractions.begin();
1794  siter != m_singleParticleInteractions.end();
1795  siter++
1796  )
1797  {
1798  (siter->second)->setTimeStepSize(dt);
1799  }
1800  // dynamically created IGs
1801  for(typename map<string,AParallelInteractionStorage*>::iterator iter=m_dpis.begin();iter!=m_dpis.end();iter++)
1802  {
1803  (iter->second)->setTimeStepSize(dt);
1804  }
1805  // bonded IGs
1806  for(typename map<string,AParallelInteractionStorage*>::iterator iter=m_bpis.begin();iter!=m_bpis.end();iter++)
1807  {
1808  (iter->second)->setTimeStepSize(dt);
1809  }
1810  // last, but not least - damping
1811  for(typename map<string,AParallelInteractionStorage*>::iterator iter=m_damping.begin();iter!=m_damping.end();iter++)
1812  {
1813  (iter->second)->setTimeStepSize(dt);
1814  }
1815 
1816  console.XDebug() << "end TSubLattice<T>::setTimeStepSize() \n";
1817 }
1818 
1824 template <class T>
1826 {
1827  console.XDebug() << "TSubLattice<T>::integrate \n";
1828  m_ppa->forAllParticles(&T::integrate,dt);
1829  m_ppa->forAllParticles(&T::rescale) ;
1830  console.XDebug() << "end TSubLattice<T>::integrate \n";
1831 }
1832 
1836 template <class T>
1838 {
1839  zeroForces();
1840  calcForces();
1841  integrate(m_dt);
1842 
1843  if (this->getParticleType() == "RotTherm")
1844  {
1845  this->oneStepTherm();
1846  }
1847 }
1848 
1852 template <class T>
1854 {
1855  zeroHeat(); // ???? combine?
1856  calcHeatFrict();
1857  calcHeatTrans();
1858  integrateTherm(m_dt);
1859  thermExpansion() ;
1860 }
1861 
1867 template <class T>
1869 {
1870  console.XDebug() << "TSubLattice<T>::integrateTherm \n";
1871  m_ppa->forAllParticles(&T::integrateTherm,dt);
1872 // m_ppa->forAllParticles(&T::rescale) ;
1873  console.XDebug() << "end TSubLattice<T>::integrateTherm \n";
1874 }
1875 
1876 template <class T>
1878 {
1879  console.XDebug() << "TSubLattice<T>::thermExpansion() \n";
1880  m_ppa->forAllParticles(&T::thermExpansion);
1881 // m_ppa->forAllParticles(&T::rescale) ;
1882  console.XDebug() << "end TSubLattice<T>::thermExpansion() \n";
1883 }
1884 
1888 template <class T>
1890 {
1891  console.XDebug() << "TSubLattice<T>::zeroHeat()\n";
1892 
1893  // particles
1894  m_ppa->forAllParticles(&T::zeroHeat);
1895 
1896 /*
1897 // walls
1898  for(typename vector<AWallInteractionGroup<T>*>::iterator iter=m_WIG.begin();iter!=m_WIG.end();iter++)
1899  {
1900  (*iter)->zeroForce();
1901  }
1902 */
1903  console.XDebug() << "end TSubLattice<T>::zeroHeat() \n";
1904 }
1905 
1912 template <class T>
1914 {
1915  console.XDebug() << "TSubLattice<T>::calcHeatFrict() \n";
1916 
1917  // dynamically created IGs
1918  for(
1919  typename map<string,AParallelInteractionStorage*>::iterator iter=m_dpis.begin();
1920  iter!=m_dpis.end();
1921  iter++
1922  )
1923  {
1924  (iter->second)->calcHeatFrict();
1925  }
1926 
1927  console.XDebug() << "end TSubLattice<T>::calcHeatFrict() \n";
1928 }
1929 
1930 template <class T>
1932 {
1933  console.XDebug() << "TSubLattice<T>::calcHeatTrans() \n";
1934 
1935 
1936  // dynamically created IGs
1937  for(
1938  typename map<string,AParallelInteractionStorage*>::iterator iter=m_dpis.begin();
1939  iter!=m_dpis.end();
1940  iter++
1941  )
1942  {
1943  (iter->second)->calcHeatTrans();
1944  }
1945  // bonded IGs
1946  for(
1947  typename map<string,AParallelInteractionStorage*>::iterator iter=m_bpis.begin();
1948  iter!=m_bpis.end();
1949  iter++
1950  )
1951  {
1952  (iter->second)->calcHeatTrans();
1953  }
1954 
1955  console.XDebug() << "end TSubLattice<T>::calcHeatTrans() \n";
1956 }
1957 
1961 template <class T>
1963 {
1964  m_ppa->rebuild();
1965 }
1966 
1970 template <class T>
1972 {
1973  CMPIBarrier barrier(m_worker_comm);
1974  m_pTimers->start("RebuildInteractions");
1975  m_pTimers->resume("NeighbourSearch");
1976  for(typename map<string,AParallelInteractionStorage*>::iterator iter=m_bpis.begin();
1977  iter!=m_bpis.end();
1978  iter++)
1979  {
1980  console.Debug() << "exchg & rebuild BPIS " << iter->first << " at node " << m_rank << "\n";
1981  (iter->second)->exchange();
1982  (iter->second)->rebuild();
1983  }
1984 
1985  for(typename map<string,AParallelInteractionStorage*>::iterator iter=m_dpis.begin();
1986  iter!=m_dpis.end();
1987  iter++)
1988  {
1989  console.Debug() << "exchg & rebuild DPIS " << iter->first << " at node " << m_rank << "\n";
1990  (iter->second)->exchange();
1991  m_pTimers->pause("RebuildInteractions");
1992  m_pTimers->pause("NeighbourSearch");
1993  barrier.wait("dpis::exchange");
1994  m_pTimers->resume("RebuildInteractions");
1995  m_pTimers->resume("NeighbourSearch");
1996  (iter->second)->rebuild();
1997  }
1998  resetDisplacements();
1999  m_pTimers->stop("RebuildInteractions");
2000 }
2001 
2005 template <class T>
2007 {
2008  console.Debug() << "CSubLattice<T>::searchNeighbors()\n";
2009  CMPIBarrier barrier(getWorkerComm());
2010  m_pTimers->start("NeighbourSearch");
2011  m_pTimers->start("RebuildParticleArray");
2012  rebuildParticleArray();
2013  m_pTimers->stop("RebuildParticleArray");
2014  m_pTimers->pause("NeighbourSearch");
2015  barrier.wait("PPA rebuild");
2016  rebuildInteractions();
2017  m_pTimers->stop("NeighbourSearch");
2018  console.Debug() << "end CSubLattice<T>::searchNeighbors()\n";
2019 }
2020 
2026 template <class T>
2028 {
2029  console.Debug() << "updateInteractions() \n";
2030  console.Debug() << "m_ppa->getTimeStamp() " << m_ppa->getTimeStamp() << " m_last_ns " << m_last_ns << "\n";
2031  bool need_update=false;
2032 
2033  m_pTimers->start("UpdateBondedInteractions");
2034  for(typename map<string,AParallelInteractionStorage*>::iterator iter=m_bpis.begin();
2035  iter!=m_bpis.end();
2036  iter++)
2037  {
2038  bool n=(iter->second)->update();
2039  need_update=need_update || n;
2040  }
2041  m_pTimers->stop("UpdateBondedInteractions");
2042  if((m_ppa->getTimeStamp() > m_last_ns) || need_update)
2043  {
2044  m_pTimers->start("UpdateDynamicInteractions");
2045  for(typename map<string,AParallelInteractionStorage*>::iterator iter=m_dpis.begin();
2046  iter!=m_dpis.end();
2047  iter++)
2048  {
2049  bool n=(iter->second)->update();
2050  need_update=need_update || n;
2051  }
2052  m_pTimers->stop("UpdateDynamicInteractions");
2053  for(typename map<string,AWallInteractionGroup<T>*>::iterator it=m_WIG.begin();
2054  it!=m_WIG.end();
2055  it++)
2056  {
2057  (it->second)->Update(m_ppa);
2058  }
2059  for(typename map<string,ASphereBodyInteractionGroup<T>*>::iterator it=m_SIG.begin();
2060  it!=m_SIG.end();
2061  it++)
2062  {
2063  (it->second)->Update(m_ppa);
2064  }
2065  for(typename map<string,AParallelInteractionStorage*>::iterator iter=m_damping.begin();
2066  iter!=m_damping.end();
2067  iter++){
2068  (iter->second)->update();
2069  }
2070  m_last_ns=m_ppa->getTimeStamp();
2071  }
2072 
2073  console.Debug() << "end TSubLattice<T>::updateInteractions()\n";
2074 }
2075 
2080 template <class T>
2082 {
2083  console.Debug() << "TSubLattice<T>::checkNeighbors()\n";
2084  CMPISGBufferLeaf buffer(m_comm,0,8);
2085  double mdsqr=0; // squared max. displacement
2086  double alpha=0.5*m_alpha;
2087  double srsqr=alpha*alpha; // squared search range
2088  vector<Vec3> displ; // displacements
2089  int res; // result 0/1
2090 
2091  // --- particles ---
2092  // get displacement data
2093  m_ppa->forAllParticlesGet(displ,&T::getDisplacement);
2094 
2095  // find maximum particle displacement
2096  vector<Vec3>::iterator it=displ.begin();
2097  while((it!=displ.end())&&(mdsqr<srsqr))
2098  {
2099  double sqdisp=(*it)*(*it);
2100  mdsqr = ((mdsqr < sqdisp) ? sqdisp : mdsqr);
2101  it++;
2102  //console.XDebug() << "sq. disp: " << sqdisp << "\n";
2103  }
2104  console.XDebug() << "max squared displacement " << mdsqr << "alpha^2 = " << srsqr << "\n";
2105  if (mdsqr>srsqr){
2106  res=1;
2107  } else {
2108  res=0;
2109  }
2110 
2111  // --- mesh ---
2112  // only needed if res==0
2113  if(res==0){
2114  for(map<string,TriMesh*>::iterator iter=m_mesh.begin();
2115  iter!=m_mesh.end();
2116  iter++){
2117  //std::cerr << "check mesh " << iter->first << std::endl;
2118  if(iter->second->hasMovedBy(alpha)){
2119  res=1;
2120  }
2121  }
2122  }
2123  buffer.append(res);
2124  buffer.send();
2125  console.Debug() << "end TSubLattice<T>::checkNeighbors()\n";
2126 }
2127 
2128 
2132 template <class T>
2134 {
2135  console.Debug() << "slave " << m_rank << " resetDisplacements()\n";
2136  m_ppa->forAllParticles(&T::resetDisplacement);
2137  for(map<string,TriMesh*>::iterator iter=m_mesh.begin();
2138  iter!=m_mesh.end();
2139  iter++){
2140  iter->second->resetCurrentDisplacement();
2141  }
2142  console.Debug() << "slave " << m_rank << " end resetDisplacements()\n";
2143 }
2144 
2149 template <class T>
2151 {
2152  console.Debug() << "TSubLattice<T>::moveParticleTo()\n";
2153  CVarMPIBuffer buffer(m_comm);
2154 
2155  buffer.receiveBroadcast(0); // get data from master
2156  int tag=buffer.pop_int();
2157  Vec3 mv=buffer.pop_vector();
2158  m_ppa->forParticleTag(tag,(void (T::*)(Vec3))(&T::moveToRel),mv);
2159  console.Debug() << "end TSubLattice<T>::moveParticleTo()\n";
2160 }
2161 
2166 template <class T>
2168 {
2169  console.Debug() << "TSubLattice<T>::moveTaggedParticlesBy()\n";
2170  CVarMPIBuffer buffer(m_comm);
2171 
2172  buffer.receiveBroadcast(0); // get data from master
2173  const int tag = buffer.pop_int();
2174  const Vec3 dx = buffer.pop_vector();
2175  m_ppa->forParticleTag(tag, (void (T::*)(Vec3))(&T::moveBy),dx);
2176  console.Debug() << "end TSubLattice<T>::moveTaggedParticlesBy()\n";
2177 }
2178 
2179 
2180 template <class T>
2181 void TSubLattice<T>::moveSingleParticleTo(int particleId, const Vec3 &posn)
2182 {
2183  m_ppa->forParticle(particleId, (void (T::*)(Vec3))(&T::moveTo), posn);
2184 }
2185 
2190 template <class T>
2192 {
2193  console.Debug() << "TSubLattice<T>::moveSingleNode()\n";
2194  CVarMPIBuffer buffer(m_comm);
2195 
2196  buffer.receiveBroadcast(0); // get data from master
2197  string name=string(buffer.pop_string());
2198  int id=buffer.pop_int();
2199  Vec3 disp=buffer.pop_vector();
2200 
2201  console.XDebug() << "name :" << name << " id : " << id << " disp " << disp << "\n";
2202 
2203  map<string,TriMesh*>::iterator tm=m_mesh.find(name);
2204  if (tm!=m_mesh.end()){
2205  (tm->second)->moveNode(id,disp);
2206  } else {
2207  map<string,Mesh2D*>::iterator m2d=m_mesh2d.find(name);
2208  if(m2d!=m_mesh2d.end()){
2209  (m2d->second)->moveNode(id,disp);
2210  }
2211  }
2212  console.Debug() << "end TSubLattice<T>::moveSingleNode()\n";
2213 }
2214 
2219 template <class T>
2221 {
2222  console.Error() << "TSubLattice<T>::moveTaggedNodes() NOT IMPLEMENTED\n";
2223  throw
2224  std::runtime_error(
2225  "TSubLattice<T>::moveTaggedNodes() NOT IMPLEMENTED\n"
2226  );
2227 #if 0
2228  CVarMPIBuffer buffer(m_comm);
2229 
2230  buffer.receiveBroadcast(0); // get data from master
2231  string name=string(buffer.pop_string());
2232  int tag=buffer.pop_int();
2233  Vec3 disp=buffer.pop_vector();
2234 #endif
2235 }
2236 
2243 template <class T>
2244 void TSubLattice<T>::translateMeshBy(const std::string &meshName, const Vec3 &translation)
2245 {
2246  map<string,TriMesh*>::iterator tm=m_mesh.find(meshName);
2247  if (tm != m_mesh.end()){
2248  (tm->second)->translateBy(translation);
2249  }
2250  map<string,Mesh2D*>::iterator m2d=m_mesh2d.find(meshName);
2251  if(m2d!=m_mesh2d.end()){
2252  (m2d->second)->translateBy(translation);
2253  }
2254 }
2255 
2256 template <class T>
2257 std::pair<double, int> TSubLattice<T>::findParticleNearestTo(const Vec3 &pt)
2258 {
2259  console.Debug() << "TSubLattice<T>::findParticleNearestTo: enter\n";
2260  const T *pClosest = NULL;
2261  double minDistSqrd = std::numeric_limits<double>::max();
2262 
2263  typename ParticleArray::ParticleIterator it =
2264  m_ppa->getInnerParticleIterator();
2265  while (it.hasNext())
2266  {
2267  const T &p = it.next();
2268  const double distSqrd = (pt - p.getPos()).norm2();
2269  if (distSqrd < minDistSqrd)
2270  {
2271  minDistSqrd = distSqrd;
2272  pClosest = &p;
2273  }
2274  }
2275  console.Debug() << "TSubLattice<T>::findParticleNearestTo: exit\n";
2276  return
2277  (
2278  (pClosest != NULL)
2279  ?
2280  std::make_pair(sqrt(minDistSqrd), pClosest->getID())
2281  :
2282  std::make_pair(std::numeric_limits<double>::max(), -1)
2283  );
2284 }
2285 
2289 template <class T>
2290 std::pair<int, Vec3> TSubLattice<T>::getParticlePosn(int particleId)
2291 {
2292  const T *particle = NULL;
2293  typename ParticleArray::ParticleIterator it =
2294  m_ppa->getInnerParticleIterator();
2295  while (it.hasNext())
2296  {
2297  const T &p = it.next();
2298  if (p.getID() == particleId)
2299  {
2300  particle = &p;
2301  }
2302  }
2303  if (particle != NULL)
2304  {
2305  return std::make_pair(particleId, particle->getPos());
2306  }
2307  return std::make_pair(-1,Vec3::ZERO);
2308 }
2309 
2313 template <class T>
2314 void TSubLattice<T>::getParticleData(const IdVector &particleIdVector)
2315 {
2316  console.Debug()
2317  << "TSubLattice<T>::getParticleData: enter\n";
2318  typedef std::set<int> IdSet;
2319  typedef std::vector<T> ParticleVector;
2320 
2321  ParticleVector particleVector;
2322  typename ParticleArray::ParticleIterator it =
2323  m_ppa->getInnerParticleIterator();
2324  if (particleIdVector.size() > 0)
2325  {
2326  IdSet idSet(particleIdVector.begin(), particleIdVector.end());
2327  console.Debug()
2328  << "TSubLattice<T>::getParticleData: iterating over particles\n";
2329  while (it.hasNext())
2330  {
2331  const T &p = it.next();
2332  if (idSet.find(p.getID()) != idSet.end())
2333  {
2334  particleVector.push_back(p);
2335  }
2336  }
2337  }
2338  else
2339  {
2340  m_ppa->getAllInnerParticles(particleVector);
2341  }
2342  console.Debug()
2343  << "TSubLattice<T>::getParticleData:"
2344  << " sending particle data of size " << particleVector.size() << "\n";
2345  m_tml_comm.send_gather_packed(particleVector, 0);
2346  console.Debug()
2347  << "TSubLattice<T>::getParticleData: exit\n";
2348 }
2349 
2353 template <class T>
2355 {
2356  console.Debug() << "TSubLattice<T>::tagParticleNearestTo()\n";
2357  CVarMPIBuffer buffer(m_comm);
2358 
2359  buffer.receiveBroadcast(0); // get data from master
2360  int tag=buffer.pop_int();
2361  int mask=buffer.pop_int();
2362  Vec3 pos=buffer.pop_vector();
2363 
2364  // warning - this is ugly
2365  T* part_ptr=m_ppa->getParticlePtrByPosition(pos);
2366  if(part_ptr!=NULL){
2367  int old_tag=part_ptr->getTag();
2368  int new_tag=(old_tag & (~mask)) | (tag & mask);
2369  part_ptr->setTag(new_tag);
2370 
2371  cout << "pos, realpos: " << pos << " " << part_ptr->getPos() << " old tag, new tag " << old_tag << " " << part_ptr->getTag() << endl;
2372  }
2373  console.Debug() << "end TSubLattice<T>::tagParticleNearestTo()\n";
2374 }
2375 
2380 template <class T>
2382 {
2383  console.Debug() << "TSubLattice<T>::setParticleNonDynamic()\n";
2384  CVarMPIBuffer buffer(m_comm);
2385 
2386  buffer.receiveBroadcast(0); // get data from master
2387  int tag=buffer.pop_int();
2388  m_ppa->forParticleTag(tag,(void (T::*)())(&T::setNonDynamic));
2389  console.Debug() << "end TSubLattice<T>::setParticleNonDynamic()\n";
2390 }
2391 
2396 template <class T>
2398 {
2399  console.Debug() << "TSubLattice<T>::setParticleNonRot()\n";
2400  CVarMPIBuffer buffer(m_comm);
2401 
2402  buffer.receiveBroadcast(0); // get data from master
2403  int tag=buffer.pop_int();
2404  m_ppa->forParticleTag(tag,(void (T::*)())(&T::setNonDynamicRot));
2405  console.Debug() << "end TSubLattice<T>::setParticleNonRot()\n";
2406 }
2407 
2412 template <class T>
2414 {
2415  console.Debug() << "TSubLattice<T>::setParticleNonTrans()\n";
2416  CVarMPIBuffer buffer(m_comm);
2417 
2418  buffer.receiveBroadcast(0); // get data from master
2419  int tag=buffer.pop_int();
2420  m_ppa->forParticleTag(tag,(void (T::*)())(&T::setNonDynamicLinear));
2421  console.Debug() << "end TSubLattice<T>::setParticleNonTrans()\n";
2422 }
2423 
2427 template <class T>
2429 {
2430  console.Debug() << "TSubLattice<T>::setTaggedParticleVel()\n";
2431  CVarMPIBuffer buffer(m_comm);
2432 
2433  buffer.receiveBroadcast(0); // get data from master
2434  int tag=buffer.pop_int();
2435  Vec3 v=buffer.pop_vector();
2436  m_ppa->forParticleTag(tag,(void (T::*)(Vec3))(&T::setVel),v);
2437  console.XDebug() << "end TSubLattice<T>::setTaggedParticleVel()\n";
2438 }
2439 
2443 template <class T>
2445 {
2446  console.XDebug() << "TSubLattice<T>::moveWallBy()\n";
2447  CVarMPIBuffer buffer(m_comm);
2448 
2449  buffer.receiveBroadcast(0); // get data from master
2450  string wname=buffer.pop_string();
2451  Vec3 mv=buffer.pop_vector();
2452  typename map<string,CWall*>::iterator iter=m_walls.find(wname);
2453  if(iter!=m_walls.end())
2454  {
2455  (iter->second)->moveBy(mv);
2456  }
2457 }
2458 
2462 template <class T>
2464 {
2465  console.XDebug() << "TSubLattice<T>::moveSphereBodyBy()\n";
2466  CVarMPIBuffer buffer(m_comm);
2467 
2468  buffer.receiveBroadcast(0); // get data from master
2469  string wname=buffer.pop_string();
2470  Vec3 mv=buffer.pop_vector();
2471  typename map<string,CSphereBody*>::iterator iter=m_spheres.find(wname);
2472  if(iter!=m_spheres.end())
2473  {
2474  (iter->second)->moveBy(mv);
2475  }
2476 }
2477 
2481 template <class T>
2483 {
2484  console.XDebug() << "TSubLattice<T>::setWallNormal()\n";
2485  CVarMPIBuffer buffer(m_comm);
2486 
2487  buffer.receiveBroadcast(0); // get data from master
2488  string wname=buffer.pop_string();
2489  Vec3 wn=buffer.pop_vector();
2490  typename map<string,CWall*>::iterator iter=m_walls.find(wname);
2491  if(iter!=m_walls.end())
2492  {
2493  (iter->second)->setNormal(wn);
2494  }
2495 }
2496 
2500 template <class T>
2502 {
2503  console.XDebug() << "TSubLattice<T>::applyForceToWall()\n";
2504  CVarMPIBuffer buffer(m_comm);
2505 
2506  buffer.receiveBroadcast(0); // get data from master
2507  string wname=buffer.pop_string();
2508  Vec3 f=buffer.pop_vector();
2509  typename map<string,AWallInteractionGroup<T>*>::iterator iter=m_WIG.find(wname);
2510  if(iter!=m_WIG.end())
2511  {
2512  (iter->second)->applyForce(f);
2513  }
2514 }
2515 
2520 template <class T>
2522 {
2523  console.XDebug() << "TSubLattice<T>::setVelocityOfWall()\n";
2524  CVarMPIBuffer buffer(m_comm);
2525 
2526  buffer.receiveBroadcast(0); // get data from master
2527  string wname=buffer.pop_string();
2528  Vec3 v=buffer.pop_vector();
2529  typename map<string,AWallInteractionGroup<T>*>::iterator iter=m_WIG.find(wname);
2530  if(iter!=m_WIG.end())
2531  {
2532  (iter->second)->setVelocity(v);
2533  }
2534 }
2535 
2539 template <class T>
2541 {
2542  console.Debug() << "TSubLattice<T>::setParticleVelocity()\n";
2543  CVarMPIBuffer buffer(m_comm);
2544 
2545  buffer.receiveBroadcast(0); // get data from master
2546  int id=buffer.pop_int();
2547  Vec3 mv=buffer.pop_vector();
2548  m_ppa->forParticle(id,(void (T::*)(Vec3))(&T::setVel),mv);
2549  console.XDebug() << "end TSubLattice<T>::setParticleVelocity()\n";
2550 }
2551 
2555 template <class T>
2557 {
2558  console.Debug() << "TSubLattice<T>::setParticleDensity()\n";
2559  CVarMPIBuffer buffer(m_comm);
2560 
2561  buffer.receiveBroadcast(0); // get data from master
2562  int tag=buffer.pop_int();
2563  int mask=buffer.pop_int();
2564  double rho=buffer.pop_double();
2565  m_ppa->forParticleTagMask(tag,mask,(void (T::*)(double))(&T::setDensity),rho);
2566  console.XDebug() << "end TSubLattice<T>::setParticleVelocity()\n";
2567 }
2568 
2569 
2573 template <class T>
2575 {
2576  console.Debug() << "TSubLattice<T>::sendDataToMaster()\n";
2577  vector<Vec3> positions;
2578  vector<double> radii;
2579  vector<int> ids;
2580 
2581  m_ppa->forAllParticlesGet(positions,(Vec3 (T::*)() const)(&T::getPos));
2582  m_ppa->forAllParticlesGet(radii,(double (T::*)() const)(&T::getRad));
2583  m_ppa->forAllParticlesGet(ids,(int (T::*)() const)(&T::getID));
2584 
2585  m_tml_comm.send_gather(positions,0);
2586  m_tml_comm.send_gather(radii,0);
2587  m_tml_comm.send_gather(ids,0);
2588 
2589  console.Debug() << "end TSubLattice<T>::sendDataToMaster()\n";
2590 }
2591 
2595 template <class T>
2597 {
2598  console.Debug()<<"TSubLattice<T>::countParticles()\n";
2599  CMPIVarSGBufferLeaf buffer(m_comm,0);
2600  //-- pack particles into buffer
2601  buffer.append(m_ppa->size());
2602  // send
2603  buffer.send();
2604 }
2605 
2609 template <class T>
2611 {
2612  cout<< "My Rank : " << m_rank << "\n" ;
2613  if(m_ppa!=NULL)
2614  {
2615  cout << *m_ppa << endl;
2616  }
2617 }
2618 
2619 template <class T>
2621 {
2622  cout << "Data: my rank : " << m_rank << "particles : \n" ;
2623  m_ppa->forAllParticles((void (T::*)())(&T::print));
2624 }
2625 
2626 template <class T>
2628 {
2629  console.Debug() << "time spent calculating force : " << forcetime << " sec\n";
2630  console.Debug() << "time spent communicating : " << commtime << " sec\n";
2631  console.Debug() << "time spent packing : " << packtime << " sec\n";
2632  console.Debug() << "time spent unpacking : " << unpacktime << " sec\n";
2633 }
2634 
2635 //-------------- FIELD FUNCTIONS ----------------
2636 
2637 
2638 
2642 template <class T>
2644 {
2645  // cout << "TSubLattice<T>::addScalarParticleField\n";
2646  string fieldname;
2647  int id,is_tagged;
2648 
2649  m_tml_comm.recv_broadcast_cont(fieldname,0);
2650  //cout << "recvd. fieldname: " << fieldname << "\n";
2651  m_tml_comm.recv_broadcast(id,0);
2652  //cout << "recvd. id: " << id << "\n";
2653  m_tml_comm.recv_broadcast(is_tagged,0);
2654  //cout << "recvd. is_tagged: " << is_tagged << "\n";
2655 
2656  typename T::ScalarFieldFunction rdf=T::getScalarFieldFunction(fieldname);
2657  ScalarParticleFieldSlave<T> *new_spfs;
2658  if(is_tagged==0)
2659  {
2660  new_spfs=new ScalarParticleFieldSlave<T>(&m_tml_comm,m_ppa,rdf);
2661  }
2662  else
2663  {
2664  int tag,mask;
2665  m_tml_comm.recv_broadcast(tag,0);
2666  console.XDebug() << "recvd. tag: " << tag << "\n";
2667  m_tml_comm.recv_broadcast(mask,0);
2668  console.XDebug() << "recvd. mask: " << mask << "\n";
2669  new_spfs=new ScalarParticleFieldSlaveTagged<T>(&m_tml_comm,m_ppa,rdf,tag,mask);
2670  }
2671  m_field_slaves.insert(make_pair(id,new_spfs));
2672 }
2673 
2677 template <class T>
2679 {
2680  console.XDebug() << "TSubLattice<T>::addVectorParticleField\n";
2681  string fieldname;
2682  int id,is_tagged;
2683 
2684  m_tml_comm.recv_broadcast_cont(fieldname,0);
2685  console.XDebug() << "recvd. fieldname: " << fieldname << "\n";
2686  m_tml_comm.recv_broadcast(id,0);
2687  console.XDebug() << "recvd. id: " << id << "\n";
2688  m_tml_comm.recv_broadcast(is_tagged,0);
2689  console.XDebug() << "recvd. is_tagged: " << is_tagged << "\n";
2690 
2691  typename T::VectorFieldFunction rdf=T::getVectorFieldFunction(fieldname);
2692  VectorParticleFieldSlave<T> *new_vpfs;
2693  if(is_tagged==0)
2694  {
2695  new_vpfs=new VectorParticleFieldSlave<T>(&m_tml_comm,m_ppa,rdf);
2696  }
2697  else
2698  {
2699  int tag,mask;
2700  m_tml_comm.recv_broadcast(tag,0);
2701  console.XDebug() << "recvd. tag: " << tag << "\n";
2702  m_tml_comm.recv_broadcast(mask,0);
2703  console.XDebug() << "recvd. mask: " << mask << "\n";
2704  new_vpfs=new VectorParticleFieldSlaveTagged<T>(&m_tml_comm,m_ppa,rdf,tag,mask);
2705  }
2706  m_field_slaves.insert(make_pair(id,new_vpfs));
2707 
2708  console.Debug() << "end TSubLattice<T>::addVectorParticleField\n";
2709 }
2710 
2711 
2715 template <class T>
2717 {
2718  console.XDebug() << "TSubLattice<T>::addScalarInteractionField\n";
2719  string fieldname;
2720  string igname;
2721  string igtype;
2722  int id,is_tagged,tag,mask,is_checked;
2723 
2724  m_tml_comm.recv_broadcast_cont(fieldname,0);
2725  console.XDebug() << "recvd. fieldname: " << fieldname << "\n";
2726  m_tml_comm.recv_broadcast(id,0);
2727  console.XDebug() << "recvd. id: " << id << "\n";
2728  m_tml_comm.recv_broadcast_cont(igname,0);
2729  console.XDebug() << "recvd. interaction group name: " << igname << "\n";
2730  m_tml_comm.recv_broadcast_cont(igtype,0);
2731  console.XDebug() << "recvd. interaction group name: " << igtype << "\n";
2732  m_tml_comm.recv_broadcast(is_tagged,0);
2733  console.XDebug() << "recvd. is_tagged: " << is_tagged << "\n";
2734 
2735  // get interaction group
2736  map<string,AParallelInteractionStorage*>::iterator it=m_dpis.find(igname);
2737  if(is_tagged==1)
2738  {
2739  m_tml_comm.recv_broadcast(tag,0);
2740  m_tml_comm.recv_broadcast(mask,0);
2741  }
2742  m_tml_comm.recv_broadcast(is_checked,0);
2743  console.XDebug() << "recvd. is_checked: " << is_checked << "\n";
2744 
2745  if(it!=m_dpis.end())
2746  {
2747  console.XDebug() << "found interaction group in dynamic\n";
2748  AFieldSlave* new_sifs;
2749  new_sifs=(it->second)->generateNewScalarFieldSlave(&m_tml_comm,fieldname,is_checked,is_tagged,tag,mask);
2750  m_field_slaves.insert(make_pair(id,new_sifs));
2751  }
2752  else
2753  {
2754  it=m_bpis.find(igname);
2755  if(it!=m_bpis.end()){
2756  console.XDebug() << "found interaction group in bonded\n";
2757  AFieldSlave* new_sifs;
2758  new_sifs=(it->second)->generateNewScalarFieldSlave(&m_tml_comm,fieldname,is_checked,is_tagged,tag,mask);
2759  m_field_slaves.insert(make_pair(id,new_sifs));
2760  }
2761  else // not in dynamic or bonded -> try damping
2762  {
2763  //typename map<string,CDampingGroup<T>*>::iterator it2=m_damping.find(igname);
2764  it=m_damping.find(igname);
2765  if(it!=m_damping.end()) // found it in damping
2766  {
2767  AFieldSlave* new_sifs;
2768  new_sifs=(it->second)->generateNewScalarFieldSlave(&m_tml_comm,fieldname,is_checked,is_tagged,tag,mask);
2769  m_field_slaves.insert(make_pair(id,new_sifs));
2770  }
2771  else // still not found -> unknown name -> error
2772  {
2773  cerr << "ERROR : unknown interaction group name in addScalarInteractionField " << endl;
2774  }
2775  }
2776  }
2777 
2778  console.XDebug() << "end TSubLattice<T>::addScalarInteractionField\n";
2779 }
2780 
2784 template <class T>
2786 {
2787  console.Debug() << "TSubLattice<T>::addVectorInteractionField\n";
2788  string fieldname;
2789  string igname;
2790  string igtype;
2791  int id,is_tagged,tag,mask,is_checked;
2792 
2793  m_tml_comm.recv_broadcast_cont(fieldname,0);
2794  console.XDebug() << "recvd. fieldname: " << fieldname << "\n";
2795  m_tml_comm.recv_broadcast(id,0);
2796  console.XDebug() << "recvd. id: " << id << "\n";
2797  m_tml_comm.recv_broadcast_cont(igname,0);
2798  console.XDebug() << "recvd. interaction group name: " << igname << "\n";
2799  m_tml_comm.recv_broadcast_cont(igtype,0);
2800  console.XDebug() << "recvd. interaction group type: " << igtype << "\n";
2801  m_tml_comm.recv_broadcast(is_tagged,0);
2802  console.XDebug() << "recvd. is_tagged: " << is_tagged << "\n";
2803 
2804  // get interaction group
2805  map<string,AParallelInteractionStorage*>::iterator it=m_dpis.find(igname);
2806  if(is_tagged==1)
2807  {
2808  m_tml_comm.recv_broadcast(tag,0);
2809  m_tml_comm.recv_broadcast(mask,0);
2810  }
2811  m_tml_comm.recv_broadcast(is_checked,0);
2812  console.XDebug() << "recvd. is_checked: " << is_checked << "\n";
2813 
2814  if(it!=m_dpis.end())
2815  {
2816  console.XDebug() << "found interaction group in dynamic\n";
2817  AFieldSlave* new_sifs;
2818  new_sifs=(it->second)->generateNewVectorFieldSlave(&m_tml_comm,fieldname,is_checked,is_tagged,tag,mask);
2819  if(new_sifs!=NULL){
2820  m_field_slaves.insert(make_pair(id,new_sifs));
2821  } else {
2822  console.Error()<<"ERROR: could not generate Field Slave for field " << fieldname << "\n";
2823  }
2824  }
2825  else
2826  {
2827  it=m_bpis.find(igname);
2828  if(it!=m_bpis.end()){
2829  console.XDebug() << "found interaction group in bonded\n";
2830  AFieldSlave* new_sifs;
2831  new_sifs=(it->second)->generateNewVectorFieldSlave(&m_tml_comm,fieldname,is_checked,is_tagged,tag,mask);
2832  m_field_slaves.insert(make_pair(id,new_sifs));
2833  }
2834  else // not in dynamic or bonded -> try damping
2835  {
2836  //typename map<string,CDampingGroup<T>*>::iterator it2=m_damping.find(igname);
2837  it=m_damping.find(igname);
2838  if(it!=m_damping.end()) // found it in damping
2839  {
2840  AFieldSlave* new_sifs;
2841  new_sifs=(it->second)->generateNewVectorFieldSlave(&m_tml_comm,fieldname,is_checked,is_tagged,tag,mask);
2842  m_field_slaves.insert(make_pair(id,new_sifs));
2843  }
2844  else // still not found -> unknown name -> error
2845  {
2846  cerr << "ERROR : unknown interaction group name in addScalarInteractionField " << endl;
2847  }
2848  }
2849  }
2850 
2851  console.Debug() << "end TSubLattice<T>::addVectorInteractionField\n";
2852 }
2853 
2857 template <class T>
2859 {
2860  console.XDebug() << "TSubLattice<T>::addScalarHistoryInteractionField\n";
2861  string fieldname;
2862  string igname;
2863  string igtype;
2864  int id,is_tagged,tag,mask,is_checked;
2865 
2866  m_tml_comm.recv_broadcast_cont(fieldname,0);
2867  console.XDebug() << "recvd. fieldname: " << fieldname << "\n";
2868  m_tml_comm.recv_broadcast(id,0);
2869  console.XDebug() << "recvd. id: " << id << "\n";
2870  m_tml_comm.recv_broadcast_cont(igname,0);
2871  console.XDebug() << "recvd. interaction group name: " << igname << "\n";
2872  m_tml_comm.recv_broadcast_cont(igtype,0);
2873  console.XDebug() << "recvd. interaction group name: " << igtype << "\n";
2874  m_tml_comm.recv_broadcast(is_tagged,0);
2875  console.XDebug() << "recvd. is_tagged: " << is_tagged << "\n";
2876 
2877  if(is_tagged==1)
2878  {
2879  m_tml_comm.recv_broadcast(tag,0);
2880  m_tml_comm.recv_broadcast(mask,0);
2881  }
2882  m_tml_comm.recv_broadcast(is_checked,0);
2883  console.XDebug() << "recvd. is_checked: " << is_checked << "\n";
2884 
2885  // get interaction group
2886  map<string,AParallelInteractionStorage*>::iterator it=m_bpis.find(igname);
2887  if(it!=m_bpis.end()){
2888  console.XDebug() << "found interaction group in bonded\n";
2889  AFieldSlave* new_sifs;
2890  new_sifs=(it->second)->generateNewScalarHistoryFieldSlave(&m_tml_comm,fieldname,is_tagged,tag,mask);
2891  if(new_sifs!=NULL){
2892  m_field_slaves.insert(make_pair(id,new_sifs));
2893  }
2894  } else { // not in dynamic or bonded -> throw error
2895  cerr << "ERROR : unknown interaction group name in addScalarHistoryInteractionField " << endl;
2896  }
2897 
2898  console.XDebug() << "end TSubLattice<T>::addScalarHistoryInteractionField\n";
2899 }
2900 
2901 
2906 template <class T>
2908 {
2909  console.Debug() << "TSubLattice<T>::addVectorTriangleField()\n";
2910  string fieldname;
2911  string meshname;
2912  int id;
2913 
2914  // receive params
2915  m_tml_comm.recv_broadcast_cont(fieldname,0);
2916  console.XDebug() << "recvd. fieldname: " << fieldname << "\n";
2917  m_tml_comm.recv_broadcast_cont(meshname,0);
2918  console.XDebug() << "recvd. meshname: " << meshname << "\n";
2919  m_tml_comm.recv_broadcast(id,0);
2920  console.XDebug() << "recvd. id: " << id << "\n";
2921 
2922  map<string,TriMesh*>::iterator tm=m_mesh.find(meshname);
2923  // if meshname is in trimesh map
2924  if (tm!=m_mesh.end()){
2925  // get reader function
2927  // check it
2928  if(rdf==NULL){
2929  console.Critical() << "NULL rdf !!!\n";
2930  }
2931  VectorTriangleFieldSlave* new_vfs=new VectorTriangleFieldSlave(&m_tml_comm,tm->second,rdf);
2932  m_field_slaves.insert(make_pair(id,new_vfs));
2933  } else {
2934  map<string,Mesh2D*>::iterator m2d=m_mesh2d.find(meshname);
2935  if(m2d!=m_mesh2d.end()){
2937  // check it
2938  if(rdf==NULL){
2939  console.Critical() << "NULL rdf !!!\n";
2940  }
2941  VectorEdge2DFieldSlave* new_efs= new VectorEdge2DFieldSlave(&m_tml_comm,m2d->second,rdf);
2942  m_field_slaves.insert(make_pair(id,new_efs));
2943  }
2944  }
2945  console.Debug() << "end TSubLattice<T>::addVectorTriangleField()\n";
2946 }
2947 
2951 template <class T>
2953 {
2954  console.Debug() << "TSubLattice<T>::addScalarTriangleField()\n";
2955  string fieldname;
2956  string meshname;
2957  int id;
2958 
2959  // receive params
2960  m_tml_comm.recv_broadcast_cont(fieldname,0);
2961  console.XDebug() << "recvd. fieldname: " << fieldname << "\n";
2962  m_tml_comm.recv_broadcast_cont(meshname,0);
2963  console.XDebug() << "recvd. meshname: " << meshname << "\n";
2964  m_tml_comm.recv_broadcast(id,0);
2965  console.XDebug() << "recvd. id: " << id << "\n";
2966 
2967  // get reader function
2969  // check it
2970  if(rdf==NULL){
2971  console.Critical() << "NULL rdf !!!\n";
2972  }
2973  ScalarTriangleFieldSlave* new_vtfs=new ScalarTriangleFieldSlave(&m_tml_comm,m_mesh[meshname],rdf);
2974  m_field_slaves.insert(make_pair(id,new_vtfs));
2975  console.Debug() << "end TSubLattice<T>::addScalarTriangleField()\n";
2976 }
2977 
2981 template <class T>
2983 {
2984  console.XDebug() << "begin TSubLattice<T>::addVectorWallField()\n";
2985  string fieldname;
2986  string tmp_wallname;
2987  vector<string> wallnames;
2988  int nwall;
2989  int id;
2990 
2991  // receive params
2992  m_tml_comm.recv_broadcast_cont(fieldname,0);
2993  console.XDebug() << "recvd. fieldname: " << fieldname << "\n";
2994  m_tml_comm.recv_broadcast(nwall,0);
2995  console.XDebug() << "recvd. nwall: " << nwall << "\n";
2996  for(int i=0;i<nwall;i++){
2997  m_tml_comm.recv_broadcast_cont(tmp_wallname,0);
2998  wallnames.push_back(tmp_wallname);
2999  console.XDebug() << "recvd. wallname: " << tmp_wallname << "\n";
3000  tmp_wallname.clear();
3001  }
3002  m_tml_comm.recv_broadcast(id,0);
3003  console.XDebug() << "recvd. id: " << id << "\n";
3004 
3005  // check validity of 1st wall name
3006  map<string,CWall*>::iterator cwalliter=m_walls.find(*(wallnames.begin()));
3007  if(cwalliter==m_walls.end()){ // 1st wall name invalid -> exit
3008  std::stringstream msg;
3009  msg
3010  << "ERROR in addVectorWallField: wallname '"
3011  << *(wallnames.begin()) << " 'invalid. Valid wall names: ";
3012  for (map<string,CWall*>::const_iterator it = m_walls.begin(); it != m_walls.end(); it++)
3013  {
3014  msg << "'" << it->first << "' ";
3015  }
3016  console.Error() << msg.str() << "\n";
3017  throw std::runtime_error(msg.str());
3018  } else { // first wall valid -> try to get slave
3019  // get summation flag from wall
3020  int sumflag=(cwalliter->second)->getFieldSummationFlag(fieldname);
3021  // if process 1, send summation flag back to master
3022  if(m_tml_comm.rank()==1){
3023  m_tml_comm.send(sumflag,0);
3024  }
3025  m_tml_comm.barrier();
3026 
3027  //field slave
3028  AWallFieldSlave* new_fs=(cwalliter->second)->generateVectorFieldSlave(&m_tml_comm,fieldname);
3029 
3030  // try to insert other walls
3031  vector<string>::iterator niter=wallnames.begin();
3032  if(niter!=wallnames.end()) niter++ ; // jump past 1st wall - already got it
3033  while(niter!=wallnames.end()){
3034  string wname=*niter;
3035  map<string,CWall*>::iterator iter=m_walls.find(wname);
3036  if(iter==m_walls.end()){ // wall name invalid -> exit
3037  std::stringstream msg;
3038  msg
3039  << "ERROR in addVectorWallField: wallname '"
3040  << wname << " 'invalid";
3041  for (map<string,CWall*>::const_iterator it = m_walls.begin(); it != m_walls.end(); it++)
3042  {
3043  msg << "'" << it->first << "' ";
3044  }
3045 
3046  console.Error() << msg.str() << "\n";
3047  throw std::runtime_error(msg.str());
3048  } else {
3049  new_fs->addWall(iter->second);
3050  }
3051  niter++;
3052  }
3053  if(new_fs!=NULL){
3054  m_field_slaves.insert(make_pair(id,new_fs));
3055  } else {
3056  console.Error() << "ERROR in addVectorWallField: got NULL Slave\n";
3057  }
3058  }
3059 
3060  console.XDebug() << "end TSubLattice<T>::addVectorWallField()\n";
3061 }
3062 
3066 template <class T>
3068 {
3069  console.Debug() << "TSubLattice<T>::sendFieldData()\n";
3070  // receive id's of field to send
3071  int id;
3072  m_tml_comm.recv_broadcast(id,0);
3073  console.Debug() << "received field id " << id << " for data collection\n" ;
3074  if(m_field_slaves[id] != NULL)
3075  {
3076  m_field_slaves[id]->sendData();
3077  }
3078  else
3079  { // can not happen
3080  cerr << "NULL pointer in m_field_slaves!" << endl;
3081  }
3082  // call the sending function of the field
3083  console.Debug() << "end TSubLattice<T>::sendFieldData()\n";
3084 }
3085 
3086 
3087 // ---- Checkpointing ----------
3091 template <class T>
3092 void TSubLattice<T>::saveSnapShotData(std::ostream &oStream)
3093 {
3094  // get precision of output stream and set it to 9 significant digits
3095  std::streamsize oldprec=oStream.precision(9);
3096 
3097  //
3098  // Save particle check-point data
3099  //
3100  ParticleArray &particleArray = dynamic_cast<ParticleArray &>(*m_ppa);
3102  particleIt(particleArray.getInnerParticleIterator());
3103 
3104  const std::string delim = "\n";
3105 
3106  oStream << particleIt.getNumRemaining() << delim;
3107  while (particleIt.hasNext()) {
3108  particleIt.next().saveSnapShotData(oStream);
3109  oStream << delim;
3110  }
3111 
3112  //
3113  // Save Bonded interaction check-point data.
3114  //
3115  typedef std::map<string,AParallelInteractionStorage*> NameBondedInteractionsMap;
3116  typename NameBondedInteractionsMap::iterator it;
3117  oStream << m_bpis.size() << delim;
3118  for (it = m_bpis.begin(); it != m_bpis.end(); it++) {
3119  it->second->saveSnapShotData(oStream);
3120  oStream << delim;
3121  }
3122 
3123  // dump trimeshdata (if exists)
3124  oStream << "TMIG " << m_mesh.size() << delim;
3125  for(typename map<string,TriMesh*>::iterator tm_iter=m_mesh.begin();
3126  tm_iter!=m_mesh.end();
3127  tm_iter++){
3128  oStream << tm_iter->first << delim;
3129  tm_iter->second->writeCheckPoint(oStream,delim);
3130  }
3131 
3132  // restore output stream to old precision
3133  oStream.precision(oldprec);
3134 }
3135 
3139 template <class T>
3140 void TSubLattice<T>::saveCheckPointData(std::ostream &oStream)
3141 {
3142  const std::string delim = "\n";
3143  //
3144  // Save particle check-point data
3145  //
3146  m_ppa->saveCheckPointData(oStream);
3147 
3148  //
3149  // Save Bonded interaction check-point data.
3150  //
3151  typedef std::map<string,AParallelInteractionStorage*> NameBondedInteractionsMap;
3152  typename NameBondedInteractionsMap::iterator it;
3153  oStream << m_bpis.size() << delim;
3154  for (it = m_bpis.begin(); it != m_bpis.end(); it++) {
3155  it->second->saveCheckPointData(oStream);
3156  oStream << delim;
3157  }
3158 
3159  //
3160  // Save Non-bonded interaction check-point data
3161  //
3162  int count_save=0;
3163  for(std::map<string,AParallelInteractionStorage*>::iterator iter=m_dpis.begin();
3164  iter!=m_dpis.end();
3165  iter++){
3166  if(iter->second->willSave()) count_save++;
3167  }
3168  oStream << count_save << delim;
3169  for(std::map<string,AParallelInteractionStorage*>::iterator iter=m_dpis.begin();
3170  iter!=m_dpis.end();
3171  iter++){
3172  if(iter->second->willSave()) {
3173  iter->second->saveCheckPointData(oStream);
3174  oStream << delim;
3175  }
3176  }
3177 
3178  // Save walls (name, pos, normal)
3179  oStream << "Walls " << m_walls.size() << delim;
3180  for(map<string,CWall*>::iterator w_iter=m_walls.begin();
3181  w_iter!=m_walls.end();
3182  w_iter++){
3183  oStream << w_iter->first << delim;
3184  w_iter->second->writeCheckPoint(oStream,delim);
3185  }
3186 
3187  // Save sphere bodies (name, pos, radius)
3188  oStream << "Spheres " << m_spheres.size() << delim;
3189  for(map<string,CSphereBody*>::iterator w_iter=m_spheres.begin();
3190  w_iter!=m_spheres.end();
3191  w_iter++){
3192  oStream << w_iter->first << delim;
3193  w_iter->second->writeCheckPoint(oStream,delim);
3194  }
3195 
3196  // dump trimeshdata (if exists)
3197  oStream << "TriMesh " << m_mesh.size() << delim;
3198  for(typename map<string,TriMesh*>::iterator tm_iter=m_mesh.begin();
3199  tm_iter!=m_mesh.end();
3200  tm_iter++){
3201  oStream << tm_iter->first << delim;
3202  tm_iter->second->writeCheckPoint(oStream,delim);
3203  }
3204  // dump 2D mesh data (if exists)
3205  oStream << "Mesh2D " << m_mesh2d.size() << delim;
3206  for(typename map<string,Mesh2D*>::iterator tm_iter=m_mesh2d.begin();
3207  tm_iter!=m_mesh2d.end();
3208  tm_iter++){
3209  oStream << tm_iter->first << delim;
3210  tm_iter->second->writeCheckPoint(oStream,delim);
3211  }
3212 }
3213 
3214 template <class T>
3215 void TSubLattice<T>::loadCheckPointData(std::istream &iStream)
3216 {
3217  // get particles
3218  m_ppa->loadCheckPointData(iStream);
3219 
3220  // rebuild neighbor table
3221  CMPIBarrier barrier(getWorkerComm());
3222  m_ppa->rebuild();
3223  barrier.wait("PPA rebuild");
3224 
3225  //-- get bonds --
3226  // get nr. of bonded interaction group in the checkpoint file
3227  unsigned int nr_bonded_ig;
3228  iStream >> nr_bonded_ig;
3229 
3230  // compare with existing bonded particle interaction storage (bpis)
3231  // barf if not equal
3232  if(nr_bonded_ig!=m_bpis.size()){
3233  std::cerr << "number of bonded interaction groups differ between snapshot and script!" << std::endl;
3234  } else { // numbers fit -> read data
3235  for (map<string,AParallelInteractionStorage*>::iterator it = m_bpis.begin();
3236  it != m_bpis.end();
3237  it++) { // for all interaction groups
3238  it->second->loadCheckPointData(iStream);
3239  }
3240  }
3241  //-- get nonbonded interactions --
3242  // get nr. of non-bonded interaction group in the checkpoint file
3243  unsigned int nr_nonbonded_ig;
3244  iStream >> nr_nonbonded_ig;
3245 
3246  // compare with existing non-bonded (dynamic) particle interaction storage (dpis)
3247  // barf if not equal
3248  if(nr_nonbonded_ig!=m_dpis.size()){
3249  std::cerr << "number of dynamic interaction groups differ between snapshot and script!" << std::endl;
3250  } else { // numbers fit -> read data
3251  for (map<string,AParallelInteractionStorage*>::iterator it = m_dpis.begin();
3252  it != m_dpis.end();
3253  it++) { // for all interaction groups
3254  it->second->loadCheckPointData(iStream);
3255  }
3256  }
3257  //--- load walls ---
3258  string token;
3259  iStream >> token;
3260  if(token!="Walls") { // found wrong token -> barf
3261  std::cerr << "expected Walls , got " << token << std::endl;
3262  }
3263  // nr. of walls
3264  int nwalls;
3265  iStream >> nwalls;
3266  // read wall names & data
3267  string wname;
3268  for(int i=0;i<nwalls;i++){
3269  CWall* new_wall = new CWall();
3270  iStream >> wname;
3271  new_wall->loadCheckPoint(iStream);
3272  m_walls[wname]=new_wall;
3273  }
3274 
3275  iStream >> token;
3276  if(token!="Spheres") { // found wrong token -> barf
3277  std::cerr << "expected Spheres , got " << token << std::endl;
3278  }
3279 
3280  // nr. of sphere bodies
3281  int nspheres;
3282  iStream >> nspheres;
3283  // read sphere body names & data
3284  string sname;
3285  for(int i=0;i<nspheres;i++){
3286  CSphereBody* new_sphere = new CSphereBody();
3287  iStream >> sname;
3288  new_sphere->loadCheckPoint(iStream);
3289  m_spheres[sname]=new_sphere;
3290  }
3291  // --- load meshes --
3292  int nmesh;
3293  string mname;
3294  // Trimesh (3D)
3295  iStream >> token;
3296  if(token!="TriMesh") { // found wrong token -> barf
3297  std::cerr << "expected TriMesh , got " << token << std::endl;
3298  }
3299  // nr. of meshes
3300  iStream >> nmesh;
3301  // read wall names & data
3302  for(int i=0;i<nmesh;i++){
3303  TriMesh* new_tm=new TriMesh();
3304  iStream >> mname;
3305  new_tm->loadCheckPoint(iStream);
3306  m_mesh.insert(make_pair(mname,new_tm));
3307  }
3308  // Mesh2D
3309  iStream >> token;
3310  if(token!="Mesh2D") { // found wrong token -> barf
3311  std::cerr << "expected Mesh2D , got " << token << std::endl;
3312  }
3313  // nr. of meshes
3314  iStream >> nmesh;
3315  // read wall names & data
3316  for(int i=0;i<nmesh;i++){
3317  Mesh2D* new_m2d=new Mesh2D();
3318  iStream >> mname;
3319  new_m2d->loadCheckPoint(iStream);
3320  m_mesh2d.insert(make_pair(mname,new_m2d));
3321  }
3322 }
3323 
3324 // -- mesh data exchange functions --
3325 
3329 template <class T>
3331 {
3332  console.XDebug() << "TSubLattice<T>::getMeshNodeRef()\n";
3333  vector<int> ref_vec;
3334 
3335  // MPI buffer
3336  CVarMPIBuffer param_buffer(m_comm);
3337  // receive mesh name
3338  param_buffer.receiveBroadcast(0);
3339  string meshname=param_buffer.pop_string();
3340  console.XDebug() << "Mesh name: " << meshname << "\n";
3341 
3342  // find mesh & collect node ids into array
3343  map<string,TriMesh*>::iterator tm=m_mesh.find(meshname);
3344  if (tm!=m_mesh.end()){
3345  for(TriMesh::corner_iterator iter=(tm->second)->corners_begin();
3346  iter!=(tm->second)->corners_end();
3347  iter++){
3348  ref_vec.push_back(iter->getID());
3349  }
3350  } else {
3351  map<string,Mesh2D*>::iterator m2d=m_mesh2d.find(meshname);
3352  if(m2d!=m_mesh2d.end()){
3353  for(Mesh2D::corner_iterator iter=(m2d->second)->corners_begin();
3354  iter!=(m2d->second)->corners_end();
3355  iter++){
3356  ref_vec.push_back(iter->getID());
3357  }
3358  } else {
3359  console.Critical() << "ERROR - WRONG MESH NAME IN getMeshNodeRef() !! \n";
3360  }
3361  }
3362  // send back to master
3363  m_tml_comm.send_gather(ref_vec,0);
3364 
3365  console.XDebug() << "end TSubLattice<T>::getMeshNodeRef()\n";
3366 }
3367 
3371 template <class T>
3373 {
3374  console.XDebug() << "TSubLattice<T>::getMeshFaceRef()\n";
3375  vector<int> ref_vec;
3376 
3377  // MPI buffer
3378  CVarMPIBuffer param_buffer(m_comm);
3379  // receive mesh name
3380  param_buffer.receiveBroadcast(0);
3381  string meshname=param_buffer.pop_string();
3382  console.XDebug() << "Mesh name: " << meshname << "\n";
3383 
3384  // find mesh & collect node ids into array
3385  map<string,TriMesh*>::iterator tm=m_mesh.find(meshname);
3386  if (tm!=m_mesh.end()){
3387  for(TriMesh::triangle_iterator iter=(tm->second)->triangles_begin();
3388  iter!=(tm->second)->triangles_end();
3389  iter++){
3390  ref_vec.push_back(iter->getID());
3391  }
3392  } else {
3393  map<string,Mesh2D*>::iterator m2d=m_mesh2d.find(meshname);
3394  if(m2d!=m_mesh2d.end()){
3395  for(Mesh2D::edge_iterator iter=(m2d->second)->edges_begin();
3396  iter!=(m2d->second)->edges_end();
3397  iter++){
3398  ref_vec.push_back(iter->getID());
3399  }
3400  } else {
3401  console.Critical() << "ERROR - WRONG MESH NAME IN getMeshNodeRef() !! \n";
3402  }
3403  }
3404  // send back to master
3405  m_tml_comm.send_gather(ref_vec,0);
3406 
3407  console.XDebug() << "end TSubLattice<T>::getMeshNodeRef()\n";
3408 }
3409 
3413 template <class T>
3415 {
3416  console.XDebug() << "TSubLattice<T>::getMesh2DStress()\n";
3417  // receive mesh name
3418  // MPI buffer
3419  CVarMPIBuffer param_buffer(m_comm);
3420  param_buffer.receiveBroadcast(0);
3421  string meshname=param_buffer.pop_string();
3422  console.XDebug() << "Mesh name: " << meshname << "\n";
3423 
3424  // find mesh & collect data
3425  map<string,Mesh2D*>::iterator m2d=m_mesh2d.find(meshname);
3426  if(m2d!=m_mesh2d.end()){
3427  vector<pair<int,Vec3> > data_vec;
3428  // get data
3429  data_vec=(m2d->second)->forAllEdgesGetIndexed(&Edge2D::getForceDensity);
3430 
3431  // send data to master
3432  m_tml_comm.send_gather(data_vec,0);
3433  } else {
3434  console.Critical() << "ERROR - WRONG MESH NAME IN getMesh2DStress() !! \n";
3435  }
3436 
3437  console.XDebug() << "end TSubLattice<T>::getMesh2DStress()\n";
3438 }
3439 
3443 template <class T>
3445 {
3446  console.XDebug() << "TSubLattice<T>::getTriMeshStress(): enter\n";
3447  // receive mesh name
3448  // MPI buffers
3449  CVarMPIBuffer param_buffer(m_comm);
3450  param_buffer.receiveBroadcast(0);
3451  const std::string meshName = param_buffer.pop_string();
3452  console.XDebug() << "Mesh name: " << meshName << "\n";
3453 
3454  // find mesh & collect data
3455  map<string,TriMesh*>::iterator m=m_mesh.find(meshName);
3456  if(m != m_mesh.end()){
3457  vector<pair<int,Vec3> > data_vec;
3458  // get data
3459  data_vec=(m->second)->forAllTrianglesGetIndexed(&Triangle::getForce);
3460 
3461  // send data to master
3462  m_tml_comm.send_gather(data_vec,0);
3463  } else {
3464  std::stringstream msg;
3465  msg << "Invalid mesh name: " << meshName << ". No such triangular mesh.";
3466  throw std::runtime_error(msg.str().c_str());
3467  }
3468 
3469  console.XDebug() << "TSubLattice<T>::getTriMeshStress(): exit\n";
3470 }
virtual void addBondedWIG()
Definition: SubLattice.hpp:531
virtual void loadCheckPoint(istream &)
Definition: TriMesh.cpp:285
virtual void moveSingleNode()
Definition: SubLattice.hpp:2191
Definition: LatticeParam.h:29
virtual void printData()
Definition: SubLattice.hpp:2620
virtual Vec3 pop_vector()
Definition: mpibuf.cpp:26
double x0
Definition: FractalFriction.h:40
virtual void addScalarParticleField()
Definition: SubLattice.hpp:2643
base class for spherical non-inertial bodies (similar to simple walls)
Definition: SphereBody.h:39
double k
Definition: BTriMeshIP.h:21
virtual void printTimes()
Definition: SubLattice.hpp:2627
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:559
virtual void addScalarTriangleField()
Definition: SubLattice.hpp:2952
virtual void getWallForce()
Definition: SubLattice.hpp:649
void buildFromPPATagged(int, int)
Definition: mesh2d_pis_eb.hpp:357
double k_s
Definition: RotThermFricInteraction.h:51
virtual void addSingleIG()
Definition: SubLattice.hpp:1309
Console & XDebug()
set verbose level of next message to "xdg"
Definition: console.cpp:219
double m_alpha
Definition: SubLattice.h:98
virtual ~TSubLattice()
Definition: SubLattice.hpp:173
double y0
Definition: FractalFriction.h:40
Definition: RotThermParticle.h:54
int m_last_ns
Definition: SubLattice.h:100
virtual int getNumParticles()
Definition: SubLattice.hpp:241
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:108
Interaction group parameters for CRotElasticInteractionGroups.
Definition: RotElasticInteraction.h:24
VEC3_INLINE double & Z()
Definition: vec3.h:121
virtual void addScalarInteractionField()
Definition: SubLattice.hpp:2716
double commtime
Definition: SubLattice.h:121
int getNumRemaining() const
Definition: pp_array.hpp:678
VEC3_INLINE double & Y()
Definition: vec3.h:120
void resetDisplacements()
Definition: SubLattice.hpp:2133
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:1546
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:2982
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:785
virtual void exchangePos()
Definition: SubLattice.hpp:1671
virtual void moveParticleTo()
Definition: SubLattice.hpp:2150
double dx
Definition: FractalFriction.h:40
void integrate(double)
Definition: SubLattice.hpp:1825
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:107
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:111
virtual void addMesh2D()
Definition: SubLattice.hpp:1163
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:119
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
virtual void setParticleNonTrans()
Definition: SubLattice.hpp:2413
base class for all walls
Definition: Wall.h:39
Vec3(Triangle::* VectorFieldFunction)() const
Definition: Triangle.h:50
virtual void addCappedBondedIG()
Definition: SubLattice.hpp:1472
std::string getSphereBodyName() const
Definition: ESphereBodyInteractionGroup.h:40
virtual void rebuildParticleArray()
Definition: SubLattice.hpp:1962
bool hasNext() const
Definition: pp_array.hpp:663
virtual void addElasticWIG()
Definition: SubLattice.hpp:419
virtual void checkNeighbors()
Definition: SubLattice.hpp:2081
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:2678
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:64
double r_cut
Definition: AdhesiveFriction.h:35
virtual void setVelocityOfWall()
Definition: SubLattice.hpp:2521
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:1877
virtual void setTaggedParticleVel()
Definition: SubLattice.hpp:2428
virtual void setParticleDensity()
Definition: SubLattice.hpp:2556
Console & Info()
set verbose level of next message to "inf"
Definition: console.cpp:193
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:327
virtual void getMeshNodeRef()
Definition: SubLattice.hpp:3330
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:2397
virtual void applyForceToWall()
Definition: SubLattice.hpp:2501
bool meanR_scaling
Definition: RotFricInteraction.h:79
double m_k
Definition: ElasticInteraction.h:28
virtual void setTimeStepSize(double dt)
Definition: SubLattice.hpp:1776
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:109
boost::shared_ptr< double > mu
pointer to the array of friction coeff.
Definition: FractalFriction.h:39
virtual void addScalarHistoryInteractionField()
Definition: SubLattice.hpp:2858
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:1022
virtual void initNeighborTable(const Vec3 &, const Vec3 &)
Definition: SubLattice.hpp:209
CESphereBodyIGP * extractESphereBodyIGP(AMPIBuffer *B)
Definition: ESphereBodyInteractionGroup.cpp:52
double unpacktime
Definition: SubLattice.h:120
virtual void getSphereBodyPos()
Definition: SubLattice.hpp:618
Particle & next()
Definition: pp_array.hpp:669
void calcHeatTrans()
Definition: SubLattice.hpp:1931
virtual void addESphereBodyIG()
Definition: SubLattice.hpp:454
Definition: BMesh2DIP.h:16
bool scaling
Definition: RotFricInteraction.h:77
virtual void addPairIG()
Definition: SubLattice.hpp:739
double m_cutoff
Definition: LinearDashpotInteraction.h:28
virtual void sendDataToMaster()
Definition: SubLattice.hpp:2574
double k
Definition: RotFricInteraction.h:72
virtual void moveWallBy()
Definition: SubLattice.hpp:2444
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:760
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'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:2244
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't require exch...
Definition: mesh2d_pis_ne.h:29
Abstract Base class for a group of interactions between particles and a sphere body.
Definition: SphereBodyIG.h:30
virtual void addRotThermBondedIG()
Definition: SubLattice.hpp:1536
std::string getWallName() const
Definition: brokenEWallInteractionGroup.h:40
virtual void countParticles()
Definition: SubLattice.hpp:2596
double m_E
Definition: HertzianViscoElasticInteraction.h:28
double diffusivity
Definition: RotThermFricInteraction.h:53
virtual void getTriMeshForce()
Definition: SubLattice.hpp:3444
virtual void addBondedMesh2DIG()
Definition: SubLattice.hpp:1250
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:1107
Console console
Definition: console.cpp:25
Interaction group parameters for CLocalDampingGroup.
Definition: LocalDampingIGP.h:27
virtual void saveCheckPointData(std::ostream &oStream)
Definition: SubLattice.hpp:3140
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:1202
class for slave part of scalar field defined on the particles
Definition: VectorParticleFieldSlave.h:31
void zeroHeat()
Definition: SubLattice.hpp:1889
double dt
Definition: AdhesiveFriction.h:34
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:1635
double mu
Definition: FrictionInteraction.h:39
double m_alpha
Definition: VWFrictionInteraction.h:25
double forcetime
Definition: SubLattice.h:122
Buffer for MPI scatter/gather, leaf component.
Definition: mpisgbuf.h:124
virtual void oneStepTherm()
Definition: SubLattice.hpp:1853
Slave part for saving a vector field defined on the edges in a given Mesh2D.
Definition: VectorEdge2DFieldSlave.h:34
Console & Error()
set verbose level of next message to "err"
Definition: console.cpp:154
const ProcessDims & processDims() const
Definition: LatticeParam.h:44
Definition: BTriMeshIP.h:18
virtual void tryInsert(const I &)
virtual void searchNeighbors()
Definition: SubLattice.hpp:2006
static BuoyancyIGP extract(CVarMPIBuffer *pBuffer)
Definition: BodyForceGroup.cpp:92
void calcForces()
Definition: SubLattice.hpp:1727
CEWallIGP * extractEWallIGP(AMPIBuffer *)
Definition: EWallInteractionGroup.cpp:53
const std::string & Name() const
Definition: IGParam.h:44
virtual void send()
Definition: mpisgvbuf.cpp:287
Vec3(Edge2D::* VectorFieldFunction)() const
Definition: Edge2D.h:41
virtual void addTaggedElasticWIG()
Definition: SubLattice.hpp:489
void integrateTherm(double dt)
Definition: SubLattice.hpp:1868
virtual void sendFieldData()
Definition: SubLattice.hpp:3067
CVWallIGP * extractVWallIGP(AMPIBuffer *B)
Definition: ViscWallIG.cpp:54
void buildFromPPAByGap(double)
Definition: mesh2d_pis_eb.hpp:405
virtual void addDamping()
Definition: SubLattice.hpp:1359
virtual void saveSnapShotData(std::ostream &oStream)
Definition: SubLattice.hpp:3092
parallel storage array with exchange for bonded/breakable interactions
Definition: pi_storage_eb.h:29
Interaction group parameters for CESphereBodyInteractionGroups.
Definition: ESphereBodyInteractionGroup.h:32
double rbreak
Breaking strain.
Definition: BondedInteraction.h:52
virtual void loadCheckPoint(istream &)
Definition: Wall.cpp:128
virtual void receiveConnections()
Definition: SubLattice.hpp:350
virtual void addRotBondedIG()
Definition: SubLattice.hpp:1530
TML_Comm m_tml_worker_comm
TML version of the communicator between workers (excl. master)
Definition: SubLattice.h:110
virtual void updateInteractions()
Definition: SubLattice.hpp:2027
virtual void addBondedIG()
Definition: SubLattice.hpp:1425
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:381
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:116
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
static BodyForceIGP extract(CVarMPIBuffer *pBuffer)
Definition: BodyForceGroup.cpp:52
virtual void rebuildInteractions()
Definition: SubLattice.hpp:1971
double alpha() const
Definition: LatticeParam.h:43
virtual void addTriMeshIG()
Definition: SubLattice.hpp:1060
Console & Critical()
set verbose level of next message to "crt"
Definition: console.cpp:141
virtual void append(int)
Definition: mpisgbuf.cpp:239
CLocalDampingIGP * extractLocalDampingIGP(AMPIBuffer *B)
Definition: LocalDampingIGP.cpp:57
Class for a group of unbonded,elastic interactions between particles and a sphere body...
Definition: ESphereBodyInteractionGroup.h:48
virtual void loadCheckPointData(std::istream &iStream)
Definition: SubLattice.hpp:3215
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:3414
void calcHeatFrict()
Definition: SubLattice.hpp:1913
virtual void do2dCalculations(bool do2d)
Definition: SubLattice.hpp:235
double k
Definition: FrictionInteraction.h:38
Console & Debug()
set verbose level of next message to "dbg"
Definition: console.cpp:206
VEC3_INLINE double & X()
Definition: vec3.h:119
Vec3 getForce() const
Definition: Triangle.h:91
virtual void setWallNormal()
Definition: SubLattice.hpp:2482
vector< Triangle >::iterator triangle_iterator
Definition: TriMesh.h:64
int m_rank
rank in m_comm
Definition: SubLattice.h:106
double m_nu
Definition: HertzianElasticInteraction.h:28
virtual void addVectorInteractionField()
Definition: SubLattice.hpp:2785
virtual void moveTaggedNodes()
Definition: SubLattice.hpp:2220
double m_kr
Definition: RotElasticInteraction.h:31
virtual void getSphereBodyForce()
Definition: SubLattice.hpp:680
virtual void moveSphereBodyBy()
Definition: SubLattice.hpp:2463
std::pair< int, Vec3 > getParticlePosn(int particleId)
Definition: SubLattice.hpp:2290
Abstract base class for slave part of field.
Definition: FieldSlave.h:22
virtual void setExIG()
Definition: SubLattice.hpp:1602
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:3372
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:2610
virtual void loadCheckPoint(istream &)
Definition: SphereBody.cpp:60
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
virtual void addSphereBody()
Definition: SubLattice.hpp:400
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:2381
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:2907
Definition: Mesh2D.h:46
virtual void Update(ParallelParticleArray< T > *)=0
virtual void addViscWIG()
Definition: SubLattice.hpp:711
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:2257
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:2167
double m_nu
Definition: HertzianViscoElasticFrictionInteraction.h:51
void zeroForces()
Definition: SubLattice.hpp:1684
virtual bool doAddDamping(const string &, CVarMPIBuffer &)
Definition: SubLattice.hpp:1382
double m_nrange
Definition: SubLattice.h:96
double k
Spring constant.
Definition: BondedInteraction.h:51
virtual void oneStep()
Definition: SubLattice.hpp:1837
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:2181
virtual void setParticleVelocity()
Definition: SubLattice.hpp:2540
virtual void tagParticleNearestTo()
Definition: SubLattice.hpp:2354
double(Triangle::* ScalarFieldFunction)() const
Definition: Triangle.h:51
double dt
Definition: RotFricInteraction.h:76
std::vector< SimpleParticle > ParticleVector
Definition: SimpleNTable3D.h:22
virtual void getParticleData(const IdVector &particleIdVector)
Definition: SubLattice.hpp:2314
virtual void getWallPos()
Definition: SubLattice.hpp:587
Definition: ETriMeshIP.h:17
void addWall(CWall *)
Definition: WallFieldSlave.cpp:31
Definition: RotThermElasticInteraction.h:23
Class for a group of unbonded,elastic interactions between particles and a wall using only particles ...
Definition: TaggedEWallInteractionGroup.h:31