OpenLB 1.8.1
Loading...
Searching...
No Matches
setWallFunctionBoundary3D.hh
Go to the documentation of this file.
1/* This file is part of the OpenLB library
2 *
3 * Copyright (C) 2020 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 WallFunctionBoundary
25//This is a new version of the Boundary, which only contains free floating functions
26#ifndef SET_WALL_FUNCTION_BOUNDARY_3D_HH
27#define SET_WALL_FUNCTION_BOUNDARY_3D_HH
28
30
31namespace olb {
32
33namespace legacy {
34
36template<typename T, typename DESCRIPTOR>
37void setWallFunctionBoundary(SuperLattice<T, DESCRIPTOR>& sLattice, SuperGeometry<T,3>& superGeometry, int material,
38 UnitConverter<T, DESCRIPTOR> const& converter,
40 IndicatorF3D<T>* geoIndicator)
41{
42 setWallFunctionBoundary<T,DESCRIPTOR>(sLattice, superGeometry.getMaterialIndicator(material),
43 converter, wallFunctionParam, geoIndicator);
44}
45
47template<typename T, typename DESCRIPTOR>
49 UnitConverter<T, DESCRIPTOR> const& converter,
51 IndicatorF3D<T>* geoIndicator)
52{
53 int _overlap = 1;
54 for (int iCloc = 0; iCloc < sLattice.getLoadBalancer().size(); ++iCloc) {
56 indicator->getBlockIndicatorF(iCloc),
57 converter, wallFunctionParam, geoIndicator);
58 }
59 auto& communicator = sLattice.getCommunicator(stage::PostStream());
60 communicator.template requestField<descriptors::POPULATION>();
61
62 SuperIndicatorBoundaryNeighbor<T,DESCRIPTOR::d> neighborIndicator(std::forward<decltype(indicator)>(indicator), _overlap);
63 communicator.requestOverlap(_overlap, neighborIndicator);
64 communicator.exchangeRequests();
65}
66
67
69template<typename T, typename DESCRIPTOR>
71 UnitConverter<T, DESCRIPTOR> const& converter,
73 IndicatorF3D<T>* geoIndicator)
74{
75 OstreamManager clout(std::cout, "setWallFunctionBoundary");
76 bool _output = false;
77 const auto& blockGeometryStructure = indicator.getBlockGeometry();
78 const int margin = 1;
79 std::vector<int> discreteNormal(4, 0);
80 blockGeometryStructure.forSpatialLocations([&](auto iX, auto iY, auto iZ) {
81 if (blockGeometryStructure.getNeighborhoodRadius({iX, iY, iZ}) >= margin
82 && indicator(iX, iY, iZ)) {
83 discreteNormal = blockGeometryStructure.getStatistics().getType(iX, iY, iZ);
84 std::vector<int> missingIndices;
85 for (int x = -1 ; x < 2; ++x) {
86 for (int y = -1 ; y < 2; ++y) {
87 for (int z = -1 ; z < 2; ++z) {
88 if (blockGeometryStructure.getMaterial(iX + x, iY + y, iZ + z) == 0) {
89 for (int iPop = 0; iPop < DESCRIPTOR::q; ++iPop) {
90 if (descriptors::c<DESCRIPTOR>(iPop,0) == x &&
91 descriptors::c<DESCRIPTOR>(iPop,1) == y &&
92 descriptors::c<DESCRIPTOR>(iPop,2) == z) {
93 missingIndices.push_back(descriptors::opposite<DESCRIPTOR>(iPop));
94 }
95 }
96 }
97 }
98 }
99 }
100 if (discreteNormal[1]!=0 || discreteNormal[2]!=0 || discreteNormal[3]!=0) {
101 discreteNormal.erase(discreteNormal.begin());
102 //OLB_PRECONDITION(x0==x1 || y0==y1 || z0==z1);
103 if (_output) {
104 clout << "setWallFunctionBoundary<" << discreteNormal[0] << ","<< discreteNormal[1] << ","<< discreteNormal[2] << ">(" << iX << ", "<< iX << ", " << iY << ", " << iY << ", " << iZ << ", " << iZ << " )" << std::endl;
105 }
106 auto postProcessor = std::unique_ptr<PostProcessorGenerator3D<T, DESCRIPTOR>>{ new WallFunctionBoundaryProcessorGenerator3D<T, DESCRIPTOR>(iX, iX, iY, iY, iZ, iZ, indicator.getBlockGeometry(), discreteNormal, missingIndices,
107 converter, wallFunctionParam, geoIndicator) };
108 if (postProcessor) {
109 _block.addPostProcessor(*postProcessor);
110 }
111 }
112 else {
113 clout << "Warning: Could not setWallFunctionBoundary (" << iX << ", " << iY << ", " << iZ << "), discreteNormal=(" << discreteNormal[0] <<","<< discreteNormal[1] <<","<< discreteNormal[2] <<","<< discreteNormal[3] <<"), set to bounceBack" << std::endl;
114 _block.template defineDynamics<BounceBack>({iX, iY, iZ});
115 }
116 }
117 });
118}
119
120} //namespace legacy
121
122} //namespace olb
123
124
125#endif
126
Base block indicator functor.
Definition aliases.h:204
BlockGeometry< T, 3 > & getBlockGeometry()
Get underlying block geometry structure.
Smart pointer for managing the various ways of passing functors around.
Definition functorPtr.h:60
IndicatorF3D is an application from .
Definition aliases.h:244
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.
SuperCommunicator< T, SuperLattice > & getCommunicator(STAGE stage=STAGE())
Return communicator for given communication stage.
BlockLattice< T, DESCRIPTOR > & getBlock(int locC)
Return BlockLattice with local index locC.
LoadBalancer< T > & getLoadBalancer()
Read and write access to the load balancer.
Conversion between physical and lattice units, as well as discretization.
constexpr int c(unsigned iPop, unsigned iDim) any_platform
Definition functions.h:83
constexpr int opposite(unsigned iPop) any_platform
Definition functions.h:95
void setWallFunctionBoundary(SuperLattice< T, DESCRIPTOR > &sLattice, SuperGeometry< T, 3 > &superGeometry, int material, UnitConverter< T, DESCRIPTOR > const &converter, wallFunctionParam< T > const &wallFunctionParam, IndicatorF3D< T > *geoIndicator=NULL)
Initialising the WallFunctionBoundary on the superLattice domain.
Top level namespace for all of OpenLB.
std::conditional_t< D==2, SuperIndicatorBoundaryNeighbor2D< T >, SuperIndicatorBoundaryNeighbor3D< T > > SuperIndicatorBoundaryNeighbor
Definition aliases.h:297
Communication after propagation.
Definition stages.h:36