OpenLB 1.7
Loading...
Searching...
No Matches
blockDiscretizationF2D.hh
Go to the documentation of this file.
1/* This file is part of the OpenLB library
2 *
3 * Copyright (C) 2019 Tom Braun
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_DISCRETIZATION_F_2D_HH
25#define BLOCK_DISCRETIZATION_F_2D_HH
26
28#include <algorithm>
29
30namespace olb {
31
32template <typename T>
34 T bottomBoundary,
35 T topBoundary,
36 int n)
37 :BlockF2D<T>(f.getBlockStructure(),f.getTargetDim()),_f(f),_bottomBoundary(bottomBoundary),_topBoundary(topBoundary),_n(n)
38{
39 this->getName() = "Discretization(" + _f.getName() + " ) ";
40}
41
42template <typename T>
43bool BlockDiscretizationF2D<T>::operator()(T output[], const int input[])
44{
45 const T delta = (_topBoundary - _bottomBoundary) / (util::max(_n-1,1));
46 _f(output, input);
47
48 for (int i=0; i < _f.getTargetDim(); ++i) {
49 if ( output[i] <= _bottomBoundary ) {
50 output[i] = _bottomBoundary;
51 }
52 else if ( output[i] >= _topBoundary ) {
53 output[i] = _topBoundary;
54 }
55 else if ( _n != 1 ) {
56 output[i] -= _bottomBoundary;
57 output[i] = _bottomBoundary + std::nearbyint(output[i] / delta) * delta;
58 }
59 }
60
61 return true;
62}
63
64}
65#endif
bool operator()(T output[], const int input[])
has to be implemented for 'every' derived class
BlockDiscretizationF2D(BlockF2D< T > &f, T bottomBoundary, T topBoundary, int n)
represents all functors that operate on a cuboid in general, mother class of BlockLatticeF,...
std::string & getName()
read and write access to name
Definition genericF.hh:51
cpu::simd::Pack< T > max(cpu::simd::Pack< T > rhs, cpu::simd::Pack< T > lhs)
Definition pack.h:130
Top level namespace for all of OpenLB.