Nektar++
Public Member Functions | Private Attributes | List of all members
CallbackHolderT1 Struct Reference

Helper class for holding a reference to a Python function to act as a wrapper for TimeIntegrationScheme::FunctorType1. More...

Public Member Functions

 CallbackHolderT1 (py::object cb)
 Default constructor. More...
 
void call (TimeIntegrationSchemeOperators::InArrayType &in, TimeIntegrationSchemeOperators::OutArrayType &out, const NekDouble time)
 C++ callback function to invoke Python function stored in m_cb. More...
 

Private Attributes

py::object m_cb
 Callback defined in Python code. More...
 

Detailed Description

Helper class for holding a reference to a Python function to act as a wrapper for TimeIntegrationScheme::FunctorType1.

This wrapper is used for TimeIntegrationSchemeOperators::DefineOdeRhs and TimeIntegrationSchemeOperators::DefineProjection.

Definition at line 63 of file TimeIntegrationSchemeOperators.cpp.

Constructor & Destructor Documentation

◆ CallbackHolderT1()

CallbackHolderT1::CallbackHolderT1 ( py::object  cb)
inline

Default constructor.

Definition at line 66 of file TimeIntegrationSchemeOperators.cpp.

66 : m_cb(cb)
67 {
68 }
py::object m_cb
Callback defined in Python code.

Member Function Documentation

◆ call()

void CallbackHolderT1::call ( TimeIntegrationSchemeOperators::InArrayType in,
TimeIntegrationSchemeOperators::OutArrayType out,
const NekDouble  time 
)
inline

C++ callback function to invoke Python function stored in m_cb.

Definition at line 73 of file TimeIntegrationSchemeOperators.cpp.

76 {
77 py::object ret = m_cb(in, time);
78
79 py::list outList = py::extract<py::list>(ret);
80
81 for (std::size_t i = 0; i < py::len(outList); ++i)
82 {
83 out[i] = py::extract<Array<OneD, NekDouble>>(outList[i]);
84 }
85 }

References m_cb.

Referenced by TimeIntegrationSchemeOperators_DefineOdeRhs(), and TimeIntegrationSchemeOperators_DefineProjection().

Member Data Documentation

◆ m_cb

py::object CallbackHolderT1::m_cb
private

Callback defined in Python code.

Definition at line 89 of file TimeIntegrationSchemeOperators.cpp.

Referenced by call().