OpenLB 1.8.1
Loading...
Searching...
No Matches
olb::ConcreteBlockLattice< T, DESCRIPTOR, PLATFORM > Class Template Reference

Implementation of BlockLattice on a concrete PLATFORM. More...

#include <blockLattice.h>

+ Inheritance diagram for olb::ConcreteBlockLattice< T, DESCRIPTOR, PLATFORM >:
+ Collaboration diagram for olb::ConcreteBlockLattice< T, DESCRIPTOR, PLATFORM >:

Public Types

using value_t = T
 
using descriptor_t = DESCRIPTOR
 

Public Member Functions

 ConcreteBlockLattice (Vector< int, DESCRIPTOR::d > size, int padding=0)
 
void setProcessingContext (ProcessingContext context) override
 Set processing context.
 
ConcreteData< T, DESCRIPTOR, PLATFORM > & getData ()
 
template<typename FIELD_TYPE >
bool hasData () const
 
template<typename FIELD_TYPE >
const auto & getData () const
 
template<typename FIELD_TYPE >
auto & getData ()
 
template<typename FIELD >
const auto & getField (FIELD field=FIELD()) const
 
template<typename FIELD >
auto & getField (FIELD field=FIELD())
 
bool hasCommunicatable (std::type_index field) const override
 
CommunicatablegetCommunicatable (std::type_index field) override
 
void collide () override
 Apply collision step of non-overlap interior.
 
void stream () override
 Perform propagation step on the whole block.
 
void setCollisionO (std::function< void(ConcreteBlockLattice &)> &&op)
 Replace default collision logic of BlockDynamicsMap.
 
BlockDynamicsMap< T, DESCRIPTOR, PLATFORM > & getDynamicsMap ()
 
Dynamics< T, DESCRIPTOR > * getDynamics (CellID iCell) override
 Get reference to dynamics of cell by index.
 
void setDynamics (CellID iCell, DynamicsPromise< T, DESCRIPTOR > &&promise) override
 Set dynamics at iCell to promised dynamics.
 
template<typename FIELD >
void setParameter (FieldD< T, DESCRIPTOR, FIELD > value)
 
template<typename PARAMETER , typename _DESCRIPTOR , Platform _PLATFORM, typename FIELD >
void setParameter (FieldArrayD< T, _DESCRIPTOR, _PLATFORM, FIELD > &fieldArray)
 
template<typename PARAMETER , typename _DESCRIPTOR , typename FIELD >
void setParameter (AbstractFieldArrayD< T, _DESCRIPTOR, FIELD > &abstractFieldArray)
 
bool hasPostProcessor (std::type_index stage, PostProcessorPromise< T, DESCRIPTOR > &&promise) override
 Returns true if stage contains post processor.
 
void addPostProcessor (std::type_index stage, LatticeR< DESCRIPTOR::d > latticeR, PostProcessorPromise< T, DESCRIPTOR > &&promise) override
 Schedule post processor for application to latticeR in stage.
 
void addPostProcessor (std::type_index stage, BlockIndicatorF< T, DESCRIPTOR::d > &indicator, PostProcessorPromise< T, DESCRIPTOR > &&promise) override
 Schedule post processor for application to indicated cells in stage.
 
void addPostProcessor (std::type_index stage, PostProcessorPromise< T, DESCRIPTOR > &&promise) override
 Schedule post processor for application to entire block in stage.
 
void postProcess (std::type_index stage) override
 Execute post processors of stage.
 
Vector< T *, DESCRIPTOR::q > getPopulationPointers (CellID iCell) override
 Return pointers to population values of cell index iCell.
 
auto & getDataRegistry ()
 Return reference to Data's FieldTypeRegistry.
 
void writeDescription (std::ostream &clout) const override
 Prints human-readable summary of all used dynamics and post processors.
 
void writeDynamicsAsCSV (std::ostream &clout) const override
 Prints CSV-structured list of all used dynamics.
 
void writeOperatorAsCSV (std::ostream &clout) const override
 Prints CSV-structured list of all used operators.
 
std::size_t getNblock () const override
 Number of data blocks for the serializable interface.
 
std::size_t getSerializableSize () const override
 Binary size for the serializer.
 
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 postLoad () override
 Reinit population structure after deserialization.
 
- Public Member Functions inherited from olb::BlockLattice< T, DESCRIPTOR >
 BlockLattice (Vector< int, DESCRIPTOR::d > size, int padding, Platform platform)
 
virtual ~BlockLattice ()
 
Platform getPlatform () const
 Return platform used to process lattice.
 
template<Platform PLATFORM>
ConcreteBlockLattice< T, DESCRIPTOR, PLATFORM > & asConcrete ()
 
template<typename FIELD_TYPE >
bool hasData ()
 Return whether FIELD_TYPE is available / has been allocated.
 
template<typename FIELD_TYPE >
const auto & getData (FIELD_TYPE field=FIELD_TYPE{}) const
 Return abstract interface for concrete FIELD_TYPE data.
 
template<typename FIELD_TYPE >
auto & getData (FIELD_TYPE field=FIELD_TYPE{})
 Return abstract interface for concrete FIELD_TYPE data.
 
template<typename FIELD >
const auto & getField (FIELD field=FIELD{}) const
 Return abstract interface for FIELD array.
 
template<typename FIELD >
auto & getField (FIELD field=FIELD{})
 Return abstract interface for FIELD array.
 
Cell< T, DESCRIPTOR > get (CellID iCell)
 Get Cell interface for index iCell.
 
ConstCell< T, DESCRIPTOR > get (CellID iCell) const
 Get ConstCell interface for index iCell.
 
Cell< T, DESCRIPTOR > get (LatticeR< DESCRIPTOR::d > loc)
 Get Cell interface for location loc.
 
ConstCell< T, DESCRIPTOR > get (LatticeR< DESCRIPTOR::d > loc) const
 Get ConstCell interface for location loc.
 
template<typename... R>
std::enable_if_t< sizeof...(R)==DESCRIPTOR::d, Cell< T, DESCRIPTOR > > get (R... latticeR)
 Get Cell interface for componentwise location latticeR.
 
template<typename... R>
std::enable_if_t< sizeof...(R)==DESCRIPTOR::d, ConstCell< T, DESCRIPTOR > > get (R... latticeR) const
 Get ConstCell interface for componentwise location latticeR.
 
