$treeview $search $mathjax
Palabos  Version 1.1
$projectbrief
$projectbrief
$searchbox

entropicLbTemplates.h

Go to the documentation of this file.
00001 /* This file is part of the Palabos library.
00002  *
00003  * Copyright (C) 2011 FlowKit Sarl
00004  * Avenue de Chailly 23
00005  * 1012 Lausanne, Switzerland
00006  * E-mail contact: contact@flowkit.com
00007  *
00008  * The most recent release of Palabos can be downloaded at 
00009  * <http://www.palabos.org/>
00010  *
00011  * The library Palabos is free software: you can redistribute it and/or
00012  * modify it under the terms of the GNU Affero General Public License as
00013  * published by the Free Software Foundation, either version 3 of the
00014  * License, or (at your option) any later version.
00015  *
00016  * The library is distributed in the hope that it will be useful,
00017  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019  * GNU Affero General Public License for more details.
00020  *
00021  * You should have received a copy of the GNU Affero General Public License
00022  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
00023 */
00024 
00025 /* Orestis Malaspinas contributed this code.
00026  */
00027 
00032 #ifndef ENTROPIC_LB_HELPERS_H
00033 #define ENTROPIC_LB_HELPERS_H
00034 
00035 #include "core/globalDefs.h"
00036 #include "latticeBoltzmann/geometricOperationTemplates.h"
00037 #include <cmath>
00038 
00039 namespace plb {
00040 
00041 template<typename T, template<typename U> class Descriptor>
00042 struct entropicLbTemplates 
00043 {
00045     static T equilibrium( plint iPop, T rho, Array<T,Descriptor<T>::d> const& u)
00046     {
00047         typedef Descriptor<T> L;
00048         const T invCs = sqrt(L::invCs2);
00049         const T sqt3 = sqrt(3.0);
00050         T prod = (T)1;
00051         for (int iD=0; iD < Descriptor<T>::d; ++iD)
00052         {
00053             T uc = u[iD] * invCs; // u[iD] / c_s
00054 
00055             prod *= ((T)2 - sqrt(1.0+uc*uc)) * 
00056                     pow((2.0 / sqt3 * uc + 
00057                     sqrt(1.0+uc*uc))/(1.0-uc/sqt3),
00058                         L::c[iPop][iD]/sqt3*invCs);
00059         }
00060         return rho*L::t[iPop]*prod-L::SkordosFactor()*L::t[iPop];
00061     }
00062     
00064     static T equilibriumApprox( plint iPop, T rho, Array<T,Descriptor<T>::d> const& u)
00065     {
00066         typedef Descriptor<T> L;
00067 
00068         T uSqr = VectorTemplate<T,Descriptor>::normSqr(u);
00069         T cu = T();
00070         for (int iD=0; iD < Descriptor<T>::d; ++iD)
00071         {
00072             cu += L::c[iPop][iD]*u[iD];
00073         }
00074         
00075         return rho * L::t[iPop] * (1.0 +
00076                 cu*L::invCs2 - 0.5 * uSqr*L::invCs2 + 0.5*pow(L::invCs2,2)*cu*cu
00077                 - 0.5*pow(L::invCs2,2)*cu*uSqr + pow(cu,3)*pow(L::invCs2,3)/6.0
00078                 + 0.125*uSqr*uSqr*pow(L::invCs2,2) - 0.25*cu*cu*uSqr*pow(L::invCs2,3)
00079                 + pow(cu,4)*pow(L::invCs2,4)/24.0)-L::SkordosFactor()*L::t[iPop];
00080     }
00081 };
00082 
00083 }
00084 
00085 #include "latticeBoltzmann/entropicLbTemplates2D.h"
00086 #include "latticeBoltzmann/entropicLbTemplates3D.h"
00087 
00088 #endif