OpenLB 1.7
Loading...
Searching...
No Matches
Public Member Functions | List of all members
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::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 41 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 467 of file operator.hh.

467 :
468 _dynamics(new DYNAMICS()),
469 _parameters(nullptr),
470 _mask(nullptr),
471 _cells(0),
472 _modified(true),
473 _stream(cudaStreamDefault)
474{ }

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 103 of file operator.h.

106 {
107 switch (strategy) {
109 return applyDominant(block, subdomain);
111 return applyIndividual(block, subdomain);
112 default:
113 throw std::runtime_error("Invalid collision dispatch strategy");
114 }
115 }
@ 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 92 of file operator.h.

93 {
94 return _dynamics.get();
95 }

◆ 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 68 of file operator.h.

69 {
70 return typeid(DYNAMICS);
71 }

◆ 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 78 of file operator.h.

79 {
81 if constexpr (!std::is_same_v<DYNAMICS,NoDynamics<T,DESCRIPTOR>>) {
82 if (!overlap) {
83 _mask->set(iCell, state);
84 }
85 }
86 if (state) {
87 _dynamicsOfCells[iCell] = _deviceDynamics.get();
88 }
89 _modified = true;
90 }
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 552 of file operator.hh.

554{
555 // Fetch pointers to DYNAMICS-specific parameter and mask data
556 _parameters = &block.template getData<OperatorParameters<DYNAMICS>>();
557 _mask = &block.template getData<DynamicsMask<DYNAMICS>>();
558
559 {
560 // Construct on-device dynamics proxy for dynamic dispatch
561 _deviceDynamics = gpu::cuda::device::malloc<gpu::cuda::ConcreteDynamics<T,DESCRIPTOR,DYNAMICS>>(1);
562 gpu::cuda::kernel::construct_dynamics<T,DESCRIPTOR,DYNAMICS><<<1,1>>>(
563 _deviceDynamics.get(),
564 _parameters->deviceData());
566
567 // Fetch pointer to on-device dynamic-dispatch field
568 _dynamicsOfCells = block.template getField<gpu::cuda::DYNAMICS<T,DESCRIPTOR>>()[0].data();
569 }
570}
void check()
Check errors.
Definition device.hh:48

References olb::gpu::cuda::device::check().

+ 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 73 of file operator.h.

74 {
75 return _mask->weight();
76 }

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