Skip to content

Commit

Permalink
Added vector version of NaNInterface::getNaN
Browse files Browse the repository at this point in the history
Refs #12234
  • Loading branch information
joshuahansel committed Apr 23, 2020
1 parent 82245fb commit 64b8d3f
Showing 1 changed file with 37 additions and 1 deletion.
38 changes: 37 additions & 1 deletion modules/fluid_properties/include/interfaces/NaNInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,23 @@ class NaNInterface
const enum NaNMessage _emit_on_nan;

/**
* Produces errors, warnings, or just quiet NaNs
* Throws an error or returns a NaN with or without a warning, with a default message
*/
Real getNaN() const { return getNaN("A NaN was produced."); }

/**
* Throws an error or returns NaNs with or without a warning, with a default message
*
* @param[in] n Vector size
*/
std::vector<Real> getNaNVector(const unsigned int & n) const
{
return getNaNVector(n, "A NaN was produced.");
}

/**
* Throws an error or returns a NaN with or without a warning
*/
template <typename... Args>
Real getNaN(Args &&... args) const
{
Expand All @@ -61,4 +74,27 @@ class NaNInterface
// return a quiet NaN
return std::nan("");
}

/**
* Throws an error or returns NaNs with or without a warning
*
* @param[in] n Vector size
*/
template <typename... Args>
std::vector<Real> getNaNVector(const unsigned int & n, Args &&... args) const
{
switch (_emit_on_nan)
{
case (NAN_MESSAGE_WARNING):
mooseWarning(_moose_object->name(), ": ", std::forward<Args>(args)...);
break;
case (NAN_MESSAGE_ERROR):
mooseError(_moose_object->name(), ": ", std::forward<Args>(args)...);
break;
default:
break;
}
// return quiet NaNs
return std::vector<Real>(n, std::nan(""));
}
};

0 comments on commit 64b8d3f

Please sign in to comment.