OpenLB 1.7
Loading...
Searching...
No Matches
helper.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
24#ifndef BOUNDARY_HELPER_H
25#define BOUNDARY_HELPER_H
26
27#include "core/cell.h"
28#include "core/util.h"
29
30namespace olb {
31
33template<typename T, typename DESCRIPTOR, int direction, int orientation>
35 template <typename CELL>
36 static void computeStress(
37 CELL& cell, T rho, const T u[DESCRIPTOR::d],
39 {
40 const T uSqr = util::normSqr<T,DESCRIPTOR::d>(u);
41
42 constexpr auto onWallIndices = util::populationsContributingToVelocity<DESCRIPTOR,direction,0>();
43 constexpr auto normalIndices = util::populationsContributingToVelocity<DESCRIPTOR,direction,orientation>();
44
45 T fNeq[DESCRIPTOR::q];
46 for (unsigned fIndex=0; fIndex<onWallIndices.size(); ++fIndex) {
47 int iPop = onWallIndices[fIndex];
48 if (iPop == 0) {
49 fNeq[0] = T(); // fNeq[0] will not be used anyway
50 }
51 else {
52 fNeq[iPop] =
53 cell[iPop] -
54 equilibrium<DESCRIPTOR>::secondOrder(iPop, rho, u, uSqr);
55 }
56 }
57 for (unsigned fIndex=0; fIndex<normalIndices.size(); ++fIndex) {
58 int iPop = normalIndices[fIndex];
59 fNeq[iPop] =
60 cell[iPop] -
61 equilibrium<DESCRIPTOR>::secondOrder(iPop, rho, u, uSqr);
62 }
63
64 int iPi = 0;
65 for (int iAlpha=0; iAlpha < DESCRIPTOR::d; ++iAlpha) {
66 for (int iBeta=iAlpha; iBeta < DESCRIPTOR::d; ++iBeta) {
67 pi[iPi] = T();
68 for (unsigned fIndex=0; fIndex < onWallIndices.size(); ++fIndex) {
69 const int iPop = onWallIndices[fIndex];
70 pi[iPi] += descriptors::c<DESCRIPTOR>(iPop,iAlpha)
71 * descriptors::c<DESCRIPTOR>(iPop,iBeta)
72 * fNeq[iPop];
73 }
74 for (unsigned fIndex=0; fIndex < normalIndices.size(); ++fIndex) {
75 const int iPop = normalIndices[fIndex];
76 pi[iPi] += T{2}
77 * descriptors::c<DESCRIPTOR>(iPop,iAlpha)
78 * descriptors::c<DESCRIPTOR>(iPop,iBeta)
79 * fNeq[iPop];
80 }
81 ++iPi;
82 }
83 }
84 }
85
86};
87
88}
89
90#endif
Definition of a LB cell – header file.
Top level namespace for all of OpenLB.
#define any_platform
Define preprocessor macros for device-side functions, constant storage.
Definition platform.h:78
All boundary helper functions are inside this structure.
Definition helper.h:34
static void computeStress(CELL &cell, T rho, const T u[DESCRIPTOR::d], T pi[util::TensorVal< DESCRIPTOR >::n]) any_platform
Definition helper.h:36
static V secondOrder(int iPop, const RHO &rho, const U &u, const USQR &uSqr) any_platform
Computation of equilibrium distribution, second order in u.
Definition lbm.h:51
Compute number of elements of a symmetric d-dimensional tensor.
Definition util.h:210
Set of functions commonly used in LB computations – header file.