void initialize ()
 Initialize the lattice cells to become ready for simulation.
 
bool statisticsEnabled () const
 
void setStatisticsEnabled (bool state)
 
bool isIntrospectable () const
 
void setIntrospectability (bool state)
 
template<typename... R>
std::enable_if_t< sizeof...(R)==DESCRIPTOR::d, Dynamics< T, DESCRIPTOR > * > getDynamics (R... latticeR)
 Return pointer to dynamics assigned to latticeR.
 
void defineDynamics (LatticeR< DESCRIPTOR::d > latticeR, DynamicsPromise< T, DESCRIPTOR > &&promise)
 Assign promised DYNAMICS to latticeR.
 
template<template< typename... > typename DYNAMICS>
void defineDynamics (LatticeR< DESCRIPTOR::d > latticeR)
 Assign DYNAMICS to latticeR.
 
template<typename DYNAMICS >
void defineDynamics ()
 Define DYNAMICS everywhere.
 
template<typename DYNAMICS >
void defineDynamics (BlockIndicatorF< T, DESCRIPTOR::d > &indicator)
 Define DYNAMICS on a domain described by an indicator.
 
void defineDynamics (BlockIndicatorF< T, DESCRIPTOR::d > &indicator, DynamicsPromise< T, DESCRIPTOR > &&promise)
 Define promised dynamics on a domain described by an indicator.
 
template<typename FIELD >
void setParameter (FieldD< T, DESCRIPTOR, FIELD > value)
 Set value of parameter FIELD for any dynamics that provide it.
 
template<typename PARAMETER , typename _DESCRIPTOR , typename FIELD >
void setParameter (AbstractFieldArrayD< T, _DESCRIPTOR, FIELD > &fieldArray)
 
template<typename PARAMETER , typename _DESCRIPTOR , Platform PLATFORM, typename FIELD >
void setParameter (FieldArrayD< T, _DESCRIPTOR, PLATFORM, FIELD > &fieldArray)
 
template<typename STAGE >
void postProcess ()
 Execute post processors of STAGE.
 
template<typename FIELD >
void defineField (BlockIndicatorF< T, DESCRIPTOR::d > &indicator, AnalyticalF< DESCRIPTOR::d, T, T > &field)
 Define a field on a domain described by an indicator.
 
template<typename FIELD >
void defineField (BlockIndicatorF< T, DESCRIPTOR::d > &indicator, BlockF< T, DESCRIPTOR::d > &field)
 Define a field on a domain described by an indicator.
 
template<typename FIELD >
void defineField (BlockGeometry< T, DESCRIPTOR::d > &blockGeometry, IndicatorF< T, DESCRIPTOR::d > &indicatorF, AnalyticalF< DESCRIPTOR::d, T, T > &field)
 Define a field on a domain described by an analytical indicator.
 
void defineRho (BlockIndicatorF< T, DESCRIPTOR::d > &indicator, AnalyticalF< DESCRIPTOR::d, T, T > &rho)
 Define rho on a domain described by an indicator.
 
void defineU (BlockIndicatorF< T, DESCRIPTOR::d > &indicator, AnalyticalF< DESCRIPTOR::d, T, T > &u)
 Define u on a domain described by an indicator.
 
void defineRhoU (BlockIndicatorF< T, DESCRIPTOR::d > &indicator, AnalyticalF< DESCRIPTOR::d, T, T > &rho, AnalyticalF< DESCRIPTOR::d, T, T > &u)
 Define rho and u on a domain described by an indicator.
 
void definePopulations (BlockIndicatorF< T, DESCRIPTOR::d > &indicator, AnalyticalF< DESCRIPTOR::d, T, T > &Pop)
 Define a population on a domain described by an indicator.
 
void definePopulations (BlockIndicatorF< T, DESCRIPTOR::d > &indicator, BlockF< T, DESCRIPTOR::d > &Pop)
 
void iniEquilibrium (BlockIndicatorF< T, DESCRIPTOR::d > &indicator, AnalyticalF< DESCRIPTOR::d, T, T > &rho, AnalyticalF< DESCRIPTOR::d, T, T > &u)
 Initialize by equilibrium on a domain described by an indicator.
 
void iniEquilibrium (BlockIndicatorF< T, DESCRIPTOR::d > &indicator, AnalyticalF< DESCRIPTOR::d, T, T > &rho, BlockF< T, DESCRIPTOR::d > &u)
 
void iniRegularized (BlockIndicatorF< T, DESCRIPTOR::d > &indicator, AnalyticalF< DESCRIPTOR::d, T, T > &rho, AnalyticalF< DESCRIPTOR::d, T, T > &u, AnalyticalF< DESCRIPTOR::d, T, T > &pi)
 Initialize by non- and equilibrium on a domain described by an indicator.
 
void stripeOffDensityOffset (T offset)
 Subtract the given offset from all densities.
 
LatticeStatistics< T > & getStatistics ()
 Return a handle to the LatticeStatistics object.
 
LatticeStatistics< T > const & getStatistics () const
 Return a constant handle to the LatticeStatistics object.
 
- Public Member Functions inherited from olb::BlockStructureD< D >
 BlockStructureD (Vector< int, D > size, int padding=0)
 
 BlockStructureD ()
 
void resize (Vector< int, D > size)
 
auto getCore () const
 
int getNx () const
 Read only access to block width.
 
int getNy () const
 Read only access to block height.
 
int getNz () const
 Read only access to block height.
 
LatticeR< D > getExtent () const
 
int getPadding () const
 Read only access to padding.
 
std::size_t getNcells () const
 Get number of cells.
 
CellID getCellId (LatticeR< D > latticeR) const
 Get 1D cell ID.
 
template<typename... L>
std::enable_if_t< sizeof...(L)==D, CellIDgetCellId (L... latticeR) const
 
LatticeR< D > getLatticeR (CellID iCell) const
 
CellDistance getNeighborDistance (LatticeR< D > dir) const
 Get 1D neighbor distance.
 
bool isInside (LatticeR< D > latticeR) const
 Return whether location is valid.
 
bool isInsideCore (LatticeR< D > latticeR) const
 Return whether location is inside core.
 
