~esys-p-dev/esys-particle/trunk

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
template<typename P,typename I>
ParallelInteractionStorage_EB<P,I>::ParallelInteractionStorage_EB(AParallelParticleArray* ppa,const typename I::ParameterType& param):ParallelInteractionStorage_E<P,I>(ppa,param)
{
}

/*!
  Update interactions. Check for broken interactions and remove them.
*/
template<typename P,typename InteractionType>
bool ParallelInteractionStorage_EB<P,InteractionType>::update()
{
  bool res=false;

  //cout << "PIS_EB::update on node " << m_comm.rank() << endl << flush;
  typename list<InteractionType>::iterator iter=m_interactions.begin();
  while(iter!=m_interactions.end()){
    if(iter->broken()){
      res=true;
      typename list<InteractionType>::iterator er_iter=iter;
      // get IDs to remove from set
      vector<int> pids=iter->getAllID();
      m_set.erase(make_pair(pids[0],pids[1]));
      iter++;
       // remove interaction
      m_interactions.erase(er_iter);
    } else {
      iter++;
    }
  }
  //  cout << "end PIS_EB::update on node " << m_comm.rank() << endl << flush;
  return res;
}

template<typename P,typename InteractionType>
void ParallelInteractionStorage_EB<P,InteractionType>::saveCheckPointData(std::ostream &oStream)
{
  const std::string delim = "\n";
  typedef typename InteractionType::CheckPointable CheckPointable;

  typename ParallelInteractionStorage_E<P,InteractionType>::InteractionIterator it = getInnerInteractionIterator();
  oStream << it.getNumRemaining();
  if (it.hasNext()) {
    oStream << delim;
    CheckPointable(it.next()).saveCheckPointData(oStream);
    while (it.hasNext())
    {
      oStream << delim;
      CheckPointable(it.next()).saveCheckPointData(oStream);
    }
  }
}

template<typename P,typename InteractionType>
void ParallelInteractionStorage_EB<P,InteractionType>::loadCheckPointData(std::istream &iStream)
{
  ParallelInteractionStorage_E<P,InteractionType>::loadCheckPointData(iStream);
}