Nektar++
Functions
SolverUtils.cpp File Reference
#include <LibUtilities/Python/NekPyConfig.hpp>

Go to the source code of this file.

Functions

void export_EquationSystem ()
 
void export_Filter ()
 
void export_SessionFunction ()
 
void export_UnsteadySystem ()
 
 BOOST_PYTHON_MODULE (_SolverUtils)
 

Function Documentation

◆ BOOST_PYTHON_MODULE()

BOOST_PYTHON_MODULE ( _SolverUtils  )

Definition at line 42 of file SolverUtils.cpp.

43{
44 np::initialize();
45
50}
void export_Filter()
void export_EquationSystem()
void export_UnsteadySystem()
void export_SessionFunction()

References export_EquationSystem(), export_Filter(), export_SessionFunction(), and export_UnsteadySystem().

◆ export_EquationSystem()

void export_EquationSystem ( )

Definition at line 149 of file Python/EquationSystem.cpp.

150{
151 using EqSysWrap = EquationSystemWrap<EquationSystem>;
152
155
156 py::class_<EqSysWrap, std::shared_ptr<EqSysWrap>, boost::noncopyable>(
157 "EquationSystem", py::init<LibUtilities::SessionReaderSharedPtr,
159
160 // Virtual functions that can be optionally overridden
161 .def("InitObject", &EquationSystem::InitObject,
162 &EqSysWrap::Default_v_InitObject)
163 .def("DoInitialise", &EquationSystem::DoInitialise,
164 &EqSysWrap::Default_v_DoInitialise)
165 .def("DoSolve", &EquationSystem::DoSolve, &EqSysWrap::Default_v_DoSolve)
166 .def("SetInitialConditions", &EquationSystem::SetInitialConditions,
167 &EqSysWrap::Default_v_SetInitialConditions)
168 .def("EvaluateExactSolution", &EqSysWrap::v_EvaluateExactSolution,
169 &EqSysWrap::Default_v_EvaluateExactSolution)
170 .def("LinfError", &EqSysWrap::v_LinfError,
171 &EqSysWrap::Default_v_LinfError)
172 .def("L2Error", &EqSysWrap::v_L2Error, &EqSysWrap::Default_v_L2Error)
173
174 // Fields accessors (read-only)
175 .def("GetFields", &EquationSystem_GetFields)
176 .add_property("fields", &EquationSystem_GetFields)
177
178 // Various utility functions
179 .def("GetNvariables", &EquationSystem::GetNvariables)
180 .def("GetVariable", &EquationSystem::GetVariable)
181 .def("GetNpoints", &EquationSystem::GetNpoints)
182 .def("SetInitialStep", &EquationSystem::SetInitialStep)
183 .def("ZeroPhysFields", &EquationSystem::ZeroPhysFields)
184
185 // Time accessors/properties
186 .def("GetTime", &EquationSystem::GetTime)
187 .def("SetTime", &EquationSystem::SetTime)
188 .add_property("time", &EquationSystem::GetTime,
189 &EquationSystem::SetTime)
190
191 // Timestep accessors/properties
192 .def("GetTimeStep", &EquationSystem::GetTimeStep)
193 .def("SetTimeStep", &EquationSystem::SetTimeStep)
194 .add_property("timestep", &EquationSystem::GetTimeStep,
195 &EquationSystem::SetTimeStep)
196
197 // Steps accessors/properties
198 .def("GetSteps", &EquationSystem::GetSteps)
199 .def("SetSteps", &EquationSystem::SetSteps)
200 .add_property("steps", &EquationSystem::GetSteps,
201 &EquationSystem::SetSteps)
202
203 // Print a summary
204 .def("PrintSummary", &EquationSystem_PrintSummary)
205
206 // Access functions from the session file
207 .def("GetFunction", &EquationSystem_GetFunction1)
208 .def("GetFunction", &EquationSystem_GetFunction2)
209
210 // I/O utility functions
211 .def("WriteFld", &EquationSystem_WriteFld)
212 .def("Checkpoint_Output", &EquationSystem_Checkpoint_Output)
213
214 // Factory functions.
215 .def("Create", &EquationSystem_Create)
216 .staticmethod("Create")
217 .def("Register", [](std::string const &filterName,
218 py::object &obj) { fac(filterName, obj); })
219 .staticmethod("Register");
220
222}
void EquationSystem_Checkpoint_Output(EquationSystemSharedPtr eqSys, int n)
std::shared_ptr< SessionFunction > EquationSystem_GetFunction1(EquationSystemSharedPtr eqSys, std::string name)
void EquationSystem_WriteFld(EquationSystemSharedPtr eqSys, std::string name)
EquationSystemSharedPtr EquationSystem_Create(std::string eqnSysName, LibUtilities::SessionReaderSharedPtr session, SpatialDomains::MeshGraphSharedPtr mesh)
Array< OneD, MultiRegions::ExpListSharedPtr > EquationSystem_GetFields(EquationSystemSharedPtr eqSys)
void EquationSystem_PrintSummary(EquationSystemSharedPtr eqSys)
std::shared_ptr< SessionFunction > EquationSystem_GetFunction2(EquationSystemSharedPtr eqSys, std::string name, MultiRegions::ExpListSharedPtr field)
std::shared_ptr< SessionReader > SessionReaderSharedPtr
EquationSystemFactory & GetEquationSystemFactory()
std::shared_ptr< MeshGraph > MeshGraphSharedPtr
Definition: MeshGraph.h:174
EquationSystem wrapper to handle virtual function calls in EquationSystem and its subclasses.
A helper class that for factory-based classes allows std::shared_ptr<T> as something that boost::pyth...

Referenced by BOOST_PYTHON_MODULE().

◆ export_Filter()

void export_Filter ( )

Definition at line 176 of file Python/Filter.cpp.

177{
179
180 // Define FilterWrap to be implicitly convertible to a Filter, since it
181 // seems that doesn't sometimes get picked up.
182 py::implicitly_convertible<std::shared_ptr<FilterWrap>,
183 std::shared_ptr<Filter>>();
184
185 // Wrapper for the Filter class. Note that since Filter contains a pure
186 // virtual function, we need the FilterWrap helper class to handle this for
187 // us. In the lightweight wrappers above, we therefore need to ensure we're
188 // passing std::shared_ptr<Filter> as the first argument, otherwise they
189 // won't accept objects constructed from Python.
190 py::class_<FilterWrap, std::shared_ptr<FilterWrap>, boost::noncopyable>(
191 "Filter", py::init<LibUtilities::SessionReaderSharedPtr,
193
194 .def("Initialise", &Filter_Initialise)
195 .def("Update", &Filter_Update)
196 .def("Finalise", &Filter_Finalise)
197 .def("IsTimeDependent", &Filter_IsTimeDependent)
198
199 // Factory functions.
200 .def("Create", py::raw_function(Filter_Create))
201 .staticmethod("Create")
202 .def("Register", [](std::string const &filterName,
203 py::object &obj) { fac(filterName, obj); })
204 .staticmethod("Register");
205
207}
FilterSharedPtr Filter_Create(py::tuple args, py::dict kwargs)
Lightweight wrapper for Filter factory creation function.
bool Filter_IsTimeDependent(std::shared_ptr< Filter > filter)
void Filter_Finalise(std::shared_ptr< Filter > filter, Array< OneD, MultiRegions::ExpListSharedPtr > expLists, NekDouble time)
void Filter_Initialise(std::shared_ptr< Filter > filter, Array< OneD, MultiRegions::ExpListSharedPtr > expLists, NekDouble time)
void Filter_Update(std::shared_ptr< Filter > filter, Array< OneD, MultiRegions::ExpListSharedPtr > expLists, NekDouble time)
std::shared_ptr< EquationSystem > EquationSystemSharedPtr
A shared pointer to an EquationSystem object.
FilterFactory & GetFilterFactory()

References Filter_Create(), Filter_Finalise(), Filter_Initialise(), Filter_IsTimeDependent(), Filter_Update(), and Nektar::SolverUtils::GetFilterFactory().

Referenced by BOOST_PYTHON_MODULE().

◆ export_SessionFunction()

void export_SessionFunction ( )

Definition at line 92 of file Python/SessionFunction.cpp.

93{
94 py::class_<SessionFunction, std::shared_ptr<SessionFunction>,
95 boost::noncopyable>("SessionFunction", py::no_init)
96 .def("__init__", &SessionFunction_Init)
97 .def("Describe", &SessionFunction_Describe)
98 .def("Evaluate", &SessionFunction_Evaluate)
99 .def("Evaluate", &SessionFunction_Evaluate1);
100}
std::string SessionFunction_Describe(std::shared_ptr< SessionFunction > func, std::string fieldName)
Array< OneD, MultiRegions::ExpListSharedPtr > SessionFunction_Evaluate1(std::shared_ptr< SessionFunction > func, py::list fieldNames, Array< OneD, MultiRegions::ExpListSharedPtr > explists)
std::shared_ptr< SessionFunction > SessionFunction_Init(const LibUtilities::SessionReaderSharedPtr session, const MultiRegions::ExpListSharedPtr field, std::string functionName)
Array< OneD, MultiRegions::ExpListSharedPtr > SessionFunction_Evaluate(std::shared_ptr< SessionFunction > func, py::list fieldNames, Array< OneD, MultiRegions::ExpListSharedPtr > explists, NekDouble time)

References SessionFunction_Describe(), SessionFunction_Evaluate(), SessionFunction_Evaluate1(), and SessionFunction_Init().

Referenced by BOOST_PYTHON_MODULE().

◆ export_UnsteadySystem()

void export_UnsteadySystem ( )

Definition at line 45 of file Python/UnsteadySystem.cpp.

46{
48
49 py::class_<USWrap, std::shared_ptr<USWrap>, py::bases<EquationSystem>,
50 boost::noncopyable>(
51 "UnsteadySystem", py::init<LibUtilities::SessionReaderSharedPtr,
53
54 // Add overrides for this class
55 .def("InitObject", &EquationSystem::InitObject,
56 &USWrap::Default_v_InitObject)
57 .def("DoInitialise", &EquationSystem::DoInitialise,
58 &USWrap::Default_v_DoInitialise)
59 .def("DoSolve", &EquationSystem::DoSolve, &USWrap::Default_v_DoSolve)
60 .def("SetInitialConditions", &EquationSystem::SetInitialConditions,
61 &USWrap::Default_v_SetInitialConditions)
62 .def("EvaluateExactSolution", &USWrap::v_EvaluateExactSolution,
63 &USWrap::Default_v_EvaluateExactSolution)
64 .def("LinfError", &USWrap::v_LinfError, &USWrap::Default_v_LinfError)
65 .def("L2Error", &USWrap::v_L2Error, &USWrap::Default_v_L2Error)
66
67 // Add properties for time integration
68 .add_property(
69 "ode",
70 py::make_function(
71 &UnsteadySystem::GetTimeIntegrationSchemeOperators,
72 py::return_value_policy<py::reference_existing_object>()))
73 .add_property(
74 "int_scheme",
75 py::make_function(
76 &UnsteadySystem::GetTimeIntegrationScheme,
77 py::return_value_policy<py::reference_existing_object>()));
78
80}

Referenced by BOOST_PYTHON_MODULE().