bool isPadding (LatticeR< D > latticeR) const
 Return whether location is valid.
 
bool isPadding (LatticeR< D > latticeR, int overlap) const
 
bool isPadding (CellID iCell) const
 
template<typename... L>
std::enable_if_t< sizeof...(L)==D, bool > isInside (L... latticeR) const
 
CellDistance getNeighborhoodRadius (LatticeR< D > latticeR) const
 Return maximum valid neighborhood sphere radius w.r.t. latticeR.
 
template<typename F >
void forSpatialLocations (F f) const
 
template<typename F >
void forSpatialLocationsParallel (F f) const
 
template<typename F >
void forSpatialLocations (LatticeR< D > min, LatticeR< D > max, F f) const
 
template<typename F >
void forCoreSpatialLocations (F f) const
 
template<typename F >
void forCellIndices (F f) const
 
- Public Member Functions inherited from olb::Serializable
virtual ~Serializable ()=default
 
template<bool includeLogOutputDir = true>
bool save (std::string fileName="", const bool enforceUint=false)
 Save Serializable into file fileName
 
template<bool includeLogOutputDir = true>
bool load (std::string fileName="", const bool enforceUint=false)
 Load Serializable from file fileName
 
bool save (std::uint8_t *buffer)
 Save Serializable into buffer of length getSerializableSize
 
bool load (const std::uint8_t *buffer)
 Load Serializable from buffer of length getSerializableSize
 

Static Public Attributes

static constexpr Platform platform = PLATFORM
 

Additional Inherited Members

- Protected Member Functions inherited from olb::Serializable
template<typename DataType >
void registerVar (const std::size_t iBlock, std::size_t &sizeBlock, std::size_t &currentBlock, bool *&dataPtr, const DataType &data, const size_t arrayLength=1) const
 Register primitive data types (int, double, ...) or arrays of those.
 
template<typename DataType >
void registerSerializableOfConstSize (const std::size_t iBlock, std::size_t &sizeBlock, std::size_t &currentBlock, bool *&dataPtr, DataType &data, const bool loadingMode=false)
 Register Serializable object of constant size.
 
template<typename DataType >
void registerSerializablesOfConstSize (const std::size_t iBlock, std::size_t &sizeBlock, std::size_t &currentBlock, bool *&dataPtr, DataType *data, const size_t arrayLength, const bool loadingMode=false)
 Register an array of Serializable objects of constant size.
 
- Protected Attributes inherited from olb::BlockLattice< T, DESCRIPTOR >
const Platform _platform
 Platform used by the derived concrete lattice.
 
bool _statisticsEnabled
 True if statistics are gathered during collide.
 
LatticeStatistics< T > * _statistics
 
bool _introspectable
 True for lattice that can be introspected.
 
- Protected Attributes inherited from olb::BlockStructureD< D >
LatticeR< D > _core
 
LatticeR< D > _size
 
LatticeR< D > _projection
 
int _padding
 

Detailed Description

template<typename T, typename DESCRIPTOR, Platform PLATFORM>
class olb::ConcreteBlockLattice< T, DESCRIPTOR, PLATFORM >

Implementation of BlockLattice on a concrete PLATFORM.

Definition at line 37 of file communicator.h.

Member Typedef Documentation

◆ descriptor_t

template<typename T , typename DESCRIPTOR , Platform PLATFORM>
using olb::ConcreteBlockLattice< T, DESCRIPTOR, PLATFORM >::descriptor_t = DESCRIPTOR

Definition at line 481 of file blockLattice.h.

◆ value_t

template<typename T , typename DESCRIPTOR , Platform PLATFORM>
using olb::ConcreteBlockLattice< T, DESCRIPTOR, PLATFORM >::value_t = T

Definition at line 480 of file blockLattice.h.

Constructor & Destructor Documentation

◆ ConcreteBlockLattice()

template<typename T , typename DESCRIPTOR , Platform PLATFORM>
olb::ConcreteBlockLattice< T, DESCRIPTOR, PLATFORM >::ConcreteBlockLattice ( Vector< int, DESCRIPTOR::d > size,
int padding = 0 )

Definition at line 394 of file blockLattice.hh.

396 : BlockLattice<T,DESCRIPTOR>(size, padding, PLATFORM),
397 _data(),
398 _descriptorFields(),
399 _dynamicsMap(*this)
400{
401 DESCRIPTOR::fields_t::for_each([&](auto id) {
402 using field = typename decltype(id)::type;
403 using field_type = Array<field>;
404 auto& fieldArray = _data.template allocate<field_type>(this->getNcells());
405 _descriptorFields.template set<field>(&fieldArray);
406 _communicatables[typeid(field)] = std::unique_ptr<Communicatable>(new ConcreteCommunicatable<
407 ColumnVector<typename ImplementationOf<typename field::template column_type<T>,PLATFORM>::type,
408 DESCRIPTOR::template size<field>()>
409 >(fieldArray));
410 _data.template setSerialization<field_type>(true);
411 });
412
413 for (CellID iCell=0; iCell < this->getNcells(); ++iCell) {
414 _dynamicsMap.set(iCell, meta::id<NoDynamics<T,DESCRIPTOR>>{});
415 }
416}
std::size_t getNcells() const
Get number of cells.
std::enable_if_t< DESCRIPTOR::d==2, std::shared_ptr< SuperF2D< T > > > field(SuperLattice< T, DESCRIPTOR > &sLattice)
Returns external field functor.
std::uint32_t CellID
Type for sequential block-local cell indices.
dynamics::Tuple< T, DESCRIPTOR, momenta::Tuple< momenta::OneDensity, momenta::ZeroMomentum, momenta::ZeroStress, momenta::DefineSeparately >, equilibria::None, collision::None > NoDynamics
Dynamics for "dead cells" doing nothing.
Definition dynamics.h:51

References olb::BlockStructureD< D >::getNcells().

+ Here is the call graph for this function:

Member Function Documentation

◆ addPostProcessor() [1/3]

template<typename T , typename DESCRIPTOR , Platform PLATFORM>
void olb::ConcreteBlockLattice< T, DESCRIPTOR, PLATFORM >::addPostProcessor ( std::type_index stage,
BlockIndicatorF< T, DESCRIPTOR::d > & indicator,
PostProcessorPromise< T, DESCRIPTOR > && promise )
inlineoverridevirtual

