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

Propose successive test values of a scalar (e.g. Re) to check stability of a system. More...

#include <benchmarkUtil.h>

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

Public Member Functions

 BisectStepper (T _iniVal, T _step=0.)
 The only constructor.
 
getVal (bool stable, bool doPrint=false)
 Get new value, and indicate if the previous value yielded a stable system or not.
 
bool hasConverged (T epsilon) const
 Test for convergence.
 

Detailed Description

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

Propose successive test values of a scalar (e.g. Re) to check stability of a system.

At first, the stability limit is explored by constant increments/decrements of the scalar, and then, by successive bisection.

Definition at line 103 of file benchmarkUtil.h.

Constructor & Destructor Documentation

◆ BisectStepper()

template<typename T >
olb::util::BisectStepper< T >::BisectStepper ( T _iniVal,
T _step = 0. )

The only constructor.

Parameters
_iniValInitial guess for the stability limit.
_stepStep size at which the value is initially incremented/decremented.

Definition at line 195 of file benchmarkUtil.hh.

196 : iniVal(_iniVal), step(_step), state(first), clout(std::cout,"BisectStepper")
197{
198 if (util::nearZero(step)) {
199 step = iniVal/5.;
200 }
201 assert(step>0.);
202}
bool nearZero(const ADf< T, DIM > &a)
Definition aDiff.h:1087

References olb::util::nearZero().

+ Here is the call graph for this function:

Member Function Documentation

◆ getVal()

template<typename T >
T olb::util::BisectStepper< T >::getVal ( bool stable,
bool doPrint = false )

Get new value, and indicate if the previous value yielded a stable system or not.

Definition at line 205 of file benchmarkUtil.hh.

206{
207 std::stringstream message;
208 switch (state) {
209 case first:
210 if (stable) {
211 currentVal = iniVal+step;
212 state = up;
213 message << "[" << iniVal << ",infty]";
214 }
215 else {
216 currentVal = iniVal-step;
217 state = down;
218 message << "[-infty," << iniVal << "]";
219 }
220 break;
221 case up:
222 if (stable) {
223 message << "[" << currentVal << ",infty]";
224 currentVal += step;
225 }
226 else {
227 lowerVal = currentVal-step;
228 upperVal = currentVal;
229 currentVal = 0.5*(lowerVal+upperVal);
230 state = bisect;
231 message << "[" << lowerVal << "," << upperVal << "]";
232 }
233 break;
234 case down:
235 if (!stable) {
236 message << "[-infty," << currentVal << "]";
237 currentVal -= step;
238 }
239 else {
240 lowerVal = currentVal;
241 upperVal = currentVal+step;
242 currentVal = 0.5*(lowerVal+upperVal);
243 state = bisect;
244 message << "[" << lowerVal << "," << upperVal << "]";
245 }
246 break;
247 case bisect:
248 if (stable) {
249 lowerVal = currentVal;
250 }
251 else {
252 upperVal = currentVal;
253 }
254 currentVal = 0.5*(lowerVal+upperVal);
255 message << "[" << lowerVal << "," << upperVal << "]";
256 break;
257 }
258 if (doPrint) {
259 clout << "Value in range " << message.str() << std::endl;
260 }
261 return currentVal;
262}

◆ hasConverged()

template<typename T >
bool olb::util::BisectStepper< T >::hasConverged ( T epsilon) const

Test for convergence.

Definition at line 265 of file benchmarkUtil.hh.

266{
267 return (state==bisect) && ((upperVal-lowerVal)/lowerVal < epsilon);
268}

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