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

d3q13Templates.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 
00031 #ifndef D3Q13_TEMPLATES_H
00032 #define D3Q13_TEMPLATES_H
00033 
00034 #include "core/globalDefs.h"
00035 #include "latticeBoltzmann/nearestNeighborLattices3D.h"
00036 #include "core/cell.h"
00037 #include "core/util.h"
00038 
00039 
00040 namespace plb {
00041 
00043 template<typename T>
00044 struct d3q13Templates {
00045     typedef descriptors::D3Q13Descriptor<T> Descriptor;
00046 
00048     static T collision( Cell<T,descriptors::D3Q13Descriptor>& cell,
00049                         T rho, Array<T,Descriptor::d> const& u,
00050                         T lambda_nu, T lambda_nu_prime)
00051     {
00052         const T lambda_e = descriptors::D3Q13Descriptor<T>::lambda_e;
00053         const T lambda_h = descriptors::D3Q13Descriptor<T>::lambda_h;
00054 
00055         T uxSqr = u[0]*u[0];
00056         T uySqr = u[1]*u[1];
00057         T uzSqr = u[2]*u[2];
00058         T uSqr = uxSqr + uySqr + uzSqr;
00059 
00060         T s1 = cell[7] + cell[8] + cell[9] + cell[10];
00061         T s2 = cell[11] + cell[12];
00062         T s3 = cell[1] + cell[2] + cell[3] + cell[4];
00063         T s4 = cell[5] + cell[6];
00064         T sTot = s1 + s2 + s3 + s4;
00065         T d1 = cell[7] + cell[8] - cell[9] - cell[10];
00066         T d2 = cell[1] + cell[2] - cell[3] - cell[4];
00067 
00068         T M[13]; // The terms M[0]-M[3] are not used (they correspond
00069                  // to rho, rho*ux, rho*uy, rho*uz respectively),
00070                  // but we still use a 13-component vector to preserve
00071                  // the clarity of the code.
00072         M[4] = -(T)12*cell[0] + sTot - (T)11/(T)2;
00073           // The 11/2 correction term in M4 accounts for the fact that
00074           // cell[i] corresponds to f[i]-ti, and not f[i]
00075         M[5] = s1 - (T)2*s2 + s3 - (T)2*s4;
00076         M[6] = d1 + d2;
00077         M[7] = cell[7] - cell[8] + cell[1] - cell[2];
00078         M[8] = cell[11] - cell[12] + cell[5] - cell[6];
00079         M[9] = cell[9] - cell[10] + cell[3] - cell[4];
00080         M[10] = d1 - d2;
00081         M[11] = -cell[7] + cell[8] + s2 + cell[1] - cell[2] - s4;
00082         M[12] = cell[9] - cell[10] - cell[11] + cell[12]
00083                 - cell[3] + cell[4] + cell[5] - cell[6];
00084         T Mneq[13]; // The terms Mneq[0]-Mneq[3] are not used (they are
00085                     // actually all zero, because of conservation laws),
00086                     // but we still use a 13-component vector to preserve
00087                     // the clarity of the code.
00088         Mneq[4] = M[4] + (T)11/(T)2*rho - (T)13/(T)2*rho*uSqr;
00089         Mneq[5] = M[5] - rho*( (T)2*uxSqr-(uySqr+uzSqr) );
00090         Mneq[6] = M[6] - rho*( uySqr-uzSqr );
00091         Mneq[7] = M[7] - rho*( u[0]*u[1] );
00092         Mneq[8] = M[8] - rho*( u[1]*u[2] );
00093         Mneq[9] = M[9] - rho*( u[0]*u[2] );
00094         Mneq[10] = M[10];
00095         Mneq[11] = M[11];
00096         Mneq[12] = M[12];
00097 
00098         Mneq[4]  *= lambda_e  / (T)156;
00099         Mneq[5]  *= lambda_nu / (T)24;
00100         Mneq[6]  *= lambda_nu / (T)8;
00101         Mneq[7]  *= lambda_nu_prime / (T)4;
00102         Mneq[8]  *= lambda_nu_prime / (T)4;
00103         Mneq[9]  *= lambda_nu_prime / (T)4;
00104         Mneq[10] *= lambda_h / (T)8;
00105         Mneq[11] *= lambda_h / (T)8;
00106         Mneq[12] *= lambda_h / (T)8;
00107 
00108         T F1 = Mneq[4] + Mneq[5] + Mneq[6];
00109         T F2 = Mneq[4] + Mneq[5] - Mneq[6];
00110         T F3 = Mneq[4] - (T)2*Mneq[5];
00111 
00112         cell[0]  -= (T)-12*Mneq[4];
00113         cell[1]  -= F1 + Mneq[7]                -Mneq[10]+Mneq[11];
00114         cell[2]  -= F1 - Mneq[7]                -Mneq[10]-Mneq[11];
00115         cell[3]  -= F2                  +Mneq[9]+Mneq[10]         -Mneq[12];
00116         cell[4]  -= F2                  -Mneq[9]+Mneq[10]         +Mneq[12];
00117         cell[5]  -= F3          +Mneq[8]                 -Mneq[11]+Mneq[12];
00118         cell[6]  -= F3          -Mneq[8]                 -Mneq[11]-Mneq[12];
00119         cell[7]  -= F1 + Mneq[7]                +Mneq[10]-Mneq[11];
00120         cell[8]  -= F1 - Mneq[7]                +Mneq[10]+Mneq[11];
00121         cell[9]  -= F2                  +Mneq[9]-Mneq[10]         +Mneq[12];
00122         cell[10] -= F2                  -Mneq[9]-Mneq[10]         -Mneq[12];
00123         cell[11] -= F3          +Mneq[8]                 +Mneq[11]-Mneq[12];
00124         cell[12] -= F3          -Mneq[8]                 +Mneq[11]+Mneq[12];
00125 
00126         return uSqr;
00127     }
00128 
00130     static T constRhoCollision( Cell<T,descriptors::D3Q13Descriptor>& cell,
00131                                 T rho, Array<T,Descriptor::d> const& u,
00132                                 T ratioRho,
00133                                 T lambda_nu, T lambda_nu_prime)
00134     {
00135         const T uSqr = VectorTemplate<T,descriptors::D3Q13Descriptor>::normSqr(u);
00136         return uSqr;
00137     }
00138 }; // struct d3q13Templates
00139 
00140 }  // namespace plb
00141 
00142 #endif