Skip to content

Commit 07a1348

Browse files
author
Dilawar Singh
committed
This is for tomorow.
1 parent 72f7b62 commit 07a1348

File tree

7 files changed

+19
-22
lines changed

7 files changed

+19
-22
lines changed

.gitlab-ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ build:
2222
- python3 -c "import moose; moose.test()"
2323

2424
except:
25-
- pybind11
25+
- pybind11*
2626
- devel
2727
- temp
2828

basecode/Conv.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,13 +96,13 @@ template< class T > class Conv
9696
return "float";
9797
if ( typeid( T ) == typeid( double ) )
9898
return "double";
99-
if ( typeid( T ) == typeid( Id ) )
99+
if ( typeid( T ) == typeid(Id))
100100
return "Id";
101-
if ( typeid( T ) == typeid( ObjId ) )
101+
if ( typeid( T ) == typeid(ObjId))
102102
return "ObjId";
103-
if ( typeid( T ) == typeid( vector<double> ) )
103+
if ( typeid( T ) == typeid(vector<double>))
104104
return "vector<double>";
105-
if ( typeid( T ) == typeid( vector<Variable> ) )
105+
if ( typeid( T ) == typeid(Variable))
106106
return "Variable";
107107
return typeid( T ).name(); // this is not portable but may be more useful than "bad"
108108
}

builtins/Function.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ const Cinfo * Function::initCinfo()
197197
"x",
198198
"Input variables (indexed) to the function. These can be passed via messages.",
199199
Variable::initCinfo(),
200-
&Function::getVar,
200+
&Function::getX,
201201
&Function::setNumVar,
202202
&Function::getNumVar
203203
);
@@ -716,7 +716,7 @@ void Function::setVar(unsigned int index, double value)
716716
MOOSE_WARN("Function: index " << index << " out of bounds.");
717717
}
718718

719-
Variable* Function::getVar(unsigned int ii)
719+
Variable* Function::getX(unsigned int ii)
720720
{
721721
static Variable dummy("DUMMY");
722722
if(ii >= xs_.size())

builtins/Function.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class Function
4646
// get/set the value of variable `name`
4747
void setVar(unsigned int index, double value);
4848

49-
Variable* getVar(unsigned int ii);
49+
Variable* getX(unsigned int ii);
5050

5151
// get function eval result
5252
double getValue() const;

pybind11/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ if(APPLE)
2424
"-Wl,-all_load"
2525
${MOOSE_LIBRARIES}
2626
${STATIC_LIBRARIES})
27-
target_link_libraries(_cmoose ${SYSTEM_SHARED_LIBS})
27+
target_link_libraries(_cmoose PRIVATE ${SYSTEM_SHARED_LIBS})
2828
else(APPLE)
2929
target_link_libraries(_cmoose PRIVATE
3030
"-Wl,--whole-archive"

pybind11/pymoose.cpp

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
#include "../shell/Shell.h"
3636
#include "../shell/Wildcard.h"
3737
#include "../shell/Neutral.h"
38+
#include "../builtins/Variable.h"
3839

3940
#include "helper.h"
4041
#include "pymoose.h"
@@ -78,6 +79,9 @@ py::object getFieldElement(const ObjId& oid, const string& fname)
7879
+ "'. Available: ", avl);
7980
return pybind11::none();
8081
}
82+
// FIXME: I am here.
83+
Variable res = LookupField<unsigned int, Variable>::get(oid, fname, 0);
84+
return py::cast(res);
8185
}
8286

8387
py::object getFieldGeneric(const ObjId& oid, const string& fname)
@@ -112,7 +116,7 @@ py::object getFieldGeneric(const ObjId& oid, const string& fname)
112116
return py::cast(getProp<Id>(oid, fname));
113117
else if (ftype == "ObjId")
114118
return py::cast(getProp<ObjId>(oid, fname));
115-
else if (ftype == typeid(Variable).name())
119+
else if (ftype == "Variable")
116120
return py::cast(getProp<Variable>(oid, fname));
117121
py::print("pymoose::getFieldGeneric::Warning: Unsupported type " + ftype);
118122
return pybind11::none();
@@ -199,15 +203,9 @@ PYBIND11_MODULE(_cmoose, m)
199203
">";
200204
});
201205

202-
py::class_<FinfoWrapper>(m, "_FinfoWrapper")
203-
.def(py::init<const Finfo*>())
204-
.def_property_readonly("name", &FinfoWrapper::getName)
205-
.def_property_readonly("doc", &FinfoWrapper::docs)
206-
.def_property_readonly("type", &FinfoWrapper::type)
207-
.def_property_readonly("src", &FinfoWrapper::src,
208-
py::return_value_policy::reference)
209-
.def_property_readonly("dest", &FinfoWrapper::dest,
210-
py::return_value_policy::reference);
206+
py::class_<Variable>(m, "_Variable")
207+
.def(py::init<>())
208+
;
211209

212210
py::class_<Cinfo>(m, "_Cinfo")
213211
.def(py::init<>())

tests/pybind11/test_shell.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,6 @@ def makereac2():
229229
r1.connect("prd", B, "reac")
230230

231231
sum.cobj.setField("numVars", 2)
232-
233232
print('xxx', sum.cobj.getFieldElement('x'))
234233
quit()
235234

@@ -336,8 +335,8 @@ def test_ksolve2():
336335

337336

338337
def main():
339-
test_ksolve0()
340-
test_ksolve1()
338+
#test_ksolve0()
339+
#test_ksolve1()
341340
test_ksolve2()
342341

343342
if __name__ == '__main__':

0 commit comments

Comments
 (0)