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

Go to the source code of this file.

Functions

void export_Field (py::module &m)
 
void export_Module (py::module &m)
 
 PYBIND11_MODULE (_FieldUtils, m)
 

Function Documentation

◆ export_Field()

void export_Field ( py::module &  m)

Definition at line 196 of file Field.cpp.

197{
198 py::class_<Field, std::shared_ptr<Field>>(m, "Field")
199 .def(py::init<>(&Field_Init), py::arg("argv") = py::list(),
200 py::arg("nparts") = 0, py::arg("output_points") = 0,
201 py::arg("output_points_hom_z") = 0, py::arg("error") = false,
202 py::arg("force_output") = false, py::arg("no_equispaced") = false,
203 py::arg("npz") = 0, py::arg("onlyshape") = "",
204 py::arg("part_only") = 0, py::arg("part_only_overlapping") = 0,
205 py::arg("use_session_variables") = false,
206 py::arg("use_session_expansion") = false,
207 py::arg("verbose") = false, py::arg("domain") = "")
208
209 .def("GetPts", &Field_GetPts)
210 .def("SetPts", &Field_SetPts)
211 .def("ClearField", &Field::ClearField)
212 .def("NewPartition", &NewPartition)
213 .def("ReadFieldDefs", &Field::ReadFieldDefs)
214
215 .def("SetupFromExpList", &Field::SetupFromExpList)
216
217 .def_readwrite("graph", &Field::m_graph)
218 .def_readwrite("session", &Field::m_session)
219 .def_readwrite("verbose", &Field::m_verbose)
220 .def_readwrite("comm", &Field::m_comm);
221}
void NewPartition(FieldSharedPtr f, py::list &py_argv, int part)
Definition: Field.cpp:48
void Field_SetPts(FieldSharedPtr f, const int i, const Array< OneD, const NekDouble > &inarray)
Definition: Field.cpp:190
const Array< OneD, const NekDouble > Field_GetPts(FieldSharedPtr f, const int i)
Definition: Field.cpp:180
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:64

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

Referenced by PYBIND11_MODULE().

◆ export_Module()

void export_Module ( py::module &  m)

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

385{
387
388 // Export ModuleType enum.
390
391 // Wrapper for the Module class. Note that since Module contains a pure
392 // virtual function, we need the ModuleWrap helper class to handle this for
393 // us. In the lightweight wrappers above, we therefore need to ensure we're
394 // passing std::shared_ptr<Module> as the first argument, otherwise they
395 // won't accept objects constructed from Python.
396 py::classh<Module, ModuleWrap<Module>>(m, "Module")
397 .def(py::init<FieldSharedPtr>())
398
399 // Process function for this module.
400 .def("Process", &Module_Process)
401 .def("Run", &Module_Process)
402
403 // Configuration options.
404 .def("RegisterConfig", Module_RegisterConfig, py::arg("key"),
405 py::arg("value") = "")
406 .def("PrintConfig", &Module::PrintConfig)
407 .def("SetDefaults", &Module::SetDefaults)
408 .def("GetStringConfig", Module_GetConfig<std::string>)
409 .def("GetFloatConfig", Module_GetConfig<double>)
410 .def("GetIntConfig", Module_GetConfig<int>)
411 .def("GetBoolConfig", Module_GetConfig<bool>)
412 .def("AddConfigOption", &ModuleWrap_AddConfigOption<Module>,
413 py::arg("key"), py::arg("defValue"), py::arg("desc"),
414 py::arg("isBool") = false)
415 .def("GetVtkGrid", &Module_GetVtkGrid)
416
417 // Allow direct access to field object through a property.
418 .def_readwrite("field", &ModuleWrap<Module>::m_f)
419
420 // Factory functions.
421 .def_static("Register", [](ModuleType const &modType,
422 std::string const &modName,
423 py::object &obj) {
424 ModuleKey key(modType, modName);
425 fac(key, obj, std::string(ModuleTypeMap[modType]) + "_" + modName);
426 });
427
428 PythonModuleClass<InputModule>(m, "InputModule");
429 PythonModuleClass<ProcessModule>(m, "ProcessModule");
430 PythonModuleClass<OutputModule>(m, "OutputModule");
431}
#define NEKPY_WRAP_ENUM_STRING(MOD, ENUMNAME, MAPNAME)
Definition: NekPyConfig.hpp:62
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_GetVtkGrid(std::shared_ptr< Module > mod)
std::pair< ModuleType, std::string > ModuleKey
Definition: Module.h:180
const std::string ModuleTypeMap[]
Definition: Module.h:72
ModuleFactory & GetModuleFactory()
Definition: Module.cpp:47
Module wrapper to handle virtual function calls in Module and its subclasses as defined by the templa...

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

Referenced by PYBIND11_MODULE().

◆ PYBIND11_MODULE()

PYBIND11_MODULE ( _FieldUtils  ,
 
)

Definition at line 40 of file FieldUtils.cpp.

41{
42 export_Field(m);
44}
void export_Field(py::module &m)
Definition: Field.cpp:196
void export_Module(py::module &m)

References export_Field(), and export_Module().