OpenLB 1.7
Loading...
Searching...
No Matches
column.hh
Go to the documentation of this file.
1/* This file is part of the OpenLB library
2 *
3 * Copyright (C) 2020 Adrian Kummerlaender
4 *
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 CPU_SISD_COLUMN_HH
26#define CPU_SISD_COLUMN_HH
27
28#include "column.h"
29
30#include <cstring>
31
32namespace olb {
33
34namespace cpu {
35
36namespace sisd {
37
38template<typename T>
39std::size_t Column<T>::getNblock() const
40{
41 return 2;
42}
43
44template<typename T>
46{
47 return _count * sizeof(T) + sizeof(std::size_t);
48}
49
50template<typename T>
51bool* Column<T>::getBlock(std::size_t iBlock, std::size_t& sizeBlock, bool loadingMode)
52{
53 std::size_t currentBlock = 0;
54 bool* dataPtr = nullptr;
55
56 registerVar(iBlock, sizeBlock, currentBlock, dataPtr, _count);
57 if (loadingMode && iBlock == 1) {
58 resize(_count);
59 }
60 registerVar(iBlock, sizeBlock, currentBlock, dataPtr, *data(), _count);
61
62 return dataPtr;
63}
64
65
66template<typename T>
67std::size_t CyclicColumn<T>::getNblock() const
68{
69 return 3;
70}
71
72template<typename T>
74{
75 return _count * sizeof(T) + sizeof(std::ptrdiff_t) + sizeof(std::size_t);
76}
77
78template<typename T>
79bool* CyclicColumn<T>::getBlock(std::size_t iBlock, std::size_t& sizeBlock, bool loadingMode)
80{
81 std::size_t currentBlock = 0;
82 bool* dataPtr = nullptr;
83
84 registerVar(iBlock, sizeBlock, currentBlock, dataPtr, _shift);
85 registerVar(iBlock, sizeBlock, currentBlock, dataPtr, _count);
86 registerVar(iBlock, sizeBlock, currentBlock, dataPtr, *_data.get(), _count);
87
88 return dataPtr;
89}
90
91}
92
93}
94
95}
96
97#endif
bool * getBlock(std::size_t iBlock, std::size_t &sizeBlock, bool loadingMode) override
Return a pointer to the memory of the current block and its size for the serializable interface.
Definition column.hh:51
std::size_t getSerializableSize() const override
Binary size for the serializer.
Definition column.hh:45
std::size_t getNblock() const override
Number of data blocks for the serializable interface.
Definition column.hh:39
std::size_t getNblock() const override
Number of data blocks for the serializable interface.
Definition column.hh:67
bool * getBlock(std::size_t iBlock, std::size_t &sizeBlock, bool loadingMode) override
Return a pointer to the memory of the current block and its size for the serializable interface.
Definition column.hh:79
std::size_t getSerializableSize() const override
Binary size for the serializer.
Definition column.hh:73
Top level namespace for all of OpenLB.