OpenLB 1.7
Loading...
Searching...
No Matches
entropicLbHelpers.h
Go to the documentation of this file.
1/* This file is part of the OpenLB library
2 *
3 * Copyright (C) 2006, 2007 Jonas Latt
4 * E-mail contact: info@openlb.net
5 * The most recent release of OpenLB can be downloaded at
6 * <http://www.openlb.net/>
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public
19 * License along with this program; if not, write to the Free
20 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 * Boston, MA 02110-1301, USA.
22*/
23
28#ifndef ENTROPIC_LB_HELPERS_H
29#define ENTROPIC_LB_HELPERS_H
30
31#include "utilities/omath.h"
32
33namespace olb {
34
35template<typename T, typename DESCRIPTOR>
38 static T equilibrium( int iPop, T rho, const T u[DESCRIPTOR::d])
39 {
40 typedef DESCRIPTOR L;
41 const T invCs = util::sqrt(descriptors::invCs2<T,L>());
42 const T sqt3 = util::sqrt(3.0);
43 T prod = (T)1;
44 for (int iD=0; iD < DESCRIPTOR::d; ++iD) {
45 T uc = u[iD] * invCs; // u[iD] / c_s
46
47 prod *= ((T)2 - util::sqrt(1.0+uc*uc)) *
48 util::pow((2.0 / sqt3 * uc +
49 util::sqrt(1.0+uc*uc))/(1.0-uc/sqt3),
50 descriptors::c<L>(iPop,iD)/sqt3*invCs);
51 }
52 return rho*descriptors::t<T,L>(iPop)*prod-descriptors::t<T,L>(iPop);
53 }
54
56 static T equilibriumApprox( int iPop, T rho, const T u[DESCRIPTOR::d])
57 {
58 typedef DESCRIPTOR L;
59
60 T uSqr = util::normSqr<T,L::d>(u);
61 T cu = T();
62 for (int iD=0; iD < DESCRIPTOR::d; ++iD) {
63 cu += descriptors::c<L>(iPop,iD)*u[iD];
64 }
65
66 return rho * descriptors::t<T,L>(iPop) * (1.0 +
67 cu*descriptors::invCs2<T,L>() - 0.5 * uSqr*descriptors::invCs2<T,L>() + 0.5*util::pow(descriptors::invCs2<T,L>(),2)*cu*cu
68 - 0.5*util::pow(descriptors::invCs2<T,L>(),2)*cu*uSqr + util::pow(cu,3)*util::pow(descriptors::invCs2<T,L>(),3)/6.0
69 + 0.125*uSqr*uSqr*util::pow(descriptors::invCs2<T,L>(),2) - 0.25*cu*cu*uSqr*util::pow(descriptors::invCs2<T,L>(),3)
70 + util::pow(cu,4)*util::pow(descriptors::invCs2<T,L>(),4)/24.0)-descriptors::t<T,L>(iPop);
71 }
72};
73
74}
75
76#include "entropicLbHelpers2D.h"
77#include "entropicLbHelpers3D.h"
78
79#endif
A collection of dynamics classes (e.g.
A collection of dynamics classes (e.g.
cpu::simd::Pack< T > sqrt(cpu::simd::Pack< T > value)
Definition pack.h:100
cpu::simd::Pack< T > pow(cpu::simd::Pack< T > base, cpu::simd::Pack< T > exp)
Definition pack.h:112
Top level namespace for all of OpenLB.
static T equilibriumApprox(int iPop, T rho, const T u[DESCRIPTOR::d])
Computation of equilibrium distribution.
static T equilibrium(int iPop, T rho, const T u[DESCRIPTOR::d])
Computation of equilibrium distribution.