Hi! I'm trying to add constant variables to my expressions. Specifically, I have a variable "time" which is the global time of my simulation. I'm using the Variable Blocks approach.
Here's what I tried:
SeExpr2::VarBlockCreator block_creator;
int time_handle = block_creator.registerVariable("time", SeExpr2::ExprType().FP(1).Constant());
int position_handle = block_creator.registerVariable("position", SeExpr2::TypeVec(2));
int output_handle = block_creator.registerVariable("__output", SeExpr2::TypeVec(2));
SeExpr2::Expression expression{expr_string};
expression.setDesiredReturnType(SeExpr2::TypeVec(2));
expression.setVarBlockCreator(&block_creator);
double time = ...;
double* positions = ...;
double* outputs = ...;
SeExpr2::VarBlock block = block_creator.create();
block.Pointer(time_handle) = &time;
block.Pointer(position_handle) = positions;
block.Pointer(output_handle) = outputs;
expression.evalMultiple(&block, output_handle, 0, N);
This code failed, and based on printing out the resulting output data, it looks like the 0th entry is correct, and every subsequent one is wrong. As far as I can tell, when accessing the 'time' variable it is treating it like varying and iterating through memory and getting garbage. If I make the 'time' variable artificially 'Varying' and make an array of the same value, everything works.
What am I doing wrong?
Thanks,
Chris