Schedule post processor for application to indicated cells in stage.

Implements olb::BlockLattice< T, DESCRIPTOR >.

Definition at line 634 of file blockLattice.h.

637 {
638 if (promise.scope() == OperatorScope::PerBlock) {
639 if (!indicator.isEmpty()) {
640 auto [postProcessorsOfPriority, _] = _postProcessors[stage].try_emplace(promise.priority(), this);
641 std::get<1>(*postProcessorsOfPriority).add(std::forward<decltype(promise)>(promise));
642 }
643 } else {
645 if (indicator(loc)) {
646 addPostProcessor(stage, loc, std::forward<decltype(promise)>(promise));
647 }
648 });
649 }
650 }
void forCoreSpatialLocations(F f) const
void addPostProcessor(std::type_index stage, LatticeR< DESCRIPTOR::d > latticeR, PostProcessorPromise< T, DESCRIPTOR > &&promise) override
Schedule post processor for application to latticeR in stage.
Vector< std::int32_t, D > LatticeR
Type for spatial block-local lattice coordinates.
@ PerBlock
Per-block application, i.e. OPERATOR::apply is passed a ConcreteBlockLattice.

References olb::ConcreteBlockLattice< T, DESCRIPTOR, PLATFORM >::addPostProcessor(), olb::BlockStructureD< D >::forCoreSpatialLocations(), and olb::PerBlock.

+ Here is the call graph for this function:

◆ addPostProcessor() [2/3]

template<typename T , typename DESCRIPTOR , Platform PLATFORM>
void olb::ConcreteBlockLattice< T, DESCRIPTOR, PLATFORM >::addPostProcessor ( std::type_index stage,
LatticeR< DESCRIPTOR::d > latticeR,
PostProcessorPromise< T, DESCRIPTOR > && promise )
inlineoverridevirtual

Schedule post processor for application to latticeR in stage.

Implements olb::BlockLattice< T, DESCRIPTOR >.

Definition at line 625 of file blockLattice.h.

628 {
629 auto [postProcessorsOfPriority, _] = _postProcessors[stage].try_emplace(promise.priority(), this);
630 std::get<1>(*postProcessorsOfPriority).add(this->getCellId(latticeR),
631 std::forward<decltype(promise)>(promise));
632 }
+ Here is the caller graph for this function:

◆ addPostProcessor() [3/3]

template<typename T , typename DESCRIPTOR , Platform PLATFORM>
void olb::ConcreteBlockLattice< T, DESCRIPTOR, PLATFORM >::addPostProcessor ( std::type_index stage,
PostProcessorPromise< T, DESCRIPTOR > && promise )
inlineoverridevirtual

Schedule post processor for application to entire block in stage.

Implements olb::BlockLattice< T, DESCRIPTOR >.

Definition at line 652 of file blockLattice.h.

654 {
655 if (promise.scope() == OperatorScope::PerBlock) {
656 auto [postProcessorsOfPriority, _] = _postProcessors[stage].try_emplace(promise.priority(), this);
657 std::get<1>(*postProcessorsOfPriority).add(std::forward<decltype(promise)>(promise));
658 } else {
660 addPostProcessor(stage, loc, std::forward<decltype(promise)>(promise));
661 });
662 }
663 }

References olb::ConcreteBlockLattice< T, DESCRIPTOR, PLATFORM >::addPostProcessor(), olb::BlockStructureD< D >::forCoreSpatialLocations(), and olb::PerBlock.

+ Here is the call graph for this function:

◆ collide()

template<typename T , typename DESCRIPTOR , Platform PLATFORM>
void olb::ConcreteBlockLattice< T, DESCRIPTOR, PLATFORM >::collide ( )
overridevirtual

Apply collision step of non-overlap interior.

Implements olb::BlockLattice< T, DESCRIPTOR >.

Definition at line 304 of file blockLattice.hh.

305{
306 if (_customCollisionO) {
307 _customCollisionO->operator()(*this);
308 } else {
309 if constexpr (isPlatformCPU(PLATFORM)) {
310 _dynamicsMap.collide(CollisionDispatchStrategy::Dominant);
311 } else {
312 _dynamicsMap.collide(CollisionDispatchStrategy::Individual);
313 }
314 }
315}
constexpr bool isPlatformCPU(Platform platform)
Returns true if platform is equal to Platform::CPU_*.
Definition platform.h:83
@ Individual
Apply all dynamics individually (async for Platform::GPU_CUDA)
@ Dominant
Apply dominant dynamics using mask and fallback to virtual dispatch for others.

References olb::Dominant, olb::Individual, and olb::isPlatformCPU().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getBlock()

template<typename T , typename DESCRIPTOR , Platform PLATFORM>
bool * olb::ConcreteBlockLattice< T, DESCRIPTOR, PLATFORM >::getBlock ( std::size_t iBlock,
std::size_t & sizeBlock,
bool loadingMode )
overridevirtual

Return a pointer to the memory of the current block and its size for the serializable interface.

Implements olb::Serializable.

Definition at line 622 of file blockLattice.hh.

623{
624 std::size_t currentBlock = 0;
625 bool* dataPtr = nullptr;
626
627 this->registerSerializableOfConstSize(iBlock, sizeBlock, currentBlock, dataPtr, _data, loadingMode);
628
629 return dataPtr;
630}
void registerSerializableOfConstSize(const std::size_t iBlock, std::size_t &sizeBlock, std::size_t &currentBlock, bool *&dataPtr, DataType &data, const bool loadingMode=false)
Register Serializable object of constant size.
Definition serializer.h:239

◆ getCommunicatable()

template<typename T , typename DESCRIPTOR , Platform PLATFORM>
Communicatable & olb::ConcreteBlockLattice< T, DESCRIPTOR, PLATFORM >::getCommunicatable ( std::type_index field)
inlineoverridevirtual

Implements olb::BlockLattice< T, DESCRIPTOR >.

Definition at line 518 of file blockLattice.h.

518 {
519 return *_communicatables.at(field).get();
520 }
+ Here is the caller graph for this function:

◆ getData() [1/3]

template<typename T , typename DESCRIPTOR , Platform PLATFORM>
ConcreteData< T, DESCRIPTOR, PLATFORM > & olb::ConcreteBlockLattice< T, DESCRIPTOR, PLATFORM >::getData ( )
inline

