ESyS-Particle  4.0.1
pi_storage_ne_t.hpp
1 
2 // //
3 // Copyright (c) 2003-2011 by The University of Queensland //
4 // Earth Systems Science Computational Centre (ESSCC) //
5 // http://www.uq.edu.au/esscc //
6 // //
7 // Primary Business: Brisbane, Queensland, Australia //
8 // Licensed under the Open Software License version 3.0 //
9 // http://www.opensource.org/licenses/osl-3.0.php //
10 // //
12 
13 template<typename P,typename I>
14 ParallelInteractionStorage_NE_T<P,I>::ParallelInteractionStorage_NE_T(AParallelParticleArray* ppa,const typename I::ParameterType& param,int tag1, int mask1, int tag2, int mask2):ParallelInteractionStorage_NE<P,I>(ppa,param)
15 {
16  if(tag1<=tag2){ // sort tags so that m_tag1<=m_tag2
17  m_tag1=tag1;
18  m_mask1=mask1;
19  m_tag2=tag2;
20  m_mask2=mask2;
21  } else {
22  m_tag1=tag2;
23  m_mask1=mask2;
24  m_tag2=tag1;
25  m_mask2=mask1;
26  }
27 }
28 
29 
33 template<typename T,typename InteractionType>
35 {
36  console.XDebug() << "ParallelInteractionStorage_NE_T::Update\n";
37  int count_l=0;
38  bool res=true;
39 
40  if(this->m_update_timestamp != this->m_ppa->getTimeStamp()){// m_ppa rebuild since last update
41  // clean out old interactions
42  this->m_interactions.clear();
43  this->m_set.erase(this->m_set.begin(),this->m_set.end());
44  // get list of pairs from m_ppa
45  typename ParallelParticleArray<T>::PairListHandle plh =
46  ((ParallelParticleArray<T>*)this->m_ppa)->getFullPairList();
47  // generate interactions from pairs
48  for(typename ParallelParticleArray<T>::PairListIterator iter=plh->begin();
49  iter!=plh->end();
50  iter++){
51  //--- check particle tags ---
52  // get tags
53  int t1=iter->first->getTag();
54  int t2=iter->second->getTag();
55  // sort tags
56  if(t1>t2){
57  int th=t1;
58  t1=t2;
59  t2=th;
60  }
61  // tags fit -> go on
62  if(((t1 & m_mask1)==(m_tag1 & m_mask1)) && ((t2 & m_mask2)==(m_tag2 & m_mask2))){
63  // check vs. ExIG
64  vector<int> tv;
65  tv.push_back(iter->first->getID());
66  tv.push_back(iter->second->getID());
67  if(this->m_exIG!=NULL){
68  if(!this->m_exIG->isIn(tv)){
69  this->m_interactions.push_back(InteractionType(iter->first,iter->second,this->m_param));
70  this->m_set.insert(pair<int,int>(iter->first->getID(),iter->second->getID()));
71  count_l++;
72  }
73  } else {
74  this->m_interactions.push_back(InteractionType(iter->first,iter->second,this->m_param));
75  this->m_set.insert(pair<int,int>(iter->first->getID(),iter->second->getID()));
76  count_l++;
77  }
78  }
79  }
80  } else { // m_ppa not rebuild since last update -> just get additional interactions
81  // get list of pairs from m_ppa
82  typename ParallelParticleArray<T>::PairListHandle plh =
83  ((ParallelParticleArray<T>*)this->m_ppa)->getNewPairList();
84  for(typename ParallelParticleArray<T>::PairListIterator iter=plh->begin();
85  iter!=plh->end();
86  iter++){
87  //--- check particle tags ---
88  // get tags
89  int t1=iter->first->getTag();
90  int t2=iter->second->getTag();
91  // sort tags
92  if(t1>t2){
93  int th=t1;
94  t1=t2;
95  t2=th;
96  }
97  // tags fit -> go on
98  if(((t1 & m_mask1)==(m_tag1 & m_mask1)) && ((t2 & m_mask2)==(m_tag2 & m_mask2))){
99  // check vs. ExIG
100  vector<int> tv;
101  tv.push_back(iter->first->getID());
102  tv.push_back(iter->second->getID());
103  if(this->m_exIG!=NULL){
104  if(!this->m_exIG->isIn(tv)){
105  this->m_interactions.push_back(InteractionType(iter->first,iter->second,this->m_param));
106  this->m_set.insert(pair<int,int>(iter->first->getID(),iter->second->getID()));
107  count_l++;
108  }
109  } else {
110  this->m_interactions.push_back(InteractionType(iter->first,iter->second,this->m_param));
111  this->m_set.insert(pair<int,int>(iter->first->getID(),iter->second->getID()));
112  count_l++;
113  }
114  }
115  }
116  }
117  this->m_update_timestamp = this->m_ppa->getTimeStamp();
118 
119  console.XDebug() << "added " << count_l << " pairs to EIG\n";
120  console.XDebug() << "end ParallelInteractionStorage_NE_T::Update\n";
121 
122  return res;
123 }