41#include <boost/python/raw_function.hpp>
61 Interpreter &interpreter = py::extract<Interpreter &>(args[0]);
64 std::map<std::string, NekDouble> constants;
67 py::list keys = kwargs.keys();
68 for (
int i = 0; i < py::len(keys); ++i)
70 py::object arg = kwargs[keys[i]];
73 constants[py::extract<std::string>(keys[i])] =
74 py::extract<NekDouble>(arg);
98 Interpreter &interpreter = py::extract<Interpreter &>(args[0]);
101 std::map<std::string, NekDouble> parameters;
104 py::list keys = kwargs.keys();
105 for (
int i = 0; i < py::len(keys); ++i)
107 py::object arg = kwargs[keys[i]];
110 parameters[py::extract<std::string>(keys[i])] =
111 py::extract<NekDouble>(arg);
127 std::string paramName)
130 return interpreter->GetParameter(paramName);
142 std::string constantName)
145 return interpreter->GetConstant(constantName);
159 return interpreter->Evaluate(
id);
179 return interpreter->Evaluate(
id, x, y,
z, t);
197 std::shared_ptr<Interpreter> interpreter,
const int id,
204 interpreter->Evaluate(
id, x, y,
z, t, tmp);
218 std::shared_ptr<Interpreter> interpreter,
const int expression_id,
222 interpreter->Evaluate(expression_id, points, tmp);
228 py::class_<Interpreter, std::shared_ptr<Interpreter>, boost::noncopyable>(
229 "Interpreter", py::init<>())
231 .def(
"SetRandomSeed", &Interpreter::SetRandomSeed)
234 .def(
"AddConstant", &Interpreter::AddConstant)
238 .def(
"SetParameter", &Interpreter::SetParameter)
241 .def(
"GetTime", &Interpreter::GetTime)
242 .def(
"DefineFunction", &Interpreter::DefineFunction)
NekDouble Interpreter_Evaluate2(std::shared_ptr< Interpreter > interpreter, const int id, const NekDouble x, const NekDouble y, const NekDouble z, const NekDouble t)
Wrapper for Interpreter::Evaluate (only constant parameters).
Array< OneD, NekDouble > Interpreter_Evaluate4(std::shared_ptr< Interpreter > interpreter, const int expression_id, const std::vector< Array< OneD, const NekDouble > > &points)
Wrapper for Interpreter::Evaluate (zero or more arrays).
void export_Interpreter()
NekDouble Interpreter_Evaluate(std::shared_ptr< Interpreter > interpreter, const int id)
Wrapper for Interpreter::Evaluate (only constant or parameter).
NekDouble Interpreter_GetParameter(std::shared_ptr< Interpreter > interpreter, std::string paramName)
Wrapper for Interpreter::GetParameter.
py::object Interpreter_SetParameters(py::tuple args, py::dict kwargs)
Wrapper for Interpreter::SetParameters.
Array< OneD, NekDouble > Interpreter_Evaluate3(std::shared_ptr< Interpreter > interpreter, const int id, const Array< OneD, const NekDouble > &x, const Array< OneD, const NekDouble > &y, const Array< OneD, const NekDouble > &z, const Array< OneD, const NekDouble > &t)
Wrapper for Interpreter::Evaluate (vectorised version of the evaluation method that will allow the sa...
NekDouble Interpreter_GetConstant(std::shared_ptr< Interpreter > interpreter, std::string constantName)
Wrapper for Interpreter::GetConstant.
py::object Interpreter_AddConstants(py::tuple args, py::dict kwargs)
Wrapper for Interpreter::AddConstants.
Interpreter class for the evaluation of mathematical expressions.
void AddConstants(std::map< std::string, NekDouble > const &constants)
Set constants to be evaluated.
void SetParameters(std::map< std::string, NekDouble > const ¶ms)
Set parameter values.
std::vector< double > z(NPUPPER)