OpenLB 1.7
Loading...
Searching...
No Matches
blockGeometryFaces3D.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_3D_HH
25#define BLOCK_GEOMETRY_FACES_3D_HH
26
28
29namespace olb {
30
31
32template <typename T>
34 : BlockF3D<T>(indicatorF.getBlockStructure(), 7),
35 _indicatorF(indicatorF),
36 _latticeL(latticeL)
37{
38 this->getName() = "blockGeometryFaces";
39}
40
41template <typename T>
42bool BlockGeometryFaces3D<T>::operator() (T output[], const int input[])
43{
44 for (int i=0; i<7; ++i) {
45 output[i] = T();
46 }
47
48 std::size_t counter[7] = {0};
49
50 if (!_indicatorF.isEmpty()) {
51 auto& blockGeometry = _indicatorF.getBlockGeometry();
52 const Vector<int,3> min = _indicatorF.getMin();
53 const Vector<int,3> 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 for (int iZ = min[2]; iZ <= max[2]; ++iZ) {
59 // Lock at solid nodes only
60 if (_indicatorF(iX, iY, iZ)) {
61 if (blockGeometry.getMaterial({iX-1, iY, iZ}) == 1) {
62 counter[0]++;
63 }
64 if (blockGeometry.getMaterial({iX, iY-1, iZ}) == 1) {
65 counter[1]++;
66 }
67 if (blockGeometry.getMaterial({iX, iY, iZ-1}) == 1) {
68 counter[2]++;
69 }
70 if (blockGeometry.getMaterial({iX+1, iY, iZ}) == 1) {
71 counter[3]++;
72 }
73 if (blockGeometry.getMaterial({iX, iY+1, iZ}) == 1) {
74 counter[4]++;
75 }
76 if (blockGeometry.getMaterial({iX, iY, iZ+1}) == 1) {
77 counter[5]++;
78 }
79 }
80 }
81 }
82 }
83
84 const T dx2 = _latticeL*_latticeL;
85 for (int i=0; i<6; ++i) {
86 output[i] = (T) counter[i] * dx2;
87 output[6] += (T) counter[i] * dx2;
88 }
89 }
90
91 return true;
92}
93
94template <typename T, bool HLBM>
96 BlockGeometry<T,3>& blockGeometry, SmoothIndicatorF3D<T,T,HLBM>& indicator,
97 int material, T latticeL)
98 : GenericF<T,int>(7,0), _blockGeometry(blockGeometry), _indicator(indicator),
99 _material(material), _latticeLsqr(latticeL*latticeL)
100{
101 this->getName() = "facesSmoothInd";
102}
103template <typename T, bool HLBM>
104bool BlockGeometryFacesIndicator3D<T,HLBM>::operator() (T output[], const int input[])
105{
106 int counter[6] = {0,0,0,0,0,0};
107 T inside[1];
108 T physR[3];
109 if (_blockGeometry.getStatistics().getNvoxel(_material)!=0) {
110 const int x0 = _blockGeometry.getStatistics().getMinLatticeR(_material)[0];
111 const int y0 = _blockGeometry.getStatistics().getMinLatticeR(_material)[1];
112 const int z0 = _blockGeometry.getStatistics().getMinLatticeR(_material)[2];
113 const int x1 = _blockGeometry.getStatistics().getMaxLatticeR(_material)[0];
114 const int y1 = _blockGeometry.getStatistics().getMaxLatticeR(_material)[1];
115 const int z1 = _blockGeometry.getStatistics().getMaxLatticeR(_material)[2];
116
117 // Iterate over all cells and count the cells of the face
118 for (int iX = x0; iX <= x1; ++iX) {
119 for (int iY = y0; iY <= y1; ++iY) {
120 for (int iZ = z0; iZ <= z1; ++iZ) {
121 // Look at solid nodes only
122 _blockGeometry.getPhysR(physR, {iX, iY, iZ});
123 _indicator(inside, physR);
124 if ( !util::nearZero(inside[0]) ) {
125 _blockGeometry.getPhysR(physR, {iX-1, iY, iZ});
126 _indicator(inside, physR);
127 if ( util::nearZero(inside[0]) ) {
128 counter[0]++;
129 }
130 _blockGeometry.getPhysR(physR, {iX, iY-1, iZ});
131 _indicator(inside, physR);
132 if ( util::nearZero(inside[0]) ) {
133 counter[1]++;
134 }
135 _blockGeometry.getPhysR(physR, {iX, iY, iZ-1});
136 _indicator(inside, physR);
137 if ( util::nearZero(inside[0]) ) {
138 counter[2]++;
139 }
140 _blockGeometry.getPhysR(physR, {iX+1, iY, iZ});
141 _indicator(inside, physR);
142 if ( util::nearZero(inside[0]) ) {
143 counter[3]++;
144 }
145 _blockGeometry.getPhysR(physR, {iX, iY+1, iZ});
146 _indicator(inside, physR);
147 if ( util::nearZero(inside[0]) ) {
148 counter[4]++;
149 }
150 _blockGeometry.getPhysR(physR, {iX, iY, iZ+1});
151 _indicator(inside, physR);
152 if ( util::nearZero(inside[0]) ) {
153 counter[5]++;
154 }
155 }
156 }
157 }
158 }
159
160 T total = T();
161 for (int i=0; i<6; ++i) {
162 output[i]= ((T) counter[i]) * _latticeLsqr;
163 total+= ((T) counter[i]) * _latticeLsqr;
164 }
165 output[6]=total;
166 return true;
167 }
168 else {
169 for (int i=0; i<7; ++i) {
170 output[i]=T();
171 }
172 return true;
173 }
174 return false;
175
176}
177
178}
179#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
BlockGeometryFaces3D(BlockIndicatorF3D< T > &indicatorF, T latticeL)
BlockGeometryFacesIndicator3D(BlockGeometry< T, 3 > &blockGeometry, SmoothIndicatorF3D< T, T, HLBM > &indicator, int material, T deltaX)
bool operator()(T output[], const int input[]) override
has to be implemented for 'every' derived class
Representation of a block geometry.
Base block indicator functor.
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.