OpenLB 1.7
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | Public Attributes | List of all members
olb::LatticeStatistics< T > Class Template Reference

#include <latticeStatistics.h>

+ Inheritance diagram for olb::LatticeStatistics< T >:
+ Collaboration diagram for olb::LatticeStatistics< T >:

Classes

struct  Aggregatable
 

Public Types

enum  { avRho =0 , avEnergy =1 }
 
enum  { maxU =0 }
 

Public Member Functions

 LatticeStatistics ()
 
 ~LatticeStatistics ()=default
 
void reset ()
 
void reset (T average_rho_, T average_energy_, T maxU_, size_t numCells_)
 
int subscribeAverage ()
 
int subscribeSum ()
 
int subscribeMin ()
 
int subscribeMax ()
 
void incrementStats (T rho, T uSqr)
 
void incrementStats (Aggregatable &aggregatable)
 
void gatherAverage (int whichAverage, T value)
 
void gatherSum (int whichSum, T value)
 
void gatherMin (int whichMin, T value)
 
void gatherMax (int whichMax, T value)
 
void incrementStats ()
 
getAverageRho () const
 
getAverageEnergy () const
 
getMaxU () const
 
size_t const & getNumCells () const
 
getAverage (int whichAverage) const
 
getSum (int whichSum) const
 
getMin (int whichMin) const
 
getMax (int whichMax) const
 
std::vector< T > & getAverageVect ()
 
std::vector< T > & getSumVect ()
 
std::vector< T > & getMinVect ()
 
std::vector< T > & getMaxVect ()
 
void incrementTime ()
 
void resetTime (size_t value=0)
 
size_t getTime () const
 
void print (int iterationStep, T physicalTime=-1) const
 
void initialize ()
 

Public Attributes

enum olb::LatticeStatistics:: { ... }  AverageT
 
enum olb::LatticeStatistics:: { ... }  MaxT
 

Detailed Description

template<typename T>
class olb::LatticeStatistics< T >

Definition at line 44 of file latticeStatistics.h.

Member Enumeration Documentation

◆ anonymous enum

template<typename T >
anonymous enum
Enumerator
avRho 
avEnergy 

Definition at line 46 of file latticeStatistics.h.

◆ anonymous enum

template<typename T >
anonymous enum
Enumerator
maxU 

Definition at line 47 of file latticeStatistics.h.

47{ maxU=0 } MaxT;
enum olb::LatticeStatistics::@1 MaxT

Constructor & Destructor Documentation

◆ LatticeStatistics()

template<typename T >
olb::LatticeStatistics< T >::LatticeStatistics ( )

Definition at line 38 of file latticeStatistics.hh.

38 : clout(std::cout,"LatticeStatistics")
39{
40 initialize();
41}

References olb::LatticeStatistics< T >::initialize().

+ Here is the call graph for this function:

◆ ~LatticeStatistics()

template<typename T >
olb::LatticeStatistics< T >::~LatticeStatistics ( )
default

Member Function Documentation

◆ gatherAverage()

template<typename T >
void olb::LatticeStatistics< T >::gatherAverage ( int whichAverage,
T value )

Definition at line 203 of file latticeStatistics.hh.

204{
205 OLB_PRECONDITION( whichAverage < (int) tmpAv.size() );
206 tmpAv[whichAverage] += value;
207}
typename std::integral_constant< TYPE, VALUE >::type value
Identity type to wrap non-type template arguments.
Definition meta.h:96
#define OLB_PRECONDITION(COND)
Definition olbDebug.h:46

References OLB_PRECONDITION.

◆ gatherMax()

template<typename T >
void olb::LatticeStatistics< T >::gatherMax ( int whichMax,
T value )

Definition at line 226 of file latticeStatistics.hh.

227{
228 OLB_PRECONDITION( whichMax < (int) tmpMax.size() );
229 if (value > tmpMax[whichMax]) {
230 tmpMax[whichMax] = value;
231 }
232}

References OLB_PRECONDITION.

◆ gatherMin()

template<typename T >
void olb::LatticeStatistics< T >::gatherMin ( int whichMin,
T value )

