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

364 :
365 _dynamics(new DYNAMICS()),
366 _parameters(nullptr),
367 _mask(nullptr)
368 { }

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

415 {
416 if (strategy != CollisionDispatchStrategy::Dominant) {
417 throw std::runtime_error("Platform::CPU_SIMD currently only support CollisionDispatchStrategy::Dominant");
418 }
419
420 auto& mask = *_mask;
421 typename LatticeStatistics<T>::Aggregatable statistics{};
422 #ifdef PARALLEL_MODE_OMP
423 #pragma omp declare reduction(+ : typename LatticeStatistics<T>::Aggregatable : omp_out += omp_in) initializer (omp_priv={})
424 #endif
425
426 if constexpr (dynamics::is_vectorizable_v<DYNAMICS>) {
427 // Ensure that serialized mask storage is up-to-date
429 // Apply collision to cells
430 #ifdef PARALLEL_MODE_OMP
431 #pragma omp parallel for schedule(static) reduction(+ : statistics)
432 #endif
433 for (CellID iCell=0; iCell < block.getNcells(); iCell += cpu::simd::Pack<T>::size) {
434 apply(block, subdomain, mask, *_parameters, statistics, iCell);
435 }
436 } else { // Fallback for non-vectorizable collision operators
437 #ifdef PARALLEL_MODE_OMP
438 #pragma omp parallel for schedule(static) reduction(+ : statistics)
439 #endif
440 for (std::size_t iCell=0; iCell < block.getNcells(); ++iCell) {
441 if (mask[iCell]) {
442 cpu::Cell<T,DESCRIPTOR,Platform::CPU_SIMD> cell(block, iCell);
443 if (auto cellStatistic = DYNAMICS().apply(cell, *_parameters)) {
444 statistics.increment(cellStatistic.rho, cellStatistic.uSqr);
445 }
446 } else if (subdomain[iCell]) {
447 applyOther(block, statistics, iCell);
448 }
449 }
450 }
451
452 block.getStatistics().incrementStats(statistics);
453 }
LatticeStatistics< T > & getStatistics()
Return a handle to the LatticeStatistics object.
std::size_t getNcells() const
Get number of cells.
void setProcessingContext(ProcessingContext)
Definition mask.h:94
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 393 of file operator.h.

394 {
395 return _dynamics.get();
396 }

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

371 {
372 return typeid(DYNAMICS);
373 }

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

381 {
383 if constexpr (!std::is_same_v<DYNAMICS,NoDynamics<T,DESCRIPTOR>>) {
384 if (!overlap) {
385 _mask->set(iCell, state);
386 }
387 }
388 if (state) {
389 _dynamicsOfCells[iCell] = _concreteDynamics.get();
390 }
391 }
void set(std::size_t i, bool active)
Definition mask.h:75

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

399 {
400 _parameters = &block.template getData<OperatorParameters<DYNAMICS>>().parameters;
401 _mask = &block.template getData<DynamicsMask<DYNAMICS>>();
402 if constexpr (dynamics::has_parametrized_momenta_v<DYNAMICS>) {
403 _dynamics->setMomentaParameters(_parameters);
404 }
405
406 _concreteDynamics.reset(new cpu::simd::ConcreteDynamics<T,DESCRIPTOR,DYNAMICS>(_parameters));
407 // Fetch pointer to concretized dynamic-dispatch field
408 _dynamicsOfCells = block.template getField<cpu::DYNAMICS<T,DESCRIPTOR,Platform::CPU_SIMD>>()[0].data();
409 }

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

376 {
377 return _mask->weight();
378 }

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