OpenLB 1.7
Loading...
Searching...
No Matches
superBaseF2D.hh
Go to the documentation of this file.
1/* This file is part of the OpenLB library
2 *
3 * Copyright (C) 2012 Lukas Baron, Tim Dornieden, Mathias J. Krause,
4 * Albert Mink
5 * E-mail contact: info@openlb.net
6 * The most recent release of OpenLB can be downloaded at
7 * <http://www.openlb.net/>
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public
20 * License along with this program; if not, write to the Free
21 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
22 * Boston, MA 02110-1301, USA.
23*/
24
25#ifndef SUPER_BASE_F_2D_HH
26#define SUPER_BASE_F_2D_HH
27
28
29#include "superBaseF2D.h"
30
31namespace olb {
32
33template<typename T, typename W>
34SuperF2D<T,W>::SuperF2D(SuperStructure<T,2>& superStructure, int targetDim)
35 : GenericF<W,int>(targetDim,2), _superStructure(superStructure) { }
36
37template<typename T, typename W>
39{
40 return _superStructure;
41}
42
43template <typename T, typename W>
45{
46 OLB_ASSERT(_blockF.size() < INT32_MAX,
47 "it is safe to cast std::size_t to int");
48 return _blockF.size();
49}
50
51template <typename T, typename W>
54 OLB_ASSERT(size_t(iCloc) < _blockF.size() && iCloc >= 0,
55 "block functor index within bounds");
56 return *(_blockF[iCloc]);
57}
58
59template <typename T, typename W>
60bool SuperF2D<T,W>::operator()(W output[], const int input[])
61{
62
63 LoadBalancer<T>& load = _superStructure.getLoadBalancer();
64
65 if (load.isLocal(input[0])) {
66 const int loc = load.loc(input[0]);
67
68 return this->getBlockF(loc)(output, &input[1]);
69 }
70 else {
71 return false;
72 }
73
75
77template <typename T,typename BaseType>
79 : SuperF2D<T,BaseType>(superData, superData.getDataSize()),
80 _superData(superData)
81{
82 for (int iC = 0; iC < _superData.getLoadBalancer().size(); ++iC) {
83 this->_blockF.emplace_back(new BlockDataF2D<T,BaseType>(_superData.getBlock(iC)));
84 }
85}
86
87template <typename T,typename BaseType>
88bool SuperDataF2D<T,BaseType>::operator() (BaseType output[], const int input[])
89{
90 const auto& load = _superData.getLoadBalancer();
91 if (load.rank(input[0]) == singleton::mpi().getRank()) {
92 return this->getBlockF(load.loc(input[0]))(output, &input[1]);
93 }
94 else {
95 return false;
96 }
97}
98
99template <typename T,typename BaseType>
104
105
106template <typename T, typename W>
108 : SuperF2D<T,W>(f->getSuperStructure(), f->getTargetDim()),
109 _f(std::move(f))
110{
111 this->getName() = "Id(" + _f->getName() + ")";
112
113 for (int iC = 0; iC < _f->getBlockFSize(); ++iC) {
114 this->_blockF.emplace_back(
115 new BlockIdentity2D<W>(_f->getBlockF(iC)));
116 }
117}
119template <typename T, typename W>
120bool SuperIdentity2D<T,W>::operator()(W output[], const int input[])
121{
122 return _f(output, input);
123}
124
125template <typename T, typename DESCRIPTOR>
127 int targetDim)
128 : SuperF2D<T,T>(superLattice, targetDim), _sLattice(superLattice) { }
129
130template <typename T, typename DESCRIPTOR>
135
136template<typename T, typename DESCRIPTOR>
138 T output[], const int input[])
139{
140 auto& load = this->_sLattice.getLoadBalancer();
141
142 if (load.isLocal(input[0])) {
143 const int loc = load.loc(input[0]);
144
145 return this->getBlockF(loc)(output, &input[1]);
146 }
147 else {
148 return false;
149 }
150}
151
152template <typename T, typename DESCRIPTOR>
155 int targetDim)
156 : SuperLatticeF2D<T,DESCRIPTOR>(sLattice, targetDim), _converter(converter) { }
157
158template <typename T, typename DESCRIPTOR>
160{
161 return this->_converter;
162}
163
164template <typename T, typename DESCRIPTOR, typename TDESCRIPTOR>
167 int targetDim)
168 : SuperLatticeF2D<T,TDESCRIPTOR>(sLattice, targetDim), _converter(converter) { }
169
170template <typename T, typename DESCRIPTOR, typename TDESCRIPTOR>
175
176} // end namespace olb
177
178#endif
BlockDataF2D can store data of any BlockFunctor2D.
represents all functors that operate on a cuboid in general, mother class of BlockLatticeF,...
identity functor
Smart pointer for managing the various ways of passing functors around.
Definition functorPtr.h:60
GenericF is a base class, that can represent continuous as well as discrete functions.
Definition genericF.h:50
std::string & getName()
read and write access to name
Definition genericF.hh:51
Base class for all LoadBalancer.
bool isLocal(const int &glob)
returns whether glob is on this process
int loc(const int &glob)
Functor from SuperData2D
SuperDataF2D(SuperData< 2, T, BaseType > &superData)
Constructor from SuperData2D - stores _superData reference.
represents all functors that operate on a SuperStructure<T,2> in general
int getBlockFSize() const
bool operator()(W output[], const int input[]) override
SuperStructure< T, 2 > & getSuperStructure()
SuperF2D(SuperStructure< T, 2 > &superStructure, int targetDim)
BlockF2D< W > & getBlockF(int iCloc)
identity functor for memory management
represents all functors that operate on a SuperLattice in general, e.g. getVelocity(),...
bool operator()(T output[], const int input[])
SuperLattice< T, DESCRIPTOR > & getSuperLattice()
UnitConverter< T, DESCRIPTOR > const & getConverter() const
SuperLatticePhysF2D(SuperLattice< T, DESCRIPTOR > &sLattice, const UnitConverter< T, DESCRIPTOR > &converter, int targetDim)
SuperLatticeThermalPhysF2D(SuperLattice< T, TDESCRIPTOR > &sLattice, const ThermalUnitConverter< T, DESCRIPTOR, TDESCRIPTOR > &converter, int targetDim)
ThermalUnitConverter< T, DESCRIPTOR, TDESCRIPTOR > const & getConverter() const
Super class maintaining block lattices for a cuboid decomposition.
LoadBalancer< T > & getLoadBalancer()
Read and write access to the load balancer.
Conversion between physical and lattice units, as well as discretization specialized for thermal appl...
Conversion between physical and lattice units, as well as discretization.
Top level namespace for all of OpenLB.
typename util::BaseTypeHelper< T >::type BaseType
Definition baseType.h:59
#define OLB_ASSERT(COND, MESSAGE)
Definition olbDebug.h:45