www.mooseframework.org
Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | List of all members
NaNInterface Class Reference

Interface class for producing errors, warnings, or just quiet NaNs. More...

#include <NaNInterface.h>

Inheritance diagram for NaNInterface:
[legend]

Public Member Functions

 NaNInterface (const MooseObject *moose_object)
 

Protected Types

enum  NaNMessage { NAN_MESSAGE_NONE = 0, NAN_MESSAGE_WARNING = 1, NAN_MESSAGE_ERROR = 2 }
 

Protected Member Functions

Real getNaN () const
 Produces errors, warnings, or just quiet NaNs. More...
 
template<typename... Args>
Real getNaN (Args &&... args) const
 

Protected Attributes

const MooseObject * _moose_object
 
enum NaNMessage _emit_on_nan
 Raise mooseWarning or mooseError? More...
 

Detailed Description

Interface class for producing errors, warnings, or just quiet NaNs.

For some objects it is desirable to continue running despite generation of NaN(s). This class provides an interface for choosing whether to throw an error, a warning, or nothing at all, just using a quiet NaN.

Definition at line 28 of file NaNInterface.h.

Member Enumeration Documentation

◆ NaNMessage

enum NaNInterface::NaNMessage
protected
Enumerator
NAN_MESSAGE_NONE 
NAN_MESSAGE_WARNING 
NAN_MESSAGE_ERROR 

Definition at line 34 of file NaNInterface.h.

Constructor & Destructor Documentation

◆ NaNInterface()

NaNInterface::NaNInterface ( const MooseObject *  moose_object)

Definition at line 33 of file NaNInterface.C.

34  : _emit_on_nan(
35  moose_object->getParam<MooseEnum>("emit_on_nan").getEnum<NaNInterface::NaNMessage>())
36 {
37  _moose_object = moose_object;
38 }
const MooseObject * _moose_object
Definition: NaNInterface.h:41
enum NaNMessage _emit_on_nan
Raise mooseWarning or mooseError?
Definition: NaNInterface.h:44

Member Function Documentation

◆ getNaN() [1/2]

Real NaNInterface::getNaN ( ) const
inlineprotected

Produces errors, warnings, or just quiet NaNs.

Definition at line 49 of file NaNInterface.h.

Referenced by getNaN(), NaNInterfaceTestFluidProperties::p_from_v_e(), IdealRealGasMixtureFluidProperties::v_from_p_T(), and IdealRealGasMixtureFluidProperties::xs_prim_from_p_T().

49 { return getNaN("A NaN was produced."); }
Real getNaN() const
Produces errors, warnings, or just quiet NaNs.
Definition: NaNInterface.h:49

◆ getNaN() [2/2]

template<typename... Args>
Real NaNInterface::getNaN ( Args &&...  args) const
inlineprotected

Definition at line 52 of file NaNInterface.h.

53  {
54  switch (_emit_on_nan)
55  {
56  case (NAN_MESSAGE_WARNING):
57  mooseWarning(_moose_object->name(), ": ", std::forward<Args>(args)...);
58  break;
59  case (NAN_MESSAGE_ERROR):
60  mooseError(_moose_object->name(), ": ", std::forward<Args>(args)...);
61  break;
62  default:
63  break;
64  }
65  // return a quiet NaN
66  return std::nan("");
67  }
const MooseObject * _moose_object
Definition: NaNInterface.h:41
enum NaNMessage _emit_on_nan
Raise mooseWarning or mooseError?
Definition: NaNInterface.h:44

Member Data Documentation

◆ _emit_on_nan

enum NaNMessage NaNInterface::_emit_on_nan
protected

Raise mooseWarning or mooseError?

Definition at line 44 of file NaNInterface.h.

Referenced by getNaN().

◆ _moose_object

const MooseObject* NaNInterface::_moose_object
protected

Definition at line 41 of file NaNInterface.h.

Referenced by getNaN(), and NaNInterface().


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