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 #ifndef __BONDEDINTERACTION_H 00014 #define __BONDEDINTERACTION_H 00015 00016 // -- project includes -- 00017 #include "Model/IGParam.h" // keep this one first - it drags in mpi.h 00018 #include "Model/Interaction.h" 00019 #include "Model/Particle.h" 00020 #include "Model/BondedInteractionCpData.h" 00021 #include "Foundation/vec3.h" 00022 00023 // -- I/O includes -- 00024 #include <iostream> 00025 using std::ostream; 00026 00027 // -- STL includes -- 00028 #include <utility> 00029 00030 using std::pair; 00031 00039 class CBondedIGP : public AIGParam 00040 { 00041 public: 00042 CBondedIGP(); 00043 00044 CBondedIGP(const std::string &name, int tag, double normalK, double breakDistance, bool scaling=true); 00045 00046 virtual std::string getTypeString() const 00047 { 00048 return "Bonded"; 00049 } 00050 00051 double k; 00052 double rbreak; 00053 int tag; 00054 bool m_scaling; 00055 }; 00056 00064 class CBondedInteraction : public APairInteraction 00065 { 00066 public: // types 00067 typedef CBondedIGP ParameterType; 00071 typedef BondedInteractionCpData CheckPointable; 00072 00073 typedef double (CBondedInteraction::* ScalarFieldFunction)() const; 00074 typedef pair<bool,double> (CBondedInteraction::* CheckedScalarFieldFunction)() const; 00075 typedef Vec3 (CBondedInteraction::* VectorFieldFunction)() const; 00076 00077 protected: 00078 double m_k; 00079 double m_r0; 00080 double m_dist; 00081 double m_break; 00082 Vec3 m_force; 00083 Vec3 m_cpos; 00084 int m_tag; 00085 bool m_scaling; 00086 00087 CBondedInteraction(CParticle*,CParticle*); 00088 00089 public: 00090 CBondedInteraction(); 00091 CBondedInteraction( 00092 CParticle *particle1, 00093 CParticle *particle2, 00094 const CBondedIGP ¶ms 00095 ); 00096 00097 virtual ~CBondedInteraction(); 00098 00099 static ScalarFieldFunction getScalarFieldFunction(const string&); 00100 static CheckedScalarFieldFunction getCheckedScalarFieldFunction(const string&); 00101 static VectorFieldFunction getVectorFieldFunction(const string&); 00102 00103 static string getType() {return "Bonded";}; 00104 00105 virtual void calcForces(); 00106 void setBreak(double); 00107 bool broken(); 00108 00109 inline int getTag() const {return m_tag;} 00110 inline void setTag(int tag) {m_tag = tag;} 00111 00112 double getCriterion() const; 00113 double getPotentialEnergy() const; 00114 double getStrain() const; 00115 Vec3 getForce() const; 00116 00117 virtual Vec3 getPos() const {return m_cpos;}; 00118 virtual void saveCheckPointData(std::ostream &oStream); 00119 00120 friend ostream& operator<<(ostream&,const CBondedInteraction&); 00121 friend class TML_PackedMessageInterface; 00122 00123 // save/load of restart parameters 00124 virtual void saveRestartData(std::ostream &oStream); 00125 virtual void loadRestartData(std::istream &iStream); 00126 }; 00127 00128 #endif //__BONDEDINTERACTION_H