OpenLB 1.8.1
Loading...
Searching...
No Matches
partialSlip2D.hh
Go to the documentation of this file.
1/* This file is part of the OpenLB library
2 *
3 * Copyright (C) 2024 Fedor Bukreev, 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_2D_HH
29#define PARTIAL_SLIP_2D_HH
30
31#include "partialSlip2D.h"
32
33namespace olb {
34
35namespace boundary {
36
37template <int NX, int NY>
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 mult = 2 / (NX*NX + NY*NY);
56 reflectionPop[0] =0;
57 for (int iPop = 1; iPop < DESCRIPTOR::q; iPop++) {
58 reflectionPop[iPop] = 0;
59 // iPop are the directions which pointing into the fluid, discreteNormal is pointing outwarts
60 int scalarProduct = descriptors::c<DESCRIPTOR>(iPop,0)*NX + descriptors::c<DESCRIPTOR>(iPop,1)*NY;
61 if ( scalarProduct < 0) {
62 // bounce back for the case discreteNormalX = discreteNormalY = 1, that is mult=1
63 if (mult == 1) {
64 mirrorDirection0 = -descriptors::c<DESCRIPTOR>(iPop,0);
65 mirrorDirection1 = -descriptors::c<DESCRIPTOR>(iPop,1);
66 }
67 else {
68 mirrorDirection0 = descriptors::c<DESCRIPTOR>(iPop,0) - mult*scalarProduct*NX;
69 mirrorDirection1 = descriptors::c<DESCRIPTOR>(iPop,1) - mult*scalarProduct*NY;
70 }
71
72 // run through all lattice directions and look for match of direction
73 for (int i = 1; i < DESCRIPTOR::q; i++) {
74 if (descriptors::c<DESCRIPTOR>(i,0)==mirrorDirection0
75 && descriptors::c<DESCRIPTOR>(i,1)==mirrorDirection1) {
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] = tuner*x_b[reflectionPop[iPop]];
86 }
87 }
88 for (int iPop = 1; iPop < DESCRIPTOR::q/2 ; ++iPop) {
89 V provv = x_b[descriptors::opposite<DESCRIPTOR>(iPop)];
90 x_b[descriptors::opposite<DESCRIPTOR>(iPop)] += (1.-tuner)*x_b[iPop];
91 x_b[iPop] += (1.-tuner)*provv;
92 }
93 }
94
95};
96
97}
98
99}
100
101#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
static constexpr OperatorScope scope
typename meta::list< descriptors::TUNER > parameters
void apply(CELL &x_b, PARAMETERS &parameters) any_platform
Plain wrapper for list of types.
Definition meta.h:276