summaryrefslogtreecommitdiff
path: root/src/functors/analytical/indicator/indicatorF2D.h
blob: bfff8dd7a84fd2c01c1c064414a6729c47bb8794 (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
/*  This file is part of the OpenLB library
 *
 *  Copyright (C) 2016 Thomas Henn, Cyril Masquelier, Jan Marquardt, Mathias J. Krause,
 *  Davide Dapelo
 *  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 INDICATOR_F_2D_H
#define INDICATOR_F_2D_H

#include<vector>
#include "indicatorBaseF2D.h"
#include "io/xmlReader.h"

#include "core/blockData2D.h"
#include "core/unitConverter.h"
#include "indicatorBaseF3D.h"

/** \file
 * This file contains indicator functions. These return 1 if the given
 * coordinates are inside, and 0 if they are outside of the defined set.
 * Implemented are :
 - Cuboid
 - Circle

 * The smoothIndicator functors return values in [0,1]. In particular there is
 * an epsilon enclosure of the set, wherein the return values are smooth and do
 * not jump from 0 to 1.

 Boolean operators allow to create unions and intersections. They can be used
 for example for initialization of a SuperGeometry.
*/

namespace olb {

/// indicator function for a 2D-cuboid, parallel to the planes x=0, y=0;
/// theta rotates cuboid around its center, theta in radian measure
template <typename S>
class IndicatorF2DfromIndicatorF3D : public IndicatorF2D<S> {
private:
  IndicatorF3D<S>& _indicator3D;
public:
  IndicatorF2DfromIndicatorF3D(IndicatorF3D<S>& indicator3D);

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

/// indicator function for a 2D-cuboid, parallel to the planes x=0, y=0;
/// theta rotates cuboid around its center, theta in radian measure
template <typename S>
class IndicatorCuboid2D : public IndicatorF2D<S> {
private:
  Vector<S,2> _center;
  S _xLength;
  S _yLength;
  S _theta;
public:
  /// constructs an cuboid with x axis dimension 0 to extend[0], ...
  IndicatorCuboid2D(Vector<S,2> extend, Vector<S,2> origin, S theta=0);
  /// constructs an cuboid with x axis dimension -xlength/2 to xlength/2
  IndicatorCuboid2D(S xlength, S ylength, Vector<S,2> center= {S(), S()}, S theta=0);
  /// returns true if input is inside, otherwise false
  bool operator() (bool output[], const S input[]) override;
};


/// indicator function for a 2D circle
template <typename S>
class IndicatorCircle2D : public IndicatorF2D<S> {
private:
  Vector<S,2> _center;
  S _radius2;
public:
  IndicatorCircle2D(Vector<S,2> center, S radius);
  bool operator() (bool output[], const S input[]) override;
  bool distance(S& distance, const Vector<S,2>& origin, const Vector<S,2>& direction,  int iC=-1) override;
  bool normal(Vector<S,2>& normal, const Vector<S,2>& origin, const Vector<S,2>& direction, int iC=-1) override;
};

/// Indicator function creating an layer around an input indicator (for positive \p layerSize) or
/// reducing the input indicator by a layer (for negative \p layerSize).
/// \param[in] indicatorF - some indicator (e.g. IndicatorCircle2D) 
/// \param[in] layerSize - size of the layer (can be negative) [physical units]
template <typename S>
class IndicatorLayer2D : public IndicatorF2D<S> {
private:
  IndicatorF2D<S>& _indicatorF;
  S _layerSize;
  bool _isPositive;
public:
  IndicatorLayer2D(IndicatorF2D<S>& indicatorF, S layerSize);
  bool operator() (bool output[], const S input[]) override;
};


/////////creatorFunctions//////////////////////
template <typename S>
IndicatorCuboid2D<S>* createIndicatorCuboid2D(XMLreader const& params, bool verbose=false);

template <typename S>
IndicatorCircle2D<S>* createIndicatorCircle2D(XMLreader const& params, bool verbose=false);


}

#endif