OpenLB 1.7
Loading...
Searching...
No Matches
fieldArrayD.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 * 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 FIELD_ARRAY_D_HH
25#define FIELD_ARRAY_D_HH
26
27#include "fieldArrayD.h"
28
29
30namespace olb {
31
32
33template <typename T, typename DESCRIPTOR, Platform PLATFORM, typename... FIELDS>
34template <typename FIELD>
35const typename FIELD::template value_type<T>&
37{
38 return get<FIELD>()[iDim][iCell];
39}
40
41template <typename T, typename DESCRIPTOR, Platform PLATFORM, typename... FIELDS>
42template <typename FIELD>
43typename FIELD::template value_type<T>&
45{
46 return get<FIELD>()[iDim][iCell];
47}
48
49template <typename T, typename DESCRIPTOR, Platform PLATFORM, typename... FIELDS>
50template <typename F>
52{
53 fields_t::for_each([&](auto field) {
54 f(get(field));
55 });
56}
57
58template <typename T, typename DESCRIPTOR, Platform PLATFORM, typename... FIELDS>
59template <typename F>
61{
62 fields_t::for_each([&](auto field) {
63 f(get(field));
64 });
65}
66
67template <typename T, typename DESCRIPTOR, Platform PLATFORM, typename... FIELDS>
68template <typename F>
70{
71 fields_t::for_each([&](auto field) {
72 f(get(field).getFieldPointer(idx), field);
73 });
74}
75
76template <typename T, typename DESCRIPTOR, Platform PLATFORM, typename... FIELDS>
78{
79 return (get<FIELDS>().getNblock() + ... + 0);
80}
81
82template <typename T, typename DESCRIPTOR, Platform PLATFORM, typename... FIELDS>
84{
85 return (get<FIELDS>().getSerializableSize() + ... + 0);
86}
87
88template <typename T, typename DESCRIPTOR, Platform PLATFORM, typename... FIELDS>
89bool* MultiFieldArrayD<T,DESCRIPTOR,PLATFORM,FIELDS...>::getBlock(std::size_t iBlock, std::size_t& sizeBlock, bool loadingMode)
90{
91 std::size_t currentBlock = 0;
92 bool* dataPtr = nullptr;
93
94 meta::tuple_for_each(_static, [&](auto& field) {
95 registerSerializableOfConstSize(iBlock, sizeBlock, currentBlock, dataPtr, field, loadingMode);
96 });
97
98 return dataPtr;
99}
100
101
102}
103
104#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.
std::size_t getSerializableSize() const override
Binary size for the serializer.
const FIELD::template value_type< T > & getFieldComponent(std::size_t iCell, unsigned iDim) const
void forFieldsAt(std::size_t idx, F f)
Apply generic lambda expression to each FIELD of a cell.
std::size_t getNblock() const override
Number of data blocks for the serializable interface.
void forFields(F f) const
Apply generic expression to each FIELD array.
void tuple_for_each(TUPLE &tuple, F &&f)
Apply F to each element of TUPLE.
Definition meta.h:369
Top level namespace for all of OpenLB.
Platform
OpenLB execution targets.
Definition platform.h:36