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:219

References export_Field(), and export_Module().

◆ export_Field()

void export_Field ( )

Definition at line 219 of file Field.cpp.

220 {
221  py::class_<Field, std::shared_ptr<Field>>("Field", py::no_init)
222  .def("GetPts", &Field_GetPts)
223  .def("SetPts", &Field_SetPts)
224  .def("ClearField", &Field::ClearField)
225  .def("NewPartition", &NewPartition)
226  .def("__init__",
227  py::make_constructor(
228  &Field_Init, py::default_call_policies(),
229  (py::arg("py_argv"), py::arg("nparts") = 0,
230  py::arg("output_points") = 0,
231  py::arg("output_points_hom_z") = 0, py::arg("error") = false,
232  py::arg("forceoutput") = false, py::arg("domain") = "",
233  py::arg("noequispaced") = false, py::arg("npz") = 0,
234  py::arg("onlyshape") = "", py::arg("part_only") = 0,
235  py::arg("part_only_overlapping") = 0,
236  py::arg("useSessionVariables") = false,
237  py::arg("useSessionExpansion") = false,
238  py::arg("verbose") = false)));
239 }
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:201
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:211

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 407 of file Python/Module.cpp.

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