OpenLB 1.8.1
Loading...
Searching...
No Matches
setSlipBoundaryWithDynamics3D.hh
Go to the documentation of this file.
1/* This file is part of the OpenLB library
2 *
3 * Copyright (C) 2020 Alexander Schulz, Davide Dapelo
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 with dynamics
25//This is a new version of the Boundary, which only contains free floating functions
26#ifndef SET_SLIP_BOUNDARY_WITH_DYNAMICS_HH
27#define SET_SLIP_BOUNDARY_WITH_DYNAMICS_HH
28
30
31namespace olb {
32
34template<typename T,typename DESCRIPTOR, class MixinDynamics>
39
41template<typename T, typename DESCRIPTOR, class MixinDynamics>
43{
44 int _overlap = 1;
45 for (int iC = 0; iC < sLattice.getLoadBalancer().size(); ++iC) {
46 setSlipBoundaryWithDynamics<T,DESCRIPTOR,MixinDynamics>(sLattice.getBlock(iC), indicator->getBlockIndicatorF(iC));
47 }
49 //the addPoints2CommBC function is initialised inside setLocalVelocityBoundary3D.h/hh
50 //TODO: Is communication really needed for this BC?
51 addPoints2CommBC(sLattice,std::forward<decltype(indicator)>(indicator), _overlap);
52}
53
54
55//set SlipBoundaryWithDynamics on indicated cells inside the block domain
56template<typename T, typename DESCRIPTOR, class MixinDynamics>
58{
59 using namespace boundaryhelper;
60 OstreamManager clout(std::cout, "setslipBoundaryWithDynamics");
61 auto& blockGeometryStructure = indicator.getBlockGeometry();
62 const int margin = 1;
63 std::vector<int> discreteNormal(4,0);
64 blockGeometryStructure.forSpatialLocations([&](auto iX, auto iY, auto iZ) {
65 if (blockGeometryStructure.getNeighborhoodRadius({iX, iY, iZ}) >= margin
66 && indicator(iX, iY, iZ)) {
67 Dynamics<T,DESCRIPTOR>* dynamics = nullptr;
68 discreteNormal = indicator.getBlockGeometry().getStatistics().getType(iX, iY, iZ);
69 // Setting postProcessor as in setSlipBoundary3D
70 if (discreteNormal[1]!=0 || discreteNormal[2]!=0 || discreteNormal[3]!=0) {//set postProcessors for indicated cells
71 bool _output = false;
72 if (_output) {
73 clout << "setSlipBoundary<" << discreteNormal[1] << ","<< discreteNormal[2] << ","<< discreteNormal[3] << ">(" << iX << ", "<< iX << ", " << iY << ", " << iY << ", " << iZ << ", " << iZ << " )" << std::endl;
74 }
75 PostProcessorGenerator3D<T, DESCRIPTOR>* postProcessor = new SlipBoundaryProcessorGenerator3D<T, DESCRIPTOR>(iX, iX, iY, iY, iZ, iZ, discreteNormal[1], discreteNormal[2], discreteNormal[3]);
76 if (postProcessor) {
77 block.addPostProcessor(*postProcessor);
78 }
79 }
80 else {//define dynamics for indicated cells
81 clout << "Warning: Could not setSlipBoundary (" << iX << ", " << iY << ", " << iZ << "), discreteNormal=(" << discreteNormal[0] <<","<< discreteNormal[1] <<","<< discreteNormal[2] <<","<< discreteNormal[3] <<"), set to bounceBack" << std::endl;
82 block.template defineDynamics<BounceBack>({iX, iY, iZ});
83 }
84 // Setting dynamics and momenta as in interpolatedVelocityBoundary3D
85 if (discreteNormal[0] == 0) {
86 if (discreteNormal[1] != 0 && discreteNormal[1] == -1) {//set momenta, dynamics and postProcessors on indicated velocityBoundaryCells
87 dynamics = block.template getDynamics<typename MixinDynamics::template exchange_momenta<
89 >>();
90 }
91 else if (discreteNormal[1] != 0 && discreteNormal[1] == 1) {
92 dynamics = block.template getDynamics<typename MixinDynamics::template exchange_momenta<
94 >>();
95 }
96 else if (discreteNormal[2] != 0 && discreteNormal[2] == -1) {
97 dynamics = block.template getDynamics<typename MixinDynamics::template exchange_momenta<
99 >>();
100 }
101 else if (discreteNormal[2] != 0 && discreteNormal[2] == 1) {
102 dynamics = block.template getDynamics<typename MixinDynamics::template exchange_momenta<
104 >>();
105 }
106 else if (discreteNormal[3] != 0 && discreteNormal[3] == -1) {
107 dynamics = block.template getDynamics<typename MixinDynamics::template exchange_momenta<
109 >>();
110 }
111 else if (discreteNormal[3] != 0 && discreteNormal[3] == 1) {
112 dynamics = block.template getDynamics<typename MixinDynamics::template exchange_momenta<
114 >>();
115 }
116 }
117 else if (discreteNormal[0] == 1) {//set momenta,dynamics and postProcessors on indicated velocityBoundary External Corner cells
118 dynamics = block.template getDynamics<typename MixinDynamics::template exchange_momenta<
120 >>();
121 }
122 else if (discreteNormal[0] == 2) {//Internalvelocitycorner
123 dynamics = block.getDynamics(PlainMixinDynamicsForNormalMomenta<T,DESCRIPTOR,
125 >::construct(Vector<int,3>(discreteNormal.data() + 1)));
126 }
127 //ExternalVelocityEdge
128 else if (discreteNormal[0] == 3) {//set momenta,dynamics and postProcessors on indicated velocityBoundary External Edge cells
129 dynamics = block.template getDynamics<typename MixinDynamics::template exchange_momenta<
131 >>();
132 }
133 //InternalVelocityEdge
134 else if (discreteNormal[0] == 4) {//set momenta,dynamics and postProcessors on indicated velocityBoundary Inner Edge cells
135 dynamics = block.getDynamics(PlainMixinDynamicsForNormalSpecialMomenta<T,DESCRIPTOR,
137 >::construct(Vector<int,3>(discreteNormal.data() + 1)));
138 }
139 setBoundary(block, iX,iY,iZ, dynamics);
140 }
141 });
142}
143
144}
145#endif
const BlockGeometryStatistics< T, D > & getStatistics() const
Read only access to the associated block statistic.
Base block indicator functor.
Definition aliases.h:204
BlockGeometry< T, 3 > & getBlockGeometry()
Get underlying block geometry structure.
Regularized BGK collision followed by any other Dynamics.
Definition dynamics.h:395
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)
Definition aliases.h:194
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.
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 setSlipBoundaryWithDynamics(SuperLattice< T, DESCRIPTOR > &sLattice, SuperGeometry< T, 2 > &superGeometry, int material)
Initialising the setSlipBoundaryWithDynamics function on the superLattice domain Interpolated Boundar...
void setBoundary(BlockLattice< T, DESCRIPTOR > &block, int iX, int iY, Dynamics< T, DESCRIPTOR > *dynamics, PostProcessorGenerator2D< T, DESCRIPTOR > *postProcessor)
Interface for per-cell dynamics.
Definition interface.h:56