summaryrefslogtreecommitdiff
path: root/src/functors/lattice/reductionF3D.h
blob: 38a83c5051f11814e400f4f6e2d8373b3972e986 (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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
/*  This file is part of the OpenLB library
 *
 *  Copyright (C) 2012-2017 Lukas Baron, Tim Dornieden, Mathias J. Krause,
 *  Albert Mink, Benjamin Förster, Adrian Kummerlaender
 *  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 REDUCTION_F_3D_H
#define REDUCTION_F_3D_H

#include "blockBaseF3D.h"
#include "superBaseF3D.h"
#include "geometry/cuboidGeometry3D.h"
#include "geometry/blockGeometry3D.h"
#include "geometry/superGeometry3D.h"
#include "functors/analytical/analyticalF.h"

namespace olb {


/// Functor used to convert analytical functions to lattice functions
/**
 *  Input functions are interpreted as SI->SI units, the resulting lattice
 *  function will map lattice->lattice units
 */
template <typename T, typename DESCRIPTOR>
class SuperLatticeFfromAnalyticalF3D final : public SuperLatticeF3D<T,DESCRIPTOR> {
protected:
  FunctorPtr<AnalyticalF3D<T,T>> _f;
public:
  /**
   * \param f        Analytical functor to be converted into a lattice functor
   * \param sLattice DESCRIPTOR reference required for conversion and block functor construction
   **/
  SuperLatticeFfromAnalyticalF3D(FunctorPtr<AnalyticalF3D<T,T>>&& f,
                                 SuperLattice3D<T,DESCRIPTOR>&    sLattice);
  bool operator() (T output[], const int input[]) override;
};


/// Block level functor for conversion of analytical to lattice functors.
/**
 * Instances are contained in SuperLatticeFfromAnalyticalF3D::_blockF.
 **/
template <typename T, typename DESCRIPTOR>
class BlockLatticeFfromAnalyticalF3D final : public BlockLatticeF3D<T,DESCRIPTOR> {
protected:
  AnalyticalF3D<T,T>& _f;
  Cuboid3D<T>&        _cuboid;
public:
  /**
   * \param f       Analytical functor to be converted into a lattice functor
   * \param lattice Block lattice structure required for BlockLatticeF3D construction
   * \param cuboid  Cuboid reference required for input parameter conversion
   **/
  BlockLatticeFfromAnalyticalF3D(AnalyticalF3D<T,T>&                    f,
                                 BlockLatticeStructure3D<T,DESCRIPTOR>& lattice,
                                 Cuboid3D<T>&                           cuboid);
  bool operator() (T output[], const int input[]) override;
};

//////////// not yet working // symbolically ///////////////////
////////////////////////////////////////////////
template <typename T, typename DESCRIPTOR>
class SmoothBlockIndicator3D final : public BlockDataF3D<T,T> {
protected:
  IndicatorF3D<T>&  _f;
  T _h;
  T _eps;
  /*
  * int _wa (weight accuracy): to change the size of the weights array, 3 should be enough, 7 & 5 is more accurate.
  * only use these sizes: 3, 5, 7, 9, ... (still 3 or 5 is recommended)
  * more testing has to be done
  * the size of the weights matrix affects the particle size, therefore it has to be known earlier, to calculate the BlockData size
  *
  * Note: wa influences the boundary size. Maybe unify eps-boundary size somehow.
  */
  int _wa;
public:
  SmoothBlockIndicator3D(IndicatorF3D<T>& f, T h, T eps, int wa = 3);
  //bool operator() (T output[], const int input[]);
};

// TODO: comment code
template <typename T, typename DESCRIPTOR>
class BlockLatticeInterpPhysVelocity3Degree3D final : public
  BlockLatticeF3D<T,DESCRIPTOR> {
protected:
  UnitConverter<T,DESCRIPTOR>& _conv;
  Cuboid3D<T>* _cuboid;
  int _overlap;
  int _range;
public:
  BlockLatticeInterpPhysVelocity3Degree3D(
    BlockLatticeStructure3D<T,DESCRIPTOR>& blockLattice,
    UnitConverter<T,DESCRIPTOR>& conv, Cuboid3D<T>* c, int overlap, int range);
  BlockLatticeInterpPhysVelocity3Degree3D(
    const BlockLatticeInterpPhysVelocity3Degree3D<T,DESCRIPTOR>& rhs);
  bool operator() (T output[], const int input[]) override
  {
    return false;
  }
  void operator() (T output[], const T input[]);
};

// TODO: comment code
template <typename T, typename DESCRIPTOR>
class SuperLatticeInterpPhysVelocity3Degree3D final : public
  SuperLatticeF3D<T,DESCRIPTOR> {
private:
  std::vector<BlockLatticeInterpPhysVelocity3Degree3D<T,DESCRIPTOR>* > _bLattices;
public:
  SuperLatticeInterpPhysVelocity3Degree3D(
    SuperLattice3D<T,DESCRIPTOR>& sLattice, UnitConverter<T,DESCRIPTOR>& conv,
    int range=1);
  bool operator() (T output[], const int input[]) override
  {
    return 0;
  }
  void operator()(T output[], const T input[], const int iC);
};

// TODO: comment code
template <typename T, typename DESCRIPTOR>
class BlockLatticeInterpDensity3Degree3D final : public
  BlockLatticeF3D<T,DESCRIPTOR> {
protected:
  BlockGeometryStructure3D<T>& _blockGeometry;
  UnitConverter<T,DESCRIPTOR>& _conv;
  Cuboid3D<T>* _cuboid;
  int _overlap;
  int _range; // degree of interpolation can be changed (2,3,4,...)
public:
  BlockLatticeInterpDensity3Degree3D(
    BlockLatticeStructure3D<T,DESCRIPTOR>& blockLattice,
    BlockGeometryStructure3D<T>& blockGeometry,
    UnitConverter<T,DESCRIPTOR>& conv, Cuboid3D<T>* c, int overlap, int range);
  BlockLatticeInterpDensity3Degree3D(
    const BlockLatticeInterpDensity3Degree3D<T,DESCRIPTOR>& rhs);
  bool operator() (T output[], const int input[]) override
  {
    return false;
  }
  void operator() (T output[DESCRIPTOR::q], const T input[3]);
};

// TODO: comment code
template <typename T, typename DESCRIPTOR>
class SuperLatticeInterpDensity3Degree3D final : public
  SuperLatticeF3D<T,DESCRIPTOR> {
private:
  std::vector<BlockLatticeInterpDensity3Degree3D<T,DESCRIPTOR>* > _bLattices;
public:
  SuperLatticeInterpDensity3Degree3D(SuperLattice3D<T,DESCRIPTOR>& sLattice,
                                     SuperGeometry3D<T>& sGeometry,
                                     UnitConverter<T,DESCRIPTOR>& conv, int range=1);
  ~SuperLatticeInterpDensity3Degree3D() override;
  // range equals degree of interpolation and can be changed (2,3,4,...)
  bool operator() (T output[], const int input[]) override
  {
    return 0;
  }
  void operator()(T output[], const T input[], const int iC);
};

// TODO: comment code
template <typename T, typename DESCRIPTOR>
class BlockLatticeSmoothDiracDelta3D final : public
  BlockLatticeF3D<T,DESCRIPTOR> {
protected:
  UnitConverter<T,DESCRIPTOR>& _conv;
  Cuboid3D<T>* _cuboid;
public:
  BlockLatticeSmoothDiracDelta3D(BlockLattice3D<T,DESCRIPTOR>& blockLattice,
                                 UnitConverter<T,DESCRIPTOR>& conv, Cuboid3D<T>* c);
  BlockLatticeSmoothDiracDelta3D(
    const BlockLatticeSmoothDiracDelta3D<T,DESCRIPTOR>& rhs);
  bool operator() (T output[], const int input[]) override
  {
    return false;
  }
  void operator() (T delta[4][4][4], const T physPosP[3]);
};

// TODO: comment code
template <typename T, typename DESCRIPTOR>
class SuperLatticeSmoothDiracDelta3D final : public
  SuperLatticeF3D<T,DESCRIPTOR> {
private:
  std::vector<BlockLatticeSmoothDiracDelta3D<T,DESCRIPTOR>* > _bLattices;
public:
  SuperLatticeSmoothDiracDelta3D(SuperLattice3D<T, DESCRIPTOR>& sLattice,
                                 UnitConverter<T,DESCRIPTOR>& conv,
                                 SuperGeometry3D<T>& superGeometry);
  ~SuperLatticeSmoothDiracDelta3D() override;
  bool operator()(T output[], const int input[]) override
  {
    return false;
  };
  void operator()(T delta[4][4][4], const T physPos[3], const int iC);
};


} // end namespace olb

#endif