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 50 of file TimeIntegrationSchemeOperators.cpp.

Constructor & Destructor Documentation

◆ CallbackHolderT1()

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

Default constructor.

Definition at line 53 of file TimeIntegrationSchemeOperators.cpp.

53 : m_cb(cb)
54 {
55 }
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 60 of file TimeIntegrationSchemeOperators.cpp.

63 {
64 py::object ret = m_cb(in, time);
65
66 py::list outList = py::cast<py::list>(ret);
67
68 for (std::size_t i = 0; i < py::len(outList); ++i)
69 {
70 out[i] = py::cast<Array<OneD, NekDouble>>(outList[i]);
71 }
72 }

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 76 of file TimeIntegrationSchemeOperators.cpp.

Referenced by call().