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

References export_Field(), and export_Module().

◆ export_Field()

void export_Field ( )

Definition at line 221 of file Field.cpp.

222{
223 py::class_<Field, std::shared_ptr<Field>>("Field", py::no_init)
224 .def("__init__",
225 py::make_constructor(
226 &Field_Init, py::default_call_policies(),
227 (py::arg("argv") = py::list(), py::arg("nparts") = 0,
228 py::arg("output_points") = 0,
229 py::arg("output_points_hom_z") = 0, py::arg("error") = false,
230 py::arg("force_output") = false,
231 py::arg("no_equispaced") = false, py::arg("npz") = 0,
232 py::arg("onlyshape") = "", py::arg("part_only") = 0,
233 py::arg("part_only_overlapping") = 0,
234 py::arg("use_session_variables") = false,
235 py::arg("use_session_expansion") = false,
236 py::arg("verbose") = false, py::arg("domain") = "")))
237
238 .def("GetPts", &Field_GetPts)
239 .def("SetPts", &Field_SetPts)
240 .def("ClearField", &Field::ClearField)
241 .def("NewPartition", &NewPartition)
242 .def("ReadFieldDefs", &Field::ReadFieldDefs)
243
244 .def("SetupFromExpList", Field_SetupFromExpList)
245
246 .def_readwrite("graph", &Field::m_graph)
247 .def_readwrite("session", &Field::m_session)
248 .def_readwrite("verbose", &Field::m_verbose)
249 .def_readwrite("comm", &Field::m_comm);
250}
void Field_SetupFromExpList(FieldSharedPtr f, py::list &explists)
Definition: Field.cpp:214
void NewPartition(FieldSharedPtr f, py::list &py_argv, int part)
Definition: Field.cpp:47
void Field_SetPts(FieldSharedPtr f, const int i, const Array< OneD, const NekDouble > &inarray)
Definition: Field.cpp:189
const Array< OneD, const NekDouble > Field_GetPts(FieldSharedPtr f, const int i)
Definition: Field.cpp:179
FieldSharedPtr Field_Init(py::list &argv, int nparts=0, int output_points=0, int output_points_hom_z=0, bool error=false, bool force_output=false, bool no_equispaced=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, std::string domain="")
Definition: Field.cpp:63

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

Referenced by BOOST_PYTHON_MODULE().

◆ export_Module()

void export_Module ( )

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

438{
439 // Export ModuleType enum.
441
442#ifdef NEKTAR_USING_VTK
443 VTK_PYTHON_CONVERSION(vtkUnstructuredGrid);
444#endif
445
446 // Define ModuleWrap to be implicitly convertible to a Module, since it
447 // seems that doesn't sometimes get picked up.
448 py::implicitly_convertible<std::shared_ptr<ModuleWrap<Module>>,
449 std::shared_ptr<Module>>();
450 py::implicitly_convertible<std::shared_ptr<ModuleWrap<InputModule>>,
451 std::shared_ptr<Module>>();
452 py::implicitly_convertible<std::shared_ptr<ModuleWrap<OutputModule>>,
453 std::shared_ptr<Module>>();
454 py::implicitly_convertible<std::shared_ptr<ModuleWrap<ProcessModule>>,
455 std::shared_ptr<Module>>();
456
457 // Wrapper for the Module class. Note that since Module contains a pure
458 // virtual function, we need the ModuleWrap helper class to handle this for
459 // us. In the lightweight wrappers above, we therefore need to ensure we're
460 // passing std::shared_ptr<Module> as the first argument, otherwise they
461 // won't accept objects constructed from Python.
462 py::class_<ModuleWrap<Module>, std::shared_ptr<ModuleWrap<Module>>,
463 boost::noncopyable>("Module", py::init<FieldSharedPtr>())
464
465 // Process function for this module.
466 .def("Process", py::pure_virtual(&Module_Process))
467 .def("Run", py::pure_virtual(&Module_Process))
468
469 // Configuration options.
470 .def("RegisterConfig", Module_RegisterConfig,
471 (py::arg("key"), py::arg("value") = ""))
472 .def("PrintConfig", &Module::PrintConfig)
473 .def("SetDefaults", &Module::SetDefaults)
474 .def("GetStringConfig", Module_GetConfig<std::string>)
475 .def("GetFloatConfig", Module_GetConfig<double>)
476 .def("GetIntConfig", Module_GetConfig<int>)
477 .def("GetBoolConfig", Module_GetConfig<bool>)
478 .def("AddConfigOption", ModuleWrap_AddConfigOption<Module>,
479 (py::arg("key"), py::arg("defValue"), py::arg("desc"),
480 py::arg("isBool") = false))
481 .def("GetVtkGrid", Module_GetVtkGrid,
482 py::return_value_policy<py::return_by_value>())
483
484 // Allow direct access to field object through a property.
485 .def_readwrite("field", &ModuleWrap<Module>::m_f)
486
487 // Factory functions.
488 .def("Register", &Module_Register)
489 .staticmethod("Register");
490
492
493 PythonModuleClass<InputModule>("InputModule");
494 PythonModuleClass<ProcessModule>("ProcessModule");
495 PythonModuleClass<OutputModule>("OutputModule");
496}
#define NEKPY_WRAP_ENUM_STRING(ENUMNAME, MAPNAME)
Definition: NekPyConfig.hpp:80
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...
void Module_GetVtkGrid(std::shared_ptr< Module > mod)
#define VTK_PYTHON_CONVERSION(type)
Definition: VtkWrapper.hpp:145
const std::string ModuleTypeMap[]
Definition: Module.h:72
Module wrapper to handle virtual function calls in Module and its subclasses as defined by the templa...

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

Referenced by BOOST_PYTHON_MODULE().