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();
43  export_Field();
44  export_Module();
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
const Array< OneD, const NekDouble > Field_GetPts(FieldSharedPtr f, const int i)
Definition: Field.cpp:200
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

References Nektar::FieldUtils::Field::ClearField(), Field_GetPts(), Field_Init(), Field_SetPts(), and NewPartition().

Referenced by BOOST_PYTHON_MODULE().

◆ export_Module()

void export_Module ( )

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

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

Referenced by BOOST_PYTHON_MODULE().