ESyS-Particle  2.3.4
ESphereBodyInteraction.hpp
Go to the documentation of this file.
1 // //
3 // Copyright (c) 2003-2017 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.apache.org/licenses/LICENSE-2.0 //
10 // //
12 
13 
14 #ifndef MODEL_ESPHEREBODYINTERACTION_HPP
15 #define MODEL_ESPHEREBODYINTERACTION_HPP
16 
25 template <class T>
27  ASphereBodyInteraction<T>(p,w,iflag)
28 {
29  double f=1.0;
30  // scale elastic param
32  f*=3.141592654*this->m_p->getRad();
33  }
34  m_k=f*k;
35 }
36 
40 template <class T>
42 {
43 
44  Vec3 pvec=this->m_p->getPos()-this->m_sphere->getCentre();
45  Vec3 normalVec=pvec.unit();
46  double dist=pvec.norm() - this->m_sphere->getRadius();
47 
48  if(dist<this->m_p->getRad()){
49  Vec3 force=m_k*(this->m_p->getRad()-dist)*normalVec;
50  Vec3 pos=this->m_p->getPos()-dist*normalVec;
51 
52  this->m_p->applyForce(force,pos);
53  if(this->m_inner_flag) this->m_sphere->addForce(-1.0*force);
54  }
55 }
56 
60 template <class T>
62 {
63  Vec3 force=Vec3(0.0,0.0,0.0);
64  Vec3 pvec=this->m_p->getPos()-this->m_sphere->getCentre();
65  Vec3 normalVec=pvec.unit();
66  double dist=pvec.norm() - this->m_sphere->getRadius();
67 
68  if(dist<this->m_p->getRad()){
69  force=m_k*(this->m_p->getRad()-dist)*normalVec;
70  }
71 
72  return -1.0*force;
73 }
74 
79 template <class T>
81 {
82  double res=0.0;
83  Vec3 pvec=this->m_p->getPos()-this->m_sphere->getCentre();
84  double dist=pvec.norm() - this->m_sphere->getRadius();
85  if(dist<this->m_p->getRad()){
86  res=m_k;
87  }
88 
89  return res;
90 }
91 
92 #endif
CElasticSphereBodyInteraction::getForce
virtual Vec3 getForce()
Definition: ESphereBodyInteraction.hpp:61
Vec3::unit
VEC3_INLINE Vec3 unit() const
Definition: vec3.hpp:225
CElasticSphereBodyInteraction::m_k
double m_k
spring constant
Definition: ESphereBodyInteraction.h:33
CElasticSphereBodyInteraction::getStiffness
virtual double getStiffness()
Definition: ESphereBodyInteraction.hpp:80
Vec3::norm
VEC3_INLINE double norm() const
Definition: vec3.hpp:211
CSphereBody
base class for spherical non-inertial bodies (similar to simple walls)
Definition: SphereBody.h:40
ASphereBodyInteraction
Abstract base for all interactions between a particle and a sphere body.
Definition: SphereBodyInteraction.h:30
CElasticSphereBodyInteraction::CElasticSphereBodyInteraction
CElasticSphereBodyInteraction()
Vec3
Definition: vec3.h:47
CParticle::getDo2dCalculations
static bool getDo2dCalculations()
Definition: Particle.h:181
ASphereBodyInteraction::m_p
T * m_p
Definition: SphereBodyInteraction.h:32
CElasticSphereBodyInteraction::calcForces
virtual void calcForces()
Definition: ESphereBodyInteraction.hpp:41