www.mooseframework.org
NaNInterface.h
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
3 //*
4 //* All rights reserved, see COPYRIGHT for full restrictions
5 //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6 //*
7 //* Licensed under LGPL 2.1, please see LICENSE for details
8 //* https://www.gnu.org/licenses/lgpl-2.1.html
9 
10 #pragma once
11 
12 #include "InputParameters.h"
13 #include "MooseObject.h"
14 
15 class NaNInterface;
16 
17 template <>
18 InputParameters validParams<NaNInterface>();
19 
28 {
29 public:
30  NaNInterface(const MooseObject * moose_object);
31 
32 protected:
34  {
38  };
39 
40  const MooseObject * _moose_object;
41 
44 
48  Real getNaN() const { return getNaN("A NaN was produced."); }
49 
50  template <typename... Args>
51  Real getNaN(Args &&... args) const
52  {
53  switch (_emit_on_nan)
54  {
55  case (NAN_MESSAGE_WARNING):
56  mooseWarning(_moose_object->name(), ": ", std::forward<Args>(args)...);
57  break;
58  case (NAN_MESSAGE_ERROR):
59  mooseError(_moose_object->name(), ": ", std::forward<Args>(args)...);
60  break;
61  default:
62  break;
63  }
64  // return a quiet NaN
65  return std::nan("");
66  }
67 };
68 
NaNInterface::_moose_object
const MooseObject * _moose_object
Definition: NaNInterface.h:40
NaNInterface::_emit_on_nan
enum NaNMessage _emit_on_nan
Raise mooseWarning or mooseError?
Definition: NaNInterface.h:43
NaNInterface::NAN_MESSAGE_ERROR
Definition: NaNInterface.h:37
NaNInterface::NaNMessage
NaNMessage
Definition: NaNInterface.h:33
NaNInterface::NAN_MESSAGE_NONE
Definition: NaNInterface.h:35
NaNInterface::NAN_MESSAGE_WARNING
Definition: NaNInterface.h:36
NaNInterface::getNaN
Real getNaN(Args &&... args) const
Definition: NaNInterface.h:51
NaNInterface::getNaN
Real getNaN() const
Produces errors, warnings, or just quiet NaNs.
Definition: NaNInterface.h:48
NaNInterface
Interface class for producing errors, warnings, or just quiet NaNs.
Definition: NaNInterface.h:27
validParams< NaNInterface >
InputParameters validParams< NaNInterface >()
Definition: NaNInterface.C:16
NaNInterface::NaNInterface
NaNInterface(const MooseObject *moose_object)
Definition: NaNInterface.C:33