OpenLB 1.7
Loading...
Searching...
No Matches
setSlipBoundary3D.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#ifndef SET_SLIP_BOUNDARY_HH
28#define SET_SLIP_BOUNDARY_HH
29
30#include "setSlipBoundary3D.h"
31
32
33
34namespace olb {
35template <typename,typename,int NX, int NY, int NZ>
38
39 int getPriority() const {
40 return -1;
41 }
42
43
44 template <typename CELL, typename V = typename CELL::value_t>
45 void apply(CELL& x_b) any_platform {
46 using DESCRIPTOR = typename CELL::descriptor_t;
47 int reflectionPop[DESCRIPTOR::q];
48 int mirrorDirection0;
49 int mirrorDirection1;
50 int mirrorDirection2;
51 int mult = 2 / (NX*NX + NY*NY + NZ*NZ);
52 reflectionPop[0] =0;
53 for (int iPop = 1; iPop < DESCRIPTOR::q; iPop++) {
54 reflectionPop[iPop] = 0;
55 // iPop are the directions which pointing into the fluid, discreteNormal is pointing outwarts
56 int scalarProduct = descriptors::c<DESCRIPTOR>(iPop,0)*NX + descriptors::c<DESCRIPTOR>(iPop,1)*NY + descriptors::c<DESCRIPTOR>(iPop,2)*NZ;
57 if ( scalarProduct < 0) {
58 // bounce back for the case discreteNormalX = discreteNormalY = discreteNormalZ = 1, that is mult=0
59 if (mult == 0) {
60 mirrorDirection0 = -descriptors::c<DESCRIPTOR>(iPop,0);
61 mirrorDirection1 = -descriptors::c<DESCRIPTOR>(iPop,1);
62 mirrorDirection2 = -descriptors::c<DESCRIPTOR>(iPop,2);
63 }
64 else {
65 mirrorDirection0 = descriptors::c<DESCRIPTOR>(iPop,0) - mult*scalarProduct*NX;
66 mirrorDirection1 = descriptors::c<DESCRIPTOR>(iPop,1) - mult*scalarProduct*NY;
67 mirrorDirection2 = descriptors::c<DESCRIPTOR>(iPop,2) - mult*scalarProduct*NZ;
68 }
69
70 // run through all lattice directions and look for match of direction
71 for (int i = 1; i < DESCRIPTOR::q; i++) {
72 if (descriptors::c<DESCRIPTOR>(i,0)==mirrorDirection0
73 && descriptors::c<DESCRIPTOR>(i,1)==mirrorDirection1
74 && descriptors::c<DESCRIPTOR>(i,2)==mirrorDirection2) {
75 reflectionPop[iPop] = i;
76 break;
77 }
78 }
79 }
80 }
81 for (int iPop = 1; iPop < DESCRIPTOR::q ; ++iPop) {
82 if (reflectionPop[iPop]!=0) {
83 //do reflection
84 x_b[iPop] = x_b[reflectionPop[iPop]];
85 }
86 }
87 }
88
89};
90
92template<typename T, typename DESCRIPTOR>
93void setSlipBoundary(SuperLattice<T, DESCRIPTOR>& sLattice, SuperGeometry<T,3>& superGeometry, int material)
94{
95 setSlipBoundary<T, DESCRIPTOR>(sLattice, superGeometry.getMaterialIndicator(material));
96}
97
99template<typename T, typename DESCRIPTOR>
101{
102 bool includeOuterCells = false;
103 int _overlap = 1;
104 OstreamManager clout(std::cout, "setslipBoundary");
105 if (indicator->getSuperGeometry().getOverlap() == 1) {
106 includeOuterCells = true;
107 clout << "WARNING: overlap == 1, boundary conditions set on overlap despite unknown neighbor materials" << std::endl;
108 }
109 for (int iCloc = 0; iCloc < sLattice.getLoadBalancer().size(); ++iCloc) {
110 setSlipBoundary(sLattice.getBlock(iCloc), indicator->getBlockIndicatorF(iCloc), includeOuterCells);
111 }
113 addPoints2CommBC(sLattice, std::forward<decltype(indicator)>(indicator), _overlap);
114}
115
117template<typename T, typename DESCRIPTOR>
118void setSlipBoundary(BlockLattice<T,DESCRIPTOR>& block,BlockIndicatorF3D<T>& indicator, bool includeOuterCells )
119{
120 OstreamManager clout(std::cout, "setslipBoundary");
121 auto& blockGeometryStructure = indicator.getBlockGeometry();
122 const int margin = includeOuterCells ? 0 : 1;
123 std::vector<int> discreteNormal(4, 0);
124 blockGeometryStructure.forSpatialLocations([&](auto iX, auto iY, auto iZ) {
125 if (blockGeometryStructure.getNeighborhoodRadius({iX, iY, iZ}) >= margin
126 && indicator(iX, iY, iZ)) {
127 discreteNormal = blockGeometryStructure.getStatistics().getType(iX, iY, iZ);
128 if (discreteNormal[1]!=0 || discreteNormal[2]!=0 || discreteNormal[3]!=0) {//set postProcessors for indicated cells
129 OstreamManager clout(std::cout, "setslipBoundary");
130 bool _output = false;
131 if (_output) {
132 clout << "setSlipBoundary<" << discreteNormal[1] << ","<< discreteNormal[2] << ","<< discreteNormal[3] << ">(" << iX << ", "<< iX << ", " << iY << ", " << iY << ", " << iZ << ", " << iZ << " )" << std::endl;
133 }
134 block.addPostProcessor(
135 typeid(stage::PostStream), {iX,iY,iZ},
136 boundaryhelper::promisePostProcessorForNormal<T, DESCRIPTOR, FullSlipBoundaryPostProcessor3D>(
137 Vector <int,3> (discreteNormal.data()+1)
138 )
139 );
140 }
141 else {//define dynamics for indicated cells
142 clout << "Warning: Could not setSlipBoundary (" << iX << ", " << iY << ", " << iZ << "), discreteNormal=(" << discreteNormal[0] <<","<< discreteNormal[1] <<","<< discreteNormal[2] <<","<< discreteNormal[3] <<"), set to bounceBack" << std::endl;
143 block.template defineDynamics<BounceBack>({iX, iY, iZ});
144 }
145 }
146 });
147}
148}//namespace olb
149
150#endif
Base block indicator functor.
BlockGeometry< T, 3 > & getBlockGeometry()
Get underlying block geometry structure.
Platform-abstracted block lattice for external access and inter-block interaction.
virtual void addPostProcessor(std::type_index stage, LatticeR< DESCRIPTOR::d > latticeR, PostProcessorPromise< T, DESCRIPTOR > &&promise)=0
Schedule post processor for application to latticeR in stage.
Smart pointer for managing the various ways of passing functors around.
Definition functorPtr.h:60
class for marking output with some text
Representation of a statistic for a parallel 2D geometry.
std::unique_ptr< SuperIndicatorF< T, D > > getMaterialIndicator(std::vector< int > &&materials)
Returns a material indicator using the given vector of materials.
Base indicator functor (discrete)
Super class maintaining block lattices for a cuboid decomposition.
BlockLattice< T, DESCRIPTOR > & getBlock(int locC)
Return BlockLattice with local index locC.
LoadBalancer< T > & getLoadBalancer()
Read and write access to the load balancer.
Top level namespace for all of OpenLB.
void addPoints2CommBC(SuperLattice< T, DESCRIPTOR > &sLattice, FunctorPtr< SuperIndicatorF2D< T > > &&indicator, int _overlap)
Adds needed Cells to the Communicator _commBC in SuperLattice.
void setSlipBoundary(SuperLattice< T, DESCRIPTOR > &sLattice, SuperGeometry< T, 2 > &superGeometry, int material)
Initialising the SlipBoundary on the superLattice domain.
OperatorScope
Block-wide operator application scopes.
Definition operator.h:54
@ 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:78
void apply(CELL &x_b) any_platform
static constexpr OperatorScope scope
Communication after propagation.
Definition stages.h:36