OpenLB 1.7
Loading...
Searching...
No Matches
blockBaseF3D.hh
Go to the documentation of this file.
1/* This file is part of the OpenLB library
2 *
3 * Copyright (C) 2012 Lukas Baron, Mathias J. Krause, Albert Mink
4 * E-mail contact: info@openlb.net
5 * The most recent release of OpenLB can be downloaded at
6 * <http://www.openlb.net/>
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public
19 * License along with this program; if not, write to the Free
20 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 * Boston, MA 02110-1301, USA.
22*/
23
24#ifndef BLOCK_BASE_F_3D_HH
25#define BLOCK_BASE_F_3D_HH
26
27#include "blockBaseF3D.h"
28
29namespace olb {
30
31
32template <typename T>
33BlockF3D<T>::BlockF3D(BlockStructureD<3>& blockStructure, int targetDim)
34 : GenericF<T,int>(targetDim,3), _blockStructure(blockStructure) { }
35
36template <typename T>
38{
39 return _blockStructure;
40}
41
42template <typename T,typename BaseType>
44 : BlockF3D<T>(blockData, blockData.getSize()),
45 _blockData(blockData)
46{ }
47
48template <typename T,typename BaseType>
50 : BlockF3D<T>(f.getBlockStructure(), f.getTargetDim()),
51 _blockDataStorage(new BlockData<3,T,BaseType>(f)),
52 _blockData(*_blockDataStorage)
53{ }
54
55template <typename T,typename BaseType>
56BlockDataF3D<T,BaseType>::BlockDataF3D(int nx, int ny, int nz, int size)
57// hacky solution to both managing BlockData3D using std::unique_ptr and
58// passing it down the line to the base class
59 : BlockF3D<T>(*(new BlockData<3,T,BaseType>({{nx, ny, nz}, 0}, size)), size),
60 _blockDataStorage(static_cast<BlockData<3,T,BaseType>*>(&(this->getBlockStructure()))),
61 _blockData(*_blockDataStorage)
62{ }
63
64template <typename T,typename BaseType>
66{
67 return _blockData;
68}
69
70template <typename T, typename BaseType>
71bool BlockDataF3D<T,BaseType>::operator() (BaseType output[], const int input[])
72{
73 for (int iDim = 0; iDim < this->getTargetDim(); ++iDim) {
74 output[iDim] = _blockData.get(input, iDim);
75 }
76 return true;
78
80template <typename T>
82 : BlockF3D<T>(f.getBlockStructure(),f.getTargetDim() ), _f(f)
83{
84 this->getName() = _f.getName();
85 std::swap( _f._ptrCalcC, this->_ptrCalcC );
86}
87
88template <typename T>
89bool BlockIdentity3D<T>::operator()(T output[], const int input[])
90{
91 return _f(output,input);
92}
93
94
95template <typename T>
97 : BlockF3D<T>(f.getBlockStructure(),1 ), _f(f), _extractDim(extractDim)
98{
99 this->getName() = _f.getName();
100}
101
102template <typename T>
104{
105 return _extractDim;
106}
107
108template <typename T>
109bool BlockExtractComponentF3D<T>::operator()(T output[], const int input[])
110{
111 std::vector<T> outTmp(_f.getTargetDim(), T{});
112 _f(outTmp.data(), input);
113 output[0] = outTmp[_extractDim];
114 return true;
115}
116
117
118template <typename T>
120 BlockF3D<T>& f, int extractDim, BlockIndicatorF3D<T>& indicatorF)
121 : BlockExtractComponentF3D<T>(f, extractDim),
122 _indicatorF(indicatorF)
123{
124 this->getName() = f.getName();
125}
126
127template <typename T>
128bool BlockExtractComponentIndicatorF3D<T>::operator()(T output[], const int input[])
129{
130 output[0] = T{};
131 if (_indicatorF(input)) {
132 return BlockExtractComponentF3D<T>::operator()(output, input);
133 }
134 return true;
135}
136
137
138template <typename T>
140 BlockF3D<T>& f, BlockIndicatorF3D<T>& indicatorF)
141 : BlockF3D<T>(f.getBlockStructure(), f.getTargetDim()),
142 _f(f),
143 _indicatorF(indicatorF)
144{
145 this->getName() = f.getName();
146}
147
148template <typename T>
149bool BlockExtractIndicatorF3D<T>::operator()(T output[], const int input[])
150{
151 for (int i = 0; i < this->getTargetDim(); ++i) {
152 output[i] = T{};
153 }
154 if (_indicatorF(input)) {
155 _f(output, input);
156 }
157 return true;
158}
159
160
161template <typename T, typename T2>
163 : BlockF3D<T>(f.getBlockStructure(), f.getTargetDim()),
164 _f(f)
165{
166 this->getName() = f.getName();
167}
168
169template <typename T, typename T2>
170bool BlockTypecastF3D<T,T2>::operator()(T output[], const int input[])
171{
172 T2 result[this->getTargetDim()];
173 _f(result, input);
174 for (int i = 0; i < this->getTargetDim(); ++i) {
175 output[i] = static_cast<T>(result[i]);
176 }
177 return true;
178}
179
180
181template <typename T, typename DESCRIPTOR>
183(BlockLattice<T,DESCRIPTOR>& blockStructure, int targetDim)
184 : BlockF3D<T>(blockStructure, targetDim), _blockLattice(blockStructure)
185{ }
186/*
187template <typename T, typename DESCRIPTOR>
188BlockLatticeF3D<T,DESCRIPTOR>::BlockLatticeF3D(BlockLatticeF3D<T,DESCRIPTOR> const& rhs)
189 : BlockF3D<T>(rhs.getBlockStructure(), rhs.getTargetDim() ), _blockLattice(rhs.getBlock())
190{ }
191
192template <typename T, typename DESCRIPTOR>
193BlockLatticeF3D<T,DESCRIPTOR>& BlockLatticeF3D<T,DESCRIPTOR>::operator=(BlockLatticeF3D<T,DESCRIPTOR> const& rhs)
194{
195 BlockLatticeF3D<T,DESCRIPTOR> tmp(rhs);
196 return tmp;
197}
198*/
199template <typename T, typename DESCRIPTOR>
204
205
206template <typename T, typename DESCRIPTOR>
209 : BlockLatticeF3D<T,DESCRIPTOR>(f.getBlock(),f.getTargetDim()),
210 _f(f)
211{
212 this->getName() = _f.getName();
213 std::swap( _f._ptrCalcC, this->_ptrCalcC );
214}
215
216template <typename T, typename DESCRIPTOR>
217bool BlockLatticeIdentity3D<T,DESCRIPTOR>::operator()(T output[], const int input[])
218{
219 return _f(output,input);
220}
221
222
223template <typename T, typename DESCRIPTOR>
225(BlockLattice<T,DESCRIPTOR>& blockLattice, const UnitConverter<T,DESCRIPTOR>& converter, int targetDim)
226 : BlockLatticeF3D<T,DESCRIPTOR>(blockLattice, targetDim), _converter(converter)
227{ }
228
229template <typename T, typename DESCRIPTOR, typename TDESCRIPTOR>
231(BlockLattice<T,TDESCRIPTOR>& blockLattice, const ThermalUnitConverter<T,DESCRIPTOR,TDESCRIPTOR>& converter, int targetDim)
232 : BlockLatticeF3D<T,TDESCRIPTOR>(blockLattice, targetDim), _converter(converter)
233{ }
234
235
236
237
238} // end namespace olb
239
240#endif
bool operator()(BaseType output[], const int input[]) override
access to _blockData via its get()
BlockData< 3, T, BaseType > & getBlockData()
returns _blockData
BlockDataF3D(int nx, int ny, int nz, int size=1)
U & get(std::size_t iCell, int iD=0)
Definition blockData.hh:94
functor to extract one component
bool operator()(T output[], const int input[])
has to be implemented for 'every' derived class
BlockExtractComponentF3D(BlockF3D< T > &f, int extractDim)
BlockExtractComponentIndicatorF3D(BlockF3D< T > &f, int extractDim, BlockIndicatorF3D< T > &indicatorF)
bool operator()(T output[], const int input[]) override
has to be implemented for 'every' derived class
BlockExtractIndicatorF3D(BlockF3D< T > &f, BlockIndicatorF3D< T > &indicatorF)
bool operator()(T output[], const int input[])
has to be implemented for 'every' derived class
represents all functors that operate on a cuboid in general, mother class of BlockLatticeF,...
BlockF3D(BlockStructureD< 3 > &blockStructure, int targetDim)
virtual BlockStructureD< 3 > & getBlockStructure() const
BlockIdentity3D(BlockF3D< T > &f)
BlockF3D< T > & _f
bool operator()(T output[], const int input[]) override
has to be implemented for 'every' derived class
Base block indicator functor.
represents all functors that operate on a DESCRIPTOR in general, e.g. getVelocity(),...
BlockLattice< T, DESCRIPTOR > & getBlock()
Copy Constructor.
BlockLatticeF3D(BlockLattice< T, DESCRIPTOR > &blockLattice, int targetDim)
bool operator()(T output[], const int input[]) override
has to be implemented for 'every' derived class
BlockLatticeF3D< T, DESCRIPTOR > & _f
BlockLatticeIdentity3D(BlockLatticeF3D< T, DESCRIPTOR > &f)
BlockLatticePhysF3D(BlockLattice< T, DESCRIPTOR > &blockLattice, const UnitConverter< T, DESCRIPTOR > &converter, int targetDim)
BlockLatticeThermalPhysF3D(BlockLattice< T, TDESCRIPTOR > &blockLattice, const ThermalUnitConverter< T, DESCRIPTOR, TDESCRIPTOR > &converter, int targetDim)
Platform-abstracted block lattice for external access and inter-block interaction.
Base of a regular block.
BlockTypecastF3D(BlockF3D< T2 > &f)
bool operator()(T output[], const int input[])
has to be implemented for 'every' derived class
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
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