OpenLB 1.7
Loading...
Searching...
No Matches
blockIndicatorF3D.hh
Go to the documentation of this file.
1/* This file is part of the OpenLB library
2 *
3 * Copyright (C) 2017 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_INDICATOR_F_3D_HH
25#define BLOCK_INDICATOR_F_3D_HH
26
27#include <algorithm>
28
29#include "blockIndicatorF3D.h"
30#include "core/util.h"
31
32namespace olb {
33
34template <typename T>
36 IndicatorF3D<T>& indicatorF, BlockGeometry<T,3>& blockGeometry)
37 : BlockIndicatorF3D<T>(blockGeometry),
38 _indicatorF(indicatorF)
39{ }
40
41template <typename T>
42bool BlockIndicatorFfromIndicatorF3D<T>::operator() (bool output[], const int input[])
43{
44 T physR[3];
45 this->_block.getPhysR(physR,input);
46 return _indicatorF(output,physR);
47}
48
49template <typename T>
51{
52 const Vector<T,3> min = _indicatorF.getMin();
53 return Vector<int,3> {
54 static_cast<int>(util::floor(min[0])),
55 static_cast<int>(util::floor(min[1])),
56 static_cast<int>(util::floor(min[2]))
57 };
58}
59
60template <typename T>
62{
63 const Vector<T,3> max = _indicatorF.getMax();
64 return Vector<int,3> {
65 static_cast<int>(util::ceil(max[0])),
66 static_cast<int>(util::ceil(max[1])),
67 static_cast<int>(util::ceil(max[2]))
68 };
69}
70
71
72template <typename T, bool HLBM>
78
79template <typename T, bool HLBM>
81{
82 T physR[3];
83 T inside[1];
84 this->_block.getPhysR(physR,input);
85 _indicatorF(inside, physR);
86 return !util::nearZero(inside[0]);
87}
88
89template <typename T, bool HLBM>
91{
92 const T min = -_indicatorF.getCircumRadius();
93 return Vector<int,3> {
94 static_cast<int>(util::floor(min)),
95 static_cast<int>(util::floor(min)),
96 static_cast<int>(util::floor(min))
97 };
98}
99
100template <typename T, bool HLBM>
102{
103 const T max = _indicatorF.getCircumRadius();
104 return Vector<int,3> {
105 static_cast<int>(util::ceil(max)),
106 static_cast<int>(util::ceil(max)),
107 static_cast<int>(util::ceil(max))
108 };
109}
110
111
112template <typename T>
114 BlockGeometry<T,3>& blockGeometry, std::vector<int> materials)
115 : BlockIndicatorF3D<T>(blockGeometry),
116 _materials(materials)
117{ }
118
119template <typename T>
121 BlockGeometry<T,3>& blockGeometry, std::list<int> materials)
122 : BlockIndicatorMaterial3D(blockGeometry,
123 std::vector<int>(materials.begin(), materials.end()))
124{ }
125
126template <typename T>
128 BlockGeometry<T,3>& blockGeometry, int material)
129 : BlockIndicatorMaterial3D(blockGeometry, std::vector<int>(1,material))
130{ }
131
132template <typename T>
133bool BlockIndicatorMaterial3D<T>::operator() (bool output[], const int input[])
134{
135 // read material number explicitly using the const version
136 // of BlockGeometry<T,3>::get to avoid resetting geometry
137 // statistics:
138 const auto& blockGeometry = this->getBlockGeometry();
139 const int current = blockGeometry.getMaterial({input[0], input[1], input[2]});
140 output[0] = std::any_of(_materials.cbegin(),
141 _materials.cend(),
142 [current](int material) {
143 return current == material;
144 });
145
146 return true;
147}
148
149template <typename T>
151{
152 auto& statistics = this->getBlockGeometry().getStatistics();
153
154 return std::none_of(_materials.cbegin(), _materials.cend(),
155 [&statistics](int material) -> bool {
156 return statistics.getNvoxel(material) > 0;
157 });
158}
159
160template <typename T>
162{
163 auto& blockGeometry = this->getBlockGeometry();
164 auto& statistics = blockGeometry.getStatistics();
165
166 Vector<int,3> globalMin{
167 blockGeometry.getNx()+blockGeometry.getPadding()-1,
168 blockGeometry.getNy()+blockGeometry.getPadding()-1,
169 blockGeometry.getNz()+blockGeometry.getPadding()-1,
170 };
171
172 for ( int material : _materials ) {
173 if ( statistics.getNvoxel(material) > 0 ) {
174 const Vector<int,3> localMin = statistics.getMinLatticeR(material);
175 for ( int d = 0; d < 3; ++d ) {
176 globalMin[d] = localMin[d] < globalMin[d] ? localMin[d] : globalMin[d];
177 }
178 }
179 }
180
181 return globalMin;
182}
183
184template <typename T>
186{
187 auto& statistics = this->getBlockGeometry().getStatistics();
188
189 Vector<int,3> globalMax = -this->getBlockGeometry().getPadding();
190
191 for ( int material : _materials ) {
192 if ( statistics.getNvoxel(material) > 0 ) {
193 const Vector<int,3> localMax = statistics.getMaxLatticeR(material);
194 for ( int d = 0; d < 3; ++d ) {
195 globalMax[d] = localMax[d] > globalMax[d] ? localMax[d] : globalMax[d];
196 }
197 }
198 }
199
200 return globalMax;
201}
202
203template <typename T>
205 : BlockIndicatorF3D<T>(indicatorF.getBlockGeometry()),
206 _indicatorF(indicatorF)
207{ }
208
209template <typename T>
210bool BlockIndicatorLayer3D<T>::operator() (bool output[], const int input[])
211{
212 _indicatorF(output, input);
213 for (int iPop=1; iPop < descriptors::D3Q27<>::q; ++iPop) {
214 bool tmpOutput{};
215 Vector<int,3> tmpInput(input);
216 tmpInput += descriptors::c<descriptors::D3Q27<>>(iPop);
217 _indicatorF(&tmpOutput, tmpInput.data());
218 output[0] |= tmpOutput;
219 }
220 return true;
221}
222
223template <typename T>
225{
226 return _indicatorF.getMin()-1;
227}
228
229template <typename T>
231{
232 return _indicatorF.getMax()+1;
233}
234
235template <typename T>
237 : BlockIndicatorF3D<T>(indicatorF.getBlockGeometry()),
238 _indicatorF(indicatorF)
239{ }
240
241template <typename T>
242bool BlockIndicatorIdentity3D<T>::operator() (bool output[], const int input[])
243{
244 return _indicatorF(output, input);
245}
246
247template <typename T>
249{
250 return _indicatorF.getMin();
251}
252
253template <typename T>
255{
256 return _indicatorF.getMax();
257}
258
259
260template <typename T>
266
267template <typename T>
268bool BlockIndicatorMultiplication3D<T>::operator() (bool output[], const int input[])
269{
270 _f(output, input);
271 if (output[0]) {
272 _g(output, input);
273 }
274 return output[0];
275}
276
277template <typename T>
279{
280 auto resF = _f.getMin();
281 auto resG = _g.getMin();
282 return {util::max(resF[0], resG[0]),
283 util::max(resF[1], resG[1]),
284 util::max(resF[2], resG[2])};
285}
286
287template <typename T>
289{
290 auto resF = _f.getMax();
291 auto resG = _g.getMax();
292 return {util::min(resF[0], resG[0]),
293 util::min(resF[1], resG[1]),
294 util::min(resF[2], resG[2])};
295}
296
297
298template <typename T>
300 : BlockIndicatorF3D<T>(indicatorF.getBlockGeometry()),
301 _indicatorF(indicatorF),
302 _overlap(overlap)
303{ }
304
305template <typename T>
306bool BlockIndicatorBoundaryNeighbor3D<T>::operator() (bool output[], const int input[])
307{
308 // check if current position is not solid
309 if ( this->getBlockGeometry().getMaterial(input[0],input[1],input[2]) != 0 ) {
310 // check all neighbors if they are part of boundary via indicator
311 for ( int iXo = -_overlap; iXo <= _overlap; ++iXo ) {
312 for ( int iYo = -_overlap; iYo <= _overlap; ++iYo ) {
313 for ( int iZo = -_overlap; iZo <= _overlap; ++iZo ) {
314 const int neighborPos[3] = {iXo + input[0], iYo + input[1], iZo + input[2]};
315 bool partOfBoundary[1] = {false};
316 // material-indicator to check if part of boundary
317 _indicatorF( partOfBoundary, neighborPos );
318 if ( partOfBoundary[0] ) {
319 return true;
320 }
321 }
322 }
323 }
324 }
325 return false;
326}
327
328template <typename T>
330{
331 return _indicatorF.getMin() - _overlap;
332}
333
334template <typename T>
336{
337 return _indicatorF.getMax() + _overlap;
338}
339
340} // namespace olb
341
342#endif
Representation of a block geometry.
Vector< int, 3 > getMax() override
Returns max lattice position of the indicated domain's bounding box.
Vector< int, 3 > getMin() override
Returns min lattice position of the indicated domain's bounding box.
bool operator()(bool output[], const int input[]) override
BlockIndicatorBoundaryNeighbor3D(BlockIndicatorF3D< T > &indicatorF, int overlap)
Base block indicator functor.
bool operator()(bool output[], const int input[]) override
Vector< int, 3 > getMax() override
Returns max lattice position of the indicated domain's bounding box.
BlockIndicatorFfromIndicatorF3D(IndicatorF3D< T > &indicatorF, BlockGeometry< T, 3 > &blockGeometry)
Vector< int, 3 > getMin() override
Returns min lattice position of the indicated domain's bounding box.
Vector< int, 3 > getMin() override
Returns min lattice position of the indicated domain's bounding box.
BlockIndicatorFfromSmoothIndicatorF3D(SmoothIndicatorF3D< T, T, HLBM > &indicatorF, BlockGeometry< T, 3 > &blockGeometry)
Vector< int, 3 > getMax() override
Returns max lattice position of the indicated domain's bounding box.
bool operator()(bool output[], const int input[]) override
bool operator()(bool output[], const int input[]) override
Vector< int, 3 > getMax() override
Returns max lattice position of the indicated domain's bounding box.
Vector< int, 3 > getMin() override
Returns min lattice position of the indicated domain's bounding box.
BlockIndicatorIdentity3D(BlockIndicatorF3D< T > &indicatorF)
Vector< int, 3 > getMin() override
Returns min lattice position of the indicated domain's bounding box.
bool operator()(bool output[], const int input[]) override
Vector< int, 3 > getMax() override
Returns max lattice position of the indicated domain's bounding box.
BlockIndicatorLayer3D(BlockIndicatorF3D< T > &indicatorF)
Block indicator functor from material numbers.
BlockIndicatorMaterial3D(BlockGeometry< T, 3 > &blockGeometry, std::vector< int > materials)
Vector< int, 3 > getMin() override
Returns min lattice position of the indicated domain's bounding box.
bool isEmpty() override
Returns true iff indicated domain subset is empty.
bool operator()(bool output[], const int input[]) override
Vector< int, 3 > getMax() override
Returns max lattice position of the indicated domain's bounding box.
Vector< int, 3 > getMax() override
Returns max lattice position of the indicated domain's bounding box.
BlockIndicatorMultiplication3D(BlockIndicatorF3D< T > &f, BlockIndicatorF3D< T > &g)
bool operator()(bool output[], const int input[]) override
Vector< int, 3 > getMin() override
Returns min lattice position of the indicated domain's bounding box.
IndicatorF3D is an application from .
Plain old scalar vector.
Definition vector.h:47
constexpr const T * data() const any_platform
Definition vector.h:161
ADf< T, DIM > ceil(const ADf< T, DIM > &a)
Definition aDiff.h:900
ADf< T, DIM > floor(const ADf< T, DIM > &a)
Definition aDiff.h:869
cpu::simd::Pack< T > min(cpu::simd::Pack< T > rhs, cpu::simd::Pack< T > lhs)
Definition pack.h:124
cpu::simd::Pack< T > max(cpu::simd::Pack< T > rhs, cpu::simd::Pack< T > lhs)
Definition pack.h:130
bool nearZero(const ADf< T, DIM > &a)
Definition aDiff.h:1087
Top level namespace for all of OpenLB.
Set of functions commonly used in LB computations – header file.