Definition at line 499 of file blockLattice.h.

499 {
500 return _data;
501 }
+ Here is the caller graph for this function:

◆ getData() [2/3]

template<typename T , typename DESCRIPTOR , Platform PLATFORM>
template<typename FIELD_TYPE >
auto & olb::ConcreteBlockLattice< T, DESCRIPTOR, PLATFORM >::getData ( )

Definition at line 436 of file blockLattice.hh.

437{
438 if (_data.template provides<FIELD_TYPE>()) {
439 return _data.template get<FIELD_TYPE>();
440 } else {
441 // TODO: Implement more generic approach to constructing arbitrary data from specific args
442 auto& data = _data.template allocate<FIELD_TYPE>(this->getNcells());
443 // Manage serializables and communicatables for array fields
444 using concrete_data_t = typename FIELD_TYPE::template type<T,DESCRIPTOR,PLATFORM>;
445 if constexpr (std::is_base_of_v<ColumnVectorBase,concrete_data_t>) {
446 using field_t = typename concrete_data_t::field_t;
447 if constexpr (field_t::isSerializable()) {
448 _data.template setSerialization<FIELD_TYPE>(true);
449 }
450 _communicatables[typeid(field_t)] = std::unique_ptr<Communicatable>(new ConcreteCommunicatable<
451 ColumnVector<typename ImplementationOf<typename field_t::template column_type<T>,PLATFORM>::type,
452 DESCRIPTOR::template size<field_t>()>
453 >(data));
454 }
455 return data;
456 }
457 __builtin_unreachable();
458}
Cell< T, DESCRIPTOR > get(CellID iCell)
Get Cell interface for index iCell.

◆ getData() [3/3]

template<typename T , typename DESCRIPTOR , Platform PLATFORM>
template<typename FIELD_TYPE >
const auto & olb::ConcreteBlockLattice< T, DESCRIPTOR, PLATFORM >::getData ( ) const

Definition at line 427 of file blockLattice.hh.

428{
429 OLB_ASSERT(_data.template provides<FIELD_TYPE>(),
430 "FIELD_TYPE must be allocated to be accessed");
431 return _data.template get<FIELD_TYPE>();
432}
#define OLB_ASSERT(COND, MESSAGE)
Definition olbDebug.h:45

References OLB_ASSERT.

◆ getDataRegistry()

template<typename T , typename DESCRIPTOR , Platform PLATFORM>
auto & olb::ConcreteBlockLattice< T, DESCRIPTOR, PLATFORM >::getDataRegistry ( )
inline

Return reference to Data's FieldTypeRegistry.

Only of interest for implementing specific device support

Definition at line 683 of file blockLattice.h.

683 {
684 return _data.getRegistry();
685 }

References olb::ConcreteData< T, DESCRIPTOR, PLATFORM >::getRegistry().

+ Here is the call graph for this function:

◆ getDynamics()

template<typename T , typename DESCRIPTOR , Platform PLATFORM>
Dynamics< T, DESCRIPTOR > * olb::ConcreteBlockLattice< T, DESCRIPTOR, PLATFORM >::getDynamics ( CellID iCell)
inlineoverridevirtual

Get reference to dynamics of cell by index.

Implements olb::BlockLattice< T, DESCRIPTOR >.

Definition at line 550 of file blockLattice.h.

551 {
552 return _dynamicsMap.get(iCell);
553 }

References olb::BlockDynamicsMap< T, DESCRIPTOR, PLATFORM >::get().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getDynamicsMap()

template<typename T , typename DESCRIPTOR , Platform PLATFORM>
BlockDynamicsMap< T, DESCRIPTOR, PLATFORM > & olb::ConcreteBlockLattice< T, DESCRIPTOR, PLATFORM >::getDynamicsMap ( )
inline

Definition at line 545 of file blockLattice.h.

545 {
546 return _dynamicsMap;
547 }

◆ getField() [1/2]

template<typename T , typename DESCRIPTOR , Platform PLATFORM>
template<typename FIELD >
auto & olb::ConcreteBlockLattice< T, DESCRIPTOR, PLATFORM >::getField ( FIELD field = FIELD())

Definition at line 462 of file blockLattice.hh.

463{
464 if constexpr (DESCRIPTOR::fields_t::template contains<FIELD>()) {
465 return static_cast<FieldArrayD<T,DESCRIPTOR,PLATFORM,FIELD>&>(*_descriptorFields.template get<FIELD>());
466 } else {
467 return getData<Array<FIELD>>();
468 }
469 __builtin_unreachable();
470}
ConcreteData< T, DESCRIPTOR, PLATFORM > & getData()

◆ getField() [2/2]

template<typename T , typename DESCRIPTOR , Platform PLATFORM>
template<typename FIELD >
const auto & olb::ConcreteBlockLattice< T, DESCRIPTOR, PLATFORM >::getField ( FIELD field = FIELD()) const

Definition at line 474 of file blockLattice.hh.

475{
476 if constexpr (DESCRIPTOR::fields_t::template contains<FIELD>()) {
477 return static_cast<const FieldArrayD<T,DESCRIPTOR,PLATFORM,FIELD>&>(*_descriptorFields.template get<FIELD>());
478 } else {
479 return getData<Array<FIELD>>();
480 }
481 __builtin_unreachable();
482}
+ Here is the caller graph for this function:

◆ getNblock()

template<typename T , typename DESCRIPTOR , Platform PLATFORM>
std::size_t olb::ConcreteBlockLattice< T, DESCRIPTOR, PLATFORM >::getNblock ( ) const
overridevirtual

Number of data blocks for the serializable interface.

Implements olb::Serializable.

Definition at line 610 of file blockLattice.hh.

611{
612 return _data.getNblock();
613}

◆ getPopulationPointers()

template<typename T , typename DESCRIPTOR , Platform PLATFORM>
Vector< T *, DESCRIPTOR::q > olb::ConcreteBlockLattice< T, DESCRIPTOR, PLATFORM >::getPopulationPointers ( CellID iCell)
inlineoverridevirtual

Return pointers to population values of cell index iCell.

Performance optimization for access via virtual Cell

