MechSys  1.0
Computing library for simulations in continuum and discrete mechanics
/home/dorival/mechsys/lib/sph/special_functions.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_SPECIAL_H
00021 #define MECHSYS_SPH_SPECIAL_H
00022 
00023 // Std lib
00024 #include <iostream>
00025 
00026 // MechSys
00027 #include <mechsys/linalg/matvec.h>
00028 
00029 namespace SPH {
00030 
00031 inline double Kernel(double r,double h)
00032 {
00033     double C = 1.0/(h*h*h*M_PI);
00034     double q = r/h;
00035     if ((q>=0.0)&&(q<1)) return C*(1-(3.0/2.0)*q*q+(3.0/4.0)*q*q*q);
00036     else if (q<=2)       return C*((1.0/4.0)*(2-q)*(2-q)*(2-q));
00037     else                 return 0.0;
00038 }
00039 
00040 inline double GradKernel(double r, double h)
00041 {
00042     double C = 1.0/(h*h*h*M_PI);
00043     double q = r/h;
00044     if ((q>=0.0)&&(q<1)) return C*(1-3.0*q+(9.0/4.0)*q*q);
00045     else if (q<=2)       return C*(-(3.0/4.0)*(2-q)*(2-q));
00046     else                 return 0.0;
00047 }
00048 
00049 inline double Kernel(Vec3_t & x, Vec3_t & xp, double h)
00050 {
00051     double r = norm(xp-x);
00052     return Kernel(r,h);
00053 }
00054 
00055 inline double Pressure(double rho)
00056 {
00057     double P0 = 10.0;
00058     double rho0 = 10.0;
00059     return P0*(pow(rho/rho0,7)-1);
00060 }
00061 
00062 inline double SoundSpeed(double rho)
00063 {
00064     double P0 = 10.0;
00065     double rho0 = 10.0;
00066     return sqrt(7*P0*(pow(rho/rho0,6)/rho0));
00067 }
00068 
00069 }; // namespace SPH
00070 
00071 #endif // MECHSYS_SPH_SPECIAL_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines