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

latticeTemplates.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 LATTICE_TEMPLATES_H
00032 #define LATTICE_TEMPLATES_H
00033 
00034 #include "core/globalDefs.h"
00035 #include "core/cell.h"
00036 #include "core/util.h"
00037 
00038 namespace plb {
00039 
00041 template<typename T, template<typename U> class Descriptor>
00042 struct latticeTemplates {
00043 
00045 static void swapAndStream2D(Cell<T,Descriptor> **grid, plint iX, plint iY)
00046 {
00047     const plint half = Descriptor<T>::q/2;
00048     for (plint iPop=1; iPop<=half; ++iPop) {
00049         plint nextX = iX + Descriptor<T>::c[iPop][0];
00050         plint nextY = iY + Descriptor<T>::c[iPop][1];
00051         T fTmp                   = grid[iX][iY][iPop];
00052         grid[iX][iY][iPop]       = grid[iX][iY][iPop+half];
00053         grid[iX][iY][iPop+half]  = grid[nextX][nextY][iPop];
00054         grid[nextX][nextY][iPop] = fTmp;
00055      }
00056 }
00057 
00059 static void swapAndStream3D(Cell<T,Descriptor> ***grid,
00060                             plint iX, plint iY, plint iZ)
00061 {
00062     const plint half = Descriptor<T>::q/2;
00063     for (plint iPop=1; iPop<=half; ++iPop) {
00064         plint nextX = iX + Descriptor<T>::c[iPop][0];
00065         plint nextY = iY + Descriptor<T>::c[iPop][1];
00066         plint nextZ = iZ + Descriptor<T>::c[iPop][2];
00067         T fTmp                          = grid[iX][iY][iZ][iPop];
00068         grid[iX][iY][iZ][iPop]          = grid[iX][iY][iZ][iPop+half];
00069         grid[iX][iY][iZ][iPop+half]     = grid[nextX][nextY][nextZ][iPop];
00070         grid[nextX][nextY][nextZ][iPop] = fTmp;
00071      }
00072 }
00073 
00074 
00075 };
00076 
00077 }  // namespace plb
00078 
00079 #include "latticeBoltzmann/latticeTemplates2D.h"
00080 #include "latticeBoltzmann/latticeTemplates3D.h"
00081 
00082 #endif