summaryrefslogtreecommitdiff
path: root/src/functors/lattice/superBaseF2D.h
blob: 4b5b1b55ed1105f058dc697b58f2bf0b3ae03b5c (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
/*  This file is part of the OpenLB library
 *
 *  Copyright (C) 2012 Lukas Baron, Tim Dornieden, 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 SUPER_BASE_F_2D_H
#define SUPER_BASE_F_2D_H

#include <memory>

#include "functors/genericF.h"
#include "blockBaseF2D.h"
#include "communication/superStructure2D.h"
#include "core/superData2D.h"
#include "core/superLattice2D.h"

/** 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 {

template<typename T, typename DESCRIPTOR> class SuperLattice2D;
template<typename T, typename BaseType> class SuperData2D;
template<typename T> class SuperStructure2D;
template<typename T, typename W> class SuperIdentity2D;
template<typename T> class BlockF2D;

/// represents all functors that operate on a SuperStructure2D<T> in general
template <typename T, typename W = T>
class SuperF2D : public GenericF<W, int> {
protected:
  SuperF2D(SuperStructure2D<T>& superStructure, int targetDim);

  SuperStructure2D<T>& _superStructure;
  /// Super functors may consist of several BlockF2D<W> derived functors
  /**
   * By convention: If block level functors are used at all they should
   * number exactly LoadBalancer<T>::size per process.
   **/
  std::vector<std::unique_ptr<BlockF2D<W>>> _blockF;
public:
  using identity_functor_type = SuperIdentity2D<T,W>;

  SuperF2D<T,W>& operator-(SuperF2D<T,W>& rhs);
  SuperF2D<T,W>& operator+(SuperF2D<T,W>& rhs);
  SuperF2D<T,W>& operator*(SuperF2D<T,W>& rhs);
  SuperF2D<T,W>& operator/(SuperF2D<T,W>& rhs);

  /// \return _superStructure
  SuperStructure2D<T>& getSuperStructure();
  /// \return Size of SuperF3D<T,W>::_blockF vector
  int getBlockFSize() const;
  /// \return _blockF[iCloc]
  BlockF2D<W>& getBlockF(int iCloc);
};


/// Functor from `SuperData2D`
template<typename T, typename BaseType>
class SuperDataF2D : public SuperF2D<T,BaseType> {
protected:
  /// `SuperData2D` object this functor was created from
  SuperData2D<T,BaseType>& _superData;
public:
  /// Constructor from `SuperData2D` - stores `_superData` reference
  SuperDataF2D(SuperData2D<T,BaseType>& superData);
  /// Operator for this functor - copies data from `_superData` object into output
  bool operator() (BaseType output[], const int input[]);
  /// Getter for `_superData`
  SuperData2D<T,BaseType>& getSuperData();
};

/// identity functor for memory management
template <typename T, typename W>
class SuperIdentity2D : public SuperF2D<T,W> {
protected:
  FunctorPtr<SuperF2D<T,W>> _f;
public:
  SuperIdentity2D(FunctorPtr<SuperF2D<T,W>>&& f);
  bool operator() (W output[], const int input[]) override;
};

/// represents all functors that operate on a SuperLattice in general, e.g. getVelocity(), getForce(), getPressure()
template <typename T, typename DESCRIPTOR>
class SuperLatticeF2D : public SuperF2D<T,T> {
protected:
  SuperLatticeF2D(SuperLattice2D<T,DESCRIPTOR>& superLattice, int targetDim);

  SuperLattice2D<T,DESCRIPTOR>& _sLattice;
public:
  SuperLattice2D<T,DESCRIPTOR>& getSuperLattice();
};

/// represents all functors that operate on a DESCRIPTOR with output in Phys, e.g. physVelocity(), physForce(), physPressure()
template <typename T, typename DESCRIPTOR>
class SuperLatticePhysF2D : public SuperLatticeF2D<T,DESCRIPTOR> {
protected:
  SuperLatticePhysF2D(SuperLattice2D<T,DESCRIPTOR>& sLattice,
                      const UnitConverter<T,DESCRIPTOR>& converter, int targetDim);
  const UnitConverter<T,DESCRIPTOR>& _converter;
public:
  UnitConverter<T,DESCRIPTOR> const& getConverter() const;
};

/// 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 SuperLatticeThermalPhysF2D : public SuperLatticeF2D<T,TDESCRIPTOR> {
protected:
  SuperLatticeThermalPhysF2D(SuperLattice2D<T,TDESCRIPTOR>& sLattice,
                             const ThermalUnitConverter<T,DESCRIPTOR,TDESCRIPTOR>& converter, int targetDim);
  const ThermalUnitConverter<T,DESCRIPTOR,TDESCRIPTOR>& _converter;
public:
  ThermalUnitConverter<T,DESCRIPTOR,TDESCRIPTOR> const& getConverter() const;
};

} // end namespace olb

#endif