OpenLB 1.8.1
Loading...
Searching...
No Matches
partialSlip3D.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 Partial 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 PARTIAL_SLIP_HH
29#define PARTIAL_SLIP_HH
30
31#include "partialSlip3D.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
46
47
48 template <typename CELL, typename PARAMETERS, typename V = typename CELL::value_t>
49 void apply(CELL& x_b, PARAMETERS& parameters) any_platform {
50 using DESCRIPTOR = typename CELL::descriptor_t;
51 const V tuner = parameters.template get<descriptors::TUNER>();
52 int reflectionPop[DESCRIPTOR::q];
53 int mirrorDirection0;
54 int mirrorDirection1;
55 int mirrorDirection2;
56 int mult = 2 / (NX*NX + NY*NY + NZ*NZ);
57 reflectionPop[0] =0;
58 for (int iPop = 1; iPop < DESCRIPTOR::q; iPop++) {
59 reflectionPop[iPop] = 0;
60 // iPop are the directions which pointing into the fluid, discreteNormal is pointing outwarts
61 int scalarProduct = descriptors::c<DESCRIPTOR>(iPop,0)*NX + descriptors::c<DESCRIPTOR>(iPop,1)*NY + descriptors::c<DESCRIPTOR>(iPop,2)*NZ;
62 if ( scalarProduct < 0) {
63 // bounce back for the case discreteNormalX = discreteNormalY = discreteNormalZ = 1, that is mult=0
64 if (mult == 0) {
65 mirrorDirection0 = -descriptors::c<DESCRIPTOR>(iPop,0);
66 mirrorDirection1 = -descriptors::c<DESCRIPTOR>(iPop,1);
67 mirrorDirection2 = -descriptors::c<DESCRIPTOR>(iPop,2);
68 }
69 else {
70 mirrorDirection0 = descriptors::c<DESCRIPTOR>(iPop,0) - mult*scalarProduct*NX;
71 mirrorDirection1 = descriptors::c<DESCRIPTOR>(iPop,1) - mult*scalarProduct*NY;
72 mirrorDirection2 = descriptors::c<DESCRIPTOR>(iPop,2) - mult*scalarProduct*NZ;
73 }
74
75 // run through all lattice directions and look for match of direction
76 for (int i = 1; i < DESCRIPTOR::q; i++) {
77 if (descriptors::c<DESCRIPTOR>(i,0)==mirrorDirection0
78 && descriptors::c<DESCRIPTOR>(i,1)==mirrorDirection1
79 && descriptors::c<DESCRIPTOR>(i,2)==mirrorDirection2) {
80 reflectionPop[iPop] = i;
81 break;
82 }
83 }
84 }
85 }
86 for (int iPop = 1; iPop < DESCRIPTOR::q ; ++iPop) {
87 if (reflectionPop[iPop]!=0) {
88 //do reflection
89 x_b[iPop] = tuner*x_b[reflectionPop[iPop]];
90 }
91 }
92 for (int iPop = 1; iPop < DESCRIPTOR::q/2 ; ++iPop) {
93 V provv = x_b[descriptors::opposite<DESCRIPTOR>(iPop)];
94 x_b[descriptors::opposite<DESCRIPTOR>(iPop)] += (1.-tuner)*x_b[iPop];
95 x_b[iPop] += (1.-tuner)*provv;
96 }
97 }
98
99};
100
101}
102
103}
104
105#endif
constexpr int c(unsigned iPop, unsigned iDim) any_platform
Definition functions.h:83
constexpr int opposite(unsigned iPop) any_platform
Definition functions.h:95
Top level namespace for all of OpenLB.
OperatorScope
Block-wide operator application scopes.
@ PerCellWithParameters
Per-cell application with parameters, i.e. OPERATOR::apply is passed a CELL concept implementation an...
#define any_platform
Define preprocessor macros for device-side functions, constant storage.
Definition platform.h:77
void apply(CELL &x_b, PARAMETERS &parameters) any_platform
typename meta::list< descriptors::TUNER > parameters
static constexpr OperatorScope scope
Plain wrapper for list of types.
Definition meta.h:276