OpenLB 1.7
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Attributes | List of all members
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.
 
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 (DynamicsPromise< T, DESCRIPTOR > &&promise) override
 Return pointer to dynamics yielded by promise.
 
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.
 
void setDynamics (CellID iCell, Dynamics< T, DESCRIPTOR > *dynamics) override
 
template<typename FIELD >
void setParameter (FieldD< T, DESCRIPTOR, FIELD > value)
 
template<typename PARAMETER , Platform _PLATFORM, typename FIELD >
void setParameter (FieldArrayD< T, DESCRIPTOR, _PLATFORM, FIELD > &fieldArray)
 
template<typename PARAMETER , 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 addPostProcessor (std::type_index stage, PostProcessor< T, DESCRIPTOR > *postProcessor) override
 Schedule legacy post processor for application in stage.
 
void addPostProcessor (std::type_index stage, const PostProcessorGenerator< T, DESCRIPTOR > &ppGen) override
 Schedule legacy post processor in stage.
 
void addPostProcessor (std::type_index stage, BlockIndicatorF< T, DESCRIPTOR::d > &indicator, const PostProcessorGenerator< T, DESCRIPTOR > &ppGen) override
 Schedule legacy post processor for application to indicated cells 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.
 
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<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)
 
template<typename DYNAMICS >
Dynamics< T, DESCRIPTOR > * getDynamics ()
 Return pointer to DYNAMICS (legacy)
 
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 > typename DYNAMICS>
void defineDynamics (LatticeR< DESCRIPTOR::d > latticeR)
 Assign DYNAMICS to latticeR.
 
void defineDynamics (LatticeR< DESCRIPTOR::d > latticeR, Dynamics< T, DESCRIPTOR > *dynamics)
 Assign dynamics to latticeR via pointer (legacy)
 
void defineDynamics (BlockIndicatorF< T, DESCRIPTOR::d > &indicator, Dynamics< T, DESCRIPTOR > *dynamics)
 Define the dynamics on a domain described by an indicator.
 
template<typename DYNAMICS >
void defineDynamics (BlockIndicatorF< T, DESCRIPTOR::d > &indicator)
 Define DYNAMICS on a domain described by an indicator.
 
void defineDynamics (Dynamics< T, DESCRIPTOR > *dynamics)
 Define the same dynamics on all cells.
 
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 FIELD >
void setParameter (AbstractFieldArrayD< T, DESCRIPTOR, FIELD > &fieldArray)
 
template<typename PARAMETER , Platform PLATFORM, typename FIELD >
void setParameter (FieldArrayD< T, DESCRIPTOR, PLATFORM, FIELD > &fieldArray)
 
template<typename STAGE = stage::PostStream>
void addPostProcessor (PostProcessor< T, DESCRIPTOR > *postProcessor)
 Schedule legacy post processor for application in STAGE.
 
template<typename STAGE = stage::PostStream>
void addPostProcessor (const PostProcessorGenerator< T, DESCRIPTOR > &ppGen)
 Schedule legacy post processor for application in STAGE.
 
template<typename STAGE = stage::PostStream>
void addPostProcessor (BlockIndicatorF< T, DESCRIPTOR::d > &indicator, const PostProcessorGenerator< T, DESCRIPTOR > &ppGen)
 Schedule legacy post processor for application to indicated cells in STAGE.
 
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.
 
void addLatticeCoupling (LatticeCouplingGenerator< T, DESCRIPTOR > const &lcGen, std::vector< BlockStructureD< DESCRIPTOR::d > * > partners)
 Add a non-local post-processing step (legacy)
 
void addLatticeCoupling (BlockIndicatorF< T, DESCRIPTOR::d > &indicator, LatticeCouplingGenerator< T, DESCRIPTOR > const &lcGen, std::vector< BlockStructureD< DESCRIPTOR::d > * > partners)
 
void executeCoupling ()
 Execute couplings steps (legacy)
 
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 ()
 
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
 
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.
 
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
 
bool _statisticsEnabled
 
LatticeStatistics< T > * _statistics
 
- 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 = Platform::CPU_SISD>
class olb::ConcreteBlockLattice< T, DESCRIPTOR, PLATFORM >

Implementation of BlockLattice on a concrete PLATFORM.

Definition at line 464 of file blockLattice.h.

Member Typedef Documentation

◆ descriptor_t

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

Definition at line 485 of file blockLattice.h.

