#include <Parser.h>
|
virtual std::string | eval (hit::Field *n, const std::list< std::string > &args, hit::BraceExpander &exp) |
|
Definition at line 29 of file Parser.h.
◆ eval()
std::string UnitsConversionEvaler::eval |
( |
hit::Field * |
n, |
|
|
const std::list< std::string > & |
args, |
|
|
hit::BraceExpander & |
exp |
|
) |
| |
|
virtual |
Definition at line 83 of file Parser.C.
87 std::vector<std::string> argv;
88 argv.insert(argv.begin(), args.begin(), args.end());
93 n->setVal(n->val(), hit::Field::Kind::Float);
98 if (argv.size() != 4 || (argv.size() >= 3 && argv[2] !=
"->"))
100 exp.errors.emplace_back(
"units error: Expected 4 arguments ${units number from_unit -> " 101 "to_unit} or 2 arguments ${units number unit} in '" +
110 if (!from_unit.conformsTo(to_unit))
112 std::ostringstream
err;
113 err <<
"units error: " << argv[1] <<
" (" << from_unit <<
") does not convert to " << argv[3]
114 <<
" (" << to_unit <<
") in '" << n->fullpath() <<
"'";
115 exp.errors.emplace_back(
err.str(), n);
120 Real num = MooseUtils::convert<Real>(argv[0]);
123 std::stringstream ss;
124 ss << std::setprecision(17) << to_unit.convert(num, from_unit);
139 n->setVal(n->val(), hit::Field::Kind::Float);
void mooseInfoRepeated(Args &&... args)
Emit an informational message with the given stringified, concatenated args.
std::string stringify(const T &t)
conversion to string
Physical unit management class with runtime unit string parsing, unit checking, unit conversion...
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
The documentation for this class was generated from the following files: