![]() |
MechSys
1.0
Computing library for simulations in continuum and discrete mechanics
|
00001 /************************************************************************ 00002 * MechSys - Open Library for Mechanical Systems * 00003 * Copyright (C) 2005 Dorival M. Pedroso, Raul Durand * 00004 * Copyright (C) 2009 Sergio Galindo * 00005 * * 00006 * This program is free software: you can redistribute it and/or modify * 00007 * it under the terms of the GNU General Public License as published by * 00008 * the Free Software Foundation, either version 3 of the License, or * 00009 * any later version. * 00010 * * 00011 * This program is distributed in the hope that it will be useful, * 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00014 * GNU General Public License for more details. * 00015 * * 00016 * You should have received a copy of the GNU General Public License * 00017 * along with this program. If not, see <http://www.gnu.org/licenses/> * 00018 ************************************************************************/ 00019 00020 00021 #ifndef MECHSYS_LBM_INTERACTON_H 00022 #define MECHSYS_LBM_INTERACTON_H 00023 00024 // Mechsys 00025 #include <mechsys/lbm/Dem.h> 00026 #include <mechsys/dem/basic_functions.h> 00027 namespace LBM 00028 { 00029 class Interacton 00030 { 00031 public: 00032 //Constructor 00033 Interacton () {}; 00034 Interacton(Particle * D1, Particle * D2); 00035 00036 //Methods 00037 void CalcForce (double dt); 00038 bool UpdateContacts (double Alpha); 00039 00040 //Data 00041 Particle * D1; 00042 Particle * D2; 00043 double Kn; 00044 double Gn; 00045 }; 00046 00047 Interacton::Interacton(Particle * Dp1, Particle * Dp2) 00048 { 00049 D1 = Dp1; 00050 D2 = Dp2; 00051 Kn = 2.0*ReducedValue(D1->Kn,D2->Kn); 00052 Gn = 2.0*ReducedValue(D1->Gn,D2->Gn)*ReducedValue(D1->M,D2->M); 00053 } 00054 00055 void Interacton::CalcForce(double dt) 00056 { 00057 double dist = norm(D2->X - D1->X); 00058 double delta = D1->R + D2->R - dist; 00059 //std::cout << delta << std::endl; 00060 if (delta>0) 00061 { 00062 Vec3_t n = (D2->X - D1->X)/dist; 00063 Vec3_t Vrel = D1->V - D2->V; 00064 Vec3_t F = (Kn*delta + Gn*dot(n,Vrel))*n; 00065 D1->F -= Kn*delta*n; 00066 D2->F += Kn*delta*n; 00067 } 00068 } 00069 00070 bool Interacton::UpdateContacts(double Alpha) 00071 { 00072 if (norm(D1->X-D2->X) <= D1->R + D2->R + 2*Alpha) return true; 00073 else return false; 00074 } 00075 } 00076 #endif