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