◆ value_t

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

Definition at line 484 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 416 of file blockLattice.hh.

417 : BlockLattice<T,DESCRIPTOR>(size, padding, PLATFORM),
418 _data(),
419 _descriptorFields(),
420 _dynamicsMap(*this)
421{
422 DESCRIPTOR::fields_t::template for_each([&](auto id) {
423 using field = typename decltype(id)::type;
424 using field_type = Array<field>;
425 auto& fieldArray = _data.template allocate<field_type>(this->getNcells());
426 _descriptorFields.template set<field>(&fieldArray);
427 _communicatables[typeid(field)] = std::unique_ptr<Communicatable>(new ConcreteCommunicatable<
428 ColumnVector<typename ImplementationOf<typename field::template column_type<T>,PLATFORM>::type,
429 DESCRIPTOR::template size<field>()>
430 >(fieldArray));
431 _data.template setSerialization<field_type>(true);
432 });
433
434 Dynamics<T,DESCRIPTOR>* noDynamics = _dynamicsMap.get(DynamicsPromise(meta::id<NoDynamics<T,DESCRIPTOR>>{}));
435 for (CellID iCell=0; iCell < this->getNcells(); ++iCell) {
436 _dynamicsMap.set(iCell, noDynamics);
437 }
438}
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.
DynamicsPromise(meta::id< DYNAMICS >) -> DynamicsPromise< typename DYNAMICS::value_t, typename DYNAMICS::descriptor_t >

Member Function Documentation

◆ addPostProcessor() [1/6]

template<typename T , typename DESCRIPTOR , Platform PLATFORM>
void olb::ConcreteBlockLattice< T, DESCRIPTOR, PLATFORM >::addPostProcessor ( std::type_index stage,
BlockIndicatorF< T, DESCRIPTOR::d > & indicator,
const PostProcessorGenerator< T, DESCRIPTOR > & ppGen )
overridevirtual

Schedule legacy post processor for application to indicated cells in stage.

Implements olb::BlockLattice< T, DESCRIPTOR >.

Definition at line 522 of file blockLattice.hh.

524{
525 if (!indicator.isEmpty()) {
526 this->forCoreSpatialLocations([&](LatticeR<DESCRIPTOR::d> loc) {
527 if (indicator(loc)) {
528 std::unique_ptr<PostProcessorGenerator<T,DESCRIPTOR>> extractedPpGen{ ppGen.clone() };
529 if (extractedPpGen->extract(0, 0)) {
530 extractedPpGen->shift(loc);
531 addPostProcessor(stage, *extractedPpGen);
532 }
533 }
534 });
535 }
536}
void forCoreSpatialLocations(F f) const

◆ addPostProcessor() [2/6]

template<typename T , typename DESCRIPTOR , Platform PLATFORM = Platform::CPU_SISD>
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 625 of file blockLattice.h.

628 {
629 this->forCoreSpatialLocations([&](LatticeR<DESCRIPTOR::d> loc) {
630 if (indicator(loc)) {
631 addPostProcessor(stage, loc, std::forward<decltype(promise)>(promise));
632 }
633 });
634 }
void addPostProcessor(std::type_index stage, LatticeR< DESCRIPTOR::d > latticeR, PostProcessorPromise< T, DESCRIPTOR > &&promise) override
Schedule post processor for application to latticeR in stage.

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

+ Here is the call graph for this function:

◆ addPostProcessor() [3/6]

template<typename T , typename DESCRIPTOR , Platform PLATFORM>
void olb::ConcreteBlockLattice< T, DESCRIPTOR, PLATFORM >::addPostProcessor ( std::type_index stage,
const PostProcessorGenerator< T, DESCRIPTOR > & ppGen )
overridevirtual

Schedule legacy post processor in stage.

Implements olb::BlockLattice< T, DESCRIPTOR >.

Definition at line 515 of file blockLattice.hh.

517{
518 addPostProcessor(stage, ppGen.generate());
519}

◆ addPostProcessor() [4/6]

template<typename T , typename DESCRIPTOR , Platform PLATFORM = Platform::CPU_SISD>
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 614 of file blockLattice.h.

617 {
618 if (!this->isPadding(latticeR)) {
619 auto [postProcessorsOfPriority, _] = _postProcessors[stage].try_emplace(promise.priority(), this);
620 std::get<1>(*postProcessorsOfPriority).add(this->getCellId(latticeR),
621 std::forward<decltype(promise)>(promise));
622 }
623 }
bool isPadding(LatticeR< D > latticeR) const
Return whether location is valid.

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

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

