ESyS-Particle  2.3.4
pi_storage_ed.hpp
Go to the documentation of this file.
1 // //
3 // Copyright (c) 2003-2017 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.apache.org/licenses/LICENSE-2.0 //
10 // //
12 
13 template<typename P,typename I>
15 {
17 }
18 
19 template<typename P,typename InteractionType>
21 {
22  console.Debug() << "setExIG " << eg << "\n";
23  m_exIG.push_back(eg);
24  // clean out excluded interactions
25  typename list<InteractionType>::iterator iter = this->m_interactions.begin();
26  while(iter != this->m_interactions.end()){
27  // check if in exIG
28  vector<int> rm_pids=iter->getAllID();
29  if(eg->isIn(rm_pids)){
30  console.XDebug() << "removing excluded: " << rm_pids[0] << " - " << rm_pids[1] << "\n";
31  typename list<InteractionType>::iterator er_iter=iter;
32  // get particle ids and remove pair from set
33  this->m_set.erase(make_pair(rm_pids[0],rm_pids[1]));
34  iter++;
35  this->m_interactions.erase(er_iter);
36  } else {
37  iter++;
38  }
39  }
40 }
41 
42 
48 template<typename T,typename InteractionType>
50 {
51  bool in_exig=false;
52  if(m_exIG.size()>0){ // if there is an ExIG
53  vector<AParallelInteractionStorage*>::iterator exiter=m_exIG.begin();
54  while(exiter!=m_exIG.end() && (!in_exig)){ // not yet excluded and more excluders to check
55  in_exig=(*exiter)->isIn(tv);
56  exiter++;
57  }
58  }
59  return in_exig;
60 }
61 
62 template<typename T,typename InteractionType>
64  double dt
65 )
66 {
67  console.Debug()
68  << "setting time step size for "
69  << this->m_interactions.size() << " interaction forces\n" ;
70  this->m_param.setTimeStepSize(dt);
71  for (
72  typename std::list<InteractionType>::iterator it = this->m_interactions.begin();
73  it != this->m_interactions.end();
74  it++
75  ){
76  it->setTimeStepSize(dt);
77  }
78 }
79 
83 template<typename T,typename InteractionType>
85 {
86  //std::cout << "ParallelInteractionStorage_ED::update at node " << m_comm.rank() << std::endl << std::flush;
87  int count_l=0;
88  bool res=true;
89 
90  if (this->m_update_timestamp != this->m_ppa->getTimeStamp()){// m_ppa rebuild since last update
91  console.XDebug() << "node " << this->m_comm.rank() << " ppa has been rebuilt\n";
92  // clean out old interactions if not flagged as persistent
93  typename list<InteractionType>::iterator iter = this->m_interactions.begin();
94  while(iter != this->m_interactions.end()){
95  if(iter->isPersistent()){
96  iter++;
97  //console.XDebug() << "node " << m_comm.rank() << "persistent interaction\n";
98  }else{
99  typename list<InteractionType>::iterator er_iter=iter;
100  // get particle ids and remove pair from set
101  vector<int> rm_pids=iter->getAllID();
102  this->m_set.erase(make_pair(rm_pids[0],rm_pids[1]));
103  iter++;
104  this->m_interactions.erase(er_iter);
105  }
106  }
107  // get list of pairs from m_ppa
109  ((ParallelParticleArray<T>*)this->m_ppa)->getFullPairList();
110  // generate interactions from pairs
111  for(typename ParallelParticleArray<T>::PairListIterator iter=plh->begin();
112  iter!=plh->end();
113  iter++){
114  // check vs. ExIG
115  vector<int> tv;
116  // ids in pair
117  int id1=iter->first->getID();
118  int id2=iter->second->getID();
119  tv.push_back(id1);
120  tv.push_back(id2);
121  if((!isExcluded(tv))&&(!this->isIn(tv))){ // if not already in or in ExIG
122  this->m_interactions.push_back(
123  InteractionType(iter->first,iter->second,this->m_param)
124  );
125  this->m_set.insert(make_pair(id1,id2));
126  count_l++;
127  }
128  }
129  } else { // m_ppa not rebuild since last update -> just get additional interactions
130  console.XDebug() << "node " << this->m_comm.rank() << " ppa not rebuilt\n";
131  // get list of pairs from m_ppa
133  ((ParallelParticleArray<T>*)this->m_ppa)->getNewPairList();
134  for (
135  typename ParallelParticleArray<T>::PairListIterator iter=plh->begin();
136  iter!=plh->end();
137  iter++
138  ){
139  // check vs. ExIG
140  vector<int> tv;
141  // ids in pair
142  int id1=iter->first->getID();
143  int id2=iter->second->getID();
144  tv.push_back(id1);
145  tv.push_back(id2);
146  if((!isExcluded(tv))&&(!this->isIn(tv))){
147  this->m_interactions.push_back(
148  InteractionType(iter->first,iter->second, this->m_param)
149  );
150  this->m_set.insert(make_pair(id1,id2));
151  count_l++;
152  }
153  }
154  }
155  m_update_timestamp = this->m_ppa->getTimeStamp();
156 
157  console.Debug() << "added " << count_l << " pairs to ParallelInteractionStorage_ED\n";
158  // std::cout << "end ParallelInteractionStorage_ED::update at node " << m_comm.rank() << std::endl << std::flush;
159 
160  return res;
161 }
162 
163 
164 template<typename T,typename InteractionType>
166 {
167  console.Debug()
168  << "calculating "
169  << this->m_interactions.size()
170  << " frictional heatings\n" ;
171 
172  for(
173  typename list<InteractionType>::iterator it = this->m_interactions.begin();
174  it != this->m_interactions.end();
175  it++
176  ){
177  it->calcHeatFrict();
178  }
179 }
180 
181 template<typename P,typename InteractionType>
183 {
184  console.Debug()
185  << "calculating "
186  << this->m_interactions.size()
187  << " heat transfers\n" ;
188 
189  for(
190  typename list<InteractionType>::iterator it = this->m_interactions.begin();
191  it != this->m_interactions.end();
192  it++
193  ){
194  it->calcHeatTrans();
195  }
196 }
197 
201 template<typename P,typename InteractionType>
203 {
204  const std::string delim = "\n";
205 
207  this->getInnerInteractionIterator();
208  oStream << InteractionType::getType() << delim;
209  oStream << it.getNumRemaining();
210  if (it.hasNext()) {
211  oStream << delim;
212  it.next().saveRestartData(oStream);
213  while (it.hasNext())
214  {
215  oStream << delim;
216  it.next().saveRestartData(oStream);
217  }
218  }
219 }
220 
228 template<typename P,typename InteractionType>
230 {
231  // read interaction type from stream
232  std::string cp_interaction_type;
233  iStream >> cp_interaction_type;
234  // compare interaction type in stream with type of this IG
235  // in not equal, signal error
236  if(cp_interaction_type!=InteractionType::getType()){
237  std::cerr << "interaction types differ between checkpoint "
238  << cp_interaction_type << " and scipt "
239  << InteractionType::getType() << std::endl;
240  } else { // correct type -> read data
241  // read nr. of bonds in IG
242  int nconn;
243  iStream >> nconn;
244  std::cerr << "reading " << nconn << " " << InteractionType::getType() << " interactions " << std::endl;
245 
246  // -- read bonds
247  for(int i=0;i<nconn;i++){
248  InteractionType new_bond;
249  // read a bond
250  new_bond.loadRestartData(iStream);
251  // insert it into interaction storage
252  this->tryInsert(new_bond);
253  }
254  }
255 }
ParallelParticleArray::PairListIterator
NeighborTable< T >::pairlist::iterator PairListIterator
Definition: pp_array.h:78
ParallelInteractionStorage_ED::update
virtual bool update()
Definition: pi_storage_ed.hpp:84
TParallelInteractionStorage::InteractionIterator::getNumRemaining
int getNumRemaining()
Definition: pi_storage.hpp:69
Console::Debug
Console & Debug()
set verbose level of next message to "dbg"
TParallelInteractionStorage::InteractionIterator::next
Interaction & next()
Definition: pi_storage.hpp:57
ParallelInteractionStorage_ED::calcHeatFrict
virtual void calcHeatFrict()
Definition: pi_storage_ed.hpp:165
ParallelInteractionStorage_ED::setTimeStepSize
virtual void setTimeStepSize(double dt)
does nothing
Definition: pi_storage_ed.hpp:63
ParallelInteractionStorage_E
parallel interaction storage array with exchange
Definition: pi_storage_e.h:37
AParallelInteractionStorage
abstract base class for parallel interaction storage array
Definition: pi_storage.h:45
ParallelInteractionStorage_ED::saveCheckPointData
virtual void saveCheckPointData(std::ostream &oStream)
Definition: pi_storage_ed.hpp:202
ParallelParticleArray
parrallel particle storage array with neighborsearch and variable exchange
Definition: pp_array.h:75
Console::XDebug
Console & XDebug()
set verbose level of next message to "xdg"
AParallelParticleArray
abstract base class for parallel particle storage array
Definition: pp_array.h:42
ParallelInteractionStorage_ED::ParallelInteractionStorage_ED
ParallelInteractionStorage_ED(AParallelParticleArray *, const typename I::ParameterType &)
Definition: pi_storage_ed.hpp:14
T_Handle
Template class for a handle/ref. counted pointer.
Definition: handle.h:27
ParallelInteractionStorage_ED::m_update_timestamp
int m_update_timestamp
Definition: pi_storage_ed.h:36
AParallelInteractionStorage::isIn
virtual bool isIn(const vector< int > &)=0
esys::lsm::bpu::iter
boost::python::object iter(const boost::python::object &pyOb)
Definition: Util.h:25
ParallelInteractionStorage_ED::calcHeatTrans
virtual void calcHeatTrans()
Definition: pi_storage_ed.hpp:182
ParallelInteractionStorage_ED::loadCheckPointData
virtual void loadCheckPointData(std::istream &iStream)
Definition: pi_storage_ed.hpp:229
ParallelInteractionStorage_ED::addExIG
virtual void addExIG(AParallelInteractionStorage *)
Definition: pi_storage_ed.hpp:20
ParallelInteractionStorage_ED::isExcluded
bool isExcluded(const vector< int >)
Definition: pi_storage_ed.hpp:49
TParallelInteractionStorage::InteractionIterator
Definition: pi_storage.h:102
console
Console console
Definition: console.cpp:25
TParallelInteractionStorage::InteractionIterator::hasNext
bool hasNext()
Definition: pi_storage.hpp:50