MercuryDPM  0.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
CTangentialSprings Class Reference

Member variable of #Particle storing all tangential springs $\vec{\delta}_{ij}^t$ of particle PI with contacting particles PJ. More...

#include <CTangentialSpring.h>

+ Inheritance diagram for CTangentialSprings:

Classes

struct  check_spring_time
 Construction required for the erase/remove_if stuff. More...
 

Public Member Functions

std::vector< intto_be_erased (Mdouble time)
 Function selects the tangential spring vector for particle-particle interations (also removed not used springs}. More...
 
void to_erase (Mdouble time)
 Function selects the tangential spring vector for particle-particle interations (also removed not used springs}. More...
 
CTangentialSpringselect_particle_spring (int P, Mdouble time_, Mdouble dt)
 Function selects the tangential spring vector for particle-particle interations (also removed not used springs}. More...
 
CTangentialSpringcreate_new (int P, Mdouble time_, Mdouble dt)
 
CTangentialSpringcreate_new (int P, Mdouble time_, Mdouble dt, CTangentialSpring &CTS)
 
CTangentialSpringcreate_new_wall (int W, Mdouble time_, Mdouble dt)
 
bool has_particle_spring (int P, Mdouble time_)
 
CTangentialSpringselect_wall_spring (int W, Mdouble time_, Mdouble dt)
 Function selects the tangential spring vector for particle-particle interations (also removed not used springs}. More...
 
void reset ()
 Resets the tangential springs. More...
 
void print (std::ostream &os, Mdouble time_)
 outputs all current active tangential springs More...
 

Friends

std::ostream & operator<< (std::ostream &os, const CTangentialSprings &p)
 writes all springs More...
 
std::istream & operator>> (std::istream &is, CTangentialSprings &p)
 reads all springs More...
 

Detailed Description

Member variable of #Particle storing all tangential springs $\vec{\delta}_{ij}^t$ of particle PI with contacting particles PJ.

A tangential spring between PI and PJ can be stored in either particle depending on which particle is the first particle in MD::compute_internal_forces.

Geometrically, there can be no more than 13 possible contacts in 3D, so the vector size is limited.

Definition at line 137 of file CTangentialSpring.h.

Member Function Documentation

CTangentialSpring* CTangentialSprings::create_new ( int  P,
Mdouble  time_,
Mdouble  dt 
)
inline

Definition at line 179 of file CTangentialSpring.h.

Referenced by MD::getTangentialSpring().

180  {
181  //if not, create it
182  push_back(CTangentialSpring(P,-1,time_+dt));
183  return &back();
184  }
Stores the tangential spring needed to compute a tangential elastic force between particles PI...
CTangentialSpring* CTangentialSprings::create_new ( int  P,
Mdouble  time_,
Mdouble  dt,
CTangentialSpring CTS 
)
inline

Definition at line 186 of file CTangentialSpring.h.

187  {
188  //if not, create it
189  push_back(CTangentialSpring(CTS));
190  back().pParticle=P;
191  back().time=time_+dt;
192  return &back();
193  }
Stores the tangential spring needed to compute a tangential elastic force between particles PI...
CTangentialSpring* CTangentialSprings::create_new_wall ( int  W,
Mdouble  time_,
Mdouble  dt 
)
inline

Definition at line 195 of file CTangentialSpring.h.

Referenced by MD::getTangentialSpringWall().

196  {
197  //if not, create it
198  push_back(CTangentialSpring(-1,W,time_+dt));
199  return &(back());
200  }
Stores the tangential spring needed to compute a tangential elastic force between particles PI...
bool CTangentialSprings::has_particle_spring ( int  P,
Mdouble  time_ 
)
inline

Definition at line 203 of file CTangentialSpring.h.

203  {
204  //Remove_if reconstructs the vector with only elements passing the check_spring_time function
205  //Erase removes the end of the vector
206  erase(remove_if(begin(),end(),bind2nd(check_spring_time(),time_)),end());
207  //Loops over all Springs and returns the correct one (if it exists)
208  for (CTangentialSprings::iterator it=begin(); it!=end();it++){
209  if (it->pParticle==P)
210  {
211  return true;
212  }
213  }
214  //if not, create it
215  return false;
216  }
void CTangentialSprings::print ( std::ostream &  os,
Mdouble  time_ 
)
inline

