OpenLB 1.8.1
Loading...
Searching...
No Matches
slip3D.hh
Go to the documentation of this file.
1/* This file is part of the OpenLB library
2 *
3 * Copyright (C) 2023 Dennis Teutscher, Alexander Schulz
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//This file contains the Slip Boundary
25//This is an onLattice boundary
26//This is a new version of the Boundary, which only contains free floating functions
27
28#ifndef SLIP_HH
29#define SLIP_HH
30
31#include "slip3D.h"
32
33namespace olb {
34
35namespace boundary {
36
37template <int NX, int NY, int NZ>
40
41 int getPriority() const {
42 return -1;
43 }
44
45 template <typename CELL, typename V = typename CELL::value_t>
46 void apply(CELL& x_b) any_platform {
47 using DESCRIPTOR = typename CELL::descriptor_t;
48 int reflectionPop[DESCRIPTOR::q];
49 int mirrorDirection0;
50 int mirrorDirection1;
51 int mirrorDirection2;
52 int mult = 2 / (NX*NX + NY*NY + NZ*NZ);
53 reflectionPop[0] =0;
54 for (int iPop = 1; iPop < DESCRIPTOR::q; iPop++) {
55 reflectionPop[iPop] = 0;
56 // iPop are the directions which pointing into the fluid, discreteNormal is pointing outwarts
57 int scalarProduct = descriptors::c<DESCRIPTOR>(iPop,0)*NX + descriptors::c<DESCRIPTOR>(iPop,1)*NY + descriptors::c<DESCRIPTOR>(iPop,2)*NZ;
58 if ( scalarProduct < 0) {
59 // bounce back for the case discreteNormalX = discreteNormalY = discreteNormalZ = 1, that is mult=0
60 if (mult == 0) {
61 mirrorDirection0 = -descriptors::c<DESCRIPTOR>(iPop,0);
62 mirrorDirection1 = -descriptors::c<DESCRIPTOR>(iPop,1);
63 mirrorDirection2 = -descriptors::c<DESCRIPTOR>(iPop,2);
64 }
65 else {
66 mirrorDirection0 = descriptors::c<DESCRIPTOR>(iPop,0) - mult*scalarProduct*NX;
67 mirrorDirection1 = descriptors::c<DESCRIPTOR>(iPop,1) - mult*scalarProduct*NY;
68 mirrorDirection2 = descriptors::c<DESCRIPTOR>(iPop,2) - mult*scalarProduct*NZ;
69 }
70
71 // run through all lattice directions and look for match of direction
72 for (int i = 1; i < DESCRIPTOR::q; i++) {
73 if (descriptors::c<DESCRIPTOR>(i,0)==mirrorDirection0
74 && descriptors::c<DESCRIPTOR>(i,1)==mirrorDirection1
75 && descriptors::c<DESCRIPTOR>(i,2)==mirrorDirection2) {
76 reflectionPop[iPop] = i;
77 break;
78 }
79 }
80 }
81 }
82 for (int iPop = 1; iPop < DESCRIPTOR::q ; ++iPop) {
83 if (reflectionPop[iPop]!=0) {
84 //do reflection
85 x_b[iPop] = x_b[reflectionPop[iPop]];
86 }
87 }
88 }
89
90};
91
92}
93
94}
95
96#endif
constexpr int c(unsigned iPop, unsigned iDim) any_platform
Definition functions.h:83
Top level namespace for all of OpenLB.
OperatorScope
Block-wide operator application scopes.
@ PerCell
Per-cell application, i.e. OPERATOR::apply is passed a CELL concept implementation.
#define any_platform
Define preprocessor macros for device-side functions, constant storage.
Definition platform.h:77
void apply(CELL &x_b) any_platform
Definition slip3D.hh:46
int getPriority() const
Definition slip3D.hh:41
static constexpr OperatorScope scope
Definition slip3D.hh:39