OpenLB 1.8.1
Loading...
Searching...
No Matches
olb::ConcreteBlockCollisionO< T, DESCRIPTOR, Platform::GPU_CUDA, DYNAMICS > Class Template Referencefinal

Application of the collision step on a concrete CUDA block. More...

#include <operator.h>

+ Inheritance diagram for olb::ConcreteBlockCollisionO< T, DESCRIPTOR, Platform::GPU_CUDA, DYNAMICS >:
+ Collaboration diagram for olb::ConcreteBlockCollisionO< T, DESCRIPTOR, Platform::GPU_CUDA, DYNAMICS >:

Public Member Functions

 ConcreteBlockCollisionO ()
 
std::type_index id () const override
 
std::size_t weight () const override
 Returns number of assigned cells.
 
void set (CellID iCell, bool state, bool overlap) override
 Set whether iCell is covered by the present collision step.
 
Dynamics< T, DESCRIPTOR > * getDynamics () override
 
void setup (ConcreteBlockLattice< T, DESCRIPTOR, Platform::GPU_CUDA > &block) override
 
void apply (ConcreteBlockLattice< T, DESCRIPTOR, Platform::GPU_CUDA > &block, ConcreteBlockMask< T, Platform::GPU_CUDA > &subdomain, CollisionDispatchStrategy strategy) override
 Apply collision to subdomain of block using strategy.
 
- Public Member Functions inherited from olb::BlockCollisionO< T, DESCRIPTOR, Platform::GPU_CUDA >
virtual void setup (ConcreteBlockLattice< T, DESCRIPTOR, PLATFORM > &block)=0
 Setup collision on block.
 
virtual void apply (ConcreteBlockLattice< T, DESCRIPTOR, PLATFORM > &block, ConcreteBlockMask< T, PLATFORM > &subdomain, CollisionDispatchStrategy strategy)=0
 Apply collision on subdomain of block using strategy.
 
- Public Member Functions inherited from olb::AbstractCollisionO< T, DESCRIPTOR >
- Public Member Functions inherited from olb::AbstractBlockO
virtual ~AbstractBlockO ()=default
 

Detailed Description

template<typename T, typename DESCRIPTOR, typename DYNAMICS>
class olb::ConcreteBlockCollisionO< T, DESCRIPTOR, Platform::GPU_CUDA, DYNAMICS >

Application of the collision step on a concrete CUDA block.

Definition at line 48 of file operator.h.

Constructor & Destructor Documentation

◆ ConcreteBlockCollisionO()

template<typename T , typename DESCRIPTOR , typename DYNAMICS >
olb::ConcreteBlockCollisionO< T, DESCRIPTOR, Platform::GPU_CUDA, DYNAMICS >::ConcreteBlockCollisionO ( )

Definition at line 538 of file operator.hh.

538 :
539 _dynamics(new DYNAMICS()),
540 _parameters(nullptr),
541 _mask(nullptr),
542 _cells(0),
543 _modified(true),
544 _stream(cudaStreamDefault)
545{ }

Member Function Documentation

◆ apply()

template<typename T , typename DESCRIPTOR , typename DYNAMICS >
void olb::ConcreteBlockCollisionO< T, DESCRIPTOR, Platform::GPU_CUDA, DYNAMICS >::apply ( ConcreteBlockLattice< T, DESCRIPTOR, Platform::GPU_CUDA > & block,
ConcreteBlockMask< T, Platform::GPU_CUDA > & subdomain,
CollisionDispatchStrategy strategy )
inlineoverride

Apply collision to subdomain of block using strategy.

The subdomain argument is currently assumed to be the core mask of BlockDynamicsMap

Definition at line 110 of file operator.h.

113 {
114 switch (strategy) {
116 return applyDominant(block, subdomain);
118 return applyIndividual(block, subdomain);
119 default:
120 throw std::runtime_error("Invalid collision dispatch strategy");
121 }
122 }
@ 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, and olb::Individual.

◆ getDynamics()

