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

boundaryTemplates.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 
00029 #ifndef BOUNDARY_TEMPLATES_H
00030 #define BOUNDARY_TEMPLATES_H
00031 
00032 #include "boundaryCondition/regularizedBoundaryDynamics.h"
00033 #include "core/cell.h"
00034 #include "latticeBoltzmann/indexTemplates.h"
00035 
00036 namespace plb {
00037 
00038 template<typename T, template<typename U> class Descriptor, int direction, int orientation>
00039 struct boundaryTemplates {
00040     static void compute_PiNeq (
00041          Dynamics<T,Descriptor> const& dynamics,
00042          Cell<T,Descriptor> const& cell, T rhoBar, Array<T,Descriptor<T>::d> const& j, T jSqr,
00043          Array<T,SymmetricTensor<T,Descriptor>::n>& PiNeq )
00044     {
00045         typedef Descriptor<T> L;
00046 
00047         std::vector<plint> const& onWallIndices = indexTemplates::subIndex<L, direction, 0>();
00048         std::vector<plint> const& normalIndices = indexTemplates::subIndex<L, direction, orientation>();
00049 
00050         // Compute off-equilibrium for known particle populations.
00051         Array<T,Descriptor<T>::q> fNeq;
00052         for (pluint fIndex=0; fIndex<onWallIndices.size(); ++fIndex) {
00053             plint iPop = onWallIndices[fIndex];
00054             fNeq[iPop] = cell[iPop] - dynamics.computeEquilibrium(iPop, rhoBar, j, jSqr);
00055         }
00056         for (pluint fIndex=0; fIndex<normalIndices.size(); ++fIndex) {
00057             plint iPop = normalIndices[fIndex];
00058             if (iPop == 0) {
00059                 fNeq[iPop] = T();  // fNeq[0] will not be used anyway
00060             }
00061             else {
00062                 fNeq[iPop] = cell[iPop] - dynamics.computeEquilibrium(iPop, rhoBar, j, jSqr);
00063             }
00064         }
00065 
00066         // Compute PiNeq from fNeq, by using "bounce-back of off-equilibrium part" rule.
00067         int iPi = 0;
00068         for (int iAlpha=0; iAlpha<L::d; ++iAlpha) {
00069             for (int iBeta=iAlpha; iBeta<L::d; ++iBeta) {
00070                 PiNeq[iPi] = T();
00071                 for (pluint fIndex=0; fIndex<onWallIndices.size(); ++fIndex)
00072                 {
00073                     const plint iPop = onWallIndices[fIndex];
00074                     PiNeq[iPi] += L::c[iPop][iAlpha]*L::c[iPop][iBeta]*fNeq[iPop];
00075                 }
00076                 for (pluint fIndex=0; fIndex<normalIndices.size(); ++fIndex)
00077                 {
00078                     const plint iPop = normalIndices[fIndex];
00079                     PiNeq[iPi] += (T)2 * L::c[iPop][iAlpha]*L::c[iPop][iBeta]* fNeq[iPop];
00080                 }
00081                 ++iPi;
00082             }
00083         }
00084     }
00085 
00086 };  // struct boundaryTemplates
00087 
00088 }  // namespace plb
00089 
00090 #endif  // BOUNDARY_TEMPLATES_H