30template<
typename T,
typename DESCRIPTOR>
class BlockD;
31template<
typename T,
typename DESCRIPTOR, Platform PLATFORM>
class ConcreteBlockD;
34template<
typename T,
typename DESCRIPTOR>
41template <Platform PLATFORM>
46template<
typename T,
typename DESCRIPTOR>
58 template<
typename FIELD>
63 template<
typename FIELD>
70template <
typename OPERATOR>
73template <
typename OPERATOR>
78 template <
typename BLOCK>
80 for (std::size_t iCell=0; iCell < block.getNcells(); ++iCell) {
82 typename BLOCK::descriptor_t,
90template <
typename OPERATOR>
95 template <
typename BLOCK>
97 auto params = block.template getData<OperatorParameters<OPERATOR>>()
99 .
template copyAs<typename BLOCK::value_t>();
100 for (std::size_t iCell=0; iCell < block.getNcells(); ++iCell) {
102 typename BLOCK::descriptor_t,
110template<
typename T,
typename DESCRIPTOR>
112 ,
public Serializable {
150 template <Platform PLATFORM>
155 throw std::runtime_error(
"Invalid PLATFORM");
160 template<
typename FIELD_TYPE>
162 return dispatch([&](
const auto* lattice) ->
bool {
168 template<
typename FIELD_TYPE>
169 const auto&
getData(FIELD_TYPE field = FIELD_TYPE{})
const
171 return *
dispatch([&](
const auto* lattice) ->
const auto* {
176 template<
typename FIELD_TYPE>
177 auto&
getData(FIELD_TYPE field = FIELD_TYPE{})
179 return *
dispatch([&](
auto* lattice) ->
auto* {
185 template<
typename FIELD>
191 template<
typename FIELD>
198 template<
typename FIELD>
204 template<
typename FIELD>
211 template <
typename FIELD>
217 template <
typename PARAMETER,
typename FIELD>
223 template <
typename PARAMETER, Platform PLATFORM,
typename FIELD>
231 return {*
this, iCell};
234 template <
typename OPERATOR>
247template<
typename T,
typename DESCRIPTOR, Platform PLATFORM>
255 std::map<std::type_index, std::unique_ptr<Communicatable>> _communicatables;
271 template<
typename FIELD_TYPE>
273 template<
typename FIELD_TYPE>
275 template<
typename FIELD_TYPE>
278 template<
typename FIELD>
279 const auto&
getField(FIELD field = FIELD())
const;
280 template<
typename FIELD>
281 auto&
getField(FIELD field = FIELD());
284 return _communicatables.find(field) != _communicatables.end();
287 return *_communicatables.at(field).get();
290 template <
typename FIELD>
293 _data.template forEachCastable<AbstractedConcreteParameters<T,DESCRIPTOR>>([&](
auto* parameters) {
294 auto& params = parameters->asAbstract();
295 if (params.template provides<FIELD>()) {
296 params.template set<FIELD>(value);
302 template <
typename PARAMETER, Platform _PLATFORM,
typename FIELD>
306 static_assert(PLATFORM == _PLATFORM,
"FieldArrayD must be available on PLATFORM");
309 for (
unsigned iD=0; iD < fieldArray.
d; ++iD) {
311 fieldArrayPointers[iD] = fieldArray[iD].deviceData();
313 fieldArrayPointers[iD] = fieldArray[iD].data();
319 template <
typename PARAMETER,
typename FIELD>
334 template <
typename OPERATOR>
337 "OPERATOR is not PerBlock scoped");
346 bool*
getBlock(std::size_t iBlock, std::size_t& sizeBlock,
bool loadingMode)
override;
357template <
typename T,
typename DESCRIPTOR,
typename... ARGS>
361 #if defined(PLATFORM_GPU_CUDA)
363 return std::unique_ptr<BlockD<T,DESCRIPTOR>>(
366 return std::unique_ptr<BlockD<T,DESCRIPTOR>>(
370 return std::unique_ptr<BlockD<T,DESCRIPTOR>>(
#define OPERATOR(OP, rhs)
Platform-agnostic interface to concrete host-side field arrays.
bool hasData()
Return whether FIELD_TYPE is available / has been allocated.
BlockD(Vector< int, DESCRIPTOR::d > size, int padding, Platform platform)
void setField(LatticeR< DESCRIPTOR::d > loc, const FieldD< T, DESCRIPTOR, FIELD > &fieldD)
Set FIELD to fieldD at loc.
virtual void setProcessingContext(ProcessingContext)=0
Set processing context.
auto & getField(FIELD field=FIELD{})
Return abstract interface for FIELD array.
void setParameter(FieldArrayD< T, DESCRIPTOR, PLATFORM, FIELD > &fieldArray)
const auto & getField(FIELD field=FIELD{}) const
Return abstract interface for FIELD array.
ConcreteBlockD< T, DESCRIPTOR, PLATFORM > & asConcrete()
auto & getData(FIELD_TYPE field=FIELD_TYPE{})
Return abstract interface for concrete FIELD_TYPE data.
BlockLatticeRowView< T, DESCRIPTOR > get(std::size_t iCell)
auto dispatch(F &&f) const
Calls f on concrete implementation of the BlockD interface.
void setParameter(AbstractFieldArrayD< T, DESCRIPTOR, FIELD > &fieldArray)
Platform getPlatform() const
Return platform used to process lattice.
const auto & getData(FIELD_TYPE field=FIELD_TYPE{}) const
Return abstract interface for concrete FIELD_TYPE data.
virtual void resize(Vector< int, DESCRIPTOR::d > size)=0
virtual bool hasCommunicatable(std::type_index) const =0
virtual Communicatable & getCommunicatable(std::type_index)=0
void setParameter(FieldD< T, DESCRIPTOR, FIELD > value)
Set value of parameter FIELD.
auto getField(LatticeR< DESCRIPTOR::d > loc) const
Return value of FIELD at loc.
BlockLatticeRowView(BlockD< T, DESCRIPTOR > &lattice, std::size_t iRow)
void setField(const FieldD< T, DESCRIPTOR, FIELD > &data) const
CellID getCellId(LatticeR< D > latticeR) const
Get 1D cell ID.
static constexpr unsigned d
Implementation of BlockD on a concrete PLATFORM.
const auto & getData() const
void resize(Vector< int, DESCRIPTOR::d > size) override
void setProcessingContext(ProcessingContext context) override
Set processing context.
Communicatable & getCommunicatable(std::type_index field) override
ConcreteBlockD(Vector< int, DESCRIPTOR::d > size, int padding=0)
bool hasCommunicatable(std::type_index field) const override
void postLoad() override
Reinit population structure after deserialization.
void setParameter(FieldArrayD< T, DESCRIPTOR, _PLATFORM, FIELD > &fieldArray)
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.
static constexpr Platform platform
void setParameter(FieldD< T, DESCRIPTOR, FIELD > value)
std::size_t getSerializableSize() const override
Binary size for the serializer.
std::size_t getNblock() const override
Number of data blocks for the serializable interface.
auto & getDataRegistry()
Return reference to Data's FieldTypeRegistry.
const auto & getField(FIELD field=FIELD()) const
void setParameter(AbstractFieldArrayD< T, DESCRIPTOR, FIELD > &abstractFieldArray)
Storage of any FIELD_TYPE data on PLATFORM.
void setProcessingContext(ProcessingContext context) override
Set processing context of all managed fields.
auto & getRegistry()
Expose FieldTypeRegistry for device-support.
SoA storage for instances of a single FIELD.
Base class for all LoadBalancer.
bool isLocal(const int &glob) const
returns whether glob is on this process
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.
@ Simulation
Data available on host for e.g. functor evaluation.
Platform
OpenLB execution targets.
@ GPU_CUDA
Vector CPU (AVX2 / AVX-512 collision)
BlockStructureD< DESCRIPTOR::d > BlockStructure
OperatorScope
Block-wide operator application scopes.
@ PerBlock
Per-block application, i.e. OPERATOR::apply is passed a ConcreteBlockLattice.
@ PerCell
Per-cell application, i.e. OPERATOR::apply is passed a CELL concept implementation.
@ PerCellWithParameters
Per-cell application with parameters, i.e. OPERATOR::apply is passed a CELL concept implementation an...
std::unique_ptr< BlockD< T, DESCRIPTOR > > makeSharedBlockD(LoadBalancer< T > &loadBalancer, ARGS &&... args)
Constructs BlockD accessible on all locally used platforms.
Describe FieldArray of a FIELD in Data.
Curried ConcreteBlockD eemplate for use in callUsingConcretePlatform.