Implements olb::BlockLattice< T, DESCRIPTOR >.

Definition at line 672 of file blockLattice.h.

672 {
674 return Vector<T*,DESCRIPTOR::q>([&](unsigned iPop) -> T* {
675 return &pops[iPop][iCell];
676 });
677 }
const auto & getField(FIELD field=FIELD()) const

References olb::ConcreteBlockLattice< T, DESCRIPTOR, PLATFORM >::getField().

+ Here is the call graph for this function:

◆ getSerializableSize()

template<typename T , typename DESCRIPTOR , Platform PLATFORM>
std::size_t olb::ConcreteBlockLattice< T, DESCRIPTOR, PLATFORM >::getSerializableSize ( ) const
overridevirtual

Binary size for the serializer.

Implements olb::Serializable.

Definition at line 616 of file blockLattice.hh.

617{
618 return _data.getSerializableSize();
619}

◆ hasCommunicatable()

template<typename T , typename DESCRIPTOR , Platform PLATFORM>
bool olb::ConcreteBlockLattice< T, DESCRIPTOR, PLATFORM >::hasCommunicatable ( std::type_index field) const
inlineoverridevirtual

Implements olb::BlockLattice< T, DESCRIPTOR >.

Definition at line 515 of file blockLattice.h.

515 {
516 return _communicatables.find(field) != _communicatables.end();
517 }

◆ hasData()

template<typename T , typename DESCRIPTOR , Platform PLATFORM>
template<typename FIELD_TYPE >
bool olb::ConcreteBlockLattice< T, DESCRIPTOR, PLATFORM >::hasData ( ) const

Definition at line 420 of file blockLattice.hh.

421{
422 return _data.template provides<FIELD_TYPE>();
423}

◆ hasPostProcessor()

template<typename T , typename DESCRIPTOR , Platform PLATFORM>
bool olb::ConcreteBlockLattice< T, DESCRIPTOR, PLATFORM >::hasPostProcessor ( std::type_index stage,
PostProcessorPromise< T, DESCRIPTOR > && promise )
inlineoverridevirtual

Returns true if stage contains post processor.

Implements olb::BlockLattice< T, DESCRIPTOR >.

Definition at line 617 of file blockLattice.h.

619 {
620 auto [postProcessorsOfPriority, _] = _postProcessors[stage].try_emplace(promise.priority(), this);
621 return std::get<1>(*postProcessorsOfPriority).contains(
622 std::forward<decltype(promise)>(promise));
623 }

◆ postLoad()

template<typename T , typename DESCRIPTOR , Platform PLATFORM>
void olb::ConcreteBlockLattice< T, DESCRIPTOR, PLATFORM >::postLoad ( )
overridevirtual

Reinit population structure after deserialization.

Reimplemented from olb::Serializable.

Definition at line 633 of file blockLattice.hh.

634{
635 auto& population = getField<descriptors::POPULATION>();
636 for (unsigned iPop=0; iPop < DESCRIPTOR::q; ++iPop) {
637 population[iPop].postLoad();
638 }
639}

◆ postProcess()

template<typename T , typename DESCRIPTOR , Platform PLATFORM>
void olb::ConcreteBlockLattice< T, DESCRIPTOR, PLATFORM >::postProcess ( std::type_index stage)
overridevirtual

Execute post processors of stage.

Implements olb::BlockLattice< T, DESCRIPTOR >.

Definition at line 485 of file blockLattice.hh.

486{
487 for (auto& [_, postProcessorsOfPriority] : _postProcessors[stage]) {
488 postProcessorsOfPriority.apply();
489 }
490}
+ Here is the caller graph for this function:

◆ setCollisionO()

template<typename T , typename DESCRIPTOR , Platform PLATFORM>
void olb::ConcreteBlockLattice< T, DESCRIPTOR, PLATFORM >::setCollisionO ( std::function< void(ConcreteBlockLattice< T, DESCRIPTOR, PLATFORM > &)> && op)
inline

Replace default collision logic of BlockDynamicsMap.

May be used to inject domain knowledge for improving performance by e.g. reducing the need to use virtual dispatching for non-dominant dynamics. This is necessarily platform specific.

Definition at line 541 of file blockLattice.h.

541 {
542 _customCollisionO = op;
543 }

◆ setDynamics()

template<typename T , typename DESCRIPTOR , Platform PLATFORM>
void olb::ConcreteBlockLattice< T, DESCRIPTOR, PLATFORM >::setDynamics ( CellID iCell,
DynamicsPromise< T, DESCRIPTOR > &&  )
inlineoverridevirtual

Set dynamics at iCell to promised dynamics.

Implements olb::BlockLattice< T, DESCRIPTOR >.

Definition at line 555 of file blockLattice.h.

556 {
557 _dynamicsMap.set(iCell, std::forward<decltype(promise)>(promise));
558 auto cell = this->get(iCell);
559 getDynamics(iCell)->initialize(cell);
560 }
Dynamics< T, DESCRIPTOR > * getDynamics(CellID iCell) override
Get reference to dynamics of cell by index.

References olb::BlockLattice< T, DESCRIPTOR >::get(), olb::ConcreteBlockLattice< T, DESCRIPTOR, PLATFORM >::getDynamics(), and olb::BlockDynamicsMap< T, DESCRIPTOR, PLATFORM >::set().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setParameter() [1/3]

template<typename T , typename DESCRIPTOR , Platform PLATFORM>
template<typename PARAMETER , typename _DESCRIPTOR , typename FIELD >
void olb::ConcreteBlockLattice< T, DESCRIPTOR, PLATFORM >::setParameter ( AbstractFieldArrayD< T, _DESCRIPTOR, FIELD > & abstractFieldArray)
inline

Definition at line 594 of file blockLattice.h.

