OpenLB 1.8.1
Loading...
Searching...
No Matches
fieldArrayD.h
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_H
25#define FIELD_ARRAY_D_H
26
27#include "meta.h"
28#include "vector.h"
29#include "columnVector.h"
30#include "serializer.h"
31#include "descriptor/base.h"
32
33#include "platform/platform.h"
34
35#include <memory>
36#include <tuple>
37
38namespace olb {
39
40
41template<typename T, typename DESCRIPTOR, Platform PLATFORM, typename FIELD>
42class FieldArrayD;
43
46
48template<typename T, typename DESCRIPTOR, typename FIELD>
50private:
51 virtual const typename FIELD::template column_type<T>& getAbstractColumn(unsigned iDim) const = 0;
52 virtual typename FIELD::template column_type<T>& getAbstractColumn(unsigned iDim) = 0;
53
54public:
55 class const_ptr;
56 class ptr;
57
58 using descriptor_t = DESCRIPTOR;
59 using field_t = FIELD;
60
62 virtual Platform getPlatform() const = 0;
64 template <Platform PLATFORM>
66 if (auto* ptr = dynamic_cast<FieldArrayD<T,DESCRIPTOR,PLATFORM,FIELD>*>(this);
67 ptr != nullptr) {
68 return *ptr;
69 } else {
70 throw std::invalid_argument("FieldArrayD is not of PLATFORM");
71 }
72 }
73
75 if (auto* ptr = dynamic_cast<ColumnVectorBase*>(this);
76 ptr != nullptr) {
77 return *ptr;
78 } else {
79 throw std::invalid_argument("FieldArrayD is not based on ColumnVectorBase. Something is wrong.");
80 }
81 }
82
84 virtual void setProcessingContext(ProcessingContext context) = 0;
86 virtual void resize(std::size_t newCount) = 0;
87
88 const auto& operator[](unsigned iDim) const
89 {
90 return getAbstractColumn(iDim);
91 }
92
93 auto& operator[](unsigned iDim)
94 {
95 return getAbstractColumn(iDim);
96 }
97
98 auto get(std::size_t i) const
99 {
100 if constexpr (DESCRIPTOR::template size<FIELD>() == 1) {
101 return operator[](0)[i];
102 } else {
104 DESCRIPTOR::template size<FIELD>()>([this,i](unsigned iD) {
105 return operator[](iD)[i];
106 });
107 }
108 }
109
110 void set(std::size_t i, const FieldD<T,DESCRIPTOR,FIELD>& data)
111 {
112 for (unsigned iD=0; iD < DESCRIPTOR::template size<FIELD>(); ++iD) {
113 operator[](iD)[i] = data[iD];
114 }
115 }
116
117 const_ptr getPointer(std::size_t i) const
118 {
119 return const_ptr(*this, i);
120 }
121
122 ptr getPointer(std::size_t i)
123 {
124 return ptr(*this, i);
125 }
126
127};
128
130template<typename T, typename DESCRIPTOR, typename FIELD>
131class AbstractFieldArrayD<T,DESCRIPTOR,FIELD>::const_ptr
132 : public ScalarVector<const typename FIELD::template value_type<T>,
133 DESCRIPTOR::template size<FIELD>(),
134 const_ptr> {
135private:
137 std::size_t _index;
138
140 DESCRIPTOR::template size<FIELD>(),
141 const_ptr>::type;
142
143protected:
144
145public:
146 const_ptr(const AbstractFieldArrayD<T,DESCRIPTOR,FIELD>& data, std::size_t index):
147 _data(data),
148 _index(index) { }
149
151 _data(rhs._data),
152 _index(rhs._index) { }
153
154 const typename FIELD::template value_type<T>* getComponentPointer(unsigned iDim) const
155 {
156 return &_data[iDim][_index];
157 }
158
159 std::size_t getIndex() const
160 {
161 return _index;
162 }
163
164 void setIndex(std::size_t index)
165 {
166 _index = index;
167 }
168
169};
170
172template<typename T, typename DESCRIPTOR, typename FIELD>
173class AbstractFieldArrayD<T,DESCRIPTOR,FIELD>::ptr
174 : public ScalarVector<typename FIELD::template value_type<T>,
175 DESCRIPTOR::template size<FIELD>(),
176 ptr> {
177private:
179 std::size_t _index;
180
182 DESCRIPTOR::template size<FIELD>(),
183 ptr>::type;
184
185protected:
186
187public:
189 _data(data),
190 _index(index) { }
191
192 ptr(ptr&& rhs):
193 _data(rhs._data),
194 _index(rhs._index) { }
195
196 const typename FIELD::template value_type<T>* getComponentPointer(unsigned iDim) const
197 {
198 return &_data[iDim][_index];
199 }
200
201 typename FIELD::template value_type<T>* getComponentPointer(unsigned iDim)
202 {
203 return &_data[iDim][_index];
204 }
205
206 template <typename U, typename IMPL>
207 ptr& operator=(const GenericVector<U,DESCRIPTOR::template size<FIELD>(),IMPL>& rhs)
208 {
209 for (unsigned iD=0; iD < DESCRIPTOR::template size<FIELD>(); ++iD) {
210 this->operator[](iD) = rhs[iD];
211 }
212 return *this;
213 }
214
215 std::size_t getIndex() const
216 {
217 return _index;
218 }
219
220 void setIndex(std::size_t index)
221 {
222 _index = index;
223 }
224
225};
226
227
229template<typename T, typename DESCRIPTOR, Platform PLATFORM, typename FIELD>
230class FieldArrayD final : public ColumnVector<typename ImplementationOf<typename FIELD::template column_type<T>,PLATFORM>::type,
231 DESCRIPTOR::template size<FIELD>()>
232 , public AbstractFieldArrayD<T,DESCRIPTOR,FIELD>
233{
234private:
235 const typename FIELD::template column_type<T>& getAbstractColumn(unsigned iDim) const override
236 {
237 return this->operator[](iDim);
238 }
239
240 typename FIELD::template column_type<T>& getAbstractColumn(unsigned iDim) override
241 {
242 return this->operator[](iDim);
243 }
244
245public:
246 using field_t = FIELD;
247 using value_type = typename FIELD::template value_type<T>;
249
250 constexpr static Platform platform = PLATFORM;
251
252 using ColumnVector<column_type,DESCRIPTOR::template size<FIELD>()>::operator[];
253
254 FieldArrayD(std::size_t count):
256 DESCRIPTOR::template size<FIELD>()>(count)
257 {
258 const auto initial = FIELD::template getInitialValue<T,DESCRIPTOR>();
259 for (std::size_t i=0; i < count; ++i) {
260 this->getRowPointer(i) = initial;
261 }
262 }
263
265 {
266 return static_cast<const AbstractFieldArrayD<T,DESCRIPTOR,FIELD>&>(*this);
267 }
268
273
274 Platform getPlatform() const override
275 {
276 return PLATFORM;
277 }
278
280 {
281 for (unsigned iDim=0; iDim < DESCRIPTOR::template size<FIELD>(); ++iDim) {
282 this->operator[](iDim).setProcessingContext(context);
283 }
284 }
285
286 void resize(std::size_t newCount) override {
287 const std::size_t oldCount = this->_count;
288 for (unsigned iDim=0; iDim < DESCRIPTOR::template size<FIELD>(); ++iDim) {
289 operator[](iDim).resize(newCount);
290 }
291 this->_count = newCount;
292 if (oldCount < newCount) {
293 const auto initial = FIELD::template getInitialValue<T,DESCRIPTOR>();
294 for (std::size_t i=oldCount; i < newCount; ++i) {
295 this->getRowPointer(i) = initial;
296 }
297 }
298 }
299
301 auto getField(std::size_t iCell) const
302 {
303 return this->getRow(iCell);
304 }
305
307 void setField(std::size_t iCell, const FieldD<T,DESCRIPTOR,FIELD>& v)
308 {
309 this->setRow(iCell, v);
310 }
311
312 auto getFieldPointer(std::size_t iCell) const
313 {
314 return this->getRowPointer(iCell);
315 }
316 auto getFieldPointer(std::size_t iCell)
317 {
318 return this->getRowPointer(iCell);
319 }
320
321};
322
324template <typename T, typename DESCRIPTOR, typename FIELD>
326 using value_t = T;
327
329
330 template <Platform PLATFORM>
332
333};
334
335template<typename T> class LoadBalancer;
336
338
341template <typename T, typename DESCRIPTOR, typename FIELD>
342std::unique_ptr<AbstractFieldArrayD<T,DESCRIPTOR,FIELD>> makeSharedAbstractFieldArrayD(
343 LoadBalancer<T>& loadBalancer, std::size_t count=1)
344{
345 #if defined(PLATFORM_GPU_CUDA)
346 if (loadBalancer.isLocal(Platform::GPU_CUDA)) {
347 return std::unique_ptr<AbstractFieldArrayD<T,DESCRIPTOR,FIELD>>(
349 } else {
350 return std::unique_ptr<AbstractFieldArrayD<T,DESCRIPTOR,FIELD>>(
352 }
353 #else
354 return std::unique_ptr<AbstractFieldArrayD<T,DESCRIPTOR,FIELD>>(
356 #endif
357}
358
359template <typename T, typename DESCRIPTOR, Platform PLATFORM, typename FIELD>
360class ConcreteCommunicatable<FieldArrayD<T,DESCRIPTOR,PLATFORM,FIELD>> final : public Communicatable {
361private:
363
364public:
366 _communicatee{communicatee} { }
367
369 std::size_t size(ConstSpan<CellID> indices) const override
370 {
372 ColumnVector<typename ImplementationOf<typename FIELD::template column_type<T>,PLATFORM>::type,
373 DESCRIPTOR::template size<FIELD>()>
374 >(_communicatee).size(indices));
375 }
376
378 std::size_t serialize(ConstSpan<CellID> indices,
379 std::uint8_t* buffer) const override
380 {
381 std::uint8_t* curr = buffer;
384 DESCRIPTOR::template size<FIELD>()>
385 >(_communicatee).serialize(indices, curr);
386 return curr - buffer;
387 }
388
390 std::size_t deserialize(ConstSpan<CellID> indices,
391 const std::uint8_t* buffer) override
392 {
393 const std::uint8_t* curr = buffer;
396 DESCRIPTOR::template size<FIELD>()>
397 >(_communicatee).deserialize(indices, curr);
398 return curr - buffer;
399 }
400};
401
403
409template<typename T, typename DESCRIPTOR, Platform PLATFORM, typename... FIELDS>
411private:
413 std::size_t _count;
415 std::tuple<FieldArrayD<T,DESCRIPTOR,PLATFORM,FIELDS>...> _static;
416
417public:
418 using fields_t = meta::list<FIELDS...>;
419
420 MultiFieldArrayD(std::size_t count=1):
421 _count(count),
422 // Trickery to construct each member of _static with `count`.
423 // Uses the comma operator in conjunction with type dropping.
424 _static((std::void_t<FIELDS>(), count)...)
425 { }
426
427 template <typename FIELD>
429 {
430 static_assert(meta::contains<FIELD,FIELDS...>(), "FIELD not contained in FIELDS");
431 return std::get<(fields_t::template index<FIELD>())>(_static);
432 }
433
434 template <typename FIELD>
436 {
437 static_assert(meta::contains<FIELD,FIELDS...>(), "FIELD not contained in FIELDS");
438 return std::get<(fields_t::template index<FIELD>())>(_static);
439 }
440
442 template <typename FIELD>
443 auto getField(std::size_t iCell) const
444 {
445 return get<FIELD>().getRow(iCell);
446 }
447
449 template <typename FIELD>
450 void setField(std::size_t iCell, const FieldD<T,DESCRIPTOR,FIELD>& v)
451 {
452 get<FIELD>().setRow(iCell, v);
453 }
454
455 template <typename FIELD>
456 const typename FIELD::template value_type<T>& getFieldComponent(std::size_t iCell, unsigned iDim) const;
457 template <typename FIELD>
458 typename FIELD::template value_type<T>& getFieldComponent(std::size_t iCell, unsigned iDim);
459
460 template <typename FIELD>
461 auto getFieldPointer(std::size_t iCell) const
462 {
463 return get<FIELD>().getRowPointer(iCell);
464 }
465 template <typename FIELD>
466 auto getFieldPointer(std::size_t iCell)
467 {
468 return get<FIELD>().getRowPointer(iCell);
469 }
470
472 template <typename F>
473 void forFields(F f) const;
474 template <typename F>
475 void forFields(F f);
477 template <typename F>
478 void forFieldsAt(std::size_t idx, F f);
479
481
484 void resize(std::size_t newCount)
485 {
486 forFields([newCount](auto& fieldArray) {
487 fieldArray.resize(newCount);
488 });
489 _count = newCount;
490 }
491
493 void swap(std::size_t i, std::size_t j)
494 {
495 forFields([i,j](auto& fieldArray) {
496 fieldArray.swap(i,j);
497 });
498 }
499
501 forFields([context](auto& fieldArray) {
502 fieldArray.setProcessingContext(context);
503 });
504 }
505
507 std::size_t getNblock() const override;
509 std::size_t getSerializableSize() const override;
511 bool* getBlock(std::size_t iBlock, std::size_t& sizeBlock, bool loadingMode) override;
512
513};
514
515//template <typename T, typename DESCRIPTOR, Platform PLATFORM, typename FIELD>
516//ConcreteCommunicatable(FieldArrayD<T,DESCRIPTOR,PLATFORM,FIELD>&) -> ConcreteCommunicatable<
517// ColumnVector<typename ImplementationOf<typename FIELD::template column_type<T>,PLATFORM>::type,
518// DESCRIPTOR::template size<FIELD>()>
519//>;
520
521
522template <typename T, typename DESCRIPTOR, Platform PLATFORM, typename... FIELDS>
523class ConcreteCommunicatable<MultiFieldArrayD<T,DESCRIPTOR,PLATFORM,FIELDS...>> final : public Communicatable {
524private:
525 MultiFieldArrayD<T,DESCRIPTOR,PLATFORM,FIELDS...>& _communicatee;
526
527public:
529 _communicatee{communicatee} { }
530
532 std::size_t size(ConstSpan<CellID> indices) const override
533 {
535 ColumnVector<typename ImplementationOf<typename FIELDS::template column_type<T>,PLATFORM>::type,
536 DESCRIPTOR::template size<FIELDS>()>
537 >(_communicatee.template get<FIELDS>()).size(indices) + ... + 0);
538 }
539
541 std::size_t serialize(ConstSpan<CellID> indices,
542 std::uint8_t* buffer) const override
543 {
544 std::uint8_t* curr = buffer;
545 meta::list<FIELDS...>::for_each([&](auto field) {
546 using FIELD = typename decltype(field)::type;
549 DESCRIPTOR::template size<FIELD>()>
550 >(_communicatee.get(field)).serialize(indices, curr);
551 });
552 return curr - buffer;
553 }
554
556 std::size_t deserialize(ConstSpan<CellID> indices,
557 const std::uint8_t* buffer) override
558 {
559 const std::uint8_t* curr = buffer;
560 meta::list<FIELDS...>::for_each([&](auto field) {
561 using FIELD = typename decltype(field)::type;
564 DESCRIPTOR::template size<FIELD>()>
565 >(_communicatee.get(field)).deserialize(indices, curr);
566 });
567 return curr - buffer;
568 }
569};
570
571
573template <typename T, typename GROUPS>
575template <typename T, typename... GROUPS>
576class DynamicFieldGroupsD<T, meta::list<GROUPS...>> {
577private:
578 template <typename GROUP>
579 struct GroupedFieldArrayD {
580 template <typename... FIELDS>
581 using curried = MultiFieldArrayD<T,GROUP,Platform::CPU_SISD,FIELDS...>;
582 using type = typename GROUP::template decompose_into<curried>;
583 };
584
585 std::tuple<typename GroupedFieldArrayD<GROUPS>::type...> _data;
586
587 std::size_t _count;
588
589public:
590 DynamicFieldGroupsD(std::size_t count):
591 _data((std::void_t<GROUPS>(), count)...), _count(count) { }
592
593 template <typename GROUP>
594 auto& get() {
595 if constexpr (meta::contains<GROUP,GROUPS...>()) {
596 return std::get<descriptors::getIndexInFieldList<GROUP,GROUPS...>()>(_data);
597 } else {
598 throw std::invalid_argument("This DynamicFieldGroupsD does not provide GROUP.");
599 }
600 }
601
602 std::size_t count(){ return _count; }
603
604 void resize(std::size_t newCount) {
605 (get<GROUPS>().resize(newCount), ...);
606 _count = newCount;
607 }
608
609 void swap(std::size_t i, std::size_t j)
610 {
611 (get<GROUPS>().swap(i,j), ...);
612 }
613
614 std::size_t constexpr getSerializableSize()
615 {
616 return (get<GROUPS>().getSerializableSize() + ... + 0);
617 }
618
619};
620
621
622
623
624//Communicatable for GroupedFieldArrays
625template<typename DATA, typename... GROUPS>
627private:
628 DATA& _data;
629
630public:
632 : _data(data) {}
633
635 std::size_t size(ConstSpan<CellID> indices) const
636 {
637 std::size_t size = 0;
638 meta::list<GROUPS...>::for_each([&](auto group) {
639 using GROUP = typename decltype(group)::type;
640 // Workaround for Clang argument deduction bug
641 auto communicatable = ConcreteCommunicatable(_data.template get<GROUP>());
642 size += communicatable.size(indices);
643 });
644 return size;
645 }
646
648 std::size_t serialize(ConstSpan<CellID> indices, std::uint8_t* buffer) const
649 {
650 std::uint8_t* curr = buffer;
651 meta::list<GROUPS...>::for_each([&](auto group) {
652 using GROUP = typename decltype(group)::type;
653 // Workaround for Clang argument deduction bug
654 auto communicatable = ConcreteCommunicatable(_data.template get<GROUP>());
655 curr += communicatable.serialize(indices, curr);
656 });
657 return curr - buffer;
658 }
659
661 std::size_t deserialize(ConstSpan<CellID> indices, const std::uint8_t* buffer)
662 {
663 const std::uint8_t* curr = buffer;
664 meta::list<GROUPS...>::for_each([&](auto group) {
665 using GROUP = typename decltype(group)::type;
666 // Workaround for Clang argument deduction bug
667 auto communicatable = ConcreteCommunicatable(_data.template get<GROUP>());
668 curr += communicatable.deserialize(indices, curr);
669 });
670 return curr - buffer;
671 }
672};
673
675template <typename DATA, typename DESCRIPTOR>
677 template<typename... GROUPS>
679
680 using type = typename DESCRIPTOR::template decompose_into<CurriedFieldGroupsCommunicatable>;
681};
682
684template <typename T, typename DESCRIPTOR, Platform PLATFORM>
686 template<typename... FIELDS>
687 using CurriedMultiFieldArrayD = MultiFieldArrayD<T,DESCRIPTOR,PLATFORM,FIELDS...>;
688
689 using type = typename DESCRIPTOR::fields_t::template decompose_into<CurriedMultiFieldArrayD>;
690};
691
693template <typename T, typename DESCRIPTOR, Platform PLATFORM=Platform::CPU_SISD>
695
696
697}
698
699#endif
Read-only proxy for accessing a column vector entry.
const FIELD::template value_type< T > * getComponentPointer(unsigned iDim) const
const_ptr(const AbstractFieldArrayD< T, DESCRIPTOR, FIELD > &data, std::size_t index)
void setIndex(std::size_t index)
Proxy for accessing a column vector entry.
ptr & operator=(const GenericVector< U, DESCRIPTOR::template size< FIELD >(), IMPL > &rhs)
const FIELD::template value_type< T > * getComponentPointer(unsigned iDim) const
FIELD::template value_type< T > * getComponentPointer(unsigned iDim)
ptr(AbstractFieldArrayD< T, DESCRIPTOR, FIELD > &data, std::size_t index)
std::size_t getIndex() const
void setIndex(std::size_t index)
Platform-agnostic interface to concrete host-side field arrays.
Definition fieldArrayD.h:49
auto & operator[](unsigned iDim)
Definition fieldArrayD.h:93
const auto & operator[](unsigned iDim) const
Definition fieldArrayD.h:88
void set(std::size_t i, const FieldD< T, DESCRIPTOR, FIELD > &data)
const_ptr getPointer(std::size_t i) const
auto get(std::size_t i) const
Definition fieldArrayD.h:98
virtual Platform getPlatform() const =0
Returns Platform of concrete FieldArrayD.
FieldArrayD< T, DESCRIPTOR, PLATFORM, FIELD > & asConcrete()
Cast to concrete FieldArrayD<PLATFORM>
Definition fieldArrayD.h:65
ColumnVectorBase & asColumnVectorBase()
Definition fieldArrayD.h:74
virtual void setProcessingContext(ProcessingContext context)=0
Sets processing context (Platform dependent)
virtual void resize(std::size_t newCount)=0
Resize to size newCount.
ptr getPointer(std::size_t i)
Vector of columns.
auto setRow(std::size_t i, const Vector< typename ImplementationOf< FIELD::template column_type< T >, PLATFORM >::type::value_t, D > &value)
std::size_t size(ConstSpan< CellID > indices) const override
Get serialized size for data at locations indices
ConcreteCommunicatable(FieldArrayD< T, DESCRIPTOR, PLATFORM, FIELD > &communicatee)
std::size_t serialize(ConstSpan< CellID > indices, std::uint8_t *buffer) const override
Serialize data at locations indices to buffer
std::size_t deserialize(ConstSpan< CellID > indices, const std::uint8_t *buffer) override
Deserialize data at locations indices to buffer
std::size_t size(ConstSpan< CellID > indices) const override
Get serialized size for data at locations indices
std::size_t deserialize(ConstSpan< CellID > indices, const std::uint8_t *buffer) override
Deserialize data at locations indices to buffer
ConcreteCommunicatable(MultiFieldArrayD< T, DESCRIPTOR, PLATFORM, FIELDS... > &communicatee)
std::size_t serialize(ConstSpan< CellID > indices, std::uint8_t *buffer) const override
Serialize data at locations indices to buffer
std::size_t size() const
ADDITIONAL NON OVERWITTEN CALLS: Removing the necessity to provide indices.
std::size_t deserialize(ConstSpan< CellID > indices, const std::uint8_t *buffer) override
Deserialize data at locations indices to buffer
std::size_t serialize(ConstSpan< CellID > indices, std::uint8_t *buffer) const override
Serialize data at locations indices to buffer
Storage for dynamic field groups (Prototype for ParticleSystem)
SoA storage for instances of a single FIELD.
AbstractFieldArrayD< T, DESCRIPTOR, FIELD > & asAbstract()
auto getFieldPointer(std::size_t iCell) const
auto getField(std::size_t iCell) const
Return copy of FIELD data for cell iCell.
void setProcessingContext(ProcessingContext context) override
Sets processing context (Platform dependent)
Platform getPlatform() const override
Returns Platform of concrete FieldArrayD.
static constexpr Platform platform
void resize(std::size_t newCount) override
const AbstractFieldArrayD< T, DESCRIPTOR, FIELD > & asAbstract() const
void setField(std::size_t iCell, const FieldD< T, DESCRIPTOR, FIELD > &v)
Set FIELD data at cell iCell.
auto getFieldPointer(std::size_t iCell)
FieldArrayD(std::size_t count)
typename FIELD::template value_type< T > value_type
typename ImplementationOf< typename FIELD::template column_type< T >, PLATFORM >::type column_type
std::size_t serialize(ConstSpan< CellID > indices, std::uint8_t *buffer) const
Serialize data at locations indices to buffer
std::size_t size(ConstSpan< CellID > indices) const
Get serialized size for data at locations indices
std::size_t deserialize(ConstSpan< CellID > indices, const std::uint8_t *buffer)
Deserialize data at locations indices to buffer
Base class for all LoadBalancer.
Definition vtiWriter.h:42
bool isLocal(const int &glob) const
returns whether glob is on this process
Storage for a fixed set of FIELDS.
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.
MultiFieldArrayD(std::size_t count=1)
void setField(std::size_t iCell, const FieldD< T, DESCRIPTOR, FIELD > &v)
Set FIELD data at cell iCell.
auto getField(std::size_t iCell) const
Return copy of FIELD data for cell iCell.
std::size_t getSerializableSize() const override
Binary size for the serializer.
void resize(std::size_t newCount)
Change number of rows.
void swap(std::size_t i, std::size_t j)
Swap contents of rows i and j.
auto getFieldPointer(std::size_t iCell)
auto getFieldPointer(std::size_t iCell) const
const FIELD::template value_type< T > & getFieldComponent(std::size_t iCell, unsigned iDim) const
void setProcessingContext(ProcessingContext context)
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.
const FieldArrayD< T, DESCRIPTOR, PLATFORM, FIELD > & get(meta::id< FIELD > field=meta::id< FIELD >()) const
FieldArrayD< T, DESCRIPTOR, PLATFORM, FIELD > & get(meta::id< FIELD > field=meta::id< FIELD >())
void forFields(F f) const
Apply generic expression to each FIELD array.
Base class for serializable objects of constant size. For dynamic size use BufferSerializable.
Definition serializer.h:145
Plain old scalar vector.
constexpr unsigned getIndexInFieldList()
Definition fields.h:482
constexpr bool contains()
Returns true iff a given type list contains WANTED.
Definition meta.h:125
Top level namespace for all of OpenLB.
ProcessingContext
OpenLB processing contexts.
Definition platform.h:54
Platform
OpenLB execution targets.
Definition platform.h:35
@ GPU_CUDA
Vector CPU (AVX2 / AVX-512 collision)
typename MultiFieldArrayForDescriptorHelper< T, DESCRIPTOR, PLATFORM >::type MultiFieldArrayForDescriptorD
MultiFieldArrayD containing each field in DESCRIPTOR::fields_t.
std::unique_ptr< AbstractFieldArrayD< T, DESCRIPTOR, FIELD > > makeSharedAbstractFieldArrayD(LoadBalancer< T > &loadBalancer, std::size_t count=1)
Constructs FieldArrayD accessible on all locally used platforms.
Base to identify whether a type is some kind of AbstractFieldArrayD without caring about the specific...
Definition fieldArrayD.h:45
Base of all ColumnVector specializations.
Curried FieldArrayD template for use in callUsingConcretePlatform.
Generic vector of values supporting basic arithmetic.
static constexpr unsigned size()
Declare GroupedDataCommunicatable containing each GROUP in DESCRIPTOR::fields_t.
typename DESCRIPTOR::template decompose_into< CurriedFieldGroupsCommunicatable > type
Specializable declarator for concrete implementations of abstract storage types.
Definition column.h:56
Declare MultiFieldArrayD containing each field in DESCRIPTOR::fields_t.
typename DESCRIPTOR::fields_t::template decompose_into< CurriedMultiFieldArrayD > type
Vector of scalars.
Identity type to pass non-constructible types as value.
Definition meta.h:79
static constexpr void for_each(F f)
Calls f for each type of TYPES by-value (in reversed order!)
Definition meta.h:331
efficient implementation of a vector class