Definition at line 217 of file latticeStatistics.hh.

218{
219 OLB_PRECONDITION( whichMin < (int) tmpMin.size() );
220 if (value < tmpMin[whichMin]) {
221 tmpMin[whichMin] = value;
222 }
223}

References OLB_PRECONDITION.

◆ gatherSum()

template<typename T >
void olb::LatticeStatistics< T >::gatherSum ( int whichSum,
T value )

Definition at line 210 of file latticeStatistics.hh.

211{
212 OLB_PRECONDITION( whichSum < (int) tmpSum.size() );
213 tmpSum[whichSum] += value;
214}

References OLB_PRECONDITION.

◆ getAverage()

template<typename T >
T olb::LatticeStatistics< T >::getAverage ( int whichAverage) const

Definition at line 265 of file latticeStatistics.hh.

266{
267 OLB_PRECONDITION( whichAverage < (int) tmpAv.size() );
268 return averageVect[whichAverage];
269}

References OLB_PRECONDITION.

◆ getAverageEnergy()

template<typename T >
T olb::LatticeStatistics< T >::getAverageEnergy ( ) const

Definition at line 247 of file latticeStatistics.hh.

248{
249 return averageVect[avEnergy];
250}

◆ getAverageRho()

template<typename T >
T olb::LatticeStatistics< T >::getAverageRho ( ) const

Definition at line 241 of file latticeStatistics.hh.

242{
243 return averageVect[avRho];
244}

◆ getAverageVect()

template<typename T >
std::vector< T > & olb::LatticeStatistics< T >::getAverageVect ( )

Definition at line 293 of file latticeStatistics.hh.

294{
295 return averageVect;
296}

◆ getMax()

template<typename T >
T olb::LatticeStatistics< T >::getMax ( int whichMax) const

Definition at line 286 of file latticeStatistics.hh.

287{
288 OLB_PRECONDITION( whichMax < (int) tmpMax.size() );
289 return maxVect[whichMax];
290}

References OLB_PRECONDITION.

◆ getMaxU()

template<typename T >
T olb::LatticeStatistics< T >::getMaxU ( ) const

Definition at line 253 of file latticeStatistics.hh.

254{
255 return maxVect[maxU];
256}

◆ getMaxVect()

template<typename T >
std::vector< T > & olb::LatticeStatistics< T >::getMaxVect ( )

Definition at line 311 of file latticeStatistics.hh.

312{
313 return maxVect;
314}

◆ getMin()

template<typename T >
T olb::LatticeStatistics< T >::getMin ( int whichMin) const

Definition at line 279 of file latticeStatistics.hh.

280{
281 OLB_PRECONDITION( whichMin < (int) tmpMin.size() );
282 return minVect[whichMin];
283}

References OLB_PRECONDITION.

◆ getMinVect()

template<typename T >
std::vector< T > & olb::LatticeStatistics< T >::getMinVect ( )

Definition at line 305 of file latticeStatistics.hh.

306{
307 return minVect;
308}

◆ getNumCells()

template<typename T >
size_t const & olb::LatticeStatistics< T >::getNumCells ( ) const

Definition at line 259 of file latticeStatistics.hh.

260{
261 return numCells;
262}

◆ getSum()

template<typename T >
T olb::LatticeStatistics< T >::getSum ( int whichSum) const

Definition at line 272 of file latticeStatistics.hh.

273{
274 OLB_PRECONDITION( whichSum < (int) tmpSum.size() );
275 return sumVect[whichSum];
276}

References OLB_PRECONDITION.

◆ getSumVect()

template<typename T >
std::vector< T > & olb::LatticeStatistics< T >::getSumVect ( )

Definition at line 299 of file latticeStatistics.hh.

300{
301 return sumVect;
302}

◆ getTime()

template<typename T >
size_t olb::LatticeStatistics< T >::getTime ( ) const

Definition at line 329 of file latticeStatistics.hh.

330{
331 return latticeTime;
332}

◆ incrementStats() [1/3]

template<typename T >
void olb::LatticeStatistics< T >::incrementStats ( )

