ESyS-Particle  2.3.2
ElasticInteractionGroup.hpp
Go to the documentation of this file.
1 
2 // //
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 
14 #include "pis/pi_storage.h"
15 
16 //----------------------------------------------
17 // CElasticInteractionGroup functions
18 //----------------------------------------------
19 template<class T>
21 {
22  m_exIG=NULL;
23  this->m_update_timestamp=0;
24 }
25 
26 template<class T>
28 {
29  m_exIG=NULL;
30  m_k=Param->getSpringConst();
31  this->m_update_timestamp=0;
32 }
33 
34 template<class T>
36 {
37  m_k=Param->getSpringConst();
38 }
39 
40 template<class T>
42 {
43 
44  console.Debug() << "calculating " << m_interactions.size() << " elastic forces\n" ;
45 
46  for(vector<CElasticInteraction>::iterator it=m_interactions.begin();it!=m_interactions.end();it++){
47  it->calcForces();
48  }
49 }
50 
54 template<class T>
56 {
57  console.XDebug() << "CElasticInteractionGroup::Update\n";
58  int count_l=0;
59 
60  if(this->m_update_timestamp!=PPA->getTimeStamp()){// PPA rebuild since last update
61  // clean out old interactions
62  m_interactions.erase(m_interactions.begin(),m_interactions.end());
63  this->m_set.erase(this->m_set.begin(),this->m_set.end());
64  // get list of pairs from PPA
66  // generate interactions from pairs
67  for(typename ParallelParticleArray<T>::PairListIterator iter=plh->begin();
68  iter!=plh->end();
69  iter++){
70  // check vs. ExIG
71  vector<int> tv;
72  tv.push_back(iter->first->getID());
73  tv.push_back(iter->second->getID());
74  if(m_exIG!=NULL){
75  if(!m_exIG->isIn(tv)){
76  m_interactions.push_back(CElasticInteraction(iter->first,iter->second,m_k));
77  this->m_set.insert(pair<int,int>(iter->first->getID(),iter->second->getID()));
78  console.XDebug()<<"adding pair: " << iter->first->getID() << " - "
79  << iter->second->getID() << "\n";
80  count_l++;
81  } else {
82  console.XDebug()<<"not adding pair: " << iter->first->getID() << " - "
83  << iter->second->getID() << "\n";
84  }
85  } else {
86  m_interactions.push_back(CElasticInteraction(iter->first,iter->second,m_k));
87  this->m_set.insert(pair<int,int>(iter->first->getID(),iter->second->getID()));
88  console.XDebug()<<"adding pair: " << iter->first->getID() << " - "
89  << iter->second->getID() << "\n";
90  }
91  }
92  } else { // PPA not rebuild since last update -> just get additional interactions
93  // get list of pairs from PPA
95  for(typename ParallelParticleArray<T>::PairListIterator iter=plh->begin();
96  iter!=plh->end();
97  iter++){
98  // check vs. ExIG
99  vector<int> tv;
100  tv.push_back(iter->first->getID());
101  tv.push_back(iter->second->getID());
102  if(m_exIG!=NULL){
103  if(!m_exIG->isIn(tv)){
104  m_interactions.push_back(CElasticInteraction(iter->first,iter->second,m_k));
105  this->m_set.insert(pair<int,int>(iter->first->getID(),iter->second->getID()));
106  console.XDebug()<<"adding pair: " << iter->first->getID() << " - "
107  << iter->second->getID() << "\n";
108  count_l++;
109  } else {
110  console.XDebug()<<"not adding pair: " << iter->first->getID() << " - "
111  << iter->second->getID() << "\n";
112  }
113  } else {
114  m_interactions.push_back(CElasticInteraction(iter->first,iter->second,m_k));
115  this->m_set.insert(pair<int,int>(iter->first->getID(),iter->second->getID()));
116  console.XDebug()<<"adding pair: " << iter->first->getID() << " - "
117  << iter->second->getID() << "\n";
118  }
119  }
120  }
121  this->m_update_timestamp=PPA->getTimeStamp();
122  console.XDebug() << "added " << count_l << " pairs to EIG\n";
123 
124  console.XDebug() << "end CElasticInteractionGroup::Update\n";
125 }
126 
127 template<class T>
128 ostream& operator<<(ostream& ost,const CElasticInteractionGroup<T>& E)
129 {
130  ost << "CElasticInteractionGroup : \n";
131  for(vector<CElasticInteraction>::const_iterator it=E.m_interactions.begin();it!=E.m_interactions.end();it++){
132  ost << *it << " , " ;
133  }
134  ost << "exchange list: \n";
135  for(set<pair<int,int> >::const_iterator vit=E.m_exchg_list.begin();vit!=E.m_exchg_list.end();vit++){
136  ost << "[ " << vit->first << " from " << vit->second << " ] , ";
137  }
138  return ost;
139 }