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

1D Newton simple scheme More...

#include <benchmarkUtil.h>

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

Public Member Functions

 Newton1D (AnalyticalF1D< T, T > &f, T yValue=T(), T eps=1.e-8, int maxIterations=100)
 
solve (T startValue, bool print=false)
 

Protected Attributes

AnalyticalF1D< T, T > & _f
 
AnalyticalDerivativeFD1D< T > _df
 
_yValue
 
_eps
 
int _maxIterations
 

Detailed Description

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

1D Newton simple scheme

Definition at line 124 of file benchmarkUtil.h.

Constructor & Destructor Documentation

◆ Newton1D()

template<typename T >
olb::util::Newton1D< T >::Newton1D ( AnalyticalF1D< T, T > & f,
T yValue = T(),
T eps = 1.e-8,
int maxIterations = 100 )

Definition at line 273 of file benchmarkUtil.hh.

273 : _f(f), _df(f,eps), _yValue(yValue), _eps(eps), _maxIterations(maxIterations)
274{
275}
AnalyticalF1D< T, T > & _f
AnalyticalDerivativeFD1D< T > _df

Member Function Documentation

◆ solve()

template<typename T >
T olb::util::Newton1D< T >::solve ( T startValue,
bool print = false )

Definition at line 278 of file benchmarkUtil.hh.

279{
280 T fValue[1], dfValue[1], x[1];
281 x[0] = startValue;
282 _f(fValue,x);
283 T eps = util::fabs(fValue[0] - _yValue);
284 for (int i=0; i<_maxIterations && eps>_eps; i++) {
285 _f(fValue,x);
286 _df(dfValue,x);
287 eps = util::fabs(fValue[0] - _yValue);
288 if (print) {
289 std::cout << "newtonStep=" << i << "; eps=" << eps << "; x=" << x[0] << "; f(x)="<< fValue[0] << "; df(x)="<< dfValue[0] << std::endl;
290 }
291 x[0] -= (fValue[0] - _yValue)/dfValue[0];
292 }
293 return x[0];
294}
cpu::simd::Pack< T > fabs(cpu::simd::Pack< T > value)
Definition pack.h:106
void print(U data, const std::string &name="", OstreamManager clout=OstreamManager(std::cout,"print"), const char delimiter=',')

References olb::util::fabs(), and olb::util::print().

+ Here is the call graph for this function:

Member Data Documentation

◆ _df

template<typename T >
AnalyticalDerivativeFD1D<T> olb::util::Newton1D< T >::_df
protected

Definition at line 128 of file benchmarkUtil.h.

◆ _eps

template<typename T >
T olb::util::Newton1D< T >::_eps
protected

Definition at line 130 of file benchmarkUtil.h.

◆ _f

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

Definition at line 127 of file benchmarkUtil.h.

◆ _maxIterations

template<typename T >
int olb::util::Newton1D< T >::_maxIterations
protected

Definition at line 131 of file benchmarkUtil.h.

◆ _yValue

template<typename T >
T olb::util::Newton1D< T >::_yValue
protected

Definition at line 129 of file benchmarkUtil.h.


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