loopControl Class Reference

A class for managing arbitrary loops with the ability to invoke function object execution. More...

Inheritance diagram for loopControl:
[legend]
Collaboration diagram for loopControl:
[legend]

Public Member Functions

 loopControl (Time &runTime, const label nCycles, const word &dictName="loop")
 Construct from time with fixed number of cycles. More...
 
 loopControl (Time &runTime, const word &algorithmName, const word &dictName="loop")
 
 loopControl (Time &runTime, const dictionary &algorithmDict, const word &dictName="loop")
 
 ~loopControl ()
 Destructor. More...
 
const wordname () const
 Name of the loop control. More...
 
label interval () const
 The interval to execute onLoop function-objects. More...
 
bool loop ()
 
- Public Member Functions inherited from subLoopTime
 subLoopTime (Time &runTime, const label nCycles)
 Construct from time with fixed number of cycles. More...
 
 ~subLoopTime ()
 Destructor. More...
 
label index () const
 The current cycle index. More...
 
label nCycles () const
 The total number of cycles. More...
 
bool status () const
 Return true if looping is active. More...
 
void stop ()
 Force terminate the loop. More...
 
bool loop ()
 True if looping is active, increments the index. More...
 
subLoopTimeoperator++ ()
 Prefix increment. More...
 

Protected Attributes

word name_
 Name of the loop control (the lookup dictionary name). More...
 
label interval_
 The interval to execute onLoop function-objects. More...
 
dictionary convergenceDict_
 Dictionary for checking convergence (all regions) More...
 
wordRes onLoop_
 Function object names to fire during the loop (at executeInterval) More...
 
wordRes onConverged_
 Function object names to fire on convergence. More...
 
wordRes onEnd_
 
bool converged_
 Convergence tests passed. More...
 
- Protected Attributes inherited from subLoopTime
Timetime_
 
label index_
 The current sub-cycle index. More...
 
label total_
 The total number of cycles in the sub-cycle. More...
 

Detailed Description

A class for managing arbitrary loops with the ability to invoke function object execution.

Usage
Examples of function object specification:
SIMPLE
{
    energyCoupling
    {
        iterations  100;
        onLoop      ();
        onConverged ( externalCoupled  "loopThings.*" );

        convergence
        {
            "h"     1e-3;
        }
    }
}

Where the loop entries comprise:

Property Description Required Default
enabled activate/deactivate loop no true
iteration times to loop no 0
timeStart begin time for loop activation no -VGREAT
timeEnd end time of loop activation no VGREAT
interval sub-interval to execute onLoop no 0
onLoop function object names to call at executeInterval no
onConverged function object names to call when converged no
onEnd function object names to call when loop ends no
convergence dictionary of convergence values to check no

The function object names listed by onLoop, onConverged, onEnd must implement an execute(int) method. If the time controls timeStart or timeEnd are used for the loop, these values are only inspected upon creation, not during execution.

See also
fvSolution
Source files

Definition at line 140 of file loopControl.H.

Constructor & Destructor Documentation

◆ loopControl() [1/3]

loopControl ( Time runTime,
const label  nCycles,
const word dictName = "loop" 
)

Construct from time with fixed number of cycles.

Parameters
runTimethe top-level time
nCyclesthe number of times to loop
loopNamethe name of the loop

Definition at line 144 of file loopControl.C.

◆ loopControl() [2/3]

loopControl ( Time runTime,
const word algorithmName,
const word dictName = "loop" 
)

Construct from fvSolution dictionary based on time and the name of the controlling algorithm

Parameters
runTimethe top-level time
algorithmNamethe name of the fvSolution dictionary, typically PIMPLE or SIMPLE
dictNamethe name of the control dictionary

Definition at line 182 of file loopControl.C.

References dictName(), dictionary::findDict(), solution::solutionDict(), and subLoopTime::time_.

Here is the call graph for this function:

◆ loopControl() [3/3]

loopControl ( Time runTime,
const dictionary algorithmDict,
const word dictName = "loop" 
)

Construct from fvSolution dictionary based on time and the name of the controlling algorithm

Parameters
runTimethe top-level time
algorithmDictthe fvSolution algorithm dictionary, typically PIMPLE or SIMPLE
dictNamethe name of the control dictionary

Definition at line 162 of file loopControl.C.

References dictName(), and dictionary::findDict().

Here is the call graph for this function:

◆ ~loopControl()

Destructor.

Definition at line 212 of file loopControl.C.

Member Function Documentation

◆ name()

const word & name ( ) const
inline

Name of the loop control.

Definition at line 237 of file loopControl.H.

References loopControl::name_.

Referenced by Foam::operator<<().

Here is the caller graph for this function:

◆ interval()

label interval ( ) const
inline

The interval to execute onLoop function-objects.

Definition at line 243 of file loopControl.H.

References loopControl::interval_.

◆ loop()

bool loop ( )

True if looping is active, increments the index and executes the onLoop and onConverged functions.

Example usage,

while (control.loop())
{
}
CEqn solve()

Definition at line 220 of file loopControl.C.

Member Data Documentation

◆ name_

word name_
protected

Name of the loop control (the lookup dictionary name).

Definition at line 167 of file loopControl.H.

Referenced by loopControl::name().

◆ interval_

label interval_
protected

The interval to execute onLoop function-objects.

Definition at line 170 of file loopControl.H.

Referenced by loopControl::interval().

◆ convergenceDict_

dictionary convergenceDict_
protected

Dictionary for checking convergence (all regions)

Definition at line 173 of file loopControl.H.

◆ onLoop_

wordRes onLoop_
protected

Function object names to fire during the loop (at executeInterval)

Definition at line 176 of file loopControl.H.

◆ onConverged_

wordRes onConverged_
protected

Function object names to fire on convergence.

Definition at line 179 of file loopControl.H.

◆ onEnd_

wordRes onEnd_
protected

Function object names to fire when the loop exits without convergence

Definition at line 183 of file loopControl.H.

◆ converged_

bool converged_
protected

Convergence tests passed.

Definition at line 186 of file loopControl.H.


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