OpenLB 1.7
Loading...
Searching...
No Matches
blockBaseF2D.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_2D_HH
25#define BLOCK_BASE_F_2D_HH
26
27#include "blockBaseF2D.h"
28
29namespace olb {
30
31
32template <typename T>
33BlockF2D<T>::BlockF2D(BlockStructureD<2>& blockStructure, int targetDim)
34 : GenericF<T,int>(targetDim,2), _blockStructure(&blockStructure) { }
35
36 //added from old
37template <typename T>
39 : GenericF<T,int>(targetDim,2), _blockStructure(nullptr) { }
40
41template <typename T>
43{
44 return *_blockStructure;
45}
46
47 //added from old
48template <typename T>
51 _blockStructure = blockStructure;
52}
53
54template <typename T,typename BaseType>
56 : BlockF2D<T>(blockData, blockData.getSize()),
57 _blockData(&blockData),
58 _owning(false)
59{ }
60
61template <typename T,typename BaseType>
63 : BlockF2D<T>(f.getBlockStructure(), f.getTargetDim()),
64 _blockData(new BlockData<2,T,BaseType>(f)),
65 _owning(true)
66{ }
67
68template <typename T,typename BaseType>
70// hacky solution to both managing BlockData2D using std::unique_ptr and
71// passing it down the line to the base class
72 : BlockF2D<T>(*(new BlockData<2,T,BaseType>({{nx, ny}, 0}, size)), size),
73 _blockData(static_cast<BlockData<2,T,BaseType>*>(&(this->getBlockStructure()))),
74 _owning(true)
75{ }
77template <typename T,typename BaseType>
79{
80 if (_owning) {
81 delete _blockData;
82 }
83}
84
85template <typename T,typename BaseType>
90
91template <typename T, typename BaseType>
92bool BlockDataF2D<T,BaseType>::operator() (BaseType output[], const int input[])
93{
94 for (int iDim = 0; iDim < this->getTargetDim(); ++iDim) {
95 output[iDim] = _blockData->get(input, iDim);
96 }
97 return true;
98}
99
100
101template <typename T>
103 : BlockF2D<T>(f.getBlockStructure(),f.getTargetDim() ), _f(f)
104{
105 this->getName() = _f.getName();
106 std::swap( _f._ptrCalcC, this->_ptrCalcC );
107}
108
109template <typename T>
110bool BlockIdentity2D<T>::operator()(T output[], const int input[])
111{
112 return _f(output,input);
113}
114
115
116template <typename T>
118 : BlockF2D<T>(f.getBlockStructure(),1 ), _f(f), _extractDim(extractDim)
119{
120 this->getName() = _f.getName();
121}
122
123template <typename T>
125{
126 return _extractDim;
127}
128
129template <typename T>
130bool BlockExtractComponentF2D<T>::operator()(T output[], const int input[])
131{
132 std::vector<T> outTmp(_f.getTargetDim(), T{});
133 _f(outTmp.data(), input);
134 output[0] = outTmp[_extractDim];
135 return true;
136}
137
138
139template <typename T>
141 BlockF2D<T>& f, int extractDim, BlockIndicatorF2D<T>& indicatorF)
142 : BlockExtractComponentF2D<T>(f, extractDim),
143 _indicatorF(indicatorF)
144{
145 this->getName() = f.getName();
146}
147
148template <typename T>
149bool BlockExtractComponentIndicatorF2D<T>::operator()(T output[], const int input[])
150{
151 output[0] = T{};
152 if (_indicatorF(input)) {
153 return BlockExtractComponentF2D<T>::operator()(output, input);
154 }
155 return true;
156}
157
158
159template <typename T>
161 BlockF2D<T>& f, BlockIndicatorF2D<T>& indicatorF)
162 : BlockF2D<T>(f.getBlockStructure(), f.getTargetDim()),
163 _f(f),
164 _indicatorF(indicatorF)
165{
166 this->getName() = f.getName();
167}
168
169template <typename T>
170bool BlockExtractIndicatorF2D<T>::operator()(T output[], const int input[])
171{
172 for (int i = 0; i < this->getTargetDim(); ++i) {
173 output[i] = T{};
174 }
175 if (_indicatorF(input)) {
176 _f(output, input);
177 }
178 return true;
179}
180
181
182template <typename T, typename DESCRIPTOR>
184(BlockLattice<T,DESCRIPTOR>& blockStructure, int targetDim)
185 : BlockF2D<T>(blockStructure, targetDim), _blockLattice(blockStructure)
186{ }
187/*
188template <typename T, typename DESCRIPTOR>
189BlockLatticeF2D<T,DESCRIPTOR>::BlockLatticeF2D(BlockLatticeF2D<T,DESCRIPTOR> const& rhs)
190 : BlockF2D<T>(rhs.getBlockStructure(), rhs.getTargetDim() ), _blockLattice(rhs.getBlock())
191{ }
192
193template <typename T, typename DESCRIPTOR>
194BlockLatticeF2D<T,DESCRIPTOR>& BlockLatticeF2D<T,DESCRIPTOR>::operator=(BlockLatticeF2D<T,DESCRIPTOR> const& rhs)
195{
196 BlockLatticeF2D<T,DESCRIPTOR> tmp(rhs);
197 return tmp;
198}
199*/
200template <typename T, typename DESCRIPTOR>
205
206
207template <typename T, typename DESCRIPTOR>
210 : BlockLatticeF2D<T,DESCRIPTOR>(f.getBlock(),f.getTargetDim()),
211 _f(f)
212{
213 this->getName() = _f.getName();
214 std::swap( _f._ptrCalcC, this->_ptrCalcC );
215}
216
217template <typename T, typename DESCRIPTOR>
218bool BlockLatticeIdentity2D<T,DESCRIPTOR>::operator()(T output[], const int input[])
219{
220 return _f(output,input);
221}
222
223
224template <typename T, typename DESCRIPTOR>
226(BlockLattice<T,DESCRIPTOR>& blockLattice, const UnitConverter<T,DESCRIPTOR>& converter, int targetDim)
227 : BlockLatticeF2D<T,DESCRIPTOR>(blockLattice, targetDim), _converter(converter)
228{ }
229
230template <typename T, typename DESCRIPTOR, typename TDESCRIPTOR>
232(BlockLattice<T,TDESCRIPTOR>& blockLattice, const ThermalUnitConverter<T,DESCRIPTOR,TDESCRIPTOR>& converter, int targetDim)
233 : BlockLatticeF2D<T,TDESCRIPTOR>(blockLattice, targetDim), _converter(converter)
234{ }
235
236
237
238
239} // end namespace olb
240
241#endif
bool operator()(BaseType output[], const int input[]) override
access to _blockData via its get()
BlockData< 2, T, BaseType > & getBlockData()
returns _blockData
BlockDataF2D(int nx, int ny, 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
BlockExtractComponentF2D(BlockF2D< T > &f, int extractDim)
BlockExtractComponentIndicatorF2D(BlockF2D< T > &f, int extractDim, BlockIndicatorF2D< T > &indicatorF)
bool operator()(T output[], const int input[]) override
has to be implemented for 'every' derived class
bool operator()(T output[], const int input[])
has to be implemented for 'every' derived class
BlockExtractIndicatorF2D(BlockF2D< T > &f, BlockIndicatorF2D< T > &indicatorF)
represents all functors that operate on a cuboid in general, mother class of BlockLatticeF,...
virtual BlockStructureD< 2 > & getBlockStructure()
virtual destructor for defined behaviour
BlockF2D(BlockStructureD< 2 > &blockStructure, int targetDim)
void setBlockStructure(BlockStructureD< 2 > *blockStructure)
BlockF2D< T > & _f
bool operator()(T output[], const int input[]) override
has to be implemented for 'every' derived class
BlockIdentity2D(BlockF2D< T > &f)
Base block indicator functor (discrete)
represents all functors that operate on a DESCRIPTOR in general, e.g. getVelocity(),...
BlockLattice< T, DESCRIPTOR > & getBlock()
Copy Constructor.
BlockLatticeF2D(BlockLattice< T, DESCRIPTOR > &blockLattice, int targetDim)
bool operator()(T output[], const int input[]) override
has to be implemented for 'every' derived class
BlockLatticeF2D< T, DESCRIPTOR > & _f
BlockLatticeIdentity2D(BlockLatticeF2D< T, DESCRIPTOR > &f)
BlockLatticePhysF2D(BlockLattice< T, DESCRIPTOR > &blockLattice, const UnitConverter< T, DESCRIPTOR > &converter, int targetDim)
BlockLatticeThermalPhysF2D(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.
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