From 6edda7ab96ae86c65b1f52d3cee4771a435dfaf6 Mon Sep 17 00:00:00 2001 From: Dilawar Singh Date: Tue, 24 Mar 2020 00:55:13 +0530 Subject: [PATCH] Add a bit more fields. --- pybind11/pymoose.cpp | 18 ++++++++++++++++++ python/moose/__init__.py | 1 + 2 files changed, 19 insertions(+) diff --git a/pybind11/pymoose.cpp b/pybind11/pymoose.cpp index e7d96ce19d..9d4bbef41a 100644 --- a/pybind11/pymoose.cpp +++ b/pybind11/pymoose.cpp @@ -24,6 +24,7 @@ #include "../external/pybind11/include/pybind11/stl.h" #include "../basecode/header.h" +#include "../basecode/global.h" #include "../basecode/Cinfo.h" #include "../shell/Shell.h" @@ -89,8 +90,25 @@ PYBIND11_MODULE(_cmoose, m) .def("findFinfo", &Cinfo::findFinfoWrapper); m.def("create", &createIdFromPath); + + m.def("move", [](Id o, ObjId oid){ getShellPtr()->doMove(o, oid); }); + m.def("copy", [](Id o, ObjId newP, string newName="", size_t n=1, bool toGlobal=false, bool copyExtMsg=false){ + if(newName.empty()) + newName = o.element()->getName(); + getShellPtr()->doCopy(o, newP, newName, n, toGlobal, copyExtMsg); + }); + m.def("setCwe", [](Id id) { getShellPtr()->setCwe(id); }); m.def("getCwe", []() { return getShellPtr()->getCwe(); }); + m.def("delete", [](ObjId oid) { return getShellPtr()->doDelete(oid);}); + m.def("reinit", []() { return getShellPtr()->doReinit();}); + m.def("stop", []() { return getShellPtr()->doStop();}); + + m.def("seed", [](int seed) { return moose::setGlobalSeed(seed);}); + + m.def("start", [](double runtime, bool notify=false) { + getShellPtr()->doStart(runtime, notify); + }); m.def("getCinfo", [](const string& name) { return Cinfo::find(name); }, py::return_value_policy::reference); diff --git a/python/moose/__init__.py b/python/moose/__init__.py index fc383da949..1b79a4f00a 100644 --- a/python/moose/__init__.py +++ b/python/moose/__init__.py @@ -84,6 +84,7 @@ def wildcardFind(pattern): paths.append(__toMooseObject(p)) return paths +from moose._cmoose import * # Bring everything from moose.py to global namespace. # IMP: It will overwrite any c++ function with the same name. We can override