Definition at line 235 of file latticeStatistics.hh.

236{
237 ++tmpNumCells;
238}

◆ incrementStats() [2/3]

template<typename T >
void olb::LatticeStatistics< T >::incrementStats ( Aggregatable & aggregatable)

Definition at line 194 of file latticeStatistics.hh.

195{
196 tmpNumCells += aggregatable.nCells;
197 tmpAv[avRho] += aggregatable.avRho;
198 tmpAv[avEnergy] += aggregatable.avEnergy;
199 tmpMax[maxU] = std::max(aggregatable.maxU, tmpMax[maxU]);
200}

References olb::LatticeStatistics< T >::Aggregatable::avEnergy, olb::LatticeStatistics< T >::Aggregatable::avRho, olb::LatticeStatistics< T >::Aggregatable::maxU, and olb::LatticeStatistics< T >::Aggregatable::nCells.

◆ incrementStats() [3/3]

template<typename T >
void olb::LatticeStatistics< T >::incrementStats ( T rho,
T uSqr )

Definition at line 183 of file latticeStatistics.hh.

184{
185 tmpAv[avRho] += rho;
186 tmpAv[avEnergy] += uSqr;
187 if (uSqr > tmpMax[maxU]) {
188 tmpMax[maxU] = uSqr;
189 }
190 ++tmpNumCells;
191}
+ Here is the caller graph for this function:

◆ incrementTime()

template<typename T >
void olb::LatticeStatistics< T >::incrementTime ( )

Definition at line 317 of file latticeStatistics.hh.

318{
319 ++latticeTime;
320}

◆ initialize()

template<typename T >
void olb::LatticeStatistics< T >::initialize ( )

Definition at line 125 of file latticeStatistics.hh.

126{
127 tmpAv.resize(2);
128 averageVect.resize(2);
129 tmpMax.resize(1);
130 maxVect.resize(1);
131
132 tmpAv[avRho] = T();
133 tmpAv[avEnergy] = T();
134 tmpMax[maxU] = T();
135 tmpNumCells = 0;
136
137 averageVect[avRho] = (T)1;
138 averageVect[avEnergy] = T();
139 maxVect[maxU] = T();
140
141 firstCall = true;
142
143 resetTime();
144}
void resetTime(size_t value=0)
+ Here is the caller graph for this function:

◆ print()

template<typename T >
void olb::LatticeStatistics< T >::print ( int iterationStep,
T physicalTime = -1 ) const

Definition at line 335 of file latticeStatistics.hh.

336{
337 clout
338 << "step=" << iterationStep << "; "
339 << "t=" << physicalTime << "; "
340 << "uMax=" << getMaxU() << "; "
341 << "avEnergy=" << getAverageEnergy() << "; "
342 << "avRho=" << getAverageRho()
343 << std::endl;
344}

◆ reset() [1/2]

template<typename T >
void olb::LatticeStatistics< T >::reset ( )

Definition at line 44 of file latticeStatistics.hh.

