OpenLB 1.7
Loading...
Searching...
No Matches
Public Member Functions | List of all members
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 33 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}
bool statisticsEnabled() const
LatticeStatistics< T > & getStatistics()
Return a handle to the LatticeStatistics object.
std::size_t getNcells() const
Get number of cells.

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 35 of file statistics.h.

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

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