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

Go to the source code of this file.

Functions

void export_Field ()
 
void export_Module ()
 
 BOOST_PYTHON_MODULE (_FieldUtils)
 

Function Documentation

◆ BOOST_PYTHON_MODULE()

BOOST_PYTHON_MODULE ( _FieldUtils  )

Definition at line 40 of file FieldUtils.cpp.

41{
42 np::initialize();
45}
void export_Module()
void export_Field()
Definition: Field.cpp:216

References export_Field(), and export_Module().

◆ export_Field()

void export_Field ( )

Definition at line 216 of file Field.cpp.

217{
218 py::class_<Field, std::shared_ptr<Field>>("Field", py::no_init)
219 .def("GetPts", &Field_GetPts)
220 .def("SetPts", &Field_SetPts)
221 .def("ClearField", &Field::ClearField)
222 .def("NewPartition", &NewPartition)
223 .def("__init__",
224 py::make_constructor(
225 &Field_Init, py::default_call_policies(),
226 (py::arg("py_argv"), py::arg("nparts") = 0,
227 py::arg("output_points") = 0,
228 py::arg("output_points_hom_z") = 0, py::arg("error") = false,
229 py::arg("forceoutput") = false, py::arg("domain") = "",
230 py::arg("noequispaced") = false, py::arg("npz") = 0,
231 py::arg("onlyshape") = "", py::arg("part_only") = 0,
232 py::arg("part_only_overlapping") = 0,
233 py::arg("useSessionVariables") = false,
234 py::arg("useSessionExpansion") = false,
235 py::arg("verbose") = false)));
236}
FieldSharedPtr Field_Init(py::list &py_argv, int nparts=0, int output_points=0, int output_points_hom_z=0, bool error=false, bool forceoutput=false, std::string domain="", bool noequispaced=false, int npz=0, std::string onlyshape="", int part_only=0, int part_only_overlapping=0, bool useSessionVariables=false, bool useSessionExpansion=false, bool verbose=false)
Definition: Field.cpp:88
void NewPartition(FieldSharedPtr f, py::list &py_argv, int part)
Definition: Field.cpp:73
void Field_SetPts(FieldSharedPtr f, const int i, const Array< OneD, const NekDouble > &inarray)
Definition: Field.cpp:210
const Array< OneD, const NekDouble > Field_GetPts(FieldSharedPtr f, const int i)
Definition: Field.cpp:200

References Field_GetPts(), Field_Init(), Field_SetPts(), and NewPartition().

Referenced by BOOST_PYTHON_MODULE().

◆ export_Module()

void export_Module ( )

Definition at line 409 of file Python/Module.cpp.

410{
411 // Export ModuleType enum.
413
414 // Define ModuleWrap to be implicitly convertible to a Module, since it
415 // seems that doesn't sometimes get picked up.
416 py::implicitly_convertible<std::shared_ptr<ModuleWrap<Module>>,
417 std::shared_ptr<Module>>();
418 py::implicitly_convertible<std::shared_ptr<ModuleWrap<InputModule>>,
419 std::shared_ptr<Module>>();
420 py::implicitly_convertible<std::shared_ptr<ModuleWrap<OutputModule>>,
421 std::shared_ptr<Module>>();
422 py::implicitly_convertible<std::shared_ptr<ModuleWrap<ProcessModule>>,
423 std::shared_ptr<Module>>();
424
425 // Wrapper for the Module class. Note that since Module contains a pure
426 // virtual function, we need the ModuleWrap helper class to handle this for
427 // us. In the lightweight wrappers above, we therefore need to ensure we're
428 // passing std::shared_ptr<Module> as the first argument, otherwise they
429 // won't accept objects constructed from Python.
430 py::class_<ModuleWrap<Module>, std::shared_ptr<ModuleWrap<Module>>,
431 boost::noncopyable>("Module", py::init<FieldSharedPtr>())
432
433 // Process function for this module.
434 .def("Process", py::pure_virtual(&Module_Process))
435 .def("Run", py::pure_virtual(&Module_Process))
436
437 // Configuration options.
438 .def("RegisterConfig", Module_RegisterConfig,
439 (py::arg("key"), py::arg("value") = ""))
440 .def("PrintConfig", &Module::PrintConfig)
441 .def("SetDefaults", &Module::SetDefaults)
442 .def("GetStringConfig", Module_GetConfig<std::string>)
443 .def("GetFloatConfig", Module_GetConfig<double>)
444 .def("GetIntConfig", Module_GetConfig<int>)
445 .def("GetBoolConfig", Module_GetConfig<bool>)
446 .def("AddConfigOption", ModuleWrap_AddConfigOption<Module>,
447 (py::arg("key"), py::arg("defValue"), py::arg("desc"),
448 py::arg("isBool") = false))
449
450 // Allow direct access to field object through a property.
451 .def_readwrite("field", &ModuleWrap<Module>::m_f)
452
453 // Factory functions.
454 .def("Register", &Module_Register)
455 .staticmethod("Register");
456
458
459 PythonModuleClass<InputModule>("InputModule");
460 PythonModuleClass<ProcessModule>("ProcessModule");
461 PythonModuleClass<OutputModule>("OutputModule");
462}
#define NEKPY_WRAP_ENUM_STRING(ENUMNAME, MAPNAME)
Definition: NekPyConfig.hpp:78
void Module_RegisterConfig(std::shared_ptr< Module > mod, std::string const &key, std::string const &value)
Lightweight wrapper for FieldUtils::Module::RegisterConfig.
void Module_Process(ModuleSharedPtr m)
void Module_Register(ModuleType const &modType, std::string const &modName, py::object &obj)
Lightweight wrapper for the Module factory RegisterCreatorFunction, to support the ability for Python...
const std::string ModuleTypeMap[]
Definition: Module.h:74
Module wrapper to handle virtual function calls in Module and its subclasses as defined by the templa...

References Module_Process(), Module_Register(), Module_RegisterConfig(), Nektar::FieldUtils::ModuleTypeMap, and NEKPY_WRAP_ENUM_STRING.

Referenced by BOOST_PYTHON_MODULE().