outputs all current active tangential springs

Definition at line 246 of file CTangentialSpring.h.

246  {
247  os << "Tangential Springs: N=" << size() << std::endl;
248  for (CTangentialSprings::iterator it=begin(); it!=end(); it++)
249  if (it->time>=time_) {
250  it->print(os); os << std::endl;
251  }
252  }
void CTangentialSprings::reset ( )
inline

Resets the tangential springs.

Definition at line 240 of file CTangentialSpring.h.

Referenced by TangentialSpringParticle::TangentialSpringParticle().

240  {
241  clear();
242  reserve(13);
243  }
CTangentialSpring* CTangentialSprings::select_particle_spring ( int  P,
Mdouble  time_,
Mdouble  dt 
)
inline

Function selects the tangential spring vector for particle-particle interations (also removed not used springs}.

Definition at line 163 of file CTangentialSpring.h.

Referenced by MD::computeShortRangeForceWithParticle(), and MD::getTangentialSpring().

163  {
164  //Remove_if reconstructs the vector with only elements passing the check_spring_time function
165  //Erase removes the end of the vector
166  erase(remove_if(begin(),end(),bind2nd(check_spring_time(),time_)),end());
167 
168  //Loops over all Springs and returns the correct one (if it exists)
169  for (CTangentialSprings::iterator it=begin(); it!=end();it++){
170  if (it->pParticle==P)
171  {
172  it->time=time_+dt;
173  return &(*it);
174  }
175  }
176  return 0;
177  }
CTangentialSpring* CTangentialSprings::select_wall_spring ( int  W,
Mdouble  time_,
Mdouble  dt 
)
inline

Function selects the tangential spring vector for particle-particle interations (also removed not used springs}.

Definition at line 220 of file CTangentialSpring.h.

Referenced by MD::computeShortRangeForceWithWall(), and MD::getTangentialSpringWall().

220  {
221  //Remove_if reconstructs the vector with only elements passing the check_spring_time function
222  //Erase removes the end of the vector
223  erase(remove_if(begin(),end(),bind2nd(check_spring_time(),time_)),end());
224 
225  //Loops over all Springs ant returns the correct one (if it exists)
226  for (CTangentialSprings::iterator it=begin(); it!=end();it++){
227  if (it->pWall==W)
228  {
229  it->time=time_+dt;
230  return &(*it);
231  }
232  }
233 
234  //if not, create it
235  //~ std::cout << "created pw " << time_ << " " << W << std::endl;
236  return 0;
237  }
std::vector<int> CTangentialSprings::to_be_erased ( Mdouble  time)
inline

Function selects the tangential spring vector for particle-particle interations (also removed not used springs}.

Definition at line 147 of file CTangentialSpring.h.

147  {
148  std::vector<int> retval;
149  for (unsigned int i=0; i<size(); i++)
150  if (operator[](i).time<time) {
151  retval.push_back(i);
152  //std::cout << "to be erased " << time << " " << operator[](i).pParticle << " " << operator[](i).pWall << " " << size() << std::endl;
153  }
154  return retval;
155  }
void CTangentialSprings::to_erase ( Mdouble  time)
inline

Function selects the tangential spring vector for particle-particle interations (also removed not used springs}.

Definition at line 158 of file CTangentialSpring.h.

158  {
159  erase(remove_if(begin(),end(),bind2nd(check_spring_time(),time)),end());
160  }

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  os,
const CTangentialSprings p 
)
friend

writes all springs

Definition at line 256 of file CTangentialSpring.h.

257  {
258  os << p.size();
259  for (unsigned int i=0; i<p.size(); i++) os << " " << p[i];
260  return os;
261  }
std::istream& operator>> ( std::istream &  is,
CTangentialSprings p 
)
friend

reads all springs

Definition at line 264 of file CTangentialSpring.h.

265  {
266  //should return empty spring if read from is failed
267  int n; is >> n;
268  if (is.fail()) {
269  p.resize(0);
270  } else {
271  p.resize(n);
272  for (unsigned int i=0; i<p.size(); i++) is >> p[i];
273  }
274  return is;
275  }

The documentation for this class was generated from the following file: