OpenLB 1.8.1
Loading...
Searching...
No Matches
blockGeometryFaces2D.hh
Go to the documentation of this file.
1/* This file is part of the OpenLB library
2 *
3 * Copyright (C) 2013-2018 Mathias Krause, Albert Mink, Adrian Kummerlaender
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 BLOCK_GEOMETRY_FACES_2D_HH
25#define BLOCK_GEOMETRY_FACES_2D_HH
26
28
29namespace olb {
30
31
32template <typename T>
34 : BlockF2D<T>(indicatorF.getBlockStructure(), 5),
35 _indicatorF(indicatorF),
36 _latticeL(latticeL)
37{
38 this->getName() = "blockGeometryFaces";
39}
40
41template <typename T>
42bool BlockGeometryFaces2D<T>::operator() (T output[], const int input[])
43{
44 for (int i=0; i<5; ++i) {
45 output[i] = T();
46 }
47
48 std::size_t counter[5] = {0};
49
50 if (!_indicatorF.isEmpty()) {
51 const auto& blockGeometry = _indicatorF.getBlockGeometry();
52 const Vector<int,2> min = _indicatorF.getMin();
53 const Vector<int,2> max = _indicatorF.getMax();
54
55 // Iterate over all cells and count the cells of the face
56 for (int iX = min[0]; iX <= max[0]; ++iX) {
57 for (int iY = min[1]; iY <= max[1]; ++iY) {
58 // Lock at solid nodes only
59 if (_indicatorF(iX, iY)) {
60 if (blockGeometry.getMaterial({iX-1, iY}) == 1) {
61 counter[0]++;
62 }
63 if (blockGeometry.getMaterial({iX, iY-1}) == 1) {
64 counter[1]++;
65 }
66 if (blockGeometry.getMaterial({iX+1, iY}) == 1) {
67 counter[2]++;
68 }
69 if (blockGeometry.getMaterial({iX, iY+1}) == 1) {
70 counter[3]++;
71 }
72 }
73 }
74 }
75
76 const T dx2 = _latticeL*_latticeL;
77 T total = T(); //added
78 for (int i=0; i<4; ++i) {
79 output[i] = (T) counter[i] * dx2;
80 total+= (T) counter[i] * dx2; //was output[4]
81 }
82 output[4]=total;
83 return true;
84 } else {
85 for (int i=0; i<5; ++i) {
86 output[i]=T();
87 }
88 return true;
89 }
90 return false;
91}
92
93template <typename T, bool HLBM>
95 BlockGeometry<T,2>& blockGeometry, SmoothIndicatorF2D<T,T,HLBM>& indicator,
96 int material, T latticeL)
97 : GenericF<T,int>(5,0), _blockGeometry(blockGeometry), _indicator(indicator),
98 _material(material), _latticeL(latticeL) // _latticeLsqr(latticeL*latticeL)
99{
100 this->getName() = "facesSmoothInd";
101}
102template <typename T, bool HLBM>
103bool BlockGeometryFacesIndicator2D<T,HLBM>::operator() (T output[], const int input[])
104{
105 int counter[4] = {0,0,0,0};
106 T inside[1];
107 Vector<T,2> physR;
108 if (_blockGeometry.getStatistics().getNvoxel(_material)!=0) {
109 const int x0 = _blockGeometry.getStatistics().getMinLatticeR(_material)[0];
110 const int y0 = _blockGeometry.getStatistics().getMinLatticeR(_material)[1];
111 const int x1 = _blockGeometry.getStatistics().getMaxLatticeR(_material)[0];
112 const int y1 = _blockGeometry.getStatistics().getMaxLatticeR(_material)[1];
113
114 // Iterate over all cells and count the cells of the face
115 for (int iX = x0; iX <= x1; ++iX) {
116 for (int iY = y0; iY <= y1; ++iY) {
117 // Look at solid nodes only
118 LatticeR<2> latticeR = {iX, iY};
119 physR = _blockGeometry.getPhysR(latticeR);
120 _indicator(inside, physR.data());
121 if ( !util::nearZero(inside[0]) ) {
122 physR = _blockGeometry.getPhysR({iX-1, iY});
123 _indicator(inside, physR.data());
124 if ( util::nearZero(inside[0]) ) {
125 counter[0]++;
126 }
127 physR = _blockGeometry.getPhysR({iX, iY-1});
128 _indicator(inside, physR.data());
129 if ( util::nearZero(inside[0]) ) {
130 counter[1]++;
131 }
132 physR = _blockGeometry.getPhysR({iX+1, iY});
133 _indicator(inside, physR.data());
134 if ( util::nearZero(inside[0]) ) {
135 counter[2]++;
136 }
137 physR = _blockGeometry.getPhysR({iX, iY+1});
138 _indicator(inside, physR.data());
139 if ( util::nearZero(inside[0]) ) {
140 counter[3]++;
141 }
142 }
143 }
144 }
145
146 T total = T();
147 for (int i=0; i<4; ++i) {
148 output[i]= ((T) counter[i]) * _latticeL;
149 total+= ((T) counter[i]) * _latticeL;
150 }
151 output[4]=total;
152 return true;
153 } else {
154 for (int i=0; i<5; ++i) {
155 output[i]=T();
156 }
157 return true;
158 }
159 return false;
160
161}
162
163}
164#endif
represents all functors that operate on a cuboid in general, mother class of BlockLatticeF,...
Definition aliases.h:173
bool operator()(T output[], const int input[]) override
has to be implemented for 'every' derived class
BlockGeometryFaces2D(BlockIndicatorF2D< T > &indicatorF, T latticeL)
bool operator()(T output[], const int input[]) override
has to be implemented for 'every' derived class
BlockGeometryFacesIndicator2D(BlockGeometry< T, 2 > &blockGeometry, SmoothIndicatorF2D< T, T, HLBM > &indicator, int material, T deltaX)
Representation of a block geometry.
Base block indicator functor (discrete)
Definition aliases.h:203
GenericF is a base class, that can represent continuous as well as discrete functions.
Definition genericF.h:50
std::string & getName()
Definition genericF.hh:51
Plain old scalar vector.
constexpr const T * data() const any_platform
Definition vector.h:172
bool nearZero(T a) any_platform
return true if a is close to zero
Definition util.h:402
Top level namespace for all of OpenLB.