◆ addPostProcessor() [5/6]

template<typename T , typename DESCRIPTOR , Platform PLATFORM>
void olb::ConcreteBlockLattice< T, DESCRIPTOR, PLATFORM >::addPostProcessor ( std::type_index stage,
PostProcessor< T, DESCRIPTOR > * postProcessor )
overridevirtual

Schedule legacy post processor for application in stage.

Implements olb::BlockLattice< T, DESCRIPTOR >.

Definition at line 507 of file blockLattice.hh.

509{
510 auto [postProcessorsOfPriority, _] = _postProcessors[stage].try_emplace(postProcessor->getPriority(), this);
511 std::get<1>(*postProcessorsOfPriority).addLegacy(postProcessor);
512}

◆ addPostProcessor() [6/6]

template<typename T , typename DESCRIPTOR , Platform PLATFORM = Platform::CPU_SISD>
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 636 of file blockLattice.h.

638 {
639 if (promise.scope() == OperatorScope::PerBlock) {
640 auto [postProcessorsOfPriority, _] = _postProcessors[stage].try_emplace(promise.priority(), this);
641 std::get<1>(*postProcessorsOfPriority).add(std::forward<decltype(promise)>(promise));
642 } else {
643 this->forCoreSpatialLocations([&](LatticeR<DESCRIPTOR::d> loc) {
644 addPostProcessor(stage, loc, std::forward<decltype(promise)>(promise));
645 });
646 }
647 }
@ 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:

◆ 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 293 of file blockLattice.hh.

294{
295 if (_customCollisionO) {
296 _customCollisionO->operator()(*this);
297 } else {
298 if constexpr (isPlatformCPU(PLATFORM)) {
299 _dynamicsMap.collide(CollisionDispatchStrategy::Dominant);
300 } else {
301 _dynamicsMap.collide(CollisionDispatchStrategy::Individual);
302 }
303 }
304}
constexpr bool isPlatformCPU(Platform platform)
Returns true if platform is equal to Platform::CPU_*.
Definition platform.h:154
@ 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:

◆ 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 559 of file blockLattice.hh.

560{
561 std::size_t currentBlock = 0;
562 bool* dataPtr = nullptr;
563
564 this->registerSerializableOfConstSize(iBlock, sizeBlock, currentBlock, dataPtr, _data, loadingMode);
565
566 return dataPtr;
567}
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 = Platform::CPU_SISD>
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/2]

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

Definition at line 458 of file blockLattice.hh.

459{
460 if (_data.template provides<FIELD_TYPE>()) {
461 return _data.template get<FIELD_TYPE>();
462 } else {
463 // TODO: Implement more generic approach to constructing arbitrary data from specific args
464 auto& data = _data.template allocate<FIELD_TYPE>(this->getNcells());
465 // Manage serializables and communicatables for array fields
466 using concrete_data_t = typename FIELD_TYPE::template type<T,DESCRIPTOR,PLATFORM>;
467 if constexpr (std::is_base_of_v<ColumnVectorBase,concrete_data_t>) {
468 using field_t = typename concrete_data_t::field_t;
469 if constexpr (field_t::isSerializable()) {
470 _data.template setSerialization<FIELD_TYPE>(true);
471 }
472 _communicatables[typeid(field_t)] = std::unique_ptr<Communicatable>(new ConcreteCommunicatable<
473 ColumnVector<typename ImplementationOf<typename field_t::template column_type<T>,PLATFORM>::type,
474 DESCRIPTOR::template size<field_t>()>
475 >(data));
476 }
477 return data;
478 }
479 __builtin_unreachable();
480}

◆ getData() [2/2]

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

Definition at line 449 of file blockLattice.hh.

450{
451 OLB_ASSERT(_data.template provides<FIELD_TYPE>(),
452 "FIELD_TYPE must be allocated to be accessed");
453 return _data.template get<FIELD_TYPE>();
454}
#define OLB_ASSERT(COND, MESSAGE)
Definition olbDebug.h:45

◆ getDataRegistry()

template<typename T , typename DESCRIPTOR , Platform PLATFORM = Platform::CPU_SISD>
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 673 of file blockLattice.h.