595 {
596 if constexpr (PLATFORM == Platform::CPU_SIMD) {
597 switch (abstractFieldArray.getPlatform()) {
598 case Platform::CPU_SISD: {
599 auto& fieldArray = dynamic_cast<FieldArrayD<T,_DESCRIPTOR,Platform::CPU_SISD,FIELD>&>(abstractFieldArray);
600 setParameter<PARAMETER>(fieldArray);
601 break;
602 }
603 case Platform::CPU_SIMD: {
604 auto& fieldArray = dynamic_cast<FieldArrayD<T,_DESCRIPTOR,Platform::CPU_SIMD,FIELD>&>(abstractFieldArray);
605 setParameter<PARAMETER>(fieldArray);
606 break;
607 }
608 default:
609 throw std::bad_cast();
610 }
611 } else {
612 auto& fieldArray = dynamic_cast<FieldArrayD<T,_DESCRIPTOR,PLATFORM,FIELD>&>(abstractFieldArray);
613 setParameter<PARAMETER>(fieldArray);
614 }
615 }
void setParameter(FieldD< T, DESCRIPTOR, FIELD > value)
@ CPU_SIMD
Basic scalar CPU.

References olb::CPU_SIMD, olb::CPU_SISD, olb::AbstractFieldArrayD< T, DESCRIPTOR, FIELD >::getPlatform(), and olb::ConcreteBlockLattice< T, DESCRIPTOR, PLATFORM >::setParameter().

+ Here is the call graph for this function:

◆ setParameter() [2/3]

template<typename T , typename DESCRIPTOR , Platform PLATFORM>
template<typename PARAMETER , typename _DESCRIPTOR , Platform _PLATFORM, typename FIELD >
void olb::ConcreteBlockLattice< T, DESCRIPTOR, PLATFORM >::setParameter ( FieldArrayD< T, _DESCRIPTOR, _PLATFORM, FIELD > & fieldArray)
inline

Definition at line 575 of file blockLattice.h.

576 {
577 static_assert(DESCRIPTOR::template size<PARAMETER>() == DESCRIPTOR::template size<FIELD>(),
578 "PARAMETER field size must match FIELD size");
579 if constexpr (PLATFORM == Platform::GPU_CUDA) {
580 static_assert(PLATFORM == _PLATFORM, "FieldArrayD must be available on PLATFORM");
581 }
582 FieldD<T,DESCRIPTOR,PARAMETER> fieldArrayPointers;
583 for (unsigned iD=0; iD < fieldArray.d; ++iD) {
584 if constexpr (PLATFORM == Platform::GPU_CUDA) {
585 fieldArrayPointers[iD] = fieldArray[iD].deviceData();
586 } else {
587 fieldArrayPointers[iD] = fieldArray[iD].data();
588 }
589 }
590 setParameter<PARAMETER>(std::move(fieldArrayPointers));
591 }
@ 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.
Definition vector.h:480

References olb::ColumnVector< COLUMN, D >::d, olb::GPU_CUDA, and olb::ConcreteBlockLattice< T, DESCRIPTOR, PLATFORM >::setParameter().

+ Here is the call graph for this function:

◆ setParameter() [3/3]

template<typename T , typename DESCRIPTOR , Platform PLATFORM>
template<typename FIELD >
void olb::ConcreteBlockLattice< T, DESCRIPTOR, PLATFORM >::setParameter ( FieldD< T, DESCRIPTOR, FIELD > value)
inline

Definition at line 563 of file blockLattice.h.

564 {
565 _data.template forEachCastable<AbstractedConcreteParameters<T,DESCRIPTOR>>([&](auto* parameters) {
566 auto& params = parameters->asAbstract();
567 if (params.template provides<FIELD>()) {
568 params.template set<FIELD>(value);
569 parameters->setProcessingContext(ProcessingContext::Simulation);
570 }
571 });
572 }
@ Simulation
Data available on host for e.g. functor evaluation.

References olb::Simulation.

+ Here is the caller graph for this function:

◆ setProcessingContext()

template<typename T , typename DESCRIPTOR , Platform PLATFORM>
void olb::ConcreteBlockLattice< T, DESCRIPTOR, PLATFORM >::setProcessingContext ( ProcessingContext )
inlineoverridevirtual

Set processing context.

This is currently used to trigger data transfers between host and GPU data for Platform::GPU_CUDA.

Implements olb::BlockLattice< T, DESCRIPTOR >.

Definition at line 495 of file blockLattice.h.

495 {
496 _data.setProcessingContext(context);
497 }

References olb::ConcreteData< T, DESCRIPTOR, PLATFORM >::setProcessingContext().

+ Here is the call graph for this function:

◆ stream()

template<typename T , typename DESCRIPTOR , Platform PLATFORM>
void olb::ConcreteBlockLattice< T, DESCRIPTOR, PLATFORM >::stream ( )
overridevirtual

Perform propagation step on the whole block.

Rotates the cyclic arrays storing the POPULATION field to perform implicit propagation using the PS pattern.

  • Kummerländer, A., Dorn, M., Frank, M., and Krause, M. J. Implicit Propagation of Directly Addressed Grids in Lattice Boltzmann Methods. DOI: 10.13140/RG.2.2.35085.87523

Implements olb::BlockLattice< T, DESCRIPTOR >.

Definition at line 318 of file blockLattice.hh.

319{
320 if constexpr (PLATFORM == Platform::GPU_CUDA) {
321 DESCRIPTOR::template filter<descriptors::is_propagatable_field>
322 ::for_each([&](auto field) {
323 auto& population = getField(field.get());
324 for (unsigned iPop=0; iPop < DESCRIPTOR::q; ++iPop) {
325 population[iPop].rotate(this->getNeighborDistance(descriptors::c<DESCRIPTOR>(iPop)));
326 }
327 // Required for resolving populations in (gather,scatter)_any_fields kernel
328 getDataRegistry().refreshDeviceFieldArray(population);
329 });
330 } else {
331 DESCRIPTOR::template filter<descriptors::is_propagatable_field>
332 ::for_each([&](auto field) {
333 auto& population = getField(field.get());
334 for (unsigned iPop=0; iPop < DESCRIPTOR::q; ++iPop) {
335 population[iPop].rotate(this->getNeighborDistance(descriptors::c<DESCRIPTOR>(iPop)));
336 }
337 });
338 }
339}
CellDistance getNeighborDistance(LatticeR< D > dir) const
Get 1D neighbor distance.
auto & getDataRegistry()
Return reference to Data's FieldTypeRegistry.
constexpr int c(unsigned iPop, unsigned iDim) any_platform
Definition functions.h:83

References olb::descriptors::c(), and olb::GPU_CUDA.

+ Here is the call graph for this function:

◆ writeDescription()

