MechSys  1.0
Computing library for simulations in continuum and discrete mechanics
/home/dorival/mechsys/lib/sph/interacton.h
Go to the documentation of this file.
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 #ifndef MECHSYS_SPH_INTERACTON_H
00021 #define MECHSYS_SPH_INTERACTON_H
00022 
00023 // Mechsys
00024 #include <mechsys/sph/particle.h>
00025 #include <mechsys/sph/special_functions.h>
00026 #include <mechsys/dem/special_functions.h>
00027 
00028 namespace SPH {
00029 
00030 class Interacton
00031 {   
00032 public:
00033     // Constructor and destructor
00034     Interacton (SPHParticle * Pt1, SPHParticle * Pt2); 
00035 
00036     // Methods
00037     bool UpdateContacts (double alpha);          
00038     void CalcForce      (double dt = 0.0);       
00039     
00040 
00041     // Data
00042     SPHParticle * P1;                            
00043     SPHParticle * P2;                            
00044     double alpha;                                
00045     double beta;                                 
00046     double h;                                    
00047 };
00048 
00050 
00051 inline Interacton::Interacton (SPHParticle * Pt1, SPHParticle * Pt2)
00052 {
00053     P1 = Pt1;
00054     P2 = Pt2;
00055     h  = 2*ReducedValue(P1->h,P2->h);
00056     alpha = 0.25;
00057     beta = 0.25;
00058 }
00059 
00060 inline void Interacton::CalcForce(double dt)
00061 {
00062     double di = P1->Density;
00063     double dj = P2->Density;
00064     double d0i = P1->Density0;
00065     double d0j = P2->Density0;
00066     Vec3_t vij = P2->v - P1->v;
00067     Vec3_t rij = P2->x - P1->x;
00068     double muij = h*dot(vij,rij)/(dot(rij,rij)+0.01*h*h);
00069     double cij = (SoundSpeed(di)+SoundSpeed(dj));
00070     double piij;
00071     if (dot(vij,rij)<0) piij = (-alpha*cij*muij+beta*muij*muij)/(di+dj);
00072     else                piij = 0.0;
00073     //piij = -alpha*muij*cij/(di+dj);
00074     P1->a += d0j*(Pressure(di)/(di*di)+Pressure(dj)/(dj*dj)+piij)*rij*GradSPHKernel(norm(rij),h)/norm(rij);
00075     P2->a -= d0i*(Pressure(di)/(di*di)+Pressure(dj)/(dj*dj)+piij)*rij*GradSPHKernel(norm(rij),h)/norm(rij);
00076     P1->dDensity += d0j*dot(vij,rij)*GradSPHKernel(norm(rij),h)/norm(rij);
00077     P2->dDensity += d0i*dot(vij,rij)*GradSPHKernel(norm(rij),h)/norm(rij);
00078 }
00079 
00080 inline bool Interacton::UpdateContacts (double alpha)
00081 {
00082     if (Distance(P1->x,P2->x)<=P1->h+P2->h+2*alpha) return true;
00083     else return false;
00084 }
00085 
00086 }; // namespace SPH
00087 
00088 #endif // MECHSYS_SPH_INTERACTON_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines