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

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

#include <operator.h>

+ Inheritance diagram for olb::ConcreteBlockCollisionO< T, DESCRIPTOR, Platform::CPU_SIMD, DYNAMICS >:
+ Collaboration diagram for olb::ConcreteBlockCollisionO< T, DESCRIPTOR, Platform::CPU_SIMD, 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::CPU_SIMD > &block) override
 
void apply (ConcreteBlockLattice< T, DESCRIPTOR, Platform::CPU_SIMD > &block, ConcreteBlockMask< T, Platform::CPU_SIMD > &subdomain, CollisionDispatchStrategy strategy) override
 Apply collision on entire block.
 
- Public Member Functions inherited from olb::BlockCollisionO< T, DESCRIPTOR, Platform::CPU_SIMD >
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::CPU_SIMD, DYNAMICS >

Application of the collision step on a concrete SIMD block.

ConcreteBlockCollisionO::apply allows for applying DYNAMICS on a given cell index or an entire block. The latter option accepts a ConcreteBlockMask instance describing the subset of cells for which DYNAMICS is to be vectorized.

Definition at line 325 of file operator.h.

Constructor & Destructor Documentation

◆ ConcreteBlockCollisionO()

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

Definition at line 380 of file operator.h.

380 :
381 _dynamics(new DYNAMICS()),
382 _parameters(nullptr),
383 _mask(nullptr)
384 { }

Member Function Documentation

◆ apply()

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

Apply collision on entire block.

Definition at line 428 of file operator.h.

431 {
432 if (strategy != CollisionDispatchStrategy::Dominant) {
433 throw std::runtime_error("Platform::CPU_SIMD currently only support CollisionDispatchStrategy::Dominant");
434 }
435
436 auto& mask = *_mask;
437 typename LatticeStatistics<T>::Aggregatable statistics{};
438 #ifdef PARALLEL_MODE_OMP
439 #pragma omp declare reduction(+ : typename LatticeStatistics<T>::Aggregatable : omp_out += omp_in) initializer (omp_priv={})
440 #endif
441
442 if constexpr (dynamics::is_vectorizable_v<DYNAMICS>) {
443 // Ensure that serialized mask storage is up-to-date
444 mask.setProcessingContext(ProcessingContext::Simulation);
445 // Apply collision to cells
446 #ifdef PARALLEL_MODE_OMP
447 #pragma omp parallel for schedule(static) reduction(+ : statistics)
448 #endif
449 for (CellID iCell=0; iCell < block.getNcells(); iCell += cpu::simd::Pack<T>::size) {
450 apply(block, subdomain, mask, *_parameters, statistics, iCell);
451 }
452 } else { // Fallback for non-vectorizable collision operators
453 #ifdef PARALLEL_MODE_OMP
454 #pragma omp parallel for schedule(static) reduction(+ : statistics)
455 #endif
456 for (std::size_t iCell=0; iCell < block.getNcells(); ++iCell) {
457 if (mask[iCell]) {
458 cpu::Cell<T,DESCRIPTOR,Platform::CPU_SIMD> cell(block, iCell);
459 if (auto cellStatistic = DYNAMICS().collide(cell, *_parameters)) {
460 statistics.increment(cellStatistic.rho, cellStatistic.uSqr);
461 }
462 } else if (subdomain[iCell]) {
463 applyOther(block, statistics, iCell);
464 }
465 }
466 }
467
468 block.getStatistics().incrementStats(statistics);
469 }
std::uint32_t CellID
Type for sequential block-local cell indices.
@ Simulation
Data available on host for e.g. functor evaluation.
@ Dominant
Apply dominant dynamics using mask and fallback to virtual dispatch for others.

References olb::Dominant, olb::BlockStructureD< D >::getNcells(), olb::BlockLattice< T, DESCRIPTOR >::getStatistics(), olb::LatticeStatistics< T >::Aggregatable::increment(), and olb::Simulation.

+ Here is the call graph for this function:

◆ getDynamics()

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

Implements olb::AbstractCollisionO< T, DESCRIPTOR >.

Definition at line 409 of file operator.h.

410 {
411 return _dynamics.get();
412 }

◆ id()

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

Implements olb::AbstractBlockO.

Definition at line 386 of file operator.h.

387 {
388 return typeid(DYNAMICS);
389 }

◆ set()

template<typename T , typename DESCRIPTOR , typename DYNAMICS >
void olb::ConcreteBlockCollisionO< T, DESCRIPTOR, Platform::CPU_SIMD, 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 396 of file operator.h.

397 {
399 if constexpr (!std::is_same_v<DYNAMICS,NoDynamics<T,DESCRIPTOR>>) {
400 if (!overlap) {
401 _mask->set(iCell, state);
402 }
403 }
404 if (state) {
405 _dynamicsOfCells[iCell] = _concreteDynamics.get();
406 }
407 }
void set(std::size_t i, bool active)
Definition mask.h:79

◆ setup()

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

Definition at line 414 of file operator.h.

415 {
416 _parameters = &block.template getData<OperatorParameters<DYNAMICS>>().parameters;
417 _mask = &block.template getData<DynamicsMask<DYNAMICS>>();
418 if constexpr (dynamics::has_parametrized_momenta_v<DYNAMICS>) {
419 _dynamics->setMomentaParameters(_parameters);
420 }
421
422 _concreteDynamics.reset(new cpu::simd::ConcreteDynamics<T,DESCRIPTOR,DYNAMICS>(_parameters));
423 // Fetch pointer to concretized dynamic-dispatch field
424 _dynamicsOfCells = block.template getField<cpu::DYNAMICS<T,DESCRIPTOR,Platform::CPU_SIMD>>()[0].data();
425 }

◆ weight()

template<typename T , typename DESCRIPTOR , typename DYNAMICS >
std::size_t olb::ConcreteBlockCollisionO< T, DESCRIPTOR, Platform::CPU_SIMD, 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 391 of file operator.h.

392 {
393 return _mask->weight();
394 }

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