OpenLB 1.7
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 "utilities/aliases.h"
36
37namespace olb {
38
39
40template<unsigned D, typename T, typename U>
41class BlockData : public BlockStructureD<D>
42 , public Serializable {
43protected:
44 const unsigned _size;
45 std::vector<cpu::sisd::Column<U>> _data;
47
48public:
50
52
53 BlockData(Cuboid<T,D>& cuboid, int overlap=0, int size=1);
54 BlockData(BlockStructureD<D>&& block, int size=1);
55 BlockData(BlockF<U,D>& blockF);
57 virtual ~BlockData() = default;
58
59 bool operator() (T output[], const int input[]);
60
61 Column<U>& getColumn(unsigned iD);
62
63 U& get(std::size_t iCell, int iD=0);
64 U& get(LatticeR<D> latticeR, int iD=0);
65 U get(LatticeR<D> latticeR, int iD=0) const;
66
68 return platform;
69 }
70
71 bool hasCommunicatable(std::type_index field) const {
72 return field == typeid(DUMMY_FIELD);
73 }
74 auto& getCommunicatable(std::type_index field) {
75 OLB_ASSERT(field == typeid(DUMMY_FIELD),
76 "BlockData only offers DUMMY_FIELD for communication");
77 return _communicatable;
78 }
79
80 unsigned getSize() const;
81
82 std::size_t getNblock() const override;
83 std::size_t getSerializableSize() const override;
84 bool* getBlock(std::size_t iBlock, std::size_t& sizeBlock, bool loadingMode) override;
85
86
87};
88
90template<unsigned D, typename T, typename U>
92
94
95template <Platform PLATFORM>
97
98};
99
100}
101
102#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:71
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:67
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:45
virtual ~BlockData()=default
ConcreteCommunicatable< std::vector< cpu::sisd::Column< U > > > _communicatable
Definition blockData.h:46
const unsigned _size
Definition blockData.h:44
BlockData(Cuboid< T, D > &cuboid, int overlap=0, int size=1)
Definition blockData.hh:41
static constexpr Platform platform
Definition blockData.h:49
U & get(std::size_t iCell, int iD=0)
Definition blockData.hh:94
auto & getCommunicatable(std::type_index field)
Definition blockData.h:74
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.
Definition vector.h:47
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:188
Platform
OpenLB execution targets.
Definition platform.h:36
std::conditional_t< D==2, Cuboid2D< T >, Cuboid3D< T > > Cuboid
Definition aliases.h:37
#define OLB_ASSERT(COND, MESSAGE)
Definition olbDebug.h:45
Curried BlockData template for use in callUsingConcretePlatform.
Definition blockData.h:91
Base of a descriptor tag.