45{
46 // avoid division by zero
47 if (tmpNumCells == 0) {
48 for (unsigned iVect=0; iVect<averageVect.size(); ++iVect) {
49 averageVect[iVect] = T();
50 }
51 for (unsigned iVect=0; iVect<sumVect.size(); ++iVect) {
52 sumVect[iVect] = T();
53 }
54 for (unsigned iVect=0; iVect<minVect.size(); ++iVect) {
55 minVect[iVect] = T();
56 }
57 for (unsigned iVect=0; iVect<maxVect.size(); ++iVect) {
58 maxVect[iVect] = T();
59 }
60 numCells = 0;
61 firstCall = false;
62 }
63 else {
64 // The average density is actually used in the "ConstRhoBgk" model.
65 // Depending on the simulation setup, it is possible that it has
66 // a nonsensical value before the simulation is started. For this
67 // and similar cases, averages are initialized to 1.
68 if (firstCall) {
69 for (unsigned iVect=0; iVect<averageVect.size(); ++iVect) {
70 averageVect[iVect] = (T)1;
71 }
72 firstCall = false;
73 }
74 else {
75 for (unsigned iVect=0; iVect<averageVect.size(); ++iVect) {
76 averageVect[iVect] = tmpAv[iVect] / (T)tmpNumCells;
77 }
78 }
79 for (unsigned iVect=0; iVect<sumVect.size(); ++iVect) {
80 sumVect[iVect] = tmpSum[iVect];
81 }
82 for (unsigned iVect=0; iVect<minVect.size(); ++iVect) {
83 minVect[iVect] = tmpMin[iVect];
84 }
85 for (unsigned iVect=0; iVect<maxVect.size(); ++iVect) {
86 maxVect[iVect] = tmpMax[iVect];
87 }
88 averageVect[avEnergy] *= (T)0.5; // energy is 0.5 *uSqr
89 maxVect[maxU] = util::sqrt(maxVect[maxU]); // u is util::sqrt(uSqr)
90 numCells = tmpNumCells;
91 }
92
93 for (unsigned iVect=0; iVect<averageVect.size(); ++iVect) {
94 tmpAv[iVect] = T();
95 }
96 for (unsigned iVect=0; iVect<sumVect.size(); ++iVect) {
97 tmpSum[iVect] = T();
98 }
99 for (unsigned iVect=0; iVect<minVect.size(); ++iVect) {
100 tmpMin[iVect] = std::numeric_limits<T>::max();
101 }
102 for (unsigned iVect=0; iVect<maxVect.size(); ++iVect) {
103 tmpMax[iVect] = std::numeric_limits<T>::min();
104 }
105
106 tmpNumCells = 0;
107}
cpu::simd::Pack< T > sqrt(cpu::simd::Pack< T > value)
Definition pack.h:100
+ Here is the caller graph for this function:

◆ reset() [2/2]

template<typename T >
void olb::LatticeStatistics< T >::reset ( T average_rho_,
T average_energy_,
T maxU_,
size_t numCells_ )

Definition at line 110 of file latticeStatistics.hh.

112{
113 averageVect[avRho] = average_rho_;
114 averageVect[avEnergy] = average_energy_;
115 maxVect[maxU] = maxU_;
116 numCells = numCells_;
117
118 tmpAv[avRho] = T();
119 tmpAv[avEnergy] = T();
120 tmpMax[maxU] = T();
121 tmpNumCells = 0;
122}

◆ resetTime()

template<typename T >
void olb::LatticeStatistics< T >::resetTime ( size_t value = 0)

Definition at line 323 of file latticeStatistics.hh.

324{
325 latticeTime=value;
326}

◆ subscribeAverage()

template<typename T >
int olb::LatticeStatistics< T >::subscribeAverage ( )

Definition at line 147 of file latticeStatistics.hh.

148{
149 int newSize = tmpAv.size()+1;
150 tmpAv.resize(newSize);
151 averageVect.resize(newSize);
152 return newSize-1;
153}

◆ subscribeMax()

template<typename T >
int olb::LatticeStatistics< T >::subscribeMax ( )

Definition at line 174 of file latticeStatistics.hh.

175{
176 int newSize = tmpMax.size()+1;
177 tmpMax.resize(newSize);
178 maxVect.resize(newSize);
179 return newSize-1;
180}

◆ subscribeMin()

template<typename T >
int olb::LatticeStatistics< T >::subscribeMin ( )

Definition at line 165 of file latticeStatistics.hh.

166{
167 int newSize = tmpMin.size()+1;
168 tmpMin.resize(newSize);
169 minVect.resize(newSize);
170 return newSize-1;
171}

◆ subscribeSum()

template<typename T >
int olb::LatticeStatistics< T >::subscribeSum ( )

Definition at line 156 of file latticeStatistics.hh.

157{
158 int newSize = tmpSum.size()+1;
159 tmpSum.resize(newSize);
160 sumVect.resize(newSize);
161 return newSize-1;
162}

Member Data Documentation

◆ []

enum { ... } olb::LatticeStatistics< T >::AverageT

◆ []

enum { ... } olb::LatticeStatistics< T >::MaxT

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