OpenLB 1.8.1
Loading...
Searching...
No Matches
blockBaseF3D.h
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_H
25#define BLOCK_BASE_F_3D_H
26
27#include "functors/genericF.h"
28#include "core/blockData.h"
29#include "core/blockStructure.h"
30#include "core/unitConverter.h"
31
32#include <memory>
33
34/* Note: Throughout the whole source code directory genericFunctions, the
35 * template parameters for i/o dimensions are:
36 * F: S^m -> T^n (S=source, T=target)
37 */
38
39namespace olb {
40
41
42template <typename T> class BlockIndicatorF3D;
43
45template <typename T>
46class BlockF3D : public GenericF<T,int> {
47protected:
48 BlockF3D(BlockStructureD<3>& blockStructure, int targetDim);
50public:
52 ~BlockF3D() override {};
54
55 using GenericF<T,int>::operator();
56
61};
62
64template <typename T, typename BaseType>
65class BlockDataF3D : public BlockF3D<BaseType> {
66protected:
67 BlockDataF3D(int nx, int ny, int nz, int size=1);
68
69 std::unique_ptr<BlockData<3,T,BaseType>> _blockDataStorage;
71public:
79 bool operator() (BaseType output[], const int input[]) override;
80};
81
83template <typename T>
84class BlockIdentity3D final : public BlockF3D<T> {
85protected:
87public:
89 // access operator should not delete f, since f still has the identity as child
90 bool operator() (T output[], const int input[]) override;
91};
92
94template <typename T>
96protected:
99public:
100 BlockExtractComponentF3D(BlockF3D<T>& f, int extractDim);
101 int getExtractDim();
102 bool operator() (T output[], const int input[]);
103};
104
106template <typename T>
108protected:
110public:
112 BlockIndicatorF3D<T>& indicatorF);
113 bool operator() (T output[], const int input[]) override;
114};
115
117template <typename T>
119protected:
122public:
124 BlockIndicatorF3D<T>& indicatorF);
125 bool operator() (T output[], const int input[]);
126};
127
129// user has to guarantee that cast is well-defined
130template <typename T, typename T2>
131class BlockTypecastF3D : public BlockF3D<T> {
132protected:
134public:
136 bool operator() (T output[], const int input[]);
137};
138
140template <typename T, typename DESCRIPTOR>
141class BlockLatticeF3D : public BlockF3D<T> {
142protected:
143 BlockLatticeF3D(BlockLattice<T,DESCRIPTOR>& blockLattice, int targetDim);
145public:
147 //BlockLatticeF3D(BlockLatticeF3D<T,DESCRIPTOR> const& rhs);
149 //BlockLatticeF3D<T,DESCRIPTOR>& operator=(BlockLatticeF3D<T,DESCRIPTOR> const& rhs);
150
152};
153
154
156template <typename T, typename DESCRIPTOR>
157class BlockLatticeIdentity3D final : public BlockLatticeF3D<T,DESCRIPTOR> {
158protected:
160public:
162 bool operator() (T output[], const int input[]) override;
163};
164
165
167template <typename T, typename DESCRIPTOR>
168class BlockLatticePhysF3D : public BlockLatticeF3D<T,DESCRIPTOR> {
169protected:
172 const UnitConverter<T,DESCRIPTOR>& converter, int targetDim);
173public:
175 //BlockLatticePhysF3D(BlockLatticePhysF3D<T,DESCRIPTOR> const& rhs);
177 //BlockLatticePhysF3D<T,DESCRIPTOR>& operator=(BlockLatticePhysF3D<T,DESCRIPTOR> const& rhs);
178};
179
181template <typename T, typename DESCRIPTOR, typename TDESCRIPTOR>
188
189template <typename T, typename W = T>
190class BlockConst3D final : public BlockF3D<W> {
191protected:
192 const std::vector<W> _c;
193public:
195
200 BlockConst3D(BlockStructureD<3>& blockStructure, std::vector<W> v);
201
203 BlockConst3D(BlockStructureD<3>& blockStructure, W scalar);
205 template <unsigned Size>
207 : BlockConst3D(blockStructure, v.toStdVector()) { };
208
209 bool operator() (W output[], const int input[]) override;
210};
211
212
215template <typename T, typename DESCRIPTOR>
216class BlockLatticeFfromCallableF final : public BlockLatticeF<T,DESCRIPTOR> {
217private:
218 // local block number
219 const unsigned _iC;
220 // internal function with interface defined by BlockF:
221 // takes local coordinates, writes result into array, returns bool
222 std::function<bool(T*,const int*)> _f;
223
224public:
233 template <typename F>
235 : BlockLatticeF<T,DESCRIPTOR>(blockLattice, 1), _iC(iC),
236 _f([&,f](T* output, const int* input) -> bool {
237 auto cell = blockLattice.get(input);
238 if constexpr (std::is_invocable_v<F, T*, decltype(cell)>) {
239 f(output, cell);
240 } else if constexpr (std::is_invocable_v<F, T*, decltype(cell), int, const int*>) {
241 f(output, cell, _iC, input);
242 } else {
243 f(output, _iC, input);
244 }
245 return true;
246 })
247 { }
248
249 bool operator() (T output[], const int input[]) override {
250 return _f(output, input);
251 }
252};
253
254
255} // end namespace olb
256
257#endif
BlockConst3D(BlockStructureD< 3 > &blockStructure, Vector< W, Size > v)
Constructor template accepting vectors.
BlockConst3D(BlockStructureD< 3 > &blockStructure, std::vector< W > v)
Constructor accepting std::vector.
bool operator()(W output[], const int input[]) override
const std::vector< W > _c
bool operator()(BaseType output[], const int input[]) override
access to _blockData via its get()
BlockData< 3, T, BaseType > & getBlockData()
returns _blockData
BlockData< 3, T, BaseType > & _blockData
std::unique_ptr< BlockData< 3, T, BaseType > > _blockDataStorage
BlockDataF3D(int nx, int ny, int nz, int size=1)
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)
functor to extract one component inside an indicator
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
BlockIndicatorF3D< T > & _indicatorF
functor to extract data inside an indicator
BlockExtractIndicatorF3D(BlockF3D< T > &f, BlockIndicatorF3D< T > &indicatorF)
bool operator()(T output[], const int input[])
has to be implemented for 'every' derived class
BlockIndicatorF3D< T > & _indicatorF
represents all functors that operate on a cuboid in general, mother class of BlockLatticeF,...
Definition aliases.h:174
BlockF3D< T > & operator-(BlockF3D< T > &rhs)
BlockF3D< T > & operator+(BlockF3D< T > &rhs)
BlockF3D< T > & operator/(BlockF3D< T > &rhs)
BlockF3D(BlockStructureD< 3 > &blockStructure, int targetDim)
BlockStructureD< 3 > & _blockStructure
virtual BlockStructureD< 3 > & getBlockStructure() const
~BlockF3D() override
virtual destructor for defined behaviour
BlockF3D< T > & operator*(BlockF3D< T > &rhs)
identity functor
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.
Definition aliases.h:204
represents all functors that operate on a DESCRIPTOR in general, e.g. getVelocity(),...
Definition aliases.h:144
BlockLattice< T, DESCRIPTOR > & getBlock()
Copy Constructor.
BlockLatticeF3D(BlockLattice< T, DESCRIPTOR > &blockLattice, int targetDim)
BlockLattice< T, DESCRIPTOR > & _blockLattice
Generate a BlockLatticeF from an arbitrary function.
BlockLatticeFfromCallableF(BlockLattice< T, DESCRIPTOR > &blockLattice, unsigned iC, F &&f)
Generate a BlockLatticeF from an arbitrary function.
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)
represents all functors that operate on a DESCRIPTOR with output in Phys, e.g. physVelocity(),...
Definition aliases.h:325
const UnitConverter< T, DESCRIPTOR > & _converter
BlockLatticePhysF3D(BlockLattice< T, DESCRIPTOR > &blockLattice, const UnitConverter< T, DESCRIPTOR > &converter, int targetDim)
represents all thermal functors that operate on a DESCRIPTOR with output in Phys, e....
BlockLatticeThermalPhysF3D(BlockLattice< T, TDESCRIPTOR > &blockLattice, const ThermalUnitConverter< T, DESCRIPTOR, TDESCRIPTOR > &converter, int targetDim)
const ThermalUnitConverter< T, DESCRIPTOR, TDESCRIPTOR > & _converter
Base of a regular block.
perform explicit typecast from output type T2 to T
BlockF3D< T2 > & _f
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
Conversion between physical and lattice units, as well as discretization specialized for thermal appl...
Conversion between physical and lattice units, as well as discretization.
Plain old scalar vector.
The description of a generic interface for all functor classes – header file.
Top level namespace for all of OpenLB.
constexpr std::vector< T > toStdVector(const ScalarVector< T, D, IMPL > &a)
Copies data into a standard vector.
std::conditional_t< DESCRIPTOR::d==2, BlockLatticeF2D< T, DESCRIPTOR >, BlockLatticeF3D< T, DESCRIPTOR > > BlockLatticeF
Definition aliases.h:147
typename util::BaseTypeHelper< T >::type BaseType
Definition baseType.h:59
Unit conversion handling – header file.