template<typename T , typename DESCRIPTOR , Platform PLATFORM>
void olb::ConcreteBlockLattice< T, DESCRIPTOR, PLATFORM >::writeDescription ( std::ostream & ) const
overridevirtual

Prints human-readable summary of all used dynamics and post processors.

Implements olb::BlockLattice< T, DESCRIPTOR >.

Definition at line 493 of file blockLattice.hh.

494{
495 const auto dynamics = _dynamicsMap.getAll();
496 for (const auto& promise : dynamics) {
497 auto simplifiedName = introspection::getSimplifiedDynamicsName(promise.name());
498 std::istringstream stream(simplifiedName);
499 std::string fragment;
500 std::vector<std::string> fragments;
501 while (std::getline(stream, fragment, '\n')) {
502 if (!fragment.empty()) {
503 fragments.push_back(fragment);
504 }
505 }
506
507 clout << "---Dynamics Details---" << std::endl;
508 clout << " name: " << fragments[0] << std::endl;
509 for (unsigned i=1; i < fragments.size(); ++i) {
510 clout << " " << fragments[i] << std::endl;
511 }
512 clout << " weight: " << _dynamicsMap.getWeight(promise) << std::endl;
513 if (auto optimizable = promise.isOptimizable()) {
514 clout << " isOptimizable: " << *optimizable << std::endl;
515 }
516 clout << " isOptimized: " << promise.hasOptimizedVersion() << std::endl;
517 if (auto count = promise.getArithmeticOperationCount()) {
518 clout << " operations[FLOP]: " << *count << std::endl;
519 }
520 if (auto count = promise.getMemoryBandwidth()) {
521 clout << " bandwidth[byte]: " << *count << std::endl;
522 }
523 clout << "----------------------" << std::endl;
524 }
525
526 for (const auto& [stage, map] : _postProcessors) {
527 clout << "---Stage Details---" << std::endl;
528 clout << " name: " << stage.name() << std::endl;
529
530 for (const auto& [priority, postProcessorsOfPriority] : map) {
531 clout << std::endl;
532 const auto operators = postProcessorsOfPriority.getAll();
533 for (const auto& promise : operators) {
534 clout << "---Post Processor Details---" << std::endl;
535 clout << " name: " << promise.name() << std::endl;
536 clout << " priority: " << promise.priority() << std::endl;
537 clout << " scope: " << getName(promise.scope()) << std::endl;
538 clout << " weight: " << postProcessorsOfPriority.getWeight(promise) << std::endl;
539 clout << " isOptimized: " << promise.hasOptimizedVersion() << std::endl;
540 clout << "---------------------------" << std::endl;
541 }
542 }
543
544 clout << "-------------------" << std::endl;
545 }
546}
void stream() override
Perform propagation step on the whole block.
std::string getSimplifiedDynamicsName(std::string name)
Return reduced and reasonable newline-separated version of given full dynamics name.
std::string getName(OperatorScope scope)
Returns human-readable name of scope.

◆ writeDynamicsAsCSV()

template<typename T , typename DESCRIPTOR , Platform PLATFORM>
void olb::ConcreteBlockLattice< T, DESCRIPTOR, PLATFORM >::writeDynamicsAsCSV ( std::ostream & ) const
overridevirtual

Prints CSV-structured list of all used dynamics.

Used as input for automatic code generation

Implements olb::BlockLattice< T, DESCRIPTOR >.

Definition at line 549 of file blockLattice.hh.

550{
551 const auto dynamics = _dynamicsMap.getAll();
552 clout << "name; weight; isOptimizable; isOptimized; FLOP; complexity; bandwidth" << std::endl;
553 for (const auto& promise : dynamics) {
554 clout << promise.name()
555 << "; " << _dynamicsMap.getWeight(promise);
556 if (auto optimizable = promise.isOptimizable()) {
557 clout << "; " << *optimizable;
558 } else {
559 clout << "; -1";
560 }
561 clout << "; " << promise.hasOptimizedVersion();
562 if (auto count = promise.getArithmeticOperationCount()) {
563 clout << "; " << *count;
564 } else {
565 clout << "; -1";
566 }
567 if (auto count = promise.getComplexity()) {
568 clout << "; " << *count;
569 } else {
570 clout << "; -1";
571 }
572 if (auto count = promise.getMemoryBandwidth()) {
573 clout << "; " << *count;
574 } else {
575 clout << "; -1";
576 }
577 clout << std::endl;
578 }
579}

◆ writeOperatorAsCSV()

template<typename T , typename DESCRIPTOR , Platform PLATFORM>
void olb::ConcreteBlockLattice< T, DESCRIPTOR, PLATFORM >::writeOperatorAsCSV ( std::ostream & ) const
overridevirtual

Prints CSV-structured list of all used operators.

Used as input for automatic code generation

Implements olb::BlockLattice< T, DESCRIPTOR >.

Definition at line 582 of file blockLattice.hh.

583{
584 clout << "name; descriptor; weight; isOptimizable; isOptimized, complexity" << std::endl;
585 for (const auto& [stage, map] : _postProcessors) {
586 for (const auto& [priority, postProcessorsOfPriority] : map) {
587 const auto operators = postProcessorsOfPriority.getAll();
588 for (const auto& promise : operators) {
589 clout << promise.name()
590 << "; " << fields::name<DESCRIPTOR>()
591 << "; " << postProcessorsOfPriority.getWeight(promise);
592 if (auto optimizable = promise.isOptimizable()) {
593 clout << "; " << *optimizable;
594 } else {
595 clout << "; -1";
596 }
597 clout << "; " << promise.hasOptimizedVersion();
598 if (auto count = promise.getArithmeticOperationCount()) {
599 clout << "; " <<* count;
600 } else {
601 clout << "; -1";
602 }
603 clout << std::endl;
604 }
605 }
606 }
607}
std::string name()
Returns name of FIELD for human consumption.
Definition fields.h:49

References olb::fields::name().

+ Here is the call graph for this function:

Member Data Documentation

◆ platform

template<typename T , typename DESCRIPTOR , Platform PLATFORM>
Platform olb::ConcreteBlockLattice< T, DESCRIPTOR, PLATFORM >::platform = PLATFORM
staticconstexpr

Definition at line 488 of file blockLattice.h.


The documentation for this class was generated from the following files: