24#ifndef FIELD_ARRAY_D_H
25#define FIELD_ARRAY_D_H
42template<
typename T,
typename DESCRIPTOR,
typename FIELD>
44 typename FIELD::template value_type<T>,
45 DESCRIPTOR::template size<FIELD>()
49template<
typename T,
typename DESCRIPTOR,
typename FIELD>
52 virtual const typename FIELD::template column_type<T>& getAbstractColumn(
unsigned iDim)
const = 0;
53 virtual typename FIELD::template column_type<T>& getAbstractColumn(
unsigned iDim) = 0;
61 return getAbstractColumn(iDim);
66 return getAbstractColumn(iDim);
69 auto get(std::size_t i)
const
71 if constexpr (DESCRIPTOR::template size<FIELD>() == 1) {
75 DESCRIPTOR::template size<FIELD>()>([
this,i](
unsigned iD) {
83 for (
unsigned iD=0; iD < DESCRIPTOR::template size<FIELD>(); ++iD) {
98 virtual void resize(std::size_t newCount) = 0;
105template<
typename T,
typename DESCRIPTOR,
typename FIELD>
107 :
public ScalarVector<const typename FIELD::template value_type<T>,
108 DESCRIPTOR::template size<FIELD>(),
115 DESCRIPTOR::template size<FIELD>(),
121 return &_data[iDim][_index];
131 _index(rhs._index) { }
146template<
typename T,
typename DESCRIPTOR,
typename FIELD>
148 :
public ScalarVector<typename FIELD::template value_type<T>,
149 DESCRIPTOR::template size<FIELD>(),
156 DESCRIPTOR::template size<FIELD>(),
162 return &_data[iDim][_index];
167 return &_data[iDim][_index];
177 _index(rhs._index) { }
179 template <
typename U,
typename IMPL>
182 for (
unsigned iD=0; iD < DESCRIPTOR::template size<FIELD>(); ++iD) {
202template<
typename T,
typename DESCRIPTOR, Platform PLATFORM,
typename FIELD>
203class FieldArrayD final :
public ColumnVector<typename ImplementationOf<typename FIELD::template column_type<T>,PLATFORM>::type,
204 DESCRIPTOR::template size<FIELD>()>
208 const typename FIELD::template
column_type<T>& getAbstractColumn(
unsigned iDim)
const override
213 typename FIELD::template
column_type<T>& getAbstractColumn(
unsigned iDim)
override
227 DESCRIPTOR::template size<FIELD>()>(count)
229 const auto initial = FIELD::template getInitialValue<T,DESCRIPTOR>();
230 for (std::size_t i=0; i < count; ++i) {
247 for (
unsigned iDim=0; iDim < DESCRIPTOR::template size<FIELD>(); ++iDim) {
248 this->
operator[](iDim).setProcessingContext(context);
252 void resize(std::size_t newCount)
override {
253 const std::size_t oldCount = this->
_count;
256 DESCRIPTOR::template size<FIELD>()
257 >*>(
this)->
resize(newCount);
258 if (oldCount < newCount) {
259 const auto initial = FIELD::template getInitialValue<T,DESCRIPTOR>();
260 for (std::size_t i=oldCount; i < newCount; ++i) {
269 return this->
getRow(iCell);
290template <
typename T,
typename DESCRIPTOR,
typename FIELD>
295template <Platform PLATFORM>
301template <
typename T,
typename DESCRIPTOR, Platform PLATFORM,
typename FIELD>
308 _communicatee{communicatee} { }
315 DESCRIPTOR::template size<FIELD>()>
316 >(_communicatee).
size(indices));
321 std::uint8_t* buffer)
const override
323 std::uint8_t* curr = buffer;
326 DESCRIPTOR::template size<FIELD>()>
327 >(_communicatee).
serialize(indices, curr);
328 return curr - buffer;
333 const std::uint8_t* buffer)
override
335 const std::uint8_t* curr = buffer;
338 DESCRIPTOR::template size<FIELD>()>
340 return curr - buffer;
351template<
typename T,
typename DESCRIPTOR,
Platform PLATFORM,
typename... FIELDS>
357 std::tuple<FieldArrayD<T,DESCRIPTOR,PLATFORM,FIELDS>...> _static;
366 _static((std::void_t<FIELDS>(), count)...)
369 template <
typename FIELD>
372 static_assert(
meta::contains<FIELD,FIELDS...>(),
"FIELD not contained in FIELDS");
373 return std::get<(fields_t::template index<FIELD>())>(_static);
376 template <
typename FIELD>
379 static_assert(
meta::contains<FIELD,FIELDS...>(),
"FIELD not contained in FIELDS");
380 return std::get<(fields_t::template index<FIELD>())>(_static);
384 template <
typename FIELD>
387 return get<FIELD>().getRow(iCell);
391 template <
typename FIELD>
394 get<FIELD>().setRow(iCell, v);
397 template <
typename FIELD>
398 const typename FIELD::template value_type<T>&
getFieldComponent(std::size_t iCell,
unsigned iDim)
const;
399 template <
typename FIELD>
400 typename FIELD::template value_type<T>&
getFieldComponent(std::size_t iCell,
unsigned iDim);
402 template <
typename FIELD>
405 return get<FIELD>().getRowPointer(iCell);
407 template <
typename FIELD>
410 return get<FIELD>().getRowPointer(iCell);
414 template <
typename F>
416 template <
typename F>
419 template <
typename F>
429 fieldArray.resize(newCount);
435 void swap(std::size_t i, std::size_t j)
438 fieldArray.swap(i,j);
444 fieldArray.setProcessingContext(context);
453 bool*
getBlock(std::size_t iBlock, std::size_t& sizeBlock,
bool loadingMode)
override;
464template <
typename T,
typename DESCRIPTOR,
Platform PLATFORM,
typename... FIELDS>
471 _communicatee{communicatee} { }
478 DESCRIPTOR::template size<FIELDS>()>
479 >(_communicatee.template get<FIELDS>()).
size(indices) + ... + 0);
484 std::uint8_t* buffer)
const override
486 std::uint8_t* curr = buffer;
488 using FIELD =
typename decltype(field)::type;
491 DESCRIPTOR::template size<FIELD>()>
492 >(_communicatee.template get(field)).
serialize(indices, curr);
494 return curr - buffer;
499 const std::uint8_t* buffer)
override
501 const std::uint8_t* curr = buffer;
503 using FIELD =
typename decltype(field)::type;
506 DESCRIPTOR::template size<FIELD>()>
507 >(_communicatee.template get(field)).
deserialize(indices, curr);
509 return curr - buffer;
515template <
typename T,
typename GROUPS>
517template <
typename T,
typename... GROUPS>
520 template <
typename GROUP>
521 struct GroupedFieldArrayD {
522 template <
typename... FIELDS>
524 using type =
typename GROUP::template decompose_into<curried>;
527 std::tuple<typename GroupedFieldArrayD<GROUPS>::type...> _data;
533 _data((std::void_t<GROUPS>(), count)...), _count(count) { }
535 template <
typename GROUP>
540 throw std::invalid_argument(
"This DynamicFieldGroupsD does not provide GROUP.");
544 std::size_t
count(){
return _count; }
547 (get<GROUPS>().resize(newCount), ...);
551 void swap(std::size_t i, std::size_t j)
553 (get<GROUPS>().swap(i,j), ...);
558 return (get<GROUPS>().getSerializableSize() + ... + 0);
567template<
typename DATA,
typename... GROUPS>
579 std::size_t
size = 0;
581 using GROUP =
typename decltype(group)::type;
584 size += communicatable.size(indices);
592 std::uint8_t* curr = buffer;
594 using GROUP =
typename decltype(group)::type;
597 curr += communicatable.serialize(indices, curr);
599 return curr - buffer;
605 const std::uint8_t* curr = buffer;
607 using GROUP =
typename decltype(group)::type;
610 curr += communicatable.deserialize(indices, curr);
612 return curr - buffer;
617template <
typename DATA,
typename DESCRIPTOR>
619 template<
typename... GROUPS>
622 using type =
typename DESCRIPTOR::template decompose_into<CurriedFieldGroupsCommunicatable>;
626template <
typename T,
typename DESCRIPTOR, Platform PLATFORM>
628 template<
typename... FIELDS>
631 using type =
typename DESCRIPTOR::fields_t::template decompose_into<CurriedMultiFieldArrayD>;
635template <
typename T,
typename DESCRIPTOR, Platform PLATFORM=Platform::CPU_SISD>
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)
const_ptr(const_ptr &&rhs)
std::size_t getIndex() const
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.
auto & operator[](unsigned iDim)
const auto & operator[](unsigned iDim) const
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
virtual void setProcessingContext(ProcessingContext context)=0
virtual void resize(std::size_t newCount)=0
ptr getPointer(std::size_t i)
auto setRow(std::size_t i, const Vector< typename COLUMN::value_t, D > &value)
std::size_t _count
Number of rows.
auto getRow(std::size_t i) const
Return copy of data at index i.
ptr getRowPointer(std::size_t i)
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
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
GroupedDataCommunicatable(DATA &data)
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
Storage for a fixed set of static FIELDS and arbitrary custom 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.
constexpr unsigned getIndexInFieldList()
Top level namespace for all of OpenLB.
ProcessingContext
OpenLB processing contexts.
Platform
OpenLB execution targets.
typename MultiFieldArrayForDescriptorHelper< T, DESCRIPTOR, PLATFORM >::type MultiFieldArrayForDescriptorD
MultiFieldArrayD containing each field in DESCRIPTOR::fields_t.
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.
Declare MultiFieldArrayD containing each field in DESCRIPTOR::fields_t.
typename DESCRIPTOR::fields_t::template decompose_into< CurriedMultiFieldArrayD > type
efficient implementation of a vector class