template<typename T , typename DESCRIPTOR , typename DYNAMICS >
Dynamics< T, DESCRIPTOR > * olb::ConcreteBlockCollisionO< T, DESCRIPTOR, Platform::GPU_CUDA, DYNAMICS >::getDynamics ( )
inlineoverridevirtual

Implements olb::AbstractCollisionO< T, DESCRIPTOR >.

Definition at line 99 of file operator.h.

100 {
101 return _dynamics.get();
102 }

◆ id()

template<typename T , typename DESCRIPTOR , typename DYNAMICS >
std::type_index olb::ConcreteBlockCollisionO< T, DESCRIPTOR, Platform::GPU_CUDA, DYNAMICS >::id ( ) const
inlineoverridevirtual

Implements olb::AbstractBlockO.

Definition at line 75 of file operator.h.

76 {
77 return typeid(DYNAMICS);
78 }

◆ set()

template<typename T , typename DESCRIPTOR , typename DYNAMICS >
void olb::ConcreteBlockCollisionO< T, DESCRIPTOR, Platform::GPU_CUDA, DYNAMICS >::set ( CellID iCell,
bool state,
bool overlap )
inlineoverridevirtual

Set whether iCell is covered by the present collision step.

Parameters
iCellCell index
state(De)activate for this dynamics / collision
overlapCell index in overlap (set dynamics but do not collide)

Only unmask cells that actually do something

Implements olb::AbstractCollisionO< T, DESCRIPTOR >.

Definition at line 85 of file operator.h.

86 {
88 if constexpr (!std::is_same_v<DYNAMICS,NoDynamics<T,DESCRIPTOR>>) {
89 if (!overlap) {
90 _mask->set(iCell, state);
91 }
92 }
93 if (state) {
94 _dynamicsOfCells[iCell] = _deviceDynamics.get();
95 }
96 _modified = true;
97 }
void set(std::size_t i, bool active)
Definition mask.h:49

References olb::gpu::cuda::device::unique_ptr< T >::get().

+ Here is the call graph for this function:

◆ setup()

template<typename T , typename DESCRIPTOR , typename DYNAMICS >
void olb::ConcreteBlockCollisionO< T, DESCRIPTOR, Platform::GPU_CUDA, DYNAMICS >::setup ( ConcreteBlockLattice< T, DESCRIPTOR, Platform::GPU_CUDA > & block)
override

Definition at line 623 of file operator.hh.

625{
626 // Fetch pointers to DYNAMICS-specific parameter and mask data
627 _parameters = &block.template getData<OperatorParameters<DYNAMICS>>();
628 _mask = &block.template getData<DynamicsMask<DYNAMICS>>();
629
630 {
631 // Construct on-device dynamics proxy for dynamic dispatch
634 _deviceDynamics.get(),
635 _parameters->deviceData());
637
638 // Fetch pointer to on-device dynamic-dispatch field
639 _dynamicsOfCells = block.template getField<gpu::cuda::DYNAMICS<T,DESCRIPTOR>>()[0].data();
640 }
641}
void check()
Check errors.
Definition device.hh:48
T * malloc(std::size_t size)
Allocate data on device.
Definition device.hh:89
void construct_dynamics(void *target, PARAMETERS *parameters) __global__
CUDA kernel for constructing on-device ConcreteDynamics.
Definition operator.hh:412

References olb::gpu::cuda::device::check(), olb::gpu::cuda::kernel::construct_dynamics(), and olb::gpu::cuda::device::malloc().

+ Here is the call graph for this function:

◆ weight()

template<typename T , typename DESCRIPTOR , typename DYNAMICS >
std::size_t olb::ConcreteBlockCollisionO< T, DESCRIPTOR, Platform::GPU_CUDA, DYNAMICS >::weight ( ) const
inlineoverridevirtual

Returns number of assigned cells.

Used to determine the dominant dynamics to choose e.g. which collision operator to vectorize or to prefer in GPU kernels.

Implements olb::AbstractCollisionO< T, DESCRIPTOR >.

Definition at line 80 of file operator.h.

81 {
82 return _mask->weight();
83 }

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