/usr/include/palabos/latticeBoltzmann/advectionDiffusionDynamicsTemplates3D.h is in libplb-dev 1.5~r1+repack1-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 | /* This file is part of the Palabos library.
*
* Copyright (C) 2011-2015 FlowKit Sarl
* Route d'Oron 2
* 1010 Lausanne, Switzerland
* E-mail contact: contact@flowkit.com
*
* The most recent release of Palabos can be downloaded at
* <http://www.palabos.org/>
*
* The library Palabos is free software: you can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* The library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/* Main author: Orestis Malaspinas
*/
/** \file
* Helper functions for the implementation of LB dynamics. This file is all
* about efficiency. The generic template code is specialized for commonly
* used Lattices, so that a maximum performance can be taken out of each
* case.
*/
#ifndef ADVECTION_DIFFUSION_DYNAMICS_TEMPLATES_3D_H
#define ADVECTION_DIFFUSION_DYNAMICS_TEMPLATES_3D_H
namespace plb {
/// All helper functions are inside this structure
template<typename T> struct advectionDiffusionDynamicsTemplatesImpl<T,descriptors::D3Q7DescriptorBase<T> >
{
typedef descriptors::D3Q7DescriptorBase<T> Descriptor;
static T bgk_ma1_equilibrium(plint iPop, T rhoBar, Array<T,Descriptor::d> const& jEq)
{
return Descriptor::t[iPop] * (rhoBar + Descriptor::invCs2 *
(Descriptor::c[iPop][0]*jEq[0]+Descriptor::c[iPop][1]*jEq[1]+Descriptor::c[iPop][2]*jEq[2]));
}
/// Regularization
static void regularize( Array<T,Descriptor::q>& f, T rhoBar,
Array<T,Descriptor::d> const& jAdvDiff,
Array<T,Descriptor::d> const& jEq )
{
f[0] = Descriptor::t[0] * rhoBar;
f[1] = Descriptor::t[1] * (rhoBar - Descriptor::invCs2*jAdvDiff[0]);
f[2] = Descriptor::t[2] * (rhoBar - Descriptor::invCs2*jAdvDiff[1]);
f[3] = Descriptor::t[3] * (rhoBar - Descriptor::invCs2*jAdvDiff[2]);
f[4] = Descriptor::t[4] * (rhoBar + Descriptor::invCs2*jAdvDiff[0]);
f[5] = Descriptor::t[5] * (rhoBar + Descriptor::invCs2*jAdvDiff[1]);
f[6] = Descriptor::t[6] * (rhoBar + Descriptor::invCs2*jAdvDiff[2]);
}
static T no_corr_bgk_collision(
Array<T,Descriptor::q>& f, T rhoBar, Array<T,Descriptor::d> const& jEq,
T omega)
{
T invRho = Descriptor::invRho(rhoBar);
const T jSqr = jEq[0]*jEq[0] + jEq[1]*jEq[1] + jEq[2]*jEq[2];
const T oneMinusOmega = (T)1 - omega;
const T halfOmega = (T)0.5 * omega;
const T cs2RhoBar = Descriptor::cs2*rhoBar;
f[0] = oneMinusOmega*f[0]+omega*((T)1-(T)3*Descriptor::cs2)*rhoBar;
f[1] = oneMinusOmega*f[1]+halfOmega*(cs2RhoBar-jEq[0]);
f[2] = oneMinusOmega*f[2]+halfOmega*(cs2RhoBar-jEq[1]);
f[3] = oneMinusOmega*f[3]+halfOmega*(cs2RhoBar-jEq[2]);
f[4] = oneMinusOmega*f[4]+halfOmega*(cs2RhoBar+jEq[0]);
f[5] = oneMinusOmega*f[5]+halfOmega*(cs2RhoBar+jEq[1]);
f[6] = oneMinusOmega*f[6]+halfOmega*(cs2RhoBar+jEq[2]);
return jSqr*invRho*invRho;
}
static T no_corr_bgk_collision(
Array<T,Descriptor::q>& f, T rhoBar, Array<T,Descriptor::d> const& jEq,
T omega, T source)
{
T invRho = Descriptor::invRho(rhoBar);
const T jSqr = jEq[0]*jEq[0] + jEq[1]*jEq[1] + jEq[2]*jEq[2];
const T oneMinusOmega = (T)1 - omega;
const T halfOmega = (T)0.5 * omega;
const T cs2RhoBar = Descriptor::cs2*rhoBar;
const T halfSourceCs2 = (T)0.5*source * Descriptor::cs2;
f[0] = oneMinusOmega*f[0]+((T)1-(T)3*Descriptor::cs2)*(omega*rhoBar+source);
f[1] = oneMinusOmega*f[1]+halfOmega*(cs2RhoBar-jEq[0]) + halfSourceCs2;
f[2] = oneMinusOmega*f[2]+halfOmega*(cs2RhoBar-jEq[1]) + halfSourceCs2;
f[3] = oneMinusOmega*f[3]+halfOmega*(cs2RhoBar-jEq[2]) + halfSourceCs2;
f[4] = oneMinusOmega*f[4]+halfOmega*(cs2RhoBar+jEq[0]) + halfSourceCs2;
f[5] = oneMinusOmega*f[5]+halfOmega*(cs2RhoBar+jEq[1]) + halfSourceCs2;
f[6] = oneMinusOmega*f[6]+halfOmega*(cs2RhoBar+jEq[2]) + halfSourceCs2;
return jSqr*invRho*invRho;
}
static T no_corr_rlb_collision (
Array<T,Descriptor::q>& f, T rhoBar, Array<T,Descriptor::d> const& jEq,
Array<T,Descriptor::d> const& jNeq,T omega )
{
T invRho = Descriptor::invRho(rhoBar);
const T jSqr = jEq[0]*jEq[0] + jEq[1]*jEq[1] + jEq[2]*jEq[2];
const T oneHalfMinusHalfOmega = (T)0.5-(T)0.5*omega;
const T cs2RhoBar = Descriptor::cs2 * rhoBar;
const T jNeqTerm_0 = oneHalfMinusHalfOmega*jNeq[0];
const T jNeqTerm_1 = oneHalfMinusHalfOmega*jNeq[1];
const T jNeqTerm_2 = oneHalfMinusHalfOmega*jNeq[2];
f[0] = ((T)1-(T)3*Descriptor::cs2)*rhoBar;
f[1] = -jNeqTerm_0 + (T)0.5*(cs2RhoBar-jEq[0]);
f[2] = -jNeqTerm_1 + (T)0.5*(cs2RhoBar-jEq[1]);
f[3] = -jNeqTerm_2 + (T)0.5*(cs2RhoBar-jEq[2]);
f[4] = -f[1] + cs2RhoBar;
f[5] = -f[2] + cs2RhoBar;
f[6] = -f[3] + cs2RhoBar;
return jSqr*invRho*invRho;
}
static T no_corr_rlb_collision (
Array<T,Descriptor::q>& f, T rhoBar, Array<T,Descriptor::d> const& jEq,
Array<T,Descriptor::d> const& jNeq, T omega, T source )
{
T invRho = Descriptor::invRho(rhoBar);
const T jSqr = jEq[0]*jEq[0] + jEq[1]*jEq[1] + jEq[2]*jEq[2];
const T oneHalfMinusHalfOmega = (T)0.5-(T)0.5*omega;
const T cs2RhoBar = Descriptor::cs2 * rhoBar;
const T halfSourceCs2 = (T)0.5*source * Descriptor::cs2;
const T jNeqTerm_0 = oneHalfMinusHalfOmega*jNeq[0];
const T jNeqTerm_1 = oneHalfMinusHalfOmega*jNeq[1];
const T jNeqTerm_2 = oneHalfMinusHalfOmega*jNeq[2];
f[0] = ((T)1-(T)3*Descriptor::cs2)*(rhoBar+source);
f[1] = -jNeqTerm_0 + (T)0.5*(cs2RhoBar-jEq[0]);
f[2] = -jNeqTerm_1 + (T)0.5*(cs2RhoBar-jEq[1]);
f[3] = -jNeqTerm_2 + (T)0.5*(cs2RhoBar-jEq[2]);
f[4] = -f[1] + cs2RhoBar;
f[5] = -f[2] + cs2RhoBar;
f[6] = -f[3] + cs2RhoBar;
f[1] += halfSourceCs2;
f[2] += halfSourceCs2;
f[3] += halfSourceCs2;
f[4] += halfSourceCs2;
f[5] += halfSourceCs2;
f[6] += halfSourceCs2;
return jSqr*invRho*invRho;
}
}; // struct advectionDiffusionDynamicsTemplatesImpl
} // namespace plb
#endif
|