1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182
|
/////////////////////////////////////////////////////////////
// //
// Copyright (c) 2003-2014 by The University of Queensland //
// Centre for Geoscience Computing //
// http://earth.uq.edu.au/centre-geoscience-computing //
// //
// Primary Business: Brisbane, Queensland, Australia //
// Licensed under the Open Software License version 3.0 //
// http://www.apache.org/licenses/LICENSE-2.0 //
// //
/////////////////////////////////////////////////////////////
/*
HertzianViscoElasticInteraction.cpp:
Written by Laura Heredia and Pablo Richeri, 2009.
*/
#include "HertzianViscoElasticInteraction.h"
// --- system includes ---
#include <iostream>
// --- member functions for interaction group parameter class ---
//! default constructor
CHertzianViscoElasticIGP::CHertzianViscoElasticIGP()
: AIGParam(), m_A(0.0), m_E(0.0), m_nu(0.0)
{
}
/*!
constructor with parameters
\param name the name of the interaction group
\param k the stiffness constant
*/
CHertzianViscoElasticIGP::CHertzianViscoElasticIGP(
const std::string& name,
double A,
double E,
double nu
)
: AIGParam(name), m_A(A), m_E(E), m_nu(nu)
{
}
// --- function of interaction class ---
CHertzianViscoElasticInteraction::CHertzianViscoElasticInteraction(
CParticle* p1,
CParticle* p2,
const CHertzianViscoElasticIGP& param
)
: APairInteraction(p1,p2)
{
m_A=param.m_A;
m_E=param.m_E;
m_nu=param.m_nu;
m_force=Vec3(0.0,0.0,0.0);
m_dn=0.0;
}
/*!
calculate forces
*/
void CHertzianViscoElasticInteraction::calcForces()
{
Vec3 D=m_p1->getPos()-m_p2->getPos();
double dist=D*D;
double eq_dist=m_p1->getRad()+m_p2->getRad();
//std::cerr << "d: " << dist << " / " << eq_dist*eq_dist << std::endl;
if(dist<(eq_dist*eq_dist)){
double R_ij=1.0/(1.0/m_p1->getRad()+1.0/m_p2->getRad());
dist=sqrt(dist);
m_dn=eq_dist-dist;
Vec3 dir=D.unit();
//Calculate d m_dn / dt
double ex=D.X()/dist;
double ey=D.Y()/dist;
double ez=D.Z()/dist;
double dvx=m_p1->getVel().X()-m_p2->getVel().X();
double dvy=m_p1->getVel().Y()-m_p2->getVel().Y();
double dvz=m_p1->getVel().Z()-m_p2->getVel().Z();
double m_dn_dot=-(ex*dvx+ey*dvy+ez*dvz);
double norm_m_force =
(2.0*m_E*sqrt(R_ij)) /
(3.0*(1.0-m_nu*m_nu)) *
(pow(m_dn,1.5)+m_A*sqrt(m_dn)*m_dn_dot);
m_force=norm_m_force<0?Vec3(0.0,0.0,0.0):dir*norm_m_force;
//std::cerr << "HF: " << dir << " " << R_ij << " " << m_dn << " "
// << m_force << std::endl;
Vec3 pos=m_p2->getPos()+(m_p2->getRad()/eq_dist)*D;
m_p1->applyForce(m_force,pos);
m_p2->applyForce(-1.0*m_force,pos);
} else {
m_force=Vec3(0.0,0.0,0.0);
m_dn=0.0;
}
}
/*!
"field function" returning force currently exerted by interaction
*/
Vec3 CHertzianViscoElasticInteraction::getForce() const
{
return m_force;
}
/*!
"field function" returning potential energy currently stored in interaction
*/
double CHertzianViscoElasticInteraction::getPotentialEnergy() const
{
return 0.4*m_force.norm()*m_dn;
}
/*!
Get the particle member function which returns a scalar field of a given name.
\param name the name of the field
*/
CHertzianViscoElasticInteraction::ScalarFieldFunction
CHertzianViscoElasticInteraction::getScalarFieldFunction(const string& name)
{
CHertzianViscoElasticInteraction::ScalarFieldFunction sf;
if (name=="potential_energy"){
sf=&CHertzianViscoElasticInteraction::getPotentialEnergy;
} else if (name=="count"){
sf=&CHertzianViscoElasticInteraction::Count;
} else {
sf=NULL;
std::cerr
<< "ERROR - invalid name for interaction scalar access function"
<< std::endl;
}
return sf;
}
/*!
Get the particle member function which returns a vector field of a given name.
\param name the name of the field
*/
CHertzianViscoElasticInteraction::VectorFieldFunction
CHertzianViscoElasticInteraction::getVectorFieldFunction(const string& name)
{
CHertzianViscoElasticInteraction::VectorFieldFunction vf;
if (name=="force"){
vf=&CHertzianViscoElasticInteraction::getForce;
} else {
vf=NULL;
cerr
<< "ERROR - invalid name for interaction vector access function"
<< endl;
}
return vf;
}
/*!
dummy
*/
CHertzianViscoElasticInteraction::CheckedScalarFieldFunction
CHertzianViscoElasticInteraction::getCheckedScalarFieldFunction(
const string& name
)
{
CHertzianViscoElasticInteraction::CheckedScalarFieldFunction csf;
csf=NULL;
cerr
<< "ERROR - invalid name for interaction vector access function"
<< endl;
return csf;
}
|