35template <
typename T, Platform PLATFORM>
class ConcreteBlockMask;
41template <
typename FIELD>
43 template <
typename T,
typename DESCRIPTOR, Platform PLATFORM>
51template <
typename OPERATOR>
53 template <
typename T,
typename DESCRIPTOR, Platform PLATFORM>
61template <
typename DYNAMICS>
63 template <
typename T,
typename DESCRIPTOR, Platform PLATFORM>
71template<
typename T,
typename DESCRIPTOR, Platform PLATFORM>
74 std::unique_ptr<Serializable> _data;
78 template<
typename FIELD_TYPE,
typename... ARGS>
80 _data(new typename FIELD_TYPE::template type<T,DESCRIPTOR,PLATFORM>(
81 std::forward<decltype(args)>(args)...)),
83 static_cast<typename FIELD_TYPE::template type<T,DESCRIPTOR,PLATFORM>*
>(_data.get())->
setProcessingContext(context);
87 template<
typename FIELD_TYPE>
89 return static_cast<typename FIELD_TYPE::template type<T,DESCRIPTOR,PLATFORM>*
>(_data.get());
96 template<
typename TYPE>
98 if (TYPE* ptr =
dynamic_cast<TYPE*
>(_data.get())) {
99 return std::optional<TYPE*>(ptr);
106 _setProcessingContext(context);
115template<
typename T,
typename DESCRIPTOR, Platform PLATFORM>
125 template <
typename FIELD_TYPE>
127 return _index.template provides<FIELD_TYPE>();
134 template <
typename FIELD_TYPE>
136 return _index.template get<FIELD_TYPE>();
140 template <
typename FIELD_TYPE>
142 _index.template set<FIELD_TYPE>(fieldType);
154template<
typename T,
typename DESCRIPTOR, Platform PLATFORM>
158 std::map<std::type_index, std::unique_ptr<AnyFieldType<T,DESCRIPTOR,PLATFORM>>> _map;
162 std::map<std::string, Serializable*> _serializationNames;
166 template <
typename FIELD_TYPE>
168 return _registry.template provides<FIELD_TYPE>();
175 template <
typename FIELD_TYPE,
typename... ARGS>
181 _registry.template track<FIELD_TYPE>(newField);
182 return *newField->template as<FIELD_TYPE>();
191 template <
typename FIELD_TYPE>
194 _serializationNames[meta::name<FIELD_TYPE>()] = _registry.template get<FIELD_TYPE>()->asSerializable();
196 _serializationNames.erase(meta::name<FIELD_TYPE>());
201 template <
typename FIELD_TYPE>
203 return *_registry.template get<FIELD_TYPE>()->template as<FIELD_TYPE>();
210 template <
typename FIELD>
212 return get<Array<FIELD>>();
216 for (
auto& [_, field] : _map) {
217 field->setProcessingContext(context);
222 template <
typename F>
224 for (
auto& [_, field] : _map) {
233 template <
typename TYPE,
typename F>
236 if (
auto casted = any.template tryAs<TYPE>()) {
252 bool*
getBlock(std::size_t iBlock, std::size_t& sizeBlock,
bool loadingMode)
override;
256template<
typename T,
typename DESCRIPTOR, Platform PLATFORM>
259 std::size_t nBlock = 0;
260 for (
const auto& [_, serializable] : _serializationNames) {
261 nBlock += serializable->getNblock();
266template<
typename T,
typename DESCRIPTOR, Platform PLATFORM>
269 std::size_t size = 0;
270 for (
const auto& [_, serializable] : _serializationNames) {
271 size += serializable->getSerializableSize();
276template<
typename T,
typename DESCRIPTOR, Platform PLATFORM>
279 std::size_t currentBlock = 0;
280 bool* dataPtr =
nullptr;
282 for (
const auto& [_, serializable] : _serializationNames) {
283 registerSerializableOfConstSize(iBlock, sizeBlock, currentBlock, dataPtr, *serializable, loadingMode);
Helper for referring to arbitrary data instances.
Serializable * asSerializable()
AnyFieldType(meta::id< FIELD_TYPE >, ARGS &&... args)
void setProcessingContext(ProcessingContext context)
std::optional< TYPE * > tryAs()
Storage of any FIELD_TYPE data on PLATFORM.
std::size_t getNblock() const override
Number of data blocks for the serializable interface.
void setProcessingContext(ProcessingContext context)
auto & get()
Return reference to data of FIELD_TYPE.
void forEach(F f)
Call f for each managed AnyFieldType.
auto & allocate(ARGS &&... args)
Allocate and return FIELD_TYPE data.
FieldArrayD< T, DESCRIPTOR, PLATFORM, FIELD > & getFieldArray()
Return reference to data of Array<FIELD>, i.e. FieldArrayD<FIELD>
void forEachCastable(F f)
Call f for each managed AnyFieldType of TYPE.
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.
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.
auto & getRegistry()
Expose FieldTypeRegistry for device-support.
SoA storage for instances of a single FIELD.
Efficient indexing of dynamically allocated data fields.
AnyFieldType< T, DESCRIPTOR, PLATFORM > * get()
Return pointer to FIELD_TYPE data.
void track(AnyFieldType< T, DESCRIPTOR, PLATFORM > *fieldType)
Track newly allocated FIELD_TYPE.
bool provides() const
Returns true iff FIELD_TYPE is registered.
Base class for serializable objects of constant size. For dynamic size use BufferSerializable.
(Time) efficient mapping between TYPEs and VALUEs
Top level namespace for all of OpenLB.
ProcessingContext
OpenLB processing contexts.
Describe FieldArray of a FIELD in Data.
Concrete storage of ParametersD in olb::Data.
Describe mask of DYNAMICS in Data.
Describe paramaters of OPERATOR in Data.