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

Trapezoidal rule. More...

#include <benchmarkUtil.h>

+ Collaboration diagram for olb::util::TrapezRuleInt1D< T >:

Public Member Functions

 TrapezRuleInt1D (AnalyticalF1D< T, T > &f)
 
integrate (T min, T max, int nSteps)
 

Protected Attributes

AnalyticalF1D< T, T > & _f
 

Detailed Description

template<typename T>
class olb::util::TrapezRuleInt1D< T >

Trapezoidal rule.

Definition at line 141 of file benchmarkUtil.h.

Constructor & Destructor Documentation

◆ TrapezRuleInt1D()

template<typename T >
olb::util::TrapezRuleInt1D< T >::TrapezRuleInt1D ( AnalyticalF1D< T, T > & f)

Definition at line 297 of file benchmarkUtil.hh.

297 : _f(f)
298{
299}
AnalyticalF1D< T, T > & _f

Member Function Documentation

◆ integrate()

template<typename T >
T olb::util::TrapezRuleInt1D< T >::integrate ( T min,
T max,
int nSteps )

Definition at line 302 of file benchmarkUtil.hh.

303{
304 T integral[1], tmp[1], min_[1], max_[1], x[1], deltax[0];
305 min_[0] = min;
306 max_[0] = max;
307 deltax[0] = (max - min) / nSteps;
308 _f(tmp, min);
309 integral[0] = 0.5 * tmp[0];
310 x[0] = min;
311 for (int i = 1; i < nSteps; i++) {
312 x[0] += deltax[0];
313 _f(tmp, x);
314 integral[0] += tmp[0];
315 }
316
317 _f(tmp, max);
318 integral[0] += 0.5*tmp[0];
319 integral[0] *= deltax[0];
320
321 std::cout << "Itnegral=" << integral[0] << std::endl;
322
323 return integral[0];
324}
cpu::simd::Pack< T > min(cpu::simd::Pack< T > rhs, cpu::simd::Pack< T > lhs)
Definition pack.h:124
cpu::simd::Pack< T > max(cpu::simd::Pack< T > rhs, cpu::simd::Pack< T > lhs)
Definition pack.h:130

References olb::util::max(), and olb::util::min().

+ Here is the call graph for this function:

Member Data Documentation

◆ _f

template<typename T >
AnalyticalF1D<T,T>& olb::util::TrapezRuleInt1D< T >::_f
protected

Definition at line 144 of file benchmarkUtil.h.


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