https://mooseframework.inl.gov
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | Private Member Functions | Private Attributes | List of all members
Executor::Result Struct Reference

This object tracks the success/failure state of the executor system as execution proceeds in a simulation. More...

#include <Executor.h>

Public Member Functions

 Result ()
 
 Result (const std::string &name)
 
 Result (const MooseObject *obj)
 
std::string str (bool success_msg=false, const std::string &indent="", const std::string &subname="")
 Prints a full recursive output of this result object - including all descendant's results.
 
void pass (const std::string &msg, bool overwrite=false)
 Marks the result as passing/converged with the given msg text describing detail about how things ran.
 
void fail (const std::string &msg)
 Marks the result as failing/unconverged with the given msg text describing detail about how things ran.
 
bool record (const std::string &name, const Result &r)
 Records results from sub/internal executors in a executor's result.
 
bool convergedAll () const
 Returns false if any single executor in the current hierarchy of results (i.e.
 

Public Attributes

bool converged = true
 whether or not a executor ran its code successfully - only reports results from the executor itself.
 
std::string reason
 Optional message detailing why an executor passed or failed (i.e. failed to converge).
 
std::map< std::string, Resultsubs
 Maps a name/label of a executor's internal/sub executors to the result object returned by running each of those internal/sub executors.
 

Private Member Functions

std::string label (bool success_msg, const std::string &subname="")
 

Private Attributes

std::string _name
 

Detailed Description

This object tracks the success/failure state of the executor system as execution proceeds in a simulation.

Because executors can be composed into trees, result objects are correspondingly composed into trees to track simulation progress. Result objects should generally be created by executors calling the Result::newResult() function rather than by using the Result constructor directly.

Definition at line 35 of file Executor.h.

Constructor & Destructor Documentation

◆ Result() [1/3]

Executor::Result::Result ( )
inline

Definition at line 37 of file Executor.h.

37: converged(true), _name("NO_NAME") {}
std::string _name
Definition Executor.h:126
bool converged
whether or not a executor ran its code successfully - only reports results from the executor itself.
Definition Executor.h:46

◆ Result() [2/3]

Executor::Result::Result ( const std::string &  name)
inline

Definition at line 38 of file Executor.h.

38: converged(true), _name(name) {}
const std::string & name() const
Get the name of the class.
Definition MooseBase.h:103

◆ Result() [3/3]

Executor::Result::Result ( const MooseObject obj)
inline

Definition at line 39 of file Executor.h.

39: converged(true), _name(obj->name()) {}

Member Function Documentation

◆ convergedAll()

bool Executor::Result::convergedAll ( ) const
inline

Returns false if any single executor in the current hierarchy of results (i.e.

including all child results accumulated recursively via record) had a failed/unconverged return state. Returns true otherwise. This is how convergence should generally be checked/tracked by executors - rather than accessing e.g. the converged member directly.

Definition at line 108 of file Executor.h.

109 {
110 if (!converged)
111 return false;
112 for (auto & entry : subs)
113 if (!entry.second.convergedAll())
114 return false;
115 return true;
116 }
if(!dmm->_nl) SETERRQ(PETSC_COMM_WORLD
std::map< std::string, Result > subs
Maps a name/label of a executor's internal/sub executors to the result object returned by running eac...
Definition Executor.h:56
bool convergedAll() const
Returns false if any single executor in the current hierarchy of results (i.e.
Definition Executor.h:108

Referenced by Executor::lastSolveConverged(), and record().

◆ fail()

void Executor::Result::fail ( const std::string &  msg)
inline

Marks the result as failing/unconverged with the given msg text describing detail about how things ran.

Definition at line 86 of file Executor.h.

87 {
88 reason = msg;
89 converged = false;
90 }
std::string reason
Optional message detailing why an executor passed or failed (i.e. failed to converge).
Definition Executor.h:49

◆ label()

std::string Executor::Result::label ( bool  success_msg,
const std::string &  subname = "" 
)
inlineprivate

Definition at line 119 of file Executor.h.

120 {
121 std::string state_str =
122 success_msg || !converged ? (std::string("(") + (converged ? "pass" : "FAIL") + ")") : "";
123 return subname + (subname.empty() ? "" : ":") + _name + state_str +
124 ((success_msg || !converged) && !reason.empty() ? ": " + reason : "");
125 }

Referenced by str().

◆ pass()

void Executor::Result::pass ( const std::string &  msg,
bool  overwrite = false 
)
inline

Marks the result as passing/converged with the given msg text describing detail about how things ran.

A result object is in this state by default, so it is not necessary to call this function for converged/passing scenarios.

Definition at line 75 of file Executor.h.

76 {
77 mooseAssert(converged || overwrite,
78 "cannot override nonconverged executioner result with a passing one");
79 ((void)(overwrite)); // avoid unused error due to assert
80 reason = msg;
81 converged = true;
82 }

◆ record()

bool Executor::Result::record ( const std::string &  name,
const Result r 
)
inline

Records results from sub/internal executors in a executor's result.

When child-executors return a result object following their execution, this function should be called to add that info into the result hierarchy. If the child executor was identified by a label/text from the input file (e.g. via sub_solve1=foo_executor) - then "name" should be "sub_solve1".

Definition at line 97 of file Executor.h.

98 {
99 subs[name] = r;
100 return r.convergedAll();
101 }

◆ str()

std::string Executor::Result::str ( bool  success_msg = false,
const std::string &  indent = "",
const std::string &  subname = "" 
)
inline

Prints a full recursive output of this result object - including all descendant's results.

If success_msg is true, then all result output that contains a message will be printed even if it converged/passed. Otherwise, messages will only be printed for unconverged/failed results.

Definition at line 63 of file Executor.h.

64 {
65 std::string s = indent + label(success_msg, subname) + "\n";
66 for (auto & entry : subs)
67 s += entry.second.str(success_msg, indent + " ", entry.first);
68 return s;
69 }
std::string indent(unsigned int spaces)
Create empty string for indenting.
std::string str(bool success_msg=false, const std::string &indent="", const std::string &subname="")
Prints a full recursive output of this result object - including all descendant's results.
Definition Executor.h:63
std::string label(bool success_msg, const std::string &subname="")
Definition Executor.h:119

Member Data Documentation

◆ _name

std::string Executor::Result::_name
private

Definition at line 126 of file Executor.h.

Referenced by label().

◆ converged

bool Executor::Result::converged = true

whether or not a executor ran its code successfully - only reports results from the executor itself.

If a sub/internal executor of a executor fails, that sub-executor's result object will have converged=false, while the parent may still have converged=truee. Users should use convergedAll to recursively determine if there was any descendant executor failure.

Definition at line 46 of file Executor.h.

Referenced by convergedAll(), fail(), label(), and pass().

◆ reason

std::string Executor::Result::reason

Optional message detailing why an executor passed or failed (i.e. failed to converge).

Definition at line 49 of file Executor.h.

Referenced by fail(), label(), and pass().

◆ subs

std::map<std::string, Result> Executor::Result::subs

Maps a name/label of a executor's internal/sub executors to the result object returned by running each of those internal/sub executors.

This member should generally not be accessed directly. It should generally be populated through the record function. Info contained in these results will be included in printouts from the str function.

Definition at line 56 of file Executor.h.

Referenced by convergedAll(), record(), and str().


The documentation for this struct was generated from the following file: