ESyS-Particle  2.3.2
BondedInteraction.h
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 #ifndef __BONDEDINTERACTION_H
14 #define __BONDEDINTERACTION_H
15 
16 // -- project includes --
17 #include "Model/IGParam.h" // keep this one first - it drags in mpi.h
18 #include "Model/Interaction.h"
19 #include "Model/Particle.h"
21 #include "Foundation/vec3.h"
22 
23 // -- I/O includes --
24 #include <iostream>
25 using std::ostream;
26 
27 // -- STL includes --
28 #include <utility>
29 
30 using std::pair;
31 
39 class CBondedIGP : public AIGParam
40 {
41 public:
42  CBondedIGP();
43 
44  CBondedIGP(const std::string &name, int tag, double normalK, double breakDistance, bool scaling=true);
45 
46  virtual std::string getTypeString() const
47  {
48  return "Bonded";
49  }
50 
51  double k;
52  double rbreak;
53  int tag;
54  bool m_scaling;
55 };
56 
65 {
66  public: // types
72 
73  typedef double (CBondedInteraction::* ScalarFieldFunction)() const;
74  typedef pair<bool,double> (CBondedInteraction::* CheckedScalarFieldFunction)() const;
76 
77  protected:
78  double m_k;
79  double m_r0;
80  double m_dist;
81  double m_break;
84  int m_tag;
85  bool m_scaling;
86 
88 
89  public:
92  CParticle *particle1,
93  CParticle *particle2,
94  const CBondedIGP &params
95  );
96 
97  virtual ~CBondedInteraction();
98 
99  static ScalarFieldFunction getScalarFieldFunction(const string&);
101  static VectorFieldFunction getVectorFieldFunction(const string&);
102 
103  static string getType() {return "Bonded";};
104 
105  virtual void calcForces();
106  void setBreak(double);
107  bool broken();
108 
109  inline int getTag() const {return m_tag;}
110  inline void setTag(int tag) {m_tag = tag;}
111 
112  double getCriterion() const;
113  double getPotentialEnergy() const;
114  double getStrain() const;
115  Vec3 getForce() const;
116 
117  virtual Vec3 getPos() const {return m_cpos;};
118  virtual void saveCheckPointData(std::ostream &oStream);
119 
120  friend ostream& operator<<(ostream&,const CBondedInteraction&);
122 
123  // save/load of restart parameters
124  virtual void saveRestartData(std::ostream &oStream);
125  virtual void loadRestartData(std::istream &iStream);
126 };
127 
128 #endif //__BONDEDINTERACTION_H