ESyS-Particle
4.0.1
|
00001 00002 // // 00003 // Copyright (c) 2003-2011 by The University of Queensland // 00004 // Earth Systems Science Computational Centre (ESSCC) // 00005 // http://www.uq.edu.au/esscc // 00006 // // 00007 // Primary Business: Brisbane, Queensland, Australia // 00008 // Licensed under the Open Software License version 3.0 // 00009 // http://www.opensource.org/licenses/osl-3.0.php // 00010 // // 00012 00013 template<typename P,typename I> 00014 ParallelInteractionStorage_NE<P,I>::ParallelInteractionStorage_NE(AParallelParticleArray* ppa,const typename I::ParameterType& param):TParallelInteractionStorage<I>(ppa) 00015 { 00016 m_param=param; 00017 m_exIG=NULL; 00018 m_update_timestamp=0; 00019 } 00020 00021 template<typename P,typename InteractionType> 00022 void ParallelInteractionStorage_NE<P,InteractionType>::addExIG(AParallelInteractionStorage* eg) 00023 { 00024 m_exIG=eg; 00025 } 00026 00030 template<typename T,typename InteractionType> 00031 bool ParallelInteractionStorage_NE<T,InteractionType>::update() 00032 { 00033 console.XDebug() << "ParallelInteractionStorage_NE::Update\n"; 00034 int count_l=0; 00035 bool res=true; 00036 00037 if(m_update_timestamp != this->m_ppa->getTimeStamp()){// m_ppa rebuild since last update 00038 // clean out old interactions 00039 this->m_interactions.clear(); 00040 m_set.erase(m_set.begin(),m_set.end()); 00041 // get list of pairs from m_ppa 00042 typename ParallelParticleArray<T>::PairListHandle plh = 00043 ((ParallelParticleArray<T>*)this->m_ppa)->getFullPairList(); 00044 // generate interactions from pairs 00045 for(typename ParallelParticleArray<T>::PairListIterator iter=plh->begin(); 00046 iter!=plh->end(); 00047 iter++){ 00048 // check vs. ExIG 00049 vector<int> tv; 00050 tv.push_back(iter->first->getID()); 00051 tv.push_back(iter->second->getID()); 00052 if(m_exIG!=NULL){ 00053 if(!m_exIG->isIn(tv)){ 00054 this->m_interactions.push_back(InteractionType(iter->first,iter->second,m_param)); 00055 m_set.insert(pair<int,int>(iter->first->getID(),iter->second->getID())); 00056 count_l++; 00057 } 00058 } else { 00059 this->m_interactions.push_back(InteractionType(iter->first,iter->second,m_param)); 00060 m_set.insert(pair<int,int>(iter->first->getID(),iter->second->getID())); 00061 count_l++; 00062 } 00063 } 00064 } else { // m_ppa not rebuild since last update -> just get additional interactions 00065 // get list of pairs from m_ppa 00066 typename ParallelParticleArray<T>::PairListHandle plh = 00067 ((ParallelParticleArray<T>*)this->m_ppa)->getNewPairList(); 00068 //cout << "got NewPairList: "; 00069 for(typename ParallelParticleArray<T>::PairListIterator iter=plh->begin(); 00070 iter!=plh->end(); 00071 iter++){ 00072 // cout << iter->first->getID() << "-" << iter->second->getID() << endl; 00073 // check vs. ExIG 00074 vector<int> tv; 00075 tv.push_back(iter->first->getID()); 00076 tv.push_back(iter->second->getID()); 00077 if(m_exIG!=NULL){ 00078 if(!m_exIG->isIn(tv)){ 00079 this->m_interactions.push_back(InteractionType(iter->first,iter->second,m_param)); 00080 m_set.insert(pair<int,int>(iter->first->getID(),iter->second->getID())); 00081 count_l++; 00082 } 00083 } else { 00084 this->m_interactions.push_back(InteractionType(iter->first,iter->second,m_param)); 00085 m_set.insert(pair<int,int>(iter->first->getID(),iter->second->getID())); 00086 count_l++; 00087 } 00088 } 00089 } 00090 m_update_timestamp = this->m_ppa->getTimeStamp(); 00091 00092 console.XDebug() << "added " << count_l << " pairs to EIG\n"; 00093 console.XDebug() << "end ParallelInteractionStorage_NE::Update\n"; 00094 00095 return res; 00096 } 00097 00098 00102 template<typename P,typename InteractionType> 00103 bool ParallelInteractionStorage_NE<P,InteractionType>::isIn(const vector<int>& pids) 00104 { 00105 bool res; 00106 00107 res=m_set.find(make_pair(pids[0],pids[1]))!=m_set.end(); 00108 00109 return res; 00110 } 00111 00115 template<typename P,typename InteractionType> 00116 void ParallelInteractionStorage_NE<P,InteractionType>::calcForces() 00117 { 00118 console.Debug() 00119 << "calculating " 00120 << this->m_interactions.size() 00121 << " interaction forces\n"; 00122 00123 for( 00124 typename list<InteractionType>::iterator it = this->m_interactions.begin(); 00125 it != this->m_interactions.end(); 00126 it++ 00127 ){ 00128 it->calcForces(); 00129 } 00130 } 00131 00132 template<typename P,typename InteractionType> 00133 void ParallelInteractionStorage_NE<P,InteractionType>::calcHeatTrans() 00134 { 00135 console.Debug() 00136 << "calculating " 00137 << this->m_interactions.size() 00138 << " interaction heat transfers\n" ; 00139 00140 for( 00141 typename list<InteractionType>::iterator it = this->m_interactions.begin(); 00142 it != this->m_interactions.end(); 00143 it++ 00144 ){ 00145 it->calcHeatTrans(); 00146 } 00147 }