Chi-Tech
lbts_callback.cc
Go to the documentation of this file.
2
3#include "chi_runtime.h"
5
6/**Provides a callback interface to lua after each timestep. Users,
7 * can setup all sorts of controls like adaptive timestepping and
8 * outputs.*/
10{
11 const std::string fname = "lbs::TransientSolver::PostStepCallBackFunction";
12
14
15 auto& L = chi::console.GetConsoleState();
16 const auto& lua_func_name = transient_options_.console_call_back_function;
17
18 //============= Load lua function
19 lua_getglobal(L, lua_func_name.c_str());
20
21 //============= Error check lua function
22 if (not lua_isfunction(L, -1))
23 throw std::logic_error(fname + " attempted to access lua-function, " +
24 lua_func_name + ", but it seems the function"
25 " could not be retrieved.");
26
27 //============= Push arguments
28 //There are no arguments
29
30 //============= Call lua function
31 //0 arguments, 0 result (double), 0=original error object
32 double lua_return;
33 if (lua_pcall(L,0,0,0) == 0)
34 {
35 }
36 else
37 throw std::logic_error(fname + " attempted to call lua-function, " +
38 lua_func_name + ", but the call failed.");
39
40// lua_pop(L,1); //pop the double, or error code
41}
void PostStepCallBackFunction() const
Definition: lbts_callback.cc:9
struct lbs::DiscOrdTransientSolver::Options transient_options_