ESyS-Particle  2.3.4
RotElasticInteractionGroup.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 
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  this->m_kr=Param->getNormalSpringConst();
31  this->m_update_timestamp=0;
32 }
33 
34 template<class T>
36 {
37  this->m_kr=Param->getNormalSpringConst();
38 }
39 
40 template<class T>
42 {
43 
44  console.Debug() << "calculating " << m_interactions.size() << " elastic forces\n" ;
45 
46  for(vector<CRotElasticInteraction>::iterator it=m_interactions.begin();it!=m_interactions.end();it++){
47  it->calcForces();
48  }
49 }
50 
56 template<class T>
58 {
59  console.XDebug() << "CElasticInteractionGroup::Update\n";
60  int count_l=0;
61 
62  if(this->m_update_timestamp!=PPA->getTimeStamp()){// PPA rebuild since last update
63  // clean out old interactions
64  m_interactions.erase(m_interactions.begin(),m_interactions.end());
65  this->m_set.erase(this->m_set.begin(),this->m_set.end());
66  // get list of pairs from PPA
68  // generate interactions from pairs
69  for(typename ParallelParticleArray<T>::PairListIterator iter=plh->begin();iter!=plh->end();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(CRotElasticInteraction(iter->first,iter->second,m_kr));
77  this->m_set.insert(pair<int,int>(iter->first->getID(),iter->second->getID()));
78  console.XDebug() << "adding pair: " << iter->first->getID() << " - " << iter->second->getID() << "\n";
79  count_l++;
80  } else {
81  console.XDebug() << "not adding pair: " << iter->first->getID() << " - " << iter->second->getID() << "\n";
82  }
83  } else {
84  m_interactions.push_back(CRotElasticInteraction(iter->first,iter->second,m_kr));
85  this->m_set.insert(pair<int,int>(iter->first->getID(),iter->second->getID()));
86  console.XDebug() << "adding pair: " << iter->first->getID() << " - " << iter->second->getID() << "\n";
87  }
88  }
89  } else { // PPA not rebuilt since last update -> just get additional interactions
90  // get list of pairs from PPA
92  for(typename ParallelParticleArray<T>::PairListIterator iter=plh->begin();iter!=plh->end();iter++){
93  // check vs. ExIG
94  vector<int> tv;
95  tv.push_back(iter->first->getID());
96  tv.push_back(iter->second->getID());
97  if(m_exIG!=NULL){
98  if(!m_exIG->isIn(tv)){
99  m_interactions.push_back(CRotElasticInteraction(iter->first,iter->second,m_kr));
100  this->m_set.insert(pair<int,int>(iter->first->getID(),iter->second->getID()));
101  console.XDebug() << "adding pair: " << iter->first->getID() << " - " << iter->second->getID() << "\n";
102  count_l++;
103  } else {
104  console.XDebug() << "not adding pair: " << iter->first->getID() << " - " << iter->second->getID() << "\n";
105  }
106  } else {
107  m_interactions.push_back(CRotElasticInteraction(iter->first,iter->second,m_kr));
108  this->m_set.insert(pair<int,int>(iter->first->getID(),iter->second->getID()));
109  console.XDebug() << "adding pair: " << iter->first->getID() << " - " << iter->second->getID() << "\n";
110  }
111  }
112  }
113 
114  this->m_update_timestamp=PPA->getTimeStamp();
115  console.XDebug() << "added " << count_l << " pairs to EIG\n";
116  console.XDebug() << "end CElasticInteractionGroup::Update\n";
117 }
118 
119 template<class T>
120 ostream& operator<<(ostream& ost,const CRotElasticInteractionGroup<T>& E)
121 {
122  ost << "CElasticInteractionGroup : \n";
123  for(vector<CRotElasticInteraction>::const_iterator it=E.m_interactions.begin();it!=E.m_interactions.end();it++){
124  ost << *it << " , " ;
125  }
126  ost << "exchange list: \n";
127  for(set<pair<int,int> >::const_iterator vit=E.m_exchg_list.begin();vit!=E.m_exchg_list.end();vit++){
128  ost << "[ " << vit->first << " from " << vit->second << " ] , ";
129  }
130  return ost;
131 }
ParallelParticleArray::PairListIterator
NeighborTable< T >::pairlist::iterator PairListIterator
Definition: pp_array.h:78
ParallelParticleArray::getFullPairList
PairListHandle getFullPairList()
Get list of all pairs. Forwards to NTable::getFullList().
Definition: pp_array.h:187
CRotElasticInteractionGroup::Update
virtual void Update(ParallelParticleArray< T > *)
Definition: RotElasticInteractionGroup.hpp:57
pi_storage.h
operator<<
ostream & operator<<(ostream &ost, const CRotElasticInteractionGroup< T > &E)
Definition: RotElasticInteractionGroup.hpp:120
Console::Debug
Console & Debug()
set verbose level of next message to "dbg"
ParallelParticleArray::getNewPairList
PairListHandle getNewPairList()
Get list of new pairs. Forwards to NTable::getNewList().
Definition: pp_array.h:189
CRotElasticInteractionGroup::m_interactions
vector< CRotElasticInteraction > m_interactions
Definition: RotElasticInteractionGroup.h:33
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"
NULL
#define NULL
Definition: t_list.h:17
CRotElasticInteraction
Elastic Interaction between free rotational particles.
Definition: RotElasticInteraction.h:51
CRotElasticInteractionGroup::setParam
void setParam(const CRotElasticIGP *)
Definition: RotElasticInteractionGroup.hpp:35
CRotElasticInteractionGroup::CRotElasticInteractionGroup
CRotElasticInteractionGroup()
Definition: RotElasticInteractionGroup.hpp:20
CRotElasticInteractionGroup::calcForces
virtual void calcForces()
Definition: RotElasticInteractionGroup.hpp:41
CRotElasticIGP::getNormalSpringConst
double getNormalSpringConst() const
Definition: RotElasticInteraction.h:36
T_Handle
Template class for a handle/ref. counted pointer.
Definition: handle.h:27
CRotElasticInteractionGroup
Class for a group of unbonded,elastic interactions.
Definition: RotElasticInteractionGroup.h:31
esys::lsm::bpu::iter
boost::python::object iter(const boost::python::object &pyOb)
Definition: Util.h:25
CRotElasticIGP
Interaction group parameters for CRotElasticInteractionGroups.
Definition: RotElasticInteraction.h:25
console
Console console
Definition: console.cpp:25