OpenLB 1.7
Loading...
Searching...
No Matches
setNewSlipBoundary3D.hh
Go to the documentation of this file.
1/* This file is part of the OpenLB library
2 *
3 * Copyright (C) 2023 Fedor Bukreev, Adrian Kummerländer
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 SET_NEW_SLIP_BOUNDARY_3D_HH
25#define SET_NEW_SLIP_BOUNDARY_3D_HH
26
27#include "dynamics/dynamics.h"
28
29namespace olb {
30
31template <typename T, typename DESCRIPTOR, int discreteNormalX, int discreteNormalY, int discreteNormalZ>
33{
35
36 int getPriority() const {
37 return 0;
38 }
39
40 template <typename CELL>
41 void apply(CELL& cell) any_platform{
42 int mirrorDirection0;
43 int mirrorDirection1;
44 int mirrorDirection2;
45 int mult = 2 / (discreteNormalX*discreteNormalX + discreteNormalY*discreteNormalY + discreteNormalZ*discreteNormalZ);
46 int reflectionPop[DESCRIPTOR::q] = {0};
47 for (int iPop = 1; iPop < DESCRIPTOR::q; iPop++) {
48 reflectionPop[iPop] = 0;
49 // iPop are the directions which pointing into the fluid, discreteNormal is pointing outwarts
50 int scalarProduct = descriptors::c<DESCRIPTOR>(iPop,0)*discreteNormalX + descriptors::c<DESCRIPTOR>(iPop,1)*discreteNormalY + descriptors::c<DESCRIPTOR>(iPop,2)*discreteNormalZ;
51 if (scalarProduct < 0) {
52 // bounce back for the case discreteNormalX = discreteNormalY = discreteNormalZ = 1, that is mult=0
53 if (mult == 0) {
54 mirrorDirection0 = -descriptors::c<DESCRIPTOR>(iPop,0);
55 mirrorDirection1 = -descriptors::c<DESCRIPTOR>(iPop,1);
56 mirrorDirection2 = -descriptors::c<DESCRIPTOR>(iPop,2);
57 }
58 else {
59 mirrorDirection0 = descriptors::c<DESCRIPTOR>(iPop,0) - mult*scalarProduct*discreteNormalX;
60 mirrorDirection1 = descriptors::c<DESCRIPTOR>(iPop,1) - mult*scalarProduct*discreteNormalY;
61 mirrorDirection2 = descriptors::c<DESCRIPTOR>(iPop,2) - mult*scalarProduct*discreteNormalZ;
62 }
63 // run through all lattice directions and look for match of direction
64 for (int i = 1; i < DESCRIPTOR::q; i++) {
65 if (descriptors::c<DESCRIPTOR>(i,0)==mirrorDirection0
66 && descriptors::c<DESCRIPTOR>(i,1)==mirrorDirection1
67 && descriptors::c<DESCRIPTOR>(i,2)==mirrorDirection2) {
68 reflectionPop[iPop] = i;
69 break;
70 }
71 }
72 }
73 }
74 for (int iPop = 1; iPop < DESCRIPTOR::q; iPop++) {
75 if (reflectionPop[iPop]!=0) {
76 cell[iPop] = cell[reflectionPop[iPop]];
77 }
78 }
79 }
80};
81
82template<typename T,typename DESCRIPTOR>
83void setNewSlipBoundary(SuperLattice<T, DESCRIPTOR>& sLattice, SuperGeometry<T,3>& superGeometry, int material)
84{
85 setNewSlipBoundary<T,DESCRIPTOR>(sLattice, superGeometry.getMaterialIndicator(material));
86}
87
88template<typename T, typename DESCRIPTOR>
90{
91 OstreamManager clout(std::cout, "setInterpolatedVelocityBoundary");
92 int _overlap = 1;
93 bool includeOuterCells = false;
94 if (indicator->getSuperGeometry().getOverlap() == 1) {
95 includeOuterCells = true;
96 clout << "WARNING: overlap == 1, boundary conditions set on overlap despite unknown neighbor materials" << std::endl;
97 }
98 for (int iC = 0; iC < sLattice.getLoadBalancer().size(); ++iC) {
99 setNewSlipBoundary<T,DESCRIPTOR>(sLattice.getBlock(iC), indicator->getBlockIndicatorF(iC),includeOuterCells);
100 }
101 addPoints2CommBC(sLattice,std::forward<decltype(indicator)>(indicator), _overlap);
102}
103
104
105template <typename T, typename DESCRIPTOR>
106void setNewSlipBoundary(BlockLattice<T,DESCRIPTOR>& _block, BlockIndicatorF3D<T>& indicator, bool includeOuterCells)
107{
108 using namespace boundaryhelper;
109 auto& blockGeometryStructure = indicator.getBlockGeometry();
110 const int margin = includeOuterCells ? 0 : 1;
111 std::vector<int> discreteNormal(4,0);
112 blockGeometryStructure.forSpatialLocations([&](auto iX, auto iY, auto iZ) {
113 if (blockGeometryStructure.getNeighborhoodRadius({iX, iY, iZ}) >= margin
114 && indicator(iX, iY, iZ)) {
115 discreteNormal = blockGeometryStructure.getStatistics().getType(iX, iY, iZ);
116 Dynamics<T,DESCRIPTOR>* dynamics = nullptr;
117
118 if(util::fabs(discreteNormal[1])+util::fabs(discreteNormal[2])+util::fabs(discreteNormal[3]) == T{1.}){
119 _block.addPostProcessor(
120 typeid(stage::PostCollide), {iX,iY,iZ},
121 promisePostProcessorForNormal<T, DESCRIPTOR, SlipBoundaryPostProcessor3D>(
122 Vector<int,3>(discreteNormal.data()+1)
123 )
124 );
125 dynamics = _block.template getDynamics<NoCollideDynamics<T,DESCRIPTOR>>();
126 } else {
127 dynamics = _block.template getDynamics<BounceBack<T,DESCRIPTOR>>();
128 }
129 setBoundary(_block, iX, iY, iZ, dynamics);
130 }
131 });
132}
133
134}
135
136#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.
Plain old scalar vector.
Definition vector.h:47
cpu::simd::Pack< T > fabs(cpu::simd::Pack< T > value)
Definition pack.h:106
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.
OperatorScope
Block-wide operator application scopes.
Definition operator.h:54
@ PerCell
Per-cell application, i.e. OPERATOR::apply is passed a CELL concept implementation.
void setNewSlipBoundary(SuperLattice< T, DESCRIPTOR > &sLattice, SuperGeometry< T, 3 > &superGeometry, int material)
void setBoundary(BlockLattice< T, DESCRIPTOR > &block, int iX, int iY, Dynamics< T, DESCRIPTOR > *dynamics, PostProcessorGenerator2D< T, DESCRIPTOR > *postProcessor)
#define any_platform
Define preprocessor macros for device-side functions, constant storage.
Definition platform.h:78
Interface for per-cell dynamics.
Definition interface.h:54
static constexpr OperatorScope scope
void apply(CELL &cell) any_platform
Communication after collision.
Definition stages.h:34