summaryrefslogtreecommitdiff
path: root/src/functors/lattice/blockBaseF3D.h
blob: d64ff504d3aee3322b449699d0248ec9dbb5fc00 (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
/*  This file is part of the OpenLB library
 *
 *  Copyright (C) 2012 Lukas Baron, Mathias J. Krause, 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 BLOCK_BASE_F_3D_H
#define BLOCK_BASE_F_3D_H

#include "functors/genericF.h"
#include "core/blockData3D.h"
#include "core/blockStructure3D.h"
#include "core/blockLatticeStructure3D.h"
#include "core/unitConverter.h"

#include <memory>

/** Note: Throughout the whole source code directory genericFunctions, the
 *  template parameters for i/o dimensions are:
 *           F: S^m -> T^n  (S=source, T=target)
 */

namespace olb {


/// represents all functors that operate on a cuboid in general, mother class of BlockLatticeF, ..
template <typename T>
class BlockF3D : public GenericF<T,int> {
protected:
  BlockF3D(BlockStructure3D& blockStructure, int targetDim);
  BlockStructure3D& _blockStructure;
public:
  /// virtual destructor for defined behaviour
  ~BlockF3D() override {};
  virtual BlockStructure3D& getBlockStructure() const;

  std::vector<T> getMinValue();
  std::vector<T> getMaxValue();

  BlockF3D<T>& operator-(BlockF3D<T>& rhs);
  BlockF3D<T>& operator+(BlockF3D<T>& rhs);
  BlockF3D<T>& operator*(BlockF3D<T>& rhs);
  BlockF3D<T>& operator/(BlockF3D<T>& rhs);
};

/// BlockDataF3D can store data of any BlockFunctor3D
template <typename T, typename BaseType>
class BlockDataF3D : public BlockF3D<BaseType> {
protected:
  BlockDataF3D(int nx, int ny, int nz, int size=1);

  std::unique_ptr<BlockData3D<T,BaseType>> _blockDataStorage;
  BlockData3D<T,BaseType>&                 _blockData;
public:
  /// Constructor
  BlockDataF3D(BlockData3D<T,BaseType>& blockData);
  /// to store functor data, constuctor creates _blockData with functor data
  BlockDataF3D(BlockF3D<BaseType>& f);
  /// returns _blockData
  BlockData3D<T,BaseType>& getBlockData();
  /// access to _blockData via its get()
  bool operator() (BaseType output[], const int input[]) override;
};

/// Overlap-aware version of BlockDataF3D for usage in SuperDataF3D
template <typename T, typename BaseType>
class BlockDataViewF3D : public BlockDataF3D<T,BaseType> {
private:
  const int _overlap;
public:
  BlockDataViewF3D(BlockData3D<T,BaseType>& blockData, int overlap);
  /// access to _blockData shifted by overlap
  bool operator() (BaseType output[], const int input[]) override;
};

/// identity functor
template <typename T>
class BlockIdentity3D final : public BlockF3D<T> {
protected:
  BlockF3D<T>& _f;
public:
  BlockIdentity3D(BlockF3D<T>& f);
  // access operator should not delete f, since f still has the identity as child
  bool operator() (T output[], const int input[]) override;
};

/// functor to extract one component
template <typename T>
class BlockExtractComponentF3D : public BlockF3D<T> {
protected:
  BlockF3D<T>& _f;
  int _extractDim;
public:
  BlockExtractComponentF3D(BlockF3D<T>& f, int extractDim);
  int getExtractDim();
  bool operator() (T output[], const int input[]);
};

/// functor to extract one component inside an indicator
template <typename T>
class BlockExtractComponentIndicatorF3D : public BlockExtractComponentF3D<T> {
protected:
  BlockIndicatorF3D<T>& _indicatorF;
public:
  BlockExtractComponentIndicatorF3D(BlockF3D<T>& f, int extractDim,
                                    BlockIndicatorF3D<T>& indicatorF);
  bool operator() (T output[], const int input[]) override;
};

/// functor to extract data inside an indicator
template <typename T>
class BlockExtractIndicatorF3D : public BlockF3D<T> {
protected:
  BlockF3D<T>&          _f;
  BlockIndicatorF3D<T>& _indicatorF;
public:
  BlockExtractIndicatorF3D(BlockF3D<T>& f,
                           BlockIndicatorF3D<T>& indicatorF);
  bool operator() (T output[], const int input[]);
};

/// functor to extract one component
template <typename T>
class BlockDotProductF3D : public BlockF3D<T> {
protected:
  BlockF3D<T>& _f;
  T _vector[];
public:
  BlockDotProductF3D(BlockF3D<T>& f, T vector[]);
  bool operator() (T output[], const int input[]);
};


/// represents all functors that operate on a DESCRIPTOR in general, e.g. getVelocity(), getForce(), getPressure()
template <typename T, typename DESCRIPTOR>
class BlockLatticeF3D : public BlockF3D<T> {
protected:
  BlockLatticeF3D(BlockLatticeStructure3D<T,DESCRIPTOR>& blockLattice, int targetDim);
  BlockLatticeStructure3D<T,DESCRIPTOR>& _blockLattice;
public:
  /// Copy Constructor
  //BlockLatticeF3D(BlockLatticeF3D<T,DESCRIPTOR> const& rhs);
  /// Assignment Operator
  //BlockLatticeF3D<T,DESCRIPTOR>& operator=(BlockLatticeF3D<T,DESCRIPTOR> const& rhs);

  BlockLatticeStructure3D<T,DESCRIPTOR>& getBlockLattice();
};


/// identity functor
template <typename T, typename DESCRIPTOR>
class BlockLatticeIdentity3D final : public BlockLatticeF3D<T,DESCRIPTOR> {
protected:
  BlockLatticeF3D<T,DESCRIPTOR>& _f;
public:
  BlockLatticeIdentity3D(BlockLatticeF3D<T,DESCRIPTOR>& f);
  bool operator() (T output[], const int input[]) override;
};


/// represents all functors that operate on a DESCRIPTOR with output in Phys, e.g. physVelocity(), physForce(), physPressure()
template <typename T, typename DESCRIPTOR>
class BlockLatticePhysF3D : public BlockLatticeF3D<T,DESCRIPTOR> {
protected:
  const UnitConverter<T,DESCRIPTOR>& _converter;
  BlockLatticePhysF3D(BlockLatticeStructure3D<T,DESCRIPTOR>& blockLattice,
                      const UnitConverter<T,DESCRIPTOR>& converter, int targetDim);
public:
  /// Copy Constructor
  //BlockLatticePhysF3D(BlockLatticePhysF3D<T,DESCRIPTOR> const& rhs);
  /// Assignment Operator
  //BlockLatticePhysF3D<T,DESCRIPTOR>& operator=(BlockLatticePhysF3D<T,DESCRIPTOR> const& rhs);
};

/// represents all thermal functors that operate on a DESCRIPTOR with output in Phys, e.g. physTemperature(), physHeatFlux()
template <typename T, typename DESCRIPTOR, typename TDESCRIPTOR>
class BlockLatticeThermalPhysF3D : public BlockLatticeF3D<T,TDESCRIPTOR> {
protected:
  BlockLatticeThermalPhysF3D(BlockLatticeStructure3D<T,TDESCRIPTOR>& blockLattice,
                             const ThermalUnitConverter<T,DESCRIPTOR,TDESCRIPTOR>& converter, int targetDim);
  const ThermalUnitConverter<T,DESCRIPTOR,TDESCRIPTOR>& _converter;
};


} // end namespace olb

#endif