673 {
674 return _data.getRegistry();
675 }

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

+ Here is the call graph for this function:

◆ getDynamics() [1/2]

template<typename T , typename DESCRIPTOR , Platform PLATFORM = Platform::CPU_SISD>
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 554 of file blockLattice.h.

555 {
556 return _dynamicsMap.get(iCell);
557 }

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

+ Here is the call graph for this function:

◆ getDynamics() [2/2]

template<typename T , typename DESCRIPTOR , Platform PLATFORM = Platform::CPU_SISD>
Dynamics< T, DESCRIPTOR > * olb::ConcreteBlockLattice< T, DESCRIPTOR, PLATFORM >::getDynamics ( DynamicsPromise< T, DESCRIPTOR > && )
inlineoverridevirtual

Return pointer to dynamics yielded by promise.

Implements olb::BlockLattice< T, DESCRIPTOR >.

Definition at line 549 of file blockLattice.h.

549 {
550 return _dynamicsMap.get(std::forward<decltype(promise)>(promise));
551 }

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

+ Here is the call graph for this function:

◆ getDynamicsMap()

template<typename T , typename DESCRIPTOR , Platform PLATFORM = Platform::CPU_SISD>
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 484 of file blockLattice.hh.

485{
486 if constexpr (DESCRIPTOR::fields_t::template contains<FIELD>()) {
487 return static_cast<FieldArrayD<T,DESCRIPTOR,PLATFORM,FIELD>&>(*_descriptorFields.template get<FIELD>());
488 } else {
489 return getData<Array<FIELD>>();
490 }
491 __builtin_unreachable();
492}

◆ 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 496 of file blockLattice.hh.

497{
498 if constexpr (DESCRIPTOR::fields_t::template contains<FIELD>()) {
499 return static_cast<const FieldArrayD<T,DESCRIPTOR,PLATFORM,FIELD>&>(*_descriptorFields.template get<FIELD>());
500 } else {
501 return getData<Array<FIELD>>();
502 }
503 __builtin_unreachable();
504}

◆ 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 547 of file blockLattice.hh.

548{
549 return _data.getNblock();
550}

◆ getPopulationPointers()

template<typename T , typename DESCRIPTOR , Platform PLATFORM = Platform::CPU_SISD>
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 662 of file blockLattice.h.

662 {
663 auto& pops = getField<descriptors::POPULATION>();
664 return Vector<T*,DESCRIPTOR::q>([&](unsigned iPop) -> T* {
665 return &pops[iPop][iCell];
666 });
667 }

◆ 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 553 of file blockLattice.hh.

554{
555 return _data.getSerializableSize();
556}

◆ hasCommunicatable()

template<typename T , typename DESCRIPTOR , Platform PLATFORM = Platform::CPU_SISD>
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 442 of file blockLattice.hh.

443{
444 return _data.template provides<FIELD_TYPE>();
445}

◆ hasPostProcessor()

template<typename T , typename DESCRIPTOR , Platform PLATFORM = Platform::CPU_SISD>
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 606 of file blockLattice.h.

608 {
609 auto [postProcessorsOfPriority, _] = _postProcessors[stage].try_emplace(promise.priority(), this);
610 return std::get<1>(*postProcessorsOfPriority).contains(
611 std::forward<decltype(promise)>(promise));
612 }

◆ 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 570 of file blockLattice.hh.

571{
572 auto& population = getField<descriptors::POPULATION>();
573 for (unsigned iPop=0; iPop < DESCRIPTOR::q; ++iPop) {
574 population[iPop].postLoad();
575 }
576}

◆ 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 539 of file blockLattice.hh.

540{
541 for (auto& [_, postProcessorsOfPriority] : _postProcessors[stage]) {
542 postProcessorsOfPriority.apply();
543 }
544}

◆ setCollisionO()

template<typename T , typename DESCRIPTOR , Platform PLATFORM = Platform::CPU_SISD>
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() [1/2]

template<typename T , typename DESCRIPTOR , Platform PLATFORM = Platform::CPU_SISD>
void olb::ConcreteBlockLattice< T, DESCRIPTOR, PLATFORM >::setDynamics ( CellID iCell,
Dynamics< T, DESCRIPTOR > * dynamics )
inlineoverridevirtual

Implements olb::BlockLattice< T, DESCRIPTOR >.

Definition at line 565 of file blockLattice.h.

566 {
567 _dynamicsMap.set(iCell, dynamics);
568 }

◆ setDynamics() [2/2]

template<typename T , typename DESCRIPTOR , Platform PLATFORM = Platform::CPU_SISD>
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 559 of file blockLattice.h.

560 {
561 _dynamicsMap.set(iCell, std::forward<decltype(promise)>(promise));
562 auto cell = this->get(iCell);
563 getDynamics(iCell)->initialize(cell);
564 }
Dynamics< T, DESCRIPTOR > * getDynamics()
Return pointer to DYNAMICS (legacy)
Cell< T, DESCRIPTOR > get(CellID iCell)
Get Cell interface for index iCell.

References olb::BlockLattice< T, DESCRIPTOR >::get(), and olb::BlockLattice< T, DESCRIPTOR >::getDynamics().

+ Here is the call graph for this function:

◆ setParameter() [1/3]

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

Definition at line 600 of file blockLattice.h.

601 {
602 auto& fieldArray = dynamic_cast<FieldArrayD<T,DESCRIPTOR,PLATFORM,FIELD>&>(abstractFieldArray);
603 setParameter<PARAMETER>(fieldArray);
604 }

◆ setParameter() [2/3]

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

Definition at line 583 of file blockLattice.h.

584 {
585 if constexpr (PLATFORM == Platform::GPU_CUDA) {
586 static_assert(PLATFORM == _PLATFORM, "FieldArrayD must be available on PLATFORM");
587 }
588 FieldD<T,DESCRIPTOR,PARAMETER> fieldArrayPointers;
589 for (unsigned iD=0; iD < fieldArray.d; ++iD) {
590 if constexpr (PLATFORM == Platform::GPU_CUDA) {
591 fieldArrayPointers[iD] = fieldArray[iD].deviceData();
592 } else {
593 fieldArrayPointers[iD] = fieldArray[iD].data();
594 }
595 }
596 setParameter<PARAMETER>(std::move(fieldArrayPointers));
597 }
@ GPU_CUDA
Vector CPU (AVX2 / AVX-512 collision)

References olb::ColumnVector< COLUMN, D >::d, and olb::GPU_CUDA.

◆ setParameter() [3/3]

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

Definition at line 571 of file blockLattice.h.

572 {
573 _data.template forEachCastable<AbstractedConcreteParameters<T,DESCRIPTOR>>([&](auto* parameters) {
574 auto& params = parameters->asAbstract();
575 if (params.template provides<FIELD>()) {
576 params.template set<FIELD>(value);
577 parameters->setProcessingContext(ProcessingContext::Simulation);
578 }
579 });
580 }
@ Simulation
Data available on host for e.g. functor evaluation.

References olb::Simulation.

◆ setProcessingContext()

template<typename T , typename DESCRIPTOR , Platform PLATFORM = Platform::CPU_SISD>
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 499 of file blockLattice.h.

499 {
500 _data.setProcessingContext(context);
501 }

References olb::Data< 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 307 of file blockLattice.hh.

308{
309 if constexpr (PLATFORM == Platform::GPU_CUDA) {
310 DESCRIPTOR::template filter<descriptors::is_propagatable_field>
311 ::for_each([&](auto field) {
312 auto& population = getField(field.get());
313 for (unsigned iPop=0; iPop < DESCRIPTOR::q; ++iPop) {
314 population[iPop].rotate(this->getNeighborDistance(descriptors::c<DESCRIPTOR>(iPop)));
315 }
316 // Required for resolving populations in (gather,scatter)_any_fields kernel
317 getDataRegistry().refreshDeviceFieldArray(population);
318 });
319 } else {
320 DESCRIPTOR::template filter<descriptors::is_propagatable_field>
321 ::for_each([&](auto field) {
322 auto& population = getField(field.get());
323 for (unsigned iPop=0; iPop < DESCRIPTOR::q; ++iPop) {
324 population[iPop].rotate(this->getNeighborDistance(descriptors::c<DESCRIPTOR>(iPop)));
325 }
326 });
327 }
328}
CellDistance getNeighborDistance(LatticeR< D > dir) const
Get 1D neighbor distance.
auto & getDataRegistry()
Return reference to Data's FieldTypeRegistry.
const auto & getField(FIELD field=FIELD()) const

References olb::GPU_CUDA.

Member Data Documentation

◆ platform

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

Definition at line 492 of file blockLattice.h.


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