37template <
typename T, Platform PLATFORM>
class ConcreteBlockMask;
38template <
typename T,
typename DESCRIPTOR>
class BlockLattice;
39template <
typename T,
typename DESCRIPTOR>
class BlockD;
40template <
typename T,
typename DESCRIPTOR>
class Cell;
49template <
typename FIELD>
53 template <
typename T,
typename DESCRIPTOR, Platform PLATFORM>
61template <
typename OPERATOR>
63 template <
typename T,
typename DESCRIPTOR, Platform PLATFORM>
71template <
typename DYNAMICS>
73 template <
typename T,
typename DESCRIPTOR, Platform PLATFORM>
80template <
typename FIELD>
82 return std::is_base_of_v<field_type_of_field_array_tag, FIELD>;
94template<
typename T,
typename DESCRIPTOR>
98 const std::string _name;
101 std::optional<unsigned> _dim = std::nullopt;
112 template <
typename FIELD_TYPE>
114 _name{fields::
name<FIELD_TYPE>()},
115 _allocateInLattice([](
BlockLattice<T,DESCRIPTOR>& block) {
117 block.template getData<FIELD_TYPE>();
121 block.template getData<FIELD_TYPE>();
123 _setPlaceholderExpr([](Cell<Expr,DESCRIPTOR>& cell, std::vector<Expr>& expr) {
124 if constexpr (concepts::LatticeDescriptor<DESCRIPTOR>) {
126 if constexpr (std::is_same_v<Expr, typename FieldD<Expr,DESCRIPTOR,typename FIELD_TYPE::field_t>::value_t>) {
128 for (
unsigned iD=0; iD < placeholder.d; ++iD) {
129 placeholder[iD] = expr[iD];
131 cell.template setField<typename FIELD_TYPE::field_t>(placeholder);
133 throw std::runtime_error(
"Can not set placeholder for non-T types");
136 throw std::runtime_error(
"Can not set placeholder for non-FieldArray types");
140 _getPlaceholderExpr([](Cell<Expr,DESCRIPTOR>& cell) {
141 std::vector<Expr> expressions;
142 if constexpr (concepts::LatticeDescriptor<DESCRIPTOR>) {
144 if constexpr (std::is_same_v<Expr, typename FieldD<Expr,DESCRIPTOR,typename FIELD_TYPE::field_t>::value_t>) {
146 placeholder = cell.template getFieldPointer<typename FIELD_TYPE::field_t>();
147 for (
unsigned iD=0; iD < placeholder.d; ++iD) {
148 expressions.push_back(placeholder[iD]);
151 throw std::runtime_error(
"Can not get placeholder for non-T types");
154 throw std::runtime_error(
"Can not get placeholder for non-FieldArray types");
161 _dim = std::optional<unsigned>{DESCRIPTOR::template size<typename FIELD_TYPE::field_t>()};
174 _allocateInLattice(block);
178 _allocateInBlockD(block);
182 _setPlaceholderExpr(cell, expr);
186 return _getPlaceholderExpr(cell);
199template<
typename T,
typename DESCRIPTOR, Platform PLATFORM>
202 const std::string _name;
205 std::unique_ptr<Serializable> _data;
209 template<
typename FIELD_TYPE,
typename... ARGS>
211 _name(fields::name<FIELD_TYPE>()),
213 _data(new typename FIELD_TYPE::template type<T,DESCRIPTOR,PLATFORM>(
214 std::forward<decltype(args)>(args)...)),
216 static_cast<typename FIELD_TYPE::template type<T,DESCRIPTOR,PLATFORM>*
>(_data.get())->
setProcessingContext(context);
228 template<
typename FIELD_TYPE>
229 const auto*
as()
const {
230 return static_cast<const typename FIELD_TYPE::template type<T,DESCRIPTOR,PLATFORM>*
>(_data.get());
232 template<
typename FIELD_TYPE>
234 return static_cast<typename FIELD_TYPE::template type<T,DESCRIPTOR,PLATFORM>*
>(_data.get());
241 template<
typename TYPE>
243 if (TYPE* ptr =
dynamic_cast<TYPE*
>(_data.get())) {
244 return std::optional<TYPE*>(ptr);
251 _setProcessingContext(context);
260template<
typename T,
typename DESCRIPTOR, Platform PLATFORM>
270 template <
typename FIELD_TYPE>
279 template <
typename FIELD_TYPE>
287 template <
typename FIELD_TYPE>
293 template <
typename FIELD_TYPE>
295 _index.template set<FIELD_TYPE>(fieldType);
301template<
typename T,
typename DESCRIPTOR>
class Data;
302template<
typename T,
typename DESCRIPTOR, Platform PLATFORM>
class ConcreteData;
305template<
typename T,
typename DESCRIPTOR>
312template <Platform PLATFORM>
318template<
typename T,
typename DESCRIPTOR>
358 template<
typename FIELD_TYPE>
360 return dispatch([&](
const auto* data) ->
bool {
369 template <
typename FIELD_TYPE,
typename... ARGS>
377 template <
typename FIELD_TYPE>
379 return *
dispatch([&](
const auto* data) {
384 template <
typename FIELD_TYPE>
391 virtual void resize(std::size_t newSize) = 0;
393 template <
typename OPERATOR>
406 template <
typename FIELD_TYPE>
423template<
typename T,
typename DESCRIPTOR, Platform PLATFORM>
427 std::map<std::type_index, std::unique_ptr<AnyFieldTypeD<T,DESCRIPTOR,PLATFORM>>> _map;
431 std::map<std::string, Serializable*> _serializationNames;
436 Data<T,DESCRIPTOR>(PLATFORM)
441 Data<T,DESCRIPTOR>(PLATFORM)
443 DESCRIPTOR::fields_t::for_each([&](
auto id) {
444 using field =
typename decltype(id)::type;
452 template <
typename FIELD_TYPE>
458 template <
typename FIELD_TYPE,
typename... ARGS>
464 _registry.template track<FIELD_TYPE>(newField);
465 return *newField->template as<FIELD_TYPE>();
469 template <
typename FIELD_TYPE>
471 return *_registry.template
get<FIELD_TYPE>()->template as<FIELD_TYPE>();
474 template <
typename FIELD_TYPE>
476 return *_registry.template
get<FIELD_TYPE>()->template as<FIELD_TYPE>();
480 template <
typename F>
482 for (
auto& [_, field] : _map) {
491 template <
typename TYPE,
typename F>
494 if (
auto casted = any.template tryAs<TYPE>()) {
500 void resize(std::size_t newSize)
override {
502 columnVector->resize(newSize);
519 template <
typename FIELD_TYPE>
533 bool*
getBlock(std::size_t iBlock, std::size_t& sizeBlock,
bool loadingMode)
override;
538template <
typename T,
typename DESCRIPTOR,
typename... ARGS>
542 #if defined(PLATFORM_GPU_CUDA)
544 return std::unique_ptr<Data<T,DESCRIPTOR>>(
547 return std::unique_ptr<Data<T,DESCRIPTOR>>(
551 return std::unique_ptr<Data<T,DESCRIPTOR>>(
Container for arbitrary data instances.
FieldTypePromise< T, DESCRIPTOR > getPromise() const
std::string getName() const
std::optional< TYPE * > tryAs()
void setProcessingContext(ProcessingContext context)
AnyFieldTypeD(meta::id< FIELD_TYPE > id, ARGS &&... args)
Serializable * asSerializable()
Storage of any FIELD_TYPE data on PLATFORM.
ConcreteData(std::size_t size)
Construct Array<FIELD> of size for each FIELD in DESCRIPTOR and mark for serialization.
void resize(std::size_t newSize) override
auto & allocate(ARGS &&... args)
Allocate and return FIELD_TYPE data.
std::size_t getSerializableSize() const override
Binary size for the serializer.
auto & get()
Return reference to data of FIELD_TYPE.
void setProcessingContext(ProcessingContext context) override
Set processing context of all managed fields.
std::size_t getNblock() const override
Number of data blocks for the serializable interface.
auto & getRegistry()
Expose FieldTypeRegistry for device-support.
void forEach(F f)
Call f for each managed AnyFieldType.
ConcreteData()
Construct empty.
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.
void forEachCastable(F f)
Call f for each managed AnyFieldType of TYPE.
void setSerialization(bool active)
Sets FIELD_TYPE serialization state to active.
bool provides() const
Returns true iff FIELD_TYPE is allocated and can be accessed.
const auto & get() const
Return reference to data of FIELD_TYPE.
Platform-indepentent interface to ConcreteData.
auto & get()
Return reference to data of FIELD_TYPE.
auto dispatch(F &&f) const
Calls f on concrete implementation of the Data interface.
virtual void resize(std::size_t newSize)=0
virtual void setProcessingContext(ProcessingContext)=0
Set processing context.
Platform getPlatform() const
Return platform of concrete implementation.
bool provides()
Return whether FIELD_TYPE is available / has been allocated.
const auto & get() const
Return reference to data of FIELD_TYPE.
auto & allocate(ARGS &&... args)
Allocate and return FIELD_TYPE data.
void setSerialization(bool active)
Sets FIELD_TYPE serialization state to active.
SoA storage for instances of a single FIELD.
Helper for conveying the ability for operations on FIELD_TYPE.
FieldTypePromise(meta::id< FIELD_TYPE >)
void setPlaceholderExpression(Cell< Expr, DESCRIPTOR > &cell, std::vector< Expr > &expr)
std::optional< unsigned > dimension() const
void ensureAvailabilityIn(BlockLattice< T, DESCRIPTOR > &block)
bool operator<(const FieldTypePromise< T, DESCRIPTOR > &rhs) const
std::vector< Expr > getPlaceholderExpression(Cell< Expr, DESCRIPTOR > &cell)
void ensureAvailabilityIn(BlockD< T, DESCRIPTOR > &block)
Efficient indexing of dynamically allocated data fields.
const AnyFieldTypeD< T, DESCRIPTOR, PLATFORM > * get() const
Return read-only pointer to FIELD_TYPE data.
void track(AnyFieldTypeD< T, DESCRIPTOR, PLATFORM > *fieldType)
Track newly allocated FIELD_TYPE.
AnyFieldTypeD< T, DESCRIPTOR, PLATFORM > * get()
Return pointer to FIELD_TYPE data.
bool provides() const
Returns true iff FIELD_TYPE is registered.
Base class for all LoadBalancer.
bool isLocal(const int &glob) const
returns whether glob is on this process
Base class for serializable objects of constant size. For dynamic size use BufferSerializable.
(Time) efficient mapping between TYPEs and VALUEs
Descriptor of DdQq lattice and associated constants.
constexpr bool isArray()
Helper to determine if FIELD contains FieldArray.
Top level namespace for all of OpenLB.
auto callUsingConcretePlatform(Platform platform, typename CONCRETIZABLE::base_t *ptr, F f)
Dispatcher for concrete platform access.
ProcessingContext
OpenLB processing contexts.
Platform
OpenLB execution targets.
@ GPU_CUDA
Vector CPU (AVX2 / AVX-512 collision)
Vector< typename FIELD::template value_type< T >, DESCRIPTOR::template size< FIELD >() > FieldD
Vector storing a single field instance.
std::unique_ptr< Data< T, DESCRIPTOR > > makeSharedData(LoadBalancer< T > &loadBalancer, ARGS &&... args)
Constructs Data accessible on all locally used platforms.
Describe FieldArray of a FIELD in Data.
Concrete storage of ParametersD in olb::Data.
Curried ConcreteData template for use in callUsingConcretePlatform.
Describe mask of DYNAMICS in Data.
Describe paramaters of OPERATOR in Data.