hummingbird
Solving the self-adjoint angular flux transport equation using spectral elements on Cartesian geometry
Loading...
Searching...
No Matches
parsed_volumetric_source.cc
Go to the documentation of this file.
2
3#include <stdexcept>
4
5#include "utils/tinyexpr.h"
6
7namespace hummingbird {
9 : expression_(expression) {}
10
12 const Ordinate& ordinate) {
13 te_parser tep;
14 te_type x{node.x}, y{node.y}, z{node.z}, mu{ordinate.x()};
16 {{"x", &x}, {"y", &y}, {"z", &z}, {"mu", &mu}});
17 auto result = tep.evaluate(expression_);
18 if (tep.success())
19 return result;
20 else
21 throw std::runtime_error("Parse error at " +
22 std::to_string(tep.get_last_error_position()) +
23 ". Error is: " + tep.get_last_error_message());
24}
25} // namespace hummingbird
Defines a solid angle, or ordinate, in spherical geometry.
Definition ordinate.h:15
double x() const
Evaluate the x-direction cosine.
Definition ordinate.cc:32
double EvaluateAtNode(const Node &node, const Ordinate &ordinate) override
Evaluate the parsed expression_ at a node in a particular direction. The expression may reference the...
ParsedVolumetricSource(const std::string expression)
Construct a new Parsed Volumetric Source object.
const std::string expression_
Function expression to be evaluated.
Math formula parser.
Definition tinyexpr.h:382
bool success() const noexcept
Definition tinyexpr.h:540
te_type evaluate()
Evaluates expression passed to compile() previously and returns its result.
void set_variables_and_functions(std::set< te_variable > vars)
Sets the list of custom variables and functions.
Definition tinyexpr.h:579
const std::string & get_last_error_message() const noexcept
Definition tinyexpr.h:566
int64_t get_last_error_position() const noexcept
Definition tinyexpr.h:554
A point in the mesh holding its coordinates, boundary info, and flux solution values.
Definition node.h:26
double x
X-coordinate of the node.
Definition node.h:31
double z
Z-coordinate of the node.
Definition node.h:37
double y
Y-coordinate of the node.
Definition node.h:34
float te_type
Define this to use float instead of double for the parser's data type.
Definition tinyexpr.h:105