OpenLB 1.7
Loading...
Searching...
No Matches
indicatorFromBlockDataF3D.hh
Go to the documentation of this file.
1/* This file is part of the OpenLB library
2 *
3 * Copyright (C) 2021 Nicolas Hafen, Mathias J. Krause
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 INDICATOR_FROM_BLOCKDATA_F_3D_HH
25#define INDICATOR_FROM_BLOCKDATA_F_3D_HH
26
27namespace olb {
28
29template <typename S>
31 BlockData<3,S,S>& blockData,
32 Vector<S,3> extend, Vector<S,3> origin,
33 S deltaR, bool invert)
34 : _blockData(blockData), _deltaR(deltaR), _invert(invert)
35{
36 this->_myMin = origin;
37 this->_myMax = origin + extend;
38}
39
40
41template <typename S>
42bool IndicatorBlockData3D<S>::operator()(bool output[], const S input[])
43{
44
45 // Translation
46 S xDist = input[0] - this->_myMin[0];
47 S yDist = input[1] - this->_myMin[1];
48 S zDist = input[2] - this->_myMin[2];
49
50 int x = ((this->_myMin[0] + xDist)/_deltaR)+0.5;
51 int y = ((this->_myMin[1] + yDist)/_deltaR)+0.5;
52 int z = ((this->_myMin[2] + zDist)/_deltaR)+0.5;
53
54 if (x >= 0 && x < _blockData.getNx() && y >= 0 && y < _blockData.getNy() && z >= 0 && z < _blockData.getNz()) {
55 LatticeR<3> input(x,y,z);
56 if (this->_blockData.get(input) > std::numeric_limits<S>::epsilon()) {
57 if (!_invert){
58 output[0] = S(this->_blockData.get(input));
59 return true;
60 } else {
61 output[0] = S(0);
62 return false;
63 }
64 }
65 }
66 if (!_invert){
67 output[0] = S(0);
68 return false;
69 } else {
70 output[0] = 1.-S(this->_blockData.get(input));
71 return true;
72 }
73}
74
75
76} // namespace olb
77
78
79#endif
bool operator()(bool output[], const S input[]) override
returns true if input is inside, otherwise false
IndicatorBlockData3D(BlockData< 3, S, S > &blockData, Vector< S, 3 > extend, Vector< S, 3 > origin, S deltaR, bool invert=false)
constructor
Vector< S, 3 > _myMin
Vector< S, 3 > _myMax
Plain old scalar vector.
Definition vector.h:47
Top level namespace for all of OpenLB.