101 const auto path = std::filesystem::path(expr);
106 if (std::filesystem::is_regular_file(path))
112 catch (
const std::filesystem::filesystem_error &e)
118 double x = 0,
y = 0,
z = 0, t = 0;
120 std::vector<te_variable> vars = {
121 {
"x", &
x, TE_VARIABLE},
122 {
"y", &
y, TE_VARIABLE},
123 {
"z", &
z, TE_VARIABLE},
124 {
"t", &t, TE_VARIABLE},
125 {
"min", (
const void *)min, TE_FUNCTION2},
126 {
"max", (
const void *)max, TE_FUNCTION2},
127 {
"smoothstep", (
const void *)smoothstep, TE_FUNCTION1},
128 {
"half_smoothstep", (
const void *)half_smoothstep, TE_FUNCTION1},
129 {
"deg2rad", (
const void *)deg2rad, TE_FUNCTION1},
130 {
"rotate_2D_x", (
const void *)rotate_2D_x, TE_FUNCTION3},
131 {
"rotate_2D_y", (
const void *)rotate_2D_y, TE_FUNCTION3},
132 {
"if", (
const void *)iflargerthanzerothenelse, TE_FUNCTION3},
133 {
"compare", (
const void *)compare, TE_FUNCTION2},
134 {
"smooth_abs", (
const void *)smooth_abs, TE_FUNCTION2},
135 {
"sign", (
const void *)sign, TE_FUNCTION1},
139 te_expr *tmp = te_compile(expr.c_str(), vars.data(), vars.size(), &err);
142 logger().error(
"Unable to parse: {}", expr);
143 logger().error(
"Error near here: {0: >{1}}",
"^", err - 1);
253 t = std::round(t * 1000.) / 1000.;
263 logger().error(
"Cannot find dirichlet condition for time step {}.", t);
269 result =
mat_(index);
280 std::vector<te_variable> vars = {
281 {
"x", &
x, TE_VARIABLE},
282 {
"y", &
y, TE_VARIABLE},
283 {
"z", &
z, TE_VARIABLE},
284 {
"t", &t, TE_VARIABLE},
285 {
"min", (
const void *)min, TE_FUNCTION2},
286 {
"max", (
const void *)max, TE_FUNCTION2},
287 {
"smoothstep", (
const void *)smoothstep, TE_FUNCTION1},
288 {
"half_smoothstep", (
const void *)half_smoothstep, TE_FUNCTION1},
289 {
"deg2rad", (
const void *)deg2rad, TE_FUNCTION1},
290 {
"rotate_2D_x", (
const void *)rotate_2D_x, TE_FUNCTION3},
291 {
"rotate_2D_y", (
const void *)rotate_2D_y, TE_FUNCTION3},
292 {
"if", (
const void *)iflargerthanzerothenelse, TE_FUNCTION3},
293 {
"compare", (
const void *)compare, TE_FUNCTION2},
294 {
"smooth_abs", (
const void *)smooth_abs, TE_FUNCTION2},
295 {
"sign", (
const void *)sign, TE_FUNCTION1},
299 te_expr *tmp = te_compile(
expr_.c_str(), vars.data(), vars.size(), &err);
300 assert(tmp !=
nullptr);
301 result = te_eval(tmp);
305 if (!
unit_.base_units().empty())
bool read_matrix(const std::string &path, Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > &mat)
Reads a matrix from a file. Determines the file format based on the path's extension.