OpenLB 1.7
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 T physR[2];
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 _blockGeometry.getPhysR(physR, {iX, iY});
119 _indicator(inside, physR);
120 if ( !util::nearZero(inside[0]) ) {
121 _blockGeometry.getPhysR(physR, {iX-1, iY});
122 _indicator(inside, physR);
123 if ( util::nearZero(inside[0]) )
124 counter[0]++;
125 _blockGeometry.getPhysR(physR, {iX, iY-1});
126 _indicator(inside, physR);
127 if ( util::nearZero(inside[0]) )
128 counter[1]++;
129 _blockGeometry.getPhysR(physR, {iX+1, iY});
130 _indicator(inside, physR);
131 if ( util::nearZero(inside[0]) )
132 counter[2]++;
133 _blockGeometry.getPhysR(physR, {iX, iY+1});
134 _indicator(inside, physR);
135 if ( util::nearZero(inside[0]) )
136 counter[3]++;
137 }
138 }
139 }
140
141 T total = T();
142 for (int i=0; i<4; ++i) {
143 output[i]= ((T) counter[i]) * _latticeL;
144 total+= ((T) counter[i]) * _latticeL;
145 }
146 output[4]=total;
147 return true;
148 } else {
149 for (int i=0; i<5; ++i) {
150 output[i]=T();
151 }
152 return true;
153 }
154 return false;
155
156}
157
158}
159#endif
represents all functors that operate on a cuboid in general, mother class of BlockLatticeF,...
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)
GenericF is a base class, that can represent continuous as well as discrete functions.
Definition genericF.h:50
std::string & getName()
read and write access to name
Definition genericF.hh:51
Plain old scalar vector.
Definition vector.h:47
bool nearZero(const ADf< T, DIM > &a)
Definition aDiff.h:1087
Top level namespace for all of OpenLB.