ESyS-Particle  2.3.2
ElasticInteraction.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 __ELASTICINTERACTION_H
14 #define __ELASTICINTERACTION_H
15 
16 #include "Model/IGParam.h"
17 #include "Model/Interaction.h"
18 #include "Model/Particle.h"
19 
20 
24 class CElasticIGP : public AIGParam
25 {
26 protected:
27 public:
28  double m_k;
29  bool m_scaling;
30 
31  CElasticIGP();
32  CElasticIGP(const std::string&,double,bool scaling=true);
33 
34  virtual void packInto(CVarMPIBuffer*) const;
35  void setSpringConst(double k){m_k=k;};
36  double getSpringConst() const{return m_k;};
37 
38  virtual std::string getTypeString() const {return "Elastic";}
39 
40  friend ostream& operator<<(ostream&,const CElasticIGP&);
41 };
42 
43 
52 {
53 public:
54 
55  typedef double (CElasticInteraction::* ScalarFieldFunction)() const;
56  typedef pair<bool,double> (CElasticInteraction::* CheckedScalarFieldFunction)() const;
58 
59  static ScalarFieldFunction getScalarFieldFunction(const string&);
61  static VectorFieldFunction getVectorFieldFunction(const string&);
62 
63 private:
64  double m_k;
67  bool m_scaling;
68 
69 public:
71 
73  virtual ~CElasticInteraction(){};
74 
75  virtual Vec3 getPos() const {return m_cpos;};
76  double getPotentialEnergy() const;
77 
78  virtual void calcForces();
79  Vec3 getForce() const;
80  friend ostream& operator<<(ostream&,const CElasticInteraction&);
81 
82  // save/load of restart parameters
83  virtual void saveRestartData(std::ostream &oStream);
84  virtual void loadRestartData(std::istream &iStream);
85 };
86 #endif //__ELASTICINTERACTION_H