ESyS-Particle  4.0.1
RotBondedInteraction.h
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 __ROTBONDEDINTERACTION_H
00014 #define __ROTBONDEDINTERACTION_H
00015 
00016 // -- project includes --
00017 #include "Model/RotPairInteraction.h"
00018 #include "Model/RotParticle.h"
00019 #include "Model/BondedInteractionCpData.h"
00020 #include "Model/IGParam.h"
00021 #include "Foundation/vec3.h"
00022 
00023 // -- I/O includes --
00024 #include <iostream>
00025 using std::ostream;
00026 
00035  double calc_angle( double , double ) ;
00036 
00037 class CRotBondedIGP : public AIGParam
00038 {
00039 public:
00040   CRotBondedIGP();
00041   CRotBondedIGP(
00042     const  std::string &name,
00043     double kr,
00044     double ks,
00045     double kt,
00046     double kb,
00047     double max_nForce,
00048     double max_shForce,
00049     double max_tMoment,
00050     double max_bMoment,
00051     int    tag,
00052     bool   scaling
00053   );
00054 
00055   CRotBondedIGP(
00056     const  std::string &name,
00057     double youngsModulus,
00058     double poissonsRatio,
00059     double cohesion,
00060     double tanAngle,
00061     int    tag
00062   );
00063 
00064   virtual std::string getTypeString() const
00065   {
00066     return "RotBonded";
00067   }
00068   
00069   double kr,ks,kt,kb ;
00070   double max_nForce, max_shForce,max_tMoment, max_bMoment;
00071   int    tag;
00072   bool   scaling;
00073 };
00074 
00082 class CRotBondedInteraction : public ARotPairInteraction
00083 {
00084  public: // types
00085   typedef CRotBondedIGP ParameterType;
00086 
00090   typedef BondedInteractionCpData CheckPointable;
00091 
00092   typedef double (CRotBondedInteraction::* ScalarFieldFunction)() const; 
00093   typedef pair<bool,double> (CRotBondedInteraction::* CheckedScalarFieldFunction)() const;
00094   typedef Vec3 (CRotBondedInteraction::* VectorFieldFunction)() const; 
00095 
00096  private:
00097 
00098   //   protected:
00099   double m_dist;  
00100 
00101   double m_kr ;     
00102   double m_ks ;
00103   double m_kb ;
00104   double m_kt ;
00105 
00106   double m_max_nForce;   // always >0
00107   double m_max_shForce ;
00108   double m_max_tMoment ;
00109   double m_max_bMoment ;
00110 
00111   double m_nForce;  //  >0, pulling; <0 , compressing
00112   double m_shForce ; // always >0
00113   double m_tMoment ;
00114   double m_bMoment ;
00115 
00116   Vec3 m_force;   
00117   Vec3 m_moment ;
00118 
00119   Vec3 m_cpos; // ?
00120   Vec3 m_D; 
00121   int  m_tag;
00122   bool m_scaling;
00123 
00124  public:
00125 
00126   CRotBondedInteraction();
00127   CRotBondedInteraction(CRotParticle*,CRotParticle*,const CRotBondedIGP&);
00128   virtual ~CRotBondedInteraction();
00129                                                                                 
00130   static ScalarFieldFunction getScalarFieldFunction(const string&);
00131   static CheckedScalarFieldFunction getCheckedScalarFieldFunction(const string&);
00132   static VectorFieldFunction getVectorFieldFunction(const string&);
00133 
00134   static string getType(){return "RotBonded";};
00135 
00136   int getTag() const;
00137   void setTag(int tag);
00138 
00139   void calcForces();
00140   //void setBreak(double);
00141   bool broken();
00142 
00143   double getPotentialEnergy() const;
00144   double getNormalPotentialEnergy() const;
00145   double getShearPotentialEnergy() const;
00146   double getTwistPotentialEnergy() const;
00147   double getBendPotentialEnergy() const;
00148   double getCriterion() const;
00149   Vec3   getForce() const;
00150   virtual Vec3 getPos() const {return m_cpos;};
00151 
00152   Vec3 getCentrePtDiff() const;
00153   Vec3 getInitialCentrePtDiff() const;
00154   Vec3 getInitialMidPoint() const;
00155 
00156   Vec3 getP2ShearForcePt() const;
00157   Vec3 getP1ShearForcePt() const;
00158   Vec3 getContactPoint() const;
00159 
00160   Vec3 getShearDiff() const;
00161 
00162   friend ostream& operator<<(ostream&,const CRotBondedInteraction&);
00163   friend class TML_PackedMessageInterface;
00164   
00165   virtual void saveCheckPointData(std::ostream &oStream);
00166 
00167   virtual void loadCheckPointData(std::istream &iStream);
00168 
00169   // save/load of restart parameters
00170   virtual void saveRestartData(std::ostream &oStream);
00171   virtual void loadRestartData(std::istream &iStream);
00172 };
00173 
00174 #endif //__BONDEDINTERACTION_H