summaryrefslogtreecommitdiff
path: root/src/functors/analytical/indicator/indicCalc2D.h
blob: a5f644944efb28f876365d3c16733ace3832c47c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
/*  This file is part of the OpenLB library
 *
 *  Copyright (C) 2014-2016 Mathias J. Krause, Cyril Masquelier,
 *  Benjamin Förster, Albert Mink
 *  E-mail contact: info@openlb.net
 *  The most recent release of OpenLB can be downloaded at
 *  <http://www.openlb.net/>
 *
 *  This program is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU General Public License
 *  as published by the Free Software Foundation; either version 2
 *  of the License, or (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public
 *  License along with this program; if not, write to the Free
 *  Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 *  Boston, MA  02110-1301, USA.
*/

#ifndef INDIC_CALC_2D_H
#define INDIC_CALC_2D_H

#include "indicatorBaseF2D.h"
#include "utilities/arithmetic.h"

namespace olb {


/*
 *  arithmetic helper classes for IndicatorF1D, IndicatorF2D, smoothIndicator2D
 *  UNION         +
 *  WITHOUT       -
 *  INTERSECTION  *
*/

//////////////////////////////// IndicCalc1D ////////////////////////////////
/// arithmetic helper class for Indicator 1d functors
template <typename S>
class IndicCalc1D : public IndicatorF1D<S> {
protected:
  IndicatorF1D<S>& _f;
  IndicatorF1D<S>& _g;
public:
  // set image/target dimensions of IndicCalc1D as well
  IndicCalc1D(IndicatorF1D<S>& f, IndicatorF1D<S>& g);
};

/// addition functor acts as union
template <typename S>
class IndicPlus1D : public IndicCalc1D<S> {
public:
  IndicPlus1D(IndicatorF1D<S>& f, IndicatorF1D<S>& g);
  bool operator() (bool output[], const S input[]) override;
};

/// subtraction functor acts as without
template <typename S>
class IndicMinus1D : public IndicCalc1D<S> {
public:
  IndicMinus1D(IndicatorF1D<S>& f, IndicatorF1D<S>& g);
  bool operator() (bool output[], const S input[]) override;
};

/// multiplication functor acts as intersection
template <typename S>
class IndicMultiplication1D : public IndicCalc1D<S> {
public:
  IndicMultiplication1D(IndicatorF1D<S>& f, IndicatorF1D<S>& g);
  bool operator() (bool output[], const S input[]) override;
};



//////////////////////////////// indicCalc2D ////////////////////////////////
/// arithmetic helper class for Indicator 2D functors
template <typename S, template<typename U> class F>
class IndicCalc2D : public IndicatorF2D<S> {
protected:
  std::shared_ptr<IndicatorF2D<S>> _f;
  std::shared_ptr<IndicatorF2D<S>> _g;
public:
  IndicCalc2D( std::shared_ptr<IndicatorF2D<S>> f, std::shared_ptr<IndicatorF2D<S>> g );

  bool operator() (bool output[], const S input[2]) override;
};

/// Addition functor (W==bool: Union)
template <typename S>
using IndicPlus2D = IndicCalc2D<S,util::plus>;
template <typename S>
using IndicMinus2D = IndicCalc2D<S,util::minus>;
template <typename S>
using IndicMultiplication2D = IndicCalc2D<S,util::multiplies>;

template<typename S, template <typename U> class F1, template <typename V> class F2,
         typename=typename std::enable_if<std::is_base_of<IndicatorF2D<S>, F1<S>>::value>::type>
std::shared_ptr<IndicatorF2D<S>> operator+(std::shared_ptr<F1<S>> lhs, std::shared_ptr<F2<S>> rhs);

template<typename S, template <typename U> class F1, template <typename V> class F2,
         typename=typename std::enable_if<std::is_base_of<IndicatorF2D<S>, F1<S>>::value>::type>
std::shared_ptr<IndicatorF2D<S>> operator-(std::shared_ptr<F1<S>> lhs, std::shared_ptr<F2<S>> rhs);

template<typename S, template <typename U> class F1, template <typename V> class F2,
         typename=typename std::enable_if<std::is_base_of<IndicatorF2D<S>, F1<S>>::value>::type>
std::shared_ptr<IndicatorF2D<S>> operator*(std::shared_ptr<F1<S>> lhs, std::shared_ptr<F2<S>> rhs);

template<typename S, template <typename U> class F1, template <typename V> class F2,
         typename=typename std::enable_if<std::is_base_of<IndicatorIdentity2D<S>, F1<S>>::value>::type>
std::shared_ptr<IndicatorF2D<S>> operator+(F1<S> & lhs, std::shared_ptr<F2<S>> rhs);

template<typename S, template <typename U> class F1, template <typename V> class F2,
         typename=typename std::enable_if<std::is_base_of<IndicatorIdentity2D<S>, F1<S>>::value>::type>
std::shared_ptr<IndicatorF2D<S>> operator-(F1<S> & lhs, std::shared_ptr<F2<S>> rhs);

template<typename S, template <typename U> class F1, template <typename V> class F2,
         typename=typename std::enable_if<std::is_base_of<IndicatorIdentity2D<S>, F1<S>>::value>::type>
std::shared_ptr<IndicatorF2D<S>> operator*(F1<S> & lhs, std::shared_ptr<F2<S>> rhs);


} // end namespace olb

#endif