OpenLB 1.8.1
Loading...
Searching...
No Matches
blockData.h
Go to the documentation of this file.
1/* This file is part of the OpenLB library
2 *
3 * Copyright (C) 2015 Mathias J. Krause
4 * 2021 Adrian Kummerlaender
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 BLOCK_DATA_H
26#define BLOCK_DATA_H
27
28#include <vector>
29
30#include "blockStructure.h"
31#include "serializer.h"
32#include "geometry/cuboid.h"
33#include "utilities/aliases.h"
34#include "descriptor/tag.h"
37
38namespace olb {
39
40
41template<unsigned D, typename T, typename U>
42class BlockData : public BlockStructureD<D>
43 , public Serializable {
44protected:
45 const unsigned _size;
46 std::vector<cpu::sisd::Column<U>> _data;
48
49public:
51
53
54 BlockData(Cuboid<T,D>& cuboid, int overlap=0, int size=1);
55 BlockData(BlockStructureD<D>&& block, int size=1);
56 BlockData(BlockF<U,D>& blockF);
58 virtual ~BlockData() = default;
59
60 bool operator() (T output[], const int input[]);
61
62 Column<U>& getColumn(unsigned iD);
63
64 U& get(std::size_t iCell, int iD=0);
65 U& get(LatticeR<D> latticeR, int iD=0);
66 U get(LatticeR<D> latticeR, int iD=0) const;
67
69 return platform;
70 }
71
72 bool hasCommunicatable(std::type_index field) const {
73 return field == typeid(DUMMY_FIELD);
74 }
75 auto& getCommunicatable(std::type_index field) {
76 OLB_ASSERT(field == typeid(DUMMY_FIELD),
77 "BlockData only offers DUMMY_FIELD for communication");
78 return _communicatable;
79 }
80
81 unsigned getSize() const;
82
83 std::size_t getNblock() const override;
84 std::size_t getSerializableSize() const override;
85 bool* getBlock(std::size_t iBlock, std::size_t& sizeBlock, bool loadingMode) override;
86
87
88};
89
91template<unsigned D, typename T, typename U>
93
94using value_t = T;
95
97
98template <Platform PLATFORM>
100
101};
102
103}
104
105#endif
bool operator()(T output[], const int input[])
Definition blockData.hh:84
unsigned getSize() const
Definition blockData.hh:118
bool * getBlock(std::size_t iBlock, std::size_t &sizeBlock, bool loadingMode) override
Returns the address of the i-th block and its size.
Definition blockData.hh:136
bool hasCommunicatable(std::type_index field) const
Definition blockData.h:72
std::size_t getSerializableSize() const override
Returns the binary size of the data to be saved.
Definition blockData.hh:130
Platform getPlatform() const
Definition blockData.h:68
Column< U > & getColumn(unsigned iD)
Definition blockData.hh:112
BlockData(BlockData< D, T, U > &&)=default
std::size_t getNblock() const override
Returns the number of blocks.
Definition blockData.hh:124
std::vector< cpu::sisd::Column< U > > _data
Definition blockData.h:46
virtual ~BlockData()=default
ConcreteCommunicatable< std::vector< cpu::sisd::Column< U > > > _communicatable
Definition blockData.h:47
const unsigned _size
Definition blockData.h:45
BlockData(Cuboid< T, D > &cuboid, int overlap=0, int size=1)
Definition blockData.hh:41
static constexpr Platform platform
Definition blockData.h:50
U & get(std::size_t iCell, int iD=0)
Definition blockData.hh:94
auto & getCommunicatable(std::type_index field)
Definition blockData.h:75
Base of a regular block.
Base class for serializable objects of constant size. For dynamic size use BufferSerializable.
Definition serializer.h:145
Plain old scalar vector.
Plain column for SISD CPU targets (default)
Definition column.h:45
Top level namespace for all of OpenLB.
std::conditional_t< D==2, BlockF2D< T >, BlockF3D< T > > BlockF
Definition aliases.h:177
Platform
OpenLB execution targets.
Definition platform.h:35
#define OLB_ASSERT(COND, MESSAGE)
Definition olbDebug.h:45
Curried BlockData template for use in callUsingConcretePlatform.
Definition blockData.h:92
Base of a descriptor tag.
Definition tag.h:39