OpenLB 1.8.1
Loading...
Searching...
No Matches
olb::StatisticsPostProcessor::type< ConcreteBlockLattice< T, DESCRIPTOR, Platform::GPU_CUDA > > Struct Template Reference

#include <statistics.h>

+ Collaboration diagram for olb::StatisticsPostProcessor::type< ConcreteBlockLattice< T, DESCRIPTOR, Platform::GPU_CUDA > >:

Public Member Functions

void setup (ConcreteBlockLattice< T, DESCRIPTOR, Platform::GPU_CUDA > &blockLattice)
 
void apply (ConcreteBlockLattice< T, DESCRIPTOR, Platform::GPU_CUDA > &blockLattice)
 

Detailed Description

template<typename T, typename DESCRIPTOR>
struct olb::StatisticsPostProcessor::type< ConcreteBlockLattice< T, DESCRIPTOR, Platform::GPU_CUDA > >

Definition at line 32 of file statistics.h.

Member Function Documentation

◆ apply()

template<typename T , typename DESCRIPTOR >
void olb::StatisticsPostProcessor::type< ConcreteBlockLattice< T, DESCRIPTOR, Platform::GPU_CUDA > >::apply ( ConcreteBlockLattice< T, DESCRIPTOR, Platform::GPU_CUDA > & blockLattice)

Todo: Reimplement these four separate reductions as single kernel

Definition at line 80 of file statistics.hh.

82{
83 if (!blockLattice.statisticsEnabled()) {
84 return;
85 }
86
88 auto& statisticGenerated = blockLattice.template getField<descriptors::STATISTIC_GENERATED>();
89 auto& statistic = blockLattice.template getField<descriptors::STATISTIC>();
90 std::size_t nCells = thrust::reduce(thrust::device,
91 statisticGenerated[0].deviceData(),
92 statisticGenerated[0].deviceData() + blockLattice.getNcells(),
93 T{0},
94 thrust::plus<T>());
95 T rhoSum = thrust::reduce(thrust::device,
96 statistic[0].deviceData(),
97 statistic[0].deviceData() + blockLattice.getNcells(),
98 T{0},
99 thrust::plus<T>());
100 auto [maxU, uSqrSum] = thrust::reduce(thrust::device,
101 statistic[1].deviceData(),
102 statistic[1].deviceData() + blockLattice.getNcells(),
103 gpu::cuda::pair{std::numeric_limits<T>::min(), T{0}},
104 gpu::cuda::maximum_and_plus<T>());
105
106 typename LatticeStatistics<T>::Aggregatable statistics{
107 .nCells = nCells,
108 .avRho = rhoSum,
109 .avEnergy = uSqrSum,
110 .maxU = maxU
111 };
112 blockLattice.getStatistics().incrementStats(statistics);
113
114 blockLattice.getStatistics().reset();
115}

References olb::BlockStructureD< D >::getNcells(), and olb::BlockLattice< T, DESCRIPTOR >::statisticsEnabled().

+ Here is the call graph for this function:

◆ setup()

template<typename T , typename DESCRIPTOR >
void olb::StatisticsPostProcessor::type< ConcreteBlockLattice< T, DESCRIPTOR, Platform::GPU_CUDA > >::setup ( ConcreteBlockLattice< T, DESCRIPTOR, Platform::GPU_CUDA > & blockLattice)
inline

Definition at line 34 of file statistics.h.

35{
36 // Allocate on-device statistic buffer
37 blockLattice.template getField<descriptors::STATISTIC_GENERATED>();
38 blockLattice.template getField<descriptors::STATISTIC>();
39}

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