35#ifndef __H__LIMEX__AUX_OUTPUT_OBSERVER_HPP__
36#define __H__LIMEX__AUX_OUTPUT_OBSERVER_HPP__
44template <
typename TData,
typename TDataIn1,
typename TDataIn2>
50 virtual ~LuaFunction2() {};
58 void set_lua_callback(
const char* luaCallback,
size_t numArgs);
61 virtual void operator() (TData& out,
int numArgs1,
int numArgs2,...);
65 std::string m_cbValueName;
78template <
typename TData,
typename TDataIn1,
typename TDataIn2>
79LuaFunction2<TData,TDataIn1,TDataIn2>::LuaFunction2() : m_numArgs(0)
82 m_cbValueRef = LUA_NOREF;
85template <
typename TData,
typename TDataIn1,
typename TDataIn2>
86void LuaFunction2<TData,TDataIn1,TDataIn2>::set_lua_callback(
const char* luaCallback,
size_t numArgs)
89 m_cbValueName = luaCallback;
92 lua_getglobal(m_L, m_cbValueName.c_str());
95 if(lua_isnil(m_L, -1)){
96 UG_THROW(
"LuaFunction::set_lua_callback(...):"
97 "Specified lua callback does not exist: " << m_cbValueName);
101 m_cbValueRef = luaL_ref(m_L, LUA_REGISTRYINDEX);
189template<
class TDomain,
class TAlgebra>
199 { m_spReference = spExactSol; }
208 { m_spReference =
make_sp(
new LuaUserData<number, grid_function_type::dim>(ExactSol)); }
218 UG_LOG(
"L2Error(\t"<< time <<
"\t) = \t" <<
L2Error(m_spReference, uNew,
"c", time, 4) << std::endl);
219 if (m_sp_vtk.valid())
222 Interpolate<grid_function_type> (m_spReference, ref,
"c", time);
223 m_sp_vtk->print(
"MyReference", *ref, step, time);
241template<
class TDomain,
class TAlgebra>
252 IntegralSpecs(
const char* cmp,
const char* subsets,
int quadOrder,
const char *idString) :
253 m_cmp(cmp), m_subsets(subsets), m_quadOrder(quadOrder), m_idString(idString)
252 IntegralSpecs(
const char* cmp,
const char* subsets,
int quadOrder,
const char *idString) : {
…}
272 for (
typename std::vector<IntegralSpecs>::iterator it = m_vIntegralData.begin();
273 it!=m_vIntegralData.end(); ++it)
275 number value=
Integral(uNew, it->m_cmp.c_str(), it->m_subsets.c_str(), it->m_quadOrder);
276 UG_LOG(
"Integral(\t"<< it->m_idString <<
"\t"<< time <<
"\t)=\t" << value << std::endl);
287 m_vIntegralData.push_back(
IntegralSpecs(cmp, subsets, quadOrder, idString));
Integration observer: Output using Lua callback.
Definition aux_output_observer.hpp:244
GridFunction< TDomain, TAlgebra > grid_function_type
Definition aux_output_observer.hpp:247
VTKOutput< TDomain::dim > vtk_type
Definition aux_output_observer.hpp:248
ITimeIntegratorObserver< TDomain, TAlgebra > base_type
Definition aux_output_observer.hpp:246
void add_integral_specs(const char *cmp, const char *subsets, int quadOrder, const char *idString)
Definition aux_output_observer.hpp:285
virtual ~IntegrationOutputObserver()
Definition aux_output_observer.hpp:265
bool step_process(SmartPtr< grid_function_type > uNew, int step, number time, number dt) OVERRIDE
Definition aux_output_observer.hpp:269
IntegrationOutputObserver()
Definition aux_output_observer.hpp:262
std::vector< IntegralSpecs > m_vIntegralData
Definition aux_output_observer.hpp:292
Definition aux_output_observer.hpp:192
SmartPtr< UserData< number, grid_function_type::dim > > m_spReference
Definition aux_output_observer.hpp:233
PlotRefOutputObserver(SmartPtr< UserData< number, grid_function_type::dim > > spExactSol)
Definition aux_output_observer.hpp:198
virtual ~PlotRefOutputObserver()
Definition aux_output_observer.hpp:212
GridFunction< TDomain, TAlgebra > grid_function_type
Definition aux_output_observer.hpp:195
VTKOutput< TDomain::dim > vtk_type
Definition aux_output_observer.hpp:196
ITimeIntegratorObserver< TDomain, TAlgebra > base_type
Definition aux_output_observer.hpp:194
SmartPtr< vtk_type > m_sp_vtk
Definition aux_output_observer.hpp:234
bool step_process(SmartPtr< grid_function_type > uNew, int step, number time, number dt) OVERRIDE
Definition aux_output_observer.hpp:216
const NullSmartPtr SPNULL
struct lua_State lua_State
lua_State * GetDefaultLuaState()
number L2Error(SmartPtr< TGridFunction > spGridFct1, const char *cmp1, SmartPtr< TGridFunction > spGridFct2, const char *cmp2, int quadOrder)
number Integral(number val, SmartPtr< TGridFunction > spGridFct)
SmartPtr< T, FreePolicy > make_sp(T *inst)
Definition aux_output_observer.hpp:251
int m_quadOrder
Definition aux_output_observer.hpp:257
std::string m_subsets
Definition aux_output_observer.hpp:256
std::string m_cmp
Definition aux_output_observer.hpp:255
std::string m_idString
Definition aux_output_observer.hpp:258
IntegralSpecs(const char *cmp, const char *subsets, int quadOrder, const char *idString)
Definition aux_output_observer.hpp:252
#define OVERRIDE
